diff options
author | Martin Odersky <odersky@gmail.com> | 2014-11-08 09:39:35 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2014-11-09 19:09:51 +0100 |
commit | f618e471b3f4f035221234cfeb980e52cc283701 (patch) | |
tree | f77edcfd63bed2b5ea1fdc4105248ef2f5737be5 /src/dotty/tools/dotc/TypeErasure.scala | |
parent | 0f7934d42892f36e28154779588a1d2a80d80616 (diff) | |
download | dotty-f618e471b3f4f035221234cfeb980e52cc283701.tar.gz dotty-f618e471b3f4f035221234cfeb980e52cc283701.tar.bz2 dotty-f618e471b3f4f035221234cfeb980e52cc283701.zip |
Fixes to Unit handling in erasure
1. Erase unit results in getters to BoxedUnit.
2. Erase => Unit to ()Unit; was ()BoxedUnit
3. Make sure ValDefs have same type in tpt as in symbol, analogous to DefDefs.
Diffstat (limited to 'src/dotty/tools/dotc/TypeErasure.scala')
-rw-r--r-- | src/dotty/tools/dotc/TypeErasure.scala | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/TypeErasure.scala b/src/dotty/tools/dotc/TypeErasure.scala index 2a55d6732..448dd3f57 100644 --- a/src/dotty/tools/dotc/TypeErasure.scala +++ b/src/dotty/tools/dotc/TypeErasure.scala @@ -4,6 +4,7 @@ package core import Symbols._, Types._, Contexts._, Flags._, Names._, StdNames._, Decorators._, Flags.JavaDefined import dotc.transform.ExplicitOuter._ +import typer.Mode import util.DotClass /** Erased types are: @@ -89,7 +90,7 @@ object TypeErasure { /** The current context with a phase no later than erasure */ private def erasureCtx(implicit ctx: Context) = - if (ctx.erasedTypes) ctx.withPhase(ctx.erasurePhase) else ctx + if (ctx.erasedTypes) ctx.withPhase(ctx.erasurePhase).addMode(Mode.FutureDefsOK) else ctx def erasure(tp: Type)(implicit ctx: Context): Type = scalaErasureFn(tp)(erasureCtx) def semiErasure(tp: Type)(implicit ctx: Context): Type = semiErasureFn(tp)(erasureCtx) @@ -141,7 +142,12 @@ 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 eraseInfo(tp)(erasureCtx) + else eraseInfo(tp)(erasureCtx) match { + case einfo: MethodType if sym.isGetter && einfo.resultType.isRef(defn.UnitClass) => + defn.BoxedUnitClass.typeRef + case einfo => + einfo + } } def isUnboundedGeneric(tp: Type)(implicit ctx: Context) = !( @@ -319,7 +325,7 @@ class TypeErasure(isJava: Boolean, isSemi: Boolean, isConstructor: Boolean, wild } def eraseInfo(tp: Type)(implicit ctx: Context) = tp match { - case ExprType(rt) => MethodType(Nil, Nil, erasure(rt)) + case ExprType(rt) => MethodType(Nil, Nil, eraseResult(rt)) case tp => erasure(tp) } |