@@ -1180,29 +1180,34 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
1180
1180
* @param resultType The expected result type of the application
1181
1181
*/
1182
1182
def isApplicableType (tp : Type , targs : List [Type ], args : List [Tree ], resultType : Type , keepConstraint : Boolean )(implicit ctx : Context ): Boolean =
1183
- onMethod(tp, isApplicableMethodRef(_, targs, args, resultType, keepConstraint))
1183
+ onMethod(tp, targs.nonEmpty || args.nonEmpty) {
1184
+ isApplicableMethodRef(_, targs, args, resultType, keepConstraint)
1185
+ }
1184
1186
1185
1187
/** Is given type applicable to argument types `args`, possibly after inserting an `apply`?
1186
1188
* @param resultType The expected result type of the application
1187
1189
*/
1188
1190
def isApplicableType (tp : Type , args : List [Type ], resultType : Type )(implicit ctx : Context ): Boolean =
1189
- onMethod(tp, isApplicableMethodRef(_, args, resultType))
1191
+ onMethod(tp, args.nonEmpty) {
1192
+ isApplicableMethodRef(_, args, resultType)
1193
+ }
1190
1194
1191
1195
/** Is given method type applicable to type arguments `targs` and argument trees `args` without inferring views,
1192
1196
* possibly after inserting an `apply`?
1193
1197
* @param resultType The expected result type of the application
1194
1198
*/
1195
1199
def isDirectlyApplicableType (tp : Type , targs : List [Type ], args : List [Tree ], resultType : Type )(implicit ctx : Context ): Boolean =
1196
- onMethod(tp, methRef =>
1197
- ctx.test(implicit ctx => new ApplicableToTreesDirectly (methRef, targs, args, resultType).success))
1200
+ onMethod(tp, targs.nonEmpty || args.nonEmpty) { methRef =>
1201
+ ctx.test(implicit ctx => new ApplicableToTreesDirectly (methRef, targs, args, resultType).success)
1202
+ }
1198
1203
1199
- private def onMethod (tp : Type , p : TermRef => Boolean )(implicit ctx : Context ): Boolean = tp match {
1204
+ private def onMethod (tp : Type , followApply : Boolean )( p : TermRef => Boolean )(implicit ctx : Context ): Boolean = tp match {
1200
1205
case methRef : TermRef if methRef.widenSingleton.isInstanceOf [MethodicType ] =>
1201
1206
p(methRef)
1202
1207
case mt : MethodicType =>
1203
1208
p(mt.narrow)
1204
1209
case _ =>
1205
- tp.member(nme.apply).hasAltWith(d => p(TermRef (tp, nme.apply, d)))
1210
+ followApply && tp.member(nme.apply).hasAltWith(d => p(TermRef (tp, nme.apply, d)))
1206
1211
}
1207
1212
1208
1213
/** Does `tp` have an extension method named `name` with this-argument `argType` and
@@ -1564,7 +1569,7 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
1564
1569
else if (numParams > numArgs + 1 ) hasDefault
1565
1570
else isVarArgs || hasDefault
1566
1571
case tp =>
1567
- numArgs == 0 || onMethod(tp, sizeFits)
1572
+ numArgs == 0 || onMethod(tp, followApply = true )( sizeFits)
1568
1573
}
1569
1574
1570
1575
def narrowBySize (alts : List [TermRef ]): List [TermRef ] =
0 commit comments