blob: a5fb1dd705298abb303387770743988ff4bb511f (
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
|
class Outer(elem: Int, val next: Outer) {
trait InnerTrait {
def foo = elem
}
class InnerClass(x: Int) extends next.InnerTrait {
def bar = elem + x
}
class EmptyInnerClass {
def foo = 1 // still needs outer because it is not private
}
def inner = {
trait InnerTrait {
def foo = elem
}
class InnerClass(x: Int) extends next.InnerTrait {
def bar = elem + x
}
class EmptyInnerClass {
def foo = 1 // does not need outer
}
val ic = new InnerClass(1)
println(ic.bar)
println(ic.foo)
val it = new InnerTrait {}
println(it.foo)
val ec = new EmptyInnerClass
}
}
object Test extends App {
val o = new Outer(1, new Outer(2, null))
val ic = new o.InnerClass(1)
println(ic.bar)
println(ic.foo)
val it = new o.InnerTrait {}
println(it.foo)
val ec = new o.EmptyInnerClass
o.inner
}
|