diff options
author | Martin Odersky <odersky@gmail.com> | 2014-03-14 09:44:17 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2014-03-14 09:44:17 +0100 |
commit | 722661c0bada3a8e64512bda2ac7501b1c02ec10 (patch) | |
tree | a94c071b6eeea5092f3c01c48dd1e7ce421c48e2 /tests | |
parent | db950e5e168f6fd71a367da343e352139e8d653e (diff) | |
download | dotty-722661c0bada3a8e64512bda2ac7501b1c02ec10.tar.gz dotty-722661c0bada3a8e64512bda2ac7501b1c02ec10.tar.bz2 dotty-722661c0bada3a8e64512bda2ac7501b1c02ec10.zip |
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.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/pos/Patterns.scala | 12 |
1 files changed, 9 insertions, 3 deletions
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 { |