You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
runtime/compile time reflection doesn't see all knownDirectSubclasses #7046
@adriaanm said:
Actually, this only works when you query knownDirectSubclasses after those trees have been typed, so macros that occur before the class C in your example has been type checked won't see its subclasses.
Valentin Churavy (wallnuss) said (edited on Dec 10, 2013 6:46:40 AM UTC):
I still run into this on 2.10.3 and the work around with calling c.typeSignature before c.knownDirectSubclasses doesn't work for the reason Adriaan noticed. Forcing a recompile on only the parts which use the macro solve this error, but that is of course not really satisfactory.
@adriaanm said:
Sorry, this is not something we can fix due the way the typechecker is implemented. The "fix" would be to remove this method from the reflection API.
Valentin Churavy (wallnuss) said:
Would it be possible to reschedule the classes where the macro is used for compilation after the TypeCheck has occurred?
@milessabin said: @adriaanm can you elaborate on "this is not something we can fix due the way the typechecker is implemented" ... are there any specific obstacles you have in mind?
knownDirectSubclasses relies on a full top-down pass having been completed before you call it.
Technically, we could provide a onTypecheckCompilationUnit that you could use, but this isn't currently planned for the macro api (well, I'll let Eugene comment on that, but I'm not aware of any plans here -- in any case, 2.11 is in ramp down)
@xeno-by said:
Scala.meta relies on the underlying platform typechecker, so it won't change anything here unless the implementation of scalac/dotc changes.
One way to fix this issue without changing the typechecker is to move macro expansion to after typer instead of during typer. We'll have to experiment with this, because there are some technical difficulties with implementing that (e.g. implicit inference not working well after typer, etc).
Activity
scabug commentedon Jan 30, 2013
Imported From: https://issues.scala-lang.org/browse/SI-7046?orig=1
Reporter: @xeno-by
Affected Versions: 2.10.0, 2.11.0
Other Milestones: 2.12.1
scabug commentedon Jan 31, 2013
@xeno-by said:
Probably should a very easy fix. Will try to get it once we're discussing synchronization.
scabug commentedon Jan 31, 2013
@xeno-by said:
scala/scala#2039
scabug commentedon Feb 4, 2013
@xeno-by said:
Fixed in scala/scala@2403d1d
scabug commentedon Apr 11, 2013
@adriaanm said:
Actually, this only works when you query
knownDirectSubclassesafter those trees have been typed, so macros that occur before the class C in your example has been type checked won't see its subclasses.scabug commentedon May 20, 2013
@JamesIry said:
2.10.2 is about to be cut. Kicking down the road and un-assigning to foster work stealing.
scabug commentedon Jun 19, 2013
@retronym said:
Test case for compile time reflection in #7588
scabug commentedon Dec 10, 2013
Valentin Churavy (wallnuss) said (edited on Dec 10, 2013 6:46:40 AM UTC):
I still run into this on 2.10.3 and the work around with calling c.typeSignature before c.knownDirectSubclasses doesn't work for the reason Adriaan noticed. Forcing a recompile on only the parts which use the macro solve this error, but that is of course not really satisfactory.
scabug commentedon Dec 10, 2013
@adriaanm said:
Sorry, this is not something we can fix due the way the typechecker is implemented. The "fix" would be to remove this method from the reflection API.
scabug commentedon Dec 10, 2013
Valentin Churavy (wallnuss) said:
Would it be possible to reschedule the classes where the macro is used for compilation after the TypeCheck has occurred?
scabug commentedon Dec 10, 2013
@xeno-by said:
Discussion: https://groups.google.com/forum/#!topic/scala-internals/LRfKffsPxVA
scabug commentedon Apr 18, 2014
@xeno-by said:
Actually, I think we can fix this for an important subset of macros: https://groups.google.com/forum/#!topic/scala-user/oJP9aqs88rM
scabug commentedon Aug 3, 2014
@xeno-by said:
See another test case at #8776
scabug commentedon Jun 6, 2016
@milessabin said:
@adriaanm can you elaborate on "this is not something we can fix due the way the typechecker is implemented" ... are there any specific obstacles you have in mind?
scabug commentedon Jul 11, 2016
@Blaisorblade said:
redesignfor such issues.scabug commentedon Jul 12, 2016
@xeno-by said:
Scala.meta relies on the underlying platform typechecker, so it won't change anything here unless the implementation of scalac/dotc changes.
One way to fix this issue without changing the typechecker is to move macro expansion to after typer instead of during typer. We'll have to experiment with this, because there are some technical difficulties with implementing that (e.g. implicit inference not working well after typer, etc).
scabug commentedon Jul 15, 2016
@milessabin said:
WIP PR here: scala/scala#5284
scabug commentedon Aug 11, 2016
@cchantep said:
Could the following be used as workaround in some case (seems to work in my case as far as I can see).
scabug commentedon Aug 26, 2016
@milessabin said:
Fix backported to 2.11.8 is available here.
scabug commentedon Oct 18, 2016
@adriaanm said:
scala/scala#5345
scabug commentedon Jan 9, 2017
@adriaanm said:
To track future refinements, please open a new issue. Closing this one to mark our progress.