diff options
author | Martin Odersky <odersky@gmail.com> | 2013-12-20 10:07:35 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2013-12-20 10:07:35 +0100 |
commit | bac6a2081d971c7f5c87b610cfaac7cd39c06713 (patch) | |
tree | 613656e48a6c8b81680407ecd58f806749bba0df /src/dotty/tools/dotc | |
parent | 8420bbee7fa5eadeb58f0f54a7089b6f2048575e (diff) | |
download | dotty-bac6a2081d971c7f5c87b610cfaac7cd39c06713.tar.gz dotty-bac6a2081d971c7f5c87b610cfaac7cd39c06713.tar.bz2 dotty-bac6a2081d971c7f5c87b610cfaac7cd39c06713.zip |
Changing TypeMap to drop annotations
This is quite drastic. The problem is, we do not really know what to do with annotations in types. In a case demonstrated by dotc.ast.CheckTrees, a substitution of type parameter T in
class Trees[-T @uncheckedVariance]
gave us Trees[Type @uncheckedVariance], which messed up type inference in implicit search afterwards. In the case above, we clearly want to lose the annotation if the underlying type is not a type variable. Even if the underlying type is a type variable, the annotation looks wrong, since it should apply only to T, not that other variable. So the safest route seems to be to just drop the annotation.
That was a specific case, how to draft a general rule? In the absense of a better idea, it seems safest to always drop type annotations if the underlying type changes in a transformation. If some map does not want that behavior it would have to implement the AnnotatedType case explicitly.
Diffstat (limited to 'src/dotty/tools/dotc')
-rw-r--r-- | src/dotty/tools/dotc/core/Types.scala | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala index c0e4ccb14..f7308c1f1 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -2104,7 +2104,8 @@ object Types { tp.derivedOrType(this(tp.tp1), this(tp.tp2)) case tp @ AnnotatedType(annot, underlying) => - tp.derivedAnnotatedType(mapOver(annot), this(underlying)) + val underlying1 = mapOver(underlying) + if (underlying1 eq underlying) tp else underlying1 case tp @ WildcardType => tp.derivedWildcardType(mapOver(tp.optBounds)) |