Skip to content

Commit b7fbb39

Browse files
authored
Merge pull request #3317 from dotty-staging/fix-#3273-2
Fix #3273: Extend cooking to parent types
2 parents 261c3d4 + 5cf5164 commit b7fbb39

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-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)

compiler/test/dotty/tools/dotc/CompilationTests.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ class CompilationTests extends ParallelTesting {
6666
),
6767
scala2Mode
6868
) +
69+
compileFilesInDir("../tests/pos-special/i3273", defaultOptions) +
6970
compileFilesInDir("../tests/pos-special/spec-t5545", defaultOptions) +
7071
compileFilesInDir("../tests/pos-special/strawman-collections", defaultOptions) +
7172
compileFile("../scala2-library/src/library/scala/collection/immutable/IndexedSeq.scala", defaultOptions) +
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+
}
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)