Skip to content

Map parents of local classes in TreeTypeMap #12633

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions compiler/src/dotty/tools/dotc/core/Symbols.scala
Original file line number Diff line number Diff line change
Expand Up @@ -818,9 +818,10 @@ object Symbols {
val oinfo = original.info match
case ClassInfo(pre, _, parents, decls, selfInfo) =>
assert(original.isClass)
val parents1 = parents.mapConserve(ttmap.mapType)
val otypeParams = original.typeParams
if otypeParams.isEmpty then
ClassInfo(pre, copy.asClass, parents, decls.cloneScope, selfInfo)
ClassInfo(pre, copy.asClass, parents1, decls.cloneScope, selfInfo)
else
// copy type params, enter other definitions unchanged
// type parameters need to be copied early, since other type
Expand All @@ -829,11 +830,11 @@ object Symbols {
val newTypeParams = mapSymbols(original.typeParams, ttmap1, mapAlways = true)
newTypeParams.foreach(decls1.enter)
for sym <- decls do if !sym.is(TypeParam) then decls1.enter(sym)
val parents1 = parents.map(_.substSym(otypeParams, newTypeParams))
val parents2 = parents1.map(_.substSym(otypeParams, newTypeParams))
val selfInfo1 = selfInfo match
case selfInfo: Type => selfInfo.substSym(otypeParams, newTypeParams)
case _ => selfInfo
ClassInfo(pre, copy.asClass, parents1, decls1, selfInfo1)
ClassInfo(pre, copy.asClass, parents2, decls1, selfInfo1)
case oinfo => oinfo

denot.info = oinfo // needed as otherwise we won't be able to go from Sym -> parents & etc
Expand Down
10 changes: 10 additions & 0 deletions tests/pos/i12632.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class CCC[S](val i: Int) {
def this() =
this(
{
val z = new Ordering[S] {
override def compare(x: S, y: S): Int = ???
}
3
})
}