@@ -38,7 +38,7 @@ object TypeErasure {
3838 case JavaArrayType (elem) =>
3939 isErasedType(elem)
4040 case AnnotatedType (_, tp) =>
41- isErasedType(tp)
41+ false
4242 case ThisType (tref) =>
4343 isErasedType(tref)
4444 case tp : MethodType =>
@@ -105,7 +105,7 @@ object TypeErasure {
105105 /** The erasure of a top-level reference. Differs from normal erasure in that
106106 * TermRefs are kept instead of being widened away.
107107 */
108- def erasedRef (tp : Type )(implicit ctx : Context ): Type = tp match {
108+ def erasedRef (tp : Type )(implicit ctx : Context ): Type = tp.stripAnnots match {
109109 case tp : TermRef =>
110110 assert(tp.symbol.exists, tp)
111111 val tp1 = ctx.makePackageObjPrefixExplicit(tp)
@@ -160,7 +160,7 @@ object TypeErasure {
160160 * as upper bound and that is not Java defined? Arrays of such types are
161161 * erased to `Object` instead of `ObjectArray`.
162162 */
163- def isUnboundedGeneric (tp : Type )(implicit ctx : Context ): Boolean = tp.dealias match {
163+ def isUnboundedGeneric (tp : Type )(implicit ctx : Context ): Boolean = tp.dealias.stripAnnots match {
164164 case tp : TypeRef =>
165165 ! tp.symbol.isClass &&
166166 ! tp.derivesFrom(defn.ObjectClass ) &&
@@ -186,14 +186,14 @@ object TypeErasure {
186186 * come after S.
187187 * (the reason to pick last is that we prefer classes over traits that way).
188188 */
189- def erasedLub (tp1 : Type , tp2 : Type )(implicit ctx : Context ): Type = tp1 match {
189+ def erasedLub (tp1 : Type , tp2 : Type )(implicit ctx : Context ): Type = tp1.stripAnnots match {
190190 case JavaArrayType (elem1) =>
191- tp2 match {
191+ tp2.stripAnnots match {
192192 case JavaArrayType (elem2) => JavaArrayType (erasedLub(elem1, elem2))
193193 case _ => defn.ObjectType
194194 }
195195 case _ =>
196- tp2 match {
196+ tp2.stripAnnots match {
197197 case JavaArrayType (_) => defn.ObjectType
198198 case _ =>
199199 val cls2 = tp2.classSymbol
@@ -216,14 +216,14 @@ object TypeErasure {
216216 * - subtypes over supertypes, unless isJava is set
217217 * - real classes over traits
218218 */
219- def erasedGlb (tp1 : Type , tp2 : Type , isJava : Boolean )(implicit ctx : Context ): Type = tp1 match {
219+ def erasedGlb (tp1 : Type , tp2 : Type , isJava : Boolean )(implicit ctx : Context ): Type = tp1.stripAnnots match {
220220 case JavaArrayType (elem1) =>
221- tp2 match {
221+ tp2.stripAnnots match {
222222 case JavaArrayType (elem2) => JavaArrayType (erasedGlb(elem1, elem2, isJava))
223223 case _ => tp1
224224 }
225225 case _ =>
226- tp2 match {
226+ tp2.stripAnnots match {
227227 case JavaArrayType (_) => tp2
228228 case _ =>
229229 val tsym1 = tp1.typeSymbol
@@ -346,7 +346,7 @@ class TypeErasure(isJava: Boolean, isSemi: Boolean, isConstructor: Boolean, wild
346346 else JavaArrayType (this (elemtp))
347347 }
348348
349- def eraseInfo (tp : Type , sym : Symbol )(implicit ctx : Context ) = tp match {
349+ def eraseInfo (tp : Type , sym : Symbol )(implicit ctx : Context ) = tp.stripAnnots match {
350350 case ExprType (rt) =>
351351 if (sym is Param ) apply(tp)
352352 // Note that params with ExprTypes are eliminated by ElimByName,
@@ -365,7 +365,7 @@ class TypeErasure(isJava: Boolean, isSemi: Boolean, isConstructor: Boolean, wild
365365 (if (cls.owner is Package ) normalizeClass(cls) else cls).typeRef
366366 }
367367
368- private def eraseResult (tp : Type )(implicit ctx : Context ): Type = tp match {
368+ private def eraseResult (tp : Type )(implicit ctx : Context ): Type = tp.stripAnnots match {
369369 case tp : TypeRef =>
370370 val sym = tp.typeSymbol
371371 if (sym eq defn.UnitClass ) sym.typeRef
0 commit comments