Skip to content

Fix #7944: Only treat erased as a keyword under -Yerased-terms #7947

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 1 commit into from
Jan 10, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ object projects

lazy val stdLib213 = SbtCommunityProject(
project = "stdLib213",
sbtTestCommand = "library/compile",
sbtTestCommand = """;set scalacOptions in Global += "-Yerased-terms" ;library/compile""",
sbtUpdateCommand = "library/update",
extraSbtArgs = List("-Dscala.build.compileWithDotty=true")
)
Expand Down
3 changes: 2 additions & 1 deletion compiler/src/dotty/tools/dotc/parsing/Scanners.scala
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ object Scanners {
private val commentBuf = new mutable.StringBuilder

private def handleMigration(keyword: Token): Token =
if (!isScala2CompatMode) keyword
if (keyword == ERASED && !ctx.settings.YerasedTerms.value) IDENTIFIER
else if (!isScala2CompatMode) keyword
else if (scala3keywords.contains(keyword)) treatAsIdent()
else keyword

Expand Down
3 changes: 1 addition & 2 deletions compiler/src/dotty/tools/dotc/typer/Checking.scala
Original file line number Diff line number Diff line change
Expand Up @@ -457,8 +457,7 @@ object Checking {
sym.setFlag(Private) // break the overriding relationship by making sym Private
}
if (sym.is(Erased))
if ctx.settings.YerasedTerms.value || sym == defn.Compiletime_erasedValue then checkApplicable(Erased, !sym.isOneOf(MutableOrLazy))
else fail("cannot use `erased` without " + ctx.settings.YerasedTerms.name)
checkApplicable(Erased, !sym.isOneOf(MutableOrLazy))
}

/** Check the type signature of the symbol `M` defined by `tree` does not refer
Expand Down
1 change: 1 addition & 0 deletions compiler/test/dotty/tools/dotc/CompilationTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ class CompilationTests extends ParallelTesting {
val lib =
compileList("src", librarySources,
defaultOptions.and("-Ycheck-reentrant",
"-Yerased-terms", // support declaration of scala.compiletime.erasedValue
// "-strict", // TODO: re-enable once we allow : @unchecked in pattern definitions. Right now, lots of narrowing pattern definitions fail.
"-priorityclasspath", defaultOutputDir))(libGroup)

Expand Down
5 changes: 4 additions & 1 deletion project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,8 @@ object Build {

lazy val `dotty-library` = project.in(file("library")).asDottyLibrary(NonBootstrapped)
lazy val `dotty-library-bootstrapped`: Project = project.in(file("library")).asDottyLibrary(Bootstrapped)
// TODO: move -Yerased-terms to dottyLibrarySettings on reference compiler update
.settings(scalacOptions in Compile += "-Yerased-terms") // support declaration of scala.compiletime.erasedValue

def dottyLibrary(implicit mode: Mode): Project = mode match {
case NonBootstrapped => `dotty-library`
Expand All @@ -758,6 +760,7 @@ object Build {
settings(
unmanagedSourceDirectories in Compile :=
(unmanagedSourceDirectories in (`dotty-library-bootstrapped`, Compile)).value,
scalacOptions += "-Yerased-terms", // support declaration of scala.compiletime.erasedValue
)

lazy val tastyCoreSettings = Seq(
Expand Down Expand Up @@ -990,7 +993,7 @@ object Build {
val dir = fetchScalaJSSource.value / "test-suite"
(
(dir / "shared/src/test/scala/org/scalajs/testsuite/compiler" ** (("*.scala":FileFilter) -- "RegressionTest.scala" -- "ReflectiveCallTest.scala")).get
++ (dir / "shared/src/test/scala/org/scalajs/testsuite/javalib/lang" ** (("*.scala": FileFilter) -- "StringTest.scala")).get
++ (dir / "shared/src/test/scala/org/scalajs/testsuite/javalib/lang" ** "*.scala").get
++ (dir / "shared/src/test/scala/org/scalajs/testsuite/javalib/io" ** (("*.scala": FileFilter) -- "ReadersTest.scala")).get
++ (dir / "shared/src/test/scala/org/scalajs/testsuite/javalib/math" ** "*.scala").get
++ (dir / "shared/src/test/scala/org/scalajs/testsuite/javalib/net" ** "*.scala").get
Expand Down
8 changes: 8 additions & 0 deletions tests/pos/i7944.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package hello

object HelloWorld {
def main(args: Array[String]): Unit =
println(erased(5))

def erased(x: Int): Any = x
}