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
6 changes: 3 additions & 3 deletions docs/SyntaxSummary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,13 @@ grammar.
CaseClause ::= `case' (Pattern [Guard] `=>' Block | INT) CaseDef(pat, guard?, block) // block starts at =>

Pattern ::= Pattern1 { `|' Pattern1 } Alternative(pats)
Pattern1 ::= PatVar `:' SimpleType Bind(name, Typed(Ident(wildcard), tpe))
Pattern1 ::= PatVar `:' RefinedType Bind(name, Typed(Ident(wildcard), tpe))
| Pattern2
Pattern2 ::= [varid `@'] InfixPattern Bind(name, pat)
InfixPattern ::= SimplePattern { id [nl] SimplePattern } InfixOp(pat, op, pat)
SimplePattern ::= PatVar Ident(wildcard)
| Literal Bind(name, Ident(wildcard)) | Literal
| `(' [Patterns] `)' Parens(pats) Tuple(pats)
| Literal Bind(name, Ident(wildcard))
| `(' [Patterns] `)' Parens(pats) Tuple(pats)
| XmlPattern
| SimplePattern1 [TypeArgs] [ArgumentPatterns]
SimplePattern1 ::= Path
Expand Down
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/parsing/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ object Parsers {

def typeDependingOn(location: Location.Value): Tree =
if (location == Location.InParens) typ()
else if (location == Location.InPattern) withType()
else if (location == Location.InPattern) refinedType()
else infixType()

/* ----------- EXPRESSIONS ------------------------------------------------ */
Expand Down
3 changes: 1 addition & 2 deletions src/dotty/tools/dotc/printing/PlainPrinter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ class PlainPrinter(_ctx: Context) extends Printer {
case tp: TypeRef =>
toTextPrefix(tp.prefix) ~ selectionString(tp)
case tp: RefinedType =>
// return tp.toString // !!! DEBUG
val parent :: (refined: List[RefinedType]) =
val parent :: (refined: List[RefinedType @unchecked]) =
refinementChain(tp).reverse
toTextLocal(parent) ~ "{" ~ Text(refined map toTextRefinement, "; ").close ~ "}"
case AndType(tp1, tp2) =>
Expand Down
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/typer/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
}

def typedAnnotated(tree: untpd.Annotated, pt: Type)(implicit ctx: Context): Tree = track("typedAnnotated") {
val annot1 = typed(tree.annot, defn.AnnotationClass.typeRef)
val annot1 = typedExpr(tree.annot, defn.AnnotationClass.typeRef)
val arg1 = typed(tree.arg, pt)
if (ctx.mode is Mode.Type)
assignType(cpy.Annotated(tree, annot1, arg1), annot1, arg1)
Expand Down
12 changes: 9 additions & 3 deletions tests/pos/Patterns.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,23 @@ object Patterns {
case (digit, str) => true
case _ => false
}


(xs: Any) match {
case x: Int @unchecked => true
case xs: List[Int @ unchecked] => true
case _ => false
}

def sum(xs: List[Int]): Int = xs match {
case Nil => 0
case x :: xs1 => x + sum(xs1)
}

def len[T](xs: List[T]): Int = xs match {
case _ :: xs1 => 1 + len(xs1)
case Nil => 0
}

final def sameLength[T](xs: List[T], ys: List[T]): Boolean = xs match {
case _ :: xs1 =>
ys match {
Expand Down