Skip to content

Fix #3273: Extend cooking to parent types #3317

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 3 commits into from
Oct 18, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ object ClassfileParser {
case tp @ AppliedType(tycon, args) =>
// disregard tycon itself, but map over it to visit the prefix
tp.derivedAppliedType(mapOver(tycon), args.mapConserve(this))
case tp @ TempPolyType(_, tpe) =>
val tpe1 = this(tpe)
if (tpe1 eq tpe) tp else tp.copy(tpe = tpe1)
case tp @ TempClassInfoType(parents, _, _) =>
val parents1 = parents.mapConserve(this)
if (parents eq parents1) tp else tp.copy(parentTypes = parents1)
case _ =>
mapOver(tp)
}
Expand Down Expand Up @@ -154,7 +160,7 @@ class ClassfileParser(

for (i <- 0 until in.nextChar) parseMember(method = false)
for (i <- 0 until in.nextChar) parseMember(method = true)
classInfo = parseAttributes(classRoot.symbol, classInfo)
classInfo = cook.apply(parseAttributes(classRoot.symbol, classInfo))
if (isAnnotation) addAnnotationConstructor(classInfo)

val companionClassMethod = ctx.synthesizeCompanionMethod(nme.COMPANION_CLASS_METHOD, classRoot, moduleRoot)
Expand Down
8 changes: 8 additions & 0 deletions tests/pos/i3273/Bar_1.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class Bar_1 {
static abstract class A<X> extends B {
abstract B foo();
}
static abstract class B<X> {
abstract A bar();
}
}
5 changes: 5 additions & 0 deletions tests/pos/i3273/client_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class Client {
val a = (_: Bar_1.A[AnyRef]).foo()
val b = (_: Bar_1.B[AnyRef]).bar()
def test(x: Bar_1.A[AnyRef]): Bar_1.B[_] = x
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to test these cases under joint compilation, too (usually changes to classfile parser need to be mirrored in JavaParsers)