diff options
author | Iulian Dragos <jaguarul@gmail.com> | 2006-10-26 13:45:28 +0000 |
---|---|---|
committer | Iulian Dragos <jaguarul@gmail.com> | 2006-10-26 13:45:28 +0000 |
commit | 3f8b526dd8375edf30ac8e8236ae6ca195d4990a (patch) | |
tree | 193c615c00d53a7de46f8b4626088f799194a7a0 /test/files/jvm | |
parent | 2fd723d1cdcfb7435f2fa947acff6eaf308ba778 (diff) | |
download | scala-3f8b526dd8375edf30ac8e8236ae6ca195d4990a.tar.gz scala-3f8b526dd8375edf30ac8e8236ae6ca195d4990a.tar.bz2 scala-3f8b526dd8375edf30ac8e8236ae6ca195d4990a.zip |
Added protected accessors in super accessors.
Diffstat (limited to 'test/files/jvm')
-rw-r--r-- | test/files/jvm/protectedacc.check | 10 | ||||
-rw-r--r-- | test/files/jvm/protectedacc.scala | 84 |
2 files changed, 94 insertions, 0 deletions
diff --git a/test/files/jvm/protectedacc.check b/test/files/jvm/protectedacc.check new file mode 100644 index 0000000000..632c9dabe7 --- /dev/null +++ b/test/files/jvm/protectedacc.check @@ -0,0 +1,10 @@ +10 +meth1(1) = 2 +meth2(1)(1) = 2 +10++ = 11 +count before: 3 +count after: 4 +10 +meth1(1) = 2 +meth2(1)(1) = 2 +10++ = 11 diff --git a/test/files/jvm/protectedacc.scala b/test/files/jvm/protectedacc.scala new file mode 100644 index 0000000000..f54bb33d58 --- /dev/null +++ b/test/files/jvm/protectedacc.scala @@ -0,0 +1,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; + } + } + } + } +} |