rename Kt to Kotlin in KtType, KtIcons
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.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
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 KtType returnType,
|
||||
@Nullable KtType receiverType,
|
||||
@NotNull KotlinType returnType,
|
||||
@Nullable KotlinType 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 KtType returnType,
|
||||
@Nullable KtType receiverType,
|
||||
@Nullable KotlinType returnType,
|
||||
@Nullable KotlinType 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 KtType returnType, boolean isVar
|
||||
@NotNull JavaField field, @NotNull KotlinType returnType, boolean isVar
|
||||
) {
|
||||
return new AlternativeFieldSignature(returnType, null);
|
||||
}
|
||||
@@ -89,15 +89,15 @@ public interface ExternalSignatureResolver {
|
||||
}
|
||||
|
||||
class AlternativeMethodSignature extends MemberSignature {
|
||||
private final KtType returnType;
|
||||
private final KtType receiverType;
|
||||
private final KotlinType returnType;
|
||||
private final KotlinType receiverType;
|
||||
private final List<ValueParameterDescriptor> valueParameters;
|
||||
private final List<TypeParameterDescriptor> typeParameters;
|
||||
private final boolean hasStableParameterNames;
|
||||
|
||||
public AlternativeMethodSignature(
|
||||
@Nullable KtType returnType,
|
||||
@Nullable KtType receiverType,
|
||||
@Nullable KotlinType returnType,
|
||||
@Nullable KotlinType receiverType,
|
||||
@NotNull List<ValueParameterDescriptor> valueParameters,
|
||||
@NotNull List<TypeParameterDescriptor> typeParameters,
|
||||
@NotNull List<String> signatureErrors,
|
||||
@@ -112,12 +112,12 @@ public interface ExternalSignatureResolver {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public KtType getReturnType() {
|
||||
public KotlinType getReturnType() {
|
||||
return returnType;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public KtType getReceiverType() {
|
||||
public KotlinType getReceiverType() {
|
||||
return receiverType;
|
||||
}
|
||||
|
||||
@@ -137,15 +137,15 @@ public interface ExternalSignatureResolver {
|
||||
}
|
||||
|
||||
class AlternativeFieldSignature extends MemberSignature {
|
||||
private final KtType returnType;
|
||||
private final KotlinType returnType;
|
||||
|
||||
public AlternativeFieldSignature(@NotNull KtType returnType, @Nullable String signatureError) {
|
||||
public AlternativeFieldSignature(@NotNull KotlinType returnType, @Nullable String signatureError) {
|
||||
super(signatureError == null ? Collections.<String>emptyList() : Collections.singletonList(signatureError));
|
||||
this.returnType = returnType;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public KtType getReturnType() {
|
||||
public KotlinType getReturnType() {
|
||||
return returnType;
|
||||
}
|
||||
}
|
||||
@@ -154,8 +154,8 @@ public interface ExternalSignatureResolver {
|
||||
private final List<FunctionDescriptor> superMethods;
|
||||
|
||||
public PropagatedMethodSignature(
|
||||
@Nullable KtType returnType,
|
||||
@Nullable KtType receiverType,
|
||||
@Nullable KotlinType returnType,
|
||||
@Nullable KotlinType 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 KtType returnType,
|
||||
@Nullable KtType receiverType,
|
||||
@NotNull KotlinType returnType,
|
||||
@Nullable KotlinType receiverType,
|
||||
@NotNull List<ValueParameterDescriptor> valueParameters,
|
||||
@NotNull List<TypeParameterDescriptor> typeParameters
|
||||
);
|
||||
@@ -186,8 +186,8 @@ public interface ExternalSignatureResolver {
|
||||
AlternativeMethodSignature resolveAlternativeMethodSignature(
|
||||
@NotNull JavaMember methodOrConstructor,
|
||||
boolean hasSuperMethods,
|
||||
@Nullable KtType returnType,
|
||||
@Nullable KtType receiverType,
|
||||
@Nullable KotlinType returnType,
|
||||
@Nullable KotlinType 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 KtType returnType,
|
||||
@NotNull KotlinType returnType,
|
||||
boolean isVar
|
||||
);
|
||||
|
||||
|
||||
+3
-3
@@ -22,7 +22,7 @@ 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.KtScope
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
public interface SamConversionResolver {
|
||||
public companion object EMPTY : SamConversionResolver {
|
||||
@@ -30,7 +30,7 @@ public interface SamConversionResolver {
|
||||
override fun resolveSamConstructor(name: Name, scope: KtScope) = null
|
||||
override fun resolveFunctionTypeIfSamInterface(
|
||||
classDescriptor: JavaClassDescriptor, resolveMethod: (JavaMethod) -> FunctionDescriptor
|
||||
): KtType? = null
|
||||
): KotlinType? = null
|
||||
}
|
||||
|
||||
public fun resolveSamConstructor(name: Name, scope: KtScope): SamConstructorDescriptor?
|
||||
@@ -40,5 +40,5 @@ public interface SamConversionResolver {
|
||||
public fun resolveFunctionTypeIfSamInterface(
|
||||
classDescriptor: JavaClassDescriptor,
|
||||
resolveMethod: (JavaMethod) -> FunctionDescriptor
|
||||
): KtType?
|
||||
): KotlinType?
|
||||
}
|
||||
|
||||
+4
-4
@@ -19,15 +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.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface JavaCallableMemberDescriptor extends CallableMemberDescriptor {
|
||||
@NotNull
|
||||
JavaCallableMemberDescriptor enhance(
|
||||
@Nullable KtType enhancedReceiverType,
|
||||
@NotNull List<KtType> enhancedValueParametersTypes,
|
||||
@NotNull KtType enhancedReturnType
|
||||
@Nullable KotlinType enhancedReceiverType,
|
||||
@NotNull List<KotlinType> enhancedValueParametersTypes,
|
||||
@NotNull KotlinType 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.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
public interface JavaClassDescriptor extends ClassDescriptor {
|
||||
@Nullable
|
||||
KtType getFunctionTypeForSamInterface();
|
||||
KotlinType 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.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -96,9 +96,9 @@ public class JavaConstructorDescriptor extends ConstructorDescriptorImpl impleme
|
||||
@Override
|
||||
@NotNull
|
||||
public JavaConstructorDescriptor enhance(
|
||||
@Nullable KtType enhancedReceiverType,
|
||||
@NotNull List<KtType> enhancedValueParametersTypes,
|
||||
@NotNull KtType enhancedReturnType
|
||||
@Nullable KotlinType enhancedReceiverType,
|
||||
@NotNull List<KotlinType> enhancedValueParametersTypes,
|
||||
@NotNull KotlinType 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.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
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 KtType receiverParameterType,
|
||||
@Nullable KotlinType receiverParameterType,
|
||||
@Nullable ReceiverParameterDescriptor dispatchReceiverParameter,
|
||||
@NotNull List<? extends TypeParameterDescriptor> typeParameters,
|
||||
@NotNull List<ValueParameterDescriptor> unsubstitutedValueParameters,
|
||||
@Nullable KtType unsubstitutedReturnType,
|
||||
@Nullable KotlinType unsubstitutedReturnType,
|
||||
@Nullable Modality modality,
|
||||
@NotNull Visibility visibility
|
||||
) {
|
||||
@@ -130,9 +130,9 @@ public class JavaMethodDescriptor extends SimpleFunctionDescriptorImpl implement
|
||||
@Override
|
||||
@NotNull
|
||||
public JavaMethodDescriptor enhance(
|
||||
@Nullable KtType enhancedReceiverType,
|
||||
@NotNull List<KtType> enhancedValueParametersTypes,
|
||||
@NotNull KtType enhancedReturnType
|
||||
@Nullable KotlinType enhancedReceiverType,
|
||||
@NotNull List<KotlinType> enhancedValueParametersTypes,
|
||||
@NotNull KotlinType 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.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -55,9 +55,9 @@ public class JavaPropertyDescriptor extends PropertyDescriptorImpl implements Ja
|
||||
@NotNull
|
||||
@Override
|
||||
public JavaCallableMemberDescriptor enhance(
|
||||
@Nullable KtType enhancedReceiverType,
|
||||
@NotNull List<KtType> enhancedValueParametersTypes,
|
||||
@NotNull KtType enhancedReturnType
|
||||
@Nullable KotlinType enhancedReceiverType,
|
||||
@NotNull List<KotlinType> enhancedValueParametersTypes,
|
||||
@NotNull KotlinType 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.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
fun copyValueParameters(
|
||||
newValueParametersTypes: Collection<KtType>,
|
||||
newValueParametersTypes: Collection<KotlinType>,
|
||||
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(): KtType = type()
|
||||
override fun getType(): KotlinType = type()
|
||||
|
||||
private val allValueArguments = c.storageManager.createLazyValue {
|
||||
computeValueArguments()
|
||||
|
||||
+7
-7
@@ -102,7 +102,7 @@ class LazyJavaClassDescriptor(
|
||||
}
|
||||
}
|
||||
|
||||
override fun getFunctionTypeForSamInterface(): KtType? = functionTypeForSamInterface()
|
||||
override fun getFunctionTypeForSamInterface(): KotlinType? = functionTypeForSamInterface()
|
||||
|
||||
override fun isCompanionObject() = false
|
||||
|
||||
@@ -120,12 +120,12 @@ class LazyJavaClassDescriptor(
|
||||
|
||||
override fun getParameters(): List<TypeParameterDescriptor> = parameters()
|
||||
|
||||
private val supertypes = c.storageManager.createLazyValue<Collection<KtType>> {
|
||||
private val supertypes = c.storageManager.createLazyValue<Collection<KotlinType>> {
|
||||
val javaTypes = jClass.getSupertypes()
|
||||
val result = ArrayList<KtType>(javaTypes.size())
|
||||
val result = ArrayList<KotlinType>(javaTypes.size())
|
||||
val incomplete = ArrayList<JavaType>(0)
|
||||
|
||||
val purelyImplementedSupertype: KtType? = getPurelyImplementedSupertype()
|
||||
val purelyImplementedSupertype: KotlinType? = 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(): KtType? {
|
||||
private fun getPurelyImplementedSupertype(): KotlinType? {
|
||||
val purelyImplementedFqName = getPurelyImplementsFqNameFromAnnotation()
|
||||
?: FakePureImplementationsProvider.getPurelyImplementedInterface(fqName)
|
||||
?: return null
|
||||
@@ -169,7 +169,7 @@ class LazyJavaClassDescriptor(
|
||||
parameter -> TypeProjectionImpl(Variance.INVARIANT, parameter.getDefaultType())
|
||||
}
|
||||
|
||||
return KtTypeImpl.create(
|
||||
return KotlinTypeImpl.create(
|
||||
Annotations.EMPTY, classDescriptor,
|
||||
/* nullable =*/ false, parametersAsTypeProjections
|
||||
)
|
||||
@@ -186,7 +186,7 @@ class LazyJavaClassDescriptor(
|
||||
return FqName(fqNameString)
|
||||
}
|
||||
|
||||
override fun getSupertypes(): Collection<KtType> = supertypes()
|
||||
override fun getSupertypes(): Collection<KotlinType> = supertypes()
|
||||
|
||||
override fun getAnnotations() = Annotations.EMPTY
|
||||
|
||||
|
||||
+8
-8
@@ -52,7 +52,7 @@ 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.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
|
||||
import org.jetbrains.kotlin.utils.*
|
||||
@@ -263,7 +263,7 @@ public class LazyJavaClassMemberScope(
|
||||
}
|
||||
|
||||
private fun createPropertyDescriptorWithDefaultGetter(
|
||||
method: JavaMethod, givenType: KtType? = null, modality: Modality
|
||||
method: JavaMethod, givenType: KotlinType? = 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 KtType?)
|
||||
propertyDescriptor.setType(returnType, listOf(), getDispatchReceiverParameter(), null as KotlinType?)
|
||||
getter.initialize(returnType)
|
||||
|
||||
return propertyDescriptor
|
||||
@@ -302,7 +302,7 @@ public class LazyJavaClassMemberScope(
|
||||
/* isStaticFinal = */ false
|
||||
)
|
||||
|
||||
propertyDescriptor.setType(getterMethod.returnType!!, listOf(), getDispatchReceiverParameter(), null as KtType?)
|
||||
propertyDescriptor.setType(getterMethod.returnType!!, listOf(), getDispatchReceiverParameter(), null as KotlinType?)
|
||||
|
||||
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: KtType,
|
||||
method: JavaMethod, methodTypeParameters: List<TypeParameterDescriptor>, returnType: KotlinType,
|
||||
valueParameters: LazyJavaScope.ResolvedValueParameters
|
||||
): LazyJavaScope.MethodSignatureData {
|
||||
val propagated = c.components.externalSignatureResolver.resolvePropagatedSignature(
|
||||
@@ -410,7 +410,7 @@ public class LazyJavaClassMemberScope(
|
||||
} && returnType.isSubtypeOf(builtinWithErasedParameters.returnType)
|
||||
}
|
||||
|
||||
private fun KtType?.isSubtypeOf(other: KtType?): Boolean {
|
||||
private fun KotlinType?.isSubtypeOf(other: KotlinType?): Boolean {
|
||||
return KotlinTypeChecker.DEFAULT.isSubtypeOf(this ?: return false, other ?: return false)
|
||||
}
|
||||
|
||||
@@ -510,8 +510,8 @@ public class LazyJavaClassMemberScope(
|
||||
constructor: ConstructorDescriptor,
|
||||
index: Int,
|
||||
method: JavaMethod,
|
||||
returnType: KtType,
|
||||
varargElementType: KtType?
|
||||
returnType: KotlinType,
|
||||
varargElementType: KotlinType?
|
||||
) {
|
||||
add(ValueParameterDescriptorImpl(
|
||||
constructor,
|
||||
|
||||
+5
-5
@@ -43,7 +43,7 @@ import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||
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.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
import org.jetbrains.kotlin.utils.Printer
|
||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
@@ -106,7 +106,7 @@ public abstract class LazyJavaScope(
|
||||
protected abstract fun resolveMethodSignature(
|
||||
method: JavaMethod,
|
||||
methodTypeParameters: List<TypeParameterDescriptor>,
|
||||
returnType: KtType,
|
||||
returnType: KotlinType,
|
||||
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): KtType {
|
||||
protected fun computeMethodReturnType(method: JavaMethod, annotations: Annotations, c: LazyJavaResolverContext): KotlinType {
|
||||
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 KtType?)
|
||||
propertyDescriptor.setType(effectiveSignature.getReturnType(), listOf(), getDispatchReceiverParameter(), null as KotlinType?)
|
||||
|
||||
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): KtType {
|
||||
private fun getPropertyType(field: JavaField, annotations: Annotations): KotlinType {
|
||||
// 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.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
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: KtType): Iterable<PropertyDescriptor> {
|
||||
fun getStaticProperties(supertype: KotlinType): 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.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
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: KtType,
|
||||
method: JavaMethod, methodTypeParameters: List<TypeParameterDescriptor>, returnType: KotlinType,
|
||||
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.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
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<KtType> {
|
||||
override fun resolveUpperBounds(): Set<KotlinType> {
|
||||
val bounds = javaTypeParameter.getUpperBounds()
|
||||
if (bounds.isEmpty()) {
|
||||
return setOf(LazyJavaTypeResolver.FlexibleJavaClassifierTypeCapabilities.create(
|
||||
|
||||
+14
-14
@@ -52,7 +52,7 @@ class LazyJavaTypeResolver(
|
||||
private val typeParameterResolver: TypeParameterResolver
|
||||
) {
|
||||
|
||||
public fun transformJavaType(javaType: JavaType, attr: JavaTypeAttributes): KtType {
|
||||
public fun transformJavaType(javaType: JavaType, attr: JavaTypeAttributes): KotlinType {
|
||||
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): KtType {
|
||||
public fun transformArrayType(arrayType: JavaArrayType, attr: JavaTypeAttributes, isVararg: Boolean = false): KotlinType {
|
||||
return run {
|
||||
val javaComponentType = arrayType.getComponentType()
|
||||
val primitiveType = (javaComponentType as? JavaPrimitiveType)?.getType()
|
||||
@@ -169,10 +169,10 @@ 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(): KtType {
|
||||
private fun getConstructorTypeParameterSubstitute(): KotlinType {
|
||||
// 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<KtType>()
|
||||
val supertypesJet = HashSet<KotlinType>()
|
||||
for (supertype in (classifier() as JavaTypeParameter).getUpperBounds()) {
|
||||
supertypesJet.add(transformJavaType(supertype, UPPER_BOUND.toAttributes()))
|
||||
}
|
||||
@@ -290,11 +290,11 @@ class LazyJavaTypeResolver(
|
||||
|
||||
public object FlexibleJavaClassifierTypeCapabilities : FlexibleTypeCapabilities {
|
||||
@JvmStatic
|
||||
fun create(lowerBound: KtType, upperBound: KtType) = DelegatingFlexibleType.create(lowerBound, upperBound, this)
|
||||
fun create(lowerBound: KotlinType, upperBound: KotlinType) = DelegatingFlexibleType.create(lowerBound, upperBound, this)
|
||||
|
||||
override val id: String get() = "kotlin.jvm.PlatformType"
|
||||
|
||||
override fun <T : TypeCapability> getCapability(capabilityClass: Class<T>, jetType: KtType, flexibility: Flexibility): T? {
|
||||
override fun <T : TypeCapability> getCapability(capabilityClass: Class<T>, jetType: KotlinType, 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: KtType get() = flexibility.lowerBound
|
||||
private val upperBound: KtType get() = flexibility.upperBound
|
||||
private val lowerBound: KotlinType get() = flexibility.lowerBound
|
||||
private val upperBound: KotlinType 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: KtType): KtType {
|
||||
override fun substitutionResult(replacement: KotlinType): KotlinType {
|
||||
return if (replacement.isFlexible()) replacement
|
||||
else create(replacement, TypeUtils.makeNullable(replacement))
|
||||
}
|
||||
|
||||
override fun getSpecificityRelationTo(otherType: KtType): Specificity.Relation {
|
||||
override fun getSpecificityRelationTo(otherType: KotlinType): 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: (() -> KtType) = { ErrorUtils.createErrorType("Can't compute erased upper bound of type parameter `$this`") }
|
||||
): KtType {
|
||||
defaultValue: (() -> KotlinType) = { ErrorUtils.createErrorType("Can't compute erased upper bound of type parameter `$this`") }
|
||||
): KotlinType {
|
||||
if (this === potentiallyRecursiveTypeParameter) return defaultValue()
|
||||
|
||||
val firstUpperBound = upperBounds.first()
|
||||
@@ -450,7 +450,7 @@ internal fun TypeParameterDescriptor.getErasedUpperBound(
|
||||
return defaultValue()
|
||||
}
|
||||
|
||||
private fun KtType.replaceArgumentsWithStarProjections(): KtType {
|
||||
private fun KotlinType.replaceArgumentsWithStarProjections(): KotlinType {
|
||||
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 KtType.replaceArgumentsWithStarProjections(): KtType {
|
||||
}
|
||||
|
||||
private object ConstantStarSubstitution : TypeSubstitution() {
|
||||
override fun get(key: KtType): TypeProjection? {
|
||||
override fun get(key: KotlinType): 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: KtType) = jetType.arguments.map { renderTypeProjection(it) }
|
||||
private fun DescriptorRenderer.renderArguments(jetType: KotlinType) = jetType.arguments.map { renderTypeProjection(it) }
|
||||
|
||||
private fun String.replaceArgs(newArgs: String): String {
|
||||
if (!contains('<')) return this
|
||||
return "${substringBefore('<')}<$newArgs>${substringAfterLast('>')}"
|
||||
}
|
||||
|
||||
override fun renderInflexible(type: KtType, renderer: DescriptorRenderer): String? {
|
||||
override fun renderInflexible(type: KotlinType, 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: KtType) = TypeProjectionImpl(eraseType(key))
|
||||
override fun get(key: KotlinType) = 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: KtType): KtType {
|
||||
public fun eraseType(type: KotlinType): KotlinType {
|
||||
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: KtType, declaration: ClassDescriptor, attr: JavaTypeAttributes): KtType {
|
||||
private fun eraseInflexibleBasedOnClassDescriptor(type: KotlinType, declaration: ClassDescriptor, attr: JavaTypeAttributes): KotlinType {
|
||||
if (KotlinBuiltIns.isArray(type)) {
|
||||
val componentTypeProjection = type.arguments[0]
|
||||
val arguments = listOf(
|
||||
TypeProjectionImpl(componentTypeProjection.projectionKind, eraseType(componentTypeProjection.type))
|
||||
)
|
||||
return KtTypeImpl.create(
|
||||
return KotlinTypeImpl.create(
|
||||
type.annotations, type.constructor, type.isMarkedNullable, arguments,
|
||||
(type.constructor.declarationDescriptor as ClassDescriptor).getMemberScope(arguments)
|
||||
)
|
||||
}
|
||||
|
||||
val constructor = type.constructor
|
||||
return KtTypeImpl.create(
|
||||
return KotlinTypeImpl.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: KtType = parameter.getErasedUpperBound()
|
||||
erasedUpperBound: KotlinType = parameter.getErasedUpperBound()
|
||||
) = when (attr.flexibility) {
|
||||
// Raw(List<T>) => (List<Any?>..List<*>)
|
||||
// Raw(Enum<T>) => (Enum<Enum<*>>..Enum<out Enum<*>>)
|
||||
|
||||
+5
-5
@@ -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.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
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: KtType,
|
||||
val fromOverridden: Collection<KtType>,
|
||||
val fromOverride: KotlinType,
|
||||
val fromOverridden: Collection<KotlinType>,
|
||||
val isCovariant: Boolean
|
||||
) {
|
||||
fun enhance(): KtType {
|
||||
fun enhance(): KotlinType {
|
||||
val qualifiers = fromOverride.computeIndexedQualifiersForOverride(this.fromOverridden, isCovariant)
|
||||
return fromOverride.enhance(qualifiers)
|
||||
}
|
||||
}
|
||||
|
||||
private fun <D : CallableMemberDescriptor> D.parts(isCovariant: Boolean, collector: (D) -> KtType): SignatureParts {
|
||||
private fun <D : CallableMemberDescriptor> D.parts(isCovariant: Boolean, collector: (D) -> KotlinType): 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 KtType.enhance(qualifiers: (Int) -> JavaTypeQualifiers) = this.enhancePossiblyFlexible(qualifiers, 0).type
|
||||
fun KotlinType.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: KtType, val subtreeSize: Int)
|
||||
private data class Result(val type: KotlinType, val subtreeSize: Int)
|
||||
|
||||
private fun KtType.enhancePossiblyFlexible(qualifiers: (Int) -> JavaTypeQualifiers, index: Int): Result {
|
||||
private fun KotlinType.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 KtType.enhancePossiblyFlexible(qualifiers: (Int) -> JavaTypeQualifie
|
||||
else this.enhanceInflexible(qualifiers, index, TypeComponentPosition.INFLEXIBLE)
|
||||
}
|
||||
|
||||
private fun KtType.enhanceInflexible(qualifiers: (Int) -> JavaTypeQualifiers, index: Int, position: TypeComponentPosition): Result {
|
||||
private fun KotlinType.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 KtType.enhanceInflexible(qualifiers: (Int) -> JavaTypeQualifiers, in
|
||||
typeConstructor.parameters, enhancedArguments
|
||||
)
|
||||
|
||||
val enhancedType = KtTypeImpl.create(
|
||||
val enhancedType = KotlinTypeImpl.create(
|
||||
newAnnotations,
|
||||
typeConstructor,
|
||||
enhancedNullability,
|
||||
@@ -153,7 +153,7 @@ private fun ClassifierDescriptor.enhanceMutability(qualifiers: JavaTypeQualifier
|
||||
return this.noChange()
|
||||
}
|
||||
|
||||
private fun KtType.getEnhancedNullability(qualifiers: JavaTypeQualifiers, position: TypeComponentPosition): EnhancementResult<Boolean> {
|
||||
private fun KotlinType.getEnhancedNullability(qualifiers: JavaTypeQualifiers, position: TypeComponentPosition): EnhancementResult<Boolean> {
|
||||
if (!position.shouldEnhance()) return this.isMarkedNullable().noChange()
|
||||
|
||||
return when (qualifiers.nullability) {
|
||||
|
||||
+7
-7
@@ -24,7 +24,7 @@ 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.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
|
||||
import org.jetbrains.kotlin.types.flexibility
|
||||
import org.jetbrains.kotlin.types.isFlexible
|
||||
@@ -65,7 +65,7 @@ class JavaTypeQualifiers(
|
||||
}
|
||||
}
|
||||
|
||||
private fun KtType.extractQualifiers(): JavaTypeQualifiers {
|
||||
private fun KotlinType.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 KtType.computeIndexedQualifiersForOverride(fromSupertypes: Collection<KtType>, isCovariant: Boolean): (Int) -> JavaTypeQualifiers {
|
||||
fun KtType.toIndexed(): List<KtType> {
|
||||
val list = ArrayList<KtType>(1)
|
||||
fun KotlinType.computeIndexedQualifiersForOverride(fromSupertypes: Collection<KotlinType>, isCovariant: Boolean): (Int) -> JavaTypeQualifiers {
|
||||
fun KotlinType.toIndexed(): List<KotlinType> {
|
||||
val list = ArrayList<KotlinType>(1)
|
||||
|
||||
fun add(type: KtType) {
|
||||
fun add(type: KotlinType) {
|
||||
list.add(type)
|
||||
for (arg in type.getArguments()) {
|
||||
if (arg.isStarProjection()) {
|
||||
@@ -134,7 +134,7 @@ fun KtType.computeIndexedQualifiersForOverride(fromSupertypes: Collection<KtType
|
||||
return { index -> computedResult.getOrElse(index) { JavaTypeQualifiers.NONE } }
|
||||
}
|
||||
|
||||
private fun KtType.computeQualifiersForOverride(fromSupertypes: Collection<KtType>, isCovariant: Boolean): JavaTypeQualifiers {
|
||||
private fun KotlinType.computeQualifiersForOverride(fromSupertypes: Collection<KotlinType>, 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.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
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: KtType): C? {
|
||||
override fun loadPropertyConstant(container: ProtoContainer, proto: ProtoBuf.Property, expectedType: KotlinType): C? {
|
||||
val nameResolver = container.nameResolver
|
||||
val signature = getCallableSignature(proto, nameResolver, container.typeTable, AnnotatedCallableKind.PROPERTY) ?: return null
|
||||
|
||||
|
||||
+4
-4
@@ -31,7 +31,7 @@ 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.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import java.io.Serializable
|
||||
|
||||
class BuiltInClassesAreSerializableOnJvm(
|
||||
@@ -40,14 +40,14 @@ class BuiltInClassesAreSerializableOnJvm(
|
||||
|
||||
private val mockSerializableType = createMockJavaIoSerializableType()
|
||||
|
||||
private fun createMockJavaIoSerializableType(): KtType {
|
||||
private fun createMockJavaIoSerializableType(): KotlinType {
|
||||
val mockJavaIoPackageFragment = object : PackageFragmentDescriptorImpl(moduleDescriptor, FqName("java.io")) {
|
||||
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(): KtType {
|
||||
override fun getDelegate(): KotlinType {
|
||||
return JvmBuiltIns.Instance.anyType
|
||||
}
|
||||
})
|
||||
@@ -60,7 +60,7 @@ class BuiltInClassesAreSerializableOnJvm(
|
||||
return mockSerializableClass.defaultType
|
||||
}
|
||||
|
||||
override fun forClass(classDescriptor: DeserializedClassDescriptor): Collection<KtType> {
|
||||
override fun forClass(classDescriptor: DeserializedClassDescriptor): Collection<KotlinType> {
|
||||
if (isSerializableInJava(classDescriptor.fqNameSafe)) {
|
||||
return listOf(mockSerializableType)
|
||||
}
|
||||
|
||||
+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.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
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 KtType type) {
|
||||
public boolean isMutable(@NotNull KotlinType 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 KtType type) {
|
||||
public boolean isReadOnly(@NotNull KotlinType type) {
|
||||
ClassDescriptor classDescriptor = TypeUtils.getClassDescriptor(type);
|
||||
return classDescriptor != null && isReadOnly(classDescriptor);
|
||||
}
|
||||
|
||||
+2
-2
@@ -24,7 +24,7 @@ import org.jetbrains.kotlin.resolve.constants.ConstantValue
|
||||
import org.jetbrains.kotlin.serialization.ProtoBuf
|
||||
import org.jetbrains.kotlin.serialization.builtins.BuiltInsProtoBuf
|
||||
import org.jetbrains.kotlin.serialization.deserialization.*
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
class BuiltInsAnnotationAndConstantLoader(
|
||||
module: ModuleDescriptor
|
||||
@@ -81,7 +81,7 @@ class BuiltInsAnnotationAndConstantLoader(
|
||||
override fun loadPropertyConstant(
|
||||
container: ProtoContainer,
|
||||
proto: ProtoBuf.Property,
|
||||
expectedType: KtType
|
||||
expectedType: KotlinType
|
||||
): ConstantValue<*>? {
|
||||
if (!proto.hasExtension(BuiltInsProtoBuf.compileTimeValue)) return null
|
||||
val value = proto.getExtension(BuiltInsProtoBuf.compileTimeValue)
|
||||
|
||||
@@ -61,9 +61,9 @@ public abstract class KotlinBuiltIns {
|
||||
private final BuiltinsPackageFragment builtinsPackageFragment;
|
||||
private final BuiltinsPackageFragment annotationPackageFragment;
|
||||
|
||||
private final Map<PrimitiveType, KtType> primitiveTypeToArrayJetType;
|
||||
private final Map<KtType, KtType> primitiveJetTypeToJetArrayType;
|
||||
private final Map<KtType, KtType> jetArrayTypeToPrimitiveJetType;
|
||||
private final Map<PrimitiveType, KotlinType> primitiveTypeToArrayJetType;
|
||||
private final Map<KotlinType, KotlinType> primitiveJetTypeToJetArrayType;
|
||||
private final Map<KotlinType, KotlinType> jetArrayTypeToPrimitiveJetType;
|
||||
|
||||
public static final FqNames FQ_NAMES = new FqNames();
|
||||
|
||||
@@ -91,9 +91,9 @@ public abstract class KotlinBuiltIns {
|
||||
builtinsPackageFragment = (BuiltinsPackageFragment) single(packageFragmentProvider.getPackageFragments(BUILT_INS_PACKAGE_FQ_NAME));
|
||||
annotationPackageFragment = (BuiltinsPackageFragment) single(packageFragmentProvider.getPackageFragments(ANNOTATION_PACKAGE_FQ_NAME));
|
||||
|
||||
primitiveTypeToArrayJetType = new EnumMap<PrimitiveType, KtType>(PrimitiveType.class);
|
||||
primitiveJetTypeToJetArrayType = new HashMap<KtType, KtType>();
|
||||
jetArrayTypeToPrimitiveJetType = new HashMap<KtType, KtType>();
|
||||
primitiveTypeToArrayJetType = new EnumMap<PrimitiveType, KotlinType>(PrimitiveType.class);
|
||||
primitiveJetTypeToJetArrayType = new HashMap<KotlinType, KotlinType>();
|
||||
jetArrayTypeToPrimitiveJetType = new HashMap<KotlinType, KotlinType>();
|
||||
for (PrimitiveType primitive : PrimitiveType.values()) {
|
||||
makePrimitive(primitive);
|
||||
}
|
||||
@@ -105,8 +105,8 @@ public abstract class KotlinBuiltIns {
|
||||
}
|
||||
|
||||
private void makePrimitive(@NotNull PrimitiveType primitiveType) {
|
||||
KtType type = getBuiltInTypeByClassName(primitiveType.getTypeName().asString());
|
||||
KtType arrayType = getBuiltInTypeByClassName(primitiveType.getArrayTypeName().asString());
|
||||
KotlinType type = getBuiltInTypeByClassName(primitiveType.getTypeName().asString());
|
||||
KotlinType arrayType = getBuiltInTypeByClassName(primitiveType.getArrayTypeName().asString());
|
||||
|
||||
primitiveTypeToArrayJetType.put(primitiveType, arrayType);
|
||||
primitiveJetTypeToJetArrayType.put(type, arrayType);
|
||||
@@ -540,100 +540,100 @@ public abstract class KotlinBuiltIns {
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@NotNull
|
||||
private KtType getBuiltInTypeByClassName(@NotNull String classSimpleName) {
|
||||
private KotlinType getBuiltInTypeByClassName(@NotNull String classSimpleName) {
|
||||
return getBuiltInClassByName(classSimpleName).getDefaultType();
|
||||
}
|
||||
|
||||
// Special
|
||||
|
||||
@NotNull
|
||||
public KtType getNothingType() {
|
||||
public KotlinType getNothingType() {
|
||||
return getNothing().getDefaultType();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public KtType getNullableNothingType() {
|
||||
public KotlinType getNullableNothingType() {
|
||||
return TypeUtils.makeNullable(getNothingType());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public KtType getAnyType() {
|
||||
public KotlinType getAnyType() {
|
||||
return getAny().getDefaultType();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public KtType getNullableAnyType() {
|
||||
public KotlinType getNullableAnyType() {
|
||||
return TypeUtils.makeNullable(getAnyType());
|
||||
}
|
||||
|
||||
// Primitive
|
||||
|
||||
@NotNull
|
||||
public KtType getPrimitiveJetType(@NotNull PrimitiveType type) {
|
||||
public KotlinType getPrimitiveJetType(@NotNull PrimitiveType type) {
|
||||
return getPrimitiveClassDescriptor(type).getDefaultType();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public KtType getByteType() {
|
||||
public KotlinType getByteType() {
|
||||
return getPrimitiveJetType(BYTE);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public KtType getShortType() {
|
||||
public KotlinType getShortType() {
|
||||
return getPrimitiveJetType(SHORT);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public KtType getIntType() {
|
||||
public KotlinType getIntType() {
|
||||
return getPrimitiveJetType(INT);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public KtType getLongType() {
|
||||
public KotlinType getLongType() {
|
||||
return getPrimitiveJetType(LONG);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public KtType getFloatType() {
|
||||
public KotlinType getFloatType() {
|
||||
return getPrimitiveJetType(FLOAT);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public KtType getDoubleType() {
|
||||
public KotlinType getDoubleType() {
|
||||
return getPrimitiveJetType(DOUBLE);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public KtType getCharType() {
|
||||
public KotlinType getCharType() {
|
||||
return getPrimitiveJetType(CHAR);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public KtType getBooleanType() {
|
||||
public KotlinType getBooleanType() {
|
||||
return getPrimitiveJetType(BOOLEAN);
|
||||
}
|
||||
|
||||
// Recognized
|
||||
|
||||
@NotNull
|
||||
public KtType getUnitType() {
|
||||
public KotlinType getUnitType() {
|
||||
return getUnit().getDefaultType();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public KtType getStringType() {
|
||||
public KotlinType getStringType() {
|
||||
return getString().getDefaultType();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public KtType getArrayElementType(@NotNull KtType arrayType) {
|
||||
public KotlinType getArrayElementType(@NotNull KotlinType arrayType) {
|
||||
if (isArray(arrayType)) {
|
||||
if (arrayType.getArguments().size() != 1) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
return arrayType.getArguments().get(0).getType();
|
||||
}
|
||||
KtType primitiveType = jetArrayTypeToPrimitiveJetType.get(TypeUtils.makeNotNullable(arrayType));
|
||||
KotlinType primitiveType = jetArrayTypeToPrimitiveJetType.get(TypeUtils.makeNotNullable(arrayType));
|
||||
if (primitiveType == null) {
|
||||
throw new IllegalStateException("not array: " + arrayType);
|
||||
}
|
||||
@@ -641,7 +641,7 @@ public abstract class KotlinBuiltIns {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public KtType getPrimitiveArrayJetType(@NotNull PrimitiveType primitiveType) {
|
||||
public KotlinType getPrimitiveArrayJetType(@NotNull PrimitiveType primitiveType) {
|
||||
return primitiveTypeToArrayJetType.get(primitiveType);
|
||||
}
|
||||
|
||||
@@ -649,7 +649,7 @@ public abstract class KotlinBuiltIns {
|
||||
* @return {@code null} if not primitive
|
||||
*/
|
||||
@Nullable
|
||||
public KtType getPrimitiveArrayJetTypeByPrimitiveJetType(@NotNull KtType jetType) {
|
||||
public KotlinType getPrimitiveArrayJetTypeByPrimitiveJetType(@NotNull KotlinType jetType) {
|
||||
return primitiveJetTypeToJetArrayType.get(jetType);
|
||||
}
|
||||
|
||||
@@ -668,9 +668,9 @@ public abstract class KotlinBuiltIns {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public KtType getArrayType(@NotNull Variance projectionType, @NotNull KtType argument) {
|
||||
public KotlinType getArrayType(@NotNull Variance projectionType, @NotNull KotlinType argument) {
|
||||
List<TypeProjectionImpl> types = Collections.singletonList(new TypeProjectionImpl(projectionType, argument));
|
||||
return KtTypeImpl.create(
|
||||
return KotlinTypeImpl.create(
|
||||
Annotations.Companion.getEMPTY(),
|
||||
getArray(),
|
||||
false,
|
||||
@@ -679,10 +679,10 @@ public abstract class KotlinBuiltIns {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public KtType getEnumType(@NotNull KtType argument) {
|
||||
public KotlinType getEnumType(@NotNull KotlinType argument) {
|
||||
Variance projectionType = Variance.INVARIANT;
|
||||
List<TypeProjectionImpl> types = Collections.singletonList(new TypeProjectionImpl(projectionType, argument));
|
||||
return KtTypeImpl.create(
|
||||
return KotlinTypeImpl.create(
|
||||
Annotations.Companion.getEMPTY(),
|
||||
getEnum(),
|
||||
false,
|
||||
@@ -691,7 +691,7 @@ public abstract class KotlinBuiltIns {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public KtType getAnnotationType() {
|
||||
public KotlinType getAnnotationType() {
|
||||
return getAnnotation().getDefaultType();
|
||||
}
|
||||
|
||||
@@ -701,16 +701,16 @@ public abstract class KotlinBuiltIns {
|
||||
Collections.<ValueParameterDescriptor, ConstantValue<?>>emptyMap(), SourceElement.NO_SOURCE);
|
||||
}
|
||||
|
||||
private static boolean isTypeAnnotatedWithExtension(@NotNull KtType type) {
|
||||
private static boolean isTypeAnnotatedWithExtension(@NotNull KotlinType type) {
|
||||
return type.getAnnotations().findAnnotation(FQ_NAMES.extension) != null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public KtType getFunctionType(
|
||||
public KotlinType getFunctionType(
|
||||
@NotNull Annotations annotations,
|
||||
@Nullable KtType receiverType,
|
||||
@NotNull List<KtType> parameterTypes,
|
||||
@NotNull KtType returnType
|
||||
@Nullable KotlinType receiverType,
|
||||
@NotNull List<KotlinType> parameterTypes,
|
||||
@NotNull KotlinType returnType
|
||||
) {
|
||||
List<TypeProjection> arguments = getFunctionTypeArgumentProjections(receiverType, parameterTypes, returnType);
|
||||
int size = parameterTypes.size();
|
||||
@@ -718,7 +718,7 @@ public abstract class KotlinBuiltIns {
|
||||
|
||||
Annotations typeAnnotations = receiverType == null ? annotations : addExtensionAnnotation(annotations);
|
||||
|
||||
return KtTypeImpl.create(typeAnnotations, classDescriptor, false, arguments);
|
||||
return KotlinTypeImpl.create(typeAnnotations, classDescriptor, false, arguments);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -731,22 +731,22 @@ public abstract class KotlinBuiltIns {
|
||||
|
||||
@NotNull
|
||||
public static List<TypeProjection> getFunctionTypeArgumentProjections(
|
||||
@Nullable KtType receiverType,
|
||||
@NotNull List<KtType> parameterTypes,
|
||||
@NotNull KtType returnType
|
||||
@Nullable KotlinType receiverType,
|
||||
@NotNull List<KotlinType> parameterTypes,
|
||||
@NotNull KotlinType returnType
|
||||
) {
|
||||
List<TypeProjection> arguments = new ArrayList<TypeProjection>(parameterTypes.size() + (receiverType != null ? 1 : 0) + 1);
|
||||
if (receiverType != null) {
|
||||
arguments.add(defaultProjection(receiverType));
|
||||
}
|
||||
for (KtType parameterType : parameterTypes) {
|
||||
for (KotlinType parameterType : parameterTypes) {
|
||||
arguments.add(defaultProjection(parameterType));
|
||||
}
|
||||
arguments.add(defaultProjection(returnType));
|
||||
return arguments;
|
||||
}
|
||||
|
||||
private static TypeProjection defaultProjection(KtType returnType) {
|
||||
private static TypeProjection defaultProjection(KotlinType returnType) {
|
||||
return new TypeProjectionImpl(Variance.INVARIANT, returnType);
|
||||
}
|
||||
|
||||
@@ -756,16 +756,16 @@ public abstract class KotlinBuiltIns {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public static boolean isArray(@NotNull KtType type) {
|
||||
public static boolean isArray(@NotNull KotlinType type) {
|
||||
return isConstructedFromGivenClass(type, FQ_NAMES.array);
|
||||
}
|
||||
|
||||
public static boolean isPrimitiveArray(@NotNull KtType type) {
|
||||
public static boolean isPrimitiveArray(@NotNull KotlinType type) {
|
||||
ClassifierDescriptor descriptor = type.getConstructor().getDeclarationDescriptor();
|
||||
return descriptor != null && getPrimitiveTypeByArrayClassFqName(getFqName(descriptor)) != null;
|
||||
}
|
||||
|
||||
public static boolean isPrimitiveType(@NotNull KtType type) {
|
||||
public static boolean isPrimitiveType(@NotNull KotlinType type) {
|
||||
ClassifierDescriptor descriptor = type.getConstructor().getDeclarationDescriptor();
|
||||
return !type.isMarkedNullable() && descriptor instanceof ClassDescriptor && isPrimitiveClass((ClassDescriptor) descriptor);
|
||||
}
|
||||
@@ -776,40 +776,40 @@ public abstract class KotlinBuiltIns {
|
||||
|
||||
// Functions
|
||||
|
||||
public static boolean isFunctionOrExtensionFunctionType(@NotNull KtType type) {
|
||||
public static boolean isFunctionOrExtensionFunctionType(@NotNull KotlinType type) {
|
||||
return isFunctionType(type) || isExtensionFunctionType(type);
|
||||
}
|
||||
|
||||
public static boolean isFunctionType(@NotNull KtType type) {
|
||||
public static boolean isFunctionType(@NotNull KotlinType type) {
|
||||
if (isExactFunctionType(type)) return true;
|
||||
|
||||
for (KtType superType : type.getConstructor().getSupertypes()) {
|
||||
for (KotlinType superType : type.getConstructor().getSupertypes()) {
|
||||
if (isFunctionType(superType)) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isExtensionFunctionType(@NotNull KtType type) {
|
||||
public static boolean isExtensionFunctionType(@NotNull KotlinType type) {
|
||||
if (isExactExtensionFunctionType(type)) return true;
|
||||
|
||||
for (KtType superType : type.getConstructor().getSupertypes()) {
|
||||
for (KotlinType superType : type.getConstructor().getSupertypes()) {
|
||||
if (isExtensionFunctionType(superType)) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isExactFunctionOrExtensionFunctionType(@NotNull KtType type) {
|
||||
public static boolean isExactFunctionOrExtensionFunctionType(@NotNull KotlinType type) {
|
||||
ClassifierDescriptor descriptor = type.getConstructor().getDeclarationDescriptor();
|
||||
return descriptor != null && isNumberedFunctionClassFqName(getFqName(descriptor));
|
||||
}
|
||||
|
||||
public static boolean isExactFunctionType(@NotNull KtType type) {
|
||||
public static boolean isExactFunctionType(@NotNull KotlinType type) {
|
||||
return isExactFunctionOrExtensionFunctionType(type) && !isTypeAnnotatedWithExtension(type);
|
||||
}
|
||||
|
||||
public static boolean isExactExtensionFunctionType(@NotNull KtType type) {
|
||||
public static boolean isExactExtensionFunctionType(@NotNull KotlinType type) {
|
||||
return isExactFunctionOrExtensionFunctionType(type) && isTypeAnnotatedWithExtension(type);
|
||||
}
|
||||
|
||||
@@ -828,7 +828,7 @@ public abstract class KotlinBuiltIns {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static KtType getReceiverType(@NotNull KtType type) {
|
||||
public static KotlinType getReceiverType(@NotNull KotlinType type) {
|
||||
assert isFunctionOrExtensionFunctionType(type) : type;
|
||||
if (isExtensionFunctionType(type)) {
|
||||
// TODO: this is incorrect when a class extends from an extension function and swaps type arguments
|
||||
@@ -838,7 +838,7 @@ public abstract class KotlinBuiltIns {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static List<ValueParameterDescriptor> getValueParameters(@NotNull FunctionDescriptor functionDescriptor, @NotNull KtType type) {
|
||||
public static List<ValueParameterDescriptor> getValueParameters(@NotNull FunctionDescriptor functionDescriptor, @NotNull KotlinType type) {
|
||||
assert isFunctionOrExtensionFunctionType(type);
|
||||
List<TypeProjection> parameterTypes = getParameterTypeProjectionsFromFunctionType(type);
|
||||
List<ValueParameterDescriptor> valueParameters = new ArrayList<ValueParameterDescriptor>(parameterTypes.size());
|
||||
@@ -858,14 +858,14 @@ public abstract class KotlinBuiltIns {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static KtType getReturnTypeFromFunctionType(@NotNull KtType type) {
|
||||
public static KotlinType getReturnTypeFromFunctionType(@NotNull KotlinType type) {
|
||||
assert isFunctionOrExtensionFunctionType(type);
|
||||
List<TypeProjection> arguments = type.getArguments();
|
||||
return arguments.get(arguments.size() - 1).getType();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static List<TypeProjection> getParameterTypeProjectionsFromFunctionType(@NotNull KtType type) {
|
||||
public static List<TypeProjection> getParameterTypeProjectionsFromFunctionType(@NotNull KotlinType type) {
|
||||
assert isFunctionOrExtensionFunctionType(type);
|
||||
List<TypeProjection> arguments = type.getArguments();
|
||||
int first = isExtensionFunctionType(type) ? 1 : 0;
|
||||
@@ -879,14 +879,14 @@ public abstract class KotlinBuiltIns {
|
||||
|
||||
// Recognized & special
|
||||
|
||||
private static boolean isConstructedFromGivenClass(@NotNull KtType type, @NotNull FqNameUnsafe fqName) {
|
||||
private static boolean isConstructedFromGivenClass(@NotNull KotlinType type, @NotNull FqNameUnsafe fqName) {
|
||||
ClassifierDescriptor descriptor = type.getConstructor().getDeclarationDescriptor();
|
||||
return descriptor != null &&
|
||||
/* quick check to avoid creation of full FqName instance */ descriptor.getName().equals(fqName.shortName()) &&
|
||||
fqName.equals(getFqName(descriptor));
|
||||
}
|
||||
|
||||
private static boolean isNotNullConstructedFromGivenClass(@NotNull KtType type, @NotNull FqNameUnsafe fqName) {
|
||||
private static boolean isNotNullConstructedFromGivenClass(@NotNull KotlinType type, @NotNull FqNameUnsafe fqName) {
|
||||
return !type.isMarkedNullable() && isConstructedFromGivenClass(type, fqName);
|
||||
}
|
||||
|
||||
@@ -899,16 +899,16 @@ public abstract class KotlinBuiltIns {
|
||||
return isAny(getFqName(descriptor));
|
||||
}
|
||||
|
||||
public static boolean isAny(@NotNull KtType type) {
|
||||
public static boolean isAny(@NotNull KotlinType type) {
|
||||
return isConstructedFromGivenClassAndNotNullable(type, FQ_NAMES.any);
|
||||
}
|
||||
|
||||
public static boolean isBoolean(@NotNull KtType type) {
|
||||
public static boolean isBoolean(@NotNull KotlinType type) {
|
||||
|
||||
return isConstructedFromGivenClassAndNotNullable(type, FQ_NAMES._boolean);
|
||||
}
|
||||
|
||||
public static boolean isBooleanOrNullableBoolean(@NotNull KtType type) {
|
||||
public static boolean isBooleanOrNullableBoolean(@NotNull KotlinType type) {
|
||||
return isConstructedFromGivenClass(type, FQ_NAMES._boolean);
|
||||
}
|
||||
|
||||
@@ -916,35 +916,35 @@ public abstract class KotlinBuiltIns {
|
||||
return FQ_NAMES._boolean.equals(getFqName(classDescriptor));
|
||||
}
|
||||
|
||||
public static boolean isChar(@NotNull KtType type) {
|
||||
public static boolean isChar(@NotNull KotlinType type) {
|
||||
return isConstructedFromGivenClassAndNotNullable(type, FQ_NAMES._char);
|
||||
}
|
||||
|
||||
public static boolean isInt(@NotNull KtType type) {
|
||||
public static boolean isInt(@NotNull KotlinType type) {
|
||||
return isConstructedFromGivenClassAndNotNullable(type, FQ_NAMES._int);
|
||||
}
|
||||
|
||||
public static boolean isByte(@NotNull KtType type) {
|
||||
public static boolean isByte(@NotNull KotlinType type) {
|
||||
return isConstructedFromGivenClassAndNotNullable(type, FQ_NAMES._byte);
|
||||
}
|
||||
|
||||
public static boolean isLong(@NotNull KtType type) {
|
||||
public static boolean isLong(@NotNull KotlinType type) {
|
||||
return isConstructedFromGivenClassAndNotNullable(type, FQ_NAMES._long);
|
||||
}
|
||||
|
||||
public static boolean isShort(@NotNull KtType type) {
|
||||
public static boolean isShort(@NotNull KotlinType type) {
|
||||
return isConstructedFromGivenClassAndNotNullable(type, FQ_NAMES._short);
|
||||
}
|
||||
|
||||
public static boolean isFloat(@NotNull KtType type) {
|
||||
public static boolean isFloat(@NotNull KotlinType type) {
|
||||
return isConstructedFromGivenClassAndNotNullable(type, FQ_NAMES._float);
|
||||
}
|
||||
|
||||
public static boolean isDouble(@NotNull KtType type) {
|
||||
public static boolean isDouble(@NotNull KotlinType type) {
|
||||
return isConstructedFromGivenClassAndNotNullable(type, FQ_NAMES._double);
|
||||
}
|
||||
|
||||
private static boolean isConstructedFromGivenClassAndNotNullable(@NotNull KtType type, @NotNull FqNameUnsafe fqName) {
|
||||
private static boolean isConstructedFromGivenClassAndNotNullable(@NotNull KotlinType type, @NotNull FqNameUnsafe fqName) {
|
||||
return isConstructedFromGivenClass(type, fqName) && !type.isMarkedNullable();
|
||||
}
|
||||
|
||||
@@ -952,57 +952,57 @@ public abstract class KotlinBuiltIns {
|
||||
return FQ_NAMES.any.equals(fqName);
|
||||
}
|
||||
|
||||
public static boolean isNothing(@NotNull KtType type) {
|
||||
public static boolean isNothing(@NotNull KotlinType type) {
|
||||
return isNothingOrNullableNothing(type)
|
||||
&& !type.isMarkedNullable();
|
||||
}
|
||||
|
||||
public static boolean isNullableNothing(@NotNull KtType type) {
|
||||
public static boolean isNullableNothing(@NotNull KotlinType type) {
|
||||
return isNothingOrNullableNothing(type)
|
||||
&& type.isMarkedNullable();
|
||||
}
|
||||
|
||||
public static boolean isNothingOrNullableNothing(@NotNull KtType type) {
|
||||
public static boolean isNothingOrNullableNothing(@NotNull KotlinType type) {
|
||||
return isConstructedFromGivenClass(type, FQ_NAMES.nothing);
|
||||
}
|
||||
|
||||
public static boolean isAnyOrNullableAny(@NotNull KtType type) {
|
||||
public static boolean isAnyOrNullableAny(@NotNull KotlinType type) {
|
||||
return isConstructedFromGivenClass(type, FQ_NAMES.any);
|
||||
}
|
||||
|
||||
public static boolean isNullableAny(@NotNull KtType type) {
|
||||
public static boolean isNullableAny(@NotNull KotlinType type) {
|
||||
return isAnyOrNullableAny(type) && type.isMarkedNullable();
|
||||
}
|
||||
|
||||
public static boolean isDefaultBound(@NotNull KtType type) {
|
||||
public static boolean isDefaultBound(@NotNull KotlinType type) {
|
||||
return isNullableAny(type);
|
||||
}
|
||||
|
||||
public static boolean isUnit(@NotNull KtType type) {
|
||||
public static boolean isUnit(@NotNull KotlinType type) {
|
||||
return isNotNullConstructedFromGivenClass(type, FQ_NAMES.unit);
|
||||
}
|
||||
|
||||
public boolean isBooleanOrSubtype(@NotNull KtType type) {
|
||||
public boolean isBooleanOrSubtype(@NotNull KotlinType type) {
|
||||
return KotlinTypeChecker.DEFAULT.isSubtypeOf(type, getBooleanType());
|
||||
}
|
||||
|
||||
public static boolean isString(@Nullable KtType type) {
|
||||
public static boolean isString(@Nullable KotlinType type) {
|
||||
return type != null && isNotNullConstructedFromGivenClass(type, FQ_NAMES.string);
|
||||
}
|
||||
|
||||
public static boolean isCollectionOrNullableCollection(@NotNull KtType type) {
|
||||
public static boolean isCollectionOrNullableCollection(@NotNull KotlinType type) {
|
||||
return isConstructedFromGivenClass(type, FQ_NAMES._collection);
|
||||
}
|
||||
|
||||
public static boolean isListOrNullableList(@NotNull KtType type) {
|
||||
public static boolean isListOrNullableList(@NotNull KotlinType type) {
|
||||
return isConstructedFromGivenClass(type, FQ_NAMES._list);
|
||||
}
|
||||
|
||||
public static boolean isSetOrNullableSet(@NotNull KtType type) {
|
||||
public static boolean isSetOrNullableSet(@NotNull KotlinType type) {
|
||||
return isConstructedFromGivenClass(type, FQ_NAMES._set);
|
||||
}
|
||||
|
||||
public static boolean isIterableOrNullableIterable(@NotNull KtType type) {
|
||||
public static boolean isIterableOrNullableIterable(@NotNull KotlinType type) {
|
||||
return isConstructedFromGivenClass(type, FQ_NAMES._iterable);
|
||||
}
|
||||
|
||||
@@ -1054,7 +1054,7 @@ public abstract class KotlinBuiltIns {
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@NotNull
|
||||
public KtType getDefaultBound() {
|
||||
public KotlinType getDefaultBound() {
|
||||
return getNullableAnyType();
|
||||
}
|
||||
|
||||
|
||||
@@ -57,22 +57,22 @@ public class ReflectionTypes(private val module: ModuleDescriptor) {
|
||||
public val kMutableProperty0: ClassDescriptor by ClassLookup
|
||||
public val kMutableProperty1: ClassDescriptor by ClassLookup
|
||||
|
||||
public fun getKClassType(annotations: Annotations, type: KtType): KtType {
|
||||
public fun getKClassType(annotations: Annotations, type: KotlinType): KotlinType {
|
||||
val descriptor = kClass
|
||||
if (ErrorUtils.isError(descriptor)) {
|
||||
return descriptor.defaultType
|
||||
}
|
||||
|
||||
val arguments = listOf(TypeProjectionImpl(Variance.INVARIANT, type))
|
||||
return KtTypeImpl.create(annotations, descriptor, false, arguments)
|
||||
return KotlinTypeImpl.create(annotations, descriptor, false, arguments)
|
||||
}
|
||||
|
||||
public fun getKFunctionType(
|
||||
annotations: Annotations,
|
||||
receiverType: KtType?,
|
||||
parameterTypes: List<KtType>,
|
||||
returnType: KtType
|
||||
): KtType {
|
||||
receiverType: KotlinType?,
|
||||
parameterTypes: List<KotlinType>,
|
||||
returnType: KotlinType
|
||||
): KotlinType {
|
||||
val arguments = KotlinBuiltIns.getFunctionTypeArgumentProjections(receiverType, parameterTypes, returnType)
|
||||
|
||||
val classDescriptor = getKFunction(arguments.size() - 1 /* return type */)
|
||||
@@ -81,10 +81,10 @@ public class ReflectionTypes(private val module: ModuleDescriptor) {
|
||||
return classDescriptor.defaultType
|
||||
}
|
||||
|
||||
return KtTypeImpl.create(annotations, classDescriptor, false, arguments)
|
||||
return KotlinTypeImpl.create(annotations, classDescriptor, false, arguments)
|
||||
}
|
||||
|
||||
public fun getKPropertyType(annotations: Annotations, receiverType: KtType?, returnType: KtType, mutable: Boolean): KtType {
|
||||
public fun getKPropertyType(annotations: Annotations, receiverType: KotlinType?, returnType: KotlinType, mutable: Boolean): KotlinType {
|
||||
val classDescriptor =
|
||||
when {
|
||||
receiverType != null -> when {
|
||||
@@ -106,7 +106,7 @@ public class ReflectionTypes(private val module: ModuleDescriptor) {
|
||||
arguments.add(TypeProjectionImpl(receiverType))
|
||||
}
|
||||
arguments.add(TypeProjectionImpl(returnType))
|
||||
return KtTypeImpl.create(annotations, classDescriptor, false, arguments)
|
||||
return KotlinTypeImpl.create(annotations, classDescriptor, false, arguments)
|
||||
}
|
||||
|
||||
companion object {
|
||||
@@ -115,21 +115,21 @@ public class ReflectionTypes(private val module: ModuleDescriptor) {
|
||||
return containingPackage != null && containingPackage.fqName == KOTLIN_REFLECT_FQ_NAME
|
||||
}
|
||||
|
||||
public fun isCallableType(type: KtType): Boolean =
|
||||
public fun isCallableType(type: KotlinType): Boolean =
|
||||
KotlinBuiltIns.isFunctionOrExtensionFunctionType(type) || isKCallableType(type)
|
||||
|
||||
private fun isKCallableType(type: KtType): Boolean =
|
||||
private fun isKCallableType(type: KotlinType): Boolean =
|
||||
isExactKCallableType(type) ||
|
||||
type.constructor.supertypes.any { isKCallableType(it) }
|
||||
|
||||
private fun isExactKCallableType(type: KtType): Boolean {
|
||||
private fun isExactKCallableType(type: KotlinType): Boolean {
|
||||
val descriptor = type.constructor.declarationDescriptor
|
||||
return descriptor is ClassDescriptor && DescriptorUtils.getFqName(descriptor) == KotlinBuiltIns.FQ_NAMES.kCallable
|
||||
}
|
||||
|
||||
public fun createKPropertyStarType(module: ModuleDescriptor): KtType? {
|
||||
public fun createKPropertyStarType(module: ModuleDescriptor): KotlinType? {
|
||||
val kPropertyClass = module.findClassAcrossModuleDependencies(KotlinBuiltIns.FQ_NAMES.kProperty) ?: return null
|
||||
return KtTypeImpl.create(
|
||||
return KotlinTypeImpl.create(
|
||||
Annotations.EMPTY, kPropertyClass, false,
|
||||
listOf(StarProjectionImpl(kPropertyClass.typeConstructor.parameters.single()))
|
||||
)
|
||||
|
||||
+3
-3
@@ -108,7 +108,7 @@ public class FunctionClassDescriptor(
|
||||
}
|
||||
|
||||
private val supertypes = storageManager.createLazyValue {
|
||||
val result = ArrayList<KtType>(2)
|
||||
val result = ArrayList<KotlinType>(2)
|
||||
|
||||
fun add(packageFragment: PackageFragmentDescriptor, name: Name) {
|
||||
val descriptor = packageFragment.getMemberScope().getClassifier(name, NoLookupLocation.FROM_BUILTINS) as? ClassDescriptor
|
||||
@@ -121,7 +121,7 @@ public class FunctionClassDescriptor(
|
||||
TypeProjectionImpl(it.getDefaultType())
|
||||
}
|
||||
|
||||
result.add(KtTypeImpl.create(Annotations.EMPTY, descriptor, false, arguments))
|
||||
result.add(KotlinTypeImpl.create(Annotations.EMPTY, descriptor, false, arguments))
|
||||
}
|
||||
|
||||
// Add unnumbered base class, e.g. Function for Function{n}, KFunction for KFunction{n}
|
||||
@@ -140,7 +140,7 @@ public class FunctionClassDescriptor(
|
||||
|
||||
override fun getParameters() = parameters
|
||||
|
||||
override fun getSupertypes(): Collection<KtType> = supertypes()
|
||||
override fun getSupertypes(): Collection<KotlinType> = supertypes()
|
||||
|
||||
override fun getDeclarationDescriptor() = this@FunctionClassDescriptor
|
||||
override fun isDenotable() = true
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.descriptors;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.TypeSubstitutor;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -38,7 +38,7 @@ public interface CallableDescriptor extends DeclarationDescriptorWithVisibility,
|
||||
* Method may return null for not yet fully initialized object or if error occurred.
|
||||
*/
|
||||
@Nullable
|
||||
KtType getReturnType();
|
||||
KotlinType getReturnType();
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
|
||||
@@ -20,7 +20,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.ReadOnly;
|
||||
import org.jetbrains.kotlin.resolve.scopes.KtScope;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.TypeProjection;
|
||||
import org.jetbrains.kotlin.types.TypeSubstitution;
|
||||
import org.jetbrains.kotlin.types.TypeSubstitutor;
|
||||
@@ -57,7 +57,7 @@ public interface ClassDescriptor extends ClassifierDescriptor, MemberDescriptor,
|
||||
*/
|
||||
@NotNull
|
||||
@Override
|
||||
KtType getDefaultType();
|
||||
KotlinType getDefaultType();
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package org.jetbrains.kotlin.descriptors;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.TypeConstructor;
|
||||
|
||||
public interface ClassifierDescriptor extends DeclarationDescriptorNonRoot {
|
||||
@@ -25,5 +25,5 @@ public interface ClassifierDescriptor extends DeclarationDescriptorNonRoot {
|
||||
TypeConstructor getTypeConstructor();
|
||||
|
||||
@NotNull
|
||||
KtType getDefaultType();
|
||||
KotlinType getDefaultType();
|
||||
}
|
||||
|
||||
@@ -19,11 +19,11 @@
|
||||
package org.jetbrains.kotlin.descriptors
|
||||
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
object ConstUtil {
|
||||
@JvmStatic
|
||||
public fun canBeUsedForConstVal(type: KtType) = type.canBeUsedForConstVal()
|
||||
public fun canBeUsedForConstVal(type: KotlinType) = type.canBeUsedForConstVal()
|
||||
}
|
||||
|
||||
public fun KtType.canBeUsedForConstVal() = KotlinBuiltIns.isPrimitiveType(this) || KotlinBuiltIns.isString(this)
|
||||
public fun KotlinType.canBeUsedForConstVal() = KotlinBuiltIns.isPrimitiveType(this) || KotlinBuiltIns.isString(this)
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.descriptors;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -29,7 +29,7 @@ public interface ConstructorDescriptor extends FunctionDescriptor {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
KtType getReturnType();
|
||||
KotlinType getReturnType();
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package org.jetbrains.kotlin.descriptors
|
||||
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.TypeConstructor
|
||||
|
||||
sealed class EffectiveVisibility(val name: String) {
|
||||
@@ -231,9 +231,9 @@ sealed class EffectiveVisibility(val name: String) {
|
||||
lowerBound(visibility.forVisibility(this), this?.forClass(classes + this@forClass) ?: Public)
|
||||
}
|
||||
|
||||
fun KtType.forType() = forType(emptySet())
|
||||
fun KotlinType.forType() = forType(emptySet())
|
||||
|
||||
private fun KtType.forType(types: Set<KtType>): EffectiveVisibility =
|
||||
private fun KotlinType.forType(types: Set<KotlinType>): EffectiveVisibility =
|
||||
if (this in types) Public
|
||||
else lowerBound(constructor.forTypeConstructor(),
|
||||
arguments.map { it.type.forType(types + this) } )
|
||||
|
||||
@@ -17,11 +17,11 @@
|
||||
package org.jetbrains.kotlin.descriptors;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
public interface ParameterDescriptor extends CallableDescriptor {
|
||||
@NotNull
|
||||
KtType getType();
|
||||
KotlinType getType();
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package org.jetbrains.kotlin.descriptors;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.TypeConstructor;
|
||||
import org.jetbrains.kotlin.types.TypeSubstitutor;
|
||||
import org.jetbrains.kotlin.types.Variance;
|
||||
@@ -31,13 +31,13 @@ public interface TypeParameterDescriptor extends ClassifierDescriptor {
|
||||
Variance getVariance();
|
||||
|
||||
@NotNull
|
||||
Set<KtType> getUpperBounds();
|
||||
Set<KotlinType> getUpperBounds();
|
||||
|
||||
@NotNull
|
||||
KtType getUpperBoundsAsType();
|
||||
KotlinType getUpperBoundsAsType();
|
||||
|
||||
@NotNull
|
||||
Set<KtType> getLowerBounds();
|
||||
Set<KotlinType> getLowerBounds();
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.descriptors;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@@ -42,7 +42,7 @@ public interface ValueParameterDescriptor extends VariableDescriptor, ParameterD
|
||||
boolean declaresDefaultValue();
|
||||
|
||||
@Nullable
|
||||
KtType getVarargElementType();
|
||||
KotlinType getVarargElementType();
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
|
||||
@@ -19,12 +19,12 @@ package org.jetbrains.kotlin.descriptors;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.resolve.constants.ConstantValue;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.TypeSubstitutor;
|
||||
|
||||
public interface VariableDescriptor extends CallableDescriptor {
|
||||
@NotNull
|
||||
KtType getType();
|
||||
KotlinType getType();
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
|
||||
+2
-2
@@ -21,13 +21,13 @@ import org.jetbrains.annotations.ReadOnly;
|
||||
import org.jetbrains.kotlin.descriptors.SourceElement;
|
||||
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor;
|
||||
import org.jetbrains.kotlin.resolve.constants.ConstantValue;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface AnnotationDescriptor {
|
||||
@NotNull
|
||||
KtType getType();
|
||||
KotlinType getType();
|
||||
|
||||
@NotNull
|
||||
@ReadOnly
|
||||
|
||||
+4
-4
@@ -21,18 +21,18 @@ import org.jetbrains.kotlin.descriptors.SourceElement;
|
||||
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor;
|
||||
import org.jetbrains.kotlin.renderer.DescriptorRenderer;
|
||||
import org.jetbrains.kotlin.resolve.constants.ConstantValue;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
public class AnnotationDescriptorImpl implements AnnotationDescriptor {
|
||||
private final KtType annotationType;
|
||||
private final KotlinType annotationType;
|
||||
private final Map<ValueParameterDescriptor, ConstantValue<?>> valueArguments;
|
||||
private final SourceElement source;
|
||||
|
||||
public AnnotationDescriptorImpl(
|
||||
@NotNull KtType annotationType,
|
||||
@NotNull KotlinType annotationType,
|
||||
@NotNull Map<ValueParameterDescriptor, ConstantValue<?>> valueArguments,
|
||||
@NotNull SourceElement source
|
||||
) {
|
||||
@@ -43,7 +43,7 @@ public class AnnotationDescriptorImpl implements AnnotationDescriptor {
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public KtType getType() {
|
||||
public KotlinType getType() {
|
||||
return annotationType;
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -31,15 +31,15 @@ import java.util.List;
|
||||
|
||||
public abstract class AbstractClassDescriptor implements ClassDescriptor {
|
||||
private final Name name;
|
||||
protected final NotNullLazyValue<KtType> defaultType;
|
||||
protected final NotNullLazyValue<KotlinType> defaultType;
|
||||
private final NotNullLazyValue<KtScope> unsubstitutedInnerClassesScope;
|
||||
private final NotNullLazyValue<ReceiverParameterDescriptor> thisAsReceiverParameter;
|
||||
|
||||
public AbstractClassDescriptor(@NotNull StorageManager storageManager, @NotNull Name name) {
|
||||
this.name = name;
|
||||
this.defaultType = storageManager.createLazyValue(new Function0<KtType>() {
|
||||
this.defaultType = storageManager.createLazyValue(new Function0<KotlinType>() {
|
||||
@Override
|
||||
public KtType invoke() {
|
||||
public KotlinType invoke() {
|
||||
return TypeUtils.makeUnsubstitutedType(AbstractClassDescriptor.this, getUnsubstitutedMemberScope());
|
||||
}
|
||||
});
|
||||
@@ -113,7 +113,7 @@ public abstract class AbstractClassDescriptor implements ClassDescriptor {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public KtType getDefaultType() {
|
||||
public KotlinType getDefaultType() {
|
||||
return defaultType.invoke();
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -26,7 +26,7 @@ import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt;
|
||||
import org.jetbrains.kotlin.storage.StorageManager;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.TypeConstructor;
|
||||
import org.jetbrains.kotlin.types.Variance;
|
||||
|
||||
@@ -53,7 +53,7 @@ public abstract class AbstractLazyTypeParameterDescriptor extends AbstractTypePa
|
||||
return new TypeConstructor() {
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<KtType> getSupertypes() {
|
||||
public Collection<KotlinType> getSupertypes() {
|
||||
return AbstractLazyTypeParameterDescriptor.this.getUpperBounds();
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.TransientReceiver;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.TypeSubstitutor;
|
||||
import org.jetbrains.kotlin.types.Variance;
|
||||
|
||||
@@ -41,7 +41,7 @@ public abstract class AbstractReceiverParameterDescriptor extends DeclarationDes
|
||||
@Override
|
||||
public ReceiverParameterDescriptor substitute(@NotNull TypeSubstitutor substitutor) {
|
||||
if (substitutor.isEmpty()) return this;
|
||||
KtType substitutedType = substitutor.substitute(getType(), Variance.INVARIANT);
|
||||
KotlinType substitutedType = substitutor.substitute(getType(), Variance.INVARIANT);
|
||||
if (substitutedType == null) return null;
|
||||
|
||||
return new ReceiverParameterDescriptorImpl(getContainingDeclaration(), new TransientReceiver(substitutedType));
|
||||
@@ -72,13 +72,13 @@ public abstract class AbstractReceiverParameterDescriptor extends DeclarationDes
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public KtType getReturnType() {
|
||||
public KotlinType getReturnType() {
|
||||
return getType();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public KtType getType() {
|
||||
public KotlinType getType() {
|
||||
return getValue().getType();
|
||||
}
|
||||
|
||||
|
||||
+19
-19
@@ -43,9 +43,9 @@ public abstract class AbstractTypeParameterDescriptor extends DeclarationDescrip
|
||||
private final int index;
|
||||
|
||||
private final NotNullLazyValue<TypeConstructor> typeConstructor;
|
||||
private final NotNullLazyValue<KtType> defaultType;
|
||||
private final NotNullLazyValue<Set<KtType>> upperBounds;
|
||||
private final NotNullLazyValue<KtType> upperBoundsAsType;
|
||||
private final NotNullLazyValue<KotlinType> defaultType;
|
||||
private final NotNullLazyValue<Set<KotlinType>> upperBounds;
|
||||
private final NotNullLazyValue<KotlinType> upperBoundsAsType;
|
||||
|
||||
protected AbstractTypeParameterDescriptor(
|
||||
@NotNull final StorageManager storageManager,
|
||||
@@ -68,11 +68,11 @@ public abstract class AbstractTypeParameterDescriptor extends DeclarationDescrip
|
||||
return createTypeConstructor();
|
||||
}
|
||||
});
|
||||
this.defaultType = storageManager.createLazyValue(new Function0<KtType>() {
|
||||
this.defaultType = storageManager.createLazyValue(new Function0<KotlinType>() {
|
||||
@Override
|
||||
public KtType invoke() {
|
||||
return KtTypeImpl.create(Annotations.Companion.getEMPTY(), getTypeConstructor(), false, Collections.<TypeProjection>emptyList(),
|
||||
new LazyScopeAdapter(storageManager.createLazyValue(
|
||||
public KotlinType invoke() {
|
||||
return KotlinTypeImpl.create(Annotations.Companion.getEMPTY(), getTypeConstructor(), false, Collections.<TypeProjection>emptyList(),
|
||||
new LazyScopeAdapter(storageManager.createLazyValue(
|
||||
new Function0<KtScope>() {
|
||||
@Override
|
||||
public KtScope invoke() {
|
||||
@@ -82,15 +82,15 @@ public abstract class AbstractTypeParameterDescriptor extends DeclarationDescrip
|
||||
)));
|
||||
}
|
||||
});
|
||||
this.upperBounds = storageManager.createRecursionTolerantLazyValue(new Function0<Set<KtType>>() {
|
||||
this.upperBounds = storageManager.createRecursionTolerantLazyValue(new Function0<Set<KotlinType>>() {
|
||||
@Override
|
||||
public Set<KtType> invoke() {
|
||||
public Set<KotlinType> invoke() {
|
||||
return resolveUpperBounds();
|
||||
}
|
||||
}, Collections.singleton(ErrorUtils.createErrorType("Recursion while calculating upper bounds")));
|
||||
this.upperBoundsAsType = storageManager.createLazyValue(new Function0<KtType>() {
|
||||
this.upperBoundsAsType = storageManager.createLazyValue(new Function0<KotlinType>() {
|
||||
@Override
|
||||
public KtType invoke() {
|
||||
public KotlinType invoke() {
|
||||
return computeUpperBoundsAsType();
|
||||
}
|
||||
});
|
||||
@@ -98,7 +98,7 @@ public abstract class AbstractTypeParameterDescriptor extends DeclarationDescrip
|
||||
|
||||
@NotNull
|
||||
@ReadOnly
|
||||
protected abstract Set<KtType> resolveUpperBounds();
|
||||
protected abstract Set<KotlinType> resolveUpperBounds();
|
||||
|
||||
@NotNull
|
||||
protected abstract TypeConstructor createTypeConstructor();
|
||||
@@ -121,21 +121,21 @@ public abstract class AbstractTypeParameterDescriptor extends DeclarationDescrip
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<KtType> getUpperBounds() {
|
||||
public Set<KotlinType> getUpperBounds() {
|
||||
return upperBounds.invoke();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public KtType getUpperBoundsAsType() {
|
||||
public KotlinType getUpperBoundsAsType() {
|
||||
return upperBoundsAsType.invoke();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private KtType computeUpperBoundsAsType() {
|
||||
Set<KtType> upperBounds = getUpperBounds();
|
||||
private KotlinType computeUpperBoundsAsType() {
|
||||
Set<KotlinType> upperBounds = getUpperBounds();
|
||||
assert !upperBounds.isEmpty() : "Upper bound list is empty in " + getName();
|
||||
KtType upperBoundsAsType = TypeIntersector.intersectTypes(KotlinTypeChecker.DEFAULT, upperBounds);
|
||||
KotlinType upperBoundsAsType = TypeIntersector.intersectTypes(KotlinTypeChecker.DEFAULT, upperBounds);
|
||||
return upperBoundsAsType != null ? upperBoundsAsType : getBuiltIns(this).getNothingType();
|
||||
}
|
||||
|
||||
@@ -147,13 +147,13 @@ public abstract class AbstractTypeParameterDescriptor extends DeclarationDescrip
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public KtType getDefaultType() {
|
||||
public KotlinType getDefaultType() {
|
||||
return defaultType.invoke();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<KtType> getLowerBounds() {
|
||||
public Set<KotlinType> getLowerBounds() {
|
||||
return Collections.singleton(getBuiltIns(this).getNothingType());
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.resolve.scopes.KtScope;
|
||||
import org.jetbrains.kotlin.resolve.scopes.StaticScopeForKotlinClass;
|
||||
import org.jetbrains.kotlin.storage.LockBasedStorageManager;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.TypeConstructor;
|
||||
import org.jetbrains.kotlin.types.TypeConstructorImpl;
|
||||
|
||||
@@ -45,7 +45,7 @@ public class ClassDescriptorImpl extends ClassDescriptorBase {
|
||||
@NotNull DeclarationDescriptor containingDeclaration,
|
||||
@NotNull Name name,
|
||||
@NotNull Modality modality,
|
||||
@NotNull Collection<KtType> supertypes,
|
||||
@NotNull Collection<KotlinType> supertypes,
|
||||
@NotNull SourceElement source
|
||||
) {
|
||||
super(LockBasedStorageManager.NO_LOCKS, containingDeclaration, name, source);
|
||||
|
||||
+4
-4
@@ -34,7 +34,7 @@ import org.jetbrains.kotlin.resolve.scopes.StaticScopeForKotlinClass;
|
||||
import org.jetbrains.kotlin.storage.MemoizedFunctionToNotNull;
|
||||
import org.jetbrains.kotlin.storage.NotNullLazyValue;
|
||||
import org.jetbrains.kotlin.storage.StorageManager;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.TypeConstructor;
|
||||
import org.jetbrains.kotlin.types.TypeConstructorImpl;
|
||||
import org.jetbrains.kotlin.utils.Printer;
|
||||
@@ -63,7 +63,7 @@ public class EnumEntrySyntheticClassDescriptor extends ClassDescriptorBase {
|
||||
@NotNull NotNullLazyValue<Collection<Name>> enumMemberNames,
|
||||
@NotNull SourceElement source
|
||||
) {
|
||||
KtType enumType = enumClass.getDefaultType();
|
||||
KotlinType enumType = enumClass.getDefaultType();
|
||||
|
||||
return new EnumEntrySyntheticClassDescriptor(storageManager, enumClass, enumType, name, enumMemberNames, source);
|
||||
}
|
||||
@@ -71,7 +71,7 @@ public class EnumEntrySyntheticClassDescriptor extends ClassDescriptorBase {
|
||||
private EnumEntrySyntheticClassDescriptor(
|
||||
@NotNull StorageManager storageManager,
|
||||
@NotNull ClassDescriptor containingClass,
|
||||
@NotNull KtType supertype,
|
||||
@NotNull KotlinType supertype,
|
||||
@NotNull Name name,
|
||||
@NotNull NotNullLazyValue<Collection<Name>> enumMemberNames,
|
||||
@NotNull SourceElement source
|
||||
@@ -225,7 +225,7 @@ public class EnumEntrySyntheticClassDescriptor extends ClassDescriptorBase {
|
||||
|
||||
@NotNull
|
||||
private KtScope getSupertypeScope() {
|
||||
Collection<KtType> supertype = getTypeConstructor().getSupertypes();
|
||||
Collection<KotlinType> supertype = getTypeConstructor().getSupertypes();
|
||||
assert supertype.size() == 1 : "Enum entry and its companion object both should have exactly one supertype: " + supertype;
|
||||
return supertype.iterator().next().getMemberScope();
|
||||
}
|
||||
|
||||
+14
-14
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.resolve.DescriptorFactory;
|
||||
import org.jetbrains.kotlin.types.DescriptorSubstitutor;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.TypeSubstitutor;
|
||||
import org.jetbrains.kotlin.types.Variance;
|
||||
import org.jetbrains.kotlin.utils.CollectionsKt;
|
||||
@@ -37,7 +37,7 @@ import java.util.Set;
|
||||
public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRootImpl implements FunctionDescriptor {
|
||||
private List<TypeParameterDescriptor> typeParameters;
|
||||
private List<ValueParameterDescriptor> unsubstitutedValueParameters;
|
||||
private KtType unsubstitutedReturnType;
|
||||
private KotlinType unsubstitutedReturnType;
|
||||
private ReceiverParameterDescriptor extensionReceiverParameter;
|
||||
private ReceiverParameterDescriptor dispatchReceiverParameter;
|
||||
private Modality modality;
|
||||
@@ -66,11 +66,11 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
||||
|
||||
@NotNull
|
||||
public FunctionDescriptorImpl initialize(
|
||||
@Nullable KtType receiverParameterType,
|
||||
@Nullable KotlinType receiverParameterType,
|
||||
@Nullable ReceiverParameterDescriptor dispatchReceiverParameter,
|
||||
@NotNull List<? extends TypeParameterDescriptor> typeParameters,
|
||||
@NotNull List<ValueParameterDescriptor> unsubstitutedValueParameters,
|
||||
@Nullable KtType unsubstitutedReturnType,
|
||||
@Nullable KotlinType unsubstitutedReturnType,
|
||||
@Nullable Modality modality,
|
||||
@NotNull Visibility visibility
|
||||
) {
|
||||
@@ -125,7 +125,7 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
||||
this.isTailrec = isTailrec;
|
||||
}
|
||||
|
||||
public void setReturnType(@NotNull KtType unsubstitutedReturnType) {
|
||||
public void setReturnType(@NotNull KotlinType unsubstitutedReturnType) {
|
||||
if (this.unsubstitutedReturnType != null) {
|
||||
// TODO: uncomment and fix tests
|
||||
//throw new IllegalStateException("returnType already set");
|
||||
@@ -228,7 +228,7 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
||||
}
|
||||
|
||||
@Override
|
||||
public KtType getReturnType() {
|
||||
public KotlinType getReturnType() {
|
||||
return unsubstitutedReturnType;
|
||||
}
|
||||
|
||||
@@ -275,7 +275,7 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected KtType getExtensionReceiverParameterType() {
|
||||
protected KotlinType getExtensionReceiverParameterType() {
|
||||
if (extensionReceiverParameter == null) return null;
|
||||
return extensionReceiverParameter.getType();
|
||||
}
|
||||
@@ -295,8 +295,8 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
||||
boolean copyOverrides,
|
||||
@NotNull Kind kind,
|
||||
@NotNull List<ValueParameterDescriptor> newValueParameterDescriptors,
|
||||
@Nullable KtType newExtensionReceiverParameterType,
|
||||
@NotNull KtType newReturnType
|
||||
@Nullable KotlinType newExtensionReceiverParameterType,
|
||||
@NotNull KotlinType newReturnType
|
||||
) {
|
||||
FunctionDescriptorImpl substitutedDescriptor = createSubstitutedCopy(newOwner, original, kind);
|
||||
|
||||
@@ -306,7 +306,7 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
||||
originalTypeParameters, originalSubstitutor.getSubstitution(), substitutedDescriptor, substitutedTypeParameters
|
||||
);
|
||||
|
||||
KtType substitutedReceiverParameterType = null;
|
||||
KotlinType substitutedReceiverParameterType = null;
|
||||
if (newExtensionReceiverParameterType != null) {
|
||||
substitutedReceiverParameterType = substitutor.substitute(newExtensionReceiverParameterType, Variance.IN_VARIANCE);
|
||||
if (substitutedReceiverParameterType == null) {
|
||||
@@ -339,7 +339,7 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
||||
return null;
|
||||
}
|
||||
|
||||
KtType substitutedReturnType = substitutor.substitute(newReturnType, Variance.OUT_VARIANCE);
|
||||
KotlinType substitutedReturnType = substitutor.substitute(newReturnType, Variance.OUT_VARIANCE);
|
||||
if (substitutedReturnType == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -389,9 +389,9 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
||||
List<ValueParameterDescriptor> result = new ArrayList<ValueParameterDescriptor>(unsubstitutedValueParameters.size());
|
||||
for (ValueParameterDescriptor unsubstitutedValueParameter : unsubstitutedValueParameters) {
|
||||
// TODO : Lazy?
|
||||
KtType substitutedType = substitutor.substitute(unsubstitutedValueParameter.getType(), Variance.IN_VARIANCE);
|
||||
KtType varargElementType = unsubstitutedValueParameter.getVarargElementType();
|
||||
KtType substituteVarargElementType =
|
||||
KotlinType substitutedType = substitutor.substitute(unsubstitutedValueParameter.getType(), Variance.IN_VARIANCE);
|
||||
KotlinType varargElementType = unsubstitutedValueParameter.getVarargElementType();
|
||||
KotlinType substituteVarargElementType =
|
||||
varargElementType == null ? null : substitutor.substitute(varargElementType, Variance.IN_VARIANCE);
|
||||
if (substitutedType == null) return null;
|
||||
result.add(
|
||||
|
||||
+5
-5
@@ -68,9 +68,9 @@ public class LazySubstitutingClassDescriptor implements ClassDescriptor {
|
||||
if (typeConstructor == null) {
|
||||
TypeSubstitutor substitutor = getSubstitutor();
|
||||
|
||||
Collection<KtType> originalSupertypes = originalTypeConstructor.getSupertypes();
|
||||
Collection<KtType> supertypes = new ArrayList<KtType>(originalSupertypes.size());
|
||||
for (KtType supertype : originalSupertypes) {
|
||||
Collection<KotlinType> originalSupertypes = originalTypeConstructor.getSupertypes();
|
||||
Collection<KotlinType> supertypes = new ArrayList<KotlinType>(originalSupertypes.size());
|
||||
for (KotlinType supertype : originalSupertypes) {
|
||||
supertypes.add(substitutor.substitute(supertype, Variance.INVARIANT));
|
||||
}
|
||||
|
||||
@@ -125,9 +125,9 @@ public class LazySubstitutingClassDescriptor implements ClassDescriptor {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public KtType getDefaultType() {
|
||||
public KotlinType getDefaultType() {
|
||||
List<TypeProjection> typeProjections = TypeUtils.getDefaultTypeProjections(getTypeConstructor().getParameters());
|
||||
return KtTypeImpl.create(
|
||||
return KotlinTypeImpl.create(
|
||||
getAnnotations(),
|
||||
this,
|
||||
false,
|
||||
|
||||
+9
-9
@@ -24,7 +24,7 @@ import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.resolve.DescriptorFactory;
|
||||
import org.jetbrains.kotlin.types.DescriptorSubstitutor;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.TypeSubstitutor;
|
||||
import org.jetbrains.kotlin.types.Variance;
|
||||
import org.jetbrains.kotlin.utils.SmartSet;
|
||||
@@ -89,17 +89,17 @@ public class PropertyDescriptorImpl extends VariableDescriptorWithInitializerImp
|
||||
}
|
||||
|
||||
public void setType(
|
||||
@NotNull KtType outType,
|
||||
@NotNull KotlinType outType,
|
||||
@ReadOnly @NotNull List<? extends TypeParameterDescriptor> typeParameters,
|
||||
@Nullable ReceiverParameterDescriptor dispatchReceiverParameter,
|
||||
@Nullable KtType receiverType
|
||||
@Nullable KotlinType receiverType
|
||||
) {
|
||||
ReceiverParameterDescriptor extensionReceiverParameter = DescriptorFactory.createExtensionReceiverParameterForCallable(this, receiverType);
|
||||
setType(outType, typeParameters, dispatchReceiverParameter, extensionReceiverParameter);
|
||||
}
|
||||
|
||||
public void setType(
|
||||
@NotNull KtType outType,
|
||||
@NotNull KotlinType outType,
|
||||
@ReadOnly @NotNull List<? extends TypeParameterDescriptor> typeParameters,
|
||||
@Nullable ReceiverParameterDescriptor dispatchReceiverParameter,
|
||||
@Nullable ReceiverParameterDescriptor extensionReceiverParameter
|
||||
@@ -145,7 +145,7 @@ public class PropertyDescriptorImpl extends VariableDescriptorWithInitializerImp
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public KtType getReturnType() {
|
||||
public KotlinType getReturnType() {
|
||||
return getType();
|
||||
}
|
||||
|
||||
@@ -227,8 +227,8 @@ public class PropertyDescriptorImpl extends VariableDescriptorWithInitializerImp
|
||||
originalTypeParameters, originalSubstitutor.getSubstitution(), substitutedDescriptor, substitutedTypeParameters
|
||||
);
|
||||
|
||||
KtType originalOutType = getType();
|
||||
KtType outType = substitutor.substitute(originalOutType, Variance.OUT_VARIANCE);
|
||||
KotlinType originalOutType = getType();
|
||||
KotlinType outType = substitutor.substitute(originalOutType, Variance.OUT_VARIANCE);
|
||||
if (outType == null) {
|
||||
return null; // TODO : tell the user that the property was projected out
|
||||
}
|
||||
@@ -244,7 +244,7 @@ public class PropertyDescriptorImpl extends VariableDescriptorWithInitializerImp
|
||||
substitutedDispatchReceiver = null;
|
||||
}
|
||||
|
||||
KtType substitutedReceiverType;
|
||||
KotlinType substitutedReceiverType;
|
||||
if (extensionReceiverParameter != null) {
|
||||
substitutedReceiverType = substitutor.substitute(extensionReceiverParameter.getType(), Variance.IN_VARIANCE);
|
||||
if (substitutedReceiverType == null) return null;
|
||||
@@ -260,7 +260,7 @@ public class PropertyDescriptorImpl extends VariableDescriptorWithInitializerImp
|
||||
getter.hasBody(), getter.isDefault(), getter.isExternal(), kind, original == null ? null : original.getGetter(), SourceElement.NO_SOURCE
|
||||
);
|
||||
if (newGetter != null) {
|
||||
KtType returnType = getter.getReturnType();
|
||||
KotlinType returnType = getter.getReturnType();
|
||||
newGetter.initialize(returnType != null ? substitutor.substitute(returnType, Variance.OUT_VARIANCE) : null);
|
||||
}
|
||||
PropertySetterDescriptorImpl newSetter = setter == null ? null : new PropertySetterDescriptorImpl(
|
||||
|
||||
+4
-4
@@ -21,14 +21,14 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class PropertyGetterDescriptorImpl extends PropertyAccessorDescriptorImpl implements PropertyGetterDescriptor {
|
||||
private KtType returnType;
|
||||
private KotlinType returnType;
|
||||
|
||||
@NotNull
|
||||
private final PropertyGetterDescriptor original;
|
||||
@@ -51,7 +51,7 @@ public class PropertyGetterDescriptorImpl extends PropertyAccessorDescriptorImpl
|
||||
this.original = original != null ? original : this;
|
||||
}
|
||||
|
||||
public void initialize(KtType returnType) {
|
||||
public void initialize(KotlinType returnType) {
|
||||
this.returnType = returnType == null ? getCorrespondingProperty().getType() : returnType;
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ public class PropertyGetterDescriptorImpl extends PropertyAccessorDescriptorImpl
|
||||
}
|
||||
|
||||
@Override
|
||||
public KtType getReturnType() {
|
||||
public KotlinType getReturnType() {
|
||||
return returnType;
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -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.name.Name;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@@ -64,7 +64,7 @@ public class PropertySetterDescriptorImpl extends PropertyAccessorDescriptorImpl
|
||||
|
||||
public static ValueParameterDescriptorImpl createSetterParameter(
|
||||
@NotNull PropertySetterDescriptor setterDescriptor,
|
||||
@NotNull KtType type
|
||||
@NotNull KotlinType type
|
||||
) {
|
||||
return new ValueParameterDescriptorImpl(
|
||||
setterDescriptor, null, 0, Annotations.Companion.getEMPTY(), Name.special("<set-?>"), type,
|
||||
@@ -93,7 +93,7 @@ public class PropertySetterDescriptorImpl extends PropertyAccessorDescriptorImpl
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public KtType getReturnType() {
|
||||
public KotlinType getReturnType() {
|
||||
return getBuiltIns(this).getUnitType();
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -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.name.Name;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -35,7 +35,7 @@ public class ScriptCodeDescriptor extends FunctionDescriptorImpl {
|
||||
public void initialize(
|
||||
@NotNull ReceiverParameterDescriptor dispatchReceiverParameter,
|
||||
@NotNull List<ValueParameterDescriptor> valueParameters,
|
||||
@NotNull KtType returnType) {
|
||||
@NotNull KotlinType returnType) {
|
||||
super.initialize(null, dispatchReceiverParameter, Collections.<TypeParameterDescriptor>emptyList(), valueParameters, returnType,
|
||||
Modality.FINAL, Visibilities.INTERNAL);
|
||||
}
|
||||
|
||||
+3
-3
@@ -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.name.Name;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.TypeSubstitutor;
|
||||
|
||||
import java.util.List;
|
||||
@@ -52,11 +52,11 @@ public class SimpleFunctionDescriptorImpl extends FunctionDescriptorImpl impleme
|
||||
@NotNull
|
||||
@Override
|
||||
public SimpleFunctionDescriptorImpl initialize(
|
||||
@Nullable KtType receiverParameterType,
|
||||
@Nullable KotlinType receiverParameterType,
|
||||
@Nullable ReceiverParameterDescriptor dispatchReceiverParameter,
|
||||
@NotNull List<? extends TypeParameterDescriptor> typeParameters,
|
||||
@NotNull List<ValueParameterDescriptor> unsubstitutedValueParameters,
|
||||
@Nullable KtType unsubstitutedReturnType,
|
||||
@Nullable KotlinType unsubstitutedReturnType,
|
||||
@Nullable Modality modality,
|
||||
@NotNull Visibility visibility
|
||||
) {
|
||||
|
||||
+5
-5
@@ -24,7 +24,7 @@ import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
||||
import org.jetbrains.kotlin.storage.LockBasedStorageManager;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.TypeConstructor;
|
||||
import org.jetbrains.kotlin.types.TypeConstructorImpl;
|
||||
import org.jetbrains.kotlin.types.Variance;
|
||||
@@ -63,7 +63,7 @@ public class TypeParameterDescriptorImpl extends AbstractTypeParameterDescriptor
|
||||
return new TypeParameterDescriptorImpl(containingDeclaration, annotations, reified, variance, name, index, source);
|
||||
}
|
||||
|
||||
private final Set<KtType> upperBounds = SmartSet.create();
|
||||
private final Set<KotlinType> upperBounds = SmartSet.create();
|
||||
private boolean initialized = false;
|
||||
|
||||
private TypeParameterDescriptorImpl(
|
||||
@@ -113,12 +113,12 @@ public class TypeParameterDescriptorImpl extends AbstractTypeParameterDescriptor
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
public void addUpperBound(@NotNull KtType bound) {
|
||||
public void addUpperBound(@NotNull KotlinType bound) {
|
||||
checkUninitialized();
|
||||
doAddUpperBound(bound);
|
||||
}
|
||||
|
||||
private void doAddUpperBound(KtType bound) {
|
||||
private void doAddUpperBound(KotlinType bound) {
|
||||
upperBounds.add(bound); // TODO : Duplicates?
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ public class TypeParameterDescriptorImpl extends AbstractTypeParameterDescriptor
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected Set<KtType> resolveUpperBounds() {
|
||||
protected Set<KotlinType> resolveUpperBounds() {
|
||||
checkInitialized();
|
||||
return upperBounds;
|
||||
}
|
||||
|
||||
+5
-5
@@ -24,7 +24,7 @@ import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.resolve.constants.ConstantValue;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.TypeSubstitutor;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -33,7 +33,7 @@ public class ValueParameterDescriptorImpl extends VariableDescriptorImpl impleme
|
||||
private final boolean declaresDefaultValue;
|
||||
private final boolean isCrossinline;
|
||||
private final boolean isNoinline;
|
||||
private final KtType varargElementType;
|
||||
private final KotlinType varargElementType;
|
||||
private final int index;
|
||||
private final ValueParameterDescriptor original;
|
||||
|
||||
@@ -43,11 +43,11 @@ public class ValueParameterDescriptorImpl extends VariableDescriptorImpl impleme
|
||||
int index,
|
||||
@NotNull Annotations annotations,
|
||||
@NotNull Name name,
|
||||
@NotNull KtType outType,
|
||||
@NotNull KotlinType outType,
|
||||
boolean declaresDefaultValue,
|
||||
boolean isCrossinline,
|
||||
boolean isNoinline,
|
||||
@Nullable KtType varargElementType,
|
||||
@Nullable KotlinType varargElementType,
|
||||
@NotNull SourceElement source
|
||||
) {
|
||||
super(containingDeclaration, annotations, name, outType, source);
|
||||
@@ -87,7 +87,7 @@ public class ValueParameterDescriptorImpl extends VariableDescriptorImpl impleme
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public KtType getVarargElementType() {
|
||||
public KotlinType getVarargElementType() {
|
||||
return varargElementType;
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -21,20 +21,20 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class VariableDescriptorImpl extends DeclarationDescriptorNonRootImpl implements VariableDescriptor {
|
||||
protected KtType outType;
|
||||
protected KotlinType outType;
|
||||
|
||||
public VariableDescriptorImpl(
|
||||
@NotNull DeclarationDescriptor containingDeclaration,
|
||||
@NotNull Annotations annotations,
|
||||
@NotNull Name name,
|
||||
@Nullable KtType outType,
|
||||
@Nullable KotlinType outType,
|
||||
@NotNull SourceElement source
|
||||
) {
|
||||
super(containingDeclaration, annotations, name, source);
|
||||
@@ -44,11 +44,11 @@ public abstract class VariableDescriptorImpl extends DeclarationDescriptorNonRoo
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public KtType getType() {
|
||||
public KotlinType getType() {
|
||||
return outType;
|
||||
}
|
||||
|
||||
public void setOutType(KtType outType) {
|
||||
public void setOutType(KotlinType outType) {
|
||||
assert this.outType == null;
|
||||
this.outType = outType;
|
||||
}
|
||||
@@ -99,7 +99,7 @@ public abstract class VariableDescriptorImpl extends DeclarationDescriptorNonRoo
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public KtType getReturnType() {
|
||||
public KotlinType getReturnType() {
|
||||
return getType();
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -24,7 +24,7 @@ import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.resolve.constants.ConstantValue;
|
||||
import org.jetbrains.kotlin.storage.NullableLazyValue;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.LazyType;
|
||||
|
||||
public abstract class VariableDescriptorWithInitializerImpl extends VariableDescriptorImpl {
|
||||
@@ -36,7 +36,7 @@ public abstract class VariableDescriptorWithInitializerImpl extends VariableDesc
|
||||
@NotNull DeclarationDescriptor containingDeclaration,
|
||||
@NotNull Annotations annotations,
|
||||
@NotNull Name name,
|
||||
@Nullable KtType outType,
|
||||
@Nullable KotlinType outType,
|
||||
boolean isVar,
|
||||
@NotNull SourceElement source
|
||||
) {
|
||||
|
||||
@@ -17,10 +17,10 @@
|
||||
package org.jetbrains.kotlin.renderer
|
||||
|
||||
import org.jetbrains.kotlin.types.Flexibility
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.TypeCapability
|
||||
|
||||
public interface CustomFlexibleRendering : TypeCapability {
|
||||
public fun renderInflexible(type: KtType, renderer: DescriptorRenderer): String?
|
||||
public fun renderInflexible(type: KotlinType, renderer: DescriptorRenderer): String?
|
||||
public fun renderBounds(flexibility: Flexibility, renderer: DescriptorRenderer): Pair<String, String>?
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.FqNameBase
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.TypeConstructor
|
||||
import org.jetbrains.kotlin.types.TypeProjection
|
||||
|
||||
@@ -34,7 +34,7 @@ public abstract class DescriptorRenderer : Renderer<DeclarationDescriptor> {
|
||||
return DescriptorRendererImpl(options)
|
||||
}
|
||||
|
||||
public abstract fun renderType(type: KtType): String
|
||||
public abstract fun renderType(type: KotlinType): String
|
||||
|
||||
public abstract fun renderTypeArguments(typeArguments: List<TypeProjection>): String
|
||||
|
||||
@@ -184,7 +184,7 @@ public interface DescriptorRendererOptions {
|
||||
public var receiverAfterName: Boolean
|
||||
public var renderCompanionObjectName: Boolean
|
||||
public var withoutSuperTypes: Boolean
|
||||
public var typeNormalizer: (KtType) -> KtType
|
||||
public var typeNormalizer: (KotlinType) -> KotlinType
|
||||
public var renderDefaultValues: Boolean
|
||||
public var flexibleTypesForCode: Boolean
|
||||
public var secondaryConstructorsAsPrimary: Boolean
|
||||
|
||||
@@ -146,11 +146,11 @@ internal class DescriptorRendererImpl(
|
||||
}
|
||||
|
||||
/* TYPES RENDERING */
|
||||
override fun renderType(type: KtType): String {
|
||||
override fun renderType(type: KotlinType): String {
|
||||
return renderNormalizedType(typeNormalizer(type))
|
||||
}
|
||||
|
||||
private fun renderNormalizedType(type: KtType): String {
|
||||
private fun renderNormalizedType(type: KotlinType): String {
|
||||
if (type is LazyType && debugMode) {
|
||||
return type.toString()
|
||||
}
|
||||
@@ -172,13 +172,13 @@ internal class DescriptorRendererImpl(
|
||||
return renderInflexibleType(type)
|
||||
}
|
||||
|
||||
private fun renderFlexibleTypeWithBothBounds(lower: KtType, upper: KtType): String {
|
||||
private fun renderFlexibleTypeWithBothBounds(lower: KotlinType, upper: KotlinType): String {
|
||||
return renderFlexibleTypeWithBothBounds(renderNormalizedType(lower), renderNormalizedType(upper))
|
||||
}
|
||||
|
||||
private fun renderFlexibleTypeWithBothBounds(lower: String, upper: String) = "($lower..$upper)"
|
||||
|
||||
private fun renderInflexibleType(type: KtType): String {
|
||||
private fun renderInflexibleType(type: KotlinType): String {
|
||||
assert(!type.isFlexible()) { "Flexible types not allowed here: " + renderNormalizedType(type) }
|
||||
|
||||
val customResult = type.getCapability<CustomFlexibleRendering>()?.renderInflexible(type, this)
|
||||
@@ -202,12 +202,12 @@ internal class DescriptorRendererImpl(
|
||||
return renderDefaultType(type)
|
||||
}
|
||||
|
||||
private fun shouldRenderAsPrettyFunctionType(type: KtType): Boolean {
|
||||
private fun shouldRenderAsPrettyFunctionType(type: KotlinType): Boolean {
|
||||
return prettyFunctionTypes && KotlinBuiltIns.isExactFunctionOrExtensionFunctionType(type)
|
||||
&& type.getArguments().none { it.isStarProjection() }
|
||||
}
|
||||
|
||||
private fun renderFlexibleType(type: KtType): String {
|
||||
private fun renderFlexibleType(type: KotlinType): String {
|
||||
val lower = type.flexibility().lowerBound
|
||||
val upper = type.flexibility().upperBound
|
||||
|
||||
@@ -246,7 +246,7 @@ internal class DescriptorRendererImpl(
|
||||
}.toString()
|
||||
}
|
||||
|
||||
private fun renderDefaultType(type: KtType): String {
|
||||
private fun renderDefaultType(type: KotlinType): String {
|
||||
val sb = StringBuilder()
|
||||
|
||||
renderAnnotations(type, sb, /* needBrackets = */ true)
|
||||
@@ -290,7 +290,7 @@ internal class DescriptorRendererImpl(
|
||||
}.joinTo(builder, ", ")
|
||||
}
|
||||
|
||||
private fun renderFunctionType(type: KtType): String {
|
||||
private fun renderFunctionType(type: KotlinType): String {
|
||||
return StringBuilder {
|
||||
val isNullable = type.isMarkedNullable()
|
||||
if (isNullable) append("(")
|
||||
@@ -338,7 +338,7 @@ internal class DescriptorRendererImpl(
|
||||
private fun renderAnnotations(annotated: Annotated, builder: StringBuilder, needBrackets: Boolean = false) {
|
||||
if (DescriptorRendererModifier.ANNOTATIONS !in modifiers) return
|
||||
|
||||
val excluded = if (annotated is KtType) excludedTypeAnnotationClasses else excludedAnnotationClasses
|
||||
val excluded = if (annotated is KotlinType) excludedTypeAnnotationClasses else excludedAnnotationClasses
|
||||
|
||||
val annotationsBuilder = StringBuilder {
|
||||
// Sort is needed just to fix some order when annotations resolved from modifiers
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package org.jetbrains.kotlin.renderer
|
||||
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import java.lang.reflect.Modifier
|
||||
import kotlin.properties.Delegates
|
||||
import kotlin.properties.ObservableProperty
|
||||
@@ -92,7 +92,7 @@ internal class DescriptorRendererOptionsImpl : DescriptorRendererOptions {
|
||||
override var includePropertyConstant by property(false)
|
||||
override var withoutTypeParameters by property(false)
|
||||
override var withoutSuperTypes by property(false)
|
||||
override var typeNormalizer by property<(KtType) -> KtType>({ it })
|
||||
override var typeNormalizer by property<(KotlinType) -> KotlinType>({ it })
|
||||
override var renderDefaultValues by property(true)
|
||||
override var flexibleTypesForCode by property(false)
|
||||
override var secondaryConstructorsAsPrimary by property(true)
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.jetbrains.kotlin.descriptors.annotations.AnnotationsImpl;
|
||||
import org.jetbrains.kotlin.descriptors.impl.*;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ExtensionReceiver;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.Variance;
|
||||
|
||||
import java.util.Collections;
|
||||
@@ -141,13 +141,13 @@ public class DescriptorFactory {
|
||||
/* lateInit = */ false, /* isConst = */ false
|
||||
);
|
||||
|
||||
KtType type = getBuiltIns(enumClass).getArrayType(Variance.INVARIANT, enumClass.getDefaultType());
|
||||
KotlinType type = getBuiltIns(enumClass).getArrayType(Variance.INVARIANT, enumClass.getDefaultType());
|
||||
|
||||
PropertyGetterDescriptorImpl getter = createDefaultGetter(values, Annotations.Companion.getEMPTY());
|
||||
|
||||
values.initialize(getter, null);
|
||||
getter.initialize(type);
|
||||
values.setType(type, Collections.<TypeParameterDescriptor>emptyList(), null, (KtType) null);
|
||||
values.setType(type, Collections.<TypeParameterDescriptor>emptyList(), null, (KotlinType) null);
|
||||
|
||||
return values;
|
||||
}
|
||||
@@ -173,7 +173,7 @@ public class DescriptorFactory {
|
||||
@Nullable
|
||||
public static ReceiverParameterDescriptor createExtensionReceiverParameterForCallable(
|
||||
@NotNull CallableDescriptor owner,
|
||||
@Nullable KtType receiverParameterType
|
||||
@Nullable KotlinType receiverParameterType
|
||||
) {
|
||||
return receiverParameterType == null
|
||||
? null
|
||||
|
||||
@@ -38,7 +38,7 @@ import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter;
|
||||
import org.jetbrains.kotlin.resolve.scopes.FilteringScope;
|
||||
import org.jetbrains.kotlin.resolve.scopes.KtScope;
|
||||
import org.jetbrains.kotlin.types.ErrorUtils;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.LazyType;
|
||||
import org.jetbrains.kotlin.types.TypeConstructor;
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
|
||||
@@ -244,7 +244,7 @@ public class DescriptorUtils {
|
||||
}
|
||||
|
||||
public static boolean isDirectSubclass(@NotNull ClassDescriptor subClass, @NotNull ClassDescriptor superClass) {
|
||||
for (KtType superType : subClass.getTypeConstructor().getSupertypes()) {
|
||||
for (KotlinType superType : subClass.getTypeConstructor().getSupertypes()) {
|
||||
if (isSameClass(superType, superClass.getOriginal())) {
|
||||
return true;
|
||||
}
|
||||
@@ -256,7 +256,7 @@ public class DescriptorUtils {
|
||||
return isSubtypeOfClass(subClass.getDefaultType(), superClass.getOriginal());
|
||||
}
|
||||
|
||||
private static boolean isSameClass(@NotNull KtType type, @NotNull DeclarationDescriptor other) {
|
||||
private static boolean isSameClass(@NotNull KotlinType type, @NotNull DeclarationDescriptor other) {
|
||||
DeclarationDescriptor descriptor = type.getConstructor().getDeclarationDescriptor();
|
||||
if (descriptor != null) {
|
||||
DeclarationDescriptor originalDescriptor = descriptor.getOriginal();
|
||||
@@ -270,9 +270,9 @@ public class DescriptorUtils {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean isSubtypeOfClass(@NotNull KtType type, @NotNull DeclarationDescriptor superClass) {
|
||||
private static boolean isSubtypeOfClass(@NotNull KotlinType type, @NotNull DeclarationDescriptor superClass) {
|
||||
if (isSameClass(type, superClass)) return true;
|
||||
for (KtType superType : type.getConstructor().getSupertypes()) {
|
||||
for (KotlinType superType : type.getConstructor().getSupertypes()) {
|
||||
if (isSubtypeOfClass(superType, superClass)) {
|
||||
return true;
|
||||
}
|
||||
@@ -349,9 +349,9 @@ public class DescriptorUtils {
|
||||
|
||||
@NotNull
|
||||
public static List<ClassDescriptor> getSuperclassDescriptors(@NotNull ClassDescriptor classDescriptor) {
|
||||
Collection<KtType> superclassTypes = classDescriptor.getTypeConstructor().getSupertypes();
|
||||
Collection<KotlinType> superclassTypes = classDescriptor.getTypeConstructor().getSupertypes();
|
||||
List<ClassDescriptor> superClassDescriptors = new ArrayList<ClassDescriptor>();
|
||||
for (KtType type : superclassTypes) {
|
||||
for (KotlinType type : superclassTypes) {
|
||||
ClassDescriptor result = getClassDescriptorForType(type);
|
||||
if (!isAny(result)) {
|
||||
superClassDescriptors.add(result);
|
||||
@@ -361,9 +361,9 @@ public class DescriptorUtils {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static KtType getSuperClassType(@NotNull ClassDescriptor classDescriptor) {
|
||||
Collection<KtType> superclassTypes = classDescriptor.getTypeConstructor().getSupertypes();
|
||||
for (KtType type : superclassTypes) {
|
||||
public static KotlinType getSuperClassType(@NotNull ClassDescriptor classDescriptor) {
|
||||
Collection<KotlinType> superclassTypes = classDescriptor.getTypeConstructor().getSupertypes();
|
||||
for (KotlinType type : superclassTypes) {
|
||||
ClassDescriptor superClassDescriptor = getClassDescriptorForType(type);
|
||||
if (superClassDescriptor.getKind() != ClassKind.INTERFACE) {
|
||||
return type;
|
||||
@@ -374,8 +374,8 @@ public class DescriptorUtils {
|
||||
|
||||
@Nullable
|
||||
public static ClassDescriptor getSuperClassDescriptor(@NotNull ClassDescriptor classDescriptor) {
|
||||
Collection<KtType> superclassTypes = classDescriptor.getTypeConstructor().getSupertypes();
|
||||
for (KtType type : superclassTypes) {
|
||||
Collection<KotlinType> superclassTypes = classDescriptor.getTypeConstructor().getSupertypes();
|
||||
for (KotlinType type : superclassTypes) {
|
||||
ClassDescriptor superClassDescriptor = getClassDescriptorForType(type);
|
||||
if (superClassDescriptor.getKind() != ClassKind.INTERFACE) {
|
||||
return superClassDescriptor;
|
||||
@@ -385,7 +385,7 @@ public class DescriptorUtils {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static ClassDescriptor getClassDescriptorForType(@NotNull KtType type) {
|
||||
public static ClassDescriptor getClassDescriptorForType(@NotNull KotlinType type) {
|
||||
return getClassDescriptorForTypeConstructor(type.getConstructor());
|
||||
}
|
||||
|
||||
@@ -422,7 +422,7 @@ public class DescriptorUtils {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static KtType getReceiverParameterType(@Nullable ReceiverParameterDescriptor receiverParameterDescriptor) {
|
||||
public static KotlinType getReceiverParameterType(@Nullable ReceiverParameterDescriptor receiverParameterDescriptor) {
|
||||
return receiverParameterDescriptor == null ? null : receiverParameterDescriptor.getType();
|
||||
}
|
||||
|
||||
@@ -474,7 +474,7 @@ public class DescriptorUtils {
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
public static boolean shouldRecordInitializerForProperty(@NotNull VariableDescriptor variable, @NotNull KtType type) {
|
||||
public static boolean shouldRecordInitializerForProperty(@NotNull VariableDescriptor variable, @NotNull KotlinType type) {
|
||||
if (variable.isVar() || type.isError()) return false;
|
||||
|
||||
if (type instanceof LazyType || type.isMarkedNullable()) return true;
|
||||
|
||||
@@ -29,7 +29,7 @@ import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.FqNameUnsafe
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.constants.EnumValue
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.utils.DFS
|
||||
|
||||
public fun ClassDescriptor.getClassObjectReferenceTarget(): ClassDescriptor = getCompanionObjectDescriptor() ?: this
|
||||
@@ -74,7 +74,7 @@ public val ClassDescriptor.classId: ClassId
|
||||
public val ClassDescriptor.hasClassObjectType: Boolean get() = classObjectType != null
|
||||
|
||||
/** If a literal of this class can be used as a value, returns the type of this value */
|
||||
public val ClassDescriptor.classObjectType: KtType?
|
||||
public val ClassDescriptor.classObjectType: KotlinType?
|
||||
get() {
|
||||
val correspondingDescriptor = when (this.getKind()) {
|
||||
OBJECT -> this
|
||||
|
||||
@@ -27,7 +27,7 @@ import org.jetbrains.kotlin.descriptors.impl.PropertyAccessorDescriptorImpl;
|
||||
import org.jetbrains.kotlin.descriptors.impl.PropertyDescriptorImpl;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.TypeConstructor;
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
|
||||
import org.jetbrains.kotlin.utils.DFS;
|
||||
@@ -98,16 +98,16 @@ public class OverridingUtil {
|
||||
return receiverAndParameterResult;
|
||||
}
|
||||
|
||||
List<KtType> superValueParameters = compiledValueParameters(superDescriptor);
|
||||
List<KtType> subValueParameters = compiledValueParameters(subDescriptor);
|
||||
List<KotlinType> superValueParameters = compiledValueParameters(superDescriptor);
|
||||
List<KotlinType> subValueParameters = compiledValueParameters(subDescriptor);
|
||||
|
||||
List<TypeParameterDescriptor> superTypeParameters = superDescriptor.getTypeParameters();
|
||||
List<TypeParameterDescriptor> subTypeParameters = subDescriptor.getTypeParameters();
|
||||
|
||||
if (superTypeParameters.size() != subTypeParameters.size()) {
|
||||
for (int i = 0; i < superValueParameters.size(); ++i) {
|
||||
KtType superValueParameterType = getUpperBound(superValueParameters.get(i));
|
||||
KtType subValueParameterType = getUpperBound(subValueParameters.get(i));
|
||||
KotlinType superValueParameterType = getUpperBound(superValueParameters.get(i));
|
||||
KotlinType subValueParameterType = getUpperBound(subValueParameters.get(i));
|
||||
// TODO: compare erasure
|
||||
if (!KotlinTypeChecker.DEFAULT.equalTypes(superValueParameterType, subValueParameterType)) {
|
||||
return OverrideCompatibilityInfo.typeParameterNumberMismatch();
|
||||
@@ -147,8 +147,8 @@ public class OverridingUtil {
|
||||
}
|
||||
|
||||
for (int i = 0, unsubstitutedValueParametersSize = superValueParameters.size(); i < unsubstitutedValueParametersSize; i++) {
|
||||
KtType superValueParameter = superValueParameters.get(i);
|
||||
KtType subValueParameter = subValueParameters.get(i);
|
||||
KotlinType superValueParameter = superValueParameters.get(i);
|
||||
KotlinType subValueParameter = subValueParameters.get(i);
|
||||
|
||||
if (!areTypesEquivalent(superValueParameter, subValueParameter, localEqualityAxioms)) {
|
||||
return OverrideCompatibilityInfo.valueParameterTypeMismatch(superValueParameter, subValueParameter, INCOMPATIBLE);
|
||||
@@ -156,8 +156,8 @@ public class OverridingUtil {
|
||||
}
|
||||
|
||||
if (checkReturnType) {
|
||||
KtType superReturnType = superDescriptor.getReturnType();
|
||||
KtType subReturnType = subDescriptor.getReturnType();
|
||||
KotlinType superReturnType = superDescriptor.getReturnType();
|
||||
KotlinType subReturnType = subDescriptor.getReturnType();
|
||||
|
||||
if (superReturnType != null && subReturnType != null) {
|
||||
boolean bothErrors = subReturnType.isError() && superReturnType.isError();
|
||||
@@ -194,8 +194,8 @@ public class OverridingUtil {
|
||||
}
|
||||
|
||||
private static boolean areTypesEquivalent(
|
||||
@NotNull KtType typeInSuper,
|
||||
@NotNull KtType typeInSub,
|
||||
@NotNull KotlinType typeInSuper,
|
||||
@NotNull KotlinType typeInSub,
|
||||
@NotNull KotlinTypeChecker.TypeConstructorEquality axioms
|
||||
) {
|
||||
boolean bothErrors = typeInSuper.isError() && typeInSub.isError();
|
||||
@@ -205,9 +205,9 @@ public class OverridingUtil {
|
||||
return true;
|
||||
}
|
||||
|
||||
static List<KtType> compiledValueParameters(CallableDescriptor callableDescriptor) {
|
||||
static List<KotlinType> compiledValueParameters(CallableDescriptor callableDescriptor) {
|
||||
ReceiverParameterDescriptor receiverParameter = callableDescriptor.getExtensionReceiverParameter();
|
||||
ArrayList<KtType> parameters = new ArrayList<KtType>();
|
||||
ArrayList<KotlinType> parameters = new ArrayList<KotlinType>();
|
||||
if (receiverParameter != null) {
|
||||
parameters.add(receiverParameter.getType());
|
||||
}
|
||||
@@ -217,7 +217,7 @@ public class OverridingUtil {
|
||||
return parameters;
|
||||
}
|
||||
|
||||
static KtType getUpperBound(KtType type) {
|
||||
static KotlinType getUpperBound(KotlinType type) {
|
||||
if (type.getConstructor().getDeclarationDescriptor() instanceof ClassDescriptor) {
|
||||
return type;
|
||||
}
|
||||
@@ -297,9 +297,9 @@ public class OverridingUtil {
|
||||
if (a instanceof SimpleFunctionDescriptor) {
|
||||
assert b instanceof SimpleFunctionDescriptor : "b is " + b.getClass();
|
||||
|
||||
KtType aReturnType = a.getReturnType();
|
||||
KotlinType aReturnType = a.getReturnType();
|
||||
assert aReturnType != null;
|
||||
KtType bReturnType = b.getReturnType();
|
||||
KotlinType bReturnType = b.getReturnType();
|
||||
assert bReturnType != null;
|
||||
|
||||
return KotlinTypeChecker.DEFAULT.isSubtypeOf(aReturnType, bReturnType);
|
||||
@@ -569,7 +569,7 @@ public class OverridingUtil {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static OverrideCompatibilityInfo valueParameterTypeMismatch(KtType superValueParameter, KtType subValueParameter, Result result) {
|
||||
public static OverrideCompatibilityInfo valueParameterTypeMismatch(KotlinType superValueParameter, KotlinType subValueParameter, Result result) {
|
||||
return new OverrideCompatibilityInfo(result, "valueParameterTypeMismatch"); // TODO
|
||||
}
|
||||
|
||||
@@ -579,7 +579,7 @@ public class OverridingUtil {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static OverrideCompatibilityInfo returnTypeMismatch(KtType substitutedSuperReturnType, KtType unsubstitutedSubReturnType) {
|
||||
public static OverrideCompatibilityInfo returnTypeMismatch(KotlinType substitutedSuperReturnType, KotlinType unsubstitutedSubReturnType) {
|
||||
return new OverrideCompatibilityInfo(Result.CONFLICT, "returnTypeMismatch: " + unsubstitutedSubReturnType + " >< " + substitutedSuperReturnType); // TODO
|
||||
}
|
||||
|
||||
|
||||
@@ -20,14 +20,14 @@ import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
private val NO_INFER_ANNOTATION_FQ_NAME = FqName("kotlin.internal.NoInfer")
|
||||
private val EXACT_ANNOTATION_FQ_NAME = FqName("kotlin.internal.Exact")
|
||||
|
||||
public fun KtType.hasNoInferAnnotation(): Boolean = annotations.hasAnnotation(NO_INFER_ANNOTATION_FQ_NAME)
|
||||
public fun KotlinType.hasNoInferAnnotation(): Boolean = annotations.hasAnnotation(NO_INFER_ANNOTATION_FQ_NAME)
|
||||
|
||||
public fun KtType.hasExactAnnotation(): Boolean = annotations.hasAnnotation(EXACT_ANNOTATION_FQ_NAME)
|
||||
public fun KotlinType.hasExactAnnotation(): Boolean = annotations.hasAnnotation(EXACT_ANNOTATION_FQ_NAME)
|
||||
|
||||
public fun Annotations.hasInternalAnnotationForResolve(): Boolean =
|
||||
hasAnnotation(NO_INFER_ANNOTATION_FQ_NAME) || hasAnnotation(EXACT_ANNOTATION_FQ_NAME)
|
||||
|
||||
+9
-9
@@ -35,7 +35,7 @@ public class CapturedTypeConstructor(
|
||||
|
||||
override fun getParameters(): List<TypeParameterDescriptor> = listOf()
|
||||
|
||||
override fun getSupertypes(): Collection<KtType> {
|
||||
override fun getSupertypes(): Collection<KotlinType> {
|
||||
val superType = if (typeProjection.getProjectionKind() == Variance.OUT_VARIANCE)
|
||||
typeProjection.getType()
|
||||
else
|
||||
@@ -63,10 +63,10 @@ public class CapturedType(
|
||||
private val delegateType = run {
|
||||
val scope = ErrorUtils.createErrorScope(
|
||||
"No member resolution should be done on captured type, it used only during constraint system resolution", true)
|
||||
KtTypeImpl.create(Annotations.EMPTY, CapturedTypeConstructor(typeProjection), false, listOf(), scope)
|
||||
KotlinTypeImpl.create(Annotations.EMPTY, CapturedTypeConstructor(typeProjection), false, listOf(), scope)
|
||||
}
|
||||
|
||||
override fun getDelegate(): KtType = delegateType
|
||||
override fun getDelegate(): KotlinType = delegateType
|
||||
|
||||
override fun <T : TypeCapability> getCapability(capabilityClass: Class<T>): T? {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
@@ -74,20 +74,20 @@ public class CapturedType(
|
||||
else super<DelegatingType>.getCapability(capabilityClass)
|
||||
}
|
||||
|
||||
override val subTypeRepresentative: KtType
|
||||
override val subTypeRepresentative: KotlinType
|
||||
get() = representative(OUT_VARIANCE, builtIns.nullableAnyType)
|
||||
|
||||
override val superTypeRepresentative: KtType
|
||||
override val superTypeRepresentative: KotlinType
|
||||
get() = representative(IN_VARIANCE, builtIns.nothingType)
|
||||
|
||||
private fun representative(variance: Variance, default: KtType) =
|
||||
private fun representative(variance: Variance, default: KotlinType) =
|
||||
if (typeProjection.getProjectionKind() == variance) typeProjection.getType() else default
|
||||
|
||||
override fun sameTypeConstructor(type: KtType) = delegateType.getConstructor() === type.getConstructor()
|
||||
override fun sameTypeConstructor(type: KotlinType) = delegateType.getConstructor() === type.getConstructor()
|
||||
|
||||
override fun toString() = "Captured($typeProjection)"
|
||||
}
|
||||
|
||||
public fun createCapturedType(typeProjection: TypeProjection): KtType = CapturedType(typeProjection)
|
||||
public fun createCapturedType(typeProjection: TypeProjection): KotlinType = CapturedType(typeProjection)
|
||||
|
||||
public fun KtType.isCaptured(): Boolean = getConstructor() is CapturedTypeConstructor
|
||||
public fun KotlinType.isCaptured(): Boolean = getConstructor() is CapturedTypeConstructor
|
||||
|
||||
+3
-3
@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.resolve.calls.inference
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPosition
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.TypeSubstitutor
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
|
||||
@@ -47,7 +47,7 @@ public interface ConstraintSystem {
|
||||
* For example, for {@code "fun <T> id(t: T) {}"} to infer <tt>T</tt> in invocation <tt>"id(1)"</tt>
|
||||
* should be generated a constraint <tt>"Int is a subtype of T"</tt> where T is a subject type, and Int is a constraining type.
|
||||
*/
|
||||
public fun addSubtypeConstraint(constrainingType: KtType?, subjectType: KtType, constraintPosition: ConstraintPosition)
|
||||
public fun addSubtypeConstraint(constrainingType: KotlinType?, subjectType: KotlinType, constraintPosition: ConstraintPosition)
|
||||
|
||||
/**
|
||||
* Adds a constraint that the constraining type is a supertype of the subject type. <p/>
|
||||
@@ -56,7 +56,7 @@ public interface ConstraintSystem {
|
||||
* For example, for {@code "fun <T> create() : T"} to infer <tt>T</tt> in invocation <tt>"val i: Int = create()"</tt>
|
||||
* should be generated a constraint <tt>"Int is a supertype of T"</tt> where T is a subject type, and Int is a constraining type.
|
||||
*/
|
||||
public fun addSupertypeConstraint(constrainingType: KtType?, subjectType: KtType, constraintPosition: ConstraintPosition)
|
||||
public fun addSupertypeConstraint(constrainingType: KotlinType?, subjectType: KotlinType, constraintPosition: ConstraintPosition)
|
||||
|
||||
public fun getStatus(): ConstraintSystemStatus
|
||||
|
||||
|
||||
+31
-31
@@ -45,7 +45,7 @@ import java.util.*
|
||||
|
||||
public class ConstraintSystemImpl : ConstraintSystem {
|
||||
|
||||
data class Constraint(val kind: ConstraintKind, val subtype: KtType, val superType: KtType, val position: ConstraintPosition)
|
||||
data class Constraint(val kind: ConstraintKind, val subtype: KotlinType, val superType: KotlinType, val position: ConstraintPosition)
|
||||
|
||||
public enum class ConstraintKind {
|
||||
SUB_TYPE,
|
||||
@@ -60,7 +60,7 @@ public class ConstraintSystemImpl : ConstraintSystem {
|
||||
get() = if (externalTypeParameters.isEmpty()) allTypeParameterBounds
|
||||
else allTypeParameterBounds.filter { !externalTypeParameters.contains(it.key) }
|
||||
|
||||
private val cachedTypeForVariable = HashMap<TypeParameterDescriptor, KtType>()
|
||||
private val cachedTypeForVariable = HashMap<TypeParameterDescriptor, KotlinType>()
|
||||
|
||||
private val usedInBounds = HashMap<TypeParameterDescriptor, MutableList<TypeBounds.Bound>>()
|
||||
|
||||
@@ -165,16 +165,16 @@ public class ConstraintSystemImpl : ConstraintSystem {
|
||||
}
|
||||
}
|
||||
|
||||
val TypeParameterDescriptor.correspondingType: KtType
|
||||
val TypeParameterDescriptor.correspondingType: KotlinType
|
||||
get() = cachedTypeForVariable.getOrPut(this) {
|
||||
KtTypeImpl.create(Annotations.EMPTY, this.getTypeConstructor(), false, listOf(), KtScope.Empty)
|
||||
KotlinTypeImpl.create(Annotations.EMPTY, this.getTypeConstructor(), false, listOf(), KtScope.Empty)
|
||||
}
|
||||
|
||||
fun KtType.isProper() = !TypeUtils.containsSpecialType(this) {
|
||||
fun KotlinType.isProper() = !TypeUtils.containsSpecialType(this) {
|
||||
type -> type.getConstructor().getDeclarationDescriptor() in getAllTypeVariables()
|
||||
}
|
||||
|
||||
fun KtType.getNestedTypeVariables(original: Boolean = true): List<TypeParameterDescriptor> {
|
||||
fun KotlinType.getNestedTypeVariables(original: Boolean = true): List<TypeParameterDescriptor> {
|
||||
return getNestedArguments().map { typeProjection ->
|
||||
typeProjection.getType().getConstructor().getDeclarationDescriptor() as? TypeParameterDescriptor
|
||||
}.filterNotNull().filter { if (original) it in originalToVariables.keySet() else it in getAllTypeVariables() }
|
||||
@@ -206,22 +206,22 @@ public class ConstraintSystemImpl : ConstraintSystem {
|
||||
return newSystem
|
||||
}
|
||||
|
||||
override fun addSupertypeConstraint(constrainingType: KtType?, subjectType: KtType, constraintPosition: ConstraintPosition) {
|
||||
override fun addSupertypeConstraint(constrainingType: KotlinType?, subjectType: KotlinType, constraintPosition: ConstraintPosition) {
|
||||
if (constrainingType != null && TypeUtils.noExpectedType(constrainingType)) return
|
||||
|
||||
val newSubjectType = originalToVariablesSubstitutor.substitute(subjectType, Variance.INVARIANT)
|
||||
addConstraint(SUB_TYPE, newSubjectType, constrainingType, ConstraintContext(constraintPosition, initial = true))
|
||||
}
|
||||
|
||||
override fun addSubtypeConstraint(constrainingType: KtType?, subjectType: KtType, constraintPosition: ConstraintPosition) {
|
||||
override fun addSubtypeConstraint(constrainingType: KotlinType?, subjectType: KotlinType, constraintPosition: ConstraintPosition) {
|
||||
val newSubjectType = originalToVariablesSubstitutor.substitute(subjectType, Variance.INVARIANT)
|
||||
addConstraint(SUB_TYPE, constrainingType, newSubjectType, ConstraintContext(constraintPosition, initial = true))
|
||||
}
|
||||
|
||||
fun addConstraint(
|
||||
constraintKind: ConstraintKind,
|
||||
subType: KtType?,
|
||||
superType: KtType?,
|
||||
subType: KotlinType?,
|
||||
superType: KotlinType?,
|
||||
constraintContext: ConstraintContext
|
||||
) {
|
||||
val constraintPosition = constraintContext.position
|
||||
@@ -231,7 +231,7 @@ public class ConstraintSystemImpl : ConstraintSystem {
|
||||
val typeCheckingProcedure = TypeCheckingProcedure(object : TypeCheckingProcedureCallbacks {
|
||||
private var depth = 0
|
||||
|
||||
override fun assertEqualTypes(a: KtType, b: KtType, typeCheckingProcedure: TypeCheckingProcedure): Boolean {
|
||||
override fun assertEqualTypes(a: KotlinType, b: KotlinType, typeCheckingProcedure: TypeCheckingProcedure): Boolean {
|
||||
depth++
|
||||
doAddConstraint(EQUAL, a, b, newConstraintContext, typeCheckingProcedure)
|
||||
depth--
|
||||
@@ -243,14 +243,14 @@ public class ConstraintSystemImpl : ConstraintSystem {
|
||||
return a == b
|
||||
}
|
||||
|
||||
override fun assertSubtype(subtype: KtType, supertype: KtType, typeCheckingProcedure: TypeCheckingProcedure): Boolean {
|
||||
override fun assertSubtype(subtype: KotlinType, supertype: KotlinType, typeCheckingProcedure: TypeCheckingProcedure): Boolean {
|
||||
depth++
|
||||
doAddConstraint(SUB_TYPE, subtype, supertype, newConstraintContext, typeCheckingProcedure)
|
||||
depth--
|
||||
return true
|
||||
}
|
||||
|
||||
override fun capture(typeVariable: KtType, typeProjection: TypeProjection): Boolean {
|
||||
override fun capture(typeVariable: KotlinType, typeProjection: TypeProjection): Boolean {
|
||||
if (isMyTypeVariable(typeProjection.getType())) return false
|
||||
val myTypeVariable = getMyTypeVariable(typeVariable)
|
||||
|
||||
@@ -264,7 +264,7 @@ public class ConstraintSystemImpl : ConstraintSystem {
|
||||
return false
|
||||
}
|
||||
|
||||
override fun noCorrespondingSupertype(subtype: KtType, supertype: KtType): Boolean {
|
||||
override fun noCorrespondingSupertype(subtype: KotlinType, supertype: KotlinType): Boolean {
|
||||
errors.add(newTypeInferenceOrParameterConstraintError(constraintPosition))
|
||||
return true
|
||||
}
|
||||
@@ -272,7 +272,7 @@ public class ConstraintSystemImpl : ConstraintSystem {
|
||||
doAddConstraint(constraintKind, subType, superType, constraintContext, typeCheckingProcedure)
|
||||
}
|
||||
|
||||
private fun isErrorOrSpecialType(type: KtType?, constraintPosition: ConstraintPosition): Boolean {
|
||||
private fun isErrorOrSpecialType(type: KotlinType?, constraintPosition: ConstraintPosition): Boolean {
|
||||
if (TypeUtils.isDontCarePlaceholder(type) || ErrorUtils.isUninferredParameter(type)) {
|
||||
return true
|
||||
}
|
||||
@@ -286,8 +286,8 @@ public class ConstraintSystemImpl : ConstraintSystem {
|
||||
|
||||
private fun doAddConstraint(
|
||||
constraintKind: ConstraintKind,
|
||||
subType: KtType?,
|
||||
superType: KtType?,
|
||||
subType: KotlinType?,
|
||||
superType: KotlinType?,
|
||||
constraintContext: ConstraintContext,
|
||||
typeCheckingProcedure: TypeCheckingProcedure
|
||||
) {
|
||||
@@ -317,7 +317,7 @@ public class ConstraintSystemImpl : ConstraintSystem {
|
||||
subType
|
||||
}
|
||||
|
||||
fun simplifyConstraint(subType: KtType, superType: KtType) {
|
||||
fun simplifyConstraint(subType: KotlinType, superType: KotlinType) {
|
||||
if (isMyTypeVariable(subType)) {
|
||||
generateTypeParameterBound(subType, superType, constraintKind.toBound(), constraintContext)
|
||||
return
|
||||
@@ -348,7 +348,7 @@ public class ConstraintSystemImpl : ConstraintSystem {
|
||||
|
||||
fun addBound(
|
||||
typeVariable: TypeParameterDescriptor,
|
||||
constrainingType: KtType,
|
||||
constrainingType: KotlinType,
|
||||
kind: TypeBounds.BoundKind,
|
||||
constraintContext: ConstraintContext
|
||||
) {
|
||||
@@ -370,8 +370,8 @@ public class ConstraintSystemImpl : ConstraintSystem {
|
||||
}
|
||||
|
||||
private fun generateTypeParameterBound(
|
||||
parameterType: KtType,
|
||||
constrainingType: KtType,
|
||||
parameterType: KotlinType,
|
||||
constrainingType: KotlinType,
|
||||
boundKind: TypeBounds.BoundKind,
|
||||
constraintContext: ConstraintContext
|
||||
) {
|
||||
@@ -414,7 +414,7 @@ public class ConstraintSystemImpl : ConstraintSystem {
|
||||
}
|
||||
|
||||
private fun generateTypeParameterCaptureConstraint(
|
||||
parameterType: KtType,
|
||||
parameterType: KotlinType,
|
||||
constrainingTypeProjection: TypeProjection,
|
||||
constraintContext: ConstraintContext
|
||||
) {
|
||||
@@ -452,9 +452,9 @@ public class ConstraintSystemImpl : ConstraintSystem {
|
||||
|
||||
fun isMyTypeVariable(typeVariable: TypeParameterDescriptor) = allTypeParameterBounds.contains(typeVariable)
|
||||
|
||||
fun isMyTypeVariable(type: KtType): Boolean = getMyTypeVariable(type) != null
|
||||
fun isMyTypeVariable(type: KotlinType): Boolean = getMyTypeVariable(type) != null
|
||||
|
||||
fun getMyTypeVariable(type: KtType): TypeParameterDescriptor? {
|
||||
fun getMyTypeVariable(type: KotlinType): TypeParameterDescriptor? {
|
||||
val typeParameterDescriptor = type.getConstructor().getDeclarationDescriptor() as? TypeParameterDescriptor
|
||||
return if (typeParameterDescriptor != null && isMyTypeVariable(typeParameterDescriptor)) typeParameterDescriptor else null
|
||||
}
|
||||
@@ -471,12 +471,12 @@ public class ConstraintSystemImpl : ConstraintSystem {
|
||||
private fun getSubstitutor(substituteOriginal: Boolean, getDefaultValue: (TypeParameterDescriptor) -> TypeProjection) =
|
||||
replaceUninferredBy(getDefaultValue, substituteOriginal).setApproximateCapturedTypes()
|
||||
|
||||
private fun storeInitialConstraint(constraintKind: ConstraintKind, subType: KtType, superType: KtType, position: ConstraintPosition) {
|
||||
private fun storeInitialConstraint(constraintKind: ConstraintKind, subType: KotlinType, superType: KotlinType, position: ConstraintPosition) {
|
||||
initialConstraints.add(Constraint(constraintKind, subType, superType, position))
|
||||
}
|
||||
|
||||
private fun satisfyInitialConstraints(): Boolean {
|
||||
fun KtType.substitute(): KtType? {
|
||||
fun KotlinType.substitute(): KotlinType? {
|
||||
val substitutor = getSubstitutor(substituteOriginal = false) { TypeProjectionImpl(ErrorUtils.createUninferredParameterType(it)) }
|
||||
return substitutor.substitute(this, Variance.INVARIANT) ?: return null
|
||||
}
|
||||
@@ -518,9 +518,9 @@ public class ConstraintSystemImpl : ConstraintSystem {
|
||||
}
|
||||
|
||||
fun createTypeForFunctionPlaceholder(
|
||||
functionPlaceholder: KtType,
|
||||
expectedType: KtType
|
||||
): KtType {
|
||||
functionPlaceholder: KotlinType,
|
||||
expectedType: KotlinType
|
||||
): KotlinType {
|
||||
if (!functionPlaceholder.isFunctionPlaceholder) return functionPlaceholder
|
||||
|
||||
val functionPlaceholderTypeConstructor = functionPlaceholder.getConstructor() as FunctionPlaceholderTypeConstructor
|
||||
@@ -531,7 +531,7 @@ fun createTypeForFunctionPlaceholder(
|
||||
// the first parameter is receiver (if present), the last one is return type,
|
||||
// the remaining are function arguments
|
||||
val functionArgumentsSize = if (isExtension) typeParamSize - 2 else typeParamSize - 1
|
||||
val result = arrayListOf<KtType>()
|
||||
val result = arrayListOf<KotlinType>()
|
||||
(1..functionArgumentsSize).forEach { result.add(DONT_CARE) }
|
||||
result
|
||||
}
|
||||
@@ -575,7 +575,7 @@ public fun createTypeSubstitutor(conversion: (TypeParameterDescriptor) -> TypePa
|
||||
if (descriptor !is TypeParameterDescriptor) return null
|
||||
val typeParameterDescriptor = conversion(descriptor) ?: return null
|
||||
|
||||
val type = KtTypeImpl.create(Annotations.EMPTY, typeParameterDescriptor.getTypeConstructor(), false, listOf(), KtScope.Empty)
|
||||
val type = KotlinTypeImpl.create(Annotations.EMPTY, typeParameterDescriptor.getTypeConstructor(), false, listOf(), KtScope.Empty)
|
||||
return TypeProjectionImpl(type)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.resolve.calls.inference.TypeBounds.BoundKind.EXACT_B
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.TypeBounds.BoundKind.LOWER_BOUND
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.TypeBounds.BoundKind.UPPER_BOUND
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPosition
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
|
||||
public interface TypeBounds {
|
||||
@@ -32,10 +32,10 @@ public interface TypeBounds {
|
||||
|
||||
public val bounds: Collection<Bound>
|
||||
|
||||
public val value: KtType?
|
||||
public val value: KotlinType?
|
||||
get() = if (values.size() == 1) values.first() else null
|
||||
|
||||
public val values: Collection<KtType>
|
||||
public val values: Collection<KotlinType>
|
||||
|
||||
public enum class BoundKind {
|
||||
LOWER_BOUND,
|
||||
@@ -45,7 +45,7 @@ public interface TypeBounds {
|
||||
|
||||
public class Bound(
|
||||
public val typeVariable: TypeParameterDescriptor,
|
||||
public val constrainingType: KtType,
|
||||
public val constrainingType: KotlinType,
|
||||
public val kind: BoundKind,
|
||||
public val position: ConstraintPosition,
|
||||
public val isProper: Boolean,
|
||||
|
||||
@@ -34,7 +34,7 @@ public class TypeBoundsImpl(
|
||||
) : TypeBounds {
|
||||
override val bounds = ArrayList<Bound>()
|
||||
|
||||
private var resultValues: Collection<KtType>? = null
|
||||
private var resultValues: Collection<KotlinType>? = null
|
||||
|
||||
var isFixed: Boolean = false
|
||||
private set
|
||||
@@ -51,12 +51,12 @@ public class TypeBoundsImpl(
|
||||
bounds.add(bound)
|
||||
}
|
||||
|
||||
private fun filterBounds(bounds: Collection<Bound>, kind: BoundKind): Set<KtType> {
|
||||
private fun filterBounds(bounds: Collection<Bound>, kind: BoundKind): Set<KotlinType> {
|
||||
return filterBounds(bounds, kind, null)
|
||||
}
|
||||
|
||||
private fun filterBounds(bounds: Collection<Bound>, kind: BoundKind, errorValues: MutableCollection<KtType>?): Set<KtType> {
|
||||
val result = LinkedHashSet<KtType>()
|
||||
private fun filterBounds(bounds: Collection<Bound>, kind: BoundKind, errorValues: MutableCollection<KotlinType>?): Set<KotlinType> {
|
||||
val result = LinkedHashSet<KotlinType>()
|
||||
for (bound in bounds) {
|
||||
if (bound.kind == kind) {
|
||||
if (!ErrorUtils.containsErrorType(bound.constrainingType)) {
|
||||
@@ -76,7 +76,7 @@ public class TypeBoundsImpl(
|
||||
return result
|
||||
}
|
||||
|
||||
override val values: Collection<KtType>
|
||||
override val values: Collection<KotlinType>
|
||||
get() {
|
||||
if (resultValues == null) {
|
||||
resultValues = computeValues()
|
||||
@@ -84,8 +84,8 @@ public class TypeBoundsImpl(
|
||||
return resultValues!!
|
||||
}
|
||||
|
||||
private fun computeValues(): Collection<KtType> {
|
||||
val values = LinkedHashSet<KtType>()
|
||||
private fun computeValues(): Collection<KotlinType> {
|
||||
val values = LinkedHashSet<KotlinType>()
|
||||
val bounds = bounds.filter { it.isProper }
|
||||
|
||||
if (bounds.isEmpty()) {
|
||||
@@ -146,7 +146,7 @@ public class TypeBoundsImpl(
|
||||
return values
|
||||
}
|
||||
|
||||
private fun tryPossibleAnswer(bounds: Collection<Bound>, possibleAnswer: KtType?): Boolean {
|
||||
private fun tryPossibleAnswer(bounds: Collection<Bound>, possibleAnswer: KotlinType?): Boolean {
|
||||
if (possibleAnswer == null) return false
|
||||
// a captured type might be an answer
|
||||
if (!possibleAnswer.getConstructor().isDenotable() && !possibleAnswer.isCaptured()) return false
|
||||
|
||||
+2
-2
@@ -96,7 +96,7 @@ private fun ConstraintSystemImpl.generateNewBound(bound: Bound, substitution: Bo
|
||||
|
||||
val position = CompoundConstraintPosition(bound.position, substitution.position)
|
||||
|
||||
fun addNewBound(newConstrainingType: KtType, newBoundKind: BoundKind) {
|
||||
fun addNewBound(newConstrainingType: KotlinType, newBoundKind: BoundKind) {
|
||||
// We don't generate new recursive constraints
|
||||
val nestedTypeVariables = newConstrainingType.getNestedTypeVariables(original = false)
|
||||
if (nestedTypeVariables.contains(bound.typeVariable)) return
|
||||
@@ -117,7 +117,7 @@ private fun ConstraintSystemImpl.generateNewBound(bound: Bound, substitution: Bo
|
||||
// todo
|
||||
// if we allow non-trivial type projections, we bump into errors like
|
||||
// "Empty intersection for types [MutableCollection<in ('Int'..'Int?')>, MutableCollection<out Any?>, MutableCollection<in Int>]"
|
||||
fun KtType.containsConstrainingTypeWithoutProjection() = this.getNestedArguments().any {
|
||||
fun KotlinType.containsConstrainingTypeWithoutProjection() = this.getNestedArguments().any {
|
||||
it.getType().getConstructor() == substitution.constrainingType.getConstructor() && it.getProjectionKind() == Variance.INVARIANT
|
||||
}
|
||||
if (approximationBounds.upper.containsConstrainingTypeWithoutProjection() && bound.kind != LOWER_BOUND) {
|
||||
|
||||
@@ -26,9 +26,9 @@ public interface CompileTimeConstant<out T> {
|
||||
|
||||
public val parameters: CompileTimeConstant.Parameters
|
||||
|
||||
public fun toConstantValue(expectedType: KtType): ConstantValue<T>
|
||||
public fun toConstantValue(expectedType: KotlinType): ConstantValue<T>
|
||||
|
||||
public fun getValue(expectedType: KtType): T = toConstantValue(expectedType).value
|
||||
public fun getValue(expectedType: KotlinType): T = toConstantValue(expectedType).value
|
||||
|
||||
public val canBeUsedInAnnotations: Boolean get() = parameters.canBeUsedInAnnotation
|
||||
|
||||
@@ -53,9 +53,9 @@ public class TypedCompileTimeConstant<out T>(
|
||||
override val isError: Boolean
|
||||
get() = constantValue is ErrorValue
|
||||
|
||||
public val type: KtType = constantValue.type
|
||||
public val type: KotlinType = constantValue.type
|
||||
|
||||
override fun toConstantValue(expectedType: KtType): ConstantValue<T> = constantValue
|
||||
override fun toConstantValue(expectedType: KotlinType): ConstantValue<T> = constantValue
|
||||
}
|
||||
|
||||
public class IntegerValueTypeConstant(
|
||||
@@ -65,7 +65,7 @@ public class IntegerValueTypeConstant(
|
||||
) : CompileTimeConstant<Number> {
|
||||
private val typeConstructor = IntegerValueTypeConstructor(value.toLong(), builtIns)
|
||||
|
||||
override fun toConstantValue(expectedType: KtType): ConstantValue<Number> {
|
||||
override fun toConstantValue(expectedType: KotlinType): ConstantValue<Number> {
|
||||
val factory = ConstantValueFactory(builtIns)
|
||||
val type = getType(expectedType)
|
||||
return when {
|
||||
@@ -84,12 +84,12 @@ public class IntegerValueTypeConstant(
|
||||
}
|
||||
}
|
||||
|
||||
val unknownIntegerType = KtTypeImpl.create(
|
||||
val unknownIntegerType = KotlinTypeImpl.create(
|
||||
Annotations.EMPTY, typeConstructor, false, emptyList<TypeProjection>(),
|
||||
ErrorUtils.createErrorScope("Scope for number value type (" + typeConstructor.toString() + ")", true)
|
||||
)
|
||||
|
||||
public fun getType(expectedType: KtType): KtType = TypeUtils.getPrimitiveNumberType(typeConstructor, expectedType)
|
||||
public fun getType(expectedType: KotlinType): KotlinType = TypeUtils.getPrimitiveNumberType(typeConstructor, expectedType)
|
||||
|
||||
override fun toString() = typeConstructor.toString()
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.resolve.constants
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
|
||||
public class ConstantValueFactory(
|
||||
@@ -51,12 +51,12 @@ public class ConstantValueFactory(
|
||||
|
||||
fun createArrayValue(
|
||||
value: List<ConstantValue<*>>,
|
||||
type: KtType
|
||||
type: KotlinType
|
||||
) = ArrayValue(value, type, builtins)
|
||||
|
||||
fun createAnnotationValue(value: AnnotationDescriptor) = AnnotationValue(value)
|
||||
|
||||
fun createKClassValue(type: KtType) = KClassValue(type)
|
||||
fun createKClassValue(type: KotlinType) = KClassValue(type)
|
||||
|
||||
fun createConstantValue(
|
||||
value: Any?
|
||||
@@ -79,7 +79,7 @@ public class ConstantValueFactory(
|
||||
|
||||
public fun createIntegerConstantValue(
|
||||
value: Long,
|
||||
expectedType: KtType
|
||||
expectedType: KotlinType
|
||||
): ConstantValue<*>? {
|
||||
val notNullExpected = TypeUtils.makeNotNullable(expectedType)
|
||||
return when {
|
||||
|
||||
+4
-4
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.resolve.constants
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.TypeConstructor
|
||||
import java.util.*
|
||||
|
||||
@@ -27,7 +27,7 @@ public class IntegerValueTypeConstructor(
|
||||
private val value: Long,
|
||||
private val builtIns: KotlinBuiltIns
|
||||
) : TypeConstructor {
|
||||
private val supertypes = ArrayList<KtType>(4)
|
||||
private val supertypes = ArrayList<KotlinType>(4)
|
||||
|
||||
init {
|
||||
// order of types matters
|
||||
@@ -39,13 +39,13 @@ public class IntegerValueTypeConstructor(
|
||||
supertypes.add(builtIns.getLongType())
|
||||
}
|
||||
|
||||
private fun checkBoundsAndAddSuperType(value: Long, minValue: Long, maxValue: Long, kotlinType: KtType) {
|
||||
private fun checkBoundsAndAddSuperType(value: Long, minValue: Long, maxValue: Long, kotlinType: KotlinType) {
|
||||
if (value >= minValue && value <= maxValue) {
|
||||
supertypes.add(kotlinType)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getSupertypes(): Collection<KtType> = supertypes
|
||||
override fun getSupertypes(): Collection<KotlinType> = supertypes
|
||||
|
||||
override fun getParameters(): List<TypeParameterDescriptor> = emptyList()
|
||||
|
||||
|
||||
@@ -22,11 +22,11 @@ import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.classObjectType
|
||||
import org.jetbrains.kotlin.types.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.utils.sure
|
||||
|
||||
public abstract class ConstantValue<out T>(public open val value: T) {
|
||||
public abstract val type: KtType
|
||||
public abstract val type: KotlinType
|
||||
|
||||
public abstract fun <R, D> accept(visitor: AnnotationArgumentVisitor<R, D>, data: D): R
|
||||
|
||||
@@ -37,7 +37,7 @@ public abstract class IntegerValueConstant<T> protected constructor(value: T) :
|
||||
|
||||
public class AnnotationValue(value: AnnotationDescriptor) : ConstantValue<AnnotationDescriptor>(value) {
|
||||
|
||||
override val type: KtType
|
||||
override val type: KotlinType
|
||||
get() = value.getType()
|
||||
|
||||
override fun <R, D> accept(visitor: AnnotationArgumentVisitor<R, D>, data: D) = visitor.visitAnnotationValue(this, data)
|
||||
@@ -46,7 +46,7 @@ public class AnnotationValue(value: AnnotationDescriptor) : ConstantValue<Annota
|
||||
|
||||
public class ArrayValue(
|
||||
value: List<ConstantValue<*>>,
|
||||
override val type: KtType,
|
||||
override val type: KotlinType,
|
||||
private val builtIns: KotlinBuiltIns
|
||||
) : ConstantValue<List<ConstantValue<*>>>(value) {
|
||||
|
||||
@@ -56,7 +56,7 @@ public class ArrayValue(
|
||||
|
||||
override fun <R, D> accept(visitor: AnnotationArgumentVisitor<R, D>, data: D) = visitor.visitArrayValue(this, data)
|
||||
|
||||
public val elementType: KtType
|
||||
public val elementType: KotlinType
|
||||
get() = builtIns.getArrayElementType(type)
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
@@ -140,7 +140,7 @@ public class EnumValue(
|
||||
value: ClassDescriptor
|
||||
) : ConstantValue<ClassDescriptor>(value) {
|
||||
|
||||
override val type: KtType
|
||||
override val type: KotlinType
|
||||
get() = value.classObjectType.sure { "Enum entry must have a class object type: " + value }
|
||||
|
||||
override fun <R, D> accept(visitor: AnnotationArgumentVisitor<R, D>, data: D) = visitor.visitEnumValue(this, data)
|
||||
@@ -211,9 +211,9 @@ public class IntValue(
|
||||
override fun hashCode() = value
|
||||
}
|
||||
|
||||
public class KClassValue(override val type: KtType) :
|
||||
ConstantValue<KtType>(type) {
|
||||
override val value: KtType
|
||||
public class KClassValue(override val type: KotlinType) :
|
||||
ConstantValue<KotlinType>(type) {
|
||||
override val value: KotlinType
|
||||
get() = type.getArguments().single().getType()
|
||||
|
||||
override fun <R, D> accept(visitor: AnnotationArgumentVisitor<R, D>, data: D) = visitor.visitKClassValue(this, data)
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.resolve.scopes
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.utils.Printer
|
||||
|
||||
/**
|
||||
@@ -54,19 +54,19 @@ public abstract class AbstractScopeAdapter : KtScope {
|
||||
return workerScope.getProperties(name, location)
|
||||
}
|
||||
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KtType>, name: Name, location: LookupLocation): Collection<PropertyDescriptor> {
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KotlinType>, name: Name, location: LookupLocation): Collection<PropertyDescriptor> {
|
||||
return workerScope.getSyntheticExtensionProperties(receiverTypes, name, location)
|
||||
}
|
||||
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<KtType>, name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<KotlinType>, name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
|
||||
return workerScope.getSyntheticExtensionFunctions(receiverTypes, name, location)
|
||||
}
|
||||
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KtType>): Collection<PropertyDescriptor> {
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KotlinType>): Collection<PropertyDescriptor> {
|
||||
return workerScope.getSyntheticExtensionProperties(receiverTypes)
|
||||
}
|
||||
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<KtType>): Collection<FunctionDescriptor> {
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<KotlinType>): Collection<FunctionDescriptor> {
|
||||
return workerScope.getSyntheticExtensionFunctions(receiverTypes)
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.resolve.scopes
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.util.collectionUtils.getFirstMatch
|
||||
import org.jetbrains.kotlin.util.collectionUtils.getFromAllScopes
|
||||
import org.jetbrains.kotlin.utils.Printer
|
||||
@@ -48,16 +48,16 @@ public open class ChainedScope(
|
||||
override fun getFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor>
|
||||
= getFromAllScopes(scopeChain) { it.getFunctions(name, location) }
|
||||
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KtType>, name: Name, location: LookupLocation): Collection<PropertyDescriptor>
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KotlinType>, name: Name, location: LookupLocation): Collection<PropertyDescriptor>
|
||||
= getFromAllScopes(scopeChain) { it.getSyntheticExtensionProperties(receiverTypes, name, location) }
|
||||
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<KtType>, name: Name, location: LookupLocation): Collection<FunctionDescriptor>
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<KotlinType>, name: Name, location: LookupLocation): Collection<FunctionDescriptor>
|
||||
= getFromAllScopes(scopeChain) { it.getSyntheticExtensionFunctions(receiverTypes, name, location) }
|
||||
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KtType>): Collection<PropertyDescriptor>
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KotlinType>): Collection<PropertyDescriptor>
|
||||
= getFromAllScopes(scopeChain) { it.getSyntheticExtensionProperties(receiverTypes) }
|
||||
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<KtType>): Collection<FunctionDescriptor>
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<KotlinType>): Collection<FunctionDescriptor>
|
||||
= getFromAllScopes(scopeChain) { it.getSyntheticExtensionFunctions(receiverTypes) }
|
||||
|
||||
override fun getImplicitReceiversHierarchy(): List<ReceiverParameterDescriptor> {
|
||||
|
||||
@@ -21,7 +21,7 @@ import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.utils.Printer
|
||||
|
||||
public class FilteringScope(private val workerScope: KtScope, private val predicate: (DeclarationDescriptor) -> Boolean) : KtScope {
|
||||
@@ -39,16 +39,16 @@ public class FilteringScope(private val workerScope: KtScope, private val predic
|
||||
|
||||
override fun getProperties(name: Name, location: LookupLocation) = workerScope.getProperties(name, location).filter(predicate)
|
||||
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KtType>, name: Name, location: LookupLocation): Collection<PropertyDescriptor>
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KotlinType>, name: Name, location: LookupLocation): Collection<PropertyDescriptor>
|
||||
= workerScope.getSyntheticExtensionProperties(receiverTypes, name, location).filter(predicate)
|
||||
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<KtType>, name: Name, location: LookupLocation): Collection<FunctionDescriptor>
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<KotlinType>, name: Name, location: LookupLocation): Collection<FunctionDescriptor>
|
||||
= workerScope.getSyntheticExtensionFunctions(receiverTypes, name, location).filter(predicate)
|
||||
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KtType>): Collection<PropertyDescriptor>
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KotlinType>): Collection<PropertyDescriptor>
|
||||
= workerScope.getSyntheticExtensionProperties(receiverTypes).filter(predicate)
|
||||
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<KtType>): Collection<FunctionDescriptor>
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<KotlinType>): Collection<FunctionDescriptor>
|
||||
= workerScope.getSyntheticExtensionFunctions(receiverTypes).filter(predicate)
|
||||
|
||||
override fun getLocalVariable(name: Name) = filterDescriptor(workerScope.getLocalVariable(name))
|
||||
|
||||
@@ -20,7 +20,7 @@ import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
||||
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.utils.Printer
|
||||
import org.jetbrains.kotlin.utils.toReadOnlyList
|
||||
import java.lang.reflect.Modifier
|
||||
@@ -37,11 +37,11 @@ public interface KtScope {
|
||||
|
||||
public fun getFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor>
|
||||
|
||||
public fun getSyntheticExtensionProperties(receiverTypes: Collection<KtType>, name: Name, location: LookupLocation): Collection<PropertyDescriptor>
|
||||
public fun getSyntheticExtensionFunctions(receiverTypes: Collection<KtType>, name: Name, location: LookupLocation): Collection<FunctionDescriptor>
|
||||
public fun getSyntheticExtensionProperties(receiverTypes: Collection<KotlinType>, name: Name, location: LookupLocation): Collection<PropertyDescriptor>
|
||||
public fun getSyntheticExtensionFunctions(receiverTypes: Collection<KotlinType>, name: Name, location: LookupLocation): Collection<FunctionDescriptor>
|
||||
|
||||
public fun getSyntheticExtensionProperties(receiverTypes: Collection<KtType>): Collection<PropertyDescriptor>
|
||||
public fun getSyntheticExtensionFunctions(receiverTypes: Collection<KtType>): Collection<FunctionDescriptor>
|
||||
public fun getSyntheticExtensionProperties(receiverTypes: Collection<KotlinType>): Collection<PropertyDescriptor>
|
||||
public fun getSyntheticExtensionFunctions(receiverTypes: Collection<KotlinType>): Collection<FunctionDescriptor>
|
||||
|
||||
public fun getContainingDeclaration(): DeclarationDescriptor
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.resolve.scopes
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.utils.Printer
|
||||
|
||||
public abstract class KtScopeImpl : KtScope {
|
||||
@@ -33,11 +33,11 @@ public abstract class KtScopeImpl : KtScope {
|
||||
|
||||
override fun getFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor> = emptyList()
|
||||
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KtType>, name: Name, location: LookupLocation): Collection<PropertyDescriptor> = emptyList()
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<KtType>, name: Name, location: LookupLocation): Collection<FunctionDescriptor> = emptyList()
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KotlinType>, name: Name, location: LookupLocation): Collection<PropertyDescriptor> = emptyList()
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<KotlinType>, name: Name, location: LookupLocation): Collection<FunctionDescriptor> = emptyList()
|
||||
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KtType>): Collection<PropertyDescriptor> = emptyList()
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<KtType>): Collection<FunctionDescriptor> = emptyList()
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KotlinType>): Collection<PropertyDescriptor> = emptyList()
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<KotlinType>): Collection<FunctionDescriptor> = emptyList()
|
||||
|
||||
override fun getDeclarationsByLabel(labelName: Name): Collection<DeclarationDescriptor> = emptyList()
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
||||
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.utils.Printer
|
||||
|
||||
// see ScopeUtils.kt in the frontend module
|
||||
@@ -58,11 +58,11 @@ public interface FileScope: LexicalScope {
|
||||
|
||||
fun getPackage(name: Name): PackageViewDescriptor?
|
||||
|
||||
public fun getSyntheticExtensionProperties(receiverTypes: Collection<KtType>, name: Name, location: LookupLocation): Collection<PropertyDescriptor>
|
||||
public fun getSyntheticExtensionFunctions(receiverTypes: Collection<KtType>, name: Name, location: LookupLocation): Collection<FunctionDescriptor>
|
||||
public fun getSyntheticExtensionProperties(receiverTypes: Collection<KotlinType>, name: Name, location: LookupLocation): Collection<PropertyDescriptor>
|
||||
public fun getSyntheticExtensionFunctions(receiverTypes: Collection<KotlinType>, name: Name, location: LookupLocation): Collection<FunctionDescriptor>
|
||||
|
||||
public fun getSyntheticExtensionProperties(receiverTypes: Collection<KtType>): Collection<PropertyDescriptor>
|
||||
public fun getSyntheticExtensionFunctions(receiverTypes: Collection<KtType>): Collection<FunctionDescriptor>
|
||||
public fun getSyntheticExtensionProperties(receiverTypes: Collection<KotlinType>): Collection<PropertyDescriptor>
|
||||
public fun getSyntheticExtensionFunctions(receiverTypes: Collection<KotlinType>): Collection<FunctionDescriptor>
|
||||
|
||||
public fun getDescriptors(
|
||||
kindFilter: DescriptorKindFilter = DescriptorKindFilter.ALL,
|
||||
|
||||
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor
|
||||
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.TypeSubstitutor
|
||||
import org.jetbrains.kotlin.utils.Printer
|
||||
import org.jetbrains.kotlin.utils.newHashSetWithExpectedSize
|
||||
@@ -71,16 +71,16 @@ public class SubstitutingScope(private val workerScope: KtScope, private val sub
|
||||
|
||||
override fun getFunctions(name: Name, location: LookupLocation) = substitute(workerScope.getFunctions(name, location))
|
||||
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KtType>, name: Name, location: LookupLocation): Collection<PropertyDescriptor>
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KotlinType>, name: Name, location: LookupLocation): Collection<PropertyDescriptor>
|
||||
= substitute(workerScope.getSyntheticExtensionProperties(receiverTypes, name, location))
|
||||
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<KtType>, name: Name, location: LookupLocation): Collection<FunctionDescriptor>
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<KotlinType>, name: Name, location: LookupLocation): Collection<FunctionDescriptor>
|
||||
= substitute(workerScope.getSyntheticExtensionFunctions(receiverTypes, name, location))
|
||||
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KtType>): Collection<PropertyDescriptor>
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KotlinType>): Collection<PropertyDescriptor>
|
||||
= substitute(workerScope.getSyntheticExtensionProperties(receiverTypes))
|
||||
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<KtType>): Collection<FunctionDescriptor>
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<KotlinType>): Collection<FunctionDescriptor>
|
||||
= substitute(workerScope.getSyntheticExtensionFunctions(receiverTypes))
|
||||
|
||||
override fun getPackage(name: Name) = workerScope.getPackage(name)
|
||||
|
||||
+4
-4
@@ -17,18 +17,18 @@
|
||||
package org.jetbrains.kotlin.resolve.scopes.receivers;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
public abstract class AbstractReceiverValue implements ReceiverValue {
|
||||
protected final KtType receiverType;
|
||||
protected final KotlinType receiverType;
|
||||
|
||||
public AbstractReceiverValue(@NotNull KtType receiverType) {
|
||||
public AbstractReceiverValue(@NotNull KotlinType receiverType) {
|
||||
this.receiverType = receiverType;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public KtType getType() {
|
||||
public KotlinType getType() {
|
||||
return receiverType;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.resolve.scopes.receivers;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
public class ClassReceiver implements ThisReceiver {
|
||||
|
||||
@@ -35,7 +35,7 @@ public class ClassReceiver implements ThisReceiver {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public KtType getType() {
|
||||
public KotlinType getType() {
|
||||
return classDescriptor.getDefaultType();
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -18,13 +18,13 @@ package org.jetbrains.kotlin.resolve.scopes.receivers;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
public class ExtensionReceiver extends AbstractReceiverValue implements ThisReceiver {
|
||||
|
||||
private final CallableDescriptor descriptor;
|
||||
|
||||
public ExtensionReceiver(@NotNull CallableDescriptor callableDescriptor, @NotNull KtType receiverType) {
|
||||
public ExtensionReceiver(@NotNull CallableDescriptor callableDescriptor, @NotNull KotlinType receiverType) {
|
||||
super(receiverType);
|
||||
this.descriptor = callableDescriptor;
|
||||
}
|
||||
|
||||
+4
-4
@@ -17,13 +17,13 @@
|
||||
package org.jetbrains.kotlin.resolve.scopes.receivers;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
public interface ReceiverValue {
|
||||
ReceiverValue NO_RECEIVER = new ReceiverValue() {
|
||||
@NotNull
|
||||
@Override
|
||||
public KtType getType() {
|
||||
public KotlinType getType() {
|
||||
throw new UnsupportedOperationException("NO_RECEIVER.getType()");
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public interface ReceiverValue {
|
||||
ReceiverValue IRRELEVANT_RECEIVER = new ReceiverValue() {
|
||||
@NotNull
|
||||
@Override
|
||||
public KtType getType() {
|
||||
public KotlinType getType() {
|
||||
throw new UnsupportedOperationException("IRRELEVANT_RECEIVER.getType()");
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public interface ReceiverValue {
|
||||
};
|
||||
|
||||
@NotNull
|
||||
KtType getType();
|
||||
KotlinType getType();
|
||||
|
||||
boolean exists();
|
||||
}
|
||||
|
||||
+2
-2
@@ -17,14 +17,14 @@
|
||||
package org.jetbrains.kotlin.resolve.scopes.receivers;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
/**
|
||||
* This represents the receiver of hasNext and next() in for-loops
|
||||
* Cannot be an expression receiver because there is no expression for the iterator() call
|
||||
*/
|
||||
public class TransientReceiver extends AbstractReceiverValue {
|
||||
public TransientReceiver(@NotNull KtType type) {
|
||||
public TransientReceiver(@NotNull KotlinType type) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -25,7 +25,7 @@ import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class AbstractKtType implements KtType {
|
||||
public abstract class AbstractKotlinType implements KotlinType {
|
||||
@Nullable
|
||||
@Override
|
||||
public <T extends TypeCapability> T getCapability(@NotNull Class<T> capabilityClass) {
|
||||
@@ -49,9 +49,9 @@ public abstract class AbstractKtType implements KtType {
|
||||
@Override
|
||||
public final boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (!(obj instanceof KtType)) return false;
|
||||
if (!(obj instanceof KotlinType)) return false;
|
||||
|
||||
KtType type = (KtType) obj;
|
||||
KotlinType type = (KotlinType) obj;
|
||||
|
||||
return isMarkedNullable() == type.isMarkedNullable() && KotlinTypeChecker.FLEXIBLE_UNEQUAL_TO_INFLEXIBLE.equalTypes(this, type);
|
||||
}
|
||||
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.storage.StorageManager
|
||||
import org.jetbrains.kotlin.resolve.scopes.KtScope
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
|
||||
public abstract class AbstractLazyType(storageManager: StorageManager) : AbstractKtType(), LazyType {
|
||||
public abstract class AbstractLazyType(storageManager: StorageManager) : AbstractKotlinType(), LazyType {
|
||||
|
||||
private val typeConstructor = storageManager.createLazyValue { computeTypeConstructor() }
|
||||
override fun getConstructor(): TypeConstructor = typeConstructor()
|
||||
@@ -63,6 +63,6 @@ public abstract class AbstractLazyType(storageManager: StorageManager) : Abstrac
|
||||
if (!arguments.isComputed()) {
|
||||
return "" + getConstructor() + "<arguments are not computed>"
|
||||
}
|
||||
return super<AbstractKtType>.toString()
|
||||
return super<AbstractKotlinType>.toString()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,8 +33,8 @@ public data class ApproximationBounds<T>(
|
||||
|
||||
private class TypeArgument(
|
||||
val typeParameter: TypeParameterDescriptor,
|
||||
val inProjection: KtType,
|
||||
val outProjection: KtType
|
||||
val inProjection: KotlinType,
|
||||
val outProjection: KotlinType
|
||||
) {
|
||||
val isConsistent: Boolean
|
||||
get() = KotlinTypeChecker.DEFAULT.isSubtypeOf(inProjection, outProjection)
|
||||
@@ -85,12 +85,12 @@ private fun substituteCapturedTypes(typeProjection: TypeProjection): TypeProject
|
||||
return typeSubstitutor.substituteWithoutApproximation(typeProjection)
|
||||
}
|
||||
|
||||
public fun approximateCapturedTypes(type: KtType): ApproximationBounds<KtType> {
|
||||
public fun approximateCapturedTypes(type: KotlinType): ApproximationBounds<KotlinType> {
|
||||
val typeConstructor = type.getConstructor()
|
||||
if (type.isCaptured()) {
|
||||
val typeProjection = (typeConstructor as CapturedTypeConstructor).typeProjection
|
||||
// todo: preserve flexibility as well
|
||||
fun KtType.makeNullableIfNeeded() = TypeUtils.makeNullableIfNeeded(this, type.isMarkedNullable())
|
||||
fun KotlinType.makeNullableIfNeeded() = TypeUtils.makeNullableIfNeeded(this, type.isMarkedNullable())
|
||||
val bound = typeProjection.getType().makeNullableIfNeeded()
|
||||
|
||||
return when (typeProjection.getProjectionKind()) {
|
||||
@@ -115,9 +115,9 @@ public fun approximateCapturedTypes(type: KtType): ApproximationBounds<KtType> {
|
||||
type.replaceTypeArguments(upperBoundArguments))
|
||||
}
|
||||
|
||||
private fun KtType.replaceTypeArguments(newTypeArguments: List<TypeArgument>): KtType {
|
||||
private fun KotlinType.replaceTypeArguments(newTypeArguments: List<TypeArgument>): KotlinType {
|
||||
assert(getArguments().size() == newTypeArguments.size()) { "Incorrect type arguments $newTypeArguments" }
|
||||
return KtTypeImpl.create(
|
||||
return KotlinTypeImpl.create(
|
||||
getAnnotations(), getConstructor(), isMarkedNullable(), newTypeArguments.map { it.toTypeProjection() }, getMemberScope()
|
||||
)
|
||||
}
|
||||
|
||||
@@ -38,10 +38,10 @@ import static org.jetbrains.kotlin.types.Variance.OUT_VARIANCE;
|
||||
|
||||
public class CommonSupertypes {
|
||||
@Nullable
|
||||
public static KtType commonSupertypeForNonDenotableTypes(@NotNull Collection<KtType> types) {
|
||||
public static KotlinType commonSupertypeForNonDenotableTypes(@NotNull Collection<KotlinType> types) {
|
||||
if (types.isEmpty()) return null;
|
||||
if (types.size() == 1) {
|
||||
KtType type = types.iterator().next();
|
||||
KotlinType type = types.iterator().next();
|
||||
if (type.getConstructor() instanceof IntersectionTypeConstructor) {
|
||||
return commonSupertypeForNonDenotableTypes(type.getConstructor().getSupertypes());
|
||||
}
|
||||
@@ -50,15 +50,15 @@ public class CommonSupertypes {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static KtType commonSupertype(@NotNull Collection<KtType> types) {
|
||||
public static KotlinType commonSupertype(@NotNull Collection<KotlinType> types) {
|
||||
// Recursion should not be significantly deeper than the deepest type in question
|
||||
// It can be slightly deeper, though: e.g. when initial types are simple, but their supertypes are complex
|
||||
return findCommonSupertype(types, 0, maxDepth(types) + 3);
|
||||
}
|
||||
|
||||
private static int maxDepth(@NotNull Collection<KtType> types) {
|
||||
private static int maxDepth(@NotNull Collection<KotlinType> types) {
|
||||
int max = 0;
|
||||
for (KtType type : types) {
|
||||
for (KotlinType type : types) {
|
||||
int depth = depth(type);
|
||||
if (max < depth) {
|
||||
max = depth;
|
||||
@@ -67,10 +67,10 @@ public class CommonSupertypes {
|
||||
return max;
|
||||
}
|
||||
|
||||
private static int depth(@NotNull final KtType type) {
|
||||
return 1 + maxDepth(CollectionsKt.map(type.getArguments(), new Function1<TypeProjection, KtType>() {
|
||||
private static int depth(@NotNull final KotlinType type) {
|
||||
return 1 + maxDepth(CollectionsKt.map(type.getArguments(), new Function1<TypeProjection, KotlinType>() {
|
||||
@Override
|
||||
public KtType invoke(TypeProjection projection) {
|
||||
public KotlinType invoke(TypeProjection projection) {
|
||||
if (projection.isStarProjection()) {
|
||||
// any type is good enough for depth here
|
||||
return type.getConstructor().getBuiltIns().getAnyType();
|
||||
@@ -81,13 +81,13 @@ public class CommonSupertypes {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static KtType findCommonSupertype(@NotNull Collection<KtType> types, int recursionDepth, int maxDepth) {
|
||||
private static KotlinType findCommonSupertype(@NotNull Collection<KotlinType> types, int recursionDepth, int maxDepth) {
|
||||
assert recursionDepth <= maxDepth : "Recursion depth exceeded: " + recursionDepth + " > " + maxDepth + " for types " + types;
|
||||
boolean hasFlexible = false;
|
||||
List<KtType> upper = new ArrayList<KtType>(types.size());
|
||||
List<KtType> lower = new ArrayList<KtType>(types.size());
|
||||
List<KotlinType> upper = new ArrayList<KotlinType>(types.size());
|
||||
List<KotlinType> lower = new ArrayList<KotlinType>(types.size());
|
||||
Set<FlexibleTypeCapabilities> capabilities = new LinkedHashSet<FlexibleTypeCapabilities>();
|
||||
for (KtType type : types) {
|
||||
for (KotlinType type : types) {
|
||||
if (FlexibleTypesKt.isFlexible(type)) {
|
||||
hasFlexible = true;
|
||||
Flexibility flexibility = FlexibleTypesKt.flexibility(type);
|
||||
@@ -110,18 +110,18 @@ public class CommonSupertypes {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static KtType commonSuperTypeForInflexible(@NotNull Collection<KtType> types, int recursionDepth, int maxDepth) {
|
||||
private static KotlinType commonSuperTypeForInflexible(@NotNull Collection<KotlinType> types, int recursionDepth, int maxDepth) {
|
||||
assert !types.isEmpty();
|
||||
Collection<KtType> typeSet = new HashSet<KtType>(types);
|
||||
Collection<KotlinType> typeSet = new HashSet<KotlinType>(types);
|
||||
|
||||
KtType bestFit = FlexibleTypesKt.singleBestRepresentative(typeSet);
|
||||
KotlinType bestFit = FlexibleTypesKt.singleBestRepresentative(typeSet);
|
||||
if (bestFit != null) return bestFit;
|
||||
|
||||
// If any of the types is nullable, the result must be nullable
|
||||
// This also removed Nothing and Nothing? because they are subtypes of everything else
|
||||
boolean nullable = false;
|
||||
for (Iterator<KtType> iterator = typeSet.iterator(); iterator.hasNext();) {
|
||||
KtType type = iterator.next();
|
||||
for (Iterator<KotlinType> iterator = typeSet.iterator(); iterator.hasNext();) {
|
||||
KotlinType type = iterator.next();
|
||||
assert type != null;
|
||||
assert !FlexibleTypesKt.isFlexible(type) : "Flexible type " + type + " passed to commonSuperTypeForInflexible";
|
||||
if (KotlinBuiltIns.isNothingOrNullableNothing(type)) {
|
||||
@@ -145,10 +145,10 @@ public class CommonSupertypes {
|
||||
}
|
||||
|
||||
// constructor of the supertype -> all of its instantiations occurring as supertypes
|
||||
Map<TypeConstructor, Set<KtType>> commonSupertypes = computeCommonRawSupertypes(typeSet);
|
||||
Map<TypeConstructor, Set<KotlinType>> commonSupertypes = computeCommonRawSupertypes(typeSet);
|
||||
while (commonSupertypes.size() > 1) {
|
||||
Set<KtType> merge = new HashSet<KtType>();
|
||||
for (Set<KtType> supertypes : commonSupertypes.values()) {
|
||||
Set<KotlinType> merge = new HashSet<KotlinType>();
|
||||
for (Set<KotlinType> supertypes : commonSupertypes.values()) {
|
||||
merge.addAll(supertypes);
|
||||
}
|
||||
commonSupertypes = computeCommonRawSupertypes(merge);
|
||||
@@ -156,24 +156,24 @@ public class CommonSupertypes {
|
||||
assert !commonSupertypes.isEmpty() : commonSupertypes + " <- " + types;
|
||||
|
||||
// constructor of the supertype -> all of its instantiations occurring as supertypes
|
||||
Map.Entry<TypeConstructor, Set<KtType>> entry = commonSupertypes.entrySet().iterator().next();
|
||||
Map.Entry<TypeConstructor, Set<KotlinType>> entry = commonSupertypes.entrySet().iterator().next();
|
||||
|
||||
// Reconstructing type arguments if possible
|
||||
KtType result = computeSupertypeProjections(entry.getKey(), entry.getValue(), recursionDepth, maxDepth);
|
||||
KotlinType result = computeSupertypeProjections(entry.getKey(), entry.getValue(), recursionDepth, maxDepth);
|
||||
return TypeUtils.makeNullableIfNeeded(result, nullable);
|
||||
}
|
||||
|
||||
// Raw supertypes are superclasses w/o type arguments
|
||||
// @return TypeConstructor -> all instantiations of this constructor occurring as supertypes
|
||||
@NotNull
|
||||
private static Map<TypeConstructor, Set<KtType>> computeCommonRawSupertypes(@NotNull Collection<KtType> types) {
|
||||
private static Map<TypeConstructor, Set<KotlinType>> computeCommonRawSupertypes(@NotNull Collection<KotlinType> types) {
|
||||
assert !types.isEmpty();
|
||||
|
||||
Map<TypeConstructor, Set<KtType>> constructorToAllInstances = new HashMap<TypeConstructor, Set<KtType>>();
|
||||
Map<TypeConstructor, Set<KotlinType>> constructorToAllInstances = new HashMap<TypeConstructor, Set<KotlinType>>();
|
||||
Set<TypeConstructor> commonSuperclasses = null;
|
||||
|
||||
List<TypeConstructor> order = null;
|
||||
for (KtType type : types) {
|
||||
for (KotlinType type : types) {
|
||||
Set<TypeConstructor> visited = new HashSet<TypeConstructor>();
|
||||
order = topologicallySortSuperclassesAndRecordAllInstances(type, constructorToAllInstances, visited);
|
||||
|
||||
@@ -187,7 +187,7 @@ public class CommonSupertypes {
|
||||
assert order != null;
|
||||
|
||||
Set<TypeConstructor> notSource = new HashSet<TypeConstructor>();
|
||||
Map<TypeConstructor, Set<KtType>> result = new HashMap<TypeConstructor, Set<KtType>>();
|
||||
Map<TypeConstructor, Set<KotlinType>> result = new HashMap<TypeConstructor, Set<KotlinType>>();
|
||||
for (TypeConstructor superConstructor : order) {
|
||||
if (!commonSuperclasses.contains(superConstructor)) {
|
||||
continue;
|
||||
@@ -205,7 +205,7 @@ public class CommonSupertypes {
|
||||
// constructor - type constructor of a supertype to be instantiated
|
||||
// types - instantiations of constructor occurring as supertypes of classes we are trying to intersect
|
||||
@NotNull
|
||||
private static KtType computeSupertypeProjections(@NotNull TypeConstructor constructor, @NotNull Set<KtType> types, int recursionDepth, int maxDepth) {
|
||||
private static KotlinType computeSupertypeProjections(@NotNull TypeConstructor constructor, @NotNull Set<KotlinType> types, int recursionDepth, int maxDepth) {
|
||||
// we assume that all the given types are applications of the same type constructor
|
||||
|
||||
assert !types.isEmpty();
|
||||
@@ -218,14 +218,14 @@ public class CommonSupertypes {
|
||||
List<TypeProjection> newProjections = new ArrayList<TypeProjection>(parameters.size());
|
||||
for (TypeParameterDescriptor parameterDescriptor : parameters) {
|
||||
Set<TypeProjection> typeProjections = new HashSet<TypeProjection>();
|
||||
for (KtType type : types) {
|
||||
for (KotlinType type : types) {
|
||||
typeProjections.add(type.getArguments().get(parameterDescriptor.getIndex()));
|
||||
}
|
||||
newProjections.add(computeSupertypeProjection(parameterDescriptor, typeProjections, recursionDepth, maxDepth));
|
||||
}
|
||||
|
||||
boolean nullable = false;
|
||||
for (KtType type : types) {
|
||||
for (KotlinType type : types) {
|
||||
nullable |= type.isMarkedNullable();
|
||||
}
|
||||
|
||||
@@ -240,7 +240,7 @@ public class CommonSupertypes {
|
||||
else {
|
||||
newScope = ErrorUtils.createErrorScope("A scope for common supertype which is not a normal classifier", true);
|
||||
}
|
||||
return KtTypeImpl.create(Annotations.Companion.getEMPTY(), constructor, nullable, newProjections, newScope);
|
||||
return KotlinTypeImpl.create(Annotations.Companion.getEMPTY(), constructor, nullable, newProjections, newScope);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -260,8 +260,8 @@ public class CommonSupertypes {
|
||||
return new TypeProjectionImpl(OUT_VARIANCE, DescriptorUtilsKt.getBuiltIns(parameterDescriptor).getNullableAnyType());
|
||||
}
|
||||
|
||||
Set<KtType> ins = new HashSet<KtType>();
|
||||
Set<KtType> outs = new HashSet<KtType>();
|
||||
Set<KotlinType> ins = new HashSet<KotlinType>();
|
||||
Set<KotlinType> outs = new HashSet<KotlinType>();
|
||||
|
||||
Variance variance = parameterDescriptor.getVariance();
|
||||
switch (variance) {
|
||||
@@ -300,8 +300,8 @@ public class CommonSupertypes {
|
||||
if (outs != null) {
|
||||
assert !outs.isEmpty() : "Out projections is empty for parameter " + parameterDescriptor + ", type projections " + typeProjections;
|
||||
Variance projectionKind = variance == OUT_VARIANCE ? Variance.INVARIANT : OUT_VARIANCE;
|
||||
KtType superType = findCommonSupertype(outs, recursionDepth + 1, maxDepth);
|
||||
for (KtType upperBound: parameterDescriptor.getUpperBounds()) {
|
||||
KotlinType superType = findCommonSupertype(outs, recursionDepth + 1, maxDepth);
|
||||
for (KotlinType upperBound: parameterDescriptor.getUpperBounds()) {
|
||||
if (!TypeUtilsKt.isSubtypeOf(superType, upperBound)) {
|
||||
return new StarProjectionImpl(parameterDescriptor);
|
||||
}
|
||||
@@ -310,7 +310,7 @@ public class CommonSupertypes {
|
||||
}
|
||||
if (ins != null) {
|
||||
assert !ins.isEmpty() : "In projections is empty for parameter " + parameterDescriptor + ", type projections " + typeProjections;
|
||||
KtType intersection = TypeIntersector.intersectTypes(KotlinTypeChecker.DEFAULT, ins);
|
||||
KotlinType intersection = TypeIntersector.intersectTypes(KotlinTypeChecker.DEFAULT, ins);
|
||||
if (intersection == null) {
|
||||
return new TypeProjectionImpl(OUT_VARIANCE, findCommonSupertype(parameterDescriptor.getUpperBounds(), recursionDepth + 1, maxDepth));
|
||||
}
|
||||
@@ -325,7 +325,7 @@ public class CommonSupertypes {
|
||||
|
||||
private static void markAll(@NotNull TypeConstructor typeConstructor, @NotNull Set<TypeConstructor> markerSet) {
|
||||
markerSet.add(typeConstructor);
|
||||
for (KtType type : typeConstructor.getSupertypes()) {
|
||||
for (KotlinType type : typeConstructor.getSupertypes()) {
|
||||
markAll(type.getConstructor(), markerSet);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@ import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class DelegatingType implements KtType {
|
||||
protected abstract KtType getDelegate();
|
||||
public abstract class DelegatingType implements KotlinType {
|
||||
protected abstract KotlinType getDelegate();
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
@@ -87,9 +87,9 @@ public abstract class DelegatingType implements KtType {
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (!(obj instanceof KtType)) return false;
|
||||
if (!(obj instanceof KotlinType)) return false;
|
||||
|
||||
KtType type = (KtType) obj;
|
||||
KotlinType type = (KotlinType) obj;
|
||||
return KotlinTypeChecker.FLEXIBLE_UNEQUAL_TO_INFLEXIBLE.equalTypes(this, type);
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ public class DescriptorSubstitutor {
|
||||
|
||||
for (TypeParameterDescriptor descriptor : typeParameters) {
|
||||
TypeParameterDescriptorImpl substituted = substitutedMap.get(descriptor);
|
||||
for (KtType upperBound : descriptor.getUpperBounds()) {
|
||||
for (KotlinType upperBound : descriptor.getUpperBounds()) {
|
||||
substituted.getUpperBounds().add(substitutor.substitute(upperBound, Variance.INVARIANT));
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ public class DisjointKeysUnionTypeSubstitution private constructor(
|
||||
}
|
||||
}
|
||||
|
||||
override fun get(key: KtType) = first[key] ?: second[key]
|
||||
override fun get(key: KotlinType) = first[key] ?: second[key]
|
||||
|
||||
override fun isEmpty() = false
|
||||
|
||||
|
||||
@@ -145,7 +145,7 @@ public class ErrorUtils {
|
||||
}
|
||||
}
|
||||
for (TypeParameterDescriptor parameter : function.getTypeParameters()) {
|
||||
for (KtType upperBound : parameter.getUpperBounds()) {
|
||||
for (KotlinType upperBound : parameter.getUpperBounds()) {
|
||||
if (containsErrorType(upperBound)) {
|
||||
return true;
|
||||
}
|
||||
@@ -185,7 +185,7 @@ public class ErrorUtils {
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<PropertyDescriptor> getSyntheticExtensionProperties(
|
||||
@NotNull Collection<? extends KtType> receiverTypes, @NotNull Name name,
|
||||
@NotNull Collection<? extends KotlinType> receiverTypes, @NotNull Name name,
|
||||
@NotNull LookupLocation location
|
||||
) {
|
||||
return ERROR_PROPERTY_GROUP;
|
||||
@@ -194,7 +194,7 @@ public class ErrorUtils {
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<FunctionDescriptor> getSyntheticExtensionFunctions(
|
||||
@NotNull Collection<? extends KtType> receiverTypes, @NotNull Name name,
|
||||
@NotNull Collection<? extends KotlinType> receiverTypes, @NotNull Name name,
|
||||
@NotNull LookupLocation location
|
||||
) {
|
||||
return Collections.<FunctionDescriptor>singleton(createErrorFunction(this));
|
||||
@@ -202,14 +202,14 @@ public class ErrorUtils {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<PropertyDescriptor> getSyntheticExtensionProperties(@NotNull Collection<? extends KtType> receiverTypes) {
|
||||
public Collection<PropertyDescriptor> getSyntheticExtensionProperties(@NotNull Collection<? extends KotlinType> receiverTypes) {
|
||||
return ERROR_PROPERTY_GROUP;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<FunctionDescriptor> getSyntheticExtensionFunctions(
|
||||
@NotNull Collection<? extends KtType> receiverTypes
|
||||
@NotNull Collection<? extends KotlinType> receiverTypes
|
||||
) {
|
||||
return Collections.<FunctionDescriptor>singleton(createErrorFunction(this));
|
||||
}
|
||||
@@ -319,7 +319,7 @@ public class ErrorUtils {
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<PropertyDescriptor> getSyntheticExtensionProperties(
|
||||
@NotNull Collection<? extends KtType> receiverTypes, @NotNull Name name,
|
||||
@NotNull Collection<? extends KotlinType> receiverTypes, @NotNull Name name,
|
||||
@NotNull LookupLocation location
|
||||
) {
|
||||
throw new IllegalStateException();
|
||||
@@ -328,7 +328,7 @@ public class ErrorUtils {
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<FunctionDescriptor> getSyntheticExtensionFunctions(
|
||||
@NotNull Collection<? extends KtType> receiverTypes, @NotNull Name name,
|
||||
@NotNull Collection<? extends KotlinType> receiverTypes, @NotNull Name name,
|
||||
@NotNull LookupLocation location
|
||||
) {
|
||||
throw new IllegalStateException();
|
||||
@@ -336,14 +336,14 @@ public class ErrorUtils {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<PropertyDescriptor> getSyntheticExtensionProperties(@NotNull Collection<? extends KtType> receiverTypes) {
|
||||
public Collection<PropertyDescriptor> getSyntheticExtensionProperties(@NotNull Collection<? extends KotlinType> receiverTypes) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<FunctionDescriptor> getSyntheticExtensionFunctions(
|
||||
@NotNull Collection<? extends KtType> receiverTypes
|
||||
@NotNull Collection<? extends KotlinType> receiverTypes
|
||||
) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
@@ -402,7 +402,7 @@ public class ErrorUtils {
|
||||
private static class ErrorClassDescriptor extends ClassDescriptorImpl {
|
||||
public ErrorClassDescriptor(@Nullable String name) {
|
||||
super(getErrorModule(), Name.special(name == null ? "<ERROR CLASS>" : "<ERROR CLASS: " + name + ">"),
|
||||
Modality.OPEN, Collections.<KtType>emptyList(), SourceElement.NO_SOURCE);
|
||||
Modality.OPEN, Collections.<KotlinType>emptyList(), SourceElement.NO_SOURCE);
|
||||
|
||||
ConstructorDescriptorImpl errorConstructor = ConstructorDescriptorImpl.create(this, Annotations.Companion.getEMPTY(), true, SourceElement.NO_SOURCE);
|
||||
errorConstructor.initialize(Collections.<TypeParameterDescriptor>emptyList(), Collections.<ValueParameterDescriptor>emptyList(),
|
||||
@@ -460,7 +460,7 @@ public class ErrorUtils {
|
||||
return new ErrorScope(debugMessage);
|
||||
}
|
||||
|
||||
private static final KtType ERROR_PROPERTY_TYPE = createErrorType("<ERROR PROPERTY TYPE>");
|
||||
private static final KotlinType ERROR_PROPERTY_TYPE = createErrorType("<ERROR PROPERTY TYPE>");
|
||||
private static final PropertyDescriptor ERROR_PROPERTY = createErrorProperty();
|
||||
|
||||
private static final Set<VariableDescriptor> ERROR_VARIABLE_GROUP = Collections.<VariableDescriptor>singleton(ERROR_PROPERTY);
|
||||
@@ -483,7 +483,7 @@ public class ErrorUtils {
|
||||
descriptor.setType(ERROR_PROPERTY_TYPE,
|
||||
Collections.<TypeParameterDescriptor>emptyList(),
|
||||
null,
|
||||
(KtType) null
|
||||
(KotlinType) null
|
||||
);
|
||||
|
||||
return descriptor;
|
||||
@@ -505,22 +505,22 @@ public class ErrorUtils {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static KtType createErrorType(@NotNull String debugMessage) {
|
||||
public static KotlinType createErrorType(@NotNull String debugMessage) {
|
||||
return createErrorTypeWithArguments(debugMessage, Collections.<TypeProjection>emptyList());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static KtType createErrorTypeWithCustomDebugName(@NotNull String debugName) {
|
||||
public static KotlinType createErrorTypeWithCustomDebugName(@NotNull String debugName) {
|
||||
return createErrorTypeWithCustomConstructor(debugName, createErrorTypeConstructorWithCustomDebugName(debugName));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static KtType createErrorTypeWithCustomConstructor(@NotNull String debugName, @NotNull TypeConstructor typeConstructor) {
|
||||
public static KotlinType createErrorTypeWithCustomConstructor(@NotNull String debugName, @NotNull TypeConstructor typeConstructor) {
|
||||
return new ErrorTypeImpl(typeConstructor, createErrorScope(debugName));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static KtType createErrorTypeWithArguments(@NotNull String debugMessage, @NotNull List<TypeProjection> arguments) {
|
||||
public static KotlinType createErrorTypeWithArguments(@NotNull String debugMessage, @NotNull List<TypeProjection> arguments) {
|
||||
return new ErrorTypeImpl(createErrorTypeConstructor(debugMessage), createErrorScope(debugMessage), arguments);
|
||||
}
|
||||
|
||||
@@ -547,7 +547,7 @@ public class ErrorUtils {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<KtType> getSupertypes() {
|
||||
public Collection<KotlinType> getSupertypes() {
|
||||
return emptyList();
|
||||
}
|
||||
|
||||
@@ -586,7 +586,7 @@ public class ErrorUtils {
|
||||
};
|
||||
}
|
||||
|
||||
public static boolean containsErrorType(@Nullable KtType type) {
|
||||
public static boolean containsErrorType(@Nullable KotlinType type) {
|
||||
if (type == null) return false;
|
||||
if (type.isError()) return true;
|
||||
for (TypeProjection projection : type.getArguments()) {
|
||||
@@ -615,7 +615,7 @@ public class ErrorUtils {
|
||||
);
|
||||
}
|
||||
|
||||
private static class ErrorTypeImpl implements KtType {
|
||||
private static class ErrorTypeImpl implements KotlinType {
|
||||
private final TypeConstructor constructor;
|
||||
private final KtScope memberScope;
|
||||
private final List<TypeProjection> arguments;
|
||||
@@ -697,21 +697,21 @@ public class ErrorUtils {
|
||||
return ERROR_MODULE;
|
||||
}
|
||||
|
||||
public static boolean isUninferredParameter(@Nullable KtType type) {
|
||||
public static boolean isUninferredParameter(@Nullable KotlinType type) {
|
||||
return type != null && type.getConstructor() instanceof UninferredParameterTypeConstructor;
|
||||
}
|
||||
|
||||
public static boolean containsUninferredParameter(@Nullable KtType type) {
|
||||
return TypeUtils.containsSpecialType(type, new Function1<KtType, Boolean>() {
|
||||
public static boolean containsUninferredParameter(@Nullable KotlinType type) {
|
||||
return TypeUtils.containsSpecialType(type, new Function1<KotlinType, Boolean>() {
|
||||
@Override
|
||||
public Boolean invoke(KtType argumentType) {
|
||||
public Boolean invoke(KotlinType argumentType) {
|
||||
return isUninferredParameter(argumentType);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static KtType createUninferredParameterType(@NotNull TypeParameterDescriptor typeParameterDescriptor) {
|
||||
public static KotlinType createUninferredParameterType(@NotNull TypeParameterDescriptor typeParameterDescriptor) {
|
||||
return createErrorTypeWithCustomConstructor("Scope for error type for not inferred parameter: " + typeParameterDescriptor.getName(),
|
||||
new UninferredParameterTypeConstructor(typeParameterDescriptor));
|
||||
}
|
||||
@@ -738,7 +738,7 @@ public class ErrorUtils {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<KtType> getSupertypes() {
|
||||
public Collection<KotlinType> getSupertypes() {
|
||||
return errorTypeConstructor.getSupertypes();
|
||||
}
|
||||
|
||||
|
||||
@@ -23,9 +23,9 @@ import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
|
||||
class FunctionPlaceholders(private val builtIns: KotlinBuiltIns) {
|
||||
fun createFunctionPlaceholderType(
|
||||
argumentTypes: List<KtType>,
|
||||
argumentTypes: List<KotlinType>,
|
||||
hasDeclaredArguments: Boolean
|
||||
): KtType {
|
||||
): KotlinType {
|
||||
return ErrorUtils.createErrorTypeWithCustomConstructor(
|
||||
"function placeholder type",
|
||||
FunctionPlaceholderTypeConstructor(argumentTypes, hasDeclaredArguments, builtIns)
|
||||
@@ -33,13 +33,13 @@ class FunctionPlaceholders(private val builtIns: KotlinBuiltIns) {
|
||||
}
|
||||
}
|
||||
|
||||
val KtType?.isFunctionPlaceholder: Boolean
|
||||
val KotlinType?.isFunctionPlaceholder: Boolean
|
||||
get() {
|
||||
return this != null && constructor is FunctionPlaceholderTypeConstructor
|
||||
}
|
||||
|
||||
class FunctionPlaceholderTypeConstructor(
|
||||
val argumentTypes: List<KtType>,
|
||||
val argumentTypes: List<KotlinType>,
|
||||
val hasDeclaredArguments: Boolean,
|
||||
private val kotlinBuiltIns: KotlinBuiltIns
|
||||
) : TypeConstructor {
|
||||
@@ -49,7 +49,7 @@ class FunctionPlaceholderTypeConstructor(
|
||||
return errorTypeConstructor.parameters
|
||||
}
|
||||
|
||||
override fun getSupertypes(): Collection<KtType> {
|
||||
override fun getSupertypes(): Collection<KotlinType> {
|
||||
return errorTypeConstructor.supertypes
|
||||
}
|
||||
|
||||
|
||||
@@ -26,14 +26,14 @@ import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
||||
import java.util.*;
|
||||
|
||||
public class IntersectionTypeConstructor extends AnnotatedImpl implements TypeConstructor {
|
||||
private final Set<KtType> intersectedTypes;
|
||||
private final Set<KotlinType> intersectedTypes;
|
||||
private final int hashCode;
|
||||
|
||||
public IntersectionTypeConstructor(Annotations annotations, Collection<KtType> typesToIntersect) {
|
||||
public IntersectionTypeConstructor(Annotations annotations, Collection<KotlinType> typesToIntersect) {
|
||||
super(annotations);
|
||||
assert !typesToIntersect.isEmpty() : "Attempt to create an empty intersection";
|
||||
|
||||
this.intersectedTypes = new LinkedHashSet<KtType>(typesToIntersect);
|
||||
this.intersectedTypes = new LinkedHashSet<KotlinType>(typesToIntersect);
|
||||
this.hashCode = intersectedTypes.hashCode();
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ public class IntersectionTypeConstructor extends AnnotatedImpl implements TypeCo
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<KtType> getSupertypes() {
|
||||
public Collection<KotlinType> getSupertypes() {
|
||||
return intersectedTypes;
|
||||
}
|
||||
|
||||
@@ -75,10 +75,10 @@ public class IntersectionTypeConstructor extends AnnotatedImpl implements TypeCo
|
||||
return makeDebugNameForIntersectionType(intersectedTypes);
|
||||
}
|
||||
|
||||
private static String makeDebugNameForIntersectionType(Iterable<KtType> resultingTypes) {
|
||||
private static String makeDebugNameForIntersectionType(Iterable<KotlinType> resultingTypes) {
|
||||
StringBuilder debugName = new StringBuilder("{");
|
||||
for (Iterator<KtType> iterator = resultingTypes.iterator(); iterator.hasNext(); ) {
|
||||
KtType type = iterator.next();
|
||||
for (Iterator<KotlinType> iterator = resultingTypes.iterator(); iterator.hasNext(); ) {
|
||||
KotlinType type = iterator.next();
|
||||
|
||||
debugName.append(type.toString());
|
||||
if (iterator.hasNext()) {
|
||||
|
||||
+2
-2
@@ -26,9 +26,9 @@ import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @see KotlinTypeChecker#isSubtypeOf(KtType, KtType)
|
||||
* @see KotlinTypeChecker#isSubtypeOf(KotlinType, KotlinType)
|
||||
*/
|
||||
public interface KtType extends Annotated {
|
||||
public interface KotlinType extends Annotated {
|
||||
@NotNull
|
||||
TypeConstructor getConstructor();
|
||||
|
||||
+9
-9
@@ -20,7 +20,7 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.resolve.scopes.KtScope
|
||||
|
||||
public open class KtTypeImpl
|
||||
public open class KotlinTypeImpl
|
||||
private constructor(
|
||||
private val annotations: Annotations,
|
||||
private val constructor: TypeConstructor,
|
||||
@@ -28,7 +28,7 @@ private constructor(
|
||||
private val arguments: List<TypeProjection>,
|
||||
private val substitution: TypeSubstitution?,
|
||||
private val memberScope: KtScope
|
||||
) : AbstractKtType() {
|
||||
) : AbstractKotlinType() {
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
@@ -36,9 +36,9 @@ private constructor(
|
||||
constructor: TypeConstructor,
|
||||
nullable: Boolean,
|
||||
arguments: List<TypeProjection>,
|
||||
memberScope: KtScope): KtTypeImpl
|
||||
memberScope: KtScope): KotlinTypeImpl
|
||||
|
||||
= KtTypeImpl(annotations, constructor, nullable, arguments, null, memberScope)
|
||||
= KotlinTypeImpl(annotations, constructor, nullable, arguments, null, memberScope)
|
||||
|
||||
@JvmStatic
|
||||
public fun create(annotations: Annotations,
|
||||
@@ -48,20 +48,20 @@ private constructor(
|
||||
substitution: TypeSubstitution,
|
||||
memberScope: KtScope,
|
||||
capabilities: TypeCapabilities
|
||||
): KtTypeImpl {
|
||||
): KotlinTypeImpl {
|
||||
if (capabilities !== TypeCapabilities.NONE) {
|
||||
return WithCapabilities(annotations, constructor, nullable, arguments, substitution, memberScope, capabilities)
|
||||
}
|
||||
return KtTypeImpl(annotations, constructor, nullable, arguments, substitution, memberScope)
|
||||
return KotlinTypeImpl(annotations, constructor, nullable, arguments, substitution, memberScope)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
public fun create(annotations: Annotations,
|
||||
descriptor: ClassDescriptor,
|
||||
nullable: Boolean,
|
||||
arguments: List<TypeProjection>): KtTypeImpl
|
||||
arguments: List<TypeProjection>): KotlinTypeImpl
|
||||
|
||||
= KtTypeImpl(
|
||||
= KotlinTypeImpl(
|
||||
annotations, descriptor.typeConstructor, nullable, arguments, null, descriptor.getMemberScope(arguments)
|
||||
)
|
||||
}
|
||||
@@ -74,7 +74,7 @@ private constructor(
|
||||
substitution: TypeSubstitution?,
|
||||
memberScope: KtScope,
|
||||
private val typeCapabilities: TypeCapabilities
|
||||
) : KtTypeImpl(annotations, constructor, nullable, arguments, substitution, memberScope) {
|
||||
) : KotlinTypeImpl(annotations, constructor, nullable, arguments, substitution, memberScope) {
|
||||
override fun getCapabilities(): TypeCapabilities = typeCapabilities
|
||||
}
|
||||
|
||||
@@ -16,5 +16,5 @@
|
||||
|
||||
package org.jetbrains.kotlin.types;
|
||||
|
||||
public interface LazyType extends KtType {
|
||||
public interface LazyType extends KotlinType {
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user