Skip to content

Commit ce8e543

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 f87e9fb commit ce8e543

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
@@ -478,7 +478,7 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
478478
case tp1 @ MethodType(_, formals1) =>
479479
(tp1.signature consistentParams tp2.signature) &&
480480
matchingParams(formals1, formals2, tp1.isJava, tp2.isJava) &&
481-
tp1.isImplicit == tp2.isImplicit && // needed?
481+
(!tp1.isImplicit || tp2.isImplicit) && // non-implicit functions shadow implicit ones
482482
isSubType(tp1.resultType, tp2.resultType.subst(tp2, tp1))
483483
case _ =>
484484
false
@@ -1003,9 +1003,9 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
10031003
case tp1: MethodType =>
10041004
tp2.widen match {
10051005
case tp2: MethodType =>
1006-
tp1.isImplicit == tp2.isImplicit &&
1007-
matchingParams(tp1.paramTypes, tp2.paramTypes, tp1.isJava, tp2.isJava) &&
1008-
matchesType(tp1.resultType, tp2.resultType.subst(tp2, tp1), relaxed)
1006+
// implicitness is ignored when matching
1007+
matchingParams(tp1.paramTypes, tp2.paramTypes, tp1.isJava, tp2.isJava) &&
1008+
matchesType(tp1.resultType, tp2.resultType.subst(tp2, tp1), relaxed)
10091009
case tp2 =>
10101010
relaxed && tp1.paramNames.isEmpty &&
10111011
matchesType(tp1.resultType, tp2, relaxed)

0 commit comments

Comments
 (0)