From e498fac7fdbda3187a2a4fffcdf7fa4f9ddb7ac8 Mon Sep 17 00:00:00 2001 From: amin Date: Tue, 11 Sep 2012 15:09:03 +0200 Subject: Fix for SI-6245 with workaround for SI-2296. protected/super accessor issue: Don't subvert the creation of the standard protected accessor with the java interop accessor. For SI-2296, the compiler emits an error instead of causing an illegal access error at runtime. --- test/files/neg/t2296a.check | 5 +++++ test/files/neg/t2296a/J.java | 7 +++++++ test/files/neg/t2296a/S.scala | 18 ++++++++++++++++++ test/files/neg/t2296b.check | 5 +++++ test/files/neg/t2296b/J_1.java | 7 +++++++ test/files/neg/t2296b/S_2.scala | 18 ++++++++++++++++++ test/files/pos/t6245/Base.java | 5 +++++ test/files/pos/t6245/Foo.scala | 9 +++++++++ test/files/pos/t6245/Vis.java | 3 +++ test/files/run/t2296a.check | 2 -- test/files/run/t2296a/J.java | 7 ------- test/files/run/t2296a/S.scala | 18 ------------------ test/files/run/t2296b.check | 2 -- test/files/run/t2296b/J_1.java | 7 ------- test/files/run/t2296b/S_2.scala | 18 ------------------ 15 files changed, 77 insertions(+), 54 deletions(-) create mode 100644 test/files/neg/t2296a.check create mode 100644 test/files/neg/t2296a/J.java create mode 100644 test/files/neg/t2296a/S.scala create mode 100644 test/files/neg/t2296b.check create mode 100644 test/files/neg/t2296b/J_1.java create mode 100644 test/files/neg/t2296b/S_2.scala create mode 100644 test/files/pos/t6245/Base.java create mode 100644 test/files/pos/t6245/Foo.scala create mode 100644 test/files/pos/t6245/Vis.java delete mode 100644 test/files/run/t2296a.check delete mode 100644 test/files/run/t2296a/J.java delete mode 100644 test/files/run/t2296a/S.scala delete mode 100644 test/files/run/t2296b.check delete mode 100644 test/files/run/t2296b/J_1.java delete mode 100644 test/files/run/t2296b/S_2.scala (limited to 'test') diff --git a/test/files/neg/t2296a.check b/test/files/neg/t2296a.check new file mode 100644 index 0000000000..863b861046 --- /dev/null +++ b/test/files/neg/t2296a.check @@ -0,0 +1,5 @@ +S.scala:6: error: Implementation restriction: trait S accesses protected method foo inside a concrete trait method. +Add an accessor in a class extending class J as a workaround. + foo() + ^ +one error found diff --git a/test/files/neg/t2296a/J.java b/test/files/neg/t2296a/J.java new file mode 100644 index 0000000000..78ff3e9804 --- /dev/null +++ b/test/files/neg/t2296a/J.java @@ -0,0 +1,7 @@ +package j; + +public class J { + protected void foo() { + System.out.println("J.foo()"); + } +} \ No newline at end of file diff --git a/test/files/neg/t2296a/S.scala b/test/files/neg/t2296a/S.scala new file mode 100644 index 0000000000..532d038a42 --- /dev/null +++ b/test/files/neg/t2296a/S.scala @@ -0,0 +1,18 @@ +package s { + import j.J + + trait S extends J { + def bar() { + foo() + } + } + + class SC extends J with S +} + +object Test { + def main(args : Array[String]) { + (new s.SC).bar() + (new s.S { }).bar() + } +} \ No newline at end of file diff --git a/test/files/neg/t2296b.check b/test/files/neg/t2296b.check new file mode 100644 index 0000000000..07cc54d573 --- /dev/null +++ b/test/files/neg/t2296b.check @@ -0,0 +1,5 @@ +S_2.scala:6: error: Implementation restriction: trait S accesses protected method foo inside a concrete trait method. +Add an accessor in a class extending class J_1 as a workaround. + foo() + ^ +one error found diff --git a/test/files/neg/t2296b/J_1.java b/test/files/neg/t2296b/J_1.java new file mode 100644 index 0000000000..4c91d47073 --- /dev/null +++ b/test/files/neg/t2296b/J_1.java @@ -0,0 +1,7 @@ +package j; + +public class J_1 { + protected void foo() { + System.out.println("J.foo()"); + } +} \ No newline at end of file diff --git a/test/files/neg/t2296b/S_2.scala b/test/files/neg/t2296b/S_2.scala new file mode 100644 index 0000000000..6cdb0cfaba --- /dev/null +++ b/test/files/neg/t2296b/S_2.scala @@ -0,0 +1,18 @@ +package s { + import j.J_1 + + trait S extends J_1 { + def bar() { + foo() + } + } + + class SC extends J_1 with S +} + +object Test { + def main(args : Array[String]) { + (new s.SC).bar() + (new s.S { }).bar() + } +} diff --git a/test/files/pos/t6245/Base.java b/test/files/pos/t6245/Base.java new file mode 100644 index 0000000000..651ea08bf2 --- /dev/null +++ b/test/files/pos/t6245/Base.java @@ -0,0 +1,5 @@ +package t1; + +public class Base { + protected Vis inner; +} diff --git a/test/files/pos/t6245/Foo.scala b/test/files/pos/t6245/Foo.scala new file mode 100644 index 0000000000..f5f997fbff --- /dev/null +++ b/test/files/pos/t6245/Foo.scala @@ -0,0 +1,9 @@ +import t1.Vis + +abstract class Foo extends t1.Base { + trait Nested { + def crash() { + inner + } + } +} diff --git a/test/files/pos/t6245/Vis.java b/test/files/pos/t6245/Vis.java new file mode 100644 index 0000000000..4267f4e40b --- /dev/null +++ b/test/files/pos/t6245/Vis.java @@ -0,0 +1,3 @@ +package t1; + +public class Vis { } diff --git a/test/files/run/t2296a.check b/test/files/run/t2296a.check deleted file mode 100644 index f75aec9d81..0000000000 --- a/test/files/run/t2296a.check +++ /dev/null @@ -1,2 +0,0 @@ -J.foo() -J.foo() diff --git a/test/files/run/t2296a/J.java b/test/files/run/t2296a/J.java deleted file mode 100644 index 78ff3e9804..0000000000 --- a/test/files/run/t2296a/J.java +++ /dev/null @@ -1,7 +0,0 @@ -package j; - -public class J { - protected void foo() { - System.out.println("J.foo()"); - } -} \ No newline at end of file diff --git a/test/files/run/t2296a/S.scala b/test/files/run/t2296a/S.scala deleted file mode 100644 index 532d038a42..0000000000 --- a/test/files/run/t2296a/S.scala +++ /dev/null @@ -1,18 +0,0 @@ -package s { - import j.J - - trait S extends J { - def bar() { - foo() - } - } - - class SC extends J with S -} - -object Test { - def main(args : Array[String]) { - (new s.SC).bar() - (new s.S { }).bar() - } -} \ No newline at end of file diff --git a/test/files/run/t2296b.check b/test/files/run/t2296b.check deleted file mode 100644 index f75aec9d81..0000000000 --- a/test/files/run/t2296b.check +++ /dev/null @@ -1,2 +0,0 @@ -J.foo() -J.foo() diff --git a/test/files/run/t2296b/J_1.java b/test/files/run/t2296b/J_1.java deleted file mode 100644 index 4c91d47073..0000000000 --- a/test/files/run/t2296b/J_1.java +++ /dev/null @@ -1,7 +0,0 @@ -package j; - -public class J_1 { - protected void foo() { - System.out.println("J.foo()"); - } -} \ No newline at end of file diff --git a/test/files/run/t2296b/S_2.scala b/test/files/run/t2296b/S_2.scala deleted file mode 100644 index 6cdb0cfaba..0000000000 --- a/test/files/run/t2296b/S_2.scala +++ /dev/null @@ -1,18 +0,0 @@ -package s { - import j.J_1 - - trait S extends J_1 { - def bar() { - foo() - } - } - - class SC extends J_1 with S -} - -object Test { - def main(args : Array[String]) { - (new s.SC).bar() - (new s.S { }).bar() - } -} -- cgit v1.2.3