Fixed codegen crash on use of protected synthetic extension property
This commit is contained in:
@@ -46,6 +46,7 @@ import org.jetbrains.kotlin.resolve.jvm.JvmClassName;
|
|||||||
import org.jetbrains.kotlin.resolve.jvm.JvmPackage;
|
import org.jetbrains.kotlin.resolve.jvm.JvmPackage;
|
||||||
import org.jetbrains.kotlin.resolve.jvm.JvmPrimitiveType;
|
import org.jetbrains.kotlin.resolve.jvm.JvmPrimitiveType;
|
||||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin;
|
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin;
|
||||||
|
import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor;
|
||||||
import org.jetbrains.kotlin.types.JetType;
|
import org.jetbrains.kotlin.types.JetType;
|
||||||
import org.jetbrains.kotlin.types.TypesPackage;
|
import org.jetbrains.kotlin.types.TypesPackage;
|
||||||
import org.jetbrains.org.objectweb.asm.*;
|
import org.jetbrains.org.objectweb.asm.*;
|
||||||
@@ -308,19 +309,38 @@ public class AsmUtil {
|
|||||||
if (isInterface(containingDeclaration)) {
|
if (isInterface(containingDeclaration)) {
|
||||||
return ACC_PUBLIC;
|
return ACC_PUBLIC;
|
||||||
}
|
}
|
||||||
|
|
||||||
Visibility memberVisibility = memberDescriptor.getVisibility();
|
Visibility memberVisibility = memberDescriptor.getVisibility();
|
||||||
if (memberVisibility == Visibilities.LOCAL && memberDescriptor instanceof CallableMemberDescriptor) {
|
if (memberVisibility == Visibilities.LOCAL && memberDescriptor instanceof CallableMemberDescriptor) {
|
||||||
return ACC_PUBLIC;
|
return ACC_PUBLIC;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isEnumEntry(memberDescriptor)) {
|
if (isEnumEntry(memberDescriptor)) {
|
||||||
return NO_FLAG_PACKAGE_PRIVATE;
|
return NO_FLAG_PACKAGE_PRIVATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (memberDescriptor instanceof ConstructorDescriptor && isAnonymousObject(memberDescriptor.getContainingDeclaration())) {
|
if (memberDescriptor instanceof ConstructorDescriptor && isAnonymousObject(memberDescriptor.getContainingDeclaration())) {
|
||||||
return NO_FLAG_PACKAGE_PRIVATE;
|
return NO_FLAG_PACKAGE_PRIVATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (memberDescriptor instanceof SyntheticJavaPropertyDescriptor) {
|
||||||
|
return getVisibilityAccessFlag(((SyntheticJavaPropertyDescriptor) memberDescriptor).getGetMethod());
|
||||||
|
}
|
||||||
|
if (memberDescriptor instanceof PropertyAccessorDescriptor) {
|
||||||
|
PropertyDescriptor property = ((PropertyAccessorDescriptor) memberDescriptor).getCorrespondingProperty();
|
||||||
|
if (property instanceof SyntheticJavaPropertyDescriptor) {
|
||||||
|
FunctionDescriptor method = memberDescriptor == property.getGetter()
|
||||||
|
? ((SyntheticJavaPropertyDescriptor) property).getGetMethod()
|
||||||
|
: ((SyntheticJavaPropertyDescriptor) property).getSetMethod();
|
||||||
|
assert method != null : "No setMethod in SyntheticJavaPropertyDescriptor";
|
||||||
|
return getVisibilityAccessFlag(method);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!Visibilities.isPrivate(memberVisibility)) {
|
if (!Visibilities.isPrivate(memberVisibility)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// the following code is only for PRIVATE visibility of member
|
// the following code is only for PRIVATE visibility of member
|
||||||
if (memberDescriptor instanceof ConstructorDescriptor) {
|
if (memberDescriptor instanceof ConstructorDescriptor) {
|
||||||
if (isNonCompanionObject(containingDeclaration) || isEnumEntry(containingDeclaration)) {
|
if (isNonCompanionObject(containingDeclaration) || isEnumEntry(containingDeclaration)) {
|
||||||
@@ -332,6 +352,7 @@ public class AsmUtil {
|
|||||||
return ACC_PROTECTED;
|
return ACC_PROTECTED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (containingDeclaration instanceof PackageFragmentDescriptor) {
|
if (containingDeclaration instanceof PackageFragmentDescriptor) {
|
||||||
return ACC_PUBLIC;
|
return ACC_PUBLIC;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
public class _protected {
|
||||||
|
protected String getOk() { return "OK"; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package p
|
||||||
|
|
||||||
|
import _protected
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
return KotlinClass().ok()
|
||||||
|
}
|
||||||
|
|
||||||
|
class KotlinClass : _protected() {
|
||||||
|
fun ok() = ok
|
||||||
|
}
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
public class _protectedSetter {
|
||||||
|
private String x = null;
|
||||||
|
|
||||||
|
public String getX() { return "OK"; }
|
||||||
|
protected void setX(String x) { this.x = x; }
|
||||||
|
}
|
||||||
+15
@@ -0,0 +1,15 @@
|
|||||||
|
package p
|
||||||
|
|
||||||
|
import _protectedSetter
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
return KotlinClass().ok()
|
||||||
|
}
|
||||||
|
|
||||||
|
class KotlinClass : _protectedSetter() {
|
||||||
|
fun ok(): String {
|
||||||
|
x = "o"
|
||||||
|
x += "k"
|
||||||
|
return x
|
||||||
|
}
|
||||||
|
}
|
||||||
+12
@@ -894,6 +894,18 @@ public class BlackBoxAgainstJavaCodegenTestGenerated extends AbstractBlackBoxCod
|
|||||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxAgainstJava/syntheticExtensions/setter.kt");
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxAgainstJava/syntheticExtensions/setter.kt");
|
||||||
doTestAgainstJava(fileName);
|
doTestAgainstJava(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("_protected.kt")
|
||||||
|
public void test_protected() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxAgainstJava/syntheticExtensions/_protected.kt");
|
||||||
|
doTestAgainstJava(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("_protectedSetter.kt")
|
||||||
|
public void test_protectedSetter() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxAgainstJava/syntheticExtensions/_protectedSetter.kt");
|
||||||
|
doTestAgainstJava(fileName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/boxAgainstJava/visibility")
|
@TestMetadata("compiler/testData/codegen/boxAgainstJava/visibility")
|
||||||
|
|||||||
Reference in New Issue
Block a user