diff options
author | odersky <odersky@gmail.com> | 2014-12-14 20:03:08 +0100 |
---|---|---|
committer | odersky <odersky@gmail.com> | 2014-12-14 20:03:08 +0100 |
commit | b0d3ae041dd8d4b250decda17084ce944442345e (patch) | |
tree | 09b1cf2353833bc14b4dca9b85b47a34ad66718d | |
parent | e7a4197cfb7b622893fa0dc99f42824522d89ca1 (diff) | |
parent | fa62cff53d8d568670eadf64b3accee6f6e6d030 (diff) | |
download | dotty-b0d3ae041dd8d4b250decda17084ce944442345e.tar.gz dotty-b0d3ae041dd8d4b250decda17084ce944442345e.tar.bz2 dotty-b0d3ae041dd8d4b250decda17084ce944442345e.zip |
Merge pull request #284 from olhotak/pr-annotatedtypes
fixes to handle AnnotatedTypes transparently like the types that they wrap
-rw-r--r-- | src/dotty/tools/dotc/ast/Trees.scala | 5 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/Types.scala | 9 |
2 files changed, 14 insertions, 0 deletions
diff --git a/src/dotty/tools/dotc/ast/Trees.scala b/src/dotty/tools/dotc/ast/Trees.scala index 05e3b84d7..002287076 100644 --- a/src/dotty/tools/dotc/ast/Trees.scala +++ b/src/dotty/tools/dotc/ast/Trees.scala @@ -266,6 +266,11 @@ object Trees { override def denot(implicit ctx: Context) = tpe match { case tpe: NamedType => tpe.denot case tpe: ThisType => tpe.cls.denot + case tpe: AnnotatedType => tpe.stripAnnots match { + case tpe: NamedType => tpe.denot + case tpe: ThisType => tpe.cls.denot + case _ => NoDenotation + } case _ => NoDenotation } } diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala index 987014ff4..3100be9a0 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -622,6 +622,10 @@ object Types { */ def stripTypeVar(implicit ctx: Context): Type = this + /** Remove all AnnotatedTypes wrapping this type. + */ + def stripAnnots(implicit ctx: Context): Type = this + /** Widen from singleton type to its underlying non-singleton * base type by applying one or more `underlying` dereferences, * Also go from => T to T. @@ -673,6 +677,8 @@ object Types { if (tp1.exists) tp1.dealias else tp case tp: LazyRef => tp.ref.dealias + case tp: AnnotatedType => + tp.derivedAnnotatedType(tp.annot, tp.tpe.dealias) case tp => tp } @@ -2502,6 +2508,9 @@ object Types { def derivedAnnotatedType(annot: Annotation, tpe: Type) = if ((annot eq this.annot) && (tpe eq this.tpe)) this else AnnotatedType(annot, tpe) + + override def stripTypeVar(implicit ctx: Context): Type = tpe.stripTypeVar + override def stripAnnots(implicit ctx: Context): Type = tpe.stripAnnots } object AnnotatedType { |