diff options
author | Martin Odersky <odersky@gmail.com> | 2014-10-27 17:18:48 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2014-10-27 17:18:48 +0100 |
commit | 46eb5ea0b8ac3e80795e7f5030b128794feb692c (patch) | |
tree | 5cec66620e3c7bfdf16b117136e23ba86a644cb3 /src/dotty/tools/dotc/TypeErasure.scala | |
parent | 107049919d509c965dcee71fd8afd2e535058043 (diff) | |
download | dotty-46eb5ea0b8ac3e80795e7f5030b128794feb692c.tar.gz dotty-46eb5ea0b8ac3e80795e7f5030b128794feb692c.tar.bz2 dotty-46eb5ea0b8ac3e80795e7f5030b128794feb692c.zip |
Fix treatment of by name functions
By-name functions like `(=> T) => T` were not treated correctly before.
Witness the disabled `-Ycheck:gettersSetters` for transform/TreeCheckers
in thge test suite. This commit changes the scheme how => T types are treated
and fixes the problems with by-name functions.
Diffstat (limited to 'src/dotty/tools/dotc/TypeErasure.scala')
-rw-r--r-- | src/dotty/tools/dotc/TypeErasure.scala | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/TypeErasure.scala b/src/dotty/tools/dotc/TypeErasure.scala index 851be7658..2a55d6732 100644 --- a/src/dotty/tools/dotc/TypeErasure.scala +++ b/src/dotty/tools/dotc/TypeErasure.scala @@ -111,6 +111,12 @@ object TypeErasure { erasure(tp) } + /** The erasure of a symbol's info. This is different of `erasure` in the way `ExprType`s are + * treated. `eraseInfo` maps them them to nullary method types, whereas `erasure` maps them + * to `Function0`. + */ + def eraseInfo(tp: Type)(implicit ctx: Context): Type = scalaErasureFn.eraseInfo(tp)(erasureCtx) + /** The erasure of a function result type. Differs from normal erasure in that * Unit is kept instead of being mapped to BoxedUnit. */ @@ -135,7 +141,7 @@ object TypeErasure { if ((sym eq defn.Any_asInstanceOf) || (sym eq defn.Any_isInstanceOf)) eraseParamBounds(sym.info.asInstanceOf[PolyType]) else if (sym.isAbstractType) TypeAlias(WildcardType) else if (sym.isConstructor) outer.addParam(sym.owner.asClass, erase(tp)(erasureCtx)) - else erase(tp)(erasureCtx) + else eraseInfo(tp)(erasureCtx) } def isUnboundedGeneric(tp: Type)(implicit ctx: Context) = !( @@ -263,7 +269,7 @@ class TypeErasure(isJava: Boolean, isSemi: Boolean, isConstructor: Boolean, wild case SuperType(thistpe, supertpe) => SuperType(this(thistpe), this(supertpe)) case ExprType(rt) => - MethodType(Nil, Nil, this(rt)) + defn.FunctionClass(0).typeRef case tp: TypeProxy => this(tp.underlying) case AndType(tp1, tp2) => @@ -312,6 +318,11 @@ class TypeErasure(isJava: Boolean, isSemi: Boolean, isConstructor: Boolean, wild else JavaArrayType(this(elemtp)) } + def eraseInfo(tp: Type)(implicit ctx: Context) = tp match { + case ExprType(rt) => MethodType(Nil, Nil, erasure(rt)) + case tp => erasure(tp) + } + private def eraseDerivedValueClassRef(tref: TypeRef)(implicit ctx: Context): Type = unsupported("eraseDerivedValueClass") |