fix prop modality reading from class files
This commit is contained in:
@@ -160,6 +160,10 @@ public class PropertyCodegen {
|
||||
if(isTrait && !(kind instanceof OwnerKind.DelegateKind))
|
||||
flags |= Opcodes.ACC_ABSTRACT;
|
||||
|
||||
if (propertyDescriptor.getModality() == Modality.FINAL) {
|
||||
flags |= Opcodes.ACC_FINAL;
|
||||
}
|
||||
|
||||
JvmPropertyAccessorSignature signature = state.getTypeMapper().mapGetterSignature(propertyDescriptor, kind);
|
||||
final String descriptor = signature.getJvmMethodSignature().getAsmMethod().getDescriptor();
|
||||
String getterName = getterName(propertyDescriptor.getName());
|
||||
@@ -231,6 +235,10 @@ public class PropertyCodegen {
|
||||
if(isTrait && !(kind instanceof OwnerKind.DelegateKind))
|
||||
flags |= Opcodes.ACC_ABSTRACT;
|
||||
|
||||
if (propertyDescriptor.getModality() == Modality.FINAL) {
|
||||
flags |= Opcodes.ACC_FINAL;
|
||||
}
|
||||
|
||||
JvmPropertyAccessorSignature signature = state.getTypeMapper().mapSetterSignature(propertyDescriptor, kind);
|
||||
final String descriptor = signature.getJvmMethodSignature().getAsmMethod().getDescriptor();
|
||||
MethodVisitor mv = v.newMethod(origin, flags, setterName(propertyDescriptor.getName()), descriptor, null, null);
|
||||
|
||||
+14
-3
@@ -1158,7 +1158,9 @@ public class JavaDescriptorResolver {
|
||||
}
|
||||
|
||||
boolean isFinal;
|
||||
if (members.setter == null && members.getter == null) {
|
||||
if (!scopeData.kotlin) {
|
||||
isFinal = true;
|
||||
} else if (members.setter == null && members.getter == null) {
|
||||
isFinal = false;
|
||||
} else if (members.getter != null) {
|
||||
isFinal = members.getter.getMember().isFinal();
|
||||
@@ -1185,11 +1187,20 @@ public class JavaDescriptorResolver {
|
||||
} else {
|
||||
isVar = members.setter != null;
|
||||
}
|
||||
|
||||
|
||||
Modality modality;
|
||||
if (isFinal) {
|
||||
modality = Modality.FINAL;
|
||||
}
|
||||
else {
|
||||
modality = anyMember.getMember().isAbstract() ? Modality.ABSTRACT : Modality.OPEN;
|
||||
}
|
||||
|
||||
|
||||
PropertyDescriptor propertyDescriptor = new PropertyDescriptor(
|
||||
owner,
|
||||
Collections.<AnnotationDescriptor>emptyList(),
|
||||
isFinal && !staticMembers ? Modality.FINAL : Modality.OPEN, // TODO: abstract
|
||||
modality,
|
||||
resolveVisibilityFromPsiModifiers(anyMember.getMember().psiMember),
|
||||
isVar,
|
||||
false,
|
||||
|
||||
@@ -36,4 +36,9 @@ public class PsiFieldWrapper extends PsiMemberWrapper {
|
||||
public PsiType getType() {
|
||||
return getPsiField().getType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAbstract() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,6 +49,8 @@ public abstract class PsiMemberWrapper {
|
||||
return psiMember.hasModifierProperty(PsiModifier.FINAL);
|
||||
}
|
||||
|
||||
public abstract boolean isAbstract();
|
||||
|
||||
public String getName() {
|
||||
return psiMember.getName();
|
||||
}
|
||||
|
||||
@@ -2,5 +2,5 @@ namespace test
|
||||
|
||||
final class test.FieldAsVar : jet.Any {
|
||||
final /*constructor*/ fun <init>(): test.FieldAsVar
|
||||
var f: jet.Int
|
||||
final var f: jet.Int
|
||||
}
|
||||
|
||||
@@ -2,5 +2,5 @@ namespace test
|
||||
|
||||
open class test.FieldOfArrayType : jet.Any {
|
||||
final /*constructor*/ fun <init>(): test.FieldOfArrayType
|
||||
var files: jet.Array<java.io.File?>?
|
||||
final var files: jet.Array<java.io.File?>?
|
||||
}
|
||||
|
||||
@@ -2,5 +2,5 @@ namespace test
|
||||
|
||||
final class test.FinalFieldAsVal : jet.Any {
|
||||
final /*constructor*/ fun <init>(): test.FinalFieldAsVal
|
||||
val f: jet.Int
|
||||
final val f: jet.Int
|
||||
}
|
||||
|
||||
@@ -2,6 +2,6 @@ namespace test
|
||||
|
||||
final class test.TwoFields : jet.Any {
|
||||
final /*constructor*/ fun <init>(): test.TwoFields
|
||||
var a: jet.Int
|
||||
var b: jet.Short
|
||||
final var a: jet.Int
|
||||
final var b: jet.Short
|
||||
}
|
||||
|
||||
@@ -2,5 +2,5 @@ namespace test
|
||||
|
||||
open class test.NotNullField : jet.Any {
|
||||
final /*constructor*/ fun <init>(): test.NotNullField
|
||||
var hi: jet.String
|
||||
final var hi: jet.String
|
||||
}
|
||||
|
||||
@@ -4,6 +4,6 @@ final class test.ClassObjectDeclaresProperty : jet.Any {
|
||||
final /*constructor*/ fun <init>(): test.ClassObjectDeclaresProperty
|
||||
final object test.ClassObjectDeclaresProperty.<no name provided> : jet.Any {
|
||||
final /*constructor*/ fun <init>(): test.ClassObjectDeclaresProperty.<no name provided>
|
||||
val i: jet.Int
|
||||
final val i: jet.Int
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,6 @@ final class test.ClassObjectDeclaresProperty : jet.Any {
|
||||
final /*constructor*/ fun <init>(): test.ClassObjectDeclaresProperty
|
||||
final object test.ClassObjectDeclaresProperty.<no name provided> : jet.Any {
|
||||
final /*constructor*/ fun <init>(): test.ClassObjectDeclaresProperty.<no name provided>
|
||||
var s: jet.String
|
||||
final var s: jet.String
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -2,5 +2,5 @@ namespace test
|
||||
|
||||
final class test.TestingKotlinCollections : jet.Any {
|
||||
final /*constructor*/ fun <init>(/*0*/ arguments: java.util.Collection<jet.String>): test.TestingKotlinCollections
|
||||
val arguments: java.util.Collection<jet.String>
|
||||
final val arguments: java.util.Collection<jet.String>
|
||||
}
|
||||
|
||||
@@ -2,5 +2,5 @@ namespace test
|
||||
|
||||
final class test.ClassVal : jet.Any {
|
||||
final /*constructor*/ fun <init>(): test.ClassVal
|
||||
val aa: jet.Int
|
||||
final val aa: jet.Int
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace test
|
||||
|
||||
abstract class test.ClassValAbstract : jet.Any {
|
||||
abstract val a: jet.Int
|
||||
final /*constructor*/ fun <init>(): test.ClassValAbstract
|
||||
val a: jet.Int
|
||||
}
|
||||
|
||||
@@ -2,5 +2,5 @@ namespace test
|
||||
|
||||
final class test.ClassVar : jet.Any {
|
||||
final /*constructor*/ fun <init>(): test.ClassVar
|
||||
var aa: jet.Int
|
||||
final var aa: jet.Int
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
namespace test
|
||||
|
||||
val java.util.Collection<out jet.Any?>.anotherSize: jet.Int
|
||||
final val java.util.Collection<out jet.Any?>.anotherSize: jet.Int
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
namespace test
|
||||
|
||||
val </*0,r*/ P : jet.Any?> /*0,r*/ P : jet.Any?.anotherJavaClass: java.lang.Class</*0,r*/ P : jet.Any?>
|
||||
final val </*0,r*/ P : jet.Any?> /*0,r*/ P : jet.Any?.anotherJavaClass: java.lang.Class</*0,r*/ P : jet.Any?>
|
||||
|
||||
@@ -2,5 +2,5 @@ namespace test
|
||||
|
||||
final class test.ExtPropInClass : jet.Any {
|
||||
final /*constructor*/ fun <init>(): test.ExtPropInClass
|
||||
val jet.Int.itIs: jet.Int
|
||||
final val jet.Int.itIs: jet.Int
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
namespace test
|
||||
|
||||
val jet.Int.itIs: jet.Int
|
||||
final val jet.Int.itIs: jet.Int
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
namespace test
|
||||
|
||||
val jet.Int.ggg: jet.CharSequence
|
||||
final val jet.Int.ggg: jet.CharSequence
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
namespace test
|
||||
|
||||
val jet.Int.ggg: jet.CharSequence?
|
||||
final val jet.Int.ggg: jet.CharSequence?
|
||||
|
||||
@@ -2,5 +2,5 @@ namespace test
|
||||
|
||||
final class test.ExtValInClass : jet.Any {
|
||||
final /*constructor*/ fun <init>(): test.ExtValInClass
|
||||
val jet.Int.asas: java.util.List<jet.Int>?
|
||||
final val jet.Int.asas: java.util.List<jet.Int>?
|
||||
}
|
||||
|
||||
@@ -2,5 +2,5 @@ namespace test
|
||||
|
||||
final class test.ExtValInClass</*0,r*/ T : jet.Any?> : jet.Any {
|
||||
final /*constructor*/ fun </*0,r*/ T : jet.Any?><init>(): test.ExtValInClass</*0,r*/ T : jet.Any?>
|
||||
val jet.Int.asas: /*0,r*/ T : jet.Any?
|
||||
final val jet.Int.asas: /*0,r*/ T : jet.Any?
|
||||
}
|
||||
|
||||
@@ -2,5 +2,5 @@ namespace test
|
||||
|
||||
final class test.ExtValInClass</*0,r*/ P : jet.Any?> : jet.Any {
|
||||
final /*constructor*/ fun </*0,r*/ P : jet.Any?><init>(): test.ExtValInClass</*0,r*/ P : jet.Any?>
|
||||
val jet.Int.asas: /*0,r*/ P : jet.Any??
|
||||
final val jet.Int.asas: /*0,r*/ P : jet.Any??
|
||||
}
|
||||
|
||||
@@ -2,5 +2,5 @@ namespace test
|
||||
|
||||
final class test.ExtValPIntInClass</*0,r*/ P : jet.Any?> : jet.Any {
|
||||
final /*constructor*/ fun </*0,r*/ P : jet.Any?><init>(): test.ExtValPIntInClass</*0,r*/ P : jet.Any?>
|
||||
val /*0,r*/ P : jet.Any?.asas: jet.Int
|
||||
final val /*0,r*/ P : jet.Any?.asas: jet.Int
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
namespace test
|
||||
|
||||
var </*0,r*/ P : jet.Any?> /*0,r*/ P : jet.Any?.anotherJavaClass: java.lang.Class</*0,r*/ P : jet.Any?>
|
||||
final var </*0,r*/ P : jet.Any?> /*0,r*/ P : jet.Any?.anotherJavaClass: java.lang.Class</*0,r*/ P : jet.Any?>
|
||||
|
||||
@@ -2,5 +2,5 @@ namespace test
|
||||
|
||||
final class test.ExtPropInClass : jet.Any {
|
||||
final /*constructor*/ fun <init>(): test.ExtPropInClass
|
||||
var jet.Int.itIs: jet.Int
|
||||
final var jet.Int.itIs: jet.Int
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
namespace test
|
||||
|
||||
var jet.Int.ggg: jet.Int
|
||||
final var jet.Int.ggg: jet.Int
|
||||
|
||||
@@ -2,5 +2,5 @@ namespace test
|
||||
|
||||
final class test.ExtValInClass</*0,r*/ P : jet.Any?> : jet.Any {
|
||||
final /*constructor*/ fun </*0,r*/ P : jet.Any?><init>(): test.ExtValInClass</*0,r*/ P : jet.Any?>
|
||||
var jet.Int.asas: /*0,r*/ P : jet.Any?
|
||||
final var jet.Int.asas: /*0,r*/ P : jet.Any?
|
||||
}
|
||||
|
||||
@@ -2,5 +2,5 @@ namespace test
|
||||
|
||||
final class test.ExtValInClass</*0,r*/ P : jet.Any?> : jet.Any {
|
||||
final /*constructor*/ fun </*0,r*/ P : jet.Any?><init>(): test.ExtValInClass</*0,r*/ P : jet.Any?>
|
||||
var jet.Int.asas: /*0,r*/ P : jet.Any??
|
||||
final var jet.Int.asas: /*0,r*/ P : jet.Any??
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
namespace test
|
||||
|
||||
var </*0,r*/ P : jet.Any?, /*1,r*/ Q : jet.Any?> java.util.Map</*0,r*/ P : jet.Any?, /*1,r*/ Q : jet.Any?>.asas: jet.Int
|
||||
final var </*0,r*/ P : jet.Any?, /*1,r*/ Q : jet.Any?> java.util.Map</*0,r*/ P : jet.Any?, /*1,r*/ Q : jet.Any?>.asas: jet.Int
|
||||
|
||||
@@ -2,5 +2,5 @@ namespace test
|
||||
|
||||
final class test.ExtValPIntInClass</*0,r*/ P : jet.Any?> : jet.Any {
|
||||
final /*constructor*/ fun </*0,r*/ P : jet.Any?><init>(): test.ExtValPIntInClass</*0,r*/ P : jet.Any?>
|
||||
var /*0,r*/ P : jet.Any?.asas: jet.Int
|
||||
final var /*0,r*/ P : jet.Any?.asas: jet.Int
|
||||
}
|
||||
|
||||
@@ -2,5 +2,5 @@ namespace test
|
||||
|
||||
final class test.ExtValPIntInClass</*0,r*/ P : jet.Any?> : jet.Any {
|
||||
final /*constructor*/ fun </*0,r*/ P : jet.Any?><init>(): test.ExtValPIntInClass</*0,r*/ P : jet.Any?>
|
||||
var /*0,r*/ P : jet.Any??.asas: jet.Int
|
||||
final var /*0,r*/ P : jet.Any??.asas: jet.Int
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace test
|
||||
|
||||
val jet.String.junk: jet.Int
|
||||
var jet.Int.junk: jet.Short
|
||||
final val jet.String.junk: jet.Int
|
||||
final var jet.Int.junk: jet.Short
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
namespace test
|
||||
|
||||
val nsVal: jet.Int
|
||||
final val nsVal: jet.Int
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
namespace test
|
||||
|
||||
var nsVal: jet.Int
|
||||
final var nsVal: jet.Int
|
||||
|
||||
@@ -258,6 +258,9 @@ class NamespaceComparator {
|
||||
}
|
||||
|
||||
public void serialize(PropertyDescriptor prop) {
|
||||
serialize(prop.getModality());
|
||||
sb.append(" ");
|
||||
|
||||
if (!prop.getAnnotations().isEmpty()) {
|
||||
new Serializer(sb).serializeSeparated(prop.getAnnotations(), " ");
|
||||
sb.append(" ");
|
||||
|
||||
Reference in New Issue
Block a user