Skip to content

Commit db233d4

Browse files
Merge pull request #7994 from dotty-staging/fix-#7959
Fix #7959: Don't check Java symbols for private leaks
2 parents 83ab6c7 + a8d069b commit db233d4

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

compiler/src/dotty/tools/dotc/core/Flags.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,7 @@ object Flags {
544544
val InlineByNameProxy: FlagSet = InlineProxy | Method
545545
val JavaEnumTrait: FlagSet = JavaDefined | Enum // A Java enum trait
546546
val JavaEnumValue: FlagSet = JavaDefined | EnumValue // A Java enum value
547+
val JavaOrPrivateOrSynthetic: FlagSet = JavaDefined | Private | Synthetic
547548
val StaticProtected: FlagSet = JavaDefined | JavaStatic | Protected // Java symbol which is `protected` and `static`
548549
val JavaModule: FlagSet = JavaDefined | Module // A Java companion object
549550
val JavaInterface: FlagSet = JavaDefined | NoInits | Trait

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@ trait TypeAssigner {
161161
avoid(expr.tpe, localSyms(bindings).filter(_.isTerm))
162162

163163
def avoidPrivateLeaks(sym: Symbol)(implicit ctx: Context): Type =
164-
if (!sym.isOneOf(PrivateOrSynthetic) && sym.owner.isClass) checkNoPrivateLeaks(sym)
164+
if sym.owner.isClass && !sym.isOneOf(JavaOrPrivateOrSynthetic)
165+
then checkNoPrivateLeaks(sym)
165166
else sym.info
166167

167168
private def toRepeated(tree: Tree, from: ClassSymbol)(implicit ctx: Context): Tree =

tests/pos/i7959.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
public class i7959 {
2+
private static class Foo {
3+
Foo() { }
4+
}
5+
}

0 commit comments

Comments
 (0)