Skip to content

Commit e9c944d

Browse files
committed
Eliminate -YerasedTerms
1 parent fc82020 commit e9c944d

File tree

9 files changed

+22
-28
lines changed

9 files changed

+22
-28
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,6 @@ class ScalaSettings extends Settings.SettingGroup with CommonScalaSettings {
227227
// Extremely experimental language features
228228
val YnoKindPolymorphism: Setting[Boolean] = BooleanSetting("-Yno-kind-polymorphism", "Disable kind polymorphism.")
229229
val YexplicitNulls: Setting[Boolean] = BooleanSetting("-Yexplicit-nulls", "Make reference types non-nullable. Nullable types can be expressed with unions: e.g. String|Null.")
230-
val YerasedTerms: Setting[Boolean] = BooleanSetting("-Yerased-terms", "Allows the use of erased terms.")
231230
val YcheckInit: Setting[Boolean] = BooleanSetting("-Ysafe-init", "Ensure safe initialization of objects")
232231
val YrequireTargetName: Setting[Boolean] = BooleanSetting("-Yrequire-targetName", "Warn if an operator is defined without a @targetName annotation")
233232

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,7 @@ object Parsers {
231231
}
232232

233233
extension (td: TokenData = in)
234-
def isErased: Boolean =
235-
td.token == ERASED
236-
|| td.isIdent(nme.erased) && featureEnabled(Feature.erasedTerms)
234+
def isErased: Boolean = td.isIdent(nme.erased) && featureEnabled(Feature.erasedTerms)
237235

238236
/* ------------- ERROR HANDLING ------------------------------------------- */
239237

@@ -2692,7 +2690,6 @@ object Parsers {
26922690
case FINAL => Mod.Final()
26932691
case IMPLICIT => Mod.Implicit()
26942692
case GIVEN => Mod.Given()
2695-
case ERASED => Mod.Erased()
26962693
case LAZY => Mod.Lazy()
26972694
case OVERRIDE => Mod.Override()
26982695
case PRIVATE => Mod.Private()

compiler/src/dotty/tools/dotc/parsing/Scanners.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,7 @@ object Scanners {
215215
private val commentBuf = CharBuffer()
216216

217217
private def handleMigration(keyword: Token): Token =
218-
if keyword == ERASED && !ctx.settings.YerasedTerms.value then IDENTIFIER
219-
else if scala3keywords.contains(keyword) && migrateTo3 then treatAsIdent()
218+
if scala3keywords.contains(keyword) && migrateTo3 then treatAsIdent()
220219
else keyword
221220

222221
private def treatAsIdent(): Token =

compiler/src/dotty/tools/dotc/parsing/Tokens.scala

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ abstract class TokensCommon {
9595
//final val THEN = 60; enter(THEN, "then")
9696
//final val FORSOME = 61; enter(FORSOME, "forSome") // TODO: deprecate
9797
//final val ENUM = 62; enter(ENUM, "enum")
98-
//final val ERASED = 63; enter(ERASED, "erased")
9998

10099
/** special symbols */
101100
final val COMMA = 70; enter(COMMA, "','")
@@ -181,10 +180,9 @@ object Tokens extends TokensCommon {
181180
final val THEN = 60; enter(THEN, "then")
182181
final val FORSOME = 61; enter(FORSOME, "forSome") // TODO: deprecate
183182
final val ENUM = 62; enter(ENUM, "enum")
184-
final val ERASED = 63; enter(ERASED, "erased")
185-
final val GIVEN = 64; enter(GIVEN, "given")
186-
final val EXPORT = 65; enter(EXPORT, "export")
187-
final val MACRO = 67; enter(MACRO, "macro") // TODO: remove
183+
final val GIVEN = 63; enter(GIVEN, "given")
184+
final val EXPORT = 64; enter(EXPORT, "export")
185+
final val MACRO = 65; enter(MACRO, "macro") // TODO: remove
188186

189187
/** special symbols */
190188
final val NEWLINE = 78; enter(NEWLINE, "end of statement", "new line")
@@ -240,8 +238,7 @@ object Tokens extends TokensCommon {
240238

241239
final val defIntroTokens: TokenSet = templateIntroTokens | dclIntroTokens
242240

243-
final val localModifierTokens: TokenSet = BitSet(
244-
ABSTRACT, FINAL, SEALED, IMPLICIT, LAZY, ERASED)
241+
final val localModifierTokens: TokenSet = BitSet(ABSTRACT, FINAL, SEALED, IMPLICIT, LAZY)
245242

246243
final val accessModifierTokens: TokenSet = BitSet(
247244
PRIVATE, PROTECTED)
@@ -283,11 +280,11 @@ object Tokens extends TokensCommon {
283280
*/
284281
final val startParamTokens: BitSet = modifierTokens | BitSet(VAL, VAR, AT)
285282

286-
final val scala3keywords = BitSet(ENUM, ERASED, GIVEN)
283+
final val scala3keywords = BitSet(ENUM, GIVEN)
287284

288285
final val endMarkerTokens = identifierTokens | BitSet(IF, WHILE, FOR, MATCH, TRY, NEW, THROW, GIVEN, VAL, THIS)
289286

290287
final val skipStopTokens = BitSet(SEMI, NEWLINE, NEWLINES, RBRACE, RPAREN, RBRACKET, OUTDENT)
291288

292-
final val softModifierNames = Set(nme.inline, nme.opaque, nme.open, nme.transparent, nme.infix)
289+
final val softModifierNames = Set(nme.inline, nme.opaque, nme.open, nme.transparent, nme.infix, nme.erased)
293290
}

compiler/test/dotty/tools/DottyTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ trait DottyTest extends ContextEscapeDetection {
4242
protected def initializeCtx(fc: FreshContext): Unit = {
4343
fc.setSetting(fc.settings.encoding, "UTF8")
4444
fc.setSetting(fc.settings.classpath, TestConfiguration.basicClasspath)
45-
fc.setSetting(fc.settings.YerasedTerms, true)
45+
fc.setSetting(fc.settings.language, List("experimental.erasedTerms"))
4646
fc.setProperty(ContextDoc, new ContextDocstrings)
4747
}
4848

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ class BootstrappedOnlyCompilationTests {
118118
aggregateTests(
119119
compileFilesInDir("tests/run-macros", defaultOptions.and("-Xcheck-macros")),
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").and("-Xcheck-macros")),
121+
compileFilesInDir("tests/run-custom-args/run-macros-erased", defaultOptions.and("-language:experimental.erasedTerms").and("-Xcheck-macros")),
122122
)
123123
}.checkRuns()
124124

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class CompilationTests {
3939
compileFilesInDir("tests/pos-special/isInstanceOf", allowDeepSubtypes.and("-Xfatal-warnings")),
4040
compileFilesInDir("tests/new", defaultOptions),
4141
compileFilesInDir("tests/pos-scala2", scala2CompatMode),
42-
compileFilesInDir("tests/pos-custom-args/erased", defaultOptions.and("-Yerased-terms")),
42+
compileFilesInDir("tests/pos-custom-args/erased", defaultOptions.and("-language:experimental.erasedTerms")),
4343
compileFilesInDir("tests/pos", defaultOptions.and("-Ysafe-init")),
4444
compileFilesInDir("tests/pos-deep-subtype", allowDeepSubtypes),
4545
compileDir("tests/pos-special/java-param-names", defaultOptions.withJavacOnlyOptions("-parameters")),
@@ -126,7 +126,7 @@ class CompilationTests {
126126
compileFilesInDir("tests/neg-no-kind-polymorphism", defaultOptions and "-Yno-kind-polymorphism"),
127127
compileFilesInDir("tests/neg-custom-args/deprecation", defaultOptions.and("-Xfatal-warnings", "-deprecation")),
128128
compileFilesInDir("tests/neg-custom-args/fatal-warnings", defaultOptions.and("-Xfatal-warnings")),
129-
compileFilesInDir("tests/neg-custom-args/erased", defaultOptions.and("-Yerased-terms")),
129+
compileFilesInDir("tests/neg-custom-args/erased", defaultOptions.and("-language:experimental.erasedTerms")),
130130
compileFilesInDir("tests/neg-custom-args/allow-double-bindings", allowDoubleBindings),
131131
compileFilesInDir("tests/neg-custom-args/allow-deep-subtypes", allowDeepSubtypes),
132132
compileFilesInDir("tests/neg-custom-args/explicit-nulls", defaultOptions.and("-Yexplicit-nulls")),
@@ -165,7 +165,7 @@ class CompilationTests {
165165
compileDir("tests/neg-custom-args/adhoc-extension", defaultOptions.and("-source", "future", "-feature", "-Xfatal-warnings")),
166166
compileFile("tests/neg/i7575.scala", defaultOptions.withoutLanguageFeatures.and("-language:_")),
167167
compileFile("tests/neg-custom-args/kind-projector.scala", defaultOptions.and("-Ykind-projector")),
168-
compileFile("tests/neg-custom-args/typeclass-derivation2.scala", defaultOptions.and("-Yerased-terms")),
168+
compileFile("tests/neg-custom-args/typeclass-derivation2.scala", defaultOptions.and("-language:experimental.erasedTerms")),
169169
compileFile("tests/neg-custom-args/i5498-postfixOps.scala", defaultOptions withoutLanguageFeature "postfixOps"),
170170
compileFile("tests/neg-custom-args/deptypes.scala", defaultOptions.and("-language:experimental.dependent")),
171171
compileFile("tests/neg-custom-args/matchable.scala", defaultOptions.and("-Xfatal-warnings", "-source", "future")),
@@ -189,7 +189,7 @@ class CompilationTests {
189189
compileFile("tests/run-custom-args/fors.scala", defaultOptions.and("-source", "future")),
190190
compileFile("tests/run-custom-args/no-useless-forwarders.scala", defaultOptions and "-Xmixin-force-forwarders:false"),
191191
compileFile("tests/run-custom-args/defaults-serizaliable-no-forwarders.scala", defaultOptions and "-Xmixin-force-forwarders:false"),
192-
compileFilesInDir("tests/run-custom-args/erased", defaultOptions.and("-Yerased-terms")),
192+
compileFilesInDir("tests/run-custom-args/erased", defaultOptions.and("-language:experimental.erasedTerms")),
193193
compileFilesInDir("tests/run-deep-subtype", allowDeepSubtypes),
194194
compileFilesInDir("tests/run", defaultOptions.and("-Ysafe-init"))
195195
).checkRuns()
@@ -248,7 +248,7 @@ class CompilationTests {
248248
val lib =
249249
compileList("lib", librarySources,
250250
defaultOptions.and("-Ycheck-reentrant",
251-
"-Yerased-terms", // support declaration of scala.compiletime.erasedValue
251+
"-language:experimental.erasedTerms", // support declaration of scala.compiletime.erasedValue
252252
// "-source", "future", // TODO: re-enable once we allow : @unchecked in pattern definitions. Right now, lots of narrowing pattern definitions fail.
253253
))(libGroup)
254254

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,6 @@ extends ReplDriver(options, new PrintStream(out, true, StandardCharsets.UTF_8.na
9494
}
9595

9696
object ReplTest:
97-
val commonOptions = Array("-color:never", "-Yerased-terms", "-pagewidth", "80")
97+
val commonOptions = Array("-color:never", "-language:experimental.erasedTerms", "-pagewidth", "80")
9898
val defaultOptions = commonOptions ++ Array("-classpath", TestConfiguration.basicClasspath)
9999
lazy val withStagingOptions = commonOptions ++ Array("-classpath", TestConfiguration.withStagingClasspath)

tests/pos/CanThrow.scala

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
package canThrowStrawman
22
import language.experimental.erasedTerms
33

4-
class CanThrow[E <: Throwable]
4+
class CanThrow[E <: Exception]
55

6-
infix type throws1[R, E <: Throwable] = (erased CanThrow[E]) ?=> R
6+
infix type throws[R, E <: Exception] = (erased CanThrow[E]) ?=> R
77

88
class Fail extends Exception
99

10-
def foo(x: Boolean): Int throws1 Fail =
11-
if x then 1 else throw Fail()
10+
def raise[E <: Exception](e: E): Nothing throws E = throw e
11+
12+
def foo(x: Boolean): Int throws Fail =
13+
if x then 1 else raise(Fail())

0 commit comments

Comments
 (0)