aboutsummaryrefslogtreecommitdiff
path: root/src/dotty
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-11-07 17:05:14 +0100
committerMartin Odersky <odersky@gmail.com>2016-11-07 17:05:14 +0100
commit0d9dd7c7e366be71ca795b89b48def8b0d201a05 (patch)
tree226f41da3259288722cb6bc0a429ffb084690416 /src/dotty
parent913f76a482efc733c01dd262a72de78e795d4b7b (diff)
downloaddotty-0d9dd7c7e366be71ca795b89b48def8b0d201a05.tar.gz
dotty-0d9dd7c7e366be71ca795b89b48def8b0d201a05.tar.bz2
dotty-0d9dd7c7e366be71ca795b89b48def8b0d201a05.zip
Use inline flag instead of @inline annotation
Convert `@inline` annotations to `inline` flags, not the other way round as was done before.
Diffstat (limited to 'src/dotty')
-rw-r--r--src/dotty/tools/dotc/ast/Desugar.scala3
-rw-r--r--src/dotty/tools/dotc/core/SymDenotations.scala5
-rw-r--r--src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala2
-rw-r--r--src/dotty/tools/dotc/typer/Namer.scala17
-rw-r--r--src/dotty/tools/dotc/typer/Typer.scala5
5 files changed, 9 insertions, 23 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..725979496 100644
--- a/src/dotty/tools/dotc/typer/Namer.scala
+++ b/src/dotty/tools/dotc/typer/Namer.scala
@@ -521,6 +521,7 @@ class Namer { typer: Typer =>
mergeCompanionDefs()
val ctxWithStats = (ctx /: stats) ((ctx, stat) => indexExpanded(stat)(ctx))
createCompanionLinks(ctxWithStats)
+ //stats foreach enterAnnotations
ctxWithStats
}
@@ -568,19 +569,9 @@ 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)
+ if (denot.isInlineMethod) addInlineInfo(denot, original)
}
case _ =>
}
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