diff options
author | Martin Odersky <odersky@gmail.com> | 2016-09-10 20:58:34 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-10-02 16:11:21 +0200 |
commit | d575e585389b025d7b8056bcb43fea67dddd15d0 (patch) | |
tree | 657453c9e17f109e29ead11d52807d1e335930ae /src/dotty/tools/dotc/typer/Namer.scala | |
parent | e93b7bfe770c8950a52d17bb0aebd3e0a5e93b3c (diff) | |
download | dotty-d575e585389b025d7b8056bcb43fea67dddd15d0.tar.gz dotty-d575e585389b025d7b8056bcb43fea67dddd15d0.tar.bz2 dotty-d575e585389b025d7b8056bcb43fea67dddd15d0.zip |
Make inline a keyword
`inline` is now a modifier keyword. To keep disruption tolerable,
we still allow `@inline` as an annotation as well. Other uses of
`inline` are supported only under `-language:Scala2` and are rewritten
to identifiers in backticks.
Diffstat (limited to 'src/dotty/tools/dotc/typer/Namer.scala')
-rw-r--r-- | src/dotty/tools/dotc/typer/Namer.scala | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/typer/Namer.scala b/src/dotty/tools/dotc/typer/Namer.scala index 5e2ff4164..a33061453 100644 --- a/src/dotty/tools/dotc/typer/Namer.scala +++ b/src/dotty/tools/dotc/typer/Namer.scala @@ -562,11 +562,24 @@ class Namer { typer: Typer => protected def addAnnotations(denot: SymDenotation): Unit = original match { case original: untpd.MemberDef => + var hasInlineAnnot = false for (annotTree <- untpd.modsDeco(original).mods.annotations) { val cls = typedAheadAnnotation(annotTree) val ann = Annotation.deferred(cls, implicit ctx => typedAnnotation(annotTree)) denot.addAnnotation(ann) - if (cls == defn.InlineAnnot) addInlineInfo(denot, original) + 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) } case _ => } |