Skip to content

Commit 4b09b13

Browse files
authored
Deprecate Yno-kind-polymorphism (#22814)
Fixes #22029.
1 parent 744ba92 commit 4b09b13

File tree

5 files changed

+9
-10
lines changed

5 files changed

+9
-10
lines changed

compiler/src/dotty/tools/dotc/config/ScalaSettings.scala

+2-1
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,8 @@ private sealed trait YSettings:
443443
val YwithBestEffortTasty: Setting[Boolean] = BooleanSetting(ForkSetting, "Ywith-best-effort-tasty", "Allow to compile using best-effort tasty files. If such file is used, the compiler will stop after the pickler phase.")
444444

445445
// Experimental language features
446-
val YnoKindPolymorphism: Setting[Boolean] = BooleanSetting(ForkSetting, "Yno-kind-polymorphism", "Disable kind polymorphism.")
446+
@deprecated(message = "This flag has no effect and will be removed in a future version.", since = "3.7.0")
447+
val YnoKindPolymorphism: Setting[Boolean] = BooleanSetting(ForkSetting, "Yno-kind-polymorphism", "Disable kind polymorphism. (This flag has no effect)", deprecation = Deprecation.removed())
447448
val YexplicitNulls: Setting[Boolean] = BooleanSetting(ForkSetting, "Yexplicit-nulls", "Make reference types non-nullable. Nullable types can be expressed with unions: e.g. String|Null.")
448449
val YnoFlexibleTypes: Setting[Boolean] = BooleanSetting(ForkSetting, "Yno-flexible-types", "Disable turning nullable Java return types and parameter types into flexible types, which behave like abstract types with a nullable lower bound and non-nullable upper bound.")
449450
val YcheckInitGlobal: Setting[Boolean] = BooleanSetting(ForkSetting, "Ysafe-init-global", "Check safe initialization of global objects.")

compiler/src/dotty/tools/dotc/core/Definitions.scala

+1-4
Original file line numberDiff line numberDiff line change
@@ -449,10 +449,7 @@ class Definitions {
449449

450450
@tu lazy val AnyKindClass: ClassSymbol = {
451451
val cls = newCompleteClassSymbol(ScalaPackageClass, tpnme.AnyKind, AbstractFinal | Permanent, Nil, newScope(0))
452-
if (!ctx.settings.YnoKindPolymorphism.value)
453-
// Enable kind-polymorphism by exposing scala.AnyKind
454-
cls.entered
455-
cls
452+
cls.entered
456453
}
457454
def AnyKindType: TypeRef = AnyKindClass.typeRef
458455

docs/_docs/reference/other-new-features/kind-polymorphism.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,4 @@ It is declared `abstract` and `final`, so it can be neither instantiated nor ext
4343

4444
`AnyKind` plays a special role in Scala's subtype system: It is a supertype of all other types no matter what their kind is. It is also assumed to be kind-compatible with all other types. Furthermore, `AnyKind` is treated as a higher-kinded type (so it cannot be used as a type of values), but at the same time it has no type parameters (so it cannot be instantiated).
4545

46-
**Note:** This feature is considered experimental but stable and it can be disabled under compiler flag
47-
(i.e. `-Yno-kind-polymorphism`).
46+
**Note:** This feature is now stable. The compiler flag `-Yno-kind-polymorphism` is deprecated as of 3.7.0, has no effect (is ignored), and will be removed in a future version.

tests/neg/no-kind-polymorphism-anykind.scala

-3
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// This test is kept as a placeholder for historical reasons.
2+
// The -Yno-kind-polymorphism flag is now deprecated and has no effect.
3+
// Kind polymorphism with AnyKind is always enabled.
4+
5+
trait Foo[T <: AnyKind] // This now works as AnyKind is always defined

0 commit comments

Comments
 (0)