Skip to content

Commit ebe190d

Browse files
committed
Suppress "no outer defs" check for Java sources
Fixes scala#13106
1 parent cc47c56 commit ebe190d

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,8 @@ class Typer extends Namer
382382
if !curOwner.is(Package) || isDefinedInCurrentUnit(defDenot) then
383383
result = checkNewOrShadowed(found, Definition) // no need to go further out, we found highest prec entry
384384
found match
385-
case found: NamedType if curOwner.isClass && isInherited(found.denot) =>
385+
case found: NamedType
386+
if curOwner.isClass && isInherited(found.denot) && !ctx.compilationUnit.isJava =>
386387
checkNoOuterDefs(found.denot, ctx, ctx)
387388
case _ =>
388389
else

tests/pos/i13106.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
public final class A {
2+
public static final class C { }
3+
public static final class D {
4+
public static final class C { }
5+
public C foo() { return new C(); }
6+
}
7+
}

0 commit comments

Comments
 (0)