diff --git a/compiler/src/dotty/tools/dotc/core/SymDenotations.scala b/compiler/src/dotty/tools/dotc/core/SymDenotations.scala index 76ee96c136fd..995fd474d0bb 100644 --- a/compiler/src/dotty/tools/dotc/core/SymDenotations.scala +++ b/compiler/src/dotty/tools/dotc/core/SymDenotations.scala @@ -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) diff --git a/tests/pos-java-interop/i4357/B_1.java b/tests/pos-java-interop/i4357/B_1.java new file mode 100644 index 000000000000..1efe61b28731 --- /dev/null +++ b/tests/pos-java-interop/i4357/B_1.java @@ -0,0 +1,4 @@ +public class B_1 extends A { + public static class C {}; +} +class A {} diff --git a/tests/pos-java-interop/i4357/Test_2.scala b/tests/pos-java-interop/i4357/Test_2.scala new file mode 100644 index 000000000000..e98013d448a4 --- /dev/null +++ b/tests/pos-java-interop/i4357/Test_2.scala @@ -0,0 +1,3 @@ +object Test { + val b: B_1 = new B_1() +}