Skip to content

Commit 77208c2

Browse files
committed
Fix #3273: Extend cooking to parent types
1 parent 953a385 commit 77208c2

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ object ClassfileParser {
3232
case tp @ AppliedType(tycon, args) =>
3333
// disregard tycon itself, but map over it to visit the prefix
3434
tp.derivedAppliedType(mapOver(tycon), args.mapConserve(this))
35+
case tp @ TempPolyType(_, tpe) =>
36+
val tpe1 = this(tpe)
37+
if (tpe1 eq tpe) tp else tp.copy(tpe = tpe1)
38+
case tp @ TempClassInfoType(parents, _, _) =>
39+
val parents1 = parents.mapConserve(this)
40+
if (parents eq parents1) tp else tp.copy(parentTypes = parents1)
3541
case _ =>
3642
mapOver(tp)
3743
}
@@ -154,7 +160,7 @@ class ClassfileParser(
154160

155161
for (i <- 0 until in.nextChar) parseMember(method = false)
156162
for (i <- 0 until in.nextChar) parseMember(method = true)
157-
classInfo = parseAttributes(classRoot.symbol, classInfo)
163+
classInfo = cook.apply(parseAttributes(classRoot.symbol, classInfo))
158164
if (isAnnotation) addAnnotationConstructor(classInfo)
159165

160166
val companionClassMethod = ctx.synthesizeCompanionMethod(nme.COMPANION_CLASS_METHOD, classRoot, moduleRoot)

tests/pos/i3273/Bar_1.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class Bar_1 {
2+
static abstract class A<X> extends B {
3+
abstract B foo();
4+
}
5+
static abstract class B<X> {
6+
abstract A bar();
7+
}
8+
}

tests/pos/i3273/client_2.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class Client {
2+
val a = (_: Bar_1.A[AnyRef]).foo()
3+
val b = (_: Bar_1.B[AnyRef]).bar()
4+
def test(x: Bar_1.A[AnyRef]): Bar_1.B[_] = x
5+
}

0 commit comments

Comments
 (0)