diff options
author | Josh Suereth <Joshua.Suereth@gmail.com> | 2012-07-29 07:16:23 -0700 |
---|---|---|
committer | Josh Suereth <Joshua.Suereth@gmail.com> | 2012-07-29 07:16:23 -0700 |
commit | e95691996d3df58499491db6c5b6d386b64cefdc (patch) | |
tree | d5aca3dfa840e452e0f74a2026e68d59e0afbdcc /test | |
parent | 9cf4dd6bbeccc6a1ec2e8dbdbcf9aaa59b5bf91f (diff) | |
parent | cf709c2dd23b7f1f659e52bcb8beb098c5d02d50 (diff) | |
download | scala-e95691996d3df58499491db6c5b6d386b64cefdc.tar.gz scala-e95691996d3df58499491db6c5b6d386b64cefdc.tar.bz2 scala-e95691996d3df58499491db6c5b6d386b64cefdc.zip |
Merge pull request #988 from paulp/issue/4560
Issue/4560
Diffstat (limited to 'test')
-rw-r--r-- | test/files/run/t4560.check | 8 | ||||
-rw-r--r-- | test/files/run/t4560.scala | 65 | ||||
-rw-r--r-- | test/files/run/t4560b.check | 2 | ||||
-rw-r--r-- | test/files/run/t4560b.scala | 28 | ||||
-rw-r--r-- | test/pending/run/t4560.scala | 9 |
5 files changed, 82 insertions, 30 deletions
diff --git a/test/files/run/t4560.check b/test/files/run/t4560.check index fd3c81a4d7..f8cb0833ae 100644 --- a/test/files/run/t4560.check +++ b/test/files/run/t4560.check @@ -1,2 +1,6 @@ -5 -5 +'Test +Success 1 +'Test +Success 2 +'Test +Success 3 diff --git a/test/files/run/t4560.scala b/test/files/run/t4560.scala index 1392077e46..9979199067 100644 --- a/test/files/run/t4560.scala +++ b/test/files/run/t4560.scala @@ -1,39 +1,66 @@ -object Pimper { - implicit def pimp(i: Int) = new { - def test: String = i.toString - } -} +// SI-4560 (and SI-4601): Reflection caches are expected in the wrong classfiles +// with various differing constellations of self-types. This leads to runtime exceptions +// when the reflection caches are accessed. This tests both reflection cache accesses +// for structural type method invocations (`y.f()`) (SI-4560) and accesses to symbols which are +// handled similarly (SI-4601) -trait A +// TEST 1 +// self-type is other trait -trait B { - self: A => +trait Aa +trait Ab - def test { - import Pimper.pimp +trait B { + self: Aa with Ab => - println(5.test) + def y = new { def f() = println("Success 1") } + def fail() = { + println('Test) + y.f() } } +object Test1 extends Aa with Ab with B + +// TEST 2 +// self-type is class + class A2 trait B2 { self: A2 => - def test { - import Pimper.pimp + def y = new { def f() = println("Success 2") } + def fail() = { + println('Test) + y.f() + } +} + +object Test2 extends A2 with B2 + +// TEST 3 +// self-type is singleton type + +trait B3 { + this: Test3.type => - println(5.test) + def y = new { def f() = println("Success 3") } + def fail() = { + println('Test) + y.f() } } -object Test extends A with B { +object Test3 extends B3 { + def test { fail() } +} + +object Test { def main(args: Array[String]) { - test - Test2.test + Test1.fail() + Test2.fail() + Test3.fail() } } -object Test2 extends A2 with B2 - diff --git a/test/files/run/t4560b.check b/test/files/run/t4560b.check new file mode 100644 index 0000000000..7ee6e19b28 --- /dev/null +++ b/test/files/run/t4560b.check @@ -0,0 +1,2 @@ +23 +SUCCESS diff --git a/test/files/run/t4560b.scala b/test/files/run/t4560b.scala new file mode 100644 index 0000000000..97fe00ce37 --- /dev/null +++ b/test/files/run/t4560b.scala @@ -0,0 +1,28 @@ +object Outer { + class Tester + private[Outer] trait B4 { _: Tester => + protected val FREQ = 23 + def fail() = { + println(FREQ) + } + } + object C4 extends Tester with B4 +} + +object Outer2 { + abstract class A5 + private[Outer2] trait C5 { + def impl() { println("SUCCESS") } + } + trait B5 extends C5 { self: A5 => + def fail() { impl() } + } + object Test5 extends A5 with B5 with C5 +} + +object Test { + def main(args: Array[String]): Unit = { + Outer.C4.fail() + Outer2.Test5.fail() + } +} diff --git a/test/pending/run/t4560.scala b/test/pending/run/t4560.scala deleted file mode 100644 index fe62136319..0000000000 --- a/test/pending/run/t4560.scala +++ /dev/null @@ -1,9 +0,0 @@ -trait B { - this: Test.type => - - def y = new { def f() = () } - def fail() = y.f() -} -object Test extends B { - def main(args: Array[String]): Unit = fail() -}
\ No newline at end of file |