Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions compiler/src/dotty/tools/dotc/typer/Applications.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2036,15 +2036,25 @@ trait Applications extends Compatibility {
*/
def isAsGood(alt1: TermRef, tp1: Type, alt2: TermRef, tp2: Type): Boolean = trace(i"isAsGood $tp1 $tp2", overload) {
tp1 match

case tp1: MethodType => // (1)
tp1.paramInfos.isEmpty && tp2.isInstanceOf[LambdaType]
|| {
val cond1 = tp1.paramInfos.isEmpty
&& tp2.isInstanceOf[LambdaType]
&& {
// When tp1 is nullary (empty parameter list), it's as good as tp2 only if
// tp2 is not a varargs method (which is less specific than an explicit empty list)
tp2 match
case tp2: MethodType => !tp2.isVarArgsMethod
case _ => true
}
val cond2 = {
if tp1.isVarArgsMethod then
tp2.isVarArgsMethod
&& isApplicableMethodRef(alt2, tp1.paramInfos.map(_.repeatedToSingle), WildcardType, ArgMatch.Compatible)
else
isApplicableMethodRef(alt2, tp1.paramInfos, WildcardType, ArgMatch.Compatible)
}
cond1 || cond2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely would not want to eagerly evaluate the second expression.

case tp1: PolyType => // (2)
inContext(ctx.fresh.setExploreTyperState()) {
// Fully define the PolyType parameters so that the infos of the
Expand Down
Loading