@@ -4,6 +4,7 @@ package core
44
55import Symbols ._ , Types ._ , Contexts ._ , Flags ._ , Names ._ , StdNames ._ , Decorators ._ , Flags .JavaDefined
66import dotc .transform .ExplicitOuter ._
7+ import typer .Mode
78import util .DotClass
89
910/** Erased types are:
@@ -89,7 +90,7 @@ object TypeErasure {
8990
9091 /** The current context with a phase no later than erasure */
9192 private def erasureCtx (implicit ctx : Context ) =
92- if (ctx.erasedTypes) ctx.withPhase(ctx.erasurePhase) else ctx
93+ if (ctx.erasedTypes) ctx.withPhase(ctx.erasurePhase).addMode( Mode . FutureDefsOK ) else ctx
9394
9495 def erasure (tp : Type )(implicit ctx : Context ): Type = scalaErasureFn(tp)(erasureCtx)
9596 def semiErasure (tp : Type )(implicit ctx : Context ): Type = semiErasureFn(tp)(erasureCtx)
@@ -141,7 +142,12 @@ object TypeErasure {
141142 if ((sym eq defn.Any_asInstanceOf ) || (sym eq defn.Any_isInstanceOf )) eraseParamBounds(sym.info.asInstanceOf [PolyType ])
142143 else if (sym.isAbstractType) TypeAlias (WildcardType )
143144 else if (sym.isConstructor) outer.addParam(sym.owner.asClass, erase(tp)(erasureCtx))
144- else eraseInfo(tp)(erasureCtx)
145+ else eraseInfo(tp)(erasureCtx) match {
146+ case einfo : MethodType if sym.isGetter && einfo.resultType.isRef(defn.UnitClass ) =>
147+ defn.BoxedUnitClass .typeRef
148+ case einfo =>
149+ einfo
150+ }
145151 }
146152
147153 def isUnboundedGeneric (tp : Type )(implicit ctx : Context ) = ! (
@@ -319,7 +325,7 @@ class TypeErasure(isJava: Boolean, isSemi: Boolean, isConstructor: Boolean, wild
319325 }
320326
321327 def eraseInfo (tp : Type )(implicit ctx : Context ) = tp match {
322- case ExprType (rt) => MethodType (Nil , Nil , erasure (rt))
328+ case ExprType (rt) => MethodType (Nil , Nil , eraseResult (rt))
323329 case tp => erasure(tp)
324330 }
325331
0 commit comments