@@ -105,12 +105,6 @@ class Erasure extends Phase with DenotTransformer {
105105 if oldSymbol.isRetainedInlineMethod then
106106 newFlags = newFlags &~ Flags .Inline
107107 newAnnotations = newAnnotations.filterConserve(! _.isInstanceOf [BodyAnnotation ])
108- oldSymbol match
109- case cls : ClassSymbol if cls.is(Flags .Erased ) =>
110- newFlags = newFlags | Flags .Trait | Flags .JavaInterface
111- newAnnotations = Nil
112- newInfo = erasedClassInfo(cls)
113- case _ =>
114108 // TODO: define derivedSymDenotation?
115109 if ref.is(Flags .PackageClass )
116110 || ! ref.isClass // non-package classes are always copied since their base types change
@@ -550,8 +544,11 @@ object Erasure {
550544 case _ => tree.symbol.isEffectivelyErased
551545 }
552546
553- /** Check that Java statics and packages can only be used in selections.
554- */
547+ /** Check that
548+ * - erased values are not referred to from normal code
549+ * - inline method applications were inlined
550+ * - Java statics and packages can only be used in selections.
551+ */
555552 private def checkNotErased (tree : Tree )(using Context ): tree.type =
556553 if ! ctx.mode.is(Mode .Type ) then
557554 if isErased(tree) then
@@ -582,6 +579,9 @@ object Erasure {
582579 tree
583580 end checkNotErased
584581
582+ /** Check that initializers of erased vals and arguments to erased parameters
583+ * are pure expressions.
584+ */
585585 def checkPureErased (tree : untpd.Tree , isArgument : Boolean , isImplicit : Boolean = false )(using Context ): Unit =
586586 val tree1 = tree.asInstanceOf [tpd.Tree ]
587587 inContext(preErasureCtx):
@@ -1049,22 +1049,20 @@ object Erasure {
10491049 EmptyTree
10501050
10511051 override def typedClassDef (cdef : untpd.TypeDef , cls : ClassSymbol )(using Context ): Tree =
1052- if cls.is(Flags .Erased ) then erasedDef(cls)
1053- else
1054- val typedTree @ TypeDef (name, impl @ Template (constr, _, self, _)) = super .typedClassDef(cdef, cls): @ unchecked
1055- // In the case where a trait extends a class, we need to strip any non trait class from the signature
1056- // and accept the first one (see tests/run/mixins.scala)
1057- val newTraits = impl.parents.tail.filterConserve: tree =>
1058- def isTraitConstructor = tree match
1059- case Trees .Block (_, expr) => // Specific management for trait constructors (see tests/pos/i9213.scala)
1060- expr.symbol.isConstructor && expr.symbol.owner.is(Flags .Trait )
1061- case _ => tree.symbol.isConstructor && tree.symbol.owner.is(Flags .Trait )
1062- tree.symbol.is(Flags .Trait ) || isTraitConstructor
1063-
1064- val newParents =
1065- if impl.parents.tail eq newTraits then impl.parents
1066- else impl.parents.head :: newTraits
1067- cpy.TypeDef (typedTree)(rhs = cpy.Template (impl)(parents = newParents))
1052+ val typedTree @ TypeDef (name, impl @ Template (constr, _, self, _)) = super .typedClassDef(cdef, cls): @ unchecked
1053+ // In the case where a trait extends a class, we need to strip any non trait class from the signature
1054+ // and accept the first one (see tests/run/mixins.scala)
1055+ val newTraits = impl.parents.tail.filterConserve: tree =>
1056+ def isTraitConstructor = tree match
1057+ case Trees .Block (_, expr) => // Specific management for trait constructors (see tests/pos/i9213.scala)
1058+ expr.symbol.isConstructor && expr.symbol.owner.is(Flags .Trait )
1059+ case _ => tree.symbol.isConstructor && tree.symbol.owner.is(Flags .Trait )
1060+ tree.symbol.is(Flags .Trait ) || isTraitConstructor
1061+
1062+ val newParents =
1063+ if impl.parents.tail eq newTraits then impl.parents
1064+ else impl.parents.head :: newTraits
1065+ cpy.TypeDef (typedTree)(rhs = cpy.Template (impl)(parents = newParents))
10681066
10691067 override def typedAnnotated (tree : untpd.Annotated , pt : Type )(using Context ): Tree =
10701068 typed(tree.arg, pt)
0 commit comments