blob: f54bb33d5885101a730d3fb61cc88954577bfa3e (
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
//############################################################################
// Test Java interaction with scala inner classes
//############################################################################
// $Id: $
import java.io.{BufferedReader, File, FileWriter, InputStreamReader}
/** The entry point of this test. It has to come first,
* before the package declarations. The parser wouldn't want it
* any other way.
*/
object Test {
def main(args: Array[String]): Unit = {
val b = new p.b.B;
val c = new b.C;
c.m
val ji = new p.b.JavaInteraction(Array('a', 'b', 'c'));
(new ji.Inner).m;
(new p.b.OuterObj.Inner).m
}
}
package p {
package a {
class A {
protected val x = 10;
protected def meth1(x: Int) = x + 1;
protected def meth2(x: Int)(y: Int) = x + y;
def getA: this.type = this;
}
}
package b {
import a._;
/** Test interraction with Scala inherited methods and currying. */
class B extends A {
class C {
def m = {
Console.println(x);
Console.println("meth1(1) = " + meth1(1));
Console.println("meth2(1)(1) = " + meth2(1)(1));
val inc = &meth2(1);
Console.println("10++ = " + inc(10));
getA.x;
}
}
}
/** Test interaction with Java inherited protected fields. */
class JavaInteraction(arr: Array[Char]) extends java.io.CharArrayReader(arr) {
class Inner {
def m = {
Console.println("count before: " + count);
count = count + 1;
Console.println("count after: " + count);
}
}
}
/** Test interaction when outer is an object. */
object OuterObj extends p.a.A {
class Inner {
def m = {
Console.println(x);
Console.println("meth1(1) = " + meth1(1));
Console.println("meth2(1)(1) = " + meth2(1)(1));
val inc = &meth2(1);
Console.println("10++ = " + inc(10));
getA.x;
}
}
}
}
}
|