rename Jet* classes to Kt*
This commit is contained in:
+22
-22
@@ -22,7 +22,7 @@ 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.load.java.structure.JavaMethod;
|
||||
import org.jetbrains.kotlin.types.JetType;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -34,8 +34,8 @@ public interface ExternalSignatureResolver {
|
||||
public PropagatedMethodSignature resolvePropagatedSignature(
|
||||
@NotNull JavaMethod method,
|
||||
@NotNull ClassDescriptor owner,
|
||||
@NotNull JetType returnType,
|
||||
@Nullable JetType receiverType,
|
||||
@NotNull KtType returnType,
|
||||
@Nullable KtType receiverType,
|
||||
@NotNull List<ValueParameterDescriptor> valueParameters,
|
||||
@NotNull List<TypeParameterDescriptor> typeParameters
|
||||
) {
|
||||
@@ -50,8 +50,8 @@ public interface ExternalSignatureResolver {
|
||||
public AlternativeMethodSignature resolveAlternativeMethodSignature(
|
||||
@NotNull JavaMember methodOrConstructor,
|
||||
boolean hasSuperMethods,
|
||||
@Nullable JetType returnType,
|
||||
@Nullable JetType receiverType,
|
||||
@Nullable KtType returnType,
|
||||
@Nullable KtType receiverType,
|
||||
@NotNull List<ValueParameterDescriptor> valueParameters,
|
||||
@NotNull List<TypeParameterDescriptor> typeParameters,
|
||||
boolean hasStableParameterNames
|
||||
@@ -64,7 +64,7 @@ public interface ExternalSignatureResolver {
|
||||
@NotNull
|
||||
@Override
|
||||
public AlternativeFieldSignature resolveAlternativeFieldSignature(
|
||||
@NotNull JavaField field, @NotNull JetType returnType, boolean isVar
|
||||
@NotNull JavaField field, @NotNull KtType returnType, boolean isVar
|
||||
) {
|
||||
return new AlternativeFieldSignature(returnType, null);
|
||||
}
|
||||
@@ -89,15 +89,15 @@ public interface ExternalSignatureResolver {
|
||||
}
|
||||
|
||||
class AlternativeMethodSignature extends MemberSignature {
|
||||
private final JetType returnType;
|
||||
private final JetType receiverType;
|
||||
private final KtType returnType;
|
||||
private final KtType receiverType;
|
||||
private final List<ValueParameterDescriptor> valueParameters;
|
||||
private final List<TypeParameterDescriptor> typeParameters;
|
||||
private final boolean hasStableParameterNames;
|
||||
|
||||
public AlternativeMethodSignature(
|
||||
@Nullable JetType returnType,
|
||||
@Nullable JetType receiverType,
|
||||
@Nullable KtType returnType,
|
||||
@Nullable KtType receiverType,
|
||||
@NotNull List<ValueParameterDescriptor> valueParameters,
|
||||
@NotNull List<TypeParameterDescriptor> typeParameters,
|
||||
@NotNull List<String> signatureErrors,
|
||||
@@ -112,12 +112,12 @@ public interface ExternalSignatureResolver {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public JetType getReturnType() {
|
||||
public KtType getReturnType() {
|
||||
return returnType;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public JetType getReceiverType() {
|
||||
public KtType getReceiverType() {
|
||||
return receiverType;
|
||||
}
|
||||
|
||||
@@ -137,15 +137,15 @@ public interface ExternalSignatureResolver {
|
||||
}
|
||||
|
||||
class AlternativeFieldSignature extends MemberSignature {
|
||||
private final JetType returnType;
|
||||
private final KtType returnType;
|
||||
|
||||
public AlternativeFieldSignature(@NotNull JetType returnType, @Nullable String signatureError) {
|
||||
public AlternativeFieldSignature(@NotNull KtType returnType, @Nullable String signatureError) {
|
||||
super(signatureError == null ? Collections.<String>emptyList() : Collections.singletonList(signatureError));
|
||||
this.returnType = returnType;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JetType getReturnType() {
|
||||
public KtType getReturnType() {
|
||||
return returnType;
|
||||
}
|
||||
}
|
||||
@@ -154,8 +154,8 @@ public interface ExternalSignatureResolver {
|
||||
private final List<FunctionDescriptor> superMethods;
|
||||
|
||||
public PropagatedMethodSignature(
|
||||
@Nullable JetType returnType,
|
||||
@Nullable JetType receiverType,
|
||||
@Nullable KtType returnType,
|
||||
@Nullable KtType receiverType,
|
||||
@NotNull List<ValueParameterDescriptor> valueParameters,
|
||||
@NotNull List<TypeParameterDescriptor> typeParameters,
|
||||
@NotNull List<String> signatureErrors,
|
||||
@@ -176,8 +176,8 @@ public interface ExternalSignatureResolver {
|
||||
PropagatedMethodSignature resolvePropagatedSignature(
|
||||
@NotNull JavaMethod method,
|
||||
@NotNull ClassDescriptor owner,
|
||||
@NotNull JetType returnType,
|
||||
@Nullable JetType receiverType,
|
||||
@NotNull KtType returnType,
|
||||
@Nullable KtType receiverType,
|
||||
@NotNull List<ValueParameterDescriptor> valueParameters,
|
||||
@NotNull List<TypeParameterDescriptor> typeParameters
|
||||
);
|
||||
@@ -186,8 +186,8 @@ public interface ExternalSignatureResolver {
|
||||
AlternativeMethodSignature resolveAlternativeMethodSignature(
|
||||
@NotNull JavaMember methodOrConstructor,
|
||||
boolean hasSuperMethods,
|
||||
@Nullable JetType returnType,
|
||||
@Nullable JetType receiverType,
|
||||
@Nullable KtType returnType,
|
||||
@Nullable KtType receiverType,
|
||||
@NotNull List<ValueParameterDescriptor> valueParameters,
|
||||
@NotNull List<TypeParameterDescriptor> typeParameters,
|
||||
boolean hasStableParameterNames
|
||||
@@ -196,7 +196,7 @@ public interface ExternalSignatureResolver {
|
||||
@NotNull
|
||||
AlternativeFieldSignature resolveAlternativeFieldSignature(
|
||||
@NotNull JavaField field,
|
||||
@NotNull JetType returnType,
|
||||
@NotNull KtType returnType,
|
||||
boolean isVar
|
||||
);
|
||||
|
||||
|
||||
+6
-6
@@ -21,24 +21,24 @@ import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor
|
||||
import org.jetbrains.kotlin.load.java.descriptors.SamConstructorDescriptor
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaMethod
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||
import org.jetbrains.kotlin.types.JetType
|
||||
import org.jetbrains.kotlin.resolve.scopes.KtScope
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
|
||||
public interface SamConversionResolver {
|
||||
public companion object EMPTY : SamConversionResolver {
|
||||
override fun <D : FunctionDescriptor> resolveSamAdapter(original: D) = null
|
||||
override fun resolveSamConstructor(name: Name, scope: JetScope) = null
|
||||
override fun resolveSamConstructor(name: Name, scope: KtScope) = null
|
||||
override fun resolveFunctionTypeIfSamInterface(
|
||||
classDescriptor: JavaClassDescriptor, resolveMethod: (JavaMethod) -> FunctionDescriptor
|
||||
): JetType? = null
|
||||
): KtType? = null
|
||||
}
|
||||
|
||||
public fun resolveSamConstructor(name: Name, scope: JetScope): SamConstructorDescriptor?
|
||||
public fun resolveSamConstructor(name: Name, scope: KtScope): SamConstructorDescriptor?
|
||||
|
||||
public fun <D : FunctionDescriptor> resolveSamAdapter(original: D): D?
|
||||
|
||||
public fun resolveFunctionTypeIfSamInterface(
|
||||
classDescriptor: JavaClassDescriptor,
|
||||
resolveMethod: (JavaMethod) -> FunctionDescriptor
|
||||
): JetType?
|
||||
): KtType?
|
||||
}
|
||||
|
||||
+4
-5
@@ -19,16 +19,15 @@ package org.jetbrains.kotlin.load.java.descriptors;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor;
|
||||
import org.jetbrains.kotlin.types.JetType;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface JavaCallableMemberDescriptor extends CallableMemberDescriptor {
|
||||
@NotNull
|
||||
JavaCallableMemberDescriptor enhance(
|
||||
@Nullable JetType enhancedReceiverType,
|
||||
@NotNull List<JetType> enhancedValueParametersTypes,
|
||||
@NotNull JetType enhancedReturnType
|
||||
@Nullable KtType enhancedReceiverType,
|
||||
@NotNull List<KtType> enhancedValueParametersTypes,
|
||||
@NotNull KtType enhancedReturnType
|
||||
);
|
||||
}
|
||||
|
||||
+2
-2
@@ -18,9 +18,9 @@ package org.jetbrains.kotlin.load.java.descriptors;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.kotlin.types.JetType;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
|
||||
public interface JavaClassDescriptor extends ClassDescriptor {
|
||||
@Nullable
|
||||
JetType getFunctionTypeForSamInterface();
|
||||
KtType getFunctionTypeForSamInterface();
|
||||
}
|
||||
|
||||
+4
-4
@@ -21,7 +21,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.kotlin.descriptors.impl.ConstructorDescriptorImpl;
|
||||
import org.jetbrains.kotlin.types.JetType;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -96,9 +96,9 @@ public class JavaConstructorDescriptor extends ConstructorDescriptorImpl impleme
|
||||
@Override
|
||||
@NotNull
|
||||
public JavaConstructorDescriptor enhance(
|
||||
@Nullable JetType enhancedReceiverType,
|
||||
@NotNull List<JetType> enhancedValueParametersTypes,
|
||||
@NotNull JetType enhancedReturnType
|
||||
@Nullable KtType enhancedReceiverType,
|
||||
@NotNull List<KtType> enhancedValueParametersTypes,
|
||||
@NotNull KtType enhancedReturnType
|
||||
) {
|
||||
JavaConstructorDescriptor enhanced = createSubstitutedCopy(getContainingDeclaration(), getOriginal(), getKind());
|
||||
// We do not use doSubstitute here as in JavaMethodDescriptor.enhance because type parameters of constructor belongs to class
|
||||
|
||||
+6
-6
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.types.JetType;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.TypeSubstitutor;
|
||||
import org.jetbrains.kotlin.util.OperatorChecks;
|
||||
|
||||
@@ -77,11 +77,11 @@ public class JavaMethodDescriptor extends SimpleFunctionDescriptorImpl implement
|
||||
@NotNull
|
||||
@Override
|
||||
public SimpleFunctionDescriptorImpl initialize(
|
||||
@Nullable JetType receiverParameterType,
|
||||
@Nullable KtType receiverParameterType,
|
||||
@Nullable ReceiverParameterDescriptor dispatchReceiverParameter,
|
||||
@NotNull List<? extends TypeParameterDescriptor> typeParameters,
|
||||
@NotNull List<ValueParameterDescriptor> unsubstitutedValueParameters,
|
||||
@Nullable JetType unsubstitutedReturnType,
|
||||
@Nullable KtType unsubstitutedReturnType,
|
||||
@Nullable Modality modality,
|
||||
@NotNull Visibility visibility
|
||||
) {
|
||||
@@ -130,9 +130,9 @@ public class JavaMethodDescriptor extends SimpleFunctionDescriptorImpl implement
|
||||
@Override
|
||||
@NotNull
|
||||
public JavaMethodDescriptor enhance(
|
||||
@Nullable JetType enhancedReceiverType,
|
||||
@NotNull List<JetType> enhancedValueParametersTypes,
|
||||
@NotNull JetType enhancedReturnType
|
||||
@Nullable KtType enhancedReceiverType,
|
||||
@NotNull List<KtType> enhancedValueParametersTypes,
|
||||
@NotNull KtType enhancedReturnType
|
||||
) {
|
||||
List<ValueParameterDescriptor> enhancedValueParameters =
|
||||
UtilKt.copyValueParameters(enhancedValueParametersTypes, getValueParameters(), this);
|
||||
|
||||
+4
-4
@@ -24,7 +24,7 @@ import org.jetbrains.kotlin.descriptors.impl.PropertyDescriptorImpl;
|
||||
import org.jetbrains.kotlin.descriptors.impl.PropertyGetterDescriptorImpl;
|
||||
import org.jetbrains.kotlin.descriptors.impl.PropertySetterDescriptorImpl;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.types.JetType;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -55,9 +55,9 @@ public class JavaPropertyDescriptor extends PropertyDescriptorImpl implements Ja
|
||||
@NotNull
|
||||
@Override
|
||||
public JavaCallableMemberDescriptor enhance(
|
||||
@Nullable JetType enhancedReceiverType,
|
||||
@NotNull List<JetType> enhancedValueParametersTypes,
|
||||
@NotNull JetType enhancedReturnType
|
||||
@Nullable KtType enhancedReceiverType,
|
||||
@NotNull List<KtType> enhancedValueParametersTypes,
|
||||
@NotNull KtType enhancedReturnType
|
||||
) {
|
||||
JavaPropertyDescriptor enhanced = new JavaPropertyDescriptor(
|
||||
getContainingDeclaration(),
|
||||
|
||||
@@ -29,10 +29,10 @@ import org.jetbrains.kotlin.serialization.ProtoBuf
|
||||
import org.jetbrains.kotlin.serialization.deserialization.NameResolver
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedCallableMemberDescriptor
|
||||
import org.jetbrains.kotlin.serialization.jvm.JvmProtoBuf
|
||||
import org.jetbrains.kotlin.types.JetType
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
|
||||
fun copyValueParameters(
|
||||
newValueParametersTypes: Collection<JetType>,
|
||||
newValueParametersTypes: Collection<KtType>,
|
||||
oldValueParameters: Collection<ValueParameterDescriptor>,
|
||||
newOwner: CallableDescriptor
|
||||
): List<ValueParameterDescriptor> {
|
||||
|
||||
+1
-1
@@ -65,7 +65,7 @@ class LazyJavaAnnotationDescriptor(
|
||||
|
||||
private val factory = ConstantValueFactory(c.module.builtIns)
|
||||
|
||||
override fun getType(): JetType = type()
|
||||
override fun getType(): KtType = type()
|
||||
|
||||
private val allValueArguments = c.storageManager.createLazyValue {
|
||||
computeValueArguments()
|
||||
|
||||
+10
-10
@@ -35,7 +35,7 @@ import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.isValidJavaFqName
|
||||
import org.jetbrains.kotlin.resolve.constants.StringValue
|
||||
import org.jetbrains.kotlin.resolve.scopes.InnerClassesScopeWrapper
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.KtScope
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
import org.jetbrains.kotlin.utils.toReadOnlyList
|
||||
@@ -82,10 +82,10 @@ class LazyJavaClassDescriptor(
|
||||
override fun getUnsubstitutedMemberScope() = unsubstitutedMemberScope
|
||||
|
||||
private val innerClassesScope = InnerClassesScopeWrapper(getUnsubstitutedMemberScope())
|
||||
override fun getUnsubstitutedInnerClassesScope(): JetScope = innerClassesScope
|
||||
override fun getUnsubstitutedInnerClassesScope(): KtScope = innerClassesScope
|
||||
|
||||
private val staticScope = LazyJavaStaticClassScope(c, jClass, this)
|
||||
override fun getStaticScope(): JetScope = staticScope
|
||||
override fun getStaticScope(): KtScope = staticScope
|
||||
|
||||
override fun getUnsubstitutedPrimaryConstructor(): ConstructorDescriptor? = null
|
||||
|
||||
@@ -102,7 +102,7 @@ class LazyJavaClassDescriptor(
|
||||
}
|
||||
}
|
||||
|
||||
override fun getFunctionTypeForSamInterface(): JetType? = functionTypeForSamInterface()
|
||||
override fun getFunctionTypeForSamInterface(): KtType? = functionTypeForSamInterface()
|
||||
|
||||
override fun isCompanionObject() = false
|
||||
|
||||
@@ -120,12 +120,12 @@ class LazyJavaClassDescriptor(
|
||||
|
||||
override fun getParameters(): List<TypeParameterDescriptor> = parameters()
|
||||
|
||||
private val supertypes = c.storageManager.createLazyValue<Collection<JetType>> {
|
||||
private val supertypes = c.storageManager.createLazyValue<Collection<KtType>> {
|
||||
val javaTypes = jClass.getSupertypes()
|
||||
val result = ArrayList<JetType>(javaTypes.size())
|
||||
val result = ArrayList<KtType>(javaTypes.size())
|
||||
val incomplete = ArrayList<JavaType>(0)
|
||||
|
||||
val purelyImplementedSupertype: JetType? = getPurelyImplementedSupertype()
|
||||
val purelyImplementedSupertype: KtType? = getPurelyImplementedSupertype()
|
||||
|
||||
for (javaType in javaTypes) {
|
||||
val jetType = c.typeResolver.transformJavaType(javaType, TypeUsage.SUPERTYPE.toAttributes())
|
||||
@@ -154,7 +154,7 @@ class LazyJavaClassDescriptor(
|
||||
if (result.isNotEmpty()) result.toReadOnlyList() else listOf(c.module.builtIns.getAnyType())
|
||||
}
|
||||
|
||||
private fun getPurelyImplementedSupertype(): JetType? {
|
||||
private fun getPurelyImplementedSupertype(): KtType? {
|
||||
val purelyImplementedFqName = getPurelyImplementsFqNameFromAnnotation()
|
||||
?: FakePureImplementationsProvider.getPurelyImplementedInterface(fqName)
|
||||
?: return null
|
||||
@@ -169,7 +169,7 @@ class LazyJavaClassDescriptor(
|
||||
parameter -> TypeProjectionImpl(Variance.INVARIANT, parameter.getDefaultType())
|
||||
}
|
||||
|
||||
return JetTypeImpl.create(
|
||||
return KtTypeImpl.create(
|
||||
Annotations.EMPTY, classDescriptor,
|
||||
/* nullable =*/ false, parametersAsTypeProjections
|
||||
)
|
||||
@@ -186,7 +186,7 @@ class LazyJavaClassDescriptor(
|
||||
return FqName(fqNameString)
|
||||
}
|
||||
|
||||
override fun getSupertypes(): Collection<JetType> = supertypes()
|
||||
override fun getSupertypes(): Collection<KtType> = supertypes()
|
||||
|
||||
override fun getAnnotations() = Annotations.EMPTY
|
||||
|
||||
|
||||
+13
-13
@@ -52,9 +52,9 @@ import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.OverridingUtil
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||
import org.jetbrains.kotlin.serialization.deserialization.ErrorReporter
|
||||
import org.jetbrains.kotlin.types.JetType
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
import org.jetbrains.kotlin.types.checker.JetTypeChecker
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
|
||||
import org.jetbrains.kotlin.utils.*
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.check
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.firstNotNullResult
|
||||
@@ -165,7 +165,7 @@ public class LazyJavaClassMemberScope(
|
||||
val descriptor = resolveMethodToFunctionDescriptor(javaMethod)
|
||||
if (descriptor.valueParameters.size != 0) return@factory null
|
||||
|
||||
descriptor.check { JetTypeChecker.DEFAULT.isSubtypeOf(descriptor.returnType ?: return@check false, type) }
|
||||
descriptor.check { KotlinTypeChecker.DEFAULT.isSubtypeOf(descriptor.returnType ?: return@check false, type) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ public class LazyJavaClassMemberScope(
|
||||
if (descriptor.valueParameters.size != 1) return@factory null
|
||||
|
||||
if (!KotlinBuiltIns.isUnit(descriptor.returnType ?: return@factory null)) return@factory null
|
||||
descriptor.check { JetTypeChecker.DEFAULT.equalTypes(descriptor.valueParameters.single().type, type) }
|
||||
descriptor.check { KotlinTypeChecker.DEFAULT.equalTypes(descriptor.valueParameters.single().type, type) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -263,7 +263,7 @@ public class LazyJavaClassMemberScope(
|
||||
}
|
||||
|
||||
private fun createPropertyDescriptorWithDefaultGetter(
|
||||
method: JavaMethod, givenType: JetType? = null, modality: Modality
|
||||
method: JavaMethod, givenType: KtType? = null, modality: Modality
|
||||
): JavaPropertyDescriptor {
|
||||
val annotations = c.resolveAnnotations(method)
|
||||
|
||||
@@ -277,7 +277,7 @@ public class LazyJavaClassMemberScope(
|
||||
propertyDescriptor.initialize(getter, null)
|
||||
|
||||
val returnType = givenType ?: computeMethodReturnType(method, annotations, c.child(propertyDescriptor, method))
|
||||
propertyDescriptor.setType(returnType, listOf(), getDispatchReceiverParameter(), null as JetType?)
|
||||
propertyDescriptor.setType(returnType, listOf(), getDispatchReceiverParameter(), null as KtType?)
|
||||
getter.initialize(returnType)
|
||||
|
||||
return propertyDescriptor
|
||||
@@ -302,7 +302,7 @@ public class LazyJavaClassMemberScope(
|
||||
/* isStaticFinal = */ false
|
||||
)
|
||||
|
||||
propertyDescriptor.setType(getterMethod.returnType!!, listOf(), getDispatchReceiverParameter(), null as JetType?)
|
||||
propertyDescriptor.setType(getterMethod.returnType!!, listOf(), getDispatchReceiverParameter(), null as KtType?)
|
||||
|
||||
val getter = DescriptorFactory.createGetter(
|
||||
propertyDescriptor, getterMethod.annotations, /* isDefault = */false,
|
||||
@@ -326,7 +326,7 @@ public class LazyJavaClassMemberScope(
|
||||
}
|
||||
|
||||
override fun resolveMethodSignature(
|
||||
method: JavaMethod, methodTypeParameters: List<TypeParameterDescriptor>, returnType: JetType,
|
||||
method: JavaMethod, methodTypeParameters: List<TypeParameterDescriptor>, returnType: KtType,
|
||||
valueParameters: LazyJavaScope.ResolvedValueParameters
|
||||
): LazyJavaScope.MethodSignatureData {
|
||||
val propagated = c.components.externalSignatureResolver.resolvePropagatedSignature(
|
||||
@@ -406,12 +406,12 @@ public class LazyJavaClassMemberScope(
|
||||
val currentType = valueParameters[index].type
|
||||
val overriddenCandidate = RawSubstitution.eraseType(
|
||||
builtinWithErasedParameters.original.valueParameters[index].type)
|
||||
JetTypeChecker.DEFAULT.equalTypes(currentType, overriddenCandidate)
|
||||
KotlinTypeChecker.DEFAULT.equalTypes(currentType, overriddenCandidate)
|
||||
} && returnType.isSubtypeOf(builtinWithErasedParameters.returnType)
|
||||
}
|
||||
|
||||
private fun JetType?.isSubtypeOf(other: JetType?): Boolean {
|
||||
return JetTypeChecker.DEFAULT.isSubtypeOf(this ?: return false, other ?: return false)
|
||||
private fun KtType?.isSubtypeOf(other: KtType?): Boolean {
|
||||
return KotlinTypeChecker.DEFAULT.isSubtypeOf(this ?: return false, other ?: return false)
|
||||
}
|
||||
|
||||
private fun resolveConstructor(constructor: JavaConstructor): JavaConstructorDescriptor {
|
||||
@@ -510,8 +510,8 @@ public class LazyJavaClassMemberScope(
|
||||
constructor: ConstructorDescriptor,
|
||||
index: Int,
|
||||
method: JavaMethod,
|
||||
returnType: JetType,
|
||||
varargElementType: JetType?
|
||||
returnType: KtType,
|
||||
varargElementType: KtType?
|
||||
) {
|
||||
add(ValueParameterDescriptorImpl(
|
||||
constructor,
|
||||
|
||||
+2
-2
@@ -35,7 +35,7 @@ import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.name.SpecialNames
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.KtScope
|
||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
|
||||
public class LazyJavaPackageScope(
|
||||
@@ -75,7 +75,7 @@ public class LazyJavaPackageScope(
|
||||
c.components.deserializedDescriptorResolver.readData(binaryClass, DeserializedDescriptorResolver.KOTLIN_PACKAGE_FACADE)
|
||||
}
|
||||
|
||||
JetScope.Empty
|
||||
KtScope.Empty
|
||||
}
|
||||
else {
|
||||
c.components.deserializedDescriptorResolver.createKotlinPackageScope(packageFragment, containingDeclaration.kotlinBinaryClasses)
|
||||
|
||||
+9
-9
@@ -40,10 +40,10 @@ import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.jvm.PLATFORM_TYPES
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindExclude.NonExtensions
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScopeImpl
|
||||
import org.jetbrains.kotlin.resolve.scopes.KtScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.KtScopeImpl
|
||||
import org.jetbrains.kotlin.storage.NotNullLazyValue
|
||||
import org.jetbrains.kotlin.types.JetType
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
import org.jetbrains.kotlin.utils.Printer
|
||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
@@ -53,11 +53,11 @@ import java.util.*
|
||||
public abstract class LazyJavaScope(
|
||||
protected val c: LazyJavaResolverContext,
|
||||
private val containingDeclaration: DeclarationDescriptor
|
||||
) : JetScopeImpl() {
|
||||
) : KtScopeImpl() {
|
||||
// this lazy value is not used at all in LazyPackageFragmentScopeForJavaPackage because we do not use caching there
|
||||
// but is placed in the base class to not duplicate code
|
||||
private val allDescriptors = c.storageManager.createRecursionTolerantLazyValue<Collection<DeclarationDescriptor>>(
|
||||
{ computeDescriptors(DescriptorKindFilter.ALL, JetScope.ALL_NAME_FILTER, NoLookupLocation.WHEN_GET_ALL_DESCRIPTORS) },
|
||||
{ computeDescriptors(DescriptorKindFilter.ALL, KtScope.ALL_NAME_FILTER, NoLookupLocation.WHEN_GET_ALL_DESCRIPTORS) },
|
||||
// This is to avoid the following recursive case:
|
||||
// when computing getAllPackageNames() we ask the JavaPsiFacade for all subpackages of foo
|
||||
// it, in turn, asks JavaElementFinder for subpackages of Kotlin package foo, which calls getAllPackageNames() recursively
|
||||
@@ -106,7 +106,7 @@ public abstract class LazyJavaScope(
|
||||
protected abstract fun resolveMethodSignature(
|
||||
method: JavaMethod,
|
||||
methodTypeParameters: List<TypeParameterDescriptor>,
|
||||
returnType: JetType,
|
||||
returnType: KtType,
|
||||
valueParameters: ResolvedValueParameters): MethodSignatureData
|
||||
|
||||
open fun resolveMethodToFunctionDescriptor(method: JavaMethod): JavaMethodDescriptor {
|
||||
@@ -147,7 +147,7 @@ public abstract class LazyJavaScope(
|
||||
return functionDescriptorImpl
|
||||
}
|
||||
|
||||
protected fun computeMethodReturnType(method: JavaMethod, annotations: Annotations, c: LazyJavaResolverContext): JetType {
|
||||
protected fun computeMethodReturnType(method: JavaMethod, annotations: Annotations, c: LazyJavaResolverContext): KtType {
|
||||
val annotationMethod = method.getContainingClass().isAnnotationType()
|
||||
val returnTypeAttrs = LazyJavaTypeAttributes(
|
||||
TypeUsage.MEMBER_SIGNATURE_COVARIANT, annotations,
|
||||
@@ -255,7 +255,7 @@ public abstract class LazyJavaScope(
|
||||
c.components.externalSignatureResolver.reportSignatureErrors(propertyDescriptor, signatureErrors)
|
||||
}
|
||||
|
||||
propertyDescriptor.setType(effectiveSignature.getReturnType(), listOf(), getDispatchReceiverParameter(), null as JetType?)
|
||||
propertyDescriptor.setType(effectiveSignature.getReturnType(), listOf(), getDispatchReceiverParameter(), null as KtType?)
|
||||
|
||||
if (DescriptorUtils.shouldRecordInitializerForProperty(propertyDescriptor, propertyDescriptor.getType())) {
|
||||
propertyDescriptor.setCompileTimeInitializer(
|
||||
@@ -282,7 +282,7 @@ public abstract class LazyJavaScope(
|
||||
private val JavaField.isFinalStatic: Boolean
|
||||
get() = isFinal && isStatic
|
||||
|
||||
private fun getPropertyType(field: JavaField, annotations: Annotations): JetType {
|
||||
private fun getPropertyType(field: JavaField, annotations: Annotations): KtType {
|
||||
// Fields do not have their own generic parameters
|
||||
val finalStatic = field.isFinalStatic
|
||||
// simple static constants should not have flexible types:
|
||||
|
||||
+2
-2
@@ -33,7 +33,7 @@ import org.jetbrains.kotlin.resolve.DescriptorFactory.createEnumValuesMethod
|
||||
import org.jetbrains.kotlin.resolve.DescriptorFactory.createEnumValuesProperty
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||
import org.jetbrains.kotlin.types.JetType
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
|
||||
public class LazyJavaStaticClassScope(
|
||||
@@ -117,7 +117,7 @@ public class LazyJavaStaticClassScope(
|
||||
|
||||
private fun getStaticPropertiesFromJavaSupertypes(name: Name, descriptor: ClassDescriptor): Set<PropertyDescriptor> {
|
||||
|
||||
fun getStaticProperties(supertype: JetType): Iterable<PropertyDescriptor> {
|
||||
fun getStaticProperties(supertype: KtType): Iterable<PropertyDescriptor> {
|
||||
val superTypeDescriptor = supertype.constructor.declarationDescriptor as? ClassDescriptor ?: return emptyList()
|
||||
|
||||
val staticScope = superTypeDescriptor.staticScope
|
||||
|
||||
+2
-2
@@ -24,7 +24,7 @@ import org.jetbrains.kotlin.load.java.lazy.LazyJavaResolverContext
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaMethod
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.types.JetType
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
|
||||
public abstract class LazyJavaStaticScope(
|
||||
c: LazyJavaResolverContext,
|
||||
@@ -40,7 +40,7 @@ public abstract class LazyJavaStaticScope(
|
||||
override fun getImplicitReceiversHierarchy(): List<ReceiverParameterDescriptor> = listOf()
|
||||
|
||||
override fun resolveMethodSignature(
|
||||
method: JavaMethod, methodTypeParameters: List<TypeParameterDescriptor>, returnType: JetType,
|
||||
method: JavaMethod, methodTypeParameters: List<TypeParameterDescriptor>, returnType: KtType,
|
||||
valueParameters: LazyJavaScope.ResolvedValueParameters
|
||||
): LazyJavaScope.MethodSignatureData {
|
||||
val effectiveSignature = c.components.externalSignatureResolver.resolveAlternativeMethodSignature(
|
||||
|
||||
+2
-2
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.load.java.lazy.descriptors
|
||||
import org.jetbrains.kotlin.descriptors.impl.AbstractLazyTypeParameterDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
import org.jetbrains.kotlin.types.JetType
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaTypeParameter
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
|
||||
@@ -45,7 +45,7 @@ class LazyJavaTypeParameterDescriptor(
|
||||
SourceElement.NO_SOURCE
|
||||
) {
|
||||
|
||||
override fun resolveUpperBounds(): Set<JetType> {
|
||||
override fun resolveUpperBounds(): Set<KtType> {
|
||||
val bounds = javaTypeParameter.getUpperBounds()
|
||||
if (bounds.isEmpty()) {
|
||||
return setOf(LazyJavaTypeResolver.FlexibleJavaClassifierTypeCapabilities.create(
|
||||
|
||||
+16
-16
@@ -39,7 +39,7 @@ import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.Variance.INVARIANT
|
||||
import org.jetbrains.kotlin.types.Variance.IN_VARIANCE
|
||||
import org.jetbrains.kotlin.types.Variance.OUT_VARIANCE
|
||||
import org.jetbrains.kotlin.types.checker.JetTypeChecker
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
|
||||
import org.jetbrains.kotlin.types.typeUtil.createProjection
|
||||
import org.jetbrains.kotlin.types.typeUtil.replaceAnnotations
|
||||
import org.jetbrains.kotlin.utils.sure
|
||||
@@ -52,7 +52,7 @@ class LazyJavaTypeResolver(
|
||||
private val typeParameterResolver: TypeParameterResolver
|
||||
) {
|
||||
|
||||
public fun transformJavaType(javaType: JavaType, attr: JavaTypeAttributes): JetType {
|
||||
public fun transformJavaType(javaType: JavaType, attr: JavaTypeAttributes): KtType {
|
||||
return when (javaType) {
|
||||
is JavaPrimitiveType -> {
|
||||
val primitiveType = javaType.getType()
|
||||
@@ -71,7 +71,7 @@ class LazyJavaTypeResolver(
|
||||
}
|
||||
}
|
||||
|
||||
public fun transformArrayType(arrayType: JavaArrayType, attr: JavaTypeAttributes, isVararg: Boolean = false): JetType {
|
||||
public fun transformArrayType(arrayType: JavaArrayType, attr: JavaTypeAttributes, isVararg: Boolean = false): KtType {
|
||||
return run {
|
||||
val javaComponentType = arrayType.getComponentType()
|
||||
val primitiveType = (javaComponentType as? JavaPrimitiveType)?.getType()
|
||||
@@ -169,17 +169,17 @@ class LazyJavaTypeResolver(
|
||||
|
||||
// We do not memoize the results of this method, because it would consume much memory, and the real gain is little:
|
||||
// the case this method accounts for is very rare, not point in optimizing it
|
||||
private fun getConstructorTypeParameterSubstitute(): JetType {
|
||||
private fun getConstructorTypeParameterSubstitute(): KtType {
|
||||
// If a Java-constructor declares its own type parameters, we have no way of directly expressing them in Kotlin,
|
||||
// so we replace them by intersections of their upper bounds
|
||||
val supertypesJet = HashSet<JetType>()
|
||||
val supertypesJet = HashSet<KtType>()
|
||||
for (supertype in (classifier() as JavaTypeParameter).getUpperBounds()) {
|
||||
supertypesJet.add(transformJavaType(supertype, UPPER_BOUND.toAttributes()))
|
||||
}
|
||||
if (supertypesJet.isEmpty()) {
|
||||
return c.module.builtIns.nullableAnyType
|
||||
}
|
||||
return TypeIntersector.intersectTypes(JetTypeChecker.DEFAULT, supertypesJet)
|
||||
return TypeIntersector.intersectTypes(KotlinTypeChecker.DEFAULT, supertypesJet)
|
||||
?: ErrorUtils.createErrorType("Can't intersect upper bounds of " + javaType.getPresentableText())
|
||||
}
|
||||
|
||||
@@ -290,11 +290,11 @@ class LazyJavaTypeResolver(
|
||||
|
||||
public object FlexibleJavaClassifierTypeCapabilities : FlexibleTypeCapabilities {
|
||||
@JvmStatic
|
||||
fun create(lowerBound: JetType, upperBound: JetType) = DelegatingFlexibleType.create(lowerBound, upperBound, this)
|
||||
fun create(lowerBound: KtType, upperBound: KtType) = DelegatingFlexibleType.create(lowerBound, upperBound, this)
|
||||
|
||||
override val id: String get() = "kotlin.jvm.PlatformType"
|
||||
|
||||
override fun <T : TypeCapability> getCapability(capabilityClass: Class<T>, jetType: JetType, flexibility: Flexibility): T? {
|
||||
override fun <T : TypeCapability> getCapability(capabilityClass: Class<T>, jetType: KtType, flexibility: Flexibility): T? {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return when (capabilityClass) {
|
||||
javaClass<CustomTypeVariable>(), javaClass<Specificity>() -> Impl(flexibility) as T
|
||||
@@ -305,8 +305,8 @@ class LazyJavaTypeResolver(
|
||||
|
||||
private class Impl(val flexibility: Flexibility) : CustomTypeVariable, Specificity {
|
||||
|
||||
private val lowerBound: JetType get() = flexibility.lowerBound
|
||||
private val upperBound: JetType get() = flexibility.upperBound
|
||||
private val lowerBound: KtType get() = flexibility.lowerBound
|
||||
private val upperBound: KtType get() = flexibility.upperBound
|
||||
|
||||
override val isTypeVariable: Boolean = lowerBound.getConstructor() == upperBound.getConstructor()
|
||||
&& lowerBound.getConstructor().getDeclarationDescriptor() is TypeParameterDescriptor
|
||||
@@ -314,12 +314,12 @@ class LazyJavaTypeResolver(
|
||||
override val typeParameterDescriptor: TypeParameterDescriptor? =
|
||||
if (isTypeVariable) lowerBound.getConstructor().getDeclarationDescriptor() as TypeParameterDescriptor else null
|
||||
|
||||
override fun substitutionResult(replacement: JetType): JetType {
|
||||
override fun substitutionResult(replacement: KtType): KtType {
|
||||
return if (replacement.isFlexible()) replacement
|
||||
else create(replacement, TypeUtils.makeNullable(replacement))
|
||||
}
|
||||
|
||||
override fun getSpecificityRelationTo(otherType: JetType): Specificity.Relation {
|
||||
override fun getSpecificityRelationTo(otherType: KtType): Specificity.Relation {
|
||||
// For primitive types we have to take care of the case when there are two overloaded methods like
|
||||
// foo(int) and foo(Integer)
|
||||
// if we do not discriminate one of them, any call to foo(kotlin.Int) will result in overload resolution ambiguity
|
||||
@@ -425,8 +425,8 @@ internal fun TypeParameterDescriptor.getErasedUpperBound(
|
||||
// E.g. `class A<T extends A, F extends A>`
|
||||
// To prevent recursive calls return defaultValue() instead
|
||||
potentiallyRecursiveTypeParameter: TypeParameterDescriptor? = null,
|
||||
defaultValue: (() -> JetType) = { ErrorUtils.createErrorType("Can't compute erased upper bound of type parameter `$this`") }
|
||||
): JetType {
|
||||
defaultValue: (() -> KtType) = { ErrorUtils.createErrorType("Can't compute erased upper bound of type parameter `$this`") }
|
||||
): KtType {
|
||||
if (this === potentiallyRecursiveTypeParameter) return defaultValue()
|
||||
|
||||
val firstUpperBound = upperBounds.first()
|
||||
@@ -450,7 +450,7 @@ internal fun TypeParameterDescriptor.getErasedUpperBound(
|
||||
return defaultValue()
|
||||
}
|
||||
|
||||
private fun JetType.replaceArgumentsWithStarProjections(): JetType {
|
||||
private fun KtType.replaceArgumentsWithStarProjections(): KtType {
|
||||
if (constructor.parameters.isEmpty() || constructor.declarationDescriptor == null) return this
|
||||
|
||||
// We could just create JetTypeImpl with current type constructor and star projections,
|
||||
@@ -459,7 +459,7 @@ private fun JetType.replaceArgumentsWithStarProjections(): JetType {
|
||||
}
|
||||
|
||||
private object ConstantStarSubstitution : TypeSubstitution() {
|
||||
override fun get(key: JetType): TypeProjection? {
|
||||
override fun get(key: KtType): TypeProjection? {
|
||||
// Let substitutor deal with flexibility
|
||||
if (key.isFlexible()) return null
|
||||
|
||||
|
||||
+8
-8
@@ -32,14 +32,14 @@ public object RawTypeCapabilities : TypeCapabilities {
|
||||
}
|
||||
|
||||
private object RawFlexibleRendering : CustomFlexibleRendering {
|
||||
private fun DescriptorRenderer.renderArguments(jetType: JetType) = jetType.arguments.map { renderTypeProjection(it) }
|
||||
private fun DescriptorRenderer.renderArguments(jetType: KtType) = jetType.arguments.map { renderTypeProjection(it) }
|
||||
|
||||
private fun String.replaceArgs(newArgs: String): String {
|
||||
if (!contains('<')) return this
|
||||
return "${substringBefore('<')}<$newArgs>${substringAfterLast('>')}"
|
||||
}
|
||||
|
||||
override fun renderInflexible(type: JetType, renderer: DescriptorRenderer): String? {
|
||||
override fun renderInflexible(type: KtType, renderer: DescriptorRenderer): String? {
|
||||
if (type.arguments.isNotEmpty()) return null
|
||||
|
||||
return StringBuilder {
|
||||
@@ -81,12 +81,12 @@ public object RawTypeCapabilities : TypeCapabilities {
|
||||
}
|
||||
|
||||
internal object RawSubstitution : TypeSubstitution() {
|
||||
override fun get(key: JetType) = TypeProjectionImpl(eraseType(key))
|
||||
override fun get(key: KtType) = TypeProjectionImpl(eraseType(key))
|
||||
|
||||
private val lowerTypeAttr = TypeUsage.MEMBER_SIGNATURE_INVARIANT.toAttributes().toFlexible(JavaTypeFlexibility.FLEXIBLE_LOWER_BOUND)
|
||||
private val upperTypeAttr = TypeUsage.MEMBER_SIGNATURE_INVARIANT.toAttributes().toFlexible(JavaTypeFlexibility.FLEXIBLE_UPPER_BOUND)
|
||||
|
||||
public fun eraseType(type: JetType): JetType {
|
||||
public fun eraseType(type: KtType): KtType {
|
||||
val declaration = type.constructor.declarationDescriptor
|
||||
return when (declaration) {
|
||||
is TypeParameterDescriptor -> eraseType(declaration.getErasedUpperBound())
|
||||
@@ -102,20 +102,20 @@ internal object RawSubstitution : TypeSubstitution() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun eraseInflexibleBasedOnClassDescriptor(type: JetType, declaration: ClassDescriptor, attr: JavaTypeAttributes): JetType {
|
||||
private fun eraseInflexibleBasedOnClassDescriptor(type: KtType, declaration: ClassDescriptor, attr: JavaTypeAttributes): KtType {
|
||||
if (KotlinBuiltIns.isArray(type)) {
|
||||
val componentTypeProjection = type.arguments[0]
|
||||
val arguments = listOf(
|
||||
TypeProjectionImpl(componentTypeProjection.projectionKind, eraseType(componentTypeProjection.type))
|
||||
)
|
||||
return JetTypeImpl.create(
|
||||
return KtTypeImpl.create(
|
||||
type.annotations, type.constructor, type.isMarkedNullable, arguments,
|
||||
(type.constructor.declarationDescriptor as ClassDescriptor).getMemberScope(arguments)
|
||||
)
|
||||
}
|
||||
|
||||
val constructor = type.constructor
|
||||
return JetTypeImpl.create(
|
||||
return KtTypeImpl.create(
|
||||
type.annotations, constructor, type.isMarkedNullable,
|
||||
type.constructor.parameters.map {
|
||||
parameter ->
|
||||
@@ -130,7 +130,7 @@ internal object RawSubstitution : TypeSubstitution() {
|
||||
fun computeProjection(
|
||||
parameter: TypeParameterDescriptor,
|
||||
attr: JavaTypeAttributes,
|
||||
erasedUpperBound: JetType = parameter.getErasedUpperBound()
|
||||
erasedUpperBound: KtType = parameter.getErasedUpperBound()
|
||||
) = when (attr.flexibility) {
|
||||
// Raw(List<T>) => (List<Any?>..List<*>)
|
||||
// Raw(Enum<T>) => (Enum<Enum<*>>..Enum<out Enum<*>>)
|
||||
|
||||
+6
-6
@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.load.java.typeEnhacement
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
|
||||
import org.jetbrains.kotlin.load.java.descriptors.JavaCallableMemberDescriptor
|
||||
import org.jetbrains.kotlin.types.JetType
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
|
||||
public fun <D : CallableMemberDescriptor> enhanceSignatures(platformSignatures: Collection<D>): Collection<D> {
|
||||
return platformSignatures.map {
|
||||
@@ -51,17 +51,17 @@ public fun <D : CallableMemberDescriptor> D.enhanceSignature(): D {
|
||||
}
|
||||
|
||||
private class SignatureParts(
|
||||
val fromOverride: JetType,
|
||||
val fromOverridden: Collection<JetType>,
|
||||
val isCovariant: Boolean
|
||||
val fromOverride: KtType,
|
||||
val fromOverridden: Collection<KtType>,
|
||||
val isCovariant: Boolean
|
||||
) {
|
||||
fun enhance(): JetType {
|
||||
fun enhance(): KtType {
|
||||
val qualifiers = fromOverride.computeIndexedQualifiersForOverride(this.fromOverridden, isCovariant)
|
||||
return fromOverride.enhance(qualifiers)
|
||||
}
|
||||
}
|
||||
|
||||
private fun <D : CallableMemberDescriptor> D.parts(isCovariant: Boolean, collector: (D) -> JetType): SignatureParts {
|
||||
private fun <D : CallableMemberDescriptor> D.parts(isCovariant: Boolean, collector: (D) -> KtType): SignatureParts {
|
||||
return SignatureParts(
|
||||
collector(this),
|
||||
this.getOverriddenDescriptors().map {
|
||||
|
||||
+6
-6
@@ -37,7 +37,7 @@ import org.jetbrains.kotlin.utils.toReadOnlyList
|
||||
// Example: for `A<B, C<D, E>>`, indices go as follows: `0 - A<...>, 1 - B, 2 - C<D, E>, 3 - D, 4 - E`,
|
||||
// which corresponds to the left-to-right breadth-first walk of the tree representation of the type.
|
||||
// For flexible types, both bounds are indexed in the same way: `(A<B>..C<D>)` gives `0 - (A<B>..C<D>), 1 - B and D`.
|
||||
fun JetType.enhance(qualifiers: (Int) -> JavaTypeQualifiers) = this.enhancePossiblyFlexible(qualifiers, 0).type
|
||||
fun KtType.enhance(qualifiers: (Int) -> JavaTypeQualifiers) = this.enhancePossiblyFlexible(qualifiers, 0).type
|
||||
|
||||
|
||||
private enum class TypeComponentPosition {
|
||||
@@ -46,9 +46,9 @@ private enum class TypeComponentPosition {
|
||||
INFLEXIBLE
|
||||
}
|
||||
|
||||
private data class Result(val type: JetType, val subtreeSize: Int)
|
||||
private data class Result(val type: KtType, val subtreeSize: Int)
|
||||
|
||||
private fun JetType.enhancePossiblyFlexible(qualifiers: (Int) -> JavaTypeQualifiers, index: Int): Result {
|
||||
private fun KtType.enhancePossiblyFlexible(qualifiers: (Int) -> JavaTypeQualifiers, index: Int): Result {
|
||||
if (this.isError()) return Result(this, 1)
|
||||
return if (this.isFlexible()) {
|
||||
with(this.flexibility()) {
|
||||
@@ -67,7 +67,7 @@ private fun JetType.enhancePossiblyFlexible(qualifiers: (Int) -> JavaTypeQualifi
|
||||
else this.enhanceInflexible(qualifiers, index, TypeComponentPosition.INFLEXIBLE)
|
||||
}
|
||||
|
||||
private fun JetType.enhanceInflexible(qualifiers: (Int) -> JavaTypeQualifiers, index: Int, position: TypeComponentPosition): Result {
|
||||
private fun KtType.enhanceInflexible(qualifiers: (Int) -> JavaTypeQualifiers, index: Int, position: TypeComponentPosition): Result {
|
||||
val shouldEnhance = position.shouldEnhance()
|
||||
if (!shouldEnhance && getArguments().isEmpty()) return Result(this, 1)
|
||||
|
||||
@@ -104,7 +104,7 @@ private fun JetType.enhanceInflexible(qualifiers: (Int) -> JavaTypeQualifiers, i
|
||||
typeConstructor.parameters, enhancedArguments
|
||||
)
|
||||
|
||||
val enhancedType = JetTypeImpl.create(
|
||||
val enhancedType = KtTypeImpl.create(
|
||||
newAnnotations,
|
||||
typeConstructor,
|
||||
enhancedNullability,
|
||||
@@ -153,7 +153,7 @@ private fun ClassifierDescriptor.enhanceMutability(qualifiers: JavaTypeQualifier
|
||||
return this.noChange()
|
||||
}
|
||||
|
||||
private fun JetType.getEnhancedNullability(qualifiers: JavaTypeQualifiers, position: TypeComponentPosition): EnhancementResult<Boolean> {
|
||||
private fun KtType.getEnhancedNullability(qualifiers: JavaTypeQualifiers, position: TypeComponentPosition): EnhancementResult<Boolean> {
|
||||
if (!position.shouldEnhance()) return this.isMarkedNullable().noChange()
|
||||
|
||||
return when (qualifiers.nullability) {
|
||||
|
||||
+9
-9
@@ -24,8 +24,8 @@ import org.jetbrains.kotlin.load.java.typeEnhacement.NullabilityQualifier.NOT_NU
|
||||
import org.jetbrains.kotlin.load.java.typeEnhacement.NullabilityQualifier.NULLABLE
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.platform.JavaToKotlinClassMap
|
||||
import org.jetbrains.kotlin.types.JetType
|
||||
import org.jetbrains.kotlin.types.checker.JetTypeChecker
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
|
||||
import org.jetbrains.kotlin.types.flexibility
|
||||
import org.jetbrains.kotlin.types.isFlexible
|
||||
import java.util.ArrayList
|
||||
@@ -65,7 +65,7 @@ class JavaTypeQualifiers(
|
||||
}
|
||||
}
|
||||
|
||||
private fun JetType.extractQualifiers(): JavaTypeQualifiers {
|
||||
private fun KtType.extractQualifiers(): JavaTypeQualifiers {
|
||||
val (lower, upper) =
|
||||
if (this.isFlexible())
|
||||
flexibility().let { Pair(it.lowerBound, it.upperBound) }
|
||||
@@ -88,11 +88,11 @@ private fun Annotations.extractQualifiers(): JavaTypeQualifiers {
|
||||
)
|
||||
}
|
||||
|
||||
fun JetType.computeIndexedQualifiersForOverride(fromSupertypes: Collection<JetType>, isCovariant: Boolean): (Int) -> JavaTypeQualifiers {
|
||||
fun JetType.toIndexed(): List<JetType> {
|
||||
val list = ArrayList<JetType>(1)
|
||||
fun KtType.computeIndexedQualifiersForOverride(fromSupertypes: Collection<KtType>, isCovariant: Boolean): (Int) -> JavaTypeQualifiers {
|
||||
fun KtType.toIndexed(): List<KtType> {
|
||||
val list = ArrayList<KtType>(1)
|
||||
|
||||
fun add(type: JetType) {
|
||||
fun add(type: KtType) {
|
||||
list.add(type)
|
||||
for (arg in type.getArguments()) {
|
||||
if (arg.isStarProjection()) {
|
||||
@@ -116,7 +116,7 @@ fun JetType.computeIndexedQualifiersForOverride(fromSupertypes: Collection<JetTy
|
||||
// (outermost type), unless the type in the subclass is interchangeable with the all the types in superclasses:
|
||||
// e.g. we have (Mutable)List<String!>! in the subclass and { List<String!>, (Mutable)List<String>! } from superclasses
|
||||
// Note that `this` is flexible here, so it's equal to it's bounds
|
||||
val onlyHeadTypeConstructor = isCovariant && fromSupertypes.any { !JetTypeChecker.DEFAULT.equalTypes(it, this) }
|
||||
val onlyHeadTypeConstructor = isCovariant && fromSupertypes.any { !KotlinTypeChecker.DEFAULT.equalTypes(it, this) }
|
||||
|
||||
val treeSize = if (onlyHeadTypeConstructor) 1 else indexedThisType.size()
|
||||
val computedResult = Array(treeSize) {
|
||||
@@ -134,7 +134,7 @@ fun JetType.computeIndexedQualifiersForOverride(fromSupertypes: Collection<JetTy
|
||||
return { index -> computedResult.getOrElse(index) { JavaTypeQualifiers.NONE } }
|
||||
}
|
||||
|
||||
private fun JetType.computeQualifiersForOverride(fromSupertypes: Collection<JetType>, isCovariant: Boolean): JavaTypeQualifiers {
|
||||
private fun KtType.computeQualifiersForOverride(fromSupertypes: Collection<KtType>, isCovariant: Boolean): JavaTypeQualifiers {
|
||||
val nullabilityFromSupertypes = fromSupertypes.map { it.extractQualifiers().nullability }.filterNotNull().toSet()
|
||||
val mutabilityFromSupertypes = fromSupertypes.map { it.extractQualifiers().mutability }.filterNotNull().toSet()
|
||||
val own = getAnnotations().extractQualifiers()
|
||||
|
||||
+2
-2
@@ -30,7 +30,7 @@ import org.jetbrains.kotlin.serialization.jvm.JvmProtoBuf.propertyImplClassName
|
||||
import org.jetbrains.kotlin.serialization.jvm.JvmProtoBuf.propertySignature
|
||||
import org.jetbrains.kotlin.serialization.jvm.JvmProtoBufUtil
|
||||
import org.jetbrains.kotlin.storage.StorageManager
|
||||
import org.jetbrains.kotlin.types.JetType
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import java.util.*
|
||||
|
||||
public abstract class AbstractBinaryClassAnnotationAndConstantLoader<A : Any, C : Any, T : Any>(
|
||||
@@ -170,7 +170,7 @@ public abstract class AbstractBinaryClassAnnotationAndConstantLoader<A : Any, C
|
||||
return typeParameter.getExtension(JvmProtoBuf.typeParameterAnnotation).map { loadTypeAnnotation(it, nameResolver) }
|
||||
}
|
||||
|
||||
override fun loadPropertyConstant(container: ProtoContainer, proto: ProtoBuf.Property, expectedType: JetType): C? {
|
||||
override fun loadPropertyConstant(container: ProtoContainer, proto: ProtoBuf.Property, expectedType: KtType): C? {
|
||||
val nameResolver = container.nameResolver
|
||||
val signature = getCallableSignature(proto, nameResolver, container.typeTable, AnnotatedCallableKind.PROPERTY) ?: return null
|
||||
|
||||
|
||||
+7
-7
@@ -27,11 +27,11 @@ import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.platform.JavaToKotlinClassMap
|
||||
import org.jetbrains.kotlin.platform.JvmBuiltIns
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.KtScope
|
||||
import org.jetbrains.kotlin.serialization.deserialization.AdditionalSupertypes
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedClassDescriptor
|
||||
import org.jetbrains.kotlin.types.DelegatingType
|
||||
import org.jetbrains.kotlin.types.JetType
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import java.io.Serializable
|
||||
|
||||
class BuiltInClassesAreSerializableOnJvm(
|
||||
@@ -40,14 +40,14 @@ class BuiltInClassesAreSerializableOnJvm(
|
||||
|
||||
private val mockSerializableType = createMockJavaIoSerializableType()
|
||||
|
||||
private fun createMockJavaIoSerializableType(): JetType {
|
||||
private fun createMockJavaIoSerializableType(): KtType {
|
||||
val mockJavaIoPackageFragment = object : PackageFragmentDescriptorImpl(moduleDescriptor, FqName("java.io")) {
|
||||
override fun getMemberScope() = JetScope.Empty
|
||||
override fun getMemberScope() = KtScope.Empty
|
||||
}
|
||||
|
||||
//NOTE: can't reference anyType right away, because this is sometimes called when JvmBuiltIns are initializing
|
||||
val superTypes = listOf(object : DelegatingType() {
|
||||
override fun getDelegate(): JetType {
|
||||
override fun getDelegate(): KtType {
|
||||
return JvmBuiltIns.Instance.anyType
|
||||
}
|
||||
})
|
||||
@@ -56,11 +56,11 @@ class BuiltInClassesAreSerializableOnJvm(
|
||||
mockJavaIoPackageFragment, Name.identifier("Serializable"), Modality.ABSTRACT, superTypes, SourceElement.NO_SOURCE
|
||||
)
|
||||
|
||||
mockSerializableClass.initialize(JetScope.Empty, emptySet(), null)
|
||||
mockSerializableClass.initialize(KtScope.Empty, emptySet(), null)
|
||||
return mockSerializableClass.defaultType
|
||||
}
|
||||
|
||||
override fun forClass(classDescriptor: DeserializedClassDescriptor): Collection<JetType> {
|
||||
override fun forClass(classDescriptor: DeserializedClassDescriptor): Collection<KtType> {
|
||||
if (isSerializableInJava(classDescriptor.fqNameSafe)) {
|
||||
return listOf(mockSerializableType)
|
||||
}
|
||||
|
||||
+7
-7
@@ -24,7 +24,7 @@ import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor;
|
||||
import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.resolve.scopes.ChainedScope;
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope;
|
||||
import org.jetbrains.kotlin.resolve.scopes.KtScope;
|
||||
import org.jetbrains.kotlin.serialization.ClassData;
|
||||
import org.jetbrains.kotlin.serialization.ClassDataWithSource;
|
||||
import org.jetbrains.kotlin.serialization.PackageData;
|
||||
@@ -74,7 +74,7 @@ public final class DeserializedDescriptorResolver {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public JetScope createKotlinPackagePartScope(@NotNull PackageFragmentDescriptor descriptor, @NotNull KotlinJvmBinaryClass kotlinClass) {
|
||||
public KtScope createKotlinPackagePartScope(@NotNull PackageFragmentDescriptor descriptor, @NotNull KotlinJvmBinaryClass kotlinClass) {
|
||||
String[] data = readData(kotlinClass, KOTLIN_FILE_FACADE_OR_MULTIFILE_CLASS_PART);
|
||||
if (data != null) {
|
||||
String[] strings = kotlinClass.getClassHeader().getStrings();
|
||||
@@ -95,18 +95,18 @@ public final class DeserializedDescriptorResolver {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JetScope createKotlinPackageScope(@NotNull PackageFragmentDescriptor descriptor, @NotNull List<KotlinJvmBinaryClass> packageParts) {
|
||||
List<JetScope> list = new ArrayList<JetScope>();
|
||||
public KtScope createKotlinPackageScope(@NotNull PackageFragmentDescriptor descriptor, @NotNull List<KotlinJvmBinaryClass> packageParts) {
|
||||
List<KtScope> list = new ArrayList<KtScope>();
|
||||
for (KotlinJvmBinaryClass callable : packageParts) {
|
||||
JetScope scope = createKotlinPackagePartScope(descriptor, callable);
|
||||
KtScope scope = createKotlinPackagePartScope(descriptor, callable);
|
||||
if (scope != null) {
|
||||
list.add(scope);
|
||||
}
|
||||
}
|
||||
if (list.isEmpty()) {
|
||||
return JetScope.Empty.INSTANCE$;
|
||||
return KtScope.Empty.INSTANCE$;
|
||||
}
|
||||
return new ChainedScope(descriptor, "Member scope for union of package parts data", list.toArray(new JetScope[list.size()]));
|
||||
return new ChainedScope(descriptor, "Member scope for union of package parts data", list.toArray(new KtScope[list.size()]));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
+3
-3
@@ -28,7 +28,7 @@ import org.jetbrains.kotlin.name.FqNameUnsafe;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
||||
import org.jetbrains.kotlin.resolve.jvm.JvmPrimitiveType;
|
||||
import org.jetbrains.kotlin.types.JetType;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.TypeUtils;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
@@ -184,7 +184,7 @@ public class JavaToKotlinClassMap implements PlatformToKotlinClassMap {
|
||||
return mutableToReadOnly.containsKey(mutable);
|
||||
}
|
||||
|
||||
public boolean isMutable(@NotNull JetType type) {
|
||||
public boolean isMutable(@NotNull KtType type) {
|
||||
ClassDescriptor classDescriptor = TypeUtils.getClassDescriptor(type);
|
||||
return classDescriptor != null && isMutable(classDescriptor);
|
||||
}
|
||||
@@ -193,7 +193,7 @@ public class JavaToKotlinClassMap implements PlatformToKotlinClassMap {
|
||||
return readOnlyToMutable.containsKey(readOnly);
|
||||
}
|
||||
|
||||
public boolean isReadOnly(@NotNull JetType type) {
|
||||
public boolean isReadOnly(@NotNull KtType type) {
|
||||
ClassDescriptor classDescriptor = TypeUtils.getClassDescriptor(type);
|
||||
return classDescriptor != null && isReadOnly(classDescriptor);
|
||||
}
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.resolve.jvm
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.load.java.structure.*
|
||||
import org.jetbrains.kotlin.load.java.lazy.LazyJavaPackageFragmentProvider
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.KtScope
|
||||
import org.jetbrains.kotlin.load.java.sources.JavaSourceElement
|
||||
|
||||
public var PLATFORM_TYPES: Boolean = true
|
||||
|
||||
Reference in New Issue
Block a user