Skip to content

Commit b952d41

Browse files
committed
Avoid overcompilation involving inline or annotation trees
We used to pretty-print trees in the API info we send to sbt, but the pretty-printed output seems to be unstable leading to overcompilation, so just use the raw trees instead (this should also be faster).
1 parent 228e593 commit b952d41

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

compiler/src/dotty/tools/dotc/sbt/ExtractAPI.scala

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -595,12 +595,11 @@ private class ExtractAPICollector(implicit val ctx: Context) extends ThunkHolder
595595
if (!inlineBody.isEmpty) {
596596
// FIXME: If the body of an inlineable method changes, all the reverse
597597
// dependencies of this method need to be recompiled. sbt has no way
598-
// of tracking method bodies, so as a hack we include the pretty-printed
599-
// typed tree of the method as part of the signature we send to sbt.
598+
// of tracking method bodies, so as a hack we include the printed
599+
// tree of the method as part of the signature we send to sbt.
600600
// To do this properly we would need a way to hash trees and types in
601601
// dotty itself.
602-
val printTypesCtx = ctx.fresh.setSetting(ctx.settings.XprintTypes, true)
603-
annots += marker(inlineBody.show(printTypesCtx))
602+
annots += marker(inlineBody.toString)
604603
}
605604

606605
// In the Scala2 ExtractAPI phase we only extract annotations that extend
@@ -618,12 +617,12 @@ private class ExtractAPICollector(implicit val ctx: Context) extends ThunkHolder
618617
// FIXME: To faithfully extract an API we should extract the annotation tree,
619618
// sbt instead wants us to extract the annotation type and its arguments,
620619
// to do this properly we would need a way to hash trees and types in dotty itself,
621-
// instead we pretty-print the annotation tree.
620+
// instead we use the raw string representation of the annotation tree.
622621
// However, we still need to extract the annotation type in the way sbt expect
623622
// because sbt uses this information to find tests to run (for example
624623
// junit tests are annotated @org.junit.Test).
625624
api.Annotation.of(
626625
apiType(annot.tree.tpe), // Used by sbt to find tests to run
627-
Array(api.AnnotationArgument.of("FULLTREE", annot.tree.show)))
626+
Array(api.AnnotationArgument.of("FULLTREE", annot.tree.toString)))
628627
}
629628
}

0 commit comments

Comments
 (0)