diff options
author | Martin Odersky <odersky@gmail.com> | 2016-12-03 19:46:24 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-12-17 18:34:27 +0100 |
commit | e6da2137f48ca6019b826be501ac64e452e5fe7e (patch) | |
tree | a0dd9e4dce0cbb59128989422af4e89ff63650a0 /compiler/src | |
parent | aa6d4fd522d9ce1652a1387d28399d43b5924141 (diff) | |
download | dotty-e6da2137f48ca6019b826be501ac64e452e5fe7e.tar.gz dotty-e6da2137f48ca6019b826be501ac64e452e5fe7e.tar.bz2 dotty-e6da2137f48ca6019b826be501ac64e452e5fe7e.zip |
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.
Diffstat (limited to 'compiler/src')
-rw-r--r-- | compiler/src/dotty/tools/dotc/core/TypeComparer.scala | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala index 743220f55..ecda3b538 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala @@ -478,7 +478,7 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling { case tp1 @ MethodType(_, formals1) => (tp1.signature consistentParams tp2.signature) && matchingParams(formals1, formals2, tp1.isJava, tp2.isJava) && - tp1.isImplicit == tp2.isImplicit && // needed? + (!tp1.isImplicit || tp2.isImplicit) && // non-implicit functions shadow implicit ones isSubType(tp1.resultType, tp2.resultType.subst(tp2, tp1)) case _ => false @@ -1003,9 +1003,9 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling { case tp1: MethodType => tp2.widen match { case tp2: MethodType => - tp1.isImplicit == tp2.isImplicit && - matchingParams(tp1.paramTypes, tp2.paramTypes, tp1.isJava, tp2.isJava) && - matchesType(tp1.resultType, tp2.resultType.subst(tp2, tp1), relaxed) + // implicitness is ignored when matching + matchingParams(tp1.paramTypes, tp2.paramTypes, tp1.isJava, tp2.isJava) && + matchesType(tp1.resultType, tp2.resultType.subst(tp2, tp1), relaxed) case tp2 => relaxed && tp1.paramNames.isEmpty && matchesType(tp1.resultType, tp2, relaxed) |