Skip to content

Fix #7959: Don't check Java symbols for private leaks #7994

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions compiler/src/dotty/tools/dotc/core/Flags.scala
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,7 @@ object Flags {
val InlineByNameProxy: FlagSet = InlineProxy | Method
val JavaEnumTrait: FlagSet = JavaDefined | Enum // A Java enum trait
val JavaEnumValue: FlagSet = JavaDefined | EnumValue // A Java enum value
val JavaOrPrivateOrSynthetic: FlagSet = JavaDefined | Private | Synthetic
val StaticProtected: FlagSet = JavaDefined | JavaStatic | Protected // Java symbol which is `protected` and `static`
val JavaModule: FlagSet = JavaDefined | Module // A Java companion object
val JavaInterface: FlagSet = JavaDefined | NoInits | Trait
Expand Down
3 changes: 2 additions & 1 deletion compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ trait TypeAssigner {
avoid(expr.tpe, localSyms(bindings).filter(_.isTerm))

def avoidPrivateLeaks(sym: Symbol)(implicit ctx: Context): Type =
if (!sym.isOneOf(PrivateOrSynthetic) && sym.owner.isClass) checkNoPrivateLeaks(sym)
if sym.owner.isClass && !sym.isOneOf(JavaOrPrivateOrSynthetic)
then checkNoPrivateLeaks(sym)
else sym.info

private def toRepeated(tree: Tree, from: ClassSymbol)(implicit ctx: Context): Tree =
Expand Down
5 changes: 5 additions & 0 deletions tests/pos/i7959.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
public class i7959 {
private static class Foo {
Foo() { }
}
}