@@ -1002,26 +1002,20 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
10021002 /** Is given method reference applicable to type arguments `targs` and argument trees `args`?
10031003 * @param resultType The expected result type of the application
10041004 */
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)
10091007
10101008 /** Is given method reference applicable to type arguments `targs` and argument trees `args` without inferring views?
10111009 * @param resultType The expected result type of the application
10121010 */
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)
10171013
10181014 /** Is given method reference applicable to argument types `args`?
10191015 * @param resultType The expected result type of the application
10201016 */
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)
10251019
10261020 /** Is given type applicable to type arguments `targs` and argument trees `args`,
10271021 * possibly after inserting an `apply`?
@@ -1102,12 +1096,7 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
11021096 case tp2 : MethodType => true // (3a)
11031097 case tp2 : PolyType if tp2.resultType.isInstanceOf [MethodType ] => true // (3a)
11041098 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))
11111100 case _ => // (3b)
11121101 isAsSpecificValueType(tp1, tp2)
11131102 }
@@ -1253,22 +1242,20 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
12531242 * probability of pruning the search. result type comparisons are neither cheap nor
12541243 * do they prune much, on average.
12551244 */
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
12721259 }
12731260
12741261 var found = resolveOverloaded(alts, pt, Nil )(ctx.retractMode(Mode .ImplicitsEnabled ))
0 commit comments