@@ -4,6 +4,7 @@ package core
4
4
5
5
import Symbols ._ , Types ._ , Contexts ._ , Flags ._ , Names ._ , StdNames ._ , Decorators ._ , Flags .JavaDefined
6
6
import dotc .transform .ExplicitOuter ._
7
+ import typer .Mode
7
8
import util .DotClass
8
9
9
10
/** Erased types are:
@@ -89,7 +90,7 @@ object TypeErasure {
89
90
90
91
/** The current context with a phase no later than erasure */
91
92
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
93
94
94
95
def erasure (tp : Type )(implicit ctx : Context ): Type = scalaErasureFn(tp)(erasureCtx)
95
96
def semiErasure (tp : Type )(implicit ctx : Context ): Type = semiErasureFn(tp)(erasureCtx)
@@ -141,7 +142,12 @@ object TypeErasure {
141
142
if ((sym eq defn.Any_asInstanceOf ) || (sym eq defn.Any_isInstanceOf )) eraseParamBounds(sym.info.asInstanceOf [PolyType ])
142
143
else if (sym.isAbstractType) TypeAlias (WildcardType )
143
144
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
+ }
145
151
}
146
152
147
153
def isUnboundedGeneric (tp : Type )(implicit ctx : Context ) = ! (
@@ -319,7 +325,7 @@ class TypeErasure(isJava: Boolean, isSemi: Boolean, isConstructor: Boolean, wild
319
325
}
320
326
321
327
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))
323
329
case tp => erasure(tp)
324
330
}
325
331
0 commit comments