diff options
author | odersky <odersky@gmail.com> | 2016-11-10 12:07:24 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-10 12:07:24 +0100 |
commit | 28c2e04dd33b6389a44460f977a97b8691265994 (patch) | |
tree | e138f794cd484509e8379934b5c538b5fa15d455 /src | |
parent | ab652d191652eb471e0d7511e1a831f5a52b75fe (diff) | |
parent | 2e02b292cca07f8b619aba0e03dca878e22c415f (diff) | |
download | dotty-28c2e04dd33b6389a44460f977a97b8691265994.tar.gz dotty-28c2e04dd33b6389a44460f977a97b8691265994.tar.bz2 dotty-28c2e04dd33b6389a44460f977a97b8691265994.zip |
Merge pull request #1677 from dotty-staging/fix-#1647
Use inline flag instead of @inline annotation
Diffstat (limited to 'src')
-rw-r--r-- | src/dotty/tools/dotc/ast/Desugar.scala | 3 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/SymDenotations.scala | 5 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/Namer.scala | 20 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/Typer.scala | 5 |
5 files changed, 10 insertions, 25 deletions
diff --git a/src/dotty/tools/dotc/ast/Desugar.scala b/src/dotty/tools/dotc/ast/Desugar.scala index 639dac930..349fbfb2c 100644 --- a/src/dotty/tools/dotc/ast/Desugar.scala +++ b/src/dotty/tools/dotc/ast/Desugar.scala @@ -615,8 +615,7 @@ object desugar { */ def makeClosure(params: List[ValDef], body: Tree, tpt: Tree = TypeTree(), inlineable: Boolean)(implicit ctx: Context) = { var mods = synthetic - if (inlineable) - mods = mods.withAddedAnnotation(New(ref(defn.InlineAnnotType), Nil).withPos(body.pos)) + if (inlineable) mods |= Inline Block( DefDef(nme.ANON_FUN, Nil, params :: Nil, tpt, body).withMods(mods), Closure(Nil, Ident(nme.ANON_FUN), EmptyTree)) diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala index a25be0a1f..fb6a40100 100644 --- a/src/dotty/tools/dotc/core/SymDenotations.scala +++ b/src/dotty/tools/dotc/core/SymDenotations.scala @@ -751,10 +751,7 @@ object SymDenotations { // def isOverridable: Boolean = !!! need to enforce that classes cannot be redefined def isSkolem: Boolean = name == nme.SKOLEM - def isInlineMethod(implicit ctx: Context): Boolean = - is(Method, butNot = Accessor) && - !isCompleting && // don't force method type; recursive inlines are ignored anyway. - hasAnnotation(defn.InlineAnnot) + def isInlineMethod(implicit ctx: Context): Boolean = is(InlineMethod, butNot = Accessor) // ------ access to related symbols --------------------------------- diff --git a/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala b/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala index a0d788955..d2605afea 100644 --- a/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala +++ b/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala @@ -474,7 +474,7 @@ class TreeUnpickler(reader: TastyReader, tastyName: TastyName.Table, posUnpickle sym.completer.withDecls(newScope) forkAt(templateStart).indexTemplateParams()(localContext(sym)) } - else if (annots.exists(_.symbol == defn.InlineAnnot)) + else if (sym.isInlineMethod) sym.addAnnotation(LazyBodyAnnotation { ctx0 => implicit val ctx: Context = localContext(sym)(ctx0).addMode(Mode.ReadPositions) // avoids space leaks by not capturing the current context diff --git a/src/dotty/tools/dotc/typer/Namer.scala b/src/dotty/tools/dotc/typer/Namer.scala index 9da0e2edc..dd7326fae 100644 --- a/src/dotty/tools/dotc/typer/Namer.scala +++ b/src/dotty/tools/dotc/typer/Namer.scala @@ -568,25 +568,14 @@ class Namer { typer: Typer => val cls = typedAheadAnnotation(annotTree) val ann = Annotation.deferred(cls, implicit ctx => typedAnnotation(annotTree)) denot.addAnnotation(ann) - if (cls == defn.InlineAnnot) { - hasInlineAnnot = true - addInlineInfo(denot, original) - } - } - if (!hasInlineAnnot && denot.is(InlineMethod)) { - // create a @inline annotation. Currently, the inlining trigger - // is really the annotation, not the flag. This is done so that - // we can still compile inline methods from Scala2x. Once we stop - // being compatible with Scala2 we should revise the logic to - // be based on the flag. Then creating a separate annotation becomes unnecessary. - denot.addAnnotation(Annotation(defn.InlineAnnot)) - addInlineInfo(denot, original) + if (cls == defn.InlineAnnot && denot.is(Method, butNot = Accessor)) + denot.setFlag(Inline) } case _ => } - private def addInlineInfo(denot: SymDenotation, original: untpd.Tree) = original match { - case original: untpd.DefDef => + private def addInlineInfo(denot: SymDenotation) = original match { + case original: untpd.DefDef if denot.isInlineMethod => Inliner.registerInlineInfo( denot, implicit ctx => typedAheadExpr(original).asInstanceOf[tpd.DefDef].rhs @@ -599,6 +588,7 @@ class Namer { typer: Typer => */ def completeInCreationContext(denot: SymDenotation): Unit = { addAnnotations(denot) + addInlineInfo(denot) denot.info = typeSig(denot.symbol) Checking.checkWellFormed(denot.symbol) } diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala index 95f0c5614..a93262314 100644 --- a/src/dotty/tools/dotc/typer/Typer.scala +++ b/src/dotty/tools/dotc/typer/Typer.scala @@ -1142,7 +1142,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit } val vdef1 = assignType(cpy.ValDef(vdef)(name, tpt1, rhs1), sym) if (sym.is(Inline, butNot = DeferredOrParamAccessor)) - checkInlineConformant(rhs1, "right-hand side of inline value") + checkInlineConformant(rhs1, em"right-hand side of inline $sym") patchIfLazy(vdef1) vdef1 } @@ -1176,8 +1176,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit val rhs1 = typedExpr(ddef.rhs, tpt1.tpe)(rhsCtx) // Overwrite inline body to make sure it is not evaluated twice - if (sym.hasAnnotation(defn.InlineAnnot)) - Inliner.registerInlineInfo(sym, _ => rhs1) + if (sym.isInlineMethod) Inliner.registerInlineInfo(sym, _ => rhs1) if (sym.isAnonymousFunction) { // If we define an anonymous function, make sure the return type does not |