diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2013-02-08 02:34:46 -0800 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2013-02-08 02:34:46 -0800 |
commit | 9164c2af4183e04986eb652e09081daba3d0d279 (patch) | |
tree | ad7040b0d065ccc05d819b3fe658cf144227bd14 /test | |
parent | 3d75d217b2cc9199c2698ed8da100fe92b1db2be (diff) | |
parent | b43ae58f312e4769de5a6942b4cb820cd609f31b (diff) | |
download | scala-9164c2af4183e04986eb652e09081daba3d0d279.tar.gz scala-9164c2af4183e04986eb652e09081daba3d0d279.tar.bz2 scala-9164c2af4183e04986eb652e09081daba3d0d279.zip |
Merge pull request #2035 from scalamacros/ticket/6989
SI-6989 privateWithin is now populated in reflect
Diffstat (limited to 'test')
-rw-r--r-- | test/files/run/t6989.check | 216 | ||||
-rw-r--r-- | test/files/run/t6989/JavaClass_1.java | 41 | ||||
-rw-r--r-- | test/files/run/t6989/Test_2.scala | 42 |
3 files changed, 299 insertions, 0 deletions
diff --git a/test/files/run/t6989.check b/test/files/run/t6989.check new file mode 100644 index 0000000000..8943792115 --- /dev/null +++ b/test/files/run/t6989.check @@ -0,0 +1,216 @@ +============ +sym = class PackagePrivateJavaClass, signature = ClassInfoType(...), owner = package foo +isPrivate = false +isProtected = false +isPublic = false +privateWithin = package foo +============ +sym = constructor PackagePrivateJavaClass, signature = (x$1: Int, x$2: Int)foo.PackagePrivateJavaClass, owner = class PackagePrivateJavaClass +isPrivate = false +isProtected = false +isPublic = true +privateWithin = <none> +============ +sym = variable privateField, signature = Int, owner = class PackagePrivateJavaClass +isPrivate = true +isProtected = false +isPublic = false +privateWithin = <none> +============ +sym = method privateMethod, signature = ()Unit, owner = class PackagePrivateJavaClass +isPrivate = true +isProtected = false +isPublic = false +privateWithin = <none> +============ +sym = variable protectedField, signature = Int, owner = class PackagePrivateJavaClass +isPrivate = false +isProtected = true +isPublic = false +privateWithin = package foo +============ +sym = method protectedMethod, signature = ()Unit, owner = class PackagePrivateJavaClass +isPrivate = false +isProtected = true +isPublic = false +privateWithin = package foo +============ +sym = variable publicField, signature = Int, owner = class PackagePrivateJavaClass +isPrivate = false +isProtected = false +isPublic = true +privateWithin = <none> +============ +sym = method publicMethod, signature = ()Unit, owner = class PackagePrivateJavaClass +isPrivate = false +isProtected = false +isPublic = true +privateWithin = <none> +============ +sym = object PackagePrivateJavaClass, signature = foo.PackagePrivateJavaClass.type, owner = package foo +isPrivate = false +isProtected = false +isPublic = false +privateWithin = package foo +============ +sym = variable privateStaticField, signature = Int, owner = object PackagePrivateJavaClass +isPrivate = true +isProtected = false +isPublic = false +privateWithin = <none> +============ +sym = method privateStaticMethod, signature = ()Unit, owner = object PackagePrivateJavaClass +isPrivate = true +isProtected = false +isPublic = false +privateWithin = <none> +============ +sym = variable protectedStaticField, signature = Int, owner = object PackagePrivateJavaClass +isPrivate = false +isProtected = true +isPublic = false +privateWithin = package foo +============ +sym = method protectedStaticMethod, signature = ()Unit, owner = object PackagePrivateJavaClass +isPrivate = false +isProtected = true +isPublic = false +privateWithin = package foo +============ +sym = variable publicStaticField, signature = Int, owner = object PackagePrivateJavaClass +isPrivate = false +isProtected = false +isPublic = true +privateWithin = <none> +============ +sym = method publicStaticMethod, signature = ()Unit, owner = object PackagePrivateJavaClass +isPrivate = false +isProtected = false +isPublic = true +privateWithin = <none> +============ +sym = class JavaClass_1, signature = ClassInfoType(...), owner = package foo +isPrivate = false +isProtected = false +isPublic = true +privateWithin = <none> +============ +sym = class $PrivateJavaClass, signature = ClassInfoType(...), owner = class JavaClass_1 +isPrivate = true +isProtected = false +isPublic = false +privateWithin = <none> +============ +sym = value this$0, signature = foo.JavaClass_1, owner = class $PrivateJavaClass +isPrivate = false +isProtected = false +isPublic = false +privateWithin = package foo +============ +sym = object $PrivateJavaClass, signature = JavaClass_1.this.$PrivateJavaClass.type, owner = class JavaClass_1 +isPrivate = true +isProtected = false +isPublic = false +privateWithin = <none> +============ +sym = class $ProtectedJavaClass, signature = ClassInfoType(...), owner = class JavaClass_1 +isPrivate = false +isProtected = true +isPublic = false +privateWithin = package foo +============ +sym = value this$0, signature = foo.JavaClass_1, owner = class $ProtectedJavaClass +isPrivate = false +isProtected = false +isPublic = false +privateWithin = package foo +============ +sym = object $ProtectedJavaClass, signature = JavaClass_1.this.$ProtectedJavaClass.type, owner = class JavaClass_1 +isPrivate = false +isProtected = false +isPublic = false +privateWithin = package foo +============ +sym = class $PublicJavaClass, signature = ClassInfoType(...), owner = class JavaClass_1 +isPrivate = false +isProtected = false +isPublic = true +privateWithin = <none> +============ +sym = constructor $PublicJavaClass, signature = (x$1: foo.JavaClass_1)JavaClass_1.this.$PublicJavaClass, owner = class $PublicJavaClass +isPrivate = false +isProtected = false +isPublic = true +privateWithin = <none> +============ +sym = value this$0, signature = foo.JavaClass_1, owner = class $PublicJavaClass +isPrivate = false +isProtected = false +isPublic = false +privateWithin = package foo +============ +sym = object $PublicJavaClass, signature = JavaClass_1.this.$PublicJavaClass.type, owner = class JavaClass_1 +isPrivate = false +isProtected = false +isPublic = true +privateWithin = <none> +============ +sym = constructor JavaClass_1, signature = ()foo.JavaClass_1, owner = class JavaClass_1 +isPrivate = false +isProtected = false +isPublic = true +privateWithin = <none> +============ +sym = object JavaClass_1, signature = foo.JavaClass_1.type, owner = package foo +isPrivate = false +isProtected = false +isPublic = true +privateWithin = <none> +============ +sym = class PrivateStaticJavaClass, signature = ClassInfoType(...), owner = object JavaClass_1 +isPrivate = true +isProtected = false +isPublic = false +privateWithin = <none> +============ +sym = object PrivateStaticJavaClass, signature = foo.JavaClass_1.PrivateStaticJavaClass.type, owner = object JavaClass_1 +isPrivate = true +isProtected = false +isPublic = false +privateWithin = <none> +============ +sym = class ProtectedStaticJavaClass, signature = ClassInfoType(...), owner = object JavaClass_1 +isPrivate = true +isProtected = false +isPublic = false +privateWithin = <none> +============ +sym = object ProtectedStaticJavaClass, signature = foo.JavaClass_1.ProtectedStaticJavaClass.type, owner = object JavaClass_1 +isPrivate = true +isProtected = false +isPublic = false +privateWithin = <none> +============ +sym = class PublicStaticJavaClass, signature = ClassInfoType(...), owner = object JavaClass_1 +isPrivate = false +isProtected = false +isPublic = true +privateWithin = <none> +============ +sym = constructor PublicStaticJavaClass, signature = ()foo.JavaClass_1.PublicStaticJavaClass, owner = class PublicStaticJavaClass +isPrivate = false +isProtected = false +isPublic = true +privateWithin = <none> +============ +sym = object PublicStaticJavaClass, signature = foo.JavaClass_1.PublicStaticJavaClass.type, owner = object JavaClass_1 +isPrivate = false +isProtected = false +isPublic = true +privateWithin = <none> +============ +sym = variable staticField, signature = Int, owner = object JavaClass_1 +isPrivate = true +isProtected = false +isPublic = false +privateWithin = <none> diff --git a/test/files/run/t6989/JavaClass_1.java b/test/files/run/t6989/JavaClass_1.java new file mode 100644 index 0000000000..eb26a08700 --- /dev/null +++ b/test/files/run/t6989/JavaClass_1.java @@ -0,0 +1,41 @@ +package foo; + +// Originally composed to accommodate pull request feedback, this test has +// uncovered a handful of bugs in FromJavaClassCompleter, namely: +// * SI-7071 non-public ctors get lost +// * SI-7072 inner classes are read incorrectly + +// I'm leaving the incorrect results of FromJavaClassCompleters in the check +// file, so that we get notified when something changes there. + +class PackagePrivateJavaClass { + private int privateField = 0; + protected int protectedField = 1; + public int publicField = 2; + + private static int privateStaticField = 3; + protected static int protectedStaticField = 4; + public static int publicStaticField = 5; + + private void privateMethod() {} + protected void protectedMethod() {} + public void publicMethod() {} + + private static void privateStaticMethod() {} + protected static void protectedStaticMethod() {} + public static void publicStaticMethod() {} + + private PackagePrivateJavaClass() {} + protected PackagePrivateJavaClass(int x) {} + public PackagePrivateJavaClass(int x, int y) {} +} + +public class JavaClass_1 { + private class PrivateJavaClass {} + private static class PrivateStaticJavaClass {} + protected class ProtectedJavaClass {} + private static class ProtectedStaticJavaClass {} + public class PublicJavaClass {} + public static class PublicStaticJavaClass {} + private static int staticField = 0; +}
\ No newline at end of file diff --git a/test/files/run/t6989/Test_2.scala b/test/files/run/t6989/Test_2.scala new file mode 100644 index 0000000000..e48e82422d --- /dev/null +++ b/test/files/run/t6989/Test_2.scala @@ -0,0 +1,42 @@ +import scala.reflect.runtime.universe._ + +// Originally composed to accommodate pull request feedback, this test has +// uncovered a handful of bugs in FromJavaClassCompleter, namely: +// * SI-7071 non-public ctors get lost +// * SI-7072 inner classes are read incorrectly + +// I'm leaving the incorrect results of FromJavaClassCompleters in the check +// file, so that we get notified when something changes there. + +package object foo { + def testAll(): Unit = { + test(typeOf[foo.PackagePrivateJavaClass].typeSymbol) + test(typeOf[foo.PackagePrivateJavaClass].typeSymbol.companionSymbol) + test(typeOf[foo.JavaClass_1].typeSymbol) + test(typeOf[foo.JavaClass_1].typeSymbol.companionSymbol) + } + + def test(sym: Symbol): Unit = { + printSymbolDetails(sym) + if (sym.isClass || sym.isModule) { + sym.typeSignature.declarations.toList.sortBy(_.name.toString) foreach test + } + } + + def printSymbolDetails(sym: Symbol): Unit = { + def stableSignature(sym: Symbol) = sym.typeSignature match { + case ClassInfoType(_, _, _) => "ClassInfoType(...)" + case tpe => tpe.toString + } + println("============") + println(s"sym = $sym, signature = ${stableSignature(sym)}, owner = ${sym.owner}") + println(s"isPrivate = ${sym.isPrivate}") + println(s"isProtected = ${sym.isProtected}") + println(s"isPublic = ${sym.isPublic}") + println(s"privateWithin = ${sym.privateWithin}") + } +} + +object Test extends App { + foo.testAll() +}
\ No newline at end of file |