-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deprecate using Scala 3 hard keywords as identifiers
- Loading branch information
Showing
9 changed files
with
59 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
scala3-keywords.scala:13: warning: Wrap `enum` in backticks to use it as an identifier, it will become a keyword in Scala 3. | ||
val enum: Int = 1 // error | ||
^ | ||
scala3-keywords.scala:14: warning: Wrap `export` in backticks to use it as an identifier, it will become a keyword in Scala 3. | ||
val export: Int = 1 // error | ||
^ | ||
scala3-keywords.scala:15: warning: Wrap `given` in backticks to use it as an identifier, it will become a keyword in Scala 3. | ||
val given: Int = 1 // error | ||
^ | ||
scala3-keywords.scala:16: warning: Wrap `given` in backticks to use it as an identifier, it will become a keyword in Scala 3. | ||
def foo(given: Int) = {} // error | ||
^ | ||
scala3-keywords.scala:17: warning: Wrap `export` in backticks to use it as an identifier, it will become a keyword in Scala 3. | ||
def bla[export <: Int] = {} // error | ||
^ | ||
scala3-keywords.scala:19: warning: Wrap `enum` in backticks to use it as an identifier, it will become a keyword in Scala 3. | ||
class enum // error | ||
^ | ||
error: No warnings can be incurred under -Werror. | ||
6 warnings | ||
1 error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// scalac: -deprecation -Xfatal-warnings | ||
// | ||
class A { | ||
val `enum`: Int = 1 | ||
val `export`: Int = 1 | ||
val `given`: Int = 1 | ||
def foo(`given`: Int) = {} | ||
def bla[`export` <: Int] = { | ||
class `enum` | ||
} | ||
} | ||
class B { | ||
val enum: Int = 1 // error | ||
val export: Int = 1 // error | ||
val given: Int = 1 // error | ||
def foo(given: Int) = {} // error | ||
def bla[export <: Int] = {} // error | ||
} | ||
class enum // error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
object Test extends App { | ||
import scala.reflect.runtime.universe._ | ||
val enum = typeOf[JavaSimpleEnumeration_1].baseClasses(1).asClass | ||
val `enum` = typeOf[JavaSimpleEnumeration_1].baseClasses(1).asClass | ||
// make sure that the E's in Enum<E extends Enum<E>> are represented by the same symbol | ||
val e1 = enum.typeParams(0).asType | ||
val e1 = `enum`.typeParams(0).asType | ||
val TypeBounds(_, TypeRef(_, _, List(TypeRef(_, e2: TypeSymbol, _)))) = e1.info | ||
println(e1, e2, e1 eq e2) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters