unification of accessable descriptor lookup between functions and properties
This commit is contained in:
@@ -1656,44 +1656,43 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
|||||||
|
|
||||||
private PropertyDescriptor accessablePropertyDescriptor(PropertyDescriptor propertyDescriptor) {
|
private PropertyDescriptor accessablePropertyDescriptor(PropertyDescriptor propertyDescriptor) {
|
||||||
PropertySetterDescriptor setter = propertyDescriptor.getSetter();
|
PropertySetterDescriptor setter = propertyDescriptor.getSetter();
|
||||||
if ((propertyDescriptor.getVisibility() == Visibilities.PRIVATE ||
|
PropertyGetterDescriptor getter = propertyDescriptor.getGetter();
|
||||||
(setter != null && setter.getVisibility() == Visibilities.PRIVATE))
|
|
||||||
&& !DescriptorUtils.isClassObject(propertyDescriptor.getContainingDeclaration())
|
final int flag = CodegenUtil.getVisibilityAccessFlag(propertyDescriptor) |
|
||||||
&& propertyDescriptor.getContainingDeclaration() instanceof ClassDescriptor) {
|
(getter == null ? 0 : CodegenUtil.getVisibilityAccessFlag(getter)) |
|
||||||
if (context.getClassOrNamespaceDescriptor() != propertyDescriptor.getContainingDeclaration()) {
|
(setter == null ? 0 : CodegenUtil.getVisibilityAccessFlag(setter));
|
||||||
DeclarationDescriptor enclosed = propertyDescriptor.getContainingDeclaration();
|
|
||||||
if (!context.hasThisDescriptor() || enclosed != context.getThisDescriptor()) {
|
if ((flag & ACC_PRIVATE) == 0) {
|
||||||
CodegenContext c = context;
|
return propertyDescriptor;
|
||||||
while (c != null && c.getContextDescriptor() != enclosed) {
|
|
||||||
c = c.getParentContext();
|
|
||||||
}
|
|
||||||
if (c != null) {
|
|
||||||
propertyDescriptor = (PropertyDescriptor) c.getAccessor(propertyDescriptor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return propertyDescriptor;
|
|
||||||
|
return (PropertyDescriptor) accessibleDescriptor(context, propertyDescriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
private FunctionDescriptor accessableFunctionDescriptor(FunctionDescriptor fd) {
|
private FunctionDescriptor accessableFunctionDescriptor(FunctionDescriptor fd) {
|
||||||
if (fd.getVisibility() != Visibilities.PRIVATE || fd.getContainingDeclaration() instanceof NamespaceDescriptor) {
|
final int flag = CodegenUtil.getVisibilityAccessFlag(fd);
|
||||||
|
if ((flag & ACC_PRIVATE) == 0) {
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (context.getClassOrNamespaceDescriptor() != fd.getContainingDeclaration()) {
|
return (FunctionDescriptor) accessibleDescriptor(context, fd);
|
||||||
DeclarationDescriptor enclosed = fd.getContainingDeclaration();
|
}
|
||||||
if (enclosed != context.getThisDescriptor()) {
|
|
||||||
|
private static MemberDescriptor accessibleDescriptor(CodegenContext context, DeclarationDescriptor descriptor) {
|
||||||
|
if (context.getClassOrNamespaceDescriptor() != descriptor.getContainingDeclaration()) {
|
||||||
|
DeclarationDescriptor enclosed = descriptor.getContainingDeclaration();
|
||||||
|
if (context.hasThisDescriptor() && enclosed != context.getThisDescriptor()) {
|
||||||
CodegenContext c = context;
|
CodegenContext c = context;
|
||||||
while (c.getContextDescriptor() != enclosed) {
|
while (c.getContextDescriptor() != enclosed) {
|
||||||
c = c.getParentContext();
|
c = c.getParentContext();
|
||||||
assert c != null;
|
if (c == null) {
|
||||||
|
return (MemberDescriptor) descriptor;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fd = (FunctionDescriptor) c.getAccessor(fd);
|
return (MemberDescriptor) c.getAccessor(descriptor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return (MemberDescriptor) descriptor;
|
||||||
return fd;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private StackValue invokeFunction(
|
private StackValue invokeFunction(
|
||||||
|
|||||||
@@ -381,6 +381,7 @@ public class ClassGenTest extends CodegenTestCase {
|
|||||||
public void testKt1018() throws Exception {
|
public void testKt1018() throws Exception {
|
||||||
createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY);
|
createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY);
|
||||||
blackBoxFile("regressions/kt1018.kt");
|
blackBoxFile("regressions/kt1018.kt");
|
||||||
|
System.out.println(generateToText());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testKt1120() throws Exception {
|
public void testKt1120() throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user