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();
|
||||
}
|
||||
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.writeTypeParameters(jvmSignature.getKotlinTypeParameter());
|
||||
aw.writeReturnType(jvmSignature.getKotlinReturnType());
|
||||
|
||||
@@ -221,7 +221,7 @@ public class PropertyCodegen {
|
||||
|
||||
public static void generateJetPropertyAnnotation(MethodVisitor mv, @NotNull String kotlinType, @NotNull String typeParameters) {
|
||||
JetMethodAnnotationWriter aw = JetMethodAnnotationWriter.visitAnnotation(mv);
|
||||
aw.writeKind(JvmStdlibNames.JET_METHOD_KIND_PROPERTY);
|
||||
aw.writeFlags(JvmStdlibNames.JET_METHOD_FLAG_PROPERTY);
|
||||
aw.writeTypeParameters(typeParameters);
|
||||
aw.writePropertyType(kotlinType);
|
||||
aw.visitEnd();
|
||||
|
||||
+3
-3
@@ -31,9 +31,9 @@ public class JetMethodAnnotationWriter {
|
||||
this.av = av;
|
||||
}
|
||||
|
||||
public void writeKind(int kind) {
|
||||
if (kind != JvmStdlibNames.JET_METHOD_KIND_DEFAULT) {
|
||||
av.visit(JvmStdlibNames.JET_METHOD_KIND_FIELD, kind);
|
||||
public void writeFlags(int flags) {
|
||||
if (flags != JvmStdlibNames.JET_METHOD_FLAGS_DEFAULT) {
|
||||
av.visit(JvmStdlibNames.JET_METHOD_FLAGS_FIELD, flags);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1597,7 +1597,7 @@ public class JavaDescriptorResolver implements DependencyClassByQualifiedNameRes
|
||||
}
|
||||
|
||||
// TODO: ugly
|
||||
if (method.getJetMethod().kind() == JvmStdlibNames.JET_METHOD_KIND_PROPERTY) {
|
||||
if ((method.getJetMethod().flags() & JvmStdlibNames.JET_METHOD_FLAG_PROPERTY) != 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -125,7 +125,7 @@ class JavaDescriptorResolverHelper {
|
||||
NamedMembers members = getNamedMembers(Name.identifier(propertyName));
|
||||
|
||||
// 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;
|
||||
|
||||
@@ -167,7 +167,7 @@ class JavaDescriptorResolverHelper {
|
||||
String propertyName = propertyParseResult.getPropertyName();
|
||||
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) {
|
||||
// TODO: report error properly
|
||||
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.addMethod(method);
|
||||
}
|
||||
|
||||
@@ -40,15 +40,16 @@ public class JvmStdlibNames {
|
||||
|
||||
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_FLAGS_FIELD = "flags";
|
||||
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_TYPE_PARAMETERS_FIELD = "typeParameters";
|
||||
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_KIND_PROPERTY = 1;
|
||||
public static final int JET_METHOD_KIND_DEFAULT = JET_METHOD_KIND_REGULAR;
|
||||
|
||||
public static final int JET_METHOD_FLAGS_DEFAULT = 0;
|
||||
public static final int JET_METHOD_FLAG_PROPERTY = 1;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
private int kind;
|
||||
private boolean kindInitialized;
|
||||
public int kind() {
|
||||
if (!kindInitialized) {
|
||||
kind = getIntAttribute(JvmStdlibNames.JET_METHOD_KIND_FIELD, JvmStdlibNames.JET_METHOD_KIND_DEFAULT);
|
||||
kindInitialized = true;
|
||||
private int flags;
|
||||
private boolean flagsInitialized;
|
||||
public int flags() {
|
||||
if (!flagsInitialized) {
|
||||
flags = getIntAttribute(JvmStdlibNames.JET_METHOD_FLAGS_FIELD, -1);
|
||||
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;
|
||||
|
||||
@@ -33,10 +33,18 @@ import java.lang.annotation.Target;
|
||||
@Target({ElementType.METHOD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface JetMethod {
|
||||
int KIND_REGULAR = 0;
|
||||
int KIND_PROPERTY = 1;
|
||||
|
||||
int kind() default KIND_REGULAR;
|
||||
/**
|
||||
* @deprecated use flags instead
|
||||
*/
|
||||
@Deprecated
|
||||
int kind() default 0;
|
||||
|
||||
/**
|
||||
* Bit 0 - property/not property
|
||||
*
|
||||
* @return flags for method
|
||||
*/
|
||||
int flags() default 0;
|
||||
|
||||
/**
|
||||
* @return type projections or empty
|
||||
|
||||
Reference in New Issue
Block a user