@@ -524,7 +524,7 @@ object Inlines:
524
524
525
525
def expandDefs (overriddenDecls : Set [Symbol ]): List [Tree ] =
526
526
val stats = Inlines .defsToInline(parentSym).filterNot(stat => overriddenDecls.contains(stat.symbol))
527
- val inlinedSymbols = stats.map(stat => inlinedMember (stat.symbol))
527
+ val inlinedSymbols = stats.map(stat => inlinedSym (stat.symbol))
528
528
stats.zip(inlinedSymbols).map(expandStat)
529
529
end expandDefs
530
530
@@ -576,42 +576,41 @@ object Inlines:
576
576
case stat : TypeDef =>
577
577
inlinedTypeDef(stat, inlinedSym)
578
578
579
- private def inlinedMember (sym : Symbol )(using Context ): Symbol =
579
+ private def inlinedSym (sym : Symbol , withoutFlags : FlagSet = EmptyFlags )(using Context ): Symbol =
580
+ if sym.isClass then inlinedClassSym(sym.asClass, withoutFlags) else inlinedMemberSym(sym, withoutFlags)
581
+
582
+ private def inlinedClassSym (sym : ClassSymbol , withoutFlags : FlagSet = EmptyFlags )(using Context ): ClassSymbol =
580
583
sym.info match {
581
584
case ClassInfo (prefix, cls, declaredParents, scope, selfInfo) =>
582
585
val baseThisCls = ThisType .raw(ctx.owner.typeRef).select(sym)
583
586
val inlinedSym = newClassSymbol(
584
587
ctx.owner,
585
588
sym.asType.name,
586
- sym.flags | Synthetic ,
589
+ ( sym.flags | Synthetic ) &~ withoutFlags ,
587
590
clsSym => ClassInfo (inlinerTypeMap(prefix), clsSym, declaredParents :+ baseThisCls, Scopes .newScope, selfInfo)
588
591
)
589
592
inlinedSym.setTargetName(sym.name ++ str.NAME_JOIN ++ ctx.owner.name)
590
593
inlinedSym
591
594
case _ =>
592
- var name = sym.name
593
- var flags = sym.flags | Synthetic
594
- if sym.isType || ! sym.is(Private ) then flags |= Override
595
- if sym.isTermParamAccessor then
596
- flags &~= ParamAccessor
597
- if sym.is(Local ) then
598
- name = name.expandedName(parentSym)
599
- localParamAccessorsNames(sym.name) = name
600
- sym.copy(
601
- owner = ctx.owner,
602
- name = name,
603
- flags = flags,
604
- info = inlinerTypeMap(sym.info),
605
- coord = spanCoord(parent.span)).entered
595
+ report.error(s " Class symbol ${sym.show} does not have class info " )
596
+ sym
606
597
}
607
598
608
- private def inlinedStat (stat : Tree )(using Context ): Tree =
609
- val inlinedSym = inlinedMember(stat.symbol)
610
- stat match {
611
- // TODO check if symbols must be copied
612
- case tree : DefDef => inlinedDefDef(tree, inlinedSym)
613
- case tree : ValDef => inlinedValDef(tree, inlinedSym)
614
- }
599
+ private def inlinedMemberSym (sym : Symbol , withoutFlags : FlagSet = EmptyFlags )(using Context ): Symbol =
600
+ var name = sym.name
601
+ var flags = sym.flags | Synthetic
602
+ if sym.isType || ! sym.is(Private ) then flags |= Override
603
+ if sym.isTermParamAccessor then
604
+ flags &~= ParamAccessor
605
+ if sym.is(Local ) then
606
+ name = name.expandedName(parentSym)
607
+ localParamAccessorsNames(sym.name) = name
608
+ sym.copy(
609
+ owner = ctx.owner,
610
+ name = name,
611
+ flags = flags &~ withoutFlags,
612
+ info = inlinerTypeMap(sym.info),
613
+ coord = spanCoord(parent.span)).entered
615
614
616
615
private def inlinedValDef (vdef : ValDef , inlinedSym : Symbol )(using Context ): ValDef =
617
616
val rhs =
@@ -634,17 +633,17 @@ object Inlines:
634
633
635
634
private def inlinedPrimaryConstructorDefDef (ddef : DefDef )(using Context ): DefDef =
636
635
// TODO check if symbol must be copied
637
- val inlinedSym = inlinedMember(ddef.symbol)
638
- inlinedSym.resetFlag(Override )
636
+ val inlinedSym = inlinedMemberSym(ddef.symbol, withoutFlags = Override )
639
637
val constr = inlinedDefDef(ddef, inlinedSym)
640
638
cpy.DefDef (constr)(tpt = TypeTree (defn.UnitType ), rhs = EmptyTree )
641
639
642
- private def inlinedClassDef (clsDef : TypeDef , inlinedSym : ClassSymbol )(using Context ): Tree =
640
+ private def inlinedClassDef (clsDef : TypeDef , inlinedCls : ClassSymbol )(using Context ): Tree =
643
641
val TypeDef (_, tmpl : Template ) = clsDef : @ unchecked
644
- val (constr, body) = inContext(ctx.withOwner(inlinedSym)) {
645
- (inlinedPrimaryConstructorDefDef(tmpl.constr), tmpl.body.map(inlinedStat))
642
+ val (constr, body) = inContext(ctx.withOwner(inlinedCls)) {
643
+ val inlinedTmpl = tmpl.body.map(stat => expandStat(stat, inlinedSym(stat.symbol)))
644
+ (inlinedPrimaryConstructorDefDef(tmpl.constr), inlinedTmpl)
646
645
}
647
- val clsDef1 = tpd.ClassDefWithParents (inlinedSym , constr, tmpl.parents :+ This (ctx.owner.asClass).select(clsDef.symbol), body)
646
+ val clsDef1 = tpd.ClassDefWithParents (inlinedCls , constr, tmpl.parents :+ This (ctx.owner.asClass).select(clsDef.symbol), body)
648
647
inlined(clsDef1)._2.withSpan(clsDef.span) // TODO adapt parents
649
648
650
649
private def inlinedTypeDef (tdef : TypeDef , inlinedSym : Symbol )(using Context ): TypeDef =
0 commit comments