diff options
author | Dmitry Petrashko <dark@d-d.me> | 2014-04-09 16:36:58 +0200 |
---|---|---|
committer | Dmitry Petrashko <dark@d-d.me> | 2014-04-09 16:36:58 +0200 |
commit | 37502919ab964e7a3dc0ca79daf2a7f83747e434 (patch) | |
tree | ead93ea42ce0fe76667e6d3850f91e8ae1f2e2d6 /src/dotty | |
parent | 6bc463df6a6ea8312390915a65024b11cfdd2b77 (diff) | |
parent | 01c33eea19d95fe625ba0b52291f4ab043d883fc (diff) | |
download | dotty-37502919ab964e7a3dc0ca79daf2a7f83747e434.tar.gz dotty-37502919ab964e7a3dc0ca79daf2a7f83747e434.tar.bz2 dotty-37502919ab964e7a3dc0ca79daf2a7f83747e434.zip |
Merge pull request #118 from dotty-staging/fix/annotations
Fixing annotations
Diffstat (limited to 'src/dotty')
-rw-r--r-- | src/dotty/tools/dotc/core/Annotations.scala | 4 | ||||
-rw-r--r-- | src/dotty/tools/dotc/transform/LazyVals.scala | 4 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/Typer.scala | 11 |
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)) |