diff options
author | Paul Phillips <paulp@improving.org> | 2012-05-11 07:52:27 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-05-23 08:43:10 -0700 |
commit | 402b5e4a1341ef4549b7e0979f9c5afc06f47315 (patch) | |
tree | 0ec0f5dbd51874d9ed9d4676451d553474eb8fd1 /test/pending | |
parent | 0d7952f90fc11f4dc055a2658b16b7183f1d6683 (diff) | |
download | scala-402b5e4a1341ef4549b7e0979f9c5afc06f47315.tar.gz scala-402b5e4a1341ef4549b7e0979f9c5afc06f47315.tar.bz2 scala-402b5e4a1341ef4549b7e0979f9c5afc06f47315.zip |
Pending and passing tests.
Move now-passing SI-963 test into neg.
Test for partial specialization.
Pending test for SI-5008.
Pending test for SI-4649.
Abstract array type test.
Diffstat (limited to 'test/pending')
-rw-r--r-- | test/pending/neg/t5008.scala | 165 | ||||
-rw-r--r-- | test/pending/neg/t963.scala | 26 | ||||
-rw-r--r-- | test/pending/pos/t4649.flags | 1 | ||||
-rw-r--r-- | test/pending/pos/t4649.scala | 6 | ||||
-rw-r--r-- | test/pending/run/partial-anyref-spec.check | 13 | ||||
-rw-r--r-- | test/pending/run/partial-anyref-spec.scala | 31 |
6 files changed, 216 insertions, 26 deletions
diff --git a/test/pending/neg/t5008.scala b/test/pending/neg/t5008.scala new file mode 100644 index 0000000000..2b20bcfe12 --- /dev/null +++ b/test/pending/neg/t5008.scala @@ -0,0 +1,165 @@ +// These are members of class bar.C, completely unrelated to class foo.A. +// The types shown below include types defined within foo.A which are: +// +// - qualified private +// - qualified protected +// - object protected +// +// val a : foo.A = { /* compiled code */ } +// val xprot1 : java.lang.Object with foo.A.FooProt1 = { /* compiled code */ } +// val xprot2 : java.lang.Object with foo.A.FooProt2 = { /* compiled code */ } +// val xprot3 : java.lang.Object with foo.A.FooProt3 = { /* compiled code */ } +// val xprot4 : java.lang.Object with foo.A.FooProt4 = { /* compiled code */ } +// val xpriv3 : java.lang.Object with foo.A.FooPriv3 = { /* compiled code */ } +// val xpriv4 : java.lang.Object with foo.A.FooPriv4 = { /* compiled code */ } +// +// Indeed it will tell me a type which I cannot access: +// +// scala> new bar.C +// res0: bar.C = bar.C@1339a0dc +// +// scala> res0.xpriv3 +// res1: java.lang.Object with res0.a.FooPriv3 = bar.C$$anon$29@39556aec +// +// scala> new res0.a.FooPriv3 +// <console>:9: error: trait FooPriv3 in class A cannot be accessed in foo.A +// new res0.a.FooPriv3 +// ^ +// Looking at how the compiler prints the types of those vals, one +// develops a suspicion how some of it is being allowed: +// +// val xpriv4: C.this.a.FooPriv4 +// val xpriv3: C.this.a.FooPriv3 +// val xprot4: C.this.a.FooProt4 +// val xprot3: C.this.a.FooProt3 +// val xprot2: C.this.a.FooProt2 +// val xprot1: C.this.a.FooProt1 +// +// That is, "this" is in the prefix somewhere, it's just not a "this" +// which has any bearing. + +package foo { + class A { + trait Foo + + protected trait FooProt1 + protected[this] trait FooProt2 + protected[foo] trait FooProt3 + protected[A] trait FooProt4 + + private trait FooPriv1 + private[this] trait FooPriv2 + private[foo] trait FooPriv3 + private[A] trait FooPriv4 + + type BarProt1 = FooProt1 + type BarProt2 = FooProt2 + type BarProt3 = FooProt3 + type BarProt4 = FooProt4 + + // type BarPriv1 = FooPriv1 + // type BarPriv2 = FooPriv2 + type BarPriv3 = FooPriv3 + type BarPriv4 = FooPriv4 + + def fprot1(x: FooProt1) = x + def fprot2(x: FooProt2) = x + def fprot3(x: FooProt3) = x + def fprot4(x: FooProt4) = x + + // def fpriv1(x: FooPriv1) = x + // def fpriv2(x: FooPriv2) = x + def fpriv3(x: FooPriv3) = x + def fpriv4(x: FooPriv4) = x + + val yprot1 = new FooProt1 { } + val yprot2 = new FooProt2 { } + val yprot3 = new FooProt3 { } + val yprot4 = new FooProt4 { } + + // val ypriv1 = new FooPriv1 { } + // val ypriv2 = new FooPriv2 { } + val ypriv3 = new FooPriv3 { } + val ypriv4 = new FooPriv4 { } + + def fpriv_alt1(x: FooPriv1) = 0 // !!! isn't the private type now in the signature of the (public) method? + def fpriv_alt2(x: FooPriv2) = 0 // !!! isn't the private[this] type now in the signature of the (public) method? + } + // Same package, subclass + class B extends A { + val xprot1 = new BarProt1 { } + val xprot2 = new BarProt2 { } + val xprot3 = new BarProt3 { } + val xprot4 = new BarProt4 { } + + // val xpriv1 = new BarPriv1 { } + // val xpriv2 = new BarPriv2 { } + val xpriv3 = new BarPriv3 { } + val xpriv4 = new BarPriv4 { } + + override def fprot1(x: BarProt1) = x + override def fprot2(x: BarProt2) = x + override def fprot3(x: BarProt3) = x + override def fprot4(x: BarProt4) = x + + // override def fpriv1(x: BarPriv1) = x + // override def fpriv2(x: BarPriv2) = x + override def fpriv3(x: BarPriv3) = x + override def fpriv4(x: BarPriv4) = x + } + // Same package, unrelated class + class C { + val a = new A + import a._ + + val xprot1 = new BarProt1 { } + val xprot2 = new BarProt2 { } + val xprot3 = new BarProt3 { } + val xprot4 = new BarProt4 { } + + // val xpriv1 = new BarPriv1 { } + // val xpriv2 = new BarPriv2 { } + val xpriv3 = new BarPriv3 { } + val xpriv4 = new BarPriv4 { } + } +} + +package bar { + // Different package, subclass + class B extends foo.A { + val xprot1 = new BarProt1 { } + val xprot2 = new BarProt2 { } + val xprot3 = new BarProt3 { } + val xprot4 = new BarProt4 { } + + // val xpriv1 = new BarPriv1 { } + // val xpriv2 = new BarPriv2 { } + val xpriv3 = new BarPriv3 { } + val xpriv4 = new BarPriv4 { } + + override def fprot1(x: BarProt1) = x + override def fprot2(x: BarProt2) = x + override def fprot3(x: BarProt3) = x + override def fprot4(x: BarProt4) = x + + // override def fpriv1(x: BarPriv1) = x + // override def fpriv2(x: BarPriv2) = x + override def fpriv3(x: BarPriv3) = x + override def fpriv4(x: BarPriv4) = x + } + // Different package, unrelated class + class C { + val a = new foo.A + import a._ + + val xprot1 = new BarProt1 { } + val xprot2 = new BarProt2 { } + val xprot3 = new BarProt3 { } + val xprot4 = new BarProt4 { } + + // val xpriv1 = new BarPriv1 { } + // val xpriv2 = new BarPriv2 { } + val xpriv3 = new BarPriv3 { } + val xpriv4 = new BarPriv4 { } + } +} diff --git a/test/pending/neg/t963.scala b/test/pending/neg/t963.scala deleted file mode 100644 index 3be0be1b84..0000000000 --- a/test/pending/neg/t963.scala +++ /dev/null @@ -1,26 +0,0 @@ -// Soundness bug, at #963 and dup at #2079. -trait A { - type T - var v : T -} - -object B { - def f(x : { val y : A }) { x.y.v = x.y.v } - - var a : A = _ - var b : Boolean = false - def y : A = { - if(b) { - a = new A { type T = Int; var v = 1 } - a - } else { - a = new A { type T = String; var v = "" } - b = true - a - } - } -} - -object Test extends Application { - B.f(B) -} diff --git a/test/pending/pos/t4649.flags b/test/pending/pos/t4649.flags new file mode 100644 index 0000000000..e8fb65d50c --- /dev/null +++ b/test/pending/pos/t4649.flags @@ -0,0 +1 @@ +-Xfatal-warnings
\ No newline at end of file diff --git a/test/pending/pos/t4649.scala b/test/pending/pos/t4649.scala new file mode 100644 index 0000000000..0d6caa8d7a --- /dev/null +++ b/test/pending/pos/t4649.scala @@ -0,0 +1,6 @@ +object Test { + // @annotation.tailrec + def lazyFilter[E](s: Stream[E], p: E => Boolean): Stream[E] = s match { + case h #:: t => if (p(h)) h #:: lazyFilter(t, p) else lazyFilter(t, p) + } +} diff --git a/test/pending/run/partial-anyref-spec.check b/test/pending/run/partial-anyref-spec.check new file mode 100644 index 0000000000..26e41933e7 --- /dev/null +++ b/test/pending/run/partial-anyref-spec.check @@ -0,0 +1,13 @@ +Fn$mcII$sp +Fn$mcLI$sp +Fn$mcLI$sp +Fn$mcIL$sp +Fn +Fn +Fn$mcIL$sp +Fn +Fn +Fn3 +Fn3$mcLIDF$sp +Fn3$mcBIDF$sp +Fn3 diff --git a/test/pending/run/partial-anyref-spec.scala b/test/pending/run/partial-anyref-spec.scala new file mode 100644 index 0000000000..49ed514f03 --- /dev/null +++ b/test/pending/run/partial-anyref-spec.scala @@ -0,0 +1,31 @@ +class Fn[@specialized(Int, AnyRef) -T, @specialized(Int, AnyRef) +R] { + override def toString = getClass.getName +} + +class Fn3[ + @specialized(Int, AnyRef) -T1, + @specialized(Double, AnyRef) -T2, + @specialized(Float) -T3, + @specialized(Byte, AnyRef) +R +] { + override def toString = getClass.getName +} + +object Test { + def main(args: Array[String]): Unit = { + println(new Fn[Int, Int]) + println(new Fn[Int, Byte]) + println(new Fn[Int, AnyRef]) + println(new Fn[Byte, Int]) + println(new Fn[Byte, Byte]) + println(new Fn[Byte, AnyRef]) + println(new Fn[AnyRef, Int]) + println(new Fn[AnyRef, Byte]) + println(new Fn[AnyRef, AnyRef]) + + println(new Fn3[Int, Int, Int, Int]) + println(new Fn3[Int, Double, Float, Int]) + println(new Fn3[Int, Double, Float, Byte]) + println(new Fn3[AnyRef, Double, AnyRef, Int]) + } +} |