Skip to content

Commit 0aee2c1

Browse files
Fix scala#13223: Disalow ? in match types pats/bodies
1 parent 9039a77 commit 0aee2c1

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2616,11 +2616,11 @@ object Parsers {
26162616
val start = in.skipToken()
26172617
Ident(tpnme.WILDCARD).withSpan(Span(start, in.lastOffset, start))
26182618
case _ =>
2619-
infixType()
2619+
rejectWildcardType(infixType())
26202620
}
26212621
}
26222622
CaseDef(pat, EmptyTree, atSpan(accept(ARROW)) {
2623-
val t = typ()
2623+
val t = rejectWildcardType(typ())
26242624
newLinesOptWhenFollowedBy(CASE)
26252625
t
26262626
})

tests/neg/12261.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
type M0[X] = X match {
2+
case ? => String // error: Unbound wildcard type
3+
}
4+
5+
type M1[X] = X match {
6+
case Any => _ // error: Unbound wildcard type
7+
}
8+
9+
type M2[X] = X match {
10+
case Any => ? // error: Unbound wildcard type
11+
}

tests/pos/9239.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ object ABug:
2424
N match
2525
case Zero => One
2626
case One => One
27-
case ? => ![--[N]] × (N)
27+
case _ => ![--[N]] × (N)
2828
case ? :: ? => ![--[N]] × (N)

0 commit comments

Comments
 (0)