Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions compiler/src/dotty/tools/dotc/parsing/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 ------------------------------------------------ */
Expand Down Expand Up @@ -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
})
Expand Down
15 changes: 15 additions & 0 deletions tests/neg/12261.scala
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion tests/pos/9239.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ object ABug:
N match
case Zero => One
case One => One
case ? => ![--[N]] × (N)
case _ => ![--[N]] × (N)
case ? :: ? => ![--[N]] × (N)