aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/SymDenotations.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-07-03 19:02:26 +0200
committerMartin Odersky <odersky@gmail.com>2014-07-17 11:02:00 +0200
commitdb88bf06958e33ae415ca227808ab1f3e48fed7f (patch)
treedef81047ef7f2bdf930e2a5561cfcd2403a61912 /src/dotty/tools/dotc/core/SymDenotations.scala
parentefe4f7e43652a303d16a5253f84316e547f45cca (diff)
downloaddotty-db88bf06958e33ae415ca227808ab1f3e48fed7f.tar.gz
dotty-db88bf06958e33ae415ca227808ab1f3e48fed7f.tar.bz2
dotty-db88bf06958e33ae415ca227808ab1f3e48fed7f.zip
Various cleanups and utility additions
- Some new functionality in tpd and in Symbols. - Added `sm` interpolator to print nicely. - Make use of nestedMap where possible. - Add IdentityDenotTransformer as a convencience class
Diffstat (limited to 'src/dotty/tools/dotc/core/SymDenotations.scala')
-rw-r--r--src/dotty/tools/dotc/core/SymDenotations.scala38
1 files changed, 35 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala
index 643237038..ba57909a0 100644
--- a/src/dotty/tools/dotc/core/SymDenotations.scala
+++ b/src/dotty/tools/dotc/core/SymDenotations.scala
@@ -212,6 +212,14 @@ object SymDenotations {
final def addAnnotation(annot: Annotation): Unit =
annotations = annot :: myAnnotations
+ /** Remove annotation with given class from this denotation */
+ final def removeAnnotation(cls: Symbol)(implicit ctx: Context): Unit =
+ annotations = myAnnotations.filterNot(_ matches cls)
+
+ /** Copy all annotations from given symbol by adding them to this symbol */
+ final def addAnnotations(from: Symbol)(implicit ctx: Context): Unit =
+ from.annotations.foreach(addAnnotation)
+
@tailrec
private def dropOtherAnnotations(anns: List[Annotation], cls: Symbol)(implicit ctx: Context): List[Annotation] = anns match {
case ann :: rest => if (ann matches cls) anns else dropOtherAnnotations(rest, cls)
@@ -861,6 +869,22 @@ object SymDenotations {
/** Install this denotation as the result of the given denotation transformer. */
override def installAfter(phase: DenotTransformer)(implicit ctx: Context): Unit =
super.installAfter(phase)
+
+ /** Remove private modifier from symbol's definition. If this symbol
+ * is not a constructor nor a static module, rename it by expanding its name to avoid name clashes
+ * @param base the fully qualified name of this class will be appended if name expansion is needed
+ */
+ final def makeNotPrivateAfter(base: Symbol, phase: DenotTransformer)(implicit ctx: Context): Unit = {
+ if (this.is(Private)) {
+ val newName =
+ if (this.is(Module) && isStatic || isClassConstructor) name
+ else {
+ if (this.is(Module)) moduleClass.makeNotPrivateAfter(base, phase)
+ name.expandedName(base)
+ }
+ copySymDenotation(name = newName, initFlags = flags &~ Private).installAfter(phase)
+ }
+ }
}
/** The contents of a class definition during a period
@@ -1311,9 +1335,17 @@ object SymDenotations {
decls.denotsNamed(cname).first.symbol
}
- def underlyingOfValueClass: Type = ???
-
- def valueClassUnbox: Symbol = ???
+ /** The member that of a derived value class that unboxes it. */
+ def valueClassUnbox(implicit ctx: Context): Symbol =
+ // (info.decl(nme.unbox)).orElse(...) uncomment once we accept unbox methods
+ classInfo.decls
+ .find(d => d.isTerm && d.symbol.is(ParamAccessor))
+ .map(_.symbol)
+ .getOrElse(NoSymbol)
+
+ /** The unboxed type that underlies a derived value class */
+ def underlyingOfValueClass(implicit ctx: Context): Type =
+ valueClassUnbox.info.resultType
/** If this class has the same `decls` scope reference in `phase` and
* `phase.next`, install a new denotation with a cloned scope in `phase.next`.