KT-36973 Keep private default interface members private

This commit is contained in:
Dmitry Petrov
2020-03-18 12:22:42 +03:00
parent 1c24a97b9e
commit dd27b3d4f1
12 changed files with 74 additions and 5 deletions
@@ -233,11 +233,10 @@ class JvmDeclarationFactory(
// Old backend doesn't generate ACC_FINAL on DefaultImpls methods.
modality = Modality.OPEN,
// Interface functions are always public, with one exception: clone in Cloneable, which is protected. However, Cloneable
// has no DefaultImpls, so this merely replicates the incorrect behavior of the old backend. We should rather not generate
// a bridge to clone when interface inherits from Cloneable at all. Below, we force everything, including those bridges,
// to be public so that we won't try to generate synthetic accessor for them.
visibility = Visibilities.PUBLIC,
// Interface functions are public or private, with one exception: clone in Cloneable, which is protected.
// However, Cloneable has no DefaultImpls, so this merely replicates the incorrect behavior of the old backend.
// We should rather not generate a bridge to clone when interface inherits from Cloneable at all.
visibility = if (interfaceFun.visibility == Visibilities.PRIVATE) Visibilities.PRIVATE else Visibilities.PUBLIC,
typeParametersFromContext = parent.typeParameters
)