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

ClassSymbol.knownDirectSubclasses gives inconsistent results #8776

Closed
scabug opened this issue Aug 3, 2014 · 2 comments
Closed

ClassSymbol.knownDirectSubclasses gives inconsistent results #8776

scabug opened this issue Aug 3, 2014 · 2 comments

Comments

@scabug
Copy link

scabug commented Aug 3, 2014

I have a very simple macro here that makes use of ClassSymbol.knownDirectSubclasses

The macro is invoked in the test (EnumerateSpec.scala). It works as expected when you pass it the type of trait Foo, which is defined in src/main. But when you pass it the type of trait Goo, which is defined in src/test, it cannot find any of the trait's subclasses. (ClassSymbol.knownDirectSubclasses returns an empty Set, as you can see from the println output.)

If you checkout the bugreport branch of https://github.com/cb372/enumerate and run sbt test you can see for yourself.

The weird thing is, if you then make an edit to src/main/scala/enumerate/package.scala, triggering recompilation, then the macro starts working as expected and the tests pass. So I'm guessing this is somehow related to compilation order.

At first I thought it might be a thread-safety issue similar to #6240, but as far as I can tell the Symbol has already been initialized. Manually calling initialize, info, etc. before knownDirectSubclasses did not fix the problem.

@scabug
Copy link
Author

scabug commented Aug 3, 2014

Imported From: https://issues.scala-lang.org/browse/SI-8776?orig=1
Reporter: Chris Birchall (cb372)
Affected Versions: 2.11.2
Duplicates #7046

@scabug
Copy link
Author

scabug commented Aug 3, 2014

@xeno-by said:
This is a duplicate of #7046. Thank you very much for taking time to provide such a detailed report - I've linked it to the original issue!

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

2 participants