diff --git a/compiler/src/dotty/tools/dotc/config/Feature.scala b/compiler/src/dotty/tools/dotc/config/Feature.scala index fed67b380092..09419abd4279 100644 --- a/compiler/src/dotty/tools/dotc/config/Feature.scala +++ b/compiler/src/dotty/tools/dotc/config/Feature.scala @@ -36,7 +36,7 @@ object Feature: val into = experimental("into") val namedTuples = experimental("namedTuples") val modularity = experimental("modularity") - val betterMatchTypeExtractors = experimental("betterMatchTypeExtractors") + val betterMatchTypeExtractors = deprecated("betterMatchTypeExtractors") def experimentalAutoEnableFeatures(using Context): List[TermName] = defn.languageExperimentalFeatures @@ -128,8 +128,6 @@ object Feature: def scala2ExperimentalMacroEnabled(using Context) = enabled(scala2macros) - def betterMatchTypeExtractorsEnabled(using Context) = enabled(betterMatchTypeExtractors) - /** Is pureFunctions enabled for this compilation unit? */ def pureFunsEnabled(using Context) = enabledBySetting(pureFunctions) diff --git a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala index dca8bf206bac..03b394e075ac 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala @@ -10,7 +10,7 @@ import TypeOps.refineUsingParent import collection.mutable import util.{Stats, NoSourcePosition, EqHashMap} import config.Config -import config.Feature.{betterMatchTypeExtractorsEnabled, migrateTo3, sourceVersion} +import config.Feature.{migrateTo3, sourceVersion} import config.Printers.{subtyping, gadts, matchTypes, noPrinter} import config.SourceVersion import TypeErasure.{erasedLub, erasedGlb} @@ -3481,10 +3481,8 @@ class MatchReducer(initctx: Context) extends TypeComparer(initctx) { case MatchTypeCasePattern.TypeMemberExtractor(typeMemberName, capture) => /** Try to remove references to `skolem` from a type in accordance with the spec. * - * If `betterMatchTypeExtractorsEnabled` is enabled then references - * to `skolem` occuring are avoided by following aliases and - * singletons, otherwise no attempt made to avoid references to - * `skolem`. + * References to `skolem` occuring are avoided by following aliases and + * singletons. * * If any reference to `skolem` remains in the result type, * `refersToSkolem` is set to true. @@ -3498,7 +3496,7 @@ class MatchReducer(initctx: Context) extends TypeComparer(initctx) { case `skolem` => refersToSkolem = true tp - case tp: NamedType if betterMatchTypeExtractorsEnabled => + case tp: NamedType => val pre1 = apply(tp.prefix) if refersToSkolem then tp match @@ -3516,7 +3514,7 @@ class MatchReducer(initctx: Context) extends TypeComparer(initctx) { tp.derivedSelect(pre1) else tp.derivedSelect(pre1) - case tp: LazyRef if betterMatchTypeExtractorsEnabled => + case tp: LazyRef => // By default, TypeMap maps LazyRefs lazily. We need to // force it for `refersToSkolem` to be correctly set. apply(tp.ref) diff --git a/library/src/scala/runtime/stdLibPatches/language.scala b/library/src/scala/runtime/stdLibPatches/language.scala index c9343286328d..953e92c34a8b 100644 --- a/library/src/scala/runtime/stdLibPatches/language.scala +++ b/library/src/scala/runtime/stdLibPatches/language.scala @@ -124,6 +124,7 @@ object language: * @see [[https://github.com/scala/improvement-proposals/pull/84]] */ @compileTimeOnly("`betterMatchTypeExtractors` can only be used at compile time in import statements") + @deprecated("The experimental.betterMatchTypeExtractors language import is no longer needed since the feature is now standard", since = "3.6") object betterMatchTypeExtractors end experimental diff --git a/tests/neg/mt-deskolemize-2.scala b/tests/neg/mt-deskolemize-2.scala index 90d506a42e6f..505e47637ac4 100644 --- a/tests/neg/mt-deskolemize-2.scala +++ b/tests/neg/mt-deskolemize-2.scala @@ -1,5 +1,3 @@ -//> using options -language:experimental.betterMatchTypeExtractors - trait Expr: type Value object Expr: diff --git a/tests/pos/20538.scala b/tests/pos/20538.scala new file mode 100644 index 000000000000..a03bf98f6ac3 --- /dev/null +++ b/tests/pos/20538.scala @@ -0,0 +1,32 @@ +trait Column: + type T + type F[X] + type Q = F[T] + +class varchar extends Column: + type T = String + +trait notnull extends Column: + type F[X] = X + +object Error: + + val firstName = new varchar with notnull + val lastName = new varchar with notnull + + val relation = (firstName, lastName) + + type RelationTypes = Tuple.InverseMap[relation.type, [X] =>> Column { type Q = X }] + + summon[RelationTypes =:= (String, String)] + +object Works: + + object firstName extends varchar with notnull + object lastName extends varchar with notnull + + val relation = (firstName, lastName) + + type RelationTypes = Tuple.InverseMap[relation.type, [X] =>> Column { type Q = X }] + + summon[RelationTypes =:= (String, String)] diff --git a/tests/pos/20538b.scala b/tests/pos/20538b.scala new file mode 100644 index 000000000000..d6d176f8a10d --- /dev/null +++ b/tests/pos/20538b.scala @@ -0,0 +1,19 @@ +trait A: + type T + type U = T + +trait B extends A: + type T = String + +object C extends B + + +type F[X] = A { type U = X } // works when `U` is replaced with `T` + +type InvF[Y] = Y match + case F[x] => x + + +object Test: + summon[InvF[C.type] =:= String] // ok + summon[InvF[B] =:= String] // error: selector B does not uniquely determine parameter x diff --git a/tests/pos/mt-deskolemize.scala b/tests/pos/mt-deskolemize.scala index abd61d9d55e6..34f38289b24d 100644 --- a/tests/pos/mt-deskolemize.scala +++ b/tests/pos/mt-deskolemize.scala @@ -1,5 +1,3 @@ -//> using options -language:experimental.betterMatchTypeExtractors - trait Expr: type Value