diff --git a/community-build/community-projects/scodec b/community-build/community-projects/scodec index 18047cac1feb..d59c0440b078 160000 --- a/community-build/community-projects/scodec +++ b/community-build/community-projects/scodec @@ -1 +1 @@ -Subproject commit 18047cac1febc840e03dee91a31183d64e632222 +Subproject commit d59c0440b078292dedff10b6743d6a086f468527 diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala index 399eabfff0f1..6d152dc116d8 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala @@ -1820,7 +1820,7 @@ object Parsers { def typeDependingOn(location: Location): Tree = if location.inParens then typ() - else if location.inPattern then refinedType() + else if location.inPattern then rejectWildcardType(refinedType()) else infixType() /* ----------- EXPRESSIONS ------------------------------------------------ */ @@ -2609,10 +2609,10 @@ object Parsers { def typeCaseClause(): CaseDef = atSpan(in.offset) { val pat = inSepRegion(InCase) { accept(CASE) - infixType() + rejectWildcardType(infixType()) } CaseDef(pat, EmptyTree, atSpan(accept(ARROW)) { - val t = typ() + val t = rejectWildcardType(typ()) newLinesOptWhenFollowedBy(CASE) t }) diff --git a/tests/neg/12261.scala b/tests/neg/12261.scala new file mode 100644 index 000000000000..70120671a05b --- /dev/null +++ b/tests/neg/12261.scala @@ -0,0 +1,15 @@ +type M0[X] = X match { + case ? => String // error: Unbound wildcard type +} + +type M1[X] = X match { + case Any => _ // error: Unbound wildcard type +} + +type M2[X] = X match { + case Any => ? // error: Unbound wildcard type +} + +val a = "" match { case _: _ => () } // error: Unbound wildcard type + +val b = try { } catch { case _: _ => () } // error: Unbound wildcard type diff --git a/tests/pos/9239.scala b/tests/pos/9239.scala index 8f3ddfbd1ced..c9c0ec268218 100644 --- a/tests/pos/9239.scala +++ b/tests/pos/9239.scala @@ -24,5 +24,5 @@ object ABug: N match case Zero => One case One => One - case ? => ![--[N]] × (N) + case _ => ![--[N]] × (N) case ? :: ? => ![--[N]] × (N)