Skip to content

Commit ccfbf15

Browse files
committed
Drop first pass in narrowByTrees
The two pass approach was originally introduced in 295c981 to lower the priority of implicit conversions, but just a month later in 6253125 a similar two pass approach was used to call resolveOverloaded which itself calls narrowByTrees, rendering the first commit moot. Therefore, we can just remove this first pass and all associated code without affecting anything.
1 parent 675d44f commit ccfbf15

File tree

1 file changed

+11
-22
lines changed

1 file changed

+11
-22
lines changed

compiler/src/dotty/tools/dotc/typer/Applications.scala

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,6 @@ trait Applications extends Compatibility {
614614

615615
/** The degree to which an argument has to match a formal parameter */
616616
enum ArgMatch:
617-
case SubType // argument is a relaxed subtype of formal
618617
case Compatible // argument is compatible with formal
619618
case CompatibleCAP // capture-converted argument is compatible with formal
620619

@@ -639,17 +638,14 @@ trait Applications extends Compatibility {
639638
case SAMType(sam) => argtpe <:< sam.toFunctionType(isJava = formal.classSymbol.is(JavaDefined))
640639
case _ => false
641640
}
642-
if argMatch == ArgMatch.SubType then
643-
argtpe relaxed_<:< formal.widenExpr
644-
else
645-
isCompatible(argtpe, formal)
646-
|| ctx.mode.is(Mode.ImplicitsEnabled) && SAMargOK
647-
|| argMatch == ArgMatch.CompatibleCAP
648-
&& {
649-
val argtpe1 = argtpe.widen
650-
val captured = captureWildcards(argtpe1)
651-
(captured ne argtpe1) && isCompatible(captured, formal.widenExpr)
652-
}
641+
isCompatible(argtpe, formal)
642+
|| ctx.mode.is(Mode.ImplicitsEnabled) && SAMargOK
643+
|| argMatch == ArgMatch.CompatibleCAP
644+
&& {
645+
val argtpe1 = argtpe.widen
646+
val captured = captureWildcards(argtpe1)
647+
(captured ne argtpe1) && isCompatible(captured, formal.widenExpr)
648+
}
653649

654650
/** The type of the given argument */
655651
protected def argType(arg: Arg, formal: Type): Type
@@ -1863,17 +1859,10 @@ trait Applications extends Compatibility {
18631859
else
18641860
alts
18651861

1866-
def narrowByTrees(alts: List[TermRef], args: List[Tree], resultType: Type): List[TermRef] = {
1867-
val alts2 = alts.filterConserve(alt =>
1868-
isApplicableMethodRef(alt, args, resultType, keepConstraint = false, ArgMatch.SubType)
1862+
def narrowByTrees(alts: List[TermRef], args: List[Tree], resultType: Type): List[TermRef] =
1863+
alts.filterConserve(alt =>
1864+
isApplicableMethodRef(alt, args, resultType, keepConstraint = false, ArgMatch.CompatibleCAP)
18691865
)
1870-
if (alts2.isEmpty && !ctx.isAfterTyper)
1871-
alts.filterConserve(alt =>
1872-
isApplicableMethodRef(alt, args, resultType, keepConstraint = false, ArgMatch.CompatibleCAP)
1873-
)
1874-
else
1875-
alts2
1876-
}
18771866

18781867
record("resolveOverloaded.FunProto", alts.length)
18791868
val alts1 = narrowBySize(alts)

0 commit comments

Comments
 (0)