Assume StubSymbols are not StaticAnnotations#8379
Assume StubSymbols are not StaticAnnotations#8379retronym wants to merge 1 commit intoscala:2.12.xfrom
Conversation
In the reproduction in scala/bug#11679, an SBT build that uses `--release 8` and as such does not have `sun._` on the classpath, `APIPhase` (a custom compiler phase in SBT/Zinc that serializes the API of each file to perform change detection in incremental compilation) is attempting to serialize the API of the member `@CallerSensitive ClassLoader getParent` that `de.sciss.synth.proc.impl.MemoryClassLoader` inherits from `j.l.ClassLoader`. Until that point, scalac was doing okay without having a classfile for `CallerSensitve` -- it just used a `StubSymbol` in its place. Scala's pickle phase only serializes `.decls`, not `.members`. When `APIPhase` filters the list of annotations: https://github.com/sbt/zinc/blob/4b414b6677/internal/compiler-bridge/src/main/scala/xsbt/ExtractAPI.scala#L789-L800 for those that extend `scala.StaticAnnotation`, the stub symbol fails and aborts compilation. Static annotations are part of the API because the are could affect how client code is compiled. This commit changes `AnnotationInfo.isStatic` to return false for annotations to absent classfiles. It also makes sure that we still have a hard-error if annotations based on absent classfiles are processed by the pickle phase. I have manually tested this commit with the SBT project in the bug. Fixes scala/bug#11679
|
It seems to me this is a bit of a flaw in the design of the Could we instead change our classpath to fall back to the classfiles in the |
|
In general, I don't believe that Zinc should fail when a class being compiled has an inherited member that is annotated with an absent class. If we were to add |
I agree there.
Would it be cleaner to fix it in Zinc? |
In the reproduction in scala/bug#11679, an SBT build that uses
--release 8and as such does not havesun._on the classpath,APIPhase(a custom compiler phase in SBT/Zinc that serializes the APIof each file to perform change detection in incremental compilation)
is attempting to serialize the API of the member
@CallerSensitive ClassLoader getParentthatde.sciss.synth.proc.impl.MemoryClassLoaderinherits fromj.l.ClassLoader.Until that point, scalac was doing okay without having a classfile
for
CallerSensitve-- it just used aStubSymbolin its place.Scala's pickle phase only serializes
.decls, not.members.When
APIPhasefilters the list of annotations:https://github.com/sbt/zinc/blob/4b414b6677/internal/compiler-bridge/src/main/scala/xsbt/ExtractAPI.scala#L789-L800
for those that extend
scala.StaticAnnotation, the stub symbol failsand aborts compilation. Static annotations are part of the API because
the are could affect how client code is compiled.
This commit changes
AnnotationInfo.isStaticto return falsefor annotations to absent classfiles. It also makes sure that we
still have a hard-error if annotations based on absent classfiles
are processed by the pickle phase.
I have manually tested this commit with the SBT project in the bug.
Fixes scala/bug#11679