Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runtime reflection java interop: non-public constructors aren't present in declarations #7071

Closed
scabug opened this issue Feb 4, 2013 · 2 comments

Comments

@scabug
Copy link

scabug commented Feb 4, 2013

package foo;

class PackagePrivateJavaClass {
  private PackagePrivateJavaClass() {}
  protected PackagePrivateJavaClass(int x) {}
  public PackagePrivateJavaClass(int x, int y) {}
}

====


import scala.reflect.runtime.universe._

package object foo {
  def testAll(): Unit = {
    test(typeOf[foo.PackagePrivateJavaClass].typeSymbol)
  }

  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()
}
============
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>
@scabug
Copy link
Author

scabug commented Feb 4, 2013

Imported From: https://issues.scala-lang.org/browse/SI-7071?orig=1
Reporter: @xeno-by
Affected Versions: 2.10.0

@SethTisue
Copy link
Member

closing many stale scala.reflect tickets

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants