Skip to content

Commit 5a81d5a

Browse files
Disalow wildcard types in match types pats/bodies
1 parent 0efa54e commit 5a81d5a

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
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+
}

0 commit comments

Comments
 (0)