diff options
author | Martin Odersky <odersky@gmail.com> | 2015-09-29 17:33:09 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2015-09-29 19:19:31 +0200 |
commit | 5b07f556ebb1e87d5b5c87c6375fa33c29c9a72d (patch) | |
tree | 01a1f22becd246dc494ef398c7980fcc9f2c16fd /src | |
parent | 9c8e247d8900f3fb6f497bc5e269b68f6bc967b7 (diff) | |
download | dotty-5b07f556ebb1e87d5b5c87c6375fa33c29c9a72d.tar.gz dotty-5b07f556ebb1e87d5b5c87c6375fa33c29c9a72d.tar.bz2 dotty-5b07f556ebb1e87d5b5c87c6375fa33c29c9a72d.zip |
Eliminate Config.newMatch option
With the new approach to matching it is no longer sound.
We always have to match infos anyway to be sure.
Diffstat (limited to 'src')
-rw-r--r-- | src/dotty/tools/dotc/config/Config.scala | 6 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/TypeComparer.scala | 32 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/Types.scala | 9 |
3 files changed, 4 insertions, 43 deletions
diff --git a/src/dotty/tools/dotc/config/Config.scala b/src/dotty/tools/dotc/config/Config.scala index d66d1ecdb..7e3615416 100644 --- a/src/dotty/tools/dotc/config/Config.scala +++ b/src/dotty/tools/dotc/config/Config.scala @@ -76,12 +76,6 @@ object Config { */ final val checkProjections = false - /** When set, use new signature-based matching. - * Advantage of doing so: It's supposed to be faster - * Disadvantage: It might hide inconsistencies, so while debugging it's better to turn it off - */ - final val newMatch = false - /** The recursion depth for showing a summarized string */ final val summarizeDepth = 2 diff --git a/src/dotty/tools/dotc/core/TypeComparer.scala b/src/dotty/tools/dotc/core/TypeComparer.scala index fce803c56..e3e5f3960 100644 --- a/src/dotty/tools/dotc/core/TypeComparer.scala +++ b/src/dotty/tools/dotc/core/TypeComparer.scala @@ -358,8 +358,7 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling { def compareMethod = tp1 match { case tp1 @ MethodType(_, formals1) => (tp1.signature sameParams tp2.signature) && - (if (Config.newMatch) subsumeParams(formals1, formals2, tp1.isJava, tp2.isJava) - else matchingParams(formals1, formals2, tp1.isJava, tp2.isJava)) && + matchingParams(formals1, formals2, tp1.isJava, tp2.isJava) && tp1.isImplicit == tp2.isImplicit && // needed? isSubType(tp1.resultType, tp2.resultType.subst(tp2, tp1)) case _ => @@ -705,21 +704,6 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling { formals2.isEmpty } - private def subsumeParams(formals1: List[Type], formals2: List[Type], isJava1: Boolean, isJava2: Boolean): Boolean = formals1 match { - case formal1 :: rest1 => - formals2 match { - case formal2 :: rest2 => - (isSubType(formal2, formal1) - || isJava1 && (formal2 isRef ObjectClass) && (formal1 isRef AnyClass) - || isJava2 && (formal1 isRef ObjectClass) && (formal2 isRef AnyClass)) && - subsumeParams(rest1, rest2, isJava1, isJava2) - case nil => - false - } - case nil => - formals2.isEmpty - } - /** Do poly types `poly1` and `poly2` have type parameters that * have the same bounds (after renaming one set to the other)? */ @@ -948,13 +932,6 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling { case tp1 @ MethodType(names1, formals1) => tp2 match { case tp2 @ MethodType(names2, formals2) - if Config.newMatch && tp1.signature.sameParams(tp2.signature) && - tp1.isImplicit == tp2.isImplicit => - tp1.derivedMethodType( - mergeNames(names1, names2, nme.syntheticParamName), - (formals1 zipWithConserve formals2)(_ | _), - tp1.resultType & tp2.resultType.subst(tp2, tp1)) - case tp2 @ MethodType(names2, formals2) if matchingParams(formals1, formals2, tp1.isJava, tp2.isJava) && tp1.isImplicit == tp2.isImplicit => tp1.derivedMethodType( @@ -1014,13 +991,6 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling { case tp1 @ MethodType(names1, formals1) => tp2 match { case tp2 @ MethodType(names2, formals2) - if Config.newMatch && tp1.signature.sameParams(tp2.signature) && - tp1.isImplicit == tp2.isImplicit => - tp1.derivedMethodType( - mergeNames(names1, names2, nme.syntheticParamName), - (formals1 zipWithConserve formals2)(_ & _), - tp1.resultType | tp2.resultType.subst(tp2, tp1)) - case tp2 @ MethodType(names2, formals2) if matchingParams(formals1, formals2, tp1.isJava, tp2.isJava) && tp1.isImplicit == tp2.isImplicit => tp1.derivedMethodType( diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala index e545066af..c35b9a35a 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -647,12 +647,9 @@ object Types { * (*) when matching with a Java method, we also regard Any and Object as equivalent * parameter types. */ - def matches(that: Type)(implicit ctx: Context): Boolean = - if (Config.newMatch) this.signature matches that.signature - else track("matches") { - ctx.typeComparer.matchesType( - this, that, relaxed = !ctx.phase.erasedTypes) - } + def matches(that: Type)(implicit ctx: Context): Boolean = track("matches") { + ctx.typeComparer.matchesType(this, that, relaxed = !ctx.phase.erasedTypes) + } /** This is the same as `matches` except that it also matches => T with T and * vice versa. |