Skip to content
Merged
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
3 changes: 2 additions & 1 deletion compiler/src/dotty/tools/dotc/parsing/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2604,7 +2604,7 @@ object Parsers {
})
}

/** TypeCaseClause ::= ‘case’ InfixType ‘=>’ Type [nl]
/** TypeCaseClause ::= ‘case’ InfixType ‘=>’ Type [semi]
*/
def typeCaseClause(): CaseDef = atSpan(in.offset) {
val pat = inSepRegion(InCase) {
Expand All @@ -2613,6 +2613,7 @@ object Parsers {
}
CaseDef(pat, EmptyTree, atSpan(accept(ARROW)) {
val t = typ()
if in.token == SEMI then in.nextToken()
newLinesOptWhenFollowedBy(CASE)
t
})
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/internals/syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ CaseClauses ::= CaseClause { CaseClause }
CaseClause ::= ‘case’ Pattern [Guard] ‘=>’ Block CaseDef(pat, guard?, block) // block starts at =>
ExprCaseClause ::= ‘case’ Pattern [Guard] ‘=>’ Expr
TypeCaseClauses ::= TypeCaseClause { TypeCaseClause }
TypeCaseClause ::= ‘case’ InfixType ‘=>’ Type [nl]
TypeCaseClause ::= ‘case’ InfixType ‘=>’ Type [semi]

Pattern ::= Pattern1 { ‘|’ Pattern1 } Alternative(pats)
Pattern1 ::= Pattern2 [‘:’ RefinedType] Bind(name, Typed(Ident(wildcard), tpe))
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/reference/syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ CaseClauses ::= CaseClause { CaseClause }
CaseClause ::= ‘case’ Pattern [Guard] ‘=>’ Block
ExprCaseClause ::= ‘case’ Pattern [Guard] ‘=>’ Expr
TypeCaseClauses ::= TypeCaseClause { TypeCaseClause }
TypeCaseClause ::= ‘case’ InfixType ‘=>’ Type [nl]
TypeCaseClause ::= ‘case’ InfixType ‘=>’ Type [semi]

Pattern ::= Pattern1 { ‘|’ Pattern1 }
Pattern1 ::= Pattern2 [‘:’ RefinedType]
Expand Down
File renamed without changes.
3 changes: 3 additions & 0 deletions tests/pos/i13331.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def Choice = (_: Any) match { case Int => Long; case Long => Int } // ok

type Choice[A] = A match { case Int => Long ; case Long => Int } // error