blob: 1008bdf7b9bde0f7eefb681216ea98a7f512e88e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
// 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)
// TEST 1
// self-type is other trait
import scala.language.{ reflectiveCalls }
trait Aa
trait Ab
trait B {
self: Aa with Ab =>
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 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 =>
def y = new { def f() = println("Success 3") }
def fail() = {
println('Test)
y.f()
}
}
object Test3 extends B3 {
def test: Unit = { fail() }
}
object Test {
def main(args: Array[String]): Unit = {
Test1.fail()
Test2.fail()
Test3.fail()
}
}
|