File tree Expand file tree Collapse file tree 9 files changed +44
-4
lines changed
compiler/src/dotty/tools/dotc/sbt
sbt-dotty/sbt-test/source-dependencies/missing-annot Expand file tree Collapse file tree 9 files changed +44
-4
lines changed Original file line number Diff line number Diff line change @@ -604,10 +604,12 @@ private class ExtractAPICollector(using Context) extends ThunkHolder {
604
604
605
605
// In the Scala2 ExtractAPI phase we only extract annotations that extend
606
606
// StaticAnnotation, but in Dotty we currently pickle all annotations so we
607
- // extract everything (except inline body annotations which are handled
608
- // above).
609
- s.annotations.filter(_.symbol != defn.BodyAnnot ) foreach { annot =>
610
- annots += apiAnnotation(annot)
607
+ // extract everything (except annotations missing from the classpath which
608
+ // we simply skip over, and inline body annotations which are handled above).
609
+ s.annotations.foreach { annot =>
610
+ val sym = annot.symbol
611
+ if sym.exists && sym != defn.BodyAnnot then
612
+ annots += apiAnnotation(annot)
611
613
}
612
614
613
615
annots.toList
Original file line number Diff line number Diff line change
1
+ class A {
2
+ @ JavaAnnot def foo : Int = 1
3
+ @ ScalaAnnot def bar : Int = 1
4
+ }
Original file line number Diff line number Diff line change
1
+ import java .lang .annotation .*;
2
+
3
+ public @interface JavaAnnot {}
Original file line number Diff line number Diff line change
1
+ class ScalaAnnot extends scala.annotation.StaticAnnotation
Original file line number Diff line number Diff line change
1
+ class B extends A
Original file line number Diff line number Diff line change
1
+ lazy val a = project.in(file(" a" ))
2
+ .settings(
3
+ Compile / classDirectory := (ThisBuild / baseDirectory).value / " a-output"
4
+ )
5
+
6
+ lazy val b = project.in(file(" b" ))
7
+ .settings(
8
+ Compile / unmanagedClasspath += (ThisBuild / baseDirectory).value / " b-input"
9
+ )
Original file line number Diff line number Diff line change
1
+ import sbt ._
2
+ import Keys ._
3
+
4
+ object DottyInjectedPlugin extends AutoPlugin {
5
+ override def requires = plugins.JvmPlugin
6
+ override def trigger = allRequirements
7
+
8
+ override val projectSettings = Seq (
9
+ scalaVersion := sys.props(" plugin.scalaVersion" )
10
+ )
11
+ }
Original file line number Diff line number Diff line change
1
+ addSbtPlugin(" ch.epfl.lamp" % " sbt-dotty" % sys.props(" plugin.version" ))
Original file line number Diff line number Diff line change
1
+ > a/compile
2
+ $ mkdir b-input
3
+ # Add A to the classpath of b but not the annotations referenced by the members of A
4
+ $ copy-file a-output/A.class b-input/A.class
5
+ $ copy-file a-output/A.tasty b-input/A.tasty
6
+ # B should still be able to compile even though ExtractAPI forces the
7
+ # annotations of all inherited members.
8
+ > b/compile
You can’t perform that action at this time.
0 commit comments