Write ACC_DEPRECATED in byte codes.
#KT-2950 Fixed
This commit is contained in:
@@ -45,6 +45,7 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import static org.jetbrains.asm4.Opcodes.*;
|
import static org.jetbrains.asm4.Opcodes.*;
|
||||||
|
import static org.jetbrains.jet.codegen.CodegenUtil.isDeprecated;
|
||||||
import static org.jetbrains.jet.codegen.CodegenUtil.isInterface;
|
import static org.jetbrains.jet.codegen.CodegenUtil.isInterface;
|
||||||
import static org.jetbrains.jet.lang.resolve.DescriptorUtils.isClassObject;
|
import static org.jetbrains.jet.lang.resolve.DescriptorUtils.isClassObject;
|
||||||
import static org.jetbrains.jet.lang.resolve.java.AsmTypeConstants.JAVA_STRING_TYPE;
|
import static org.jetbrains.jet.lang.resolve.java.AsmTypeConstants.JAVA_STRING_TYPE;
|
||||||
@@ -152,6 +153,18 @@ public class AsmUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int getDeprecatedAccessFlag(@NotNull MemberDescriptor descriptor) {
|
||||||
|
if (descriptor instanceof PropertyAccessorDescriptor) {
|
||||||
|
return isDeprecated(descriptor)
|
||||||
|
? ACC_DEPRECATED
|
||||||
|
: getDeprecatedAccessFlag(((PropertyAccessorDescriptor) descriptor).getCorrespondingProperty());
|
||||||
|
}
|
||||||
|
else if (isDeprecated(descriptor)) {
|
||||||
|
return ACC_DEPRECATED;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private static Integer specialCaseVisibility(@NotNull MemberDescriptor memberDescriptor) {
|
private static Integer specialCaseVisibility(@NotNull MemberDescriptor memberDescriptor) {
|
||||||
DeclarationDescriptor containingDeclaration = memberDescriptor.getContainingDeclaration();
|
DeclarationDescriptor containingDeclaration = memberDescriptor.getContainingDeclaration();
|
||||||
|
|||||||
@@ -385,6 +385,10 @@ public class FunctionCodegen extends GenerationStateAware {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isAbstract) flags |= ACC_ABSTRACT;
|
if (isAbstract) flags |= ACC_ABSTRACT;
|
||||||
|
|
||||||
|
if (CodegenUtil.isDeprecated(functionDescriptor)) {
|
||||||
|
flags |= ACC_DEPRECATED;
|
||||||
|
}
|
||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -149,6 +149,9 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
if (isAnnotation) {
|
if (isAnnotation) {
|
||||||
access |= ACC_ANNOTATION;
|
access |= ACC_ANNOTATION;
|
||||||
}
|
}
|
||||||
|
if (CodegenUtil.isDeprecated(descriptor)) {
|
||||||
|
access |= ACC_DEPRECATED;
|
||||||
|
}
|
||||||
if (isEnum) {
|
if (isEnum) {
|
||||||
for (JetDeclaration declaration : myClass.getDeclarations()) {
|
for (JetDeclaration declaration : myClass.getDeclarations()) {
|
||||||
if (declaration instanceof JetEnumEntry) {
|
if (declaration instanceof JetEnumEntry) {
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ public class PropertyCodegen extends GenerationStateAware {
|
|||||||
|
|
||||||
public void generatePrimaryConstructorProperty(JetParameter p, PropertyDescriptor descriptor) {
|
public void generatePrimaryConstructorProperty(JetParameter p, PropertyDescriptor descriptor) {
|
||||||
generateBackingField(p, descriptor);
|
generateBackingField(p, descriptor);
|
||||||
int accessFlags = getVisibilityAccessFlag(descriptor) | getModalityAccessFlag(descriptor);
|
int accessFlags = getVisibilityAccessFlag(descriptor) | getModalityAccessFlag(descriptor) | getDeprecatedAccessFlag(descriptor);
|
||||||
generateDefaultGetter(descriptor, accessFlags, p);
|
generateDefaultGetter(descriptor, accessFlags, p);
|
||||||
if (descriptor.isVar()) {
|
if (descriptor.isVar()) {
|
||||||
generateDefaultSetter(descriptor, accessFlags, p);
|
generateDefaultSetter(descriptor, accessFlags, p);
|
||||||
@@ -114,6 +114,7 @@ public class PropertyCodegen extends GenerationStateAware {
|
|||||||
if (!propertyDescriptor.isVar()) {
|
if (!propertyDescriptor.isVar()) {
|
||||||
modifiers |= ACC_FINAL;
|
modifiers |= ACC_FINAL;
|
||||||
}
|
}
|
||||||
|
modifiers |= getDeprecatedAccessFlag(propertyDescriptor);
|
||||||
if (JetStandardLibrary.getInstance().isVolatile(propertyDescriptor)) {
|
if (JetStandardLibrary.getInstance().isVolatile(propertyDescriptor)) {
|
||||||
modifiers |= ACC_VOLATILE;
|
modifiers |= ACC_VOLATILE;
|
||||||
}
|
}
|
||||||
@@ -125,14 +126,16 @@ public class PropertyCodegen extends GenerationStateAware {
|
|||||||
|
|
||||||
private void generateGetter(JetProperty p, PropertyDescriptor propertyDescriptor) {
|
private void generateGetter(JetProperty p, PropertyDescriptor propertyDescriptor) {
|
||||||
JetPropertyAccessor getter = p.getGetter();
|
JetPropertyAccessor getter = p.getGetter();
|
||||||
|
PropertyGetterDescriptor getterDescriptor = propertyDescriptor.getGetter();
|
||||||
if (getter != null && getter.getBodyExpression() != null) {
|
if (getter != null && getter.getBodyExpression() != null) {
|
||||||
JvmPropertyAccessorSignature signature = typeMapper.mapGetterSignature(propertyDescriptor, kind);
|
JvmPropertyAccessorSignature signature = typeMapper.mapGetterSignature(propertyDescriptor, kind);
|
||||||
functionCodegen.generateMethod(getter, signature.getJvmMethodSignature(), true, signature.getPropertyTypeKotlinSignature(),
|
functionCodegen.generateMethod(getter, signature.getJvmMethodSignature(), true, signature.getPropertyTypeKotlinSignature(),
|
||||||
propertyDescriptor.getGetter());
|
getterDescriptor);
|
||||||
}
|
}
|
||||||
else if (isExternallyAccessible(propertyDescriptor)) {
|
else if (isExternallyAccessible(propertyDescriptor)) {
|
||||||
int flags = getVisibilityAccessFlag(propertyDescriptor);
|
int flags = getVisibilityAccessFlag(propertyDescriptor);
|
||||||
flags |= getModalityAccessFlag(propertyDescriptor);
|
flags |= getModalityAccessFlag(propertyDescriptor);
|
||||||
|
flags |= getterDescriptor == null ? getDeprecatedAccessFlag(propertyDescriptor): getDeprecatedAccessFlag(getterDescriptor);
|
||||||
generateDefaultGetter(propertyDescriptor, flags, p);
|
generateDefaultGetter(propertyDescriptor, flags, p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -151,8 +154,15 @@ public class PropertyCodegen extends GenerationStateAware {
|
|||||||
}
|
}
|
||||||
else if (isExternallyAccessible(propertyDescriptor) && propertyDescriptor.isVar()) {
|
else if (isExternallyAccessible(propertyDescriptor) && propertyDescriptor.isVar()) {
|
||||||
PropertySetterDescriptor setterDescriptor = propertyDescriptor.getSetter();
|
PropertySetterDescriptor setterDescriptor = propertyDescriptor.getSetter();
|
||||||
int flags = setterDescriptor == null ? getVisibilityAccessFlag(propertyDescriptor) : getVisibilityAccessFlag(setterDescriptor);
|
int flags = getModalityAccessFlag(propertyDescriptor);
|
||||||
flags |= getModalityAccessFlag(propertyDescriptor);
|
if (setterDescriptor == null) {
|
||||||
|
flags |= getVisibilityAccessFlag(propertyDescriptor);
|
||||||
|
flags |= getDeprecatedAccessFlag(propertyDescriptor);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
flags |= getVisibilityAccessFlag(setterDescriptor);
|
||||||
|
flags |= getDeprecatedAccessFlag(setterDescriptor);
|
||||||
|
}
|
||||||
generateDefaultSetter(propertyDescriptor, flags, p);
|
generateDefaultSetter(propertyDescriptor, flags, p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user