Skip to content

Commit

Permalink
Fix #4357: Avoid cyclic reference when parsing Java classfile
Browse files Browse the repository at this point in the history
We force all types appearing in the extends clause using `cook` before
completing the current class, in B_1.java this means we force `C` before
`B_1` is completed, ClassfileLoader#load ends up calling
`scalacLinkedClass` which before this commit forced the owner of `C`,
causing a cycle.
  • Loading branch information
smarter committed Apr 21, 2018
1 parent 9c83d27 commit ae2d13a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/SymDenotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,7 @@ object SymDenotations {
*/
private def companionNamed(name: TypeName)(implicit ctx: Context): Symbol =
if (owner.isClass)
owner.info.decl(name).suchThat(_.isCoDefinedWith(symbol)).symbol
owner.unforcedDecls.lookup(name).suchThat(_.isCoDefinedWith(symbol)).symbol
else if (!owner.exists || ctx.compilationUnit == null)
NoSymbol
else if (!ctx.compilationUnit.tpdTree.isEmpty)
Expand Down
4 changes: 4 additions & 0 deletions tests/pos-java-interop/i4357/B_1.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
public class B_1 extends A<B_1.C> {
public static class C {};
}
class A<T> {}
3 changes: 3 additions & 0 deletions tests/pos-java-interop/i4357/Test_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
object Test {
val b: B_1 = new B_1()
}

0 comments on commit ae2d13a

Please sign in to comment.