Skip to content

Commit a3f2565

Browse files
Fix #13223: Disalow ? in match types pats/bodies
1 parent e2a8eab commit a3f2565

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
@@ -2617,11 +2617,11 @@ object Parsers {
26172617
val start = in.skipToken()
26182618
Ident(tpnme.WILDCARD).withSpan(Span(start, in.lastOffset, start))
26192619
case _ =>
2620-
infixType()
2620+
rejectWildcardType(infixType())
26212621
}
26222622
}
26232623
CaseDef(pat, EmptyTree, atSpan(accept(ARROW)) {
2624-
val t = typ()
2624+
val t = rejectWildcardType(typ())
26252625
if in.token == SEMI then in.nextToken()
26262626
newLinesOptWhenFollowedBy(CASE)
26272627
t

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)