Skip to content

Commit 8d1c835

Browse files
committed
Enable kind polimorphism
Enable kind polimorphism by default by replacing `-Ykind-polymorphism` with `-Yno-kind-polymorphism`.
1 parent a775e0a commit 8d1c835

File tree

14 files changed

+9
-14
lines changed

14 files changed

+9
-14
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ class ScalaSettings extends Settings.SettingGroup {
138138
//.withPostSetHook( _ => YprofileEnabled.value = true )
139139

140140
// Extremely experimental language features
141-
val YkindPolymorphism: Setting[Boolean] = BooleanSetting("-Ykind-polymorphism", "Enable kind polymorphism (see http://dotty.epfl.ch/docs/reference/kind-polymorphism.html). Potentially unsound.")
141+
val YnoKindPolymorphism: Setting[Boolean] = BooleanSetting("-Yno-kind-polymorphism", "Enable kind polymorphism (see http://dotty.epfl.ch/docs/reference/kind-polymorphism.html). Potentially unsound.")
142142

143143
/** Area-specific debug output */
144144
val YexplainLowlevel: Setting[Boolean] = BooleanSetting("-Yexplain-lowlevel", "When explaining type errors, show types at a lower level.")

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ class Definitions {
320320

321321
lazy val AnyKindClass: ClassSymbol = {
322322
val cls = ctx.newCompleteClassSymbol(ScalaPackageClass, tpnme.AnyKind, AbstractFinal | Permanent, Nil)
323-
if (ctx.settings.YkindPolymorphism.value) {
323+
if (!ctx.settings.YnoKindPolymorphism.value) {
324324
// Enable kind-polymorphism by exposing scala.AnyKind
325325
cls.entered
326326
}

compiler/test/dotty/tools/dotc/CompilationTests.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ class CompilationTests extends ParallelTesting {
9191
compileFilesInDir("tests/pos-scala2", scala2Mode) +
9292
compileFilesInDir("tests/pos", defaultOptions) +
9393
compileFilesInDir("tests/pos-deep-subtype", allowDeepSubtypes) +
94-
compileFilesInDir("tests/pos-kind-polymorphism", defaultOptions and "-Ykind-polymorphism") +
9594
compileFile(
9695
// succeeds despite -Xfatal-warnings because of -nowarn
9796
"tests/neg-custom-args/fatal-warnings/xfatalWarnings.scala",
@@ -145,7 +144,7 @@ class CompilationTests extends ParallelTesting {
145144
implicit val testGroup: TestGroup = TestGroup("compileNeg")
146145
compileFilesInDir("tests/neg", defaultOptions) +
147146
compileFilesInDir("tests/neg-tailcall", defaultOptions) +
148-
compileFilesInDir("tests/neg-kind-polymorphism", defaultOptions and "-Ykind-polymorphism") +
147+
compileFilesInDir("tests/neg-no-kind-polymorphism", defaultOptions and "-Yno-kind-polymorphism") +
149148
compileFilesInDir("tests/neg-custom-args/deprecation", defaultOptions.and("-Xfatal-warnings", "-deprecation")) +
150149
compileFilesInDir("tests/neg-custom-args/fatal-warnings", defaultOptions.and("-Xfatal-warnings")) +
151150
compileFilesInDir("tests/neg-custom-args/allow-double-bindings", allowDoubleBindings) +

compiler/test/dotty/tools/vulpix/TestConfiguration.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ object TestConfiguration {
4747
val yCheckOptions = Array("-Ycheck:all")
4848

4949
val commonOptions = checkOptions ++ noCheckOptions ++ yCheckOptions
50-
val defaultOptions = TestFlags(basicClasspath, commonOptions) and "-Ykind-polymorphism" // FIXME remove "-Ykind-polymorphism"
50+
val defaultOptions = TestFlags(basicClasspath, commonOptions)
5151
val withCompilerOptions =
5252
defaultOptions.withClasspath(withCompilerClasspath).withRunClasspath(withCompilerClasspath)
5353
val allowDeepSubtypes = defaultOptions without "-Yno-deep-subtypes"

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,5 @@ It is declared `abstract` and `final`, so it can be neither instantiated nor ext
4242

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

45-
**Note**: This feature is considered experimental and is only enabled under a compiler flag
46-
(i.e. `-Ykind-polymorphism`).
45+
**Note**: This feature is considered experimental but stable and it can be disabled under compiler flag
46+
(i.e. `-Yno-kind-polymorphism`).

project/Build.scala

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,17 +1143,11 @@ object Build {
11431143
def asDottyCompiler(implicit mode: Mode): Project = project.withCommonSettings.
11441144
dependsOn(`dotty-interfaces`).
11451145
dependsOn(dottyLibrary).
1146-
settings(dottyCompilerSettings).
1147-
bootstrappedSettings(
1148-
// To support kind polymorphism of scala.quote.Type
1149-
scalacOptions in Compile += "-Ykind-polymorphism"
1150-
)
1146+
settings(dottyCompilerSettings)
11511147

11521148
def asDottyLibrary(implicit mode: Mode): Project = project.withCommonSettings.
11531149
settings(dottyLibrarySettings).
11541150
bootstrappedSettings(
1155-
// To support kind polymorphism of scala.quote.Type
1156-
scalacOptions in Compile += "-Ykind-polymorphism",
11571151
// Needed so that the library sources are visible when `dotty.tools.dotc.core.Definitions#init` is called.
11581152
scalacOptions in Compile ++= Seq("-sourcepath", (scalaSource in Compile).value.getAbsolutePath)
11591153
)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
trait Foo[T <: AnyKind] // Error: Not found: type AnyKind
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)