aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools
diff options
context:
space:
mode:
Diffstat (limited to 'src/dotty/tools')
-rw-r--r--src/dotty/tools/dotc/core/Annotations.scala4
-rw-r--r--src/dotty/tools/dotc/transform/LazyVals.scala4
-rw-r--r--src/dotty/tools/dotc/typer/Typer.scala11
3 files changed, 11 insertions, 8 deletions
diff --git a/src/dotty/tools/dotc/core/Annotations.scala b/src/dotty/tools/dotc/core/Annotations.scala
index 947593ca4..b4b7ebd24 100644
--- a/src/dotty/tools/dotc/core/Annotations.scala
+++ b/src/dotty/tools/dotc/core/Annotations.scala
@@ -7,7 +7,9 @@ object Annotations {
abstract class Annotation {
def tree(implicit ctx: Context): Tree
- def symbol(implicit ctx: Context): Symbol = tree.tpe.typeSymbol
+ def symbol(implicit ctx: Context): Symbol =
+ if (tree.symbol.isConstructor) tree.symbol.owner
+ else tree.tpe.typeSymbol
def matches(cls: Symbol)(implicit ctx: Context): Boolean = symbol.derivesFrom(cls)
def appliesToModule: Boolean = true // for now; see remark in SymDenotations
diff --git a/src/dotty/tools/dotc/transform/LazyVals.scala b/src/dotty/tools/dotc/transform/LazyVals.scala
index 8ed09b4b2..3ab9f5ad1 100644
--- a/src/dotty/tools/dotc/transform/LazyVals.scala
+++ b/src/dotty/tools/dotc/transform/LazyVals.scala
@@ -32,7 +32,7 @@ class LazyValsCreateCompanionObjects extends CreateCompanionObjects {
val body = forClass.rhs.asInstanceOf[Template].body
body.exists {
case x: ValDef =>
- (x.mods is Flags.Lazy) && x.mods.annotations.exists(_.tpe == defn.VolatileAnnotType)
+ (x.mods is Flags.Lazy) && x.symbol.hasAnnotation(defn.VolatileAnnot)
case _ => false
}
}
@@ -84,7 +84,7 @@ class LazyValTranformContext {
if (!(tree.mods is Flags.Lazy)) tree
else {
val isField = tree.symbol.owner.isClass
- val isVolatile = tree.mods.annotations.exists(_.tpe == defn.VolatileAnnotType)
+ val isVolatile = tree.symbol.hasAnnotation(defn.VolatileAnnot)
if (isField) {
if (isVolatile) transformFieldValDefVolatile(tree)
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala
index 6e613975b..165ae70dd 100644
--- a/src/dotty/tools/dotc/typer/Typer.scala
+++ b/src/dotty/tools/dotc/typer/Typer.scala
@@ -738,8 +738,9 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
assignType(cpy.Alternative(tree, trees1), trees1)
}
- def typedModifiers(mods: untpd.Modifiers)(implicit ctx: Context): Modifiers = track("typedModifiers") {
+ def typedModifiers(mods: untpd.Modifiers, sym: Symbol)(implicit ctx: Context): Modifiers = track("typedModifiers") {
val annotations1 = mods.annotations mapconserve typedAnnotation
+ for (tree <- annotations1) sym.addAnnotation(Annotation(tree))
if (annotations1 eq mods.annotations) mods.asInstanceOf[Modifiers]
else Modifiers(mods.flags, mods.privateWithin, annotations1)
}
@@ -750,7 +751,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
def typedValDef(vdef: untpd.ValDef, sym: Symbol)(implicit ctx: Context) = track("typedValDef") {
val ValDef(mods, name, tpt, rhs) = vdef
- val mods1 = typedModifiers(mods)
+ val mods1 = typedModifiers(mods, sym)
val tpt1 = typedType(tpt)
if ((sym is Implicit) && sym.owner.isType) checkImplicitTptNonEmpty(vdef)
val rhs1 = rhs match {
@@ -762,7 +763,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
def typedDefDef(ddef: untpd.DefDef, sym: Symbol)(implicit ctx: Context) = track("typedDefDef") {
val DefDef(mods, name, tparams, vparamss, tpt, rhs) = ddef
- val mods1 = typedModifiers(mods)
+ val mods1 = typedModifiers(mods, sym)
val tparams1 = tparams mapconserve (typed(_).asInstanceOf[TypeDef])
val vparamss1 = vparamss nestedMapconserve (typed(_).asInstanceOf[ValDef])
if (sym is Implicit) {
@@ -777,7 +778,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
def typedTypeDef(tdef: untpd.TypeDef, sym: Symbol)(implicit ctx: Context): Tree = track("typedTypeDef") {
val TypeDef(mods, name, rhs) = tdef
- val mods1 = typedModifiers(mods)
+ val mods1 = typedModifiers(mods, sym)
val _ = typedType(rhs) // unused, typecheck only to remove from typedTree
assignType(cpy.TypeDef(tdef, mods1, name, TypeTree(sym.info)), sym)
}
@@ -804,7 +805,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
}
val TypeDef(mods, name, impl @ Template(constr, parents, self, body)) = cdef
- val mods1 = typedModifiers(mods)
+ val mods1 = typedModifiers(mods, cls)
val constr1 = typed(constr).asInstanceOf[DefDef]
val parents1 = ensureConstrCall(ensureFirstIsClass(
parents mapconserve typedParent, cdef.pos.toSynthetic))