Make JvmPropertyAccessorSignature extends JvmMethodSignature
This commit is contained in:
@@ -525,18 +525,27 @@ public class BothSignatureWriter {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public JvmMethodSignature makeJvmMethodSignature(String name) {
|
public JvmMethodSignature makeJvmMethodSignature(String name) {
|
||||||
if (needGenerics) {
|
return new JvmMethodSignature(
|
||||||
return new JvmMethodSignature(
|
makeAsmMethod(name),
|
||||||
makeAsmMethod(name),
|
needGenerics ? makeJavaGenericSignature() : null,
|
||||||
makeJavaGenericSignature(),
|
needGenerics ? makeKotlinMethodTypeParameters() : null,
|
||||||
makeKotlinMethodTypeParameters(),
|
makeKotlinParameterTypes(),
|
||||||
makeKotlinParameterTypes(),
|
makeKotlinReturnTypeSignature(),
|
||||||
makeKotlinReturnTypeSignature()
|
needGenerics
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
return new JvmMethodSignature(makeAsmMethod(name), makeKotlinParameterTypes());
|
@NotNull
|
||||||
}
|
public JvmPropertyAccessorSignature makeJvmPropertyAccessorSignature(String name, boolean isGetter) {
|
||||||
|
return new JvmPropertyAccessorSignature(
|
||||||
|
makeAsmMethod(name),
|
||||||
|
needGenerics ? makeJavaGenericSignature() : null,
|
||||||
|
needGenerics ? makeKotlinMethodTypeParameters() : null,
|
||||||
|
makeKotlinParameterTypes(),
|
||||||
|
makeKotlinReturnTypeSignature(),
|
||||||
|
needGenerics,
|
||||||
|
isGetter
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,38 +43,20 @@ public class JvmMethodSignature {
|
|||||||
*/
|
*/
|
||||||
private final boolean genericsAvailable;
|
private final boolean genericsAvailable;
|
||||||
|
|
||||||
public JvmMethodSignature(
|
protected JvmMethodSignature(
|
||||||
@NotNull Method asmMethod,
|
@NotNull Method asmMethod,
|
||||||
@Nullable String genericsSignature,
|
@Nullable String genericsSignature,
|
||||||
@Nullable String kotlinTypeParameters,
|
@Nullable String kotlinTypeParameters,
|
||||||
@NotNull List<JvmMethodParameterSignature> kotlinParameterTypes,
|
@NotNull List<JvmMethodParameterSignature> kotlinParameterTypes,
|
||||||
@NotNull String kotlinReturnType
|
@NotNull String kotlinReturnType,
|
||||||
|
boolean genericsAvailable
|
||||||
) {
|
) {
|
||||||
this.asmMethod = asmMethod;
|
this.asmMethod = asmMethod;
|
||||||
this.genericsSignature = genericsSignature;
|
this.genericsSignature = genericsSignature;
|
||||||
this.kotlinTypeParameter = kotlinTypeParameters;
|
this.kotlinTypeParameter = kotlinTypeParameters;
|
||||||
this.kotlinParameterTypes = kotlinParameterTypes;
|
this.kotlinParameterTypes = kotlinParameterTypes;
|
||||||
this.kotlinReturnType = kotlinReturnType;
|
this.kotlinReturnType = kotlinReturnType;
|
||||||
this.genericsAvailable = true;
|
this.genericsAvailable = genericsAvailable;
|
||||||
}
|
|
||||||
|
|
||||||
public JvmMethodSignature(@NotNull Method asmMethod, @NotNull List<JvmMethodParameterSignature> kotlinParameterTypes) {
|
|
||||||
this.asmMethod = asmMethod;
|
|
||||||
this.genericsSignature = null;
|
|
||||||
this.kotlinTypeParameter = null;
|
|
||||||
this.kotlinParameterTypes = kotlinParameterTypes;
|
|
||||||
this.kotlinReturnType = "";
|
|
||||||
this.genericsAvailable = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static JvmMethodSignature simple(
|
|
||||||
@NotNull String methodName,
|
|
||||||
@NotNull Type returnType,
|
|
||||||
@NotNull List<JvmMethodParameterSignature> parameterSignatures
|
|
||||||
) {
|
|
||||||
List<Type> types = getTypes(parameterSignatures);
|
|
||||||
return new JvmMethodSignature(new Method(methodName, returnType, types.toArray(new Type[types.size()])),
|
|
||||||
parameterSignatures);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|||||||
+21
-10
@@ -17,25 +17,36 @@
|
|||||||
package org.jetbrains.jet.codegen.signature;
|
package org.jetbrains.jet.codegen.signature;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.jetbrains.asm4.commons.Method;
|
||||||
|
|
||||||
public class JvmPropertyAccessorSignature {
|
import java.util.List;
|
||||||
@NotNull
|
|
||||||
private final JvmMethodSignature jvmMethodSignature;
|
|
||||||
@NotNull
|
|
||||||
private final String propertyTypeKotlinSignature;
|
|
||||||
|
|
||||||
public JvmPropertyAccessorSignature(@NotNull JvmMethodSignature jvmMethodSignature, @NotNull String propertyTypeKotlinSignature) {
|
public class JvmPropertyAccessorSignature extends JvmMethodSignature {
|
||||||
this.jvmMethodSignature = jvmMethodSignature;
|
|
||||||
this.propertyTypeKotlinSignature = propertyTypeKotlinSignature;
|
private final boolean isGetter;
|
||||||
|
|
||||||
|
protected JvmPropertyAccessorSignature(
|
||||||
|
@NotNull Method asmMethod,
|
||||||
|
@Nullable String genericsSignature,
|
||||||
|
@Nullable String kotlinTypeParameters,
|
||||||
|
@NotNull List<JvmMethodParameterSignature> kotlinParameterTypes,
|
||||||
|
@NotNull String kotlinReturnType,
|
||||||
|
boolean needGenerics,
|
||||||
|
boolean isGetter
|
||||||
|
) {
|
||||||
|
super(asmMethod, genericsSignature, kotlinTypeParameters, kotlinParameterTypes,
|
||||||
|
kotlinReturnType, needGenerics);
|
||||||
|
this.isGetter = isGetter;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public JvmMethodSignature getJvmMethodSignature() {
|
public JvmMethodSignature getJvmMethodSignature() {
|
||||||
return jvmMethodSignature;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public String getPropertyTypeKotlinSignature() {
|
public String getPropertyTypeKotlinSignature() {
|
||||||
return propertyTypeKotlinSignature;
|
return isGetter ? getKotlinReturnType() : getKotlinParameterType(getParameterCount() - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -736,8 +736,6 @@ public class JetTypeMapper extends BindingTraceAware {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public JvmPropertyAccessorSignature mapGetterSignature(PropertyDescriptor descriptor, OwnerKind kind) {
|
public JvmPropertyAccessorSignature mapGetterSignature(PropertyDescriptor descriptor, OwnerKind kind) {
|
||||||
String name = getPropertyAccessorName(descriptor, true);
|
|
||||||
|
|
||||||
// TODO: do not genClassOrObject generics if not needed
|
// TODO: do not genClassOrObject generics if not needed
|
||||||
BothSignatureWriter signatureWriter = new BothSignatureWriter(BothSignatureWriter.Mode.METHOD, true);
|
BothSignatureWriter signatureWriter = new BothSignatureWriter(BothSignatureWriter.Mode.METHOD, true);
|
||||||
|
|
||||||
@@ -752,9 +750,8 @@ public class JetTypeMapper extends BindingTraceAware {
|
|||||||
mapType(descriptor.getType(), signatureWriter, JetTypeMapperMode.VALUE, Variance.OUT_VARIANCE);
|
mapType(descriptor.getType(), signatureWriter, JetTypeMapperMode.VALUE, Variance.OUT_VARIANCE);
|
||||||
signatureWriter.writeReturnTypeEnd();
|
signatureWriter.writeReturnTypeEnd();
|
||||||
|
|
||||||
JvmMethodSignature jvmMethodSignature = signatureWriter.makeJvmMethodSignature(name);
|
String name = getPropertyAccessorName(descriptor, true);
|
||||||
|
return signatureWriter.makeJvmPropertyAccessorSignature(name, true);
|
||||||
return new JvmPropertyAccessorSignature(jvmMethodSignature, jvmMethodSignature.getKotlinReturnType());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -776,9 +773,7 @@ public class JetTypeMapper extends BindingTraceAware {
|
|||||||
signatureWriter.writeVoidReturn();
|
signatureWriter.writeVoidReturn();
|
||||||
|
|
||||||
String name = getPropertyAccessorName(descriptor, false);
|
String name = getPropertyAccessorName(descriptor, false);
|
||||||
JvmMethodSignature jvmMethodSignature = signatureWriter.makeJvmMethodSignature(name);
|
return signatureWriter.makeJvmPropertyAccessorSignature(name, false);
|
||||||
return new JvmPropertyAccessorSignature(jvmMethodSignature,
|
|
||||||
jvmMethodSignature.getKotlinParameterType(jvmMethodSignature.getParameterCount() - 1));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeParameter(BothSignatureWriter signatureWriter, JetType outType) {
|
private void writeParameter(BothSignatureWriter signatureWriter, JetType outType) {
|
||||||
|
|||||||
Reference in New Issue
Block a user