Skip to content

Commit c8e5ddb

Browse files
committed
Put erased under -Yerased-terms flag
`erased` will not be included in Scala 3.0 but could be added in future version. This feature will only be available with `-Yerased-terms`.
1 parent 49bf7f4 commit c8e5ddb

File tree

141 files changed

+11
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

141 files changed

+11
-2
lines changed

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

+1
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ class ScalaSettings extends Settings.SettingGroup {
166166
// Extremely experimental language features
167167
val YnoKindPolymorphism: Setting[Boolean] = BooleanSetting("-Yno-kind-polymorphism", "Enable kind polymorphism (see https://dotty.epfl.ch/docs/reference/kind-polymorphism.html). Potentially unsound.")
168168
val YexplicitNulls: Setting[Boolean] = BooleanSetting("-Yexplicit-nulls", "Make reference types non-nullable. Nullable types can be expressed with unions: e.g. String|Null.")
169+
val YerasedTerms: Setting[Boolean] = BooleanSetting("-Yerased-terms", "Allows the use of erased terms.")
169170

170171
/** Area-specific debug output */
171172
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

+1
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ class Definitions {
221221
@tu lazy val ScalaXmlPackageClass: Symbol = ctx.getPackageClassIfDefined("scala.xml")
222222

223223
@tu lazy val CompiletimePackageObject: Symbol = ctx.requiredModule("scala.compiletime.package")
224+
@tu lazy val Compiletime_erasedValue : Symbol = CompiletimePackageObject.requiredMethod("erasedValue")
224225
@tu lazy val Compiletime_error : Symbol = CompiletimePackageObject.requiredMethod(nme.error)
225226
@tu lazy val Compiletime_constValue : Symbol = CompiletimePackageObject.requiredMethod("constValue")
226227
@tu lazy val Compiletime_constValueOpt: Symbol = CompiletimePackageObject.requiredMethod("constValueOpt")

compiler/src/dotty/tools/dotc/typer/Checking.scala

+2-1
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,8 @@ object Checking {
457457
sym.setFlag(Private) // break the overriding relationship by making sym Private
458458
}
459459
if (sym.is(Erased))
460-
checkApplicable(Erased, !sym.isOneOf(MutableOrLazy))
460+
if ctx.settings.YerasedTerms.value || sym == defn.Compiletime_erasedValue then checkApplicable(Erased, !sym.isOneOf(MutableOrLazy))
461+
else fail("cannot use `erased` without " + ctx.settings.YerasedTerms.name)
461462
}
462463

463464
/** Check the type signature of the symbol `M` defined by `tree` does not refer

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

+1
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ class BootstrappedOnlyCompilationTests extends ParallelTesting {
118118
aggregateTests(
119119
compileFilesInDir("tests/run-macros", defaultOptions),
120120
compileFilesInDir("tests/run-custom-args/Yretain-trees", defaultOptions and "-Yretain-trees"),
121+
compileFilesInDir("tests/run-custom-args/run-macros-erased", defaultOptions and "-Yerased-terms"),
121122
)
122123
}.checkRuns()
123124

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

+3
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class CompilationTests extends ParallelTesting {
4747
compileFilesInDir("tests/pos-special/isInstanceOf", allowDeepSubtypes.and("-Xfatal-warnings")),
4848
compileFilesInDir("tests/new", defaultOptions),
4949
compileFilesInDir("tests/pos-scala2", scala2CompatMode),
50+
compileFilesInDir("tests/pos-custom-args/erased", defaultOptions.and("-Yerased-terms")),
5051
compileFilesInDir("tests/pos", defaultOptions),
5152
compileFilesInDir("tests/pos-deep-subtype", allowDeepSubtypes),
5253
compileFile(
@@ -114,6 +115,7 @@ class CompilationTests extends ParallelTesting {
114115
compileFilesInDir("tests/neg-no-kind-polymorphism", defaultOptions and "-Yno-kind-polymorphism"),
115116
compileFilesInDir("tests/neg-custom-args/deprecation", defaultOptions.and("-Xfatal-warnings", "-deprecation")),
116117
compileFilesInDir("tests/neg-custom-args/fatal-warnings", defaultOptions.and("-Xfatal-warnings")),
118+
compileFilesInDir("tests/neg-custom-args/erased", defaultOptions.and("-Yerased-terms")),
117119
compileFilesInDir("tests/neg-custom-args/allow-double-bindings", allowDoubleBindings),
118120
compileFilesInDir("tests/neg-custom-args/explicit-nulls", defaultOptions.and("-Yexplicit-nulls")),
119121
compileDir("tests/neg-custom-args/impl-conv", defaultOptions.and("-Xfatal-warnings", "-feature")),
@@ -165,6 +167,7 @@ class CompilationTests extends ParallelTesting {
165167
compileFile("tests/run-custom-args/i5256.scala", allowDeepSubtypes),
166168
compileFile("tests/run-custom-args/fors.scala", defaultOptions and "-strict"),
167169
compileFile("tests/run-custom-args/no-useless-forwarders.scala", defaultOptions and "-Xmixin-force-forwarders:false"),
170+
compileFilesInDir("tests/run-custom-args/erased", defaultOptions.and("-Yerased-terms")),
168171
compileFilesInDir("tests/run-deep-subtype", allowDeepSubtypes),
169172
compileFilesInDir("tests/run", defaultOptions)
170173
).checkRuns()

compiler/test/dotty/tools/repl/ReplTest.scala

+3-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ class ReplTest(withStaging: Boolean = false, out: ByteArrayOutputStream = new By
2121
TestConfiguration.withStagingClasspath
2222
else
2323
TestConfiguration.basicClasspath,
24-
"-color:never"),
24+
"-color:never",
25+
"-Yerased-terms",
26+
),
2527
new PrintStream(out)
2628
) with MessageRendering {
2729
/** Get the stored output from `out`, resetting the buffer */
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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)