Skip to content

Commit

Permalink
[backport] Allow ? as a wildcard even without -Xsource:3
Browse files Browse the repository at this point in the history
This backports scala#9990 to Scala 2.12 as discussed in that PR.
  • Loading branch information
smarter committed Apr 18, 2022
1 parent e9e4ebb commit 6d2ca69
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
Expand Up @@ -704,7 +704,7 @@ self =>
def isRawIdent = in.token == IDENTIFIER

def isWildcardType = in.token == USCORE || isScala3WildcardType
def isScala3WildcardType = currentRun.isScala3 && isRawIdent && in.name == raw.QMARK
def isScala3WildcardType = isRawIdent && in.name == raw.QMARK

def isIdent = in.token == IDENTIFIER || in.token == BACKQUOTED_IDENT
def isMacro = in.token == IDENTIFIER && in.name == nme.MACROkw
Expand Down
@@ -1,5 +1,3 @@
// scalac: -Xsource:3
//
object Test {
val xs: List[?] = List(1, 2, 3)
val ys: Map[? <: AnyRef, ? >: Null] = Map()
Expand All @@ -9,8 +7,7 @@ object Test {
case _ => x
}

// Only allowed in Scala 3 under -source 3.0-migration
type ? = Int
type `?` = Int

val xs2: List[`?`] = List(1)
val xs3: List[Int] = xs2
Expand Down

0 comments on commit 6d2ca69

Please sign in to comment.