From ebe190d37e65e5e80d2a7ad04db165673b12e299 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 19 Jul 2021 19:27:58 +0200 Subject: [PATCH 1/2] Suppress "no outer defs" check for Java sources Fixes #13106 --- compiler/src/dotty/tools/dotc/typer/Typer.scala | 3 ++- tests/pos/i13106.java | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 tests/pos/i13106.java diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index 7e0191048a9c..2b77606933d7 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -382,7 +382,8 @@ class Typer extends Namer if !curOwner.is(Package) || isDefinedInCurrentUnit(defDenot) then result = checkNewOrShadowed(found, Definition) // no need to go further out, we found highest prec entry found match - case found: NamedType if curOwner.isClass && isInherited(found.denot) => + case found: NamedType + if curOwner.isClass && isInherited(found.denot) && !ctx.compilationUnit.isJava => checkNoOuterDefs(found.denot, ctx, ctx) case _ => else diff --git a/tests/pos/i13106.java b/tests/pos/i13106.java new file mode 100644 index 000000000000..3a61a7e88901 --- /dev/null +++ b/tests/pos/i13106.java @@ -0,0 +1,7 @@ +public final class A { + public static final class C { } + public static final class D { + public static final class C { } + public C foo() { return new C(); } + } +} \ No newline at end of file From ac2c70ad356af079f3487a6a5e44ef989da54005 Mon Sep 17 00:00:00 2001 From: odersky Date: Fri, 23 Jul 2021 13:19:31 +0200 Subject: [PATCH 2/2] Update tests/pos/i13106.java MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Paweł Marks --- tests/pos/i13106.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/pos/i13106.java b/tests/pos/i13106.java index 3a61a7e88901..6a10fd3cfa9b 100644 --- a/tests/pos/i13106.java +++ b/tests/pos/i13106.java @@ -1,7 +1,7 @@ -public final class A { +final class A { public static final class C { } public static final class D { public static final class C { } public C foo() { return new C(); } } -} \ No newline at end of file +}