@@ -1298,30 +1298,29 @@ trait Implicits:
1298
1298
if alt1.isExtension then
1299
1299
// Fall back: if both results are extension method applications,
1300
1300
// compare the extension methods instead of their wrappers.
1301
- def stripExtension (alt : SearchSuccess ) =
1302
- methPart(stripApply(alt.tree)).tpe: @ unchecked match { case ref : TermRef => ref }
1303
- val ref1 = stripExtension(alt1)
1304
- val ref2 = stripExtension(alt2)
1305
- // ref1 and ref2 might refer to type variables owned by
1306
- // alt1.tstate and alt2.tstate respectively, to compare the
1307
- // alternatives correctly we need a TyperState that includes
1308
- // constraints from both sides, see
1309
- // tests/*/extension-specificity2.scala for test cases.
1310
- val constraintsIn1 = alt1.tstate.constraint ne ctx.typerState.constraint
1311
- val constraintsIn2 = alt2.tstate.constraint ne ctx.typerState.constraint
1312
- def exploreState (alt : SearchSuccess ): TyperState =
1313
- alt.tstate.fresh(committable = false )
1314
- val comparisonState =
1315
- if constraintsIn1 && constraintsIn2 then
1316
- exploreState(alt1).mergeConstraintWith(alt2.tstate)
1317
- else if constraintsIn1 then
1318
- exploreState(alt1)
1319
- else if constraintsIn2 then
1320
- exploreState(alt2)
1321
- else
1322
- ctx.typerState
1323
-
1324
- diff = inContext(ctx.withTyperState(comparisonState)):
1301
+ def stripExtension (alt : SearchSuccess ) = methPart(stripApply(alt.tree)).tpe
1302
+ ((stripExtension(alt1), stripExtension(alt2)) : @ unchecked) match
1303
+ case (ref1 : TermRef , ref2 : TermRef ) =>
1304
+ // ref1 and ref2 might refer to type variables owned by
1305
+ // alt1.tstate and alt2.tstate respectively, to compare the
1306
+ // alternatives correctly we need a TyperState that includes
1307
+ // constraints from both sides, see
1308
+ // tests/*/extension-specificity2.scala for test cases.
1309
+ val constraintsIn1 = alt1.tstate.constraint ne ctx.typerState.constraint
1310
+ val constraintsIn2 = alt2.tstate.constraint ne ctx.typerState.constraint
1311
+ def exploreState (alt : SearchSuccess ): TyperState =
1312
+ alt.tstate.fresh(committable = false )
1313
+ val comparisonState =
1314
+ if constraintsIn1 && constraintsIn2 then
1315
+ exploreState(alt1).mergeConstraintWith(alt2.tstate)
1316
+ else if constraintsIn1 then
1317
+ exploreState(alt1)
1318
+ else if constraintsIn2 then
1319
+ exploreState(alt2)
1320
+ else
1321
+ ctx.typerState
1322
+
1323
+ diff = inContext(ctx.withTyperState(comparisonState)):
1325
1324
compare(ref1, ref2)
1326
1325
else // alt1 is a conversion, prefer extension alt2 over it
1327
1326
diff = - 1
0 commit comments