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

isPackage returns true for package classes #6732

Open
scabug opened this issue Nov 28, 2012 · 4 comments
Open

isPackage returns true for package classes #6732

scabug opened this issue Nov 28, 2012 · 4 comments
Milestone

Comments

@scabug
Copy link

scabug commented Nov 28, 2012

The API docs say that isPackage should imply isTerm, which makes sense. However, in 2.10-RC2, isPackage returns true for both packages and package classes, which are not terms.

Example repro code:

import scala.tools.nsc
val compiler = new nsc.Global(new nsc.Settings)
new compiler.Run
val sp = compiler.definitions.ScalaPackageClass

println("isPackageClass: " + sp.isPackageClass)
println("isPackage: " + sp.isPackage)
println("isTerm: " + sp.isTerm)

This prints:

isPackageClass: true
isPackage: true
isTerm: false

Something should give. In my opinion, the public API docs make more sense than the current behavior, so change the implementation. Have isPackage return false for package classes.

@scabug
Copy link
Author

scabug commented Nov 28, 2012

Imported From: https://issues.scala-lang.org/browse/SI-6732?orig=1
Reporter: Lex Spoon (lexspoon)
Affected Versions: 2.10.0-RC2

@scabug
Copy link
Author

scabug commented Nov 28, 2012

@paulp said:
In my view packages and package classes (and modules and module classes) should never have made it into the public api; now that they're there, the distinction probably has to be maintained. But certainly isPackage{Class} and isModule{Class} should behave consistently with one another.

On the compiler side there is isModuleOrModuleClass. I thought there was an isPackageOrPackageClass, but I don't see it now.

@scabug
Copy link
Author

scabug commented Feb 1, 2014

@xeno-by said:
Some progress: scala/scala#3452

@scabug
Copy link
Author

scabug commented Feb 1, 2014

Lex Spoon (lexspoon) said:
Great to see. I'm involved in writing queries against the reflection API, and inconsistencies like this can really suck away time.

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