@@ -1002,26 +1002,20 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
1002
1002
/** Is given method reference applicable to type arguments `targs` and argument trees `args`?
1003
1003
* @param resultType The expected result type of the application
1004
1004
*/
1005
- def isApplicable (methRef : TermRef , targs : List [Type ], args : List [Tree ], resultType : Type )(implicit ctx : Context ): Boolean = {
1006
- val nestedContext = ctx.fresh.setExploreTyperState
1007
- new ApplicableToTrees (methRef, targs, args, resultType)(nestedContext).success
1008
- }
1005
+ def isApplicable (methRef : TermRef , targs : List [Type ], args : List [Tree ], resultType : Type )(implicit ctx : Context ): Boolean =
1006
+ ctx.typerState.test(new ApplicableToTrees (methRef, targs, args, resultType).success)
1009
1007
1010
1008
/** Is given method reference applicable to type arguments `targs` and argument trees `args` without inferring views?
1011
1009
* @param resultType The expected result type of the application
1012
1010
*/
1013
- def isDirectlyApplicable (methRef : TermRef , targs : List [Type ], args : List [Tree ], resultType : Type )(implicit ctx : Context ): Boolean = {
1014
- val nestedContext = ctx.fresh.setExploreTyperState
1015
- new ApplicableToTreesDirectly (methRef, targs, args, resultType)(nestedContext).success
1016
- }
1011
+ def isDirectlyApplicable (methRef : TermRef , targs : List [Type ], args : List [Tree ], resultType : Type )(implicit ctx : Context ): Boolean =
1012
+ ctx.typerState.test(new ApplicableToTreesDirectly (methRef, targs, args, resultType).success)
1017
1013
1018
1014
/** Is given method reference applicable to argument types `args`?
1019
1015
* @param resultType The expected result type of the application
1020
1016
*/
1021
- def isApplicable (methRef : TermRef , args : List [Type ], resultType : Type )(implicit ctx : Context ): Boolean = {
1022
- val nestedContext = ctx.fresh.setExploreTyperState
1023
- new ApplicableToTypes (methRef, args, resultType)(nestedContext).success
1024
- }
1017
+ def isApplicable (methRef : TermRef , args : List [Type ], resultType : Type )(implicit ctx : Context ): Boolean =
1018
+ ctx.typerState.test(new ApplicableToTypes (methRef, args, resultType).success)
1025
1019
1026
1020
/** Is given type applicable to type arguments `targs` and argument trees `args`,
1027
1021
* possibly after inserting an `apply`?
@@ -1102,12 +1096,7 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
1102
1096
case tp2 : MethodType => true // (3a)
1103
1097
case tp2 : PolyType if tp2.resultType.isInstanceOf [MethodType ] => true // (3a)
1104
1098
case tp2 : PolyType => // (3b)
1105
- val nestedCtx = ctx.fresh.setExploreTyperState
1106
-
1107
- {
1108
- implicit val ctx = nestedCtx
1109
- isAsSpecificValueType(tp1, constrained(tp2).resultType)
1110
- }
1099
+ ctx.typerState.test(isAsSpecificValueType(tp1, constrained(tp2).resultType))
1111
1100
case _ => // (3b)
1112
1101
isAsSpecificValueType(tp1, tp2)
1113
1102
}
@@ -1253,22 +1242,20 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
1253
1242
* probability of pruning the search. result type comparisons are neither cheap nor
1254
1243
* do they prune much, on average.
1255
1244
*/
1256
- def adaptByResult (chosen : TermRef ) = {
1257
- def nestedCtx = ctx.fresh.setExploreTyperState
1258
- pt match {
1259
- case pt : FunProto if ! resultConforms(chosen, pt.resultType)(nestedCtx) =>
1260
- alts.filter(alt =>
1261
- (alt ne chosen) && resultConforms(alt, pt.resultType)(nestedCtx)) match {
1262
- case Nil => chosen
1263
- case alt2 :: Nil => alt2
1264
- case alts2 =>
1265
- resolveOverloaded(alts2, pt) match {
1266
- case alt2 :: Nil => alt2
1267
- case _ => chosen
1268
- }
1269
- }
1270
- case _ => chosen
1271
- }
1245
+ def adaptByResult (chosen : TermRef ) = pt match {
1246
+ case pt : FunProto if ! ctx.typerState.test(resultConforms(chosen, pt.resultType)) =>
1247
+ val conformingAlts = alts.filter(alt =>
1248
+ (alt ne chosen) && ctx.typerState.test(resultConforms(alt, pt.resultType)))
1249
+ conformingAlts match {
1250
+ case Nil => chosen
1251
+ case alt2 :: Nil => alt2
1252
+ case alts2 =>
1253
+ resolveOverloaded(alts2, pt) match {
1254
+ case alt2 :: Nil => alt2
1255
+ case _ => chosen
1256
+ }
1257
+ }
1258
+ case _ => chosen
1272
1259
}
1273
1260
1274
1261
var found = resolveOverloaded(alts, pt, Nil )(ctx.retractMode(Mode .ImplicitsEnabled ))
0 commit comments