Skip to content

Avoid overcompilation involving inline or annotation trees #8359

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

Merged
merged 1 commit into from
Feb 26, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions compiler/src/dotty/tools/dotc/sbt/ExtractAPI.scala
Original file line number Diff line number Diff line change
Expand Up @@ -595,12 +595,11 @@ private class ExtractAPICollector(implicit val ctx: Context) extends ThunkHolder
if (!inlineBody.isEmpty) {
// FIXME: If the body of an inlineable method changes, all the reverse
// dependencies of this method need to be recompiled. sbt has no way
// of tracking method bodies, so as a hack we include the pretty-printed
// typed tree of the method as part of the signature we send to sbt.
// of tracking method bodies, so as a hack we include the printed
// tree of the method as part of the signature we send to sbt.
// To do this properly we would need a way to hash trees and types in
// dotty itself.
val printTypesCtx = ctx.fresh.setSetting(ctx.settings.XprintTypes, true)
annots += marker(inlineBody.show(printTypesCtx))
annots += marker(inlineBody.toString)
}

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment above also needs to be updated

}
}