diff options
author | Martin Odersky <odersky@gmail.com> | 2015-06-25 22:03:01 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2015-06-26 18:12:11 +0200 |
commit | 4b48243a24e533ba81149df956fdc16cdaf1460e (patch) | |
tree | ca1794cd908fa93259fa081e68f43682ed2fb4da /src | |
parent | 5e6a9a28241ea8c64617bf90f9c331a352409035 (diff) | |
download | dotty-4b48243a24e533ba81149df956fdc16cdaf1460e.tar.gz dotty-4b48243a24e533ba81149df956fdc16cdaf1460e.tar.bz2 dotty-4b48243a24e533ba81149df956fdc16cdaf1460e.zip |
Fix erasure of Thistypes.
Thistypes erased to the underlying class. This is wrong. When seen as part of some other type,
a ThisType has to erase to the erasure of the underlying type (i.e. the erasure if the selftype
of the class). unittest-collections.scala failed with a MethodNotFound error because the erasure
was computed incorrectly.
On the other hand, a tree with a ThisType type, should keep the type, analogous to a
tree with a TermRef type.
Diffstat (limited to 'src')
-rw-r--r-- | src/dotty/tools/dotc/core/TypeErasure.scala | 6 | ||||
-rw-r--r-- | src/dotty/tools/dotc/transform/Erasure.scala | 1 |
2 files changed, 2 insertions, 5 deletions
diff --git a/src/dotty/tools/dotc/core/TypeErasure.scala b/src/dotty/tools/dotc/core/TypeErasure.scala index abe5418d4..8abab9155 100644 --- a/src/dotty/tools/dotc/core/TypeErasure.scala +++ b/src/dotty/tools/dotc/core/TypeErasure.scala @@ -315,12 +315,8 @@ class TypeErasure(isJava: Boolean, semiEraseVCs: Boolean, isConstructor: Boolean val parent = tp.parent if (parent isRef defn.ArrayClass) eraseArray(tp) else this(parent) - case tp: TermRef => + case _: TermRef | _: ThisType => this(tp.widen) - case tp: ThisType => - def thisTypeErasure(tpToErase: Type) = - erasureFn(isJava, semiEraseVCs = false, isConstructor, wildcardOK)(tpToErase) - thisTypeErasure(tp.cls.typeRef) case SuperType(thistpe, supertpe) => SuperType(this(thistpe), this(supertpe)) case ExprType(rt) => diff --git a/src/dotty/tools/dotc/transform/Erasure.scala b/src/dotty/tools/dotc/transform/Erasure.scala index ad261c16b..663c309c0 100644 --- a/src/dotty/tools/dotc/transform/Erasure.scala +++ b/src/dotty/tools/dotc/transform/Erasure.scala @@ -271,6 +271,7 @@ object Erasure extends TypeTestsCasts{ def erasedType(tree: untpd.Tree, semiEraseVCs: Boolean)(implicit ctx: Context): Type = tree.typeOpt match { case tp: TermRef if tree.isTerm => erasedRef(tp) + case tp: ThisType => tp case tp => erasure(tp, semiEraseVCs) } |