Added JetMethod.flags() to replace kind(), with adding extra functionality (modality and visibility marking).
This commit is contained in:
@@ -136,7 +136,7 @@ public class FunctionCodegen {
|
|||||||
throw new IllegalStateException();
|
throw new IllegalStateException();
|
||||||
}
|
}
|
||||||
JetMethodAnnotationWriter aw = JetMethodAnnotationWriter.visitAnnotation(mv);
|
JetMethodAnnotationWriter aw = JetMethodAnnotationWriter.visitAnnotation(mv);
|
||||||
aw.writeKind(JvmStdlibNames.JET_METHOD_KIND_REGULAR);
|
aw.writeFlags(JvmStdlibNames.JET_METHOD_FLAGS_DEFAULT);
|
||||||
aw.writeNullableReturnType(functionDescriptor.getReturnType().isNullable());
|
aw.writeNullableReturnType(functionDescriptor.getReturnType().isNullable());
|
||||||
aw.writeTypeParameters(jvmSignature.getKotlinTypeParameter());
|
aw.writeTypeParameters(jvmSignature.getKotlinTypeParameter());
|
||||||
aw.writeReturnType(jvmSignature.getKotlinReturnType());
|
aw.writeReturnType(jvmSignature.getKotlinReturnType());
|
||||||
|
|||||||
@@ -221,7 +221,7 @@ public class PropertyCodegen {
|
|||||||
|
|
||||||
public static void generateJetPropertyAnnotation(MethodVisitor mv, @NotNull String kotlinType, @NotNull String typeParameters) {
|
public static void generateJetPropertyAnnotation(MethodVisitor mv, @NotNull String kotlinType, @NotNull String typeParameters) {
|
||||||
JetMethodAnnotationWriter aw = JetMethodAnnotationWriter.visitAnnotation(mv);
|
JetMethodAnnotationWriter aw = JetMethodAnnotationWriter.visitAnnotation(mv);
|
||||||
aw.writeKind(JvmStdlibNames.JET_METHOD_KIND_PROPERTY);
|
aw.writeFlags(JvmStdlibNames.JET_METHOD_FLAG_PROPERTY);
|
||||||
aw.writeTypeParameters(typeParameters);
|
aw.writeTypeParameters(typeParameters);
|
||||||
aw.writePropertyType(kotlinType);
|
aw.writePropertyType(kotlinType);
|
||||||
aw.visitEnd();
|
aw.visitEnd();
|
||||||
|
|||||||
+3
-3
@@ -31,9 +31,9 @@ public class JetMethodAnnotationWriter {
|
|||||||
this.av = av;
|
this.av = av;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeKind(int kind) {
|
public void writeFlags(int flags) {
|
||||||
if (kind != JvmStdlibNames.JET_METHOD_KIND_DEFAULT) {
|
if (flags != JvmStdlibNames.JET_METHOD_FLAGS_DEFAULT) {
|
||||||
av.visit(JvmStdlibNames.JET_METHOD_KIND_FIELD, kind);
|
av.visit(JvmStdlibNames.JET_METHOD_FLAGS_FIELD, flags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1597,7 +1597,7 @@ public class JavaDescriptorResolver implements DependencyClassByQualifiedNameRes
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: ugly
|
// TODO: ugly
|
||||||
if (method.getJetMethod().kind() == JvmStdlibNames.JET_METHOD_KIND_PROPERTY) {
|
if ((method.getJetMethod().flags() & JvmStdlibNames.JET_METHOD_FLAG_PROPERTY) != 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -125,7 +125,7 @@ class JavaDescriptorResolverHelper {
|
|||||||
NamedMembers members = getNamedMembers(Name.identifier(propertyName));
|
NamedMembers members = getNamedMembers(Name.identifier(propertyName));
|
||||||
|
|
||||||
// TODO: some java properties too
|
// TODO: some java properties too
|
||||||
if (method.getJetMethod().kind() == JvmStdlibNames.JET_METHOD_KIND_PROPERTY) {
|
if ((method.getJetMethod().flags() & JvmStdlibNames.JET_METHOD_FLAG_PROPERTY) != 0) {
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
@@ -167,7 +167,7 @@ class JavaDescriptorResolverHelper {
|
|||||||
String propertyName = propertyParseResult.getPropertyName();
|
String propertyName = propertyParseResult.getPropertyName();
|
||||||
NamedMembers members = getNamedMembers(Name.identifier(propertyName));
|
NamedMembers members = getNamedMembers(Name.identifier(propertyName));
|
||||||
|
|
||||||
if (method.getJetMethod().kind() == JvmStdlibNames.JET_METHOD_KIND_PROPERTY) {
|
if ((method.getJetMethod().flags() & JvmStdlibNames.JET_METHOD_FLAG_PROPERTY) != 0) {
|
||||||
if (method.getParameters().size() == 0) {
|
if (method.getParameters().size() == 0) {
|
||||||
// TODO: report error properly
|
// TODO: report error properly
|
||||||
throw new IllegalStateException();
|
throw new IllegalStateException();
|
||||||
@@ -204,7 +204,7 @@ class JavaDescriptorResolverHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (method.getJetMethod().kind() != JvmStdlibNames.JET_METHOD_KIND_PROPERTY) {
|
if ((method.getJetMethod().flags() & JvmStdlibNames.JET_METHOD_FLAG_PROPERTY) == 0) {
|
||||||
NamedMembers namedMembers = getNamedMembers(Name.identifier(method.getName()));
|
NamedMembers namedMembers = getNamedMembers(Name.identifier(method.getName()));
|
||||||
namedMembers.addMethod(method);
|
namedMembers.addMethod(method);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,15 +40,16 @@ public class JvmStdlibNames {
|
|||||||
|
|
||||||
public static final JvmClassName JET_METHOD = JvmClassName.byFqNameWithoutInnerClasses("jet.runtime.typeinfo.JetMethod");
|
public static final JvmClassName JET_METHOD = JvmClassName.byFqNameWithoutInnerClasses("jet.runtime.typeinfo.JetMethod");
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public static final String JET_METHOD_KIND_FIELD = "kind";
|
public static final String JET_METHOD_KIND_FIELD = "kind";
|
||||||
|
public static final String JET_METHOD_FLAGS_FIELD = "flags";
|
||||||
public static final String JET_METHOD_NULLABLE_RETURN_TYPE_FIELD = "nullableReturnType";
|
public static final String JET_METHOD_NULLABLE_RETURN_TYPE_FIELD = "nullableReturnType";
|
||||||
public static final String JET_METHOD_RETURN_TYPE_FIELD = "returnType";
|
public static final String JET_METHOD_RETURN_TYPE_FIELD = "returnType";
|
||||||
public static final String JET_METHOD_TYPE_PARAMETERS_FIELD = "typeParameters";
|
public static final String JET_METHOD_TYPE_PARAMETERS_FIELD = "typeParameters";
|
||||||
public static final String JET_METHOD_PROPERTY_TYPE_FIELD = "propertyType";
|
public static final String JET_METHOD_PROPERTY_TYPE_FIELD = "propertyType";
|
||||||
|
|
||||||
public static final int JET_METHOD_KIND_REGULAR = 0;
|
public static final int JET_METHOD_FLAGS_DEFAULT = 0;
|
||||||
public static final int JET_METHOD_KIND_PROPERTY = 1;
|
public static final int JET_METHOD_FLAG_PROPERTY = 1;
|
||||||
public static final int JET_METHOD_KIND_DEFAULT = JET_METHOD_KIND_REGULAR;
|
|
||||||
|
|
||||||
public static final JvmClassName JET_CONSTRUCTOR = JvmClassName.byFqNameWithoutInnerClasses("jet.runtime.typeinfo.JetConstructor");
|
public static final JvmClassName JET_CONSTRUCTOR = JvmClassName.byFqNameWithoutInnerClasses("jet.runtime.typeinfo.JetConstructor");
|
||||||
|
|
||||||
|
|||||||
+11
-7
@@ -31,14 +31,18 @@ public class JetMethodAnnotation extends PsiAnnotationWrapper {
|
|||||||
super(psiAnnotation);
|
super(psiAnnotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int kind;
|
private int flags;
|
||||||
private boolean kindInitialized;
|
private boolean flagsInitialized;
|
||||||
public int kind() {
|
public int flags() {
|
||||||
if (!kindInitialized) {
|
if (!flagsInitialized) {
|
||||||
kind = getIntAttribute(JvmStdlibNames.JET_METHOD_KIND_FIELD, JvmStdlibNames.JET_METHOD_KIND_DEFAULT);
|
flags = getIntAttribute(JvmStdlibNames.JET_METHOD_FLAGS_FIELD, -1);
|
||||||
kindInitialized = true;
|
if (flags == -1) {
|
||||||
|
// for compatibility
|
||||||
|
flags = getIntAttribute(JvmStdlibNames.JET_METHOD_KIND_FIELD, JvmStdlibNames.JET_METHOD_FLAGS_DEFAULT);
|
||||||
|
}
|
||||||
|
flagsInitialized = true;
|
||||||
}
|
}
|
||||||
return kind;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String typeParameters;
|
private String typeParameters;
|
||||||
|
|||||||
@@ -33,10 +33,18 @@ import java.lang.annotation.Target;
|
|||||||
@Target({ElementType.METHOD})
|
@Target({ElementType.METHOD})
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
public @interface JetMethod {
|
public @interface JetMethod {
|
||||||
int KIND_REGULAR = 0;
|
/**
|
||||||
int KIND_PROPERTY = 1;
|
* @deprecated use flags instead
|
||||||
|
*/
|
||||||
int kind() default KIND_REGULAR;
|
@Deprecated
|
||||||
|
int kind() default 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bit 0 - property/not property
|
||||||
|
*
|
||||||
|
* @return flags for method
|
||||||
|
*/
|
||||||
|
int flags() default 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return type projections or empty
|
* @return type projections or empty
|
||||||
|
|||||||
Reference in New Issue
Block a user