Skip to content

Commit 0e954f9

Browse files
committed
Changes for matching and subtyping implicit methods
Implicitness is ignored for matching (otherwise apply in ImplicitFunction could not shadow apply in Function). And explicit trumps implicit in subtyping comparisons.
1 parent 5117a8d commit 0e954f9

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

compiler/src/dotty/tools/dotc/core/TypeComparer.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
473473
case tp1 @ MethodType(_, formals1) =>
474474
(tp1.signature consistentParams tp2.signature) &&
475475
matchingParams(formals1, formals2, tp1.isJava, tp2.isJava) &&
476-
tp1.isImplicit == tp2.isImplicit && // needed?
476+
(!tp1.isImplicit || tp2.isImplicit) && // non-implicit functions shadow implicit ones
477477
isSubType(tp1.resultType, tp2.resultType.subst(tp2, tp1))
478478
case _ =>
479479
false
@@ -998,9 +998,9 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
998998
case tp1: MethodType =>
999999
tp2.widen match {
10001000
case tp2: MethodType =>
1001-
tp1.isImplicit == tp2.isImplicit &&
1002-
matchingParams(tp1.paramTypes, tp2.paramTypes, tp1.isJava, tp2.isJava) &&
1003-
matchesType(tp1.resultType, tp2.resultType.subst(tp2, tp1), relaxed)
1001+
// implicitness is ignored when matching
1002+
matchingParams(tp1.paramTypes, tp2.paramTypes, tp1.isJava, tp2.isJava) &&
1003+
matchesType(tp1.resultType, tp2.resultType.subst(tp2, tp1), relaxed)
10041004
case tp2 =>
10051005
relaxed && tp1.paramNames.isEmpty &&
10061006
matchesType(tp1.resultType, tp2, relaxed)

0 commit comments

Comments
 (0)