diff options
author | Johannes Rudolph <johannes_rudolph@gmx.de> | 2012-07-22 11:46:02 +0200 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-07-24 20:51:39 -0700 |
commit | cf709c2dd23b7f1f659e52bcb8beb098c5d02d50 (patch) | |
tree | 97a1bc815852d2b2dc1a3209142267a5645f8114 /test/files/run | |
parent | c8bdf199476fdd113d28b23793b5e871390cf825 (diff) | |
download | scala-cf709c2dd23b7f1f659e52bcb8beb098c5d02d50.tar.gz scala-cf709c2dd23b7f1f659e52bcb8beb098c5d02d50.tar.bz2 scala-cf709c2dd23b7f1f659e52bcb8beb098c5d02d50.zip |
SI-4560 - improved test
Added all the known cases of failing self-types. Added tests for symbol
access (SI-4601) as well which should now be fixed for all of the same cases
as well.
Diffstat (limited to 'test/files/run')
-rw-r--r-- | test/files/run/t4560.check | 8 | ||||
-rw-r--r-- | test/files/run/t4560.scala | 65 |
2 files changed, 52 insertions, 21 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 - |