File tree 3 files changed +8
-5
lines changed
compiler/src/dotty/tools/dotc
3 files changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -590,16 +590,16 @@ private class ExtractAPICollector(implicit val ctx: Context) extends ThunkHolder
590
590
591
591
def apiAnnotations (s : Symbol ): List [api.Annotation ] = {
592
592
val annots = new mutable.ListBuffer [api.Annotation ]
593
-
594
- if (Inliner .hasBodyToInline(s) ) {
593
+ val inlineBody = Inliner .bodyToInline(s)
594
+ if (! inlineBody.isEmpty ) {
595
595
// FIXME: If the body of an inlineable method changes, all the reverse
596
596
// dependencies of this method need to be recompiled. sbt has no way
597
597
// of tracking method bodies, so as a hack we include the pretty-printed
598
598
// typed tree of the method as part of the signature we send to sbt.
599
599
// To do this properly we would need a way to hash trees and types in
600
600
// dotty itself.
601
601
val printTypesCtx = ctx.fresh.setSetting(ctx.settings.XprintTypes , true )
602
- annots += marker(Inliner .bodyToInline(s) .show(printTypesCtx))
602
+ annots += marker(inlineBody .show(printTypesCtx))
603
603
}
604
604
605
605
// In the Scala2 ExtractAPI phase we only extract annotations that extend
Original file line number Diff line number Diff line change @@ -41,7 +41,10 @@ object Inliner {
41
41
* @pre hasBodyToInline(sym)
42
42
*/
43
43
def bodyToInline (sym : SymDenotation )(implicit ctx : Context ): Tree =
44
- sym.unforcedAnnotation(defn.BodyAnnot ).get.tree
44
+ if (sym.isInlineMethod && sym.hasAnnotation(defn.BodyAnnot ))
45
+ sym.getAnnotation(defn.BodyAnnot ).get.tree
46
+ else
47
+ EmptyTree
45
48
46
49
/** Should call to method `meth` be inlined in this context? */
47
50
def isInlineable (meth : Symbol )(implicit ctx : Context ): Boolean =
Original file line number Diff line number Diff line change @@ -2185,7 +2185,7 @@ class Typer extends Namer
2185
2185
traverse(xtree :: rest)
2186
2186
case none =>
2187
2187
typed(mdef) match {
2188
- case mdef1 : DefDef if Inliner .hasBodyToInline (mdef1.symbol) =>
2188
+ case mdef1 : DefDef if ! Inliner .bodyToInline (mdef1.symbol).isEmpty =>
2189
2189
buf += inlineExpansion(mdef1)
2190
2190
// replace body with expansion, because it will be used as inlined body
2191
2191
// from separately compiled files - the original BodyAnnotation is not kept.
You can’t perform that action at this time.
0 commit comments