@@ -105,12 +105,6 @@ class Erasure extends Phase with DenotTransformer {
105
105
if oldSymbol.isRetainedInlineMethod then
106
106
newFlags = newFlags &~ Flags .Inline
107
107
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 _ =>
114
108
// TODO: define derivedSymDenotation?
115
109
if ref.is(Flags .PackageClass )
116
110
|| ! ref.isClass // non-package classes are always copied since their base types change
@@ -550,8 +544,11 @@ object Erasure {
550
544
case _ => tree.symbol.isEffectivelyErased
551
545
}
552
546
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
+ */
555
552
private def checkNotErased (tree : Tree )(using Context ): tree.type =
556
553
if ! ctx.mode.is(Mode .Type ) then
557
554
if isErased(tree) then
@@ -582,6 +579,9 @@ object Erasure {
582
579
tree
583
580
end checkNotErased
584
581
582
+ /** Check that initializers of erased vals and arguments to erased parameters
583
+ * are pure expressions.
584
+ */
585
585
def checkPureErased (tree : untpd.Tree , isArgument : Boolean , isImplicit : Boolean = false )(using Context ): Unit =
586
586
val tree1 = tree.asInstanceOf [tpd.Tree ]
587
587
inContext(preErasureCtx):
@@ -1049,22 +1049,20 @@ object Erasure {
1049
1049
EmptyTree
1050
1050
1051
1051
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))
1068
1066
1069
1067
override def typedAnnotated (tree : untpd.Annotated , pt : Type )(using Context ): Tree =
1070
1068
typed(tree.arg, pt)
0 commit comments