Skip to content

Deprecate Yno-kind-polymorphism #22814

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion compiler/src/dotty/tools/dotc/config/ScalaSettings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,8 @@ private sealed trait YSettings:
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.")

// Experimental language features
val YnoKindPolymorphism: Setting[Boolean] = BooleanSetting(ForkSetting, "Yno-kind-polymorphism", "Disable kind polymorphism.")
@deprecated(message = "This flag has no effect and will be removed in a future version.", since = "3.7.0")
val YnoKindPolymorphism: Setting[Boolean] = BooleanSetting(ForkSetting, "Yno-kind-polymorphism", "Disable kind polymorphism. (This flag has no effect)", deprecation = Deprecation.removed())
val YexplicitNulls: Setting[Boolean] = BooleanSetting(ForkSetting, "Yexplicit-nulls", "Make reference types non-nullable. Nullable types can be expressed with unions: e.g. String|Null.")
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.")
val YcheckInitGlobal: Setting[Boolean] = BooleanSetting(ForkSetting, "Ysafe-init-global", "Check safe initialization of global objects.")
Expand Down
5 changes: 1 addition & 4 deletions compiler/src/dotty/tools/dotc/core/Definitions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -449,10 +449,7 @@ class Definitions {

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

Expand Down
3 changes: 1 addition & 2 deletions docs/_docs/reference/other-new-features/kind-polymorphism.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,4 @@ It is declared `abstract` and `final`, so it can be neither instantiated nor ext

`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).

**Note:** This feature is considered experimental but stable and it can be disabled under compiler flag
(i.e. `-Yno-kind-polymorphism`).
**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.
3 changes: 0 additions & 3 deletions tests/neg/no-kind-polymorphism-anykind.scala

This file was deleted.

5 changes: 5 additions & 0 deletions tests/pos/deprecated-no-kind-polymorphism-anykind.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// This test is kept as a placeholder for historical reasons.
// The -Yno-kind-polymorphism flag is now deprecated and has no effect.
// Kind polymorphism with AnyKind is always enabled.

trait Foo[T <: AnyKind] // This now works as AnyKind is always defined
Loading