From 722661c0bada3a8e64512bda2ac7501b1c02ec10 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Fri, 14 Mar 2014 09:44:17 +0100 Subject: Fixed two problems with annotated types in patterns Problem 1: The parser did not accept them. It has to accept a "RefinedType" as an ascription, not a "WithType" (as it did before), or even a "SimpleType" (as speced in the SyntaxSummary). Problem 2: Annotations are always typed as expressions. The annotations in question were typed as patterns before. Tests in Patterns.scala and in the Dotty compiler itself. --- tests/pos/Patterns.scala | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/pos/Patterns.scala b/tests/pos/Patterns.scala index fbcdc4c30..4470eb232 100644 --- a/tests/pos/Patterns.scala +++ b/tests/pos/Patterns.scala @@ -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 { -- cgit v1.2.3