forked from scala/scala
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deprecate calling a type
?
without backticks
scala#9560 introduced a new meaning for `?` under `-Xsource:3`, but to smooth out the migration it'd be nice if we could also enable this meaning by default. Before doing so, let's deprecate any current usage of `?` as a type that isn't wrapped in backticks.
- Loading branch information
Showing
3 changed files
with
78 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
qmark-deprecated.scala:5: warning: using `?` as a type name will require backticks in the future. | ||
type ? = String | ||
^ | ||
qmark-deprecated.scala:7: warning: The meaning of `?` in types will change to wildcard, to keep the current meaning wrap it in backticks. | ||
val x: Array[?] = new Array[?](0) | ||
^ | ||
qmark-deprecated.scala:7: warning: The meaning of `?` in types will change to wildcard, to keep the current meaning wrap it in backticks. | ||
val x: Array[?] = new Array[?](0) | ||
^ | ||
qmark-deprecated.scala:12: warning: The meaning of `?` in types will change to wildcard, to keep the current meaning wrap it in backticks. | ||
def foo1[T <: Array[?]](x: T): Array[?] = x | ||
^ | ||
qmark-deprecated.scala:12: warning: The meaning of `?` in types will change to wildcard, to keep the current meaning wrap it in backticks. | ||
def foo1[T <: Array[?]](x: T): Array[?] = x | ||
^ | ||
error: No warnings can be incurred under -Werror. | ||
5 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,40 @@ | ||
// scalac: -deprecation -Xfatal-warnings | ||
// | ||
|
||
class Foo[?] // error | ||
class Foo2[`?`] // ok | ||
class Bar[M[?] <: List[?]] // errors | ||
class Bar2[M[`?`] <: List[`?`]] // ok | ||
|
||
object G { | ||
class ? { val x = 1 } // error | ||
} | ||
object G2 { | ||
class `?` { val x = 1 } // ok | ||
} | ||
object H { | ||
trait ? // error | ||
} | ||
object H2 { | ||
trait `?` // ok | ||
} | ||
object I { | ||
type ? = Int // error | ||
} | ||
object I2 { | ||
type `?` = Int // ok | ||
|
||
val x: Array[?] = new Array[?](0) // errors | ||
val y: Array[`?`] = new Array[`?`](0) // ok | ||
|
||
def foo1[T <: Array[?]](x: T): Array[?] = x // errors | ||
def foo2[T <: Array[`?`]](x: T): Array[`?`] = x // ok | ||
|
||
def bar1[?] = {} // error | ||
def bar2[`?`] = {} // ok | ||
def bar3[M[?]] = {} // error | ||
def bar4[M[`?`]] = {} // error | ||
|
||
type A[?] = Int // error | ||
type B[`?`] = Int // ok | ||
} |