summaryrefslogtreecommitdiff
path: root/test/files
diff options
context:
space:
mode:
authorIulian Dragos <jaguarul@gmail.com>2007-11-21 14:28:19 +0000
committerIulian Dragos <jaguarul@gmail.com>2007-11-21 14:28:19 +0000
commite32400681a1370b5279afdae3a5501311a6bc340 (patch)
tree153114fe793141a0a7cab4025de7864236d6a27b /test/files
parent1bdf2c4ebf0a863756192d4879102710e839fec2 (diff)
downloadscala-e32400681a1370b5279afdae3a5501311a6bc340.tar.gz
scala-e32400681a1370b5279afdae3a5501311a6bc340.tar.bz2
scala-e32400681a1370b5279afdae3a5501311a6bc340.zip
Fixed ticket #10
Diffstat (limited to 'test/files')
-rw-r--r--test/files/jvm/protectedacc.check3
-rw-r--r--test/files/jvm/protectedacc.scala7
-rw-r--r--test/files/pos/protected-t1010.scala27
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