Skip to content

Commit a710722

Browse files
committed
Hide kind-polymorphism behind -Ykind-polymorphism
1 parent 8d07250 commit a710722

File tree

10 files changed

+9
-1
lines changed

10 files changed

+9
-1
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ class ScalaSettings extends Settings.SettingGroup {
123123
val YprofileRunGcBetweenPhases = PhasesSetting("-Yprofile-run-gc", "Run a GC between phases - this allows heap size to be accurate at the expense of more time. Specify a list of phases, or *", "_")
124124
//.withPostSetHook( _ => YprofileEnabled.value = true )
125125

126+
// Extremely experimetnal language feature
127+
val YkindPolymorphism = BooleanSetting("-Ykind-polymorphism", "Potentially unsound.")
128+
126129
/** Area-specific debug output */
127130
val YexplainLowlevel = BooleanSetting("-Yexplain-lowlevel", "When explaining type errors, show types at a lower level.")
128131
val YnoDoubleBindings = BooleanSetting("-Yno-double-bindings", "Assert no namedtype is bound twice (should be enabled only if program is error-free).")

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,10 @@ class Definitions {
306306

307307
lazy val AnyKindClass = {
308308
val cls = ctx.newCompleteClassSymbol(ScalaPackageClass, tpnme.AnyKind, AbstractFinal | Permanent, Nil)
309-
if (true) cls.entered // TODO: replace with if (ctx.settings.Yanykind.value) ...
309+
if (ctx.settings.YkindPolymorphism.value) {
310+
// Enable kind-polymorphism by exposing scala.AnyKind
311+
cls.entered
312+
}
310313
cls
311314
}
312315
def AnyKindType = AnyKindClass.typeRef

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ class CompilationTests extends ParallelTesting {
102102
compileFilesInDir("tests/pos", defaultOptions) +
103103
compileFilesInDir("tests/pos-no-optimise", defaultOptions) +
104104
compileFilesInDir("tests/pos-deep-subtype", allowDeepSubtypes) +
105+
compileFilesInDir("tests/pos-kind-polymorphism", defaultOptions and "-Ykind-polymorphism") +
105106
compileDir("tests/pos/i1137-1", defaultOptions and "-Yemit-tasty") +
106107
compileFile(
107108
// succeeds despite -Xfatal-warnings because of -nowarn
@@ -175,6 +176,7 @@ class CompilationTests extends ParallelTesting {
175176
compileFilesInDir("tests/neg", defaultOptions) +
176177
compileFilesInDir("tests/neg-tailcall", defaultOptions) +
177178
compileFilesInDir("tests/neg-no-optimise", defaultOptions) +
179+
compileFilesInDir("tests/neg-kind-polymorphism", defaultOptions and "-Ykind-polymorphism") +
178180
compileFilesInDir("tests/neg-custom-args/fatal-warnings", defaultOptions.and("-Xfatal-warnings")) +
179181
compileFilesInDir("tests/neg-custom-args/allow-double-bindings", allowDoubleBindings) +
180182
compileFile("tests/neg-custom-args/i3246.scala", scala2Mode) +
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)