aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/SymDenotations.scala
diff options
context:
space:
mode:
authorGuillaume Martres <smarter@ubuntu.com>2016-10-06 15:02:17 +0200
committerGitHub <noreply@github.com>2016-10-06 15:02:17 +0200
commit87a775724173bd803a0c4956408e61fd0d5812af (patch)
treec564a236f9247b085ed26c1fb007dad74ed049dd /src/dotty/tools/dotc/core/SymDenotations.scala
parenta3064622e7ce4d73ddd91de0fc6bebfe0ec23ae9 (diff)
parente0a14e7939eda6a7f4914831975b2ac8877696f2 (diff)
downloaddotty-87a775724173bd803a0c4956408e61fd0d5812af.tar.gz
dotty-87a775724173bd803a0c4956408e61fd0d5812af.tar.bz2
dotty-87a775724173bd803a0c4956408e61fd0d5812af.zip
Merge pull request #1492 from dotty-staging/add-inline
Implement inline
Diffstat (limited to 'src/dotty/tools/dotc/core/SymDenotations.scala')
-rw-r--r--src/dotty/tools/dotc/core/SymDenotations.scala42
1 files changed, 34 insertions, 8 deletions
diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala
index ab45550a4..969d09c3e 100644
--- a/src/dotty/tools/dotc/core/SymDenotations.scala
+++ b/src/dotty/tools/dotc/core/SymDenotations.scala
@@ -281,6 +281,15 @@ object SymDenotations {
case nil => None
}
+ /** The same as getAnnotation, but without ensuring
+ * that the symbol carrying the annotation is completed
+ */
+ final def unforcedAnnotation(cls: Symbol)(implicit ctx: Context): Option[Annotation] =
+ dropOtherAnnotations(myAnnotations, cls) match {
+ case annot :: _ => Some(annot)
+ case nil => None
+ }
+
/** Add given annotation to the annotations of this denotation */
final def addAnnotation(annot: Annotation): Unit =
annotations = annot :: myAnnotations
@@ -289,6 +298,12 @@ object SymDenotations {
final def removeAnnotation(cls: Symbol)(implicit ctx: Context): Unit =
annotations = myAnnotations.filterNot(_ matches cls)
+ /** Remove any annotations with same class as `annot`, and add `annot` */
+ final def updateAnnotation(annot: Annotation)(implicit ctx: Context): Unit = {
+ removeAnnotation(annot.symbol)
+ addAnnotation(annot)
+ }
+
/** Add all given annotations to this symbol */
final def addAnnotations(annots: TraversableOnce[Annotation])(implicit ctx: Context): Unit =
annots.foreach(addAnnotation)
@@ -670,9 +685,9 @@ object SymDenotations {
val cls = owner.enclosingSubClass
if (!cls.exists)
fail(
- i""" Access to protected $this not permitted because
- | enclosing ${ctx.owner.enclosingClass.showLocated} is not a subclass of
- | ${owner.showLocated} where target is defined""")
+ i"""
+ | Access to protected $this not permitted because enclosing ${ctx.owner.enclosingClass.showLocated}
+ | is not a subclass of ${owner.showLocated} where target is defined""")
else if (
!( isType // allow accesses to types from arbitrary subclasses fixes #4737
|| pre.baseTypeRef(cls).exists // ??? why not use derivesFrom ???
@@ -680,9 +695,9 @@ object SymDenotations {
|| (owner is ModuleClass) // don't perform this check for static members
))
fail(
- i""" Access to protected ${symbol.show} not permitted because
- | prefix type ${pre.widen.show} does not conform to
- | ${cls.showLocated} where the access takes place""")
+ i"""
+ | Access to protected ${symbol.show} not permitted because prefix type ${pre.widen.show}
+ | does not conform to ${cls.showLocated} where the access takes place""")
else true
}
@@ -744,6 +759,11 @@ 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)
+
// ------ access to related symbols ---------------------------------
/* Modules and module classes are represented as follows:
@@ -851,7 +871,7 @@ object SymDenotations {
/** A symbol is effectively final if it cannot be overridden in a subclass */
final def isEffectivelyFinal(implicit ctx: Context): Boolean =
- is(PrivateOrFinal) || !owner.isClass || owner.is(ModuleOrFinal) || owner.isAnonymousClass
+ is(PrivateOrFinalOrInline) || !owner.isClass || owner.is(ModuleOrFinal) || owner.isAnonymousClass
/** The class containing this denotation which has the given effective name. */
final def enclosingClassNamed(name: Name)(implicit ctx: Context): Symbol = {
@@ -1521,7 +1541,13 @@ object SymDenotations {
/** Enter a symbol in given `scope` without potentially replacing the old copy. */
def enterNoReplace(sym: Symbol, scope: MutableScope)(implicit ctx: Context): Unit = {
- require((sym.denot.flagsUNSAFE is Private) || !(this is Frozen) || (scope ne this.unforcedDecls) || sym.hasAnnotation(defn.ScalaStaticAnnot))
+
+ require(
+ (sym.denot.flagsUNSAFE is Private) ||
+ !(this is Frozen) ||
+ (scope ne this.unforcedDecls) ||
+ sym.hasAnnotation(defn.ScalaStaticAnnot) ||
+ sym.name.isInlineAccessor)
scope.enter(sym)
if (myMemberFingerPrint != FingerPrint.unknown)