Skip to content

Commit 2cd4590

Browse files
committed
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.
1 parent 9773b4f commit 2cd4590

File tree

3 files changed

+4
-43
lines changed

3 files changed

+4
-43
lines changed

src/dotty/tools/dotc/config/Config.scala

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,6 @@ object Config {
7171
/** If this flag is set, take the fast path when comparing same-named type-aliases and types */
7272
final val fastPathForRefinedSubtype = true
7373

74-
/** When set, use new signature-based matching.
75-
* Advantage of doing so: It's supposed to be faster
76-
* Disadvantage: It might hide inconsistencies, so while debugging it's better to turn it off
77-
*/
78-
final val newMatch = false
79-
8074
/** The recursion depth for showing a summarized string */
8175
final val summarizeDepth = 2
8276

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

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -358,8 +358,7 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
358358
def compareMethod = tp1 match {
359359
case tp1 @ MethodType(_, formals1) =>
360360
(tp1.signature sameParams tp2.signature) &&
361-
(if (Config.newMatch) subsumeParams(formals1, formals2, tp1.isJava, tp2.isJava)
362-
else matchingParams(formals1, formals2, tp1.isJava, tp2.isJava)) &&
361+
matchingParams(formals1, formals2, tp1.isJava, tp2.isJava) &&
363362
tp1.isImplicit == tp2.isImplicit && // needed?
364363
isSubType(tp1.resultType, tp2.resultType.subst(tp2, tp1))
365364
case _ =>
@@ -708,21 +707,6 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
708707
formals2.isEmpty
709708
}
710709

711-
private def subsumeParams(formals1: List[Type], formals2: List[Type], isJava1: Boolean, isJava2: Boolean): Boolean = formals1 match {
712-
case formal1 :: rest1 =>
713-
formals2 match {
714-
case formal2 :: rest2 =>
715-
(isSubType(formal2, formal1)
716-
|| isJava1 && (formal2 isRef ObjectClass) && (formal1 isRef AnyClass)
717-
|| isJava2 && (formal1 isRef ObjectClass) && (formal2 isRef AnyClass)) &&
718-
subsumeParams(rest1, rest2, isJava1, isJava2)
719-
case nil =>
720-
false
721-
}
722-
case nil =>
723-
formals2.isEmpty
724-
}
725-
726710
/** Do poly types `poly1` and `poly2` have type parameters that
727711
* have the same bounds (after renaming one set to the other)?
728712
*/
@@ -951,13 +935,6 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
951935
case tp1 @ MethodType(names1, formals1) =>
952936
tp2 match {
953937
case tp2 @ MethodType(names2, formals2)
954-
if Config.newMatch && tp1.signature.sameParams(tp2.signature) &&
955-
tp1.isImplicit == tp2.isImplicit =>
956-
tp1.derivedMethodType(
957-
mergeNames(names1, names2, nme.syntheticParamName),
958-
(formals1 zipWithConserve formals2)(_ | _),
959-
tp1.resultType & tp2.resultType.subst(tp2, tp1))
960-
case tp2 @ MethodType(names2, formals2)
961938
if matchingParams(formals1, formals2, tp1.isJava, tp2.isJava) &&
962939
tp1.isImplicit == tp2.isImplicit =>
963940
tp1.derivedMethodType(
@@ -1017,13 +994,6 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
1017994
case tp1 @ MethodType(names1, formals1) =>
1018995
tp2 match {
1019996
case tp2 @ MethodType(names2, formals2)
1020-
if Config.newMatch && tp1.signature.sameParams(tp2.signature) &&
1021-
tp1.isImplicit == tp2.isImplicit =>
1022-
tp1.derivedMethodType(
1023-
mergeNames(names1, names2, nme.syntheticParamName),
1024-
(formals1 zipWithConserve formals2)(_ & _),
1025-
tp1.resultType | tp2.resultType.subst(tp2, tp1))
1026-
case tp2 @ MethodType(names2, formals2)
1027997
if matchingParams(formals1, formals2, tp1.isJava, tp2.isJava) &&
1028998
tp1.isImplicit == tp2.isImplicit =>
1029999
tp1.derivedMethodType(

src/dotty/tools/dotc/core/Types.scala

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -647,12 +647,9 @@ object Types {
647647
* (*) when matching with a Java method, we also regard Any and Object as equivalent
648648
* parameter types.
649649
*/
650-
def matches(that: Type)(implicit ctx: Context): Boolean =
651-
if (Config.newMatch) this.signature matches that.signature
652-
else track("matches") {
653-
ctx.typeComparer.matchesType(
654-
this, that, relaxed = !ctx.phase.erasedTypes)
655-
}
650+
def matches(that: Type)(implicit ctx: Context): Boolean = track("matches") {
651+
ctx.typeComparer.matchesType(this, that, relaxed = !ctx.phase.erasedTypes)
652+
}
656653

657654
/** This is the same as `matches` except that it also matches => T with T and
658655
* vice versa.

0 commit comments

Comments
 (0)