Skip to content

Commit d7cf307

Browse files
Add proper parent to inner class info
This creates a satisfactory type for the new extending class, but it causes an assertion error when checking after inlining: ``` 5 |class B extends A[Int] |^^^^^^^^^^^^^^^^^^^^^^ *** error while checking tests\pos\inline-trait-body-trait.scala after phase inlining *** Exception in thread "main" java.lang.AssertionError: assertion failed: orphan param: U, hash of binder = 2032399795, tree = <empty>, type = AppliedType(TypeRef(ThisType(TypeRef(ThisType(TypeRef(NoPrefix,module class <empty>)),class B)),trait InnerA$trait),List(TypeParamRef(U))) ```
1 parent 80a5ec0 commit d7cf307

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

compiler/src/dotty/tools/dotc/inlines/Inlines.scala

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,13 +599,19 @@ object Inlines:
599599
private def inlinedClassSym(sym: ClassSymbol, withoutFlags: FlagSet = EmptyFlags)(using Context): ClassSymbol =
600600
sym.info match {
601601
case clsInfo: ClassInfo =>
602+
val typeParams: List[Type] = sym.primaryConstructor.info match {
603+
case poly: PolyType => poly.paramRefs
604+
case _ => Nil
605+
}
606+
// Extend inner class from inline trait to preserve typing
607+
val newParent = ctx.owner.thisType.select(sym).appliedTo(typeParams)
602608
val inlinedSym = newClassSymbol(
603609
ctx.owner,
604610
sym.name,
605611
(sym.flags | Synthetic) &~ withoutFlags,
606612
newCls => {
607613
val ClassInfo(prefix, _, parents, _, selfInfo) = inlinerTypeMap.mapClassInfo(clsInfo)
608-
ClassInfo(prefix, newCls, parents :+ ctx.owner.thisType.select(sym), Scopes.newScope, selfInfo) // TODO fix new parent type (wrong symbol?)
614+
ClassInfo(prefix, newCls, parents :+ newParent, Scopes.newScope, selfInfo) // TODO fix selfInfo (what to use?)
609615
},
610616
sym.privateWithin,
611617
spanCoord(parent.span)

0 commit comments

Comments
 (0)