Skip to content

Commit f9adeea

Browse files
authored
Merge pull request #12633 from dotty-staging/fix-12632
Map parents of local classes in TreeTypeMap
2 parents c95cc72 + 6a7b6b0 commit f9adeea

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

compiler/src/dotty/tools/dotc/core/Symbols.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -818,9 +818,10 @@ object Symbols {
818818
val oinfo = original.info match
819819
case ClassInfo(pre, _, parents, decls, selfInfo) =>
820820
assert(original.isClass)
821+
val parents1 = parents.mapConserve(ttmap.mapType)
821822
val otypeParams = original.typeParams
822823
if otypeParams.isEmpty then
823-
ClassInfo(pre, copy.asClass, parents, decls.cloneScope, selfInfo)
824+
ClassInfo(pre, copy.asClass, parents1, decls.cloneScope, selfInfo)
824825
else
825826
// copy type params, enter other definitions unchanged
826827
// type parameters need to be copied early, since other type
@@ -829,11 +830,11 @@ object Symbols {
829830
val newTypeParams = mapSymbols(original.typeParams, ttmap1, mapAlways = true)
830831
newTypeParams.foreach(decls1.enter)
831832
for sym <- decls do if !sym.is(TypeParam) then decls1.enter(sym)
832-
val parents1 = parents.map(_.substSym(otypeParams, newTypeParams))
833+
val parents2 = parents1.map(_.substSym(otypeParams, newTypeParams))
833834
val selfInfo1 = selfInfo match
834835
case selfInfo: Type => selfInfo.substSym(otypeParams, newTypeParams)
835836
case _ => selfInfo
836-
ClassInfo(pre, copy.asClass, parents1, decls1, selfInfo1)
837+
ClassInfo(pre, copy.asClass, parents2, decls1, selfInfo1)
837838
case oinfo => oinfo
838839

839840
denot.info = oinfo // needed as otherwise we won't be able to go from Sym -> parents & etc

tests/pos/i12632.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class CCC[S](val i: Int) {
2+
def this() =
3+
this(
4+
{
5+
val z = new Ordering[S] {
6+
override def compare(x: S, y: S): Int = ???
7+
}
8+
3
9+
})
10+
}

0 commit comments

Comments
 (0)