diff options
Diffstat (limited to 'test/files')
-rw-r--r-- | test/files/jvm/protectedacc.check | 3 | ||||
-rw-r--r-- | test/files/jvm/protectedacc.scala | 7 | ||||
-rw-r--r-- | test/files/pos/protected-t1010.scala | 27 |
3 files changed, 37 insertions, 0 deletions
diff --git a/test/files/jvm/protectedacc.check b/test/files/jvm/protectedacc.check index 2479af69c0..aaac0d613e 100644 --- a/test/files/jvm/protectedacc.check +++ b/test/files/jvm/protectedacc.check @@ -1,9 +1,12 @@ 10 meth1(1) = 2 +meth1(1.0) = 2.0 meth2(1)(1) = prefix: 0 meth2(1)(1) = prefix: 0 meth3 = class [I 100 = 100 +id(1) = 1 +id('a') = a count before: 3 count after: 4 10 diff --git a/test/files/jvm/protectedacc.scala b/test/files/jvm/protectedacc.scala index fc6d5336d4..f5d05e21b4 100644 --- a/test/files/jvm/protectedacc.scala +++ b/test/files/jvm/protectedacc.scala @@ -29,9 +29,12 @@ package p { protected val x = 10; protected def meth1(x: Int) = x + 1; + protected def meth1(x: Double) = x + 1 protected def meth2(x: Int)(y: String) = y + (x - 1); protected def meth3 = Array(1, 2) + protected def f[a](x: a) = x + def getA: this.type = this; } @@ -78,6 +81,7 @@ package p { def m = { Console.println(x); Console.println("meth1(1) = " + meth1(1)); + Console.println("meth1(1.0) = " + meth1(1.0)); // test accesses from closures for (val x <- 1 until 3) Console.println("meth2(1)(1) = " + meth2(1)("prefix: ")); @@ -87,6 +91,9 @@ package p { val inc = meth2(1)_; Console.println("100 = " + inc("10")); + Console.println("id(1) = " + f(1)) + Console.println("id('a') = " + f("a")) + getA.x; } } diff --git a/test/files/pos/protected-t1010.scala b/test/files/pos/protected-t1010.scala new file mode 100644 index 0000000000..8575ddaaf7 --- /dev/null +++ b/test/files/pos/protected-t1010.scala @@ -0,0 +1,27 @@ +/** Check protected accessors involving polymorphic methods. */ + +package pkg2 { + +trait PresentationsX extends pkg1.Presentations { + trait ProjectImpl extends super.ProjectImpl { + trait FileImpl extends super.FileImpl { + lockTyper(Console.println) + } + } +} + +} // pkg2 + +package pkg1 { + +trait Presentations { + trait ProjectImpl { + trait FileImpl + protected def lockTyper[T](f : => T) = { + if (this == null) None + else Some(f) + } + } +} + +} // pkg1 |