Delete KotlinSignature and corresponding code
This commit is contained in:
+2
-7
@@ -38,14 +38,9 @@ public final class JvmAnnotationNames {
|
||||
public static final FqName KOTLIN_INTERFACE_DEFAULT_IMPLS = new FqName("kotlin.jvm.internal.KotlinInterfaceDefaultImpls");
|
||||
public static final FqName KOTLIN_LOCAL_CLASS = new FqName("kotlin.jvm.internal.KotlinLocalClass");
|
||||
|
||||
public static final FqName JAVA_LANG_DEPRECATED = new FqName("java.lang.Deprecated");
|
||||
|
||||
public static final FqName KOTLIN_DELEGATED_METHOD = new FqName("kotlin.jvm.internal.KotlinDelegatedMethod");
|
||||
public static final String IMPLEMENTATION_CLASS_NAME_FIELD_NAME = "implementationClassName";
|
||||
|
||||
public static final FqName KOTLIN_SIGNATURE = new FqName("kotlin.jvm.KotlinSignature");
|
||||
public static final FqName OLD_KOTLIN_SIGNATURE = new FqName("jet.runtime.typeinfo.KotlinSignature");
|
||||
|
||||
public static final String VERSION_FIELD_NAME = "version";
|
||||
public static final String FILE_PART_CLASS_NAMES_FIELD_NAME = "filePartClassNames";
|
||||
public static final String MULTIFILE_CLASS_NAME_FIELD_NAME = "multifileClassName";
|
||||
@@ -87,7 +82,7 @@ public final class JvmAnnotationNames {
|
||||
private static final Set<JvmClassName> SPECIAL_META_ANNOTATIONS = new HashSet<JvmClassName>();
|
||||
static {
|
||||
for (FqName fqName : Arrays.asList(
|
||||
KOTLIN_CLASS, KOTLIN_PACKAGE, KOTLIN_SIGNATURE, KOTLIN_SYNTHETIC_CLASS, KOTLIN_INTERFACE_DEFAULT_IMPLS, KOTLIN_LOCAL_CLASS
|
||||
KOTLIN_CLASS, KOTLIN_PACKAGE, KOTLIN_SYNTHETIC_CLASS, KOTLIN_INTERFACE_DEFAULT_IMPLS, KOTLIN_LOCAL_CLASS
|
||||
)) {
|
||||
SPECIAL_ANNOTATIONS.add(JvmClassName.byFqNameWithoutInnerClasses(fqName));
|
||||
}
|
||||
@@ -105,7 +100,7 @@ public final class JvmAnnotationNames {
|
||||
JvmClassName className = JvmClassName.byClassId(classId);
|
||||
return (javaSpecificAnnotationsAreSpecial
|
||||
&& (NULLABILITY_ANNOTATIONS.contains(className) || SPECIAL_META_ANNOTATIONS.contains(className))
|
||||
) || SPECIAL_ANNOTATIONS.contains(className) || className.getInternalName().startsWith("jet/runtime/typeinfo/");
|
||||
) || SPECIAL_ANNOTATIONS.contains(className);
|
||||
}
|
||||
|
||||
private JvmAnnotationNames() {
|
||||
|
||||
+12
-97
@@ -18,9 +18,10 @@ package org.jetbrains.kotlin.load.java.components;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaField;
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaMember;
|
||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor;
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaMethod;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
@@ -31,68 +32,31 @@ public interface ExternalSignatureResolver {
|
||||
ExternalSignatureResolver DO_NOTHING = new ExternalSignatureResolver() {
|
||||
@NotNull
|
||||
@Override
|
||||
public PropagatedMethodSignature resolvePropagatedSignature(
|
||||
public AlternativeMethodSignature resolvePropagatedSignature(
|
||||
@NotNull JavaMethod method,
|
||||
@NotNull ClassDescriptor owner,
|
||||
@NotNull KotlinType returnType,
|
||||
@Nullable KotlinType receiverType,
|
||||
@NotNull List<ValueParameterDescriptor> valueParameters,
|
||||
@NotNull List<TypeParameterDescriptor> typeParameters
|
||||
) {
|
||||
return new PropagatedMethodSignature(
|
||||
returnType, receiverType, valueParameters, typeParameters, Collections.<String>emptyList(), false,
|
||||
Collections.<FunctionDescriptor>emptyList()
|
||||
);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public AlternativeMethodSignature resolveAlternativeMethodSignature(
|
||||
@NotNull JavaMember methodOrConstructor,
|
||||
boolean hasSuperMethods,
|
||||
@Nullable KotlinType returnType,
|
||||
@Nullable KotlinType receiverType,
|
||||
@NotNull List<ValueParameterDescriptor> valueParameters,
|
||||
@NotNull List<TypeParameterDescriptor> typeParameters,
|
||||
boolean hasStableParameterNames
|
||||
) {
|
||||
return new AlternativeMethodSignature(
|
||||
returnType, receiverType, valueParameters, typeParameters, Collections.<String>emptyList(), hasStableParameterNames
|
||||
returnType, receiverType, valueParameters, typeParameters, Collections.<String>emptyList(), false
|
||||
);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public AlternativeFieldSignature resolveAlternativeFieldSignature(
|
||||
@NotNull JavaField field, @NotNull KotlinType returnType, boolean isVar
|
||||
) {
|
||||
return new AlternativeFieldSignature(returnType, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reportSignatureErrors(@NotNull CallableMemberDescriptor descriptor, @NotNull List<String> signatureErrors) {
|
||||
throw new UnsupportedOperationException("Should not be called");
|
||||
}
|
||||
};
|
||||
|
||||
abstract class MemberSignature {
|
||||
private final List<String> signatureErrors;
|
||||
|
||||
protected MemberSignature(@NotNull List<String> signatureErrors) {
|
||||
this.signatureErrors = signatureErrors;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<String> getErrors() {
|
||||
return signatureErrors;
|
||||
}
|
||||
}
|
||||
|
||||
class AlternativeMethodSignature extends MemberSignature {
|
||||
class AlternativeMethodSignature {
|
||||
private final KotlinType returnType;
|
||||
private final KotlinType receiverType;
|
||||
private final List<ValueParameterDescriptor> valueParameters;
|
||||
private final List<TypeParameterDescriptor> typeParameters;
|
||||
private final List<String> signatureErrors;
|
||||
private final boolean hasStableParameterNames;
|
||||
|
||||
public AlternativeMethodSignature(
|
||||
@@ -103,11 +67,11 @@ public interface ExternalSignatureResolver {
|
||||
@NotNull List<String> signatureErrors,
|
||||
boolean hasStableParameterNames
|
||||
) {
|
||||
super(signatureErrors);
|
||||
this.returnType = returnType;
|
||||
this.receiverType = receiverType;
|
||||
this.valueParameters = valueParameters;
|
||||
this.typeParameters = typeParameters;
|
||||
this.signatureErrors = signatureErrors;
|
||||
this.hasStableParameterNames = hasStableParameterNames;
|
||||
}
|
||||
|
||||
@@ -134,46 +98,15 @@ public interface ExternalSignatureResolver {
|
||||
public boolean hasStableParameterNames() {
|
||||
return hasStableParameterNames;
|
||||
}
|
||||
}
|
||||
|
||||
class AlternativeFieldSignature extends MemberSignature {
|
||||
private final KotlinType returnType;
|
||||
|
||||
public AlternativeFieldSignature(@NotNull KotlinType returnType, @Nullable String signatureError) {
|
||||
super(signatureError == null ? Collections.<String>emptyList() : Collections.singletonList(signatureError));
|
||||
this.returnType = returnType;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public KotlinType getReturnType() {
|
||||
return returnType;
|
||||
}
|
||||
}
|
||||
|
||||
class PropagatedMethodSignature extends AlternativeMethodSignature {
|
||||
private final List<FunctionDescriptor> superMethods;
|
||||
|
||||
public PropagatedMethodSignature(
|
||||
@Nullable KotlinType returnType,
|
||||
@Nullable KotlinType receiverType,
|
||||
@NotNull List<ValueParameterDescriptor> valueParameters,
|
||||
@NotNull List<TypeParameterDescriptor> typeParameters,
|
||||
@NotNull List<String> signatureErrors,
|
||||
boolean hasStableParameterNames,
|
||||
@NotNull List<FunctionDescriptor> superMethods
|
||||
) {
|
||||
super(returnType, receiverType, valueParameters, typeParameters, signatureErrors, hasStableParameterNames);
|
||||
this.superMethods = superMethods;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<FunctionDescriptor> getSuperMethods() {
|
||||
return superMethods;
|
||||
public List<String> getErrors() {
|
||||
return signatureErrors;
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
PropagatedMethodSignature resolvePropagatedSignature(
|
||||
AlternativeMethodSignature resolvePropagatedSignature(
|
||||
@NotNull JavaMethod method,
|
||||
@NotNull ClassDescriptor owner,
|
||||
@NotNull KotlinType returnType,
|
||||
@@ -182,23 +115,5 @@ public interface ExternalSignatureResolver {
|
||||
@NotNull List<TypeParameterDescriptor> typeParameters
|
||||
);
|
||||
|
||||
@NotNull
|
||||
AlternativeMethodSignature resolveAlternativeMethodSignature(
|
||||
@NotNull JavaMember methodOrConstructor,
|
||||
boolean hasSuperMethods,
|
||||
@Nullable KotlinType returnType,
|
||||
@Nullable KotlinType receiverType,
|
||||
@NotNull List<ValueParameterDescriptor> valueParameters,
|
||||
@NotNull List<TypeParameterDescriptor> typeParameters,
|
||||
boolean hasStableParameterNames
|
||||
);
|
||||
|
||||
@NotNull
|
||||
AlternativeFieldSignature resolveAlternativeFieldSignature(
|
||||
@NotNull JavaField field,
|
||||
@NotNull KotlinType returnType,
|
||||
boolean isVar
|
||||
);
|
||||
|
||||
void reportSignatureErrors(@NotNull CallableMemberDescriptor descriptor, @NotNull List<String> signatureErrors);
|
||||
}
|
||||
|
||||
+4
-19
@@ -30,6 +30,7 @@ import org.jetbrains.kotlin.load.java.BuiltinMethodsWithDifferentJvmName.sameAsR
|
||||
import org.jetbrains.kotlin.load.java.BuiltinMethodsWithSpecialGenericSignature.sameAsBuiltinMethodWithErasedValueParameters
|
||||
import org.jetbrains.kotlin.load.java.BuiltinSpecialProperties.getBuiltinSpecialPropertyGetterName
|
||||
import org.jetbrains.kotlin.load.java.components.DescriptorResolverUtils
|
||||
import org.jetbrains.kotlin.load.java.components.ExternalSignatureResolver
|
||||
import org.jetbrains.kotlin.load.java.components.TypeUsage
|
||||
import org.jetbrains.kotlin.load.java.descriptors.JavaConstructorDescriptor
|
||||
import org.jetbrains.kotlin.load.java.descriptors.JavaMethodDescriptor
|
||||
@@ -425,13 +426,7 @@ public class LazyJavaClassMemberScope(
|
||||
val propagated = c.components.externalSignatureResolver.resolvePropagatedSignature(
|
||||
method, ownerDescriptor, returnType, null, valueParameters.descriptors, methodTypeParameters
|
||||
)
|
||||
val effectiveSignature = c.components.externalSignatureResolver.resolveAlternativeMethodSignature(
|
||||
method, !propagated.getSuperMethods().isEmpty(), propagated.getReturnType(),
|
||||
propagated.getReceiverType(), propagated.getValueParameters(), propagated.getTypeParameters(),
|
||||
propagated.hasStableParameterNames()
|
||||
)
|
||||
|
||||
return LazyJavaScope.MethodSignatureData(effectiveSignature, propagated.getErrors() + effectiveSignature.getErrors())
|
||||
return LazyJavaScope.MethodSignatureData(propagated, propagated.errors)
|
||||
}
|
||||
|
||||
private fun hasOverriddenBuiltinFunctionWithErasedValueParameters(
|
||||
@@ -476,23 +471,13 @@ public class LazyJavaClassMemberScope(
|
||||
)
|
||||
|
||||
val valueParameters = resolveValueParameters(c, constructorDescriptor, constructor.getValueParameters())
|
||||
val effectiveSignature = c.components.externalSignatureResolver.resolveAlternativeMethodSignature(
|
||||
constructor, false, null, null, valueParameters.descriptors, Collections.emptyList(), false)
|
||||
|
||||
constructorDescriptor.initialize(
|
||||
effectiveSignature.getValueParameters(),
|
||||
constructor.getVisibility()
|
||||
)
|
||||
constructorDescriptor.setHasStableParameterNames(effectiveSignature.hasStableParameterNames())
|
||||
constructorDescriptor.initialize(valueParameters.descriptors, constructor.visibility)
|
||||
constructorDescriptor.setHasStableParameterNames(false)
|
||||
constructorDescriptor.setHasSynthesizedParameterNames(valueParameters.hasSynthesizedNames)
|
||||
|
||||
constructorDescriptor.setReturnType(classDescriptor.getDefaultType())
|
||||
|
||||
val signatureErrors = effectiveSignature.getErrors()
|
||||
if (!signatureErrors.isEmpty()) {
|
||||
c.components.externalSignatureResolver.reportSignatureErrors(constructorDescriptor, signatureErrors)
|
||||
}
|
||||
|
||||
c.components.javaResolverCache.recordConstructor(constructor, constructorDescriptor)
|
||||
|
||||
return constructorDescriptor
|
||||
|
||||
+1
-7
@@ -241,18 +241,12 @@ public abstract class LazyJavaScope(protected val c: LazyJavaResolverContext) :
|
||||
}
|
||||
|
||||
private fun resolveProperty(field: JavaField): PropertyDescriptor {
|
||||
val isVar = !field.isFinal()
|
||||
val propertyDescriptor = createPropertyDescriptor(field)
|
||||
propertyDescriptor.initialize(null, null)
|
||||
|
||||
val propertyType = getPropertyType(field, propertyDescriptor.getAnnotations())
|
||||
val effectiveSignature = c.components.externalSignatureResolver.resolveAlternativeFieldSignature(field, propertyType, isVar)
|
||||
val signatureErrors = effectiveSignature.getErrors()
|
||||
if (!signatureErrors.isEmpty()) {
|
||||
c.components.externalSignatureResolver.reportSignatureErrors(propertyDescriptor, signatureErrors)
|
||||
}
|
||||
|
||||
propertyDescriptor.setType(effectiveSignature.getReturnType(), listOf(), getDispatchReceiverParameter(), null as KotlinType?)
|
||||
propertyDescriptor.setType(propertyType, listOf(), getDispatchReceiverParameter(), null as KotlinType?)
|
||||
|
||||
if (DescriptorUtils.shouldRecordInitializerForProperty(propertyDescriptor, propertyDescriptor.getType())) {
|
||||
propertyDescriptor.setCompileTimeInitializer(
|
||||
|
||||
+4
-2
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.load.java.lazy.descriptors
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||
import org.jetbrains.kotlin.load.java.components.ExternalSignatureResolver
|
||||
import org.jetbrains.kotlin.load.java.lazy.LazyJavaResolverContext
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaMethod
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
@@ -36,8 +37,9 @@ public abstract class LazyJavaStaticScope(c: LazyJavaResolverContext) : LazyJava
|
||||
method: JavaMethod, methodTypeParameters: List<TypeParameterDescriptor>, returnType: KotlinType,
|
||||
valueParameters: LazyJavaScope.ResolvedValueParameters
|
||||
): LazyJavaScope.MethodSignatureData {
|
||||
val effectiveSignature = c.components.externalSignatureResolver.resolveAlternativeMethodSignature(
|
||||
method, false, returnType, null, valueParameters.descriptors, methodTypeParameters, false)
|
||||
val effectiveSignature = ExternalSignatureResolver.AlternativeMethodSignature(
|
||||
returnType, null, valueParameters.descriptors, methodTypeParameters, emptyList<String>(), false
|
||||
)
|
||||
return LazyJavaScope.MethodSignatureData(effectiveSignature, effectiveSignature.getErrors())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user