Skip to content

Commit 0c09915

Browse files
Also disalow unbound wildcard type in pattern expr
1 parent a3f2565 commit 0c09915

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1821,7 +1821,7 @@ object Parsers {
18211821

18221822
def typeDependingOn(location: Location): Tree =
18231823
if location.inParens then typ()
1824-
else if location.inPattern then refinedType()
1824+
else if location.inPattern then rejectWildcardType(refinedType())
18251825
else infixType()
18261826

18271827
/* ----------- EXPRESSIONS ------------------------------------------------ */

tests/neg/12261.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@ type M1[X] = X match {
99
type M2[X] = X match {
1010
case Any => ? // error: Unbound wildcard type
1111
}
12+
13+
val a = "" match { case _: _ => () } // error: Unbound wildcard type
14+
15+
val b = try { } catch { case _: _ => () } // error: Unbound wildcard type

0 commit comments

Comments
 (0)