diff options
author | Martin Odersky <odersky@gmail.com> | 2007-06-19 15:22:33 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2007-06-19 15:22:33 +0000 |
commit | 542c248d614ab137b5d79c6a67bb98f147322a3f (patch) | |
tree | c50c23eee3fda2bf825b2d54a37b62c9cc4e2d10 /test | |
parent | c378489a951a6a250dd1a151a743e98bd22c5445 (diff) | |
download | scala-542c248d614ab137b5d79c6a67bb98f147322a3f.tar.gz scala-542c248d614ab137b5d79c6a67bb98f147322a3f.tar.bz2 scala-542c248d614ab137b5d79c6a67bb98f147322a3f.zip |
added wildcards. Changed for_some to forSome.
Diffstat (limited to 'test')
-rw-r--r-- | test/files/neg/bug1001.check | 6 | ||||
-rw-r--r-- | test/files/neg/bug1001.scala | 105 | ||||
-rw-r--r-- | test/files/run/existentials.check | 3 | ||||
-rwxr-xr-x | test/files/run/existentials.scala | 39 |
4 files changed, 36 insertions, 117 deletions
diff --git a/test/files/neg/bug1001.check b/test/files/neg/bug1001.check deleted file mode 100644 index e386359f4d..0000000000 --- a/test/files/neg/bug1001.check +++ /dev/null @@ -1,6 +0,0 @@ -bug1001.scala:104: error: the type intersection Ee with D is malformed - --- because --- -no common type instance of base types B[D] and B[Ee] exists - val data = List(N26,N25) - ^ -one error found diff --git a/test/files/neg/bug1001.scala b/test/files/neg/bug1001.scala deleted file mode 100644 index 1b909fb2ad..0000000000 --- a/test/files/neg/bug1001.scala +++ /dev/null @@ -1,105 +0,0 @@ -// I suspect the stack overflow is occurring when the compiler is determining the types for the following line at the end of the file:- -// val data = List(N26,N25) - -abstract class A -{ - // commenting out the following line (only) leads to successful compilation - protected val data: List[A] -} - -trait B[T <: B[T]] extends A { self: T => } - -abstract class C extends A -{ - // commenting out the following line (only) leads to successful compilation - protected val data: List[C] -} - -abstract class D extends C with B[D] {} - -abstract class Ee extends C with B[Ee] -{ -} - - -object N1 extends D -{ - val data = Nil -} - -object N2 extends D -{ - val data = Nil -} - -object N5 extends D -{ - val data = List(N1) -} - -object N6 extends D -{ - val data = List(N1) -} - -object N8 extends D -{ - val data = List(N1) -} - -object N10 extends D -{ - val data = Nil -} - -object N13 extends D -{ - val data = List(N2) -} - -object N14 extends D -{ - val data = List(N5,N10,N8) -} - -object N15 extends D -{ - val data = List(N14) -} - -object N16 extends D -{ - val data = List(N13,N6,N15) -} - -object N17 extends D -{ - val data = List(N16) -} - -object N21 extends D -{ - val data = List(N16) -} - -object N22 extends D -{ - val data = List(N17) -} - -object N25 extends D -{ - val data = List(N22) -} - -object N26 extends Ee -{ - val data = List(N21,N17) -} - -// Commenting out the following object (only) leads to successful compilation -object N31 extends Ee -{ - // If we use List[C](N26,N25), we achieve successful compilation - val data = List(N26,N25) -} diff --git a/test/files/run/existentials.check b/test/files/run/existentials.check index c1bffda530..ba96ae68c0 100644 --- a/test/files/run/existentials.check +++ b/test/files/run/existentials.check @@ -1,3 +1,6 @@ Int 2 Float 2 +Int 2 +Float 2 +Cell(abc) Cell(abc) diff --git a/test/files/run/existentials.scala b/test/files/run/existentials.scala index 76dd705380..b6421bcbaf 100755 --- a/test/files/run/existentials.scala +++ b/test/files/run/existentials.scala @@ -1,9 +1,19 @@ class Foo { class Line { case class Cell[T](var x: T) - def f[T](x: Any): Cell[t1] for_some { type t1 } = x match { case y: Cell[t] => y } + def f[T](x: Any): Cell[t1] forSome { type t1 } = x match { case y: Cell[t] => y } - var x: Cell[T] for_some { type T } = new Cell(1) + var x: Cell[T] forSome { type T } = new Cell(1) + println({ x = new Cell("abc"); x }) + } +} + +class FooW { + class Line { + case class Cell[T](var x: T) + def f[T](x: Any): Cell[ _ ] = x match { case y: Cell[t] => y } + + var x: Cell[_] = new Cell(1) println({ x = new Cell("abc"); x }) } } @@ -21,18 +31,31 @@ object LUB { def y = C("abc") var coinflip: boolean = _ def z = if (coinflip) x else y - def zz: C[_1] for_some { type _1 >: Int with java.lang.String } = z + def zz: C[_1] forSome { type _1 >: Int with java.lang.String } = z + def zzs: C[_ >: Int with java.lang.String] = z } - object Test extends Application { - def foo(x : Counter[T] { def name : String } for_some { type T }) = x match { +object Test extends Application { + + def foo(x : Counter[T] { def name : String } forSome { type T }) = x match { case ctr: Counter[t] => val c = ctr.newCounter println(ctr.name+" "+ctr.get(ctr.inc(ctr.inc(c)))) case _ => } - var ex: Counter[T] for_some { type T } = _ + def fooW(x : Counter[_] { def name : String }) = x match { + case ctr: Counter[t] => + val c = ctr.newCounter + println(ctr.name+" "+ctr.get(ctr.inc(ctr.inc(c)))) + case _ => + } + + var ex: Counter[T] forSome { type T } = _ + ex = ci + ex = cf + + var exW: Counter[_] = _ ex = ci ex = cf @@ -52,6 +75,10 @@ object LUB { foo(ci) foo(cf) + fooW(ci) + fooW(cf) val foo = new Foo new foo.Line + val fooW = new FooW + new fooW.Line } |