KT-2257 fix. private namespace visibility becomes protected in java land
This commit is contained in:
@@ -1000,7 +1000,7 @@ public class JetTypeMapper {
|
||||
return defaultFlags;
|
||||
}
|
||||
if (p.getContainingDeclaration() instanceof NamespaceDescriptor) {
|
||||
return ACC_PUBLIC;
|
||||
return ACC_PROTECTED;
|
||||
}
|
||||
return ACC_PRIVATE;
|
||||
}
|
||||
|
||||
@@ -117,23 +117,21 @@ public class NamespaceCodegen {
|
||||
}
|
||||
|
||||
private void generate(JetFile file, boolean multiFile) {
|
||||
NamespaceDescriptor descriptor = state.getBindingContext().get(BindingContext.FILE_TO_NAMESPACE, file);
|
||||
for (JetDeclaration declaration : file.getDeclarations()) {
|
||||
if (declaration instanceof JetProperty) {
|
||||
NamespaceDescriptor descriptor = state.getBindingContext().get(BindingContext.FILE_TO_NAMESPACE, file);
|
||||
final CodegenContext context = CodegenContexts.STATIC.intoNamespace(descriptor);
|
||||
state.getInjector().getMemberCodegen().generateFunctionOrProperty(
|
||||
(JetTypeParameterListOwner) declaration, context, v.getClassBuilder());
|
||||
}
|
||||
else if (declaration instanceof JetNamedFunction) {
|
||||
if (!multiFile) {
|
||||
NamespaceDescriptor descriptor = state.getBindingContext().get(BindingContext.FILE_TO_NAMESPACE, file);
|
||||
final CodegenContext context = CodegenContexts.STATIC.intoNamespace(descriptor);
|
||||
state.getInjector().getMemberCodegen().generateFunctionOrProperty(
|
||||
(JetTypeParameterListOwner) declaration, context, v.getClassBuilder());
|
||||
}
|
||||
}
|
||||
else if (declaration instanceof JetClassOrObject) {
|
||||
NamespaceDescriptor descriptor = state.getBindingContext().get(BindingContext.FILE_TO_NAMESPACE, file);
|
||||
final CodegenContext context = CodegenContexts.STATIC.intoNamespace(descriptor);
|
||||
state.getInjector().getClassCodegen().generate(context, (JetClassOrObject) declaration);
|
||||
}
|
||||
@@ -169,7 +167,6 @@ public class NamespaceCodegen {
|
||||
|
||||
for (JetDeclaration declaration : file.getDeclarations()) {
|
||||
if (declaration instanceof JetNamedFunction) {
|
||||
NamespaceDescriptor descriptor = state.getBindingContext().get(BindingContext.FILE_TO_NAMESPACE, file);
|
||||
{
|
||||
final CodegenContext context = CodegenContexts.STATIC.intoNamespace(descriptor);
|
||||
state.getInjector().getMemberCodegen().generateFunctionOrProperty((JetTypeParameterListOwner) declaration, context, builder);
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
fun box() = o + k
|
||||
|
||||
private val o = "O"
|
||||
@@ -0,0 +1,3 @@
|
||||
private val k = "K"
|
||||
|
||||
fun ignore() = o
|
||||
@@ -498,4 +498,10 @@ public class ClassGenTest extends CodegenTestCase {
|
||||
//System.out.println(generateToText());
|
||||
blackBox();
|
||||
}
|
||||
|
||||
public void testKt2257() {
|
||||
createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY);
|
||||
blackBoxMultiFile("regressions/kt2257_1.kt", "regressions/kt2257_2.kt");
|
||||
System.out.println(generateToText());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ public class PropertyGenTest extends CodegenTestCase {
|
||||
final Field field = fields[0];
|
||||
field.setAccessible(true);
|
||||
assertEquals("x", field.getName());
|
||||
assertEquals(Modifier.PUBLIC | Modifier.STATIC | Modifier.FINAL, field.getModifiers());
|
||||
assertEquals(Modifier.PROTECTED | Modifier.STATIC | Modifier.FINAL, field.getModifiers());
|
||||
assertEquals(239, field.get(null));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user