rename Jet* classes to Kt*
This commit is contained in:
+22
-22
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaField;
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaMember;
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaMethod;
|
||||
import org.jetbrains.kotlin.types.JetType;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -34,8 +34,8 @@ public interface ExternalSignatureResolver {
|
||||
public PropagatedMethodSignature resolvePropagatedSignature(
|
||||
@NotNull JavaMethod method,
|
||||
@NotNull ClassDescriptor owner,
|
||||
@NotNull JetType returnType,
|
||||
@Nullable JetType receiverType,
|
||||
@NotNull KtType returnType,
|
||||
@Nullable KtType receiverType,
|
||||
@NotNull List<ValueParameterDescriptor> valueParameters,
|
||||
@NotNull List<TypeParameterDescriptor> typeParameters
|
||||
) {
|
||||
@@ -50,8 +50,8 @@ public interface ExternalSignatureResolver {
|
||||
public AlternativeMethodSignature resolveAlternativeMethodSignature(
|
||||
@NotNull JavaMember methodOrConstructor,
|
||||
boolean hasSuperMethods,
|
||||
@Nullable JetType returnType,
|
||||
@Nullable JetType receiverType,
|
||||
@Nullable KtType returnType,
|
||||
@Nullable KtType receiverType,
|
||||
@NotNull List<ValueParameterDescriptor> valueParameters,
|
||||
@NotNull List<TypeParameterDescriptor> typeParameters,
|
||||
boolean hasStableParameterNames
|
||||
@@ -64,7 +64,7 @@ public interface ExternalSignatureResolver {
|
||||
@NotNull
|
||||
@Override
|
||||
public AlternativeFieldSignature resolveAlternativeFieldSignature(
|
||||
@NotNull JavaField field, @NotNull JetType returnType, boolean isVar
|
||||
@NotNull JavaField field, @NotNull KtType returnType, boolean isVar
|
||||
) {
|
||||
return new AlternativeFieldSignature(returnType, null);
|
||||
}
|
||||
@@ -89,15 +89,15 @@ public interface ExternalSignatureResolver {
|
||||
}
|
||||
|
||||
class AlternativeMethodSignature extends MemberSignature {
|
||||
private final JetType returnType;
|
||||
private final JetType receiverType;
|
||||
private final KtType returnType;
|
||||
private final KtType receiverType;
|
||||
private final List<ValueParameterDescriptor> valueParameters;
|
||||
private final List<TypeParameterDescriptor> typeParameters;
|
||||
private final boolean hasStableParameterNames;
|
||||
|
||||
public AlternativeMethodSignature(
|
||||
@Nullable JetType returnType,
|
||||
@Nullable JetType receiverType,
|
||||
@Nullable KtType returnType,
|
||||
@Nullable KtType receiverType,
|
||||
@NotNull List<ValueParameterDescriptor> valueParameters,
|
||||
@NotNull List<TypeParameterDescriptor> typeParameters,
|
||||
@NotNull List<String> signatureErrors,
|
||||
@@ -112,12 +112,12 @@ public interface ExternalSignatureResolver {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public JetType getReturnType() {
|
||||
public KtType getReturnType() {
|
||||
return returnType;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public JetType getReceiverType() {
|
||||
public KtType getReceiverType() {
|
||||
return receiverType;
|
||||
}
|
||||
|
||||
@@ -137,15 +137,15 @@ public interface ExternalSignatureResolver {
|
||||
}
|
||||
|
||||
class AlternativeFieldSignature extends MemberSignature {
|
||||
private final JetType returnType;
|
||||
private final KtType returnType;
|
||||
|
||||
public AlternativeFieldSignature(@NotNull JetType returnType, @Nullable String signatureError) {
|
||||
public AlternativeFieldSignature(@NotNull KtType returnType, @Nullable String signatureError) {
|
||||
super(signatureError == null ? Collections.<String>emptyList() : Collections.singletonList(signatureError));
|
||||
this.returnType = returnType;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JetType getReturnType() {
|
||||
public KtType getReturnType() {
|
||||
return returnType;
|
||||
}
|
||||
}
|
||||
@@ -154,8 +154,8 @@ public interface ExternalSignatureResolver {
|
||||
private final List<FunctionDescriptor> superMethods;
|
||||
|
||||
public PropagatedMethodSignature(
|
||||
@Nullable JetType returnType,
|
||||
@Nullable JetType receiverType,
|
||||
@Nullable KtType returnType,
|
||||
@Nullable KtType receiverType,
|
||||
@NotNull List<ValueParameterDescriptor> valueParameters,
|
||||
@NotNull List<TypeParameterDescriptor> typeParameters,
|
||||
@NotNull List<String> signatureErrors,
|
||||
@@ -176,8 +176,8 @@ public interface ExternalSignatureResolver {
|
||||
PropagatedMethodSignature resolvePropagatedSignature(
|
||||
@NotNull JavaMethod method,
|
||||
@NotNull ClassDescriptor owner,
|
||||
@NotNull JetType returnType,
|
||||
@Nullable JetType receiverType,
|
||||
@NotNull KtType returnType,
|
||||
@Nullable KtType receiverType,
|
||||
@NotNull List<ValueParameterDescriptor> valueParameters,
|
||||
@NotNull List<TypeParameterDescriptor> typeParameters
|
||||
);
|
||||
@@ -186,8 +186,8 @@ public interface ExternalSignatureResolver {
|
||||
AlternativeMethodSignature resolveAlternativeMethodSignature(
|
||||
@NotNull JavaMember methodOrConstructor,
|
||||
boolean hasSuperMethods,
|
||||
@Nullable JetType returnType,
|
||||
@Nullable JetType receiverType,
|
||||
@Nullable KtType returnType,
|
||||
@Nullable KtType receiverType,
|
||||
@NotNull List<ValueParameterDescriptor> valueParameters,
|
||||
@NotNull List<TypeParameterDescriptor> typeParameters,
|
||||
boolean hasStableParameterNames
|
||||
@@ -196,7 +196,7 @@ public interface ExternalSignatureResolver {
|
||||
@NotNull
|
||||
AlternativeFieldSignature resolveAlternativeFieldSignature(
|
||||
@NotNull JavaField field,
|
||||
@NotNull JetType returnType,
|
||||
@NotNull KtType returnType,
|
||||
boolean isVar
|
||||
);
|
||||
|
||||
|
||||
+6
-6
@@ -21,24 +21,24 @@ import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor
|
||||
import org.jetbrains.kotlin.load.java.descriptors.SamConstructorDescriptor
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaMethod
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||
import org.jetbrains.kotlin.types.JetType
|
||||
import org.jetbrains.kotlin.resolve.scopes.KtScope
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
|
||||
public interface SamConversionResolver {
|
||||
public companion object EMPTY : SamConversionResolver {
|
||||
override fun <D : FunctionDescriptor> resolveSamAdapter(original: D) = null
|
||||
override fun resolveSamConstructor(name: Name, scope: JetScope) = null
|
||||
override fun resolveSamConstructor(name: Name, scope: KtScope) = null
|
||||
override fun resolveFunctionTypeIfSamInterface(
|
||||
classDescriptor: JavaClassDescriptor, resolveMethod: (JavaMethod) -> FunctionDescriptor
|
||||
): JetType? = null
|
||||
): KtType? = null
|
||||
}
|
||||
|
||||
public fun resolveSamConstructor(name: Name, scope: JetScope): SamConstructorDescriptor?
|
||||
public fun resolveSamConstructor(name: Name, scope: KtScope): SamConstructorDescriptor?
|
||||
|
||||
public fun <D : FunctionDescriptor> resolveSamAdapter(original: D): D?
|
||||
|
||||
public fun resolveFunctionTypeIfSamInterface(
|
||||
classDescriptor: JavaClassDescriptor,
|
||||
resolveMethod: (JavaMethod) -> FunctionDescriptor
|
||||
): JetType?
|
||||
): KtType?
|
||||
}
|
||||
|
||||
+4
-5
@@ -19,16 +19,15 @@ package org.jetbrains.kotlin.load.java.descriptors;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor;
|
||||
import org.jetbrains.kotlin.types.JetType;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface JavaCallableMemberDescriptor extends CallableMemberDescriptor {
|
||||
@NotNull
|
||||
JavaCallableMemberDescriptor enhance(
|
||||
@Nullable JetType enhancedReceiverType,
|
||||
@NotNull List<JetType> enhancedValueParametersTypes,
|
||||
@NotNull JetType enhancedReturnType
|
||||
@Nullable KtType enhancedReceiverType,
|
||||
@NotNull List<KtType> enhancedValueParametersTypes,
|
||||
@NotNull KtType enhancedReturnType
|
||||
);
|
||||
}
|
||||
|
||||
+2
-2
@@ -18,9 +18,9 @@ package org.jetbrains.kotlin.load.java.descriptors;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.kotlin.types.JetType;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
|
||||
public interface JavaClassDescriptor extends ClassDescriptor {
|
||||
@Nullable
|
||||
JetType getFunctionTypeForSamInterface();
|
||||
KtType getFunctionTypeForSamInterface();
|
||||
}
|
||||
|
||||
+4
-4
@@ -21,7 +21,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.kotlin.descriptors.impl.ConstructorDescriptorImpl;
|
||||
import org.jetbrains.kotlin.types.JetType;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -96,9 +96,9 @@ public class JavaConstructorDescriptor extends ConstructorDescriptorImpl impleme
|
||||
@Override
|
||||
@NotNull
|
||||
public JavaConstructorDescriptor enhance(
|
||||
@Nullable JetType enhancedReceiverType,
|
||||
@NotNull List<JetType> enhancedValueParametersTypes,
|
||||
@NotNull JetType enhancedReturnType
|
||||
@Nullable KtType enhancedReceiverType,
|
||||
@NotNull List<KtType> enhancedValueParametersTypes,
|
||||
@NotNull KtType enhancedReturnType
|
||||
) {
|
||||
JavaConstructorDescriptor enhanced = createSubstitutedCopy(getContainingDeclaration(), getOriginal(), getKind());
|
||||
// We do not use doSubstitute here as in JavaMethodDescriptor.enhance because type parameters of constructor belongs to class
|
||||
|
||||
+6
-6
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.types.JetType;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.TypeSubstitutor;
|
||||
import org.jetbrains.kotlin.util.OperatorChecks;
|
||||
|
||||
@@ -77,11 +77,11 @@ public class JavaMethodDescriptor extends SimpleFunctionDescriptorImpl implement
|
||||
@NotNull
|
||||
@Override
|
||||
public SimpleFunctionDescriptorImpl initialize(
|
||||
@Nullable JetType receiverParameterType,
|
||||
@Nullable KtType receiverParameterType,
|
||||
@Nullable ReceiverParameterDescriptor dispatchReceiverParameter,
|
||||
@NotNull List<? extends TypeParameterDescriptor> typeParameters,
|
||||
@NotNull List<ValueParameterDescriptor> unsubstitutedValueParameters,
|
||||
@Nullable JetType unsubstitutedReturnType,
|
||||
@Nullable KtType unsubstitutedReturnType,
|
||||
@Nullable Modality modality,
|
||||
@NotNull Visibility visibility
|
||||
) {
|
||||
@@ -130,9 +130,9 @@ public class JavaMethodDescriptor extends SimpleFunctionDescriptorImpl implement
|
||||
@Override
|
||||
@NotNull
|
||||
public JavaMethodDescriptor enhance(
|
||||
@Nullable JetType enhancedReceiverType,
|
||||
@NotNull List<JetType> enhancedValueParametersTypes,
|
||||
@NotNull JetType enhancedReturnType
|
||||
@Nullable KtType enhancedReceiverType,
|
||||
@NotNull List<KtType> enhancedValueParametersTypes,
|
||||
@NotNull KtType enhancedReturnType
|
||||
) {
|
||||
List<ValueParameterDescriptor> enhancedValueParameters =
|
||||
UtilKt.copyValueParameters(enhancedValueParametersTypes, getValueParameters(), this);
|
||||
|
||||
+4
-4
@@ -24,7 +24,7 @@ import org.jetbrains.kotlin.descriptors.impl.PropertyDescriptorImpl;
|
||||
import org.jetbrains.kotlin.descriptors.impl.PropertyGetterDescriptorImpl;
|
||||
import org.jetbrains.kotlin.descriptors.impl.PropertySetterDescriptorImpl;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.types.JetType;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -55,9 +55,9 @@ public class JavaPropertyDescriptor extends PropertyDescriptorImpl implements Ja
|
||||
@NotNull
|
||||
@Override
|
||||
public JavaCallableMemberDescriptor enhance(
|
||||
@Nullable JetType enhancedReceiverType,
|
||||
@NotNull List<JetType> enhancedValueParametersTypes,
|
||||
@NotNull JetType enhancedReturnType
|
||||
@Nullable KtType enhancedReceiverType,
|
||||
@NotNull List<KtType> enhancedValueParametersTypes,
|
||||
@NotNull KtType enhancedReturnType
|
||||
) {
|
||||
JavaPropertyDescriptor enhanced = new JavaPropertyDescriptor(
|
||||
getContainingDeclaration(),
|
||||
|
||||
@@ -29,10 +29,10 @@ import org.jetbrains.kotlin.serialization.ProtoBuf
|
||||
import org.jetbrains.kotlin.serialization.deserialization.NameResolver
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedCallableMemberDescriptor
|
||||
import org.jetbrains.kotlin.serialization.jvm.JvmProtoBuf
|
||||
import org.jetbrains.kotlin.types.JetType
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
|
||||
fun copyValueParameters(
|
||||
newValueParametersTypes: Collection<JetType>,
|
||||
newValueParametersTypes: Collection<KtType>,
|
||||
oldValueParameters: Collection<ValueParameterDescriptor>,
|
||||
newOwner: CallableDescriptor
|
||||
): List<ValueParameterDescriptor> {
|
||||
|
||||
+1
-1
@@ -65,7 +65,7 @@ class LazyJavaAnnotationDescriptor(
|
||||
|
||||
private val factory = ConstantValueFactory(c.module.builtIns)
|
||||
|
||||
override fun getType(): JetType = type()
|
||||
override fun getType(): KtType = type()
|
||||
|
||||
private val allValueArguments = c.storageManager.createLazyValue {
|
||||
computeValueArguments()
|
||||
|
||||
+10
-10
@@ -35,7 +35,7 @@ import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.isValidJavaFqName
|
||||
import org.jetbrains.kotlin.resolve.constants.StringValue
|
||||
import org.jetbrains.kotlin.resolve.scopes.InnerClassesScopeWrapper
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.KtScope
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
import org.jetbrains.kotlin.utils.toReadOnlyList
|
||||
@@ -82,10 +82,10 @@ class LazyJavaClassDescriptor(
|
||||
override fun getUnsubstitutedMemberScope() = unsubstitutedMemberScope
|
||||
|
||||
private val innerClassesScope = InnerClassesScopeWrapper(getUnsubstitutedMemberScope())
|
||||
override fun getUnsubstitutedInnerClassesScope(): JetScope = innerClassesScope
|
||||
override fun getUnsubstitutedInnerClassesScope(): KtScope = innerClassesScope
|
||||
|
||||
private val staticScope = LazyJavaStaticClassScope(c, jClass, this)
|
||||
override fun getStaticScope(): JetScope = staticScope
|
||||
override fun getStaticScope(): KtScope = staticScope
|
||||
|
||||
override fun getUnsubstitutedPrimaryConstructor(): ConstructorDescriptor? = null
|
||||
|
||||
@@ -102,7 +102,7 @@ class LazyJavaClassDescriptor(
|
||||
}
|
||||
}
|
||||
|
||||
override fun getFunctionTypeForSamInterface(): JetType? = functionTypeForSamInterface()
|
||||
override fun getFunctionTypeForSamInterface(): KtType? = functionTypeForSamInterface()
|
||||
|
||||
override fun isCompanionObject() = false
|
||||
|
||||
@@ -120,12 +120,12 @@ class LazyJavaClassDescriptor(
|
||||
|
||||
override fun getParameters(): List<TypeParameterDescriptor> = parameters()
|
||||
|
||||
private val supertypes = c.storageManager.createLazyValue<Collection<JetType>> {
|
||||
private val supertypes = c.storageManager.createLazyValue<Collection<KtType>> {
|
||||
val javaTypes = jClass.getSupertypes()
|
||||
val result = ArrayList<JetType>(javaTypes.size())
|
||||
val result = ArrayList<KtType>(javaTypes.size())
|
||||
val incomplete = ArrayList<JavaType>(0)
|
||||
|
||||
val purelyImplementedSupertype: JetType? = getPurelyImplementedSupertype()
|
||||
val purelyImplementedSupertype: KtType? = getPurelyImplementedSupertype()
|
||||
|
||||
for (javaType in javaTypes) {
|
||||
val jetType = c.typeResolver.transformJavaType(javaType, TypeUsage.SUPERTYPE.toAttributes())
|
||||
@@ -154,7 +154,7 @@ class LazyJavaClassDescriptor(
|
||||
if (result.isNotEmpty()) result.toReadOnlyList() else listOf(c.module.builtIns.getAnyType())
|
||||
}
|
||||
|
||||
private fun getPurelyImplementedSupertype(): JetType? {
|
||||
private fun getPurelyImplementedSupertype(): KtType? {
|
||||
val purelyImplementedFqName = getPurelyImplementsFqNameFromAnnotation()
|
||||
?: FakePureImplementationsProvider.getPurelyImplementedInterface(fqName)
|
||||
?: return null
|
||||
@@ -169,7 +169,7 @@ class LazyJavaClassDescriptor(
|
||||
parameter -> TypeProjectionImpl(Variance.INVARIANT, parameter.getDefaultType())
|
||||
}
|
||||
|
||||
return JetTypeImpl.create(
|
||||
return KtTypeImpl.create(
|
||||
Annotations.EMPTY, classDescriptor,
|
||||
/* nullable =*/ false, parametersAsTypeProjections
|
||||
)
|
||||
@@ -186,7 +186,7 @@ class LazyJavaClassDescriptor(
|
||||
return FqName(fqNameString)
|
||||
}
|
||||
|
||||
override fun getSupertypes(): Collection<JetType> = supertypes()
|
||||
override fun getSupertypes(): Collection<KtType> = supertypes()
|
||||
|
||||
override fun getAnnotations() = Annotations.EMPTY
|
||||
|
||||
|
||||
+13
-13
@@ -52,9 +52,9 @@ import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.OverridingUtil
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||
import org.jetbrains.kotlin.serialization.deserialization.ErrorReporter
|
||||
import org.jetbrains.kotlin.types.JetType
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
import org.jetbrains.kotlin.types.checker.JetTypeChecker
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
|
||||
import org.jetbrains.kotlin.utils.*
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.check
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.firstNotNullResult
|
||||
@@ -165,7 +165,7 @@ public class LazyJavaClassMemberScope(
|
||||
val descriptor = resolveMethodToFunctionDescriptor(javaMethod)
|
||||
if (descriptor.valueParameters.size != 0) return@factory null
|
||||
|
||||
descriptor.check { JetTypeChecker.DEFAULT.isSubtypeOf(descriptor.returnType ?: return@check false, type) }
|
||||
descriptor.check { KotlinTypeChecker.DEFAULT.isSubtypeOf(descriptor.returnType ?: return@check false, type) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ public class LazyJavaClassMemberScope(
|
||||
if (descriptor.valueParameters.size != 1) return@factory null
|
||||
|
||||
if (!KotlinBuiltIns.isUnit(descriptor.returnType ?: return@factory null)) return@factory null
|
||||
descriptor.check { JetTypeChecker.DEFAULT.equalTypes(descriptor.valueParameters.single().type, type) }
|
||||
descriptor.check { KotlinTypeChecker.DEFAULT.equalTypes(descriptor.valueParameters.single().type, type) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -263,7 +263,7 @@ public class LazyJavaClassMemberScope(
|
||||
}
|
||||
|
||||
private fun createPropertyDescriptorWithDefaultGetter(
|
||||
method: JavaMethod, givenType: JetType? = null, modality: Modality
|
||||
method: JavaMethod, givenType: KtType? = null, modality: Modality
|
||||
): JavaPropertyDescriptor {
|
||||
val annotations = c.resolveAnnotations(method)
|
||||
|
||||
@@ -277,7 +277,7 @@ public class LazyJavaClassMemberScope(
|
||||
propertyDescriptor.initialize(getter, null)
|
||||
|
||||
val returnType = givenType ?: computeMethodReturnType(method, annotations, c.child(propertyDescriptor, method))
|
||||
propertyDescriptor.setType(returnType, listOf(), getDispatchReceiverParameter(), null as JetType?)
|
||||
propertyDescriptor.setType(returnType, listOf(), getDispatchReceiverParameter(), null as KtType?)
|
||||
getter.initialize(returnType)
|
||||
|
||||
return propertyDescriptor
|
||||
@@ -302,7 +302,7 @@ public class LazyJavaClassMemberScope(
|
||||
/* isStaticFinal = */ false
|
||||
)
|
||||
|
||||
propertyDescriptor.setType(getterMethod.returnType!!, listOf(), getDispatchReceiverParameter(), null as JetType?)
|
||||
propertyDescriptor.setType(getterMethod.returnType!!, listOf(), getDispatchReceiverParameter(), null as KtType?)
|
||||
|
||||
val getter = DescriptorFactory.createGetter(
|
||||
propertyDescriptor, getterMethod.annotations, /* isDefault = */false,
|
||||
@@ -326,7 +326,7 @@ public class LazyJavaClassMemberScope(
|
||||
}
|
||||
|
||||
override fun resolveMethodSignature(
|
||||
method: JavaMethod, methodTypeParameters: List<TypeParameterDescriptor>, returnType: JetType,
|
||||
method: JavaMethod, methodTypeParameters: List<TypeParameterDescriptor>, returnType: KtType,
|
||||
valueParameters: LazyJavaScope.ResolvedValueParameters
|
||||
): LazyJavaScope.MethodSignatureData {
|
||||
val propagated = c.components.externalSignatureResolver.resolvePropagatedSignature(
|
||||
@@ -406,12 +406,12 @@ public class LazyJavaClassMemberScope(
|
||||
val currentType = valueParameters[index].type
|
||||
val overriddenCandidate = RawSubstitution.eraseType(
|
||||
builtinWithErasedParameters.original.valueParameters[index].type)
|
||||
JetTypeChecker.DEFAULT.equalTypes(currentType, overriddenCandidate)
|
||||
KotlinTypeChecker.DEFAULT.equalTypes(currentType, overriddenCandidate)
|
||||
} && returnType.isSubtypeOf(builtinWithErasedParameters.returnType)
|
||||
}
|
||||
|
||||
private fun JetType?.isSubtypeOf(other: JetType?): Boolean {
|
||||
return JetTypeChecker.DEFAULT.isSubtypeOf(this ?: return false, other ?: return false)
|
||||
private fun KtType?.isSubtypeOf(other: KtType?): Boolean {
|
||||
return KotlinTypeChecker.DEFAULT.isSubtypeOf(this ?: return false, other ?: return false)
|
||||
}
|
||||
|
||||
private fun resolveConstructor(constructor: JavaConstructor): JavaConstructorDescriptor {
|
||||
@@ -510,8 +510,8 @@ public class LazyJavaClassMemberScope(
|
||||
constructor: ConstructorDescriptor,
|
||||
index: Int,
|
||||
method: JavaMethod,
|
||||
returnType: JetType,
|
||||
varargElementType: JetType?
|
||||
returnType: KtType,
|
||||
varargElementType: KtType?
|
||||
) {
|
||||
add(ValueParameterDescriptorImpl(
|
||||
constructor,
|
||||
|
||||
+2
-2
@@ -35,7 +35,7 @@ import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.name.SpecialNames
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.KtScope
|
||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
|
||||
public class LazyJavaPackageScope(
|
||||
@@ -75,7 +75,7 @@ public class LazyJavaPackageScope(
|
||||
c.components.deserializedDescriptorResolver.readData(binaryClass, DeserializedDescriptorResolver.KOTLIN_PACKAGE_FACADE)
|
||||
}
|
||||
|
||||
JetScope.Empty
|
||||
KtScope.Empty
|
||||
}
|
||||
else {
|
||||
c.components.deserializedDescriptorResolver.createKotlinPackageScope(packageFragment, containingDeclaration.kotlinBinaryClasses)
|
||||
|
||||
+9
-9
@@ -40,10 +40,10 @@ import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.jvm.PLATFORM_TYPES
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindExclude.NonExtensions
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScopeImpl
|
||||
import org.jetbrains.kotlin.resolve.scopes.KtScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.KtScopeImpl
|
||||
import org.jetbrains.kotlin.storage.NotNullLazyValue
|
||||
import org.jetbrains.kotlin.types.JetType
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
import org.jetbrains.kotlin.utils.Printer
|
||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
@@ -53,11 +53,11 @@ import java.util.*
|
||||
public abstract class LazyJavaScope(
|
||||
protected val c: LazyJavaResolverContext,
|
||||
private val containingDeclaration: DeclarationDescriptor
|
||||
) : JetScopeImpl() {
|
||||
) : KtScopeImpl() {
|
||||
// this lazy value is not used at all in LazyPackageFragmentScopeForJavaPackage because we do not use caching there
|
||||
// but is placed in the base class to not duplicate code
|
||||
private val allDescriptors = c.storageManager.createRecursionTolerantLazyValue<Collection<DeclarationDescriptor>>(
|
||||
{ computeDescriptors(DescriptorKindFilter.ALL, JetScope.ALL_NAME_FILTER, NoLookupLocation.WHEN_GET_ALL_DESCRIPTORS) },
|
||||
{ computeDescriptors(DescriptorKindFilter.ALL, KtScope.ALL_NAME_FILTER, NoLookupLocation.WHEN_GET_ALL_DESCRIPTORS) },
|
||||
// This is to avoid the following recursive case:
|
||||
// when computing getAllPackageNames() we ask the JavaPsiFacade for all subpackages of foo
|
||||
// it, in turn, asks JavaElementFinder for subpackages of Kotlin package foo, which calls getAllPackageNames() recursively
|
||||
@@ -106,7 +106,7 @@ public abstract class LazyJavaScope(
|
||||
protected abstract fun resolveMethodSignature(
|
||||
method: JavaMethod,
|
||||
methodTypeParameters: List<TypeParameterDescriptor>,
|
||||
returnType: JetType,
|
||||
returnType: KtType,
|
||||
valueParameters: ResolvedValueParameters): MethodSignatureData
|
||||
|
||||
open fun resolveMethodToFunctionDescriptor(method: JavaMethod): JavaMethodDescriptor {
|
||||
@@ -147,7 +147,7 @@ public abstract class LazyJavaScope(
|
||||
return functionDescriptorImpl
|
||||
}
|
||||
|
||||
protected fun computeMethodReturnType(method: JavaMethod, annotations: Annotations, c: LazyJavaResolverContext): JetType {
|
||||
protected fun computeMethodReturnType(method: JavaMethod, annotations: Annotations, c: LazyJavaResolverContext): KtType {
|
||||
val annotationMethod = method.getContainingClass().isAnnotationType()
|
||||
val returnTypeAttrs = LazyJavaTypeAttributes(
|
||||
TypeUsage.MEMBER_SIGNATURE_COVARIANT, annotations,
|
||||
@@ -255,7 +255,7 @@ public abstract class LazyJavaScope(
|
||||
c.components.externalSignatureResolver.reportSignatureErrors(propertyDescriptor, signatureErrors)
|
||||
}
|
||||
|
||||
propertyDescriptor.setType(effectiveSignature.getReturnType(), listOf(), getDispatchReceiverParameter(), null as JetType?)
|
||||
propertyDescriptor.setType(effectiveSignature.getReturnType(), listOf(), getDispatchReceiverParameter(), null as KtType?)
|
||||
|
||||
if (DescriptorUtils.shouldRecordInitializerForProperty(propertyDescriptor, propertyDescriptor.getType())) {
|
||||
propertyDescriptor.setCompileTimeInitializer(
|
||||
@@ -282,7 +282,7 @@ public abstract class LazyJavaScope(
|
||||
private val JavaField.isFinalStatic: Boolean
|
||||
get() = isFinal && isStatic
|
||||
|
||||
private fun getPropertyType(field: JavaField, annotations: Annotations): JetType {
|
||||
private fun getPropertyType(field: JavaField, annotations: Annotations): KtType {
|
||||
// Fields do not have their own generic parameters
|
||||
val finalStatic = field.isFinalStatic
|
||||
// simple static constants should not have flexible types:
|
||||
|
||||
+2
-2
@@ -33,7 +33,7 @@ import org.jetbrains.kotlin.resolve.DescriptorFactory.createEnumValuesMethod
|
||||
import org.jetbrains.kotlin.resolve.DescriptorFactory.createEnumValuesProperty
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||
import org.jetbrains.kotlin.types.JetType
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
|
||||
public class LazyJavaStaticClassScope(
|
||||
@@ -117,7 +117,7 @@ public class LazyJavaStaticClassScope(
|
||||
|
||||
private fun getStaticPropertiesFromJavaSupertypes(name: Name, descriptor: ClassDescriptor): Set<PropertyDescriptor> {
|
||||
|
||||
fun getStaticProperties(supertype: JetType): Iterable<PropertyDescriptor> {
|
||||
fun getStaticProperties(supertype: KtType): Iterable<PropertyDescriptor> {
|
||||
val superTypeDescriptor = supertype.constructor.declarationDescriptor as? ClassDescriptor ?: return emptyList()
|
||||
|
||||
val staticScope = superTypeDescriptor.staticScope
|
||||
|
||||
+2
-2
@@ -24,7 +24,7 @@ import org.jetbrains.kotlin.load.java.lazy.LazyJavaResolverContext
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaMethod
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.types.JetType
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
|
||||
public abstract class LazyJavaStaticScope(
|
||||
c: LazyJavaResolverContext,
|
||||
@@ -40,7 +40,7 @@ public abstract class LazyJavaStaticScope(
|
||||
override fun getImplicitReceiversHierarchy(): List<ReceiverParameterDescriptor> = listOf()
|
||||
|
||||
override fun resolveMethodSignature(
|
||||
method: JavaMethod, methodTypeParameters: List<TypeParameterDescriptor>, returnType: JetType,
|
||||
method: JavaMethod, methodTypeParameters: List<TypeParameterDescriptor>, returnType: KtType,
|
||||
valueParameters: LazyJavaScope.ResolvedValueParameters
|
||||
): LazyJavaScope.MethodSignatureData {
|
||||
val effectiveSignature = c.components.externalSignatureResolver.resolveAlternativeMethodSignature(
|
||||
|
||||
+2
-2
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.load.java.lazy.descriptors
|
||||
import org.jetbrains.kotlin.descriptors.impl.AbstractLazyTypeParameterDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
import org.jetbrains.kotlin.types.JetType
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaTypeParameter
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
|
||||
@@ -45,7 +45,7 @@ class LazyJavaTypeParameterDescriptor(
|
||||
SourceElement.NO_SOURCE
|
||||
) {
|
||||
|
||||
override fun resolveUpperBounds(): Set<JetType> {
|
||||
override fun resolveUpperBounds(): Set<KtType> {
|
||||
val bounds = javaTypeParameter.getUpperBounds()
|
||||
if (bounds.isEmpty()) {
|
||||
return setOf(LazyJavaTypeResolver.FlexibleJavaClassifierTypeCapabilities.create(
|
||||
|
||||
+16
-16
@@ -39,7 +39,7 @@ import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.Variance.INVARIANT
|
||||
import org.jetbrains.kotlin.types.Variance.IN_VARIANCE
|
||||
import org.jetbrains.kotlin.types.Variance.OUT_VARIANCE
|
||||
import org.jetbrains.kotlin.types.checker.JetTypeChecker
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
|
||||
import org.jetbrains.kotlin.types.typeUtil.createProjection
|
||||
import org.jetbrains.kotlin.types.typeUtil.replaceAnnotations
|
||||
import org.jetbrains.kotlin.utils.sure
|
||||
@@ -52,7 +52,7 @@ class LazyJavaTypeResolver(
|
||||
private val typeParameterResolver: TypeParameterResolver
|
||||
) {
|
||||
|
||||
public fun transformJavaType(javaType: JavaType, attr: JavaTypeAttributes): JetType {
|
||||
public fun transformJavaType(javaType: JavaType, attr: JavaTypeAttributes): KtType {
|
||||
return when (javaType) {
|
||||
is JavaPrimitiveType -> {
|
||||
val primitiveType = javaType.getType()
|
||||
@@ -71,7 +71,7 @@ class LazyJavaTypeResolver(
|
||||
}
|
||||
}
|
||||
|
||||
public fun transformArrayType(arrayType: JavaArrayType, attr: JavaTypeAttributes, isVararg: Boolean = false): JetType {
|
||||
public fun transformArrayType(arrayType: JavaArrayType, attr: JavaTypeAttributes, isVararg: Boolean = false): KtType {
|
||||
return run {
|
||||
val javaComponentType = arrayType.getComponentType()
|
||||
val primitiveType = (javaComponentType as? JavaPrimitiveType)?.getType()
|
||||
@@ -169,17 +169,17 @@ class LazyJavaTypeResolver(
|
||||
|
||||
// We do not memoize the results of this method, because it would consume much memory, and the real gain is little:
|
||||
// the case this method accounts for is very rare, not point in optimizing it
|
||||
private fun getConstructorTypeParameterSubstitute(): JetType {
|
||||
private fun getConstructorTypeParameterSubstitute(): KtType {
|
||||
// If a Java-constructor declares its own type parameters, we have no way of directly expressing them in Kotlin,
|
||||
// so we replace them by intersections of their upper bounds
|
||||
val supertypesJet = HashSet<JetType>()
|
||||
val supertypesJet = HashSet<KtType>()
|
||||
for (supertype in (classifier() as JavaTypeParameter).getUpperBounds()) {
|
||||
supertypesJet.add(transformJavaType(supertype, UPPER_BOUND.toAttributes()))
|
||||
}
|
||||
if (supertypesJet.isEmpty()) {
|
||||
return c.module.builtIns.nullableAnyType
|
||||
}
|
||||
return TypeIntersector.intersectTypes(JetTypeChecker.DEFAULT, supertypesJet)
|
||||
return TypeIntersector.intersectTypes(KotlinTypeChecker.DEFAULT, supertypesJet)
|
||||
?: ErrorUtils.createErrorType("Can't intersect upper bounds of " + javaType.getPresentableText())
|
||||
}
|
||||
|
||||
@@ -290,11 +290,11 @@ class LazyJavaTypeResolver(
|
||||
|
||||
public object FlexibleJavaClassifierTypeCapabilities : FlexibleTypeCapabilities {
|
||||
@JvmStatic
|
||||
fun create(lowerBound: JetType, upperBound: JetType) = DelegatingFlexibleType.create(lowerBound, upperBound, this)
|
||||
fun create(lowerBound: KtType, upperBound: KtType) = DelegatingFlexibleType.create(lowerBound, upperBound, this)
|
||||
|
||||
override val id: String get() = "kotlin.jvm.PlatformType"
|
||||
|
||||
override fun <T : TypeCapability> getCapability(capabilityClass: Class<T>, jetType: JetType, flexibility: Flexibility): T? {
|
||||
override fun <T : TypeCapability> getCapability(capabilityClass: Class<T>, jetType: KtType, flexibility: Flexibility): T? {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return when (capabilityClass) {
|
||||
javaClass<CustomTypeVariable>(), javaClass<Specificity>() -> Impl(flexibility) as T
|
||||
@@ -305,8 +305,8 @@ class LazyJavaTypeResolver(
|
||||
|
||||
private class Impl(val flexibility: Flexibility) : CustomTypeVariable, Specificity {
|
||||
|
||||
private val lowerBound: JetType get() = flexibility.lowerBound
|
||||
private val upperBound: JetType get() = flexibility.upperBound
|
||||
private val lowerBound: KtType get() = flexibility.lowerBound
|
||||
private val upperBound: KtType get() = flexibility.upperBound
|
||||
|
||||
override val isTypeVariable: Boolean = lowerBound.getConstructor() == upperBound.getConstructor()
|
||||
&& lowerBound.getConstructor().getDeclarationDescriptor() is TypeParameterDescriptor
|
||||
@@ -314,12 +314,12 @@ class LazyJavaTypeResolver(
|
||||
override val typeParameterDescriptor: TypeParameterDescriptor? =
|
||||
if (isTypeVariable) lowerBound.getConstructor().getDeclarationDescriptor() as TypeParameterDescriptor else null
|
||||
|
||||
override fun substitutionResult(replacement: JetType): JetType {
|
||||
override fun substitutionResult(replacement: KtType): KtType {
|
||||
return if (replacement.isFlexible()) replacement
|
||||
else create(replacement, TypeUtils.makeNullable(replacement))
|
||||
}
|
||||
|
||||
override fun getSpecificityRelationTo(otherType: JetType): Specificity.Relation {
|
||||
override fun getSpecificityRelationTo(otherType: KtType): Specificity.Relation {
|
||||
// For primitive types we have to take care of the case when there are two overloaded methods like
|
||||
// foo(int) and foo(Integer)
|
||||
// if we do not discriminate one of them, any call to foo(kotlin.Int) will result in overload resolution ambiguity
|
||||
@@ -425,8 +425,8 @@ internal fun TypeParameterDescriptor.getErasedUpperBound(
|
||||
// E.g. `class A<T extends A, F extends A>`
|
||||
// To prevent recursive calls return defaultValue() instead
|
||||
potentiallyRecursiveTypeParameter: TypeParameterDescriptor? = null,
|
||||
defaultValue: (() -> JetType) = { ErrorUtils.createErrorType("Can't compute erased upper bound of type parameter `$this`") }
|
||||
): JetType {
|
||||
defaultValue: (() -> KtType) = { ErrorUtils.createErrorType("Can't compute erased upper bound of type parameter `$this`") }
|
||||
): KtType {
|
||||
if (this === potentiallyRecursiveTypeParameter) return defaultValue()
|
||||
|
||||
val firstUpperBound = upperBounds.first()
|
||||
@@ -450,7 +450,7 @@ internal fun TypeParameterDescriptor.getErasedUpperBound(
|
||||
return defaultValue()
|
||||
}
|
||||
|
||||
private fun JetType.replaceArgumentsWithStarProjections(): JetType {
|
||||
private fun KtType.replaceArgumentsWithStarProjections(): KtType {
|
||||
if (constructor.parameters.isEmpty() || constructor.declarationDescriptor == null) return this
|
||||
|
||||
// We could just create JetTypeImpl with current type constructor and star projections,
|
||||
@@ -459,7 +459,7 @@ private fun JetType.replaceArgumentsWithStarProjections(): JetType {
|
||||
}
|
||||
|
||||
private object ConstantStarSubstitution : TypeSubstitution() {
|
||||
override fun get(key: JetType): TypeProjection? {
|
||||
override fun get(key: KtType): TypeProjection? {
|
||||
// Let substitutor deal with flexibility
|
||||
if (key.isFlexible()) return null
|
||||
|
||||
|
||||
+8
-8
@@ -32,14 +32,14 @@ public object RawTypeCapabilities : TypeCapabilities {
|
||||
}
|
||||
|
||||
private object RawFlexibleRendering : CustomFlexibleRendering {
|
||||
private fun DescriptorRenderer.renderArguments(jetType: JetType) = jetType.arguments.map { renderTypeProjection(it) }
|
||||
private fun DescriptorRenderer.renderArguments(jetType: KtType) = jetType.arguments.map { renderTypeProjection(it) }
|
||||
|
||||
private fun String.replaceArgs(newArgs: String): String {
|
||||
if (!contains('<')) return this
|
||||
return "${substringBefore('<')}<$newArgs>${substringAfterLast('>')}"
|
||||
}
|
||||
|
||||
override fun renderInflexible(type: JetType, renderer: DescriptorRenderer): String? {
|
||||
override fun renderInflexible(type: KtType, renderer: DescriptorRenderer): String? {
|
||||
if (type.arguments.isNotEmpty()) return null
|
||||
|
||||
return StringBuilder {
|
||||
@@ -81,12 +81,12 @@ public object RawTypeCapabilities : TypeCapabilities {
|
||||
}
|
||||
|
||||
internal object RawSubstitution : TypeSubstitution() {
|
||||
override fun get(key: JetType) = TypeProjectionImpl(eraseType(key))
|
||||
override fun get(key: KtType) = TypeProjectionImpl(eraseType(key))
|
||||
|
||||
private val lowerTypeAttr = TypeUsage.MEMBER_SIGNATURE_INVARIANT.toAttributes().toFlexible(JavaTypeFlexibility.FLEXIBLE_LOWER_BOUND)
|
||||
private val upperTypeAttr = TypeUsage.MEMBER_SIGNATURE_INVARIANT.toAttributes().toFlexible(JavaTypeFlexibility.FLEXIBLE_UPPER_BOUND)
|
||||
|
||||
public fun eraseType(type: JetType): JetType {
|
||||
public fun eraseType(type: KtType): KtType {
|
||||
val declaration = type.constructor.declarationDescriptor
|
||||
return when (declaration) {
|
||||
is TypeParameterDescriptor -> eraseType(declaration.getErasedUpperBound())
|
||||
@@ -102,20 +102,20 @@ internal object RawSubstitution : TypeSubstitution() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun eraseInflexibleBasedOnClassDescriptor(type: JetType, declaration: ClassDescriptor, attr: JavaTypeAttributes): JetType {
|
||||
private fun eraseInflexibleBasedOnClassDescriptor(type: KtType, declaration: ClassDescriptor, attr: JavaTypeAttributes): KtType {
|
||||
if (KotlinBuiltIns.isArray(type)) {
|
||||
val componentTypeProjection = type.arguments[0]
|
||||
val arguments = listOf(
|
||||
TypeProjectionImpl(componentTypeProjection.projectionKind, eraseType(componentTypeProjection.type))
|
||||
)
|
||||
return JetTypeImpl.create(
|
||||
return KtTypeImpl.create(
|
||||
type.annotations, type.constructor, type.isMarkedNullable, arguments,
|
||||
(type.constructor.declarationDescriptor as ClassDescriptor).getMemberScope(arguments)
|
||||
)
|
||||
}
|
||||
|
||||
val constructor = type.constructor
|
||||
return JetTypeImpl.create(
|
||||
return KtTypeImpl.create(
|
||||
type.annotations, constructor, type.isMarkedNullable,
|
||||
type.constructor.parameters.map {
|
||||
parameter ->
|
||||
@@ -130,7 +130,7 @@ internal object RawSubstitution : TypeSubstitution() {
|
||||
fun computeProjection(
|
||||
parameter: TypeParameterDescriptor,
|
||||
attr: JavaTypeAttributes,
|
||||
erasedUpperBound: JetType = parameter.getErasedUpperBound()
|
||||
erasedUpperBound: KtType = parameter.getErasedUpperBound()
|
||||
) = when (attr.flexibility) {
|
||||
// Raw(List<T>) => (List<Any?>..List<*>)
|
||||
// Raw(Enum<T>) => (Enum<Enum<*>>..Enum<out Enum<*>>)
|
||||
|
||||
+6
-6
@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.load.java.typeEnhacement
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
|
||||
import org.jetbrains.kotlin.load.java.descriptors.JavaCallableMemberDescriptor
|
||||
import org.jetbrains.kotlin.types.JetType
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
|
||||
public fun <D : CallableMemberDescriptor> enhanceSignatures(platformSignatures: Collection<D>): Collection<D> {
|
||||
return platformSignatures.map {
|
||||
@@ -51,17 +51,17 @@ public fun <D : CallableMemberDescriptor> D.enhanceSignature(): D {
|
||||
}
|
||||
|
||||
private class SignatureParts(
|
||||
val fromOverride: JetType,
|
||||
val fromOverridden: Collection<JetType>,
|
||||
val isCovariant: Boolean
|
||||
val fromOverride: KtType,
|
||||
val fromOverridden: Collection<KtType>,
|
||||
val isCovariant: Boolean
|
||||
) {
|
||||
fun enhance(): JetType {
|
||||
fun enhance(): KtType {
|
||||
val qualifiers = fromOverride.computeIndexedQualifiersForOverride(this.fromOverridden, isCovariant)
|
||||
return fromOverride.enhance(qualifiers)
|
||||
}
|
||||
}
|
||||
|
||||
private fun <D : CallableMemberDescriptor> D.parts(isCovariant: Boolean, collector: (D) -> JetType): SignatureParts {
|
||||
private fun <D : CallableMemberDescriptor> D.parts(isCovariant: Boolean, collector: (D) -> KtType): SignatureParts {
|
||||
return SignatureParts(
|
||||
collector(this),
|
||||
this.getOverriddenDescriptors().map {
|
||||
|
||||
+6
-6
@@ -37,7 +37,7 @@ import org.jetbrains.kotlin.utils.toReadOnlyList
|
||||
// Example: for `A<B, C<D, E>>`, indices go as follows: `0 - A<...>, 1 - B, 2 - C<D, E>, 3 - D, 4 - E`,
|
||||
// which corresponds to the left-to-right breadth-first walk of the tree representation of the type.
|
||||
// For flexible types, both bounds are indexed in the same way: `(A<B>..C<D>)` gives `0 - (A<B>..C<D>), 1 - B and D`.
|
||||
fun JetType.enhance(qualifiers: (Int) -> JavaTypeQualifiers) = this.enhancePossiblyFlexible(qualifiers, 0).type
|
||||
fun KtType.enhance(qualifiers: (Int) -> JavaTypeQualifiers) = this.enhancePossiblyFlexible(qualifiers, 0).type
|
||||
|
||||
|
||||
private enum class TypeComponentPosition {
|
||||
@@ -46,9 +46,9 @@ private enum class TypeComponentPosition {
|
||||
INFLEXIBLE
|
||||
}
|
||||
|
||||
private data class Result(val type: JetType, val subtreeSize: Int)
|
||||
private data class Result(val type: KtType, val subtreeSize: Int)
|
||||
|
||||
private fun JetType.enhancePossiblyFlexible(qualifiers: (Int) -> JavaTypeQualifiers, index: Int): Result {
|
||||
private fun KtType.enhancePossiblyFlexible(qualifiers: (Int) -> JavaTypeQualifiers, index: Int): Result {
|
||||
if (this.isError()) return Result(this, 1)
|
||||
return if (this.isFlexible()) {
|
||||
with(this.flexibility()) {
|
||||
@@ -67,7 +67,7 @@ private fun JetType.enhancePossiblyFlexible(qualifiers: (Int) -> JavaTypeQualifi
|
||||
else this.enhanceInflexible(qualifiers, index, TypeComponentPosition.INFLEXIBLE)
|
||||
}
|
||||
|
||||
private fun JetType.enhanceInflexible(qualifiers: (Int) -> JavaTypeQualifiers, index: Int, position: TypeComponentPosition): Result {
|
||||
private fun KtType.enhanceInflexible(qualifiers: (Int) -> JavaTypeQualifiers, index: Int, position: TypeComponentPosition): Result {
|
||||
val shouldEnhance = position.shouldEnhance()
|
||||
if (!shouldEnhance && getArguments().isEmpty()) return Result(this, 1)
|
||||
|
||||
@@ -104,7 +104,7 @@ private fun JetType.enhanceInflexible(qualifiers: (Int) -> JavaTypeQualifiers, i
|
||||
typeConstructor.parameters, enhancedArguments
|
||||
)
|
||||
|
||||
val enhancedType = JetTypeImpl.create(
|
||||
val enhancedType = KtTypeImpl.create(
|
||||
newAnnotations,
|
||||
typeConstructor,
|
||||
enhancedNullability,
|
||||
@@ -153,7 +153,7 @@ private fun ClassifierDescriptor.enhanceMutability(qualifiers: JavaTypeQualifier
|
||||
return this.noChange()
|
||||
}
|
||||
|
||||
private fun JetType.getEnhancedNullability(qualifiers: JavaTypeQualifiers, position: TypeComponentPosition): EnhancementResult<Boolean> {
|
||||
private fun KtType.getEnhancedNullability(qualifiers: JavaTypeQualifiers, position: TypeComponentPosition): EnhancementResult<Boolean> {
|
||||
if (!position.shouldEnhance()) return this.isMarkedNullable().noChange()
|
||||
|
||||
return when (qualifiers.nullability) {
|
||||
|
||||
+9
-9
@@ -24,8 +24,8 @@ import org.jetbrains.kotlin.load.java.typeEnhacement.NullabilityQualifier.NOT_NU
|
||||
import org.jetbrains.kotlin.load.java.typeEnhacement.NullabilityQualifier.NULLABLE
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.platform.JavaToKotlinClassMap
|
||||
import org.jetbrains.kotlin.types.JetType
|
||||
import org.jetbrains.kotlin.types.checker.JetTypeChecker
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
|
||||
import org.jetbrains.kotlin.types.flexibility
|
||||
import org.jetbrains.kotlin.types.isFlexible
|
||||
import java.util.ArrayList
|
||||
@@ -65,7 +65,7 @@ class JavaTypeQualifiers(
|
||||
}
|
||||
}
|
||||
|
||||
private fun JetType.extractQualifiers(): JavaTypeQualifiers {
|
||||
private fun KtType.extractQualifiers(): JavaTypeQualifiers {
|
||||
val (lower, upper) =
|
||||
if (this.isFlexible())
|
||||
flexibility().let { Pair(it.lowerBound, it.upperBound) }
|
||||
@@ -88,11 +88,11 @@ private fun Annotations.extractQualifiers(): JavaTypeQualifiers {
|
||||
)
|
||||
}
|
||||
|
||||
fun JetType.computeIndexedQualifiersForOverride(fromSupertypes: Collection<JetType>, isCovariant: Boolean): (Int) -> JavaTypeQualifiers {
|
||||
fun JetType.toIndexed(): List<JetType> {
|
||||
val list = ArrayList<JetType>(1)
|
||||
fun KtType.computeIndexedQualifiersForOverride(fromSupertypes: Collection<KtType>, isCovariant: Boolean): (Int) -> JavaTypeQualifiers {
|
||||
fun KtType.toIndexed(): List<KtType> {
|
||||
val list = ArrayList<KtType>(1)
|
||||
|
||||
fun add(type: JetType) {
|
||||
fun add(type: KtType) {
|
||||
list.add(type)
|
||||
for (arg in type.getArguments()) {
|
||||
if (arg.isStarProjection()) {
|
||||
@@ -116,7 +116,7 @@ fun JetType.computeIndexedQualifiersForOverride(fromSupertypes: Collection<JetTy
|
||||
// (outermost type), unless the type in the subclass is interchangeable with the all the types in superclasses:
|
||||
// e.g. we have (Mutable)List<String!>! in the subclass and { List<String!>, (Mutable)List<String>! } from superclasses
|
||||
// Note that `this` is flexible here, so it's equal to it's bounds
|
||||
val onlyHeadTypeConstructor = isCovariant && fromSupertypes.any { !JetTypeChecker.DEFAULT.equalTypes(it, this) }
|
||||
val onlyHeadTypeConstructor = isCovariant && fromSupertypes.any { !KotlinTypeChecker.DEFAULT.equalTypes(it, this) }
|
||||
|
||||
val treeSize = if (onlyHeadTypeConstructor) 1 else indexedThisType.size()
|
||||
val computedResult = Array(treeSize) {
|
||||
@@ -134,7 +134,7 @@ fun JetType.computeIndexedQualifiersForOverride(fromSupertypes: Collection<JetTy
|
||||
return { index -> computedResult.getOrElse(index) { JavaTypeQualifiers.NONE } }
|
||||
}
|
||||
|
||||
private fun JetType.computeQualifiersForOverride(fromSupertypes: Collection<JetType>, isCovariant: Boolean): JavaTypeQualifiers {
|
||||
private fun KtType.computeQualifiersForOverride(fromSupertypes: Collection<KtType>, isCovariant: Boolean): JavaTypeQualifiers {
|
||||
val nullabilityFromSupertypes = fromSupertypes.map { it.extractQualifiers().nullability }.filterNotNull().toSet()
|
||||
val mutabilityFromSupertypes = fromSupertypes.map { it.extractQualifiers().mutability }.filterNotNull().toSet()
|
||||
val own = getAnnotations().extractQualifiers()
|
||||
|
||||
+2
-2
@@ -30,7 +30,7 @@ import org.jetbrains.kotlin.serialization.jvm.JvmProtoBuf.propertyImplClassName
|
||||
import org.jetbrains.kotlin.serialization.jvm.JvmProtoBuf.propertySignature
|
||||
import org.jetbrains.kotlin.serialization.jvm.JvmProtoBufUtil
|
||||
import org.jetbrains.kotlin.storage.StorageManager
|
||||
import org.jetbrains.kotlin.types.JetType
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import java.util.*
|
||||
|
||||
public abstract class AbstractBinaryClassAnnotationAndConstantLoader<A : Any, C : Any, T : Any>(
|
||||
@@ -170,7 +170,7 @@ public abstract class AbstractBinaryClassAnnotationAndConstantLoader<A : Any, C
|
||||
return typeParameter.getExtension(JvmProtoBuf.typeParameterAnnotation).map { loadTypeAnnotation(it, nameResolver) }
|
||||
}
|
||||
|
||||
override fun loadPropertyConstant(container: ProtoContainer, proto: ProtoBuf.Property, expectedType: JetType): C? {
|
||||
override fun loadPropertyConstant(container: ProtoContainer, proto: ProtoBuf.Property, expectedType: KtType): C? {
|
||||
val nameResolver = container.nameResolver
|
||||
val signature = getCallableSignature(proto, nameResolver, container.typeTable, AnnotatedCallableKind.PROPERTY) ?: return null
|
||||
|
||||
|
||||
+7
-7
@@ -27,11 +27,11 @@ import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.platform.JavaToKotlinClassMap
|
||||
import org.jetbrains.kotlin.platform.JvmBuiltIns
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.KtScope
|
||||
import org.jetbrains.kotlin.serialization.deserialization.AdditionalSupertypes
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedClassDescriptor
|
||||
import org.jetbrains.kotlin.types.DelegatingType
|
||||
import org.jetbrains.kotlin.types.JetType
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import java.io.Serializable
|
||||
|
||||
class BuiltInClassesAreSerializableOnJvm(
|
||||
@@ -40,14 +40,14 @@ class BuiltInClassesAreSerializableOnJvm(
|
||||
|
||||
private val mockSerializableType = createMockJavaIoSerializableType()
|
||||
|
||||
private fun createMockJavaIoSerializableType(): JetType {
|
||||
private fun createMockJavaIoSerializableType(): KtType {
|
||||
val mockJavaIoPackageFragment = object : PackageFragmentDescriptorImpl(moduleDescriptor, FqName("java.io")) {
|
||||
override fun getMemberScope() = JetScope.Empty
|
||||
override fun getMemberScope() = KtScope.Empty
|
||||
}
|
||||
|
||||
//NOTE: can't reference anyType right away, because this is sometimes called when JvmBuiltIns are initializing
|
||||
val superTypes = listOf(object : DelegatingType() {
|
||||
override fun getDelegate(): JetType {
|
||||
override fun getDelegate(): KtType {
|
||||
return JvmBuiltIns.Instance.anyType
|
||||
}
|
||||
})
|
||||
@@ -56,11 +56,11 @@ class BuiltInClassesAreSerializableOnJvm(
|
||||
mockJavaIoPackageFragment, Name.identifier("Serializable"), Modality.ABSTRACT, superTypes, SourceElement.NO_SOURCE
|
||||
)
|
||||
|
||||
mockSerializableClass.initialize(JetScope.Empty, emptySet(), null)
|
||||
mockSerializableClass.initialize(KtScope.Empty, emptySet(), null)
|
||||
return mockSerializableClass.defaultType
|
||||
}
|
||||
|
||||
override fun forClass(classDescriptor: DeserializedClassDescriptor): Collection<JetType> {
|
||||
override fun forClass(classDescriptor: DeserializedClassDescriptor): Collection<KtType> {
|
||||
if (isSerializableInJava(classDescriptor.fqNameSafe)) {
|
||||
return listOf(mockSerializableType)
|
||||
}
|
||||
|
||||
+7
-7
@@ -24,7 +24,7 @@ import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor;
|
||||
import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.resolve.scopes.ChainedScope;
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope;
|
||||
import org.jetbrains.kotlin.resolve.scopes.KtScope;
|
||||
import org.jetbrains.kotlin.serialization.ClassData;
|
||||
import org.jetbrains.kotlin.serialization.ClassDataWithSource;
|
||||
import org.jetbrains.kotlin.serialization.PackageData;
|
||||
@@ -74,7 +74,7 @@ public final class DeserializedDescriptorResolver {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public JetScope createKotlinPackagePartScope(@NotNull PackageFragmentDescriptor descriptor, @NotNull KotlinJvmBinaryClass kotlinClass) {
|
||||
public KtScope createKotlinPackagePartScope(@NotNull PackageFragmentDescriptor descriptor, @NotNull KotlinJvmBinaryClass kotlinClass) {
|
||||
String[] data = readData(kotlinClass, KOTLIN_FILE_FACADE_OR_MULTIFILE_CLASS_PART);
|
||||
if (data != null) {
|
||||
String[] strings = kotlinClass.getClassHeader().getStrings();
|
||||
@@ -95,18 +95,18 @@ public final class DeserializedDescriptorResolver {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JetScope createKotlinPackageScope(@NotNull PackageFragmentDescriptor descriptor, @NotNull List<KotlinJvmBinaryClass> packageParts) {
|
||||
List<JetScope> list = new ArrayList<JetScope>();
|
||||
public KtScope createKotlinPackageScope(@NotNull PackageFragmentDescriptor descriptor, @NotNull List<KotlinJvmBinaryClass> packageParts) {
|
||||
List<KtScope> list = new ArrayList<KtScope>();
|
||||
for (KotlinJvmBinaryClass callable : packageParts) {
|
||||
JetScope scope = createKotlinPackagePartScope(descriptor, callable);
|
||||
KtScope scope = createKotlinPackagePartScope(descriptor, callable);
|
||||
if (scope != null) {
|
||||
list.add(scope);
|
||||
}
|
||||
}
|
||||
if (list.isEmpty()) {
|
||||
return JetScope.Empty.INSTANCE$;
|
||||
return KtScope.Empty.INSTANCE$;
|
||||
}
|
||||
return new ChainedScope(descriptor, "Member scope for union of package parts data", list.toArray(new JetScope[list.size()]));
|
||||
return new ChainedScope(descriptor, "Member scope for union of package parts data", list.toArray(new KtScope[list.size()]));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
+3
-3
@@ -28,7 +28,7 @@ import org.jetbrains.kotlin.name.FqNameUnsafe;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
||||
import org.jetbrains.kotlin.resolve.jvm.JvmPrimitiveType;
|
||||
import org.jetbrains.kotlin.types.JetType;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.TypeUtils;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
@@ -184,7 +184,7 @@ public class JavaToKotlinClassMap implements PlatformToKotlinClassMap {
|
||||
return mutableToReadOnly.containsKey(mutable);
|
||||
}
|
||||
|
||||
public boolean isMutable(@NotNull JetType type) {
|
||||
public boolean isMutable(@NotNull KtType type) {
|
||||
ClassDescriptor classDescriptor = TypeUtils.getClassDescriptor(type);
|
||||
return classDescriptor != null && isMutable(classDescriptor);
|
||||
}
|
||||
@@ -193,7 +193,7 @@ public class JavaToKotlinClassMap implements PlatformToKotlinClassMap {
|
||||
return readOnlyToMutable.containsKey(readOnly);
|
||||
}
|
||||
|
||||
public boolean isReadOnly(@NotNull JetType type) {
|
||||
public boolean isReadOnly(@NotNull KtType type) {
|
||||
ClassDescriptor classDescriptor = TypeUtils.getClassDescriptor(type);
|
||||
return classDescriptor != null && isReadOnly(classDescriptor);
|
||||
}
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.resolve.jvm
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.load.java.structure.*
|
||||
import org.jetbrains.kotlin.load.java.lazy.LazyJavaPackageFragmentProvider
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.KtScope
|
||||
import org.jetbrains.kotlin.load.java.sources.JavaSourceElement
|
||||
|
||||
public var PLATFORM_TYPES: Boolean = true
|
||||
|
||||
+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.JetType
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
|
||||
class BuiltInsAnnotationAndConstantLoader(
|
||||
module: ModuleDescriptor
|
||||
@@ -81,7 +81,7 @@ class BuiltInsAnnotationAndConstantLoader(
|
||||
override fun loadPropertyConstant(
|
||||
container: ProtoContainer,
|
||||
proto: ProtoBuf.Property,
|
||||
expectedType: JetType
|
||||
expectedType: KtType
|
||||
): ConstantValue<*>? {
|
||||
if (!proto.hasExtension(BuiltInsProtoBuf.compileTimeValue)) return null
|
||||
val value = proto.getExtension(BuiltInsProtoBuf.compileTimeValue)
|
||||
|
||||
@@ -32,11 +32,11 @@ import org.jetbrains.kotlin.name.FqNameUnsafe;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
||||
import org.jetbrains.kotlin.resolve.constants.ConstantValue;
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope;
|
||||
import org.jetbrains.kotlin.resolve.scopes.KtScope;
|
||||
import org.jetbrains.kotlin.serialization.deserialization.AdditionalSupertypes;
|
||||
import org.jetbrains.kotlin.storage.LockBasedStorageManager;
|
||||
import org.jetbrains.kotlin.types.*;
|
||||
import org.jetbrains.kotlin.types.checker.JetTypeChecker;
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.*;
|
||||
@@ -61,9 +61,9 @@ public abstract class KotlinBuiltIns {
|
||||
private final BuiltinsPackageFragment builtinsPackageFragment;
|
||||
private final BuiltinsPackageFragment annotationPackageFragment;
|
||||
|
||||
private final Map<PrimitiveType, JetType> primitiveTypeToArrayJetType;
|
||||
private final Map<JetType, JetType> primitiveJetTypeToJetArrayType;
|
||||
private final Map<JetType, JetType> jetArrayTypeToPrimitiveJetType;
|
||||
private final Map<PrimitiveType, KtType> primitiveTypeToArrayJetType;
|
||||
private final Map<KtType, KtType> primitiveJetTypeToJetArrayType;
|
||||
private final Map<KtType, KtType> 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, JetType>(PrimitiveType.class);
|
||||
primitiveJetTypeToJetArrayType = new HashMap<JetType, JetType>();
|
||||
jetArrayTypeToPrimitiveJetType = new HashMap<JetType, JetType>();
|
||||
primitiveTypeToArrayJetType = new EnumMap<PrimitiveType, KtType>(PrimitiveType.class);
|
||||
primitiveJetTypeToJetArrayType = new HashMap<KtType, KtType>();
|
||||
jetArrayTypeToPrimitiveJetType = new HashMap<KtType, KtType>();
|
||||
for (PrimitiveType primitive : PrimitiveType.values()) {
|
||||
makePrimitive(primitive);
|
||||
}
|
||||
@@ -105,8 +105,8 @@ public abstract class KotlinBuiltIns {
|
||||
}
|
||||
|
||||
private void makePrimitive(@NotNull PrimitiveType primitiveType) {
|
||||
JetType type = getBuiltInTypeByClassName(primitiveType.getTypeName().asString());
|
||||
JetType arrayType = getBuiltInTypeByClassName(primitiveType.getArrayTypeName().asString());
|
||||
KtType type = getBuiltInTypeByClassName(primitiveType.getTypeName().asString());
|
||||
KtType arrayType = getBuiltInTypeByClassName(primitiveType.getArrayTypeName().asString());
|
||||
|
||||
primitiveTypeToArrayJetType.put(primitiveType, arrayType);
|
||||
primitiveJetTypeToJetArrayType.put(type, arrayType);
|
||||
@@ -202,12 +202,12 @@ public abstract class KotlinBuiltIns {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JetScope getBuiltInsPackageScope() {
|
||||
public KtScope getBuiltInsPackageScope() {
|
||||
return builtinsPackageFragment.getMemberScope();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JetScope getAnnotationPackageScope() {
|
||||
public KtScope getAnnotationPackageScope() {
|
||||
return annotationPackageFragment.getMemberScope();
|
||||
}
|
||||
|
||||
@@ -540,100 +540,100 @@ public abstract class KotlinBuiltIns {
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@NotNull
|
||||
private JetType getBuiltInTypeByClassName(@NotNull String classSimpleName) {
|
||||
private KtType getBuiltInTypeByClassName(@NotNull String classSimpleName) {
|
||||
return getBuiltInClassByName(classSimpleName).getDefaultType();
|
||||
}
|
||||
|
||||
// Special
|
||||
|
||||
@NotNull
|
||||
public JetType getNothingType() {
|
||||
public KtType getNothingType() {
|
||||
return getNothing().getDefaultType();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JetType getNullableNothingType() {
|
||||
public KtType getNullableNothingType() {
|
||||
return TypeUtils.makeNullable(getNothingType());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JetType getAnyType() {
|
||||
public KtType getAnyType() {
|
||||
return getAny().getDefaultType();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JetType getNullableAnyType() {
|
||||
public KtType getNullableAnyType() {
|
||||
return TypeUtils.makeNullable(getAnyType());
|
||||
}
|
||||
|
||||
// Primitive
|
||||
|
||||
@NotNull
|
||||
public JetType getPrimitiveJetType(@NotNull PrimitiveType type) {
|
||||
public KtType getPrimitiveJetType(@NotNull PrimitiveType type) {
|
||||
return getPrimitiveClassDescriptor(type).getDefaultType();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JetType getByteType() {
|
||||
public KtType getByteType() {
|
||||
return getPrimitiveJetType(BYTE);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JetType getShortType() {
|
||||
public KtType getShortType() {
|
||||
return getPrimitiveJetType(SHORT);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JetType getIntType() {
|
||||
public KtType getIntType() {
|
||||
return getPrimitiveJetType(INT);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JetType getLongType() {
|
||||
public KtType getLongType() {
|
||||
return getPrimitiveJetType(LONG);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JetType getFloatType() {
|
||||
public KtType getFloatType() {
|
||||
return getPrimitiveJetType(FLOAT);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JetType getDoubleType() {
|
||||
public KtType getDoubleType() {
|
||||
return getPrimitiveJetType(DOUBLE);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JetType getCharType() {
|
||||
public KtType getCharType() {
|
||||
return getPrimitiveJetType(CHAR);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JetType getBooleanType() {
|
||||
public KtType getBooleanType() {
|
||||
return getPrimitiveJetType(BOOLEAN);
|
||||
}
|
||||
|
||||
// Recognized
|
||||
|
||||
@NotNull
|
||||
public JetType getUnitType() {
|
||||
public KtType getUnitType() {
|
||||
return getUnit().getDefaultType();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JetType getStringType() {
|
||||
public KtType getStringType() {
|
||||
return getString().getDefaultType();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JetType getArrayElementType(@NotNull JetType arrayType) {
|
||||
public KtType getArrayElementType(@NotNull KtType arrayType) {
|
||||
if (isArray(arrayType)) {
|
||||
if (arrayType.getArguments().size() != 1) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
return arrayType.getArguments().get(0).getType();
|
||||
}
|
||||
JetType primitiveType = jetArrayTypeToPrimitiveJetType.get(TypeUtils.makeNotNullable(arrayType));
|
||||
KtType 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 JetType getPrimitiveArrayJetType(@NotNull PrimitiveType primitiveType) {
|
||||
public KtType getPrimitiveArrayJetType(@NotNull PrimitiveType primitiveType) {
|
||||
return primitiveTypeToArrayJetType.get(primitiveType);
|
||||
}
|
||||
|
||||
@@ -649,7 +649,7 @@ public abstract class KotlinBuiltIns {
|
||||
* @return {@code null} if not primitive
|
||||
*/
|
||||
@Nullable
|
||||
public JetType getPrimitiveArrayJetTypeByPrimitiveJetType(@NotNull JetType jetType) {
|
||||
public KtType getPrimitiveArrayJetTypeByPrimitiveJetType(@NotNull KtType jetType) {
|
||||
return primitiveJetTypeToJetArrayType.get(jetType);
|
||||
}
|
||||
|
||||
@@ -668,9 +668,9 @@ public abstract class KotlinBuiltIns {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JetType getArrayType(@NotNull Variance projectionType, @NotNull JetType argument) {
|
||||
public KtType getArrayType(@NotNull Variance projectionType, @NotNull KtType argument) {
|
||||
List<TypeProjectionImpl> types = Collections.singletonList(new TypeProjectionImpl(projectionType, argument));
|
||||
return JetTypeImpl.create(
|
||||
return KtTypeImpl.create(
|
||||
Annotations.Companion.getEMPTY(),
|
||||
getArray(),
|
||||
false,
|
||||
@@ -679,10 +679,10 @@ public abstract class KotlinBuiltIns {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JetType getEnumType(@NotNull JetType argument) {
|
||||
public KtType getEnumType(@NotNull KtType argument) {
|
||||
Variance projectionType = Variance.INVARIANT;
|
||||
List<TypeProjectionImpl> types = Collections.singletonList(new TypeProjectionImpl(projectionType, argument));
|
||||
return JetTypeImpl.create(
|
||||
return KtTypeImpl.create(
|
||||
Annotations.Companion.getEMPTY(),
|
||||
getEnum(),
|
||||
false,
|
||||
@@ -691,7 +691,7 @@ public abstract class KotlinBuiltIns {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JetType getAnnotationType() {
|
||||
public KtType getAnnotationType() {
|
||||
return getAnnotation().getDefaultType();
|
||||
}
|
||||
|
||||
@@ -701,16 +701,16 @@ public abstract class KotlinBuiltIns {
|
||||
Collections.<ValueParameterDescriptor, ConstantValue<?>>emptyMap(), SourceElement.NO_SOURCE);
|
||||
}
|
||||
|
||||
private static boolean isTypeAnnotatedWithExtension(@NotNull JetType type) {
|
||||
private static boolean isTypeAnnotatedWithExtension(@NotNull KtType type) {
|
||||
return type.getAnnotations().findAnnotation(FQ_NAMES.extension) != null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JetType getFunctionType(
|
||||
public KtType getFunctionType(
|
||||
@NotNull Annotations annotations,
|
||||
@Nullable JetType receiverType,
|
||||
@NotNull List<JetType> parameterTypes,
|
||||
@NotNull JetType returnType
|
||||
@Nullable KtType receiverType,
|
||||
@NotNull List<KtType> parameterTypes,
|
||||
@NotNull KtType 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 JetTypeImpl.create(typeAnnotations, classDescriptor, false, arguments);
|
||||
return KtTypeImpl.create(typeAnnotations, classDescriptor, false, arguments);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -731,22 +731,22 @@ public abstract class KotlinBuiltIns {
|
||||
|
||||
@NotNull
|
||||
public static List<TypeProjection> getFunctionTypeArgumentProjections(
|
||||
@Nullable JetType receiverType,
|
||||
@NotNull List<JetType> parameterTypes,
|
||||
@NotNull JetType returnType
|
||||
@Nullable KtType receiverType,
|
||||
@NotNull List<KtType> parameterTypes,
|
||||
@NotNull KtType returnType
|
||||
) {
|
||||
List<TypeProjection> arguments = new ArrayList<TypeProjection>(parameterTypes.size() + (receiverType != null ? 1 : 0) + 1);
|
||||
if (receiverType != null) {
|
||||
arguments.add(defaultProjection(receiverType));
|
||||
}
|
||||
for (JetType parameterType : parameterTypes) {
|
||||
for (KtType parameterType : parameterTypes) {
|
||||
arguments.add(defaultProjection(parameterType));
|
||||
}
|
||||
arguments.add(defaultProjection(returnType));
|
||||
return arguments;
|
||||
}
|
||||
|
||||
private static TypeProjection defaultProjection(JetType returnType) {
|
||||
private static TypeProjection defaultProjection(KtType returnType) {
|
||||
return new TypeProjectionImpl(Variance.INVARIANT, returnType);
|
||||
}
|
||||
|
||||
@@ -756,16 +756,16 @@ public abstract class KotlinBuiltIns {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public static boolean isArray(@NotNull JetType type) {
|
||||
public static boolean isArray(@NotNull KtType type) {
|
||||
return isConstructedFromGivenClass(type, FQ_NAMES.array);
|
||||
}
|
||||
|
||||
public static boolean isPrimitiveArray(@NotNull JetType type) {
|
||||
public static boolean isPrimitiveArray(@NotNull KtType type) {
|
||||
ClassifierDescriptor descriptor = type.getConstructor().getDeclarationDescriptor();
|
||||
return descriptor != null && getPrimitiveTypeByArrayClassFqName(getFqName(descriptor)) != null;
|
||||
}
|
||||
|
||||
public static boolean isPrimitiveType(@NotNull JetType type) {
|
||||
public static boolean isPrimitiveType(@NotNull KtType 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 JetType type) {
|
||||
public static boolean isFunctionOrExtensionFunctionType(@NotNull KtType type) {
|
||||
return isFunctionType(type) || isExtensionFunctionType(type);
|
||||
}
|
||||
|
||||
public static boolean isFunctionType(@NotNull JetType type) {
|
||||
public static boolean isFunctionType(@NotNull KtType type) {
|
||||
if (isExactFunctionType(type)) return true;
|
||||
|
||||
for (JetType superType : type.getConstructor().getSupertypes()) {
|
||||
for (KtType superType : type.getConstructor().getSupertypes()) {
|
||||
if (isFunctionType(superType)) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isExtensionFunctionType(@NotNull JetType type) {
|
||||
public static boolean isExtensionFunctionType(@NotNull KtType type) {
|
||||
if (isExactExtensionFunctionType(type)) return true;
|
||||
|
||||
for (JetType superType : type.getConstructor().getSupertypes()) {
|
||||
for (KtType superType : type.getConstructor().getSupertypes()) {
|
||||
if (isExtensionFunctionType(superType)) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isExactFunctionOrExtensionFunctionType(@NotNull JetType type) {
|
||||
public static boolean isExactFunctionOrExtensionFunctionType(@NotNull KtType type) {
|
||||
ClassifierDescriptor descriptor = type.getConstructor().getDeclarationDescriptor();
|
||||
return descriptor != null && isNumberedFunctionClassFqName(getFqName(descriptor));
|
||||
}
|
||||
|
||||
public static boolean isExactFunctionType(@NotNull JetType type) {
|
||||
public static boolean isExactFunctionType(@NotNull KtType type) {
|
||||
return isExactFunctionOrExtensionFunctionType(type) && !isTypeAnnotatedWithExtension(type);
|
||||
}
|
||||
|
||||
public static boolean isExactExtensionFunctionType(@NotNull JetType type) {
|
||||
public static boolean isExactExtensionFunctionType(@NotNull KtType type) {
|
||||
return isExactFunctionOrExtensionFunctionType(type) && isTypeAnnotatedWithExtension(type);
|
||||
}
|
||||
|
||||
@@ -828,7 +828,7 @@ public abstract class KotlinBuiltIns {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static JetType getReceiverType(@NotNull JetType type) {
|
||||
public static KtType getReceiverType(@NotNull KtType 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 JetType type) {
|
||||
public static List<ValueParameterDescriptor> getValueParameters(@NotNull FunctionDescriptor functionDescriptor, @NotNull KtType 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 JetType getReturnTypeFromFunctionType(@NotNull JetType type) {
|
||||
public static KtType getReturnTypeFromFunctionType(@NotNull KtType type) {
|
||||
assert isFunctionOrExtensionFunctionType(type);
|
||||
List<TypeProjection> arguments = type.getArguments();
|
||||
return arguments.get(arguments.size() - 1).getType();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static List<TypeProjection> getParameterTypeProjectionsFromFunctionType(@NotNull JetType type) {
|
||||
public static List<TypeProjection> getParameterTypeProjectionsFromFunctionType(@NotNull KtType 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 JetType type, @NotNull FqNameUnsafe fqName) {
|
||||
private static boolean isConstructedFromGivenClass(@NotNull KtType 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 JetType type, @NotNull FqNameUnsafe fqName) {
|
||||
private static boolean isNotNullConstructedFromGivenClass(@NotNull KtType 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 JetType type) {
|
||||
public static boolean isAny(@NotNull KtType type) {
|
||||
return isConstructedFromGivenClassAndNotNullable(type, FQ_NAMES.any);
|
||||
}
|
||||
|
||||
public static boolean isBoolean(@NotNull JetType type) {
|
||||
public static boolean isBoolean(@NotNull KtType type) {
|
||||
|
||||
return isConstructedFromGivenClassAndNotNullable(type, FQ_NAMES._boolean);
|
||||
}
|
||||
|
||||
public static boolean isBooleanOrNullableBoolean(@NotNull JetType type) {
|
||||
public static boolean isBooleanOrNullableBoolean(@NotNull KtType 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 JetType type) {
|
||||
public static boolean isChar(@NotNull KtType type) {
|
||||
return isConstructedFromGivenClassAndNotNullable(type, FQ_NAMES._char);
|
||||
}
|
||||
|
||||
public static boolean isInt(@NotNull JetType type) {
|
||||
public static boolean isInt(@NotNull KtType type) {
|
||||
return isConstructedFromGivenClassAndNotNullable(type, FQ_NAMES._int);
|
||||
}
|
||||
|
||||
public static boolean isByte(@NotNull JetType type) {
|
||||
public static boolean isByte(@NotNull KtType type) {
|
||||
return isConstructedFromGivenClassAndNotNullable(type, FQ_NAMES._byte);
|
||||
}
|
||||
|
||||
public static boolean isLong(@NotNull JetType type) {
|
||||
public static boolean isLong(@NotNull KtType type) {
|
||||
return isConstructedFromGivenClassAndNotNullable(type, FQ_NAMES._long);
|
||||
}
|
||||
|
||||
public static boolean isShort(@NotNull JetType type) {
|
||||
public static boolean isShort(@NotNull KtType type) {
|
||||
return isConstructedFromGivenClassAndNotNullable(type, FQ_NAMES._short);
|
||||
}
|
||||
|
||||
public static boolean isFloat(@NotNull JetType type) {
|
||||
public static boolean isFloat(@NotNull KtType type) {
|
||||
return isConstructedFromGivenClassAndNotNullable(type, FQ_NAMES._float);
|
||||
}
|
||||
|
||||
public static boolean isDouble(@NotNull JetType type) {
|
||||
public static boolean isDouble(@NotNull KtType type) {
|
||||
return isConstructedFromGivenClassAndNotNullable(type, FQ_NAMES._double);
|
||||
}
|
||||
|
||||
private static boolean isConstructedFromGivenClassAndNotNullable(@NotNull JetType type, @NotNull FqNameUnsafe fqName) {
|
||||
private static boolean isConstructedFromGivenClassAndNotNullable(@NotNull KtType 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 JetType type) {
|
||||
public static boolean isNothing(@NotNull KtType type) {
|
||||
return isNothingOrNullableNothing(type)
|
||||
&& !type.isMarkedNullable();
|
||||
}
|
||||
|
||||
public static boolean isNullableNothing(@NotNull JetType type) {
|
||||
public static boolean isNullableNothing(@NotNull KtType type) {
|
||||
return isNothingOrNullableNothing(type)
|
||||
&& type.isMarkedNullable();
|
||||
}
|
||||
|
||||
public static boolean isNothingOrNullableNothing(@NotNull JetType type) {
|
||||
public static boolean isNothingOrNullableNothing(@NotNull KtType type) {
|
||||
return isConstructedFromGivenClass(type, FQ_NAMES.nothing);
|
||||
}
|
||||
|
||||
public static boolean isAnyOrNullableAny(@NotNull JetType type) {
|
||||
public static boolean isAnyOrNullableAny(@NotNull KtType type) {
|
||||
return isConstructedFromGivenClass(type, FQ_NAMES.any);
|
||||
}
|
||||
|
||||
public static boolean isNullableAny(@NotNull JetType type) {
|
||||
public static boolean isNullableAny(@NotNull KtType type) {
|
||||
return isAnyOrNullableAny(type) && type.isMarkedNullable();
|
||||
}
|
||||
|
||||
public static boolean isDefaultBound(@NotNull JetType type) {
|
||||
public static boolean isDefaultBound(@NotNull KtType type) {
|
||||
return isNullableAny(type);
|
||||
}
|
||||
|
||||
public static boolean isUnit(@NotNull JetType type) {
|
||||
public static boolean isUnit(@NotNull KtType type) {
|
||||
return isNotNullConstructedFromGivenClass(type, FQ_NAMES.unit);
|
||||
}
|
||||
|
||||
public boolean isBooleanOrSubtype(@NotNull JetType type) {
|
||||
return JetTypeChecker.DEFAULT.isSubtypeOf(type, getBooleanType());
|
||||
public boolean isBooleanOrSubtype(@NotNull KtType type) {
|
||||
return KotlinTypeChecker.DEFAULT.isSubtypeOf(type, getBooleanType());
|
||||
}
|
||||
|
||||
public static boolean isString(@Nullable JetType type) {
|
||||
public static boolean isString(@Nullable KtType type) {
|
||||
return type != null && isNotNullConstructedFromGivenClass(type, FQ_NAMES.string);
|
||||
}
|
||||
|
||||
public static boolean isCollectionOrNullableCollection(@NotNull JetType type) {
|
||||
public static boolean isCollectionOrNullableCollection(@NotNull KtType type) {
|
||||
return isConstructedFromGivenClass(type, FQ_NAMES._collection);
|
||||
}
|
||||
|
||||
public static boolean isListOrNullableList(@NotNull JetType type) {
|
||||
public static boolean isListOrNullableList(@NotNull KtType type) {
|
||||
return isConstructedFromGivenClass(type, FQ_NAMES._list);
|
||||
}
|
||||
|
||||
public static boolean isSetOrNullableSet(@NotNull JetType type) {
|
||||
public static boolean isSetOrNullableSet(@NotNull KtType type) {
|
||||
return isConstructedFromGivenClass(type, FQ_NAMES._set);
|
||||
}
|
||||
|
||||
public static boolean isIterableOrNullableIterable(@NotNull JetType type) {
|
||||
public static boolean isIterableOrNullableIterable(@NotNull KtType type) {
|
||||
return isConstructedFromGivenClass(type, FQ_NAMES._iterable);
|
||||
}
|
||||
|
||||
@@ -1045,7 +1045,7 @@ public abstract class KotlinBuiltIns {
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@NotNull
|
||||
public JetType getDefaultBound() {
|
||||
public KtType getDefaultBound() {
|
||||
return getNullableAnyType();
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.KtScope
|
||||
import org.jetbrains.kotlin.serialization.deserialization.findClassAcrossModuleDependencies
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import java.util.*
|
||||
@@ -32,7 +32,7 @@ import java.util.*
|
||||
val KOTLIN_REFLECT_FQ_NAME = FqName("kotlin.reflect")
|
||||
|
||||
public class ReflectionTypes(private val module: ModuleDescriptor) {
|
||||
private val kotlinReflectScope: JetScope by lazy {
|
||||
private val kotlinReflectScope: KtScope by lazy {
|
||||
module.getPackage(KOTLIN_REFLECT_FQ_NAME).memberScope
|
||||
}
|
||||
|
||||
@@ -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: JetType): JetType {
|
||||
public fun getKClassType(annotations: Annotations, type: KtType): KtType {
|
||||
val descriptor = kClass
|
||||
if (ErrorUtils.isError(descriptor)) {
|
||||
return descriptor.defaultType
|
||||
}
|
||||
|
||||
val arguments = listOf(TypeProjectionImpl(Variance.INVARIANT, type))
|
||||
return JetTypeImpl.create(annotations, descriptor, false, arguments)
|
||||
return KtTypeImpl.create(annotations, descriptor, false, arguments)
|
||||
}
|
||||
|
||||
public fun getKFunctionType(
|
||||
annotations: Annotations,
|
||||
receiverType: JetType?,
|
||||
parameterTypes: List<JetType>,
|
||||
returnType: JetType
|
||||
): JetType {
|
||||
receiverType: KtType?,
|
||||
parameterTypes: List<KtType>,
|
||||
returnType: KtType
|
||||
): KtType {
|
||||
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 JetTypeImpl.create(annotations, classDescriptor, false, arguments)
|
||||
return KtTypeImpl.create(annotations, classDescriptor, false, arguments)
|
||||
}
|
||||
|
||||
public fun getKPropertyType(annotations: Annotations, receiverType: JetType?, returnType: JetType, mutable: Boolean): JetType {
|
||||
public fun getKPropertyType(annotations: Annotations, receiverType: KtType?, returnType: KtType, mutable: Boolean): KtType {
|
||||
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 JetTypeImpl.create(annotations, classDescriptor, false, arguments)
|
||||
return KtTypeImpl.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: JetType): Boolean =
|
||||
public fun isCallableType(type: KtType): Boolean =
|
||||
KotlinBuiltIns.isFunctionOrExtensionFunctionType(type) || isKCallableType(type)
|
||||
|
||||
private fun isKCallableType(type: JetType): Boolean =
|
||||
private fun isKCallableType(type: KtType): Boolean =
|
||||
isExactKCallableType(type) ||
|
||||
type.constructor.supertypes.any { isKCallableType(it) }
|
||||
|
||||
private fun isExactKCallableType(type: JetType): Boolean {
|
||||
private fun isExactKCallableType(type: KtType): Boolean {
|
||||
val descriptor = type.constructor.declarationDescriptor
|
||||
return descriptor is ClassDescriptor && DescriptorUtils.getFqName(descriptor) == KotlinBuiltIns.FQ_NAMES.kCallable
|
||||
}
|
||||
|
||||
public fun createKPropertyStarType(module: ModuleDescriptor): JetType? {
|
||||
public fun createKPropertyStarType(module: ModuleDescriptor): KtType? {
|
||||
val kPropertyClass = module.findClassAcrossModuleDependencies(KotlinBuiltIns.FQ_NAMES.kProperty) ?: return null
|
||||
return JetTypeImpl.create(
|
||||
return KtTypeImpl.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<JetType>(2)
|
||||
val result = ArrayList<KtType>(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(JetTypeImpl.create(Annotations.EMPTY, descriptor, false, arguments))
|
||||
result.add(KtTypeImpl.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<JetType> = supertypes()
|
||||
override fun getSupertypes(): Collection<KtType> = supertypes()
|
||||
|
||||
override fun getDeclarationDescriptor() = this@FunctionClassDescriptor
|
||||
override fun isDenotable() = true
|
||||
|
||||
@@ -20,7 +20,7 @@ import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.OverridingUtil
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScopeImpl
|
||||
import org.jetbrains.kotlin.resolve.scopes.KtScopeImpl
|
||||
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
||||
import org.jetbrains.kotlin.storage.StorageManager
|
||||
import org.jetbrains.kotlin.utils.Printer
|
||||
@@ -30,7 +30,7 @@ import java.util.ArrayList
|
||||
class FunctionClassScope(
|
||||
private val storageManager: StorageManager,
|
||||
private val functionClass: FunctionClassDescriptor
|
||||
) : JetScopeImpl() {
|
||||
) : KtScopeImpl() {
|
||||
private val allDescriptors = storageManager.createLazyValue {
|
||||
if (functionClass.functionKind == FunctionClassDescriptor.Kind.Function) {
|
||||
val invoke = FunctionInvokeDescriptor.create(functionClass)
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.descriptors;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.types.JetType;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
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
|
||||
JetType getReturnType();
|
||||
KtType getReturnType();
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
|
||||
@@ -19,8 +19,8 @@ package org.jetbrains.kotlin.descriptors;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.ReadOnly;
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope;
|
||||
import org.jetbrains.kotlin.types.JetType;
|
||||
import org.jetbrains.kotlin.resolve.scopes.KtScope;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.TypeProjection;
|
||||
import org.jetbrains.kotlin.types.TypeSubstitution;
|
||||
import org.jetbrains.kotlin.types.TypeSubstitutor;
|
||||
@@ -30,19 +30,19 @@ import java.util.List;
|
||||
|
||||
public interface ClassDescriptor extends ClassifierDescriptor, MemberDescriptor, ClassOrPackageFragmentDescriptor {
|
||||
@NotNull
|
||||
JetScope getMemberScope(@NotNull List<? extends TypeProjection> typeArguments);
|
||||
KtScope getMemberScope(@NotNull List<? extends TypeProjection> typeArguments);
|
||||
|
||||
@NotNull
|
||||
JetScope getMemberScope(@NotNull TypeSubstitution typeSubstitution);
|
||||
KtScope getMemberScope(@NotNull TypeSubstitution typeSubstitution);
|
||||
|
||||
@NotNull
|
||||
JetScope getUnsubstitutedMemberScope();
|
||||
KtScope getUnsubstitutedMemberScope();
|
||||
|
||||
@NotNull
|
||||
JetScope getUnsubstitutedInnerClassesScope();
|
||||
KtScope getUnsubstitutedInnerClassesScope();
|
||||
|
||||
@NotNull
|
||||
JetScope getStaticScope();
|
||||
KtScope getStaticScope();
|
||||
|
||||
@NotNull
|
||||
@ReadOnly
|
||||
@@ -57,7 +57,7 @@ public interface ClassDescriptor extends ClassifierDescriptor, MemberDescriptor,
|
||||
*/
|
||||
@NotNull
|
||||
@Override
|
||||
JetType getDefaultType();
|
||||
KtType getDefaultType();
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package org.jetbrains.kotlin.descriptors;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.types.JetType;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.TypeConstructor;
|
||||
|
||||
public interface ClassifierDescriptor extends DeclarationDescriptorNonRoot {
|
||||
@@ -25,5 +25,5 @@ public interface ClassifierDescriptor extends DeclarationDescriptorNonRoot {
|
||||
TypeConstructor getTypeConstructor();
|
||||
|
||||
@NotNull
|
||||
JetType getDefaultType();
|
||||
KtType getDefaultType();
|
||||
}
|
||||
|
||||
@@ -19,11 +19,11 @@
|
||||
package org.jetbrains.kotlin.descriptors
|
||||
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.types.JetType
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
|
||||
object ConstUtil {
|
||||
@JvmStatic
|
||||
public fun canBeUsedForConstVal(type: JetType) = type.canBeUsedForConstVal()
|
||||
public fun canBeUsedForConstVal(type: KtType) = type.canBeUsedForConstVal()
|
||||
}
|
||||
|
||||
public fun JetType.canBeUsedForConstVal() = KotlinBuiltIns.isPrimitiveType(this) || KotlinBuiltIns.isString(this)
|
||||
public fun KtType.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.JetType;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -29,7 +29,7 @@ public interface ConstructorDescriptor extends FunctionDescriptor {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
JetType getReturnType();
|
||||
KtType getReturnType();
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package org.jetbrains.kotlin.descriptors
|
||||
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.types.JetType
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
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 JetType.forType() = forType(emptySet())
|
||||
fun KtType.forType() = forType(emptySet())
|
||||
|
||||
private fun JetType.forType(types: Set<JetType>): EffectiveVisibility =
|
||||
private fun KtType.forType(types: Set<KtType>): EffectiveVisibility =
|
||||
if (this in types) Public
|
||||
else lowerBound(constructor.forTypeConstructor(),
|
||||
arguments.map { it.type.forType(types + this) } )
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package org.jetbrains.kotlin.descriptors
|
||||
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.KtScope
|
||||
|
||||
public interface PackageFragmentDescriptor : ClassOrPackageFragmentDescriptor {
|
||||
|
||||
@@ -25,5 +25,5 @@ public interface PackageFragmentDescriptor : ClassOrPackageFragmentDescriptor {
|
||||
|
||||
public val fqName: FqName
|
||||
|
||||
public fun getMemberScope(): JetScope
|
||||
public fun getMemberScope(): KtScope
|
||||
}
|
||||
|
||||
@@ -17,14 +17,14 @@
|
||||
package org.jetbrains.kotlin.descriptors
|
||||
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.KtScope
|
||||
|
||||
public interface PackageViewDescriptor : DeclarationDescriptor {
|
||||
override fun getContainingDeclaration(): PackageViewDescriptor?
|
||||
|
||||
public val fqName: FqName
|
||||
|
||||
public val memberScope: JetScope
|
||||
public val memberScope: KtScope
|
||||
|
||||
public val module: ModuleDescriptor
|
||||
|
||||
|
||||
@@ -17,11 +17,11 @@
|
||||
package org.jetbrains.kotlin.descriptors;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.types.JetType;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
|
||||
public interface ParameterDescriptor extends CallableDescriptor {
|
||||
@NotNull
|
||||
JetType getType();
|
||||
KtType getType();
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
|
||||
@@ -19,7 +19,6 @@ package org.jetbrains.kotlin.descriptors;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.descriptors.impl.ScriptCodeDescriptor;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope;
|
||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope;
|
||||
|
||||
public interface ScriptDescriptor extends DeclarationDescriptorNonRoot {
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package org.jetbrains.kotlin.descriptors;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.types.JetType;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
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<JetType> getUpperBounds();
|
||||
Set<KtType> getUpperBounds();
|
||||
|
||||
@NotNull
|
||||
JetType getUpperBoundsAsType();
|
||||
KtType getUpperBoundsAsType();
|
||||
|
||||
@NotNull
|
||||
Set<JetType> getLowerBounds();
|
||||
Set<KtType> 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.JetType;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@@ -42,7 +42,7 @@ public interface ValueParameterDescriptor extends VariableDescriptor, ParameterD
|
||||
boolean declaresDefaultValue();
|
||||
|
||||
@Nullable
|
||||
JetType getVarargElementType();
|
||||
KtType 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.JetType;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.TypeSubstitutor;
|
||||
|
||||
public interface VariableDescriptor extends CallableDescriptor {
|
||||
@NotNull
|
||||
JetType getType();
|
||||
KtType 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.JetType;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface AnnotationDescriptor {
|
||||
@NotNull
|
||||
JetType getType();
|
||||
KtType 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.JetType;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
public class AnnotationDescriptorImpl implements AnnotationDescriptor {
|
||||
private final JetType annotationType;
|
||||
private final KtType annotationType;
|
||||
private final Map<ValueParameterDescriptor, ConstantValue<?>> valueArguments;
|
||||
private final SourceElement source;
|
||||
|
||||
public AnnotationDescriptorImpl(
|
||||
@NotNull JetType annotationType,
|
||||
@NotNull KtType annotationType,
|
||||
@NotNull Map<ValueParameterDescriptor, ConstantValue<?>> valueArguments,
|
||||
@NotNull SourceElement source
|
||||
) {
|
||||
@@ -43,7 +43,7 @@ public class AnnotationDescriptorImpl implements AnnotationDescriptor {
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public JetType getType() {
|
||||
public KtType getType() {
|
||||
return annotationType;
|
||||
}
|
||||
|
||||
|
||||
+11
-11
@@ -21,7 +21,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.resolve.scopes.InnerClassesScopeWrapper;
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope;
|
||||
import org.jetbrains.kotlin.resolve.scopes.KtScope;
|
||||
import org.jetbrains.kotlin.resolve.scopes.SubstitutingScope;
|
||||
import org.jetbrains.kotlin.storage.NotNullLazyValue;
|
||||
import org.jetbrains.kotlin.storage.StorageManager;
|
||||
@@ -31,21 +31,21 @@ import java.util.List;
|
||||
|
||||
public abstract class AbstractClassDescriptor implements ClassDescriptor {
|
||||
private final Name name;
|
||||
protected final NotNullLazyValue<JetType> defaultType;
|
||||
private final NotNullLazyValue<JetScope> unsubstitutedInnerClassesScope;
|
||||
protected final NotNullLazyValue<KtType> 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<JetType>() {
|
||||
this.defaultType = storageManager.createLazyValue(new Function0<KtType>() {
|
||||
@Override
|
||||
public JetType invoke() {
|
||||
public KtType invoke() {
|
||||
return TypeUtils.makeUnsubstitutedType(AbstractClassDescriptor.this, getUnsubstitutedMemberScope());
|
||||
}
|
||||
});
|
||||
this.unsubstitutedInnerClassesScope = storageManager.createLazyValue(new Function0<JetScope>() {
|
||||
this.unsubstitutedInnerClassesScope = storageManager.createLazyValue(new Function0<KtScope>() {
|
||||
@Override
|
||||
public JetScope invoke() {
|
||||
public KtScope invoke() {
|
||||
return new InnerClassesScopeWrapper(getUnsubstitutedMemberScope());
|
||||
}
|
||||
});
|
||||
@@ -71,7 +71,7 @@ public abstract class AbstractClassDescriptor implements ClassDescriptor {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JetScope getUnsubstitutedInnerClassesScope() {
|
||||
public KtScope getUnsubstitutedInnerClassesScope() {
|
||||
return unsubstitutedInnerClassesScope.invoke();
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ public abstract class AbstractClassDescriptor implements ClassDescriptor {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JetScope getMemberScope(@NotNull List<? extends TypeProjection> typeArguments) {
|
||||
public KtScope getMemberScope(@NotNull List<? extends TypeProjection> typeArguments) {
|
||||
assert typeArguments.size() == getTypeConstructor().getParameters().size() : "Illegal number of type arguments: expected "
|
||||
+ getTypeConstructor().getParameters().size() + " but was " + typeArguments.size()
|
||||
+ " for " + getTypeConstructor() + " " + getTypeConstructor().getParameters();
|
||||
@@ -95,7 +95,7 @@ public abstract class AbstractClassDescriptor implements ClassDescriptor {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JetScope getMemberScope(@NotNull TypeSubstitution typeSubstitution) {
|
||||
public KtScope getMemberScope(@NotNull TypeSubstitution typeSubstitution) {
|
||||
if (typeSubstitution.isEmpty()) return getUnsubstitutedMemberScope();
|
||||
|
||||
TypeSubstitutor substitutor = TypeSubstitutor.create(typeSubstitution);
|
||||
@@ -113,7 +113,7 @@ public abstract class AbstractClassDescriptor implements ClassDescriptor {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JetType getDefaultType() {
|
||||
public KtType 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.JetType;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
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<JetType> getSupertypes() {
|
||||
public Collection<KtType> 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.JetType;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
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;
|
||||
JetType substitutedType = substitutor.substitute(getType(), Variance.INVARIANT);
|
||||
KtType 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 JetType getReturnType() {
|
||||
public KtType getReturnType() {
|
||||
return getType();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JetType getType() {
|
||||
public KtType getType() {
|
||||
return getValue().getType();
|
||||
}
|
||||
|
||||
|
||||
+23
-24
@@ -19,19 +19,18 @@ package org.jetbrains.kotlin.descriptors.impl;
|
||||
import kotlin.jvm.functions.Function0;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.ReadOnly;
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptorVisitor;
|
||||
import org.jetbrains.kotlin.descriptors.SourceElement;
|
||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope;
|
||||
import org.jetbrains.kotlin.resolve.scopes.KtScope;
|
||||
import org.jetbrains.kotlin.resolve.scopes.LazyScopeAdapter;
|
||||
import org.jetbrains.kotlin.storage.NotNullLazyValue;
|
||||
import org.jetbrains.kotlin.storage.StorageManager;
|
||||
import org.jetbrains.kotlin.types.*;
|
||||
import org.jetbrains.kotlin.types.checker.JetTypeChecker;
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
@@ -44,9 +43,9 @@ public abstract class AbstractTypeParameterDescriptor extends DeclarationDescrip
|
||||
private final int index;
|
||||
|
||||
private final NotNullLazyValue<TypeConstructor> typeConstructor;
|
||||
private final NotNullLazyValue<JetType> defaultType;
|
||||
private final NotNullLazyValue<Set<JetType>> upperBounds;
|
||||
private final NotNullLazyValue<JetType> upperBoundsAsType;
|
||||
private final NotNullLazyValue<KtType> defaultType;
|
||||
private final NotNullLazyValue<Set<KtType>> upperBounds;
|
||||
private final NotNullLazyValue<KtType> upperBoundsAsType;
|
||||
|
||||
protected AbstractTypeParameterDescriptor(
|
||||
@NotNull final StorageManager storageManager,
|
||||
@@ -69,29 +68,29 @@ public abstract class AbstractTypeParameterDescriptor extends DeclarationDescrip
|
||||
return createTypeConstructor();
|
||||
}
|
||||
});
|
||||
this.defaultType = storageManager.createLazyValue(new Function0<JetType>() {
|
||||
this.defaultType = storageManager.createLazyValue(new Function0<KtType>() {
|
||||
@Override
|
||||
public JetType invoke() {
|
||||
return JetTypeImpl.create(Annotations.Companion.getEMPTY(), getTypeConstructor(), false, Collections.<TypeProjection>emptyList(),
|
||||
new LazyScopeAdapter(storageManager.createLazyValue(
|
||||
new Function0<JetScope>() {
|
||||
public KtType invoke() {
|
||||
return KtTypeImpl.create(Annotations.Companion.getEMPTY(), getTypeConstructor(), false, Collections.<TypeProjection>emptyList(),
|
||||
new LazyScopeAdapter(storageManager.createLazyValue(
|
||||
new Function0<KtScope>() {
|
||||
@Override
|
||||
public JetScope invoke() {
|
||||
public KtScope invoke() {
|
||||
return getUpperBoundsAsType().getMemberScope();
|
||||
}
|
||||
}
|
||||
)));
|
||||
}
|
||||
});
|
||||
this.upperBounds = storageManager.createRecursionTolerantLazyValue(new Function0<Set<JetType>>() {
|
||||
this.upperBounds = storageManager.createRecursionTolerantLazyValue(new Function0<Set<KtType>>() {
|
||||
@Override
|
||||
public Set<JetType> invoke() {
|
||||
public Set<KtType> invoke() {
|
||||
return resolveUpperBounds();
|
||||
}
|
||||
}, Collections.singleton(ErrorUtils.createErrorType("Recursion while calculating upper bounds")));
|
||||
this.upperBoundsAsType = storageManager.createLazyValue(new Function0<JetType>() {
|
||||
this.upperBoundsAsType = storageManager.createLazyValue(new Function0<KtType>() {
|
||||
@Override
|
||||
public JetType invoke() {
|
||||
public KtType invoke() {
|
||||
return computeUpperBoundsAsType();
|
||||
}
|
||||
});
|
||||
@@ -99,7 +98,7 @@ public abstract class AbstractTypeParameterDescriptor extends DeclarationDescrip
|
||||
|
||||
@NotNull
|
||||
@ReadOnly
|
||||
protected abstract Set<JetType> resolveUpperBounds();
|
||||
protected abstract Set<KtType> resolveUpperBounds();
|
||||
|
||||
@NotNull
|
||||
protected abstract TypeConstructor createTypeConstructor();
|
||||
@@ -122,21 +121,21 @@ public abstract class AbstractTypeParameterDescriptor extends DeclarationDescrip
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<JetType> getUpperBounds() {
|
||||
public Set<KtType> getUpperBounds() {
|
||||
return upperBounds.invoke();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JetType getUpperBoundsAsType() {
|
||||
public KtType getUpperBoundsAsType() {
|
||||
return upperBoundsAsType.invoke();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private JetType computeUpperBoundsAsType() {
|
||||
Set<JetType> upperBounds = getUpperBounds();
|
||||
private KtType computeUpperBoundsAsType() {
|
||||
Set<KtType> upperBounds = getUpperBounds();
|
||||
assert !upperBounds.isEmpty() : "Upper bound list is empty in " + getName();
|
||||
JetType upperBoundsAsType = TypeIntersector.intersectTypes(JetTypeChecker.DEFAULT, upperBounds);
|
||||
KtType upperBoundsAsType = TypeIntersector.intersectTypes(KotlinTypeChecker.DEFAULT, upperBounds);
|
||||
return upperBoundsAsType != null ? upperBoundsAsType : getBuiltIns(this).getNothingType();
|
||||
}
|
||||
|
||||
@@ -148,13 +147,13 @@ public abstract class AbstractTypeParameterDescriptor extends DeclarationDescrip
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JetType getDefaultType() {
|
||||
public KtType getDefaultType() {
|
||||
return defaultType.invoke();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<JetType> getLowerBounds() {
|
||||
public Set<KtType> getLowerBounds() {
|
||||
return Collections.singleton(getBuiltIns(this).getNothingType());
|
||||
}
|
||||
|
||||
|
||||
@@ -21,10 +21,10 @@ 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.resolve.scopes.JetScope;
|
||||
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.JetType;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.TypeConstructor;
|
||||
import org.jetbrains.kotlin.types.TypeConstructorImpl;
|
||||
|
||||
@@ -35,9 +35,9 @@ import java.util.Set;
|
||||
public class ClassDescriptorImpl extends ClassDescriptorBase {
|
||||
private final Modality modality;
|
||||
private final TypeConstructor typeConstructor;
|
||||
private final JetScope staticScope = new StaticScopeForKotlinClass(this);
|
||||
private final KtScope staticScope = new StaticScopeForKotlinClass(this);
|
||||
|
||||
private JetScope unsubstitutedMemberScope;
|
||||
private KtScope unsubstitutedMemberScope;
|
||||
private Set<ConstructorDescriptor> constructors;
|
||||
private ConstructorDescriptor primaryConstructor;
|
||||
|
||||
@@ -45,7 +45,7 @@ public class ClassDescriptorImpl extends ClassDescriptorBase {
|
||||
@NotNull DeclarationDescriptor containingDeclaration,
|
||||
@NotNull Name name,
|
||||
@NotNull Modality modality,
|
||||
@NotNull Collection<JetType> supertypes,
|
||||
@NotNull Collection<KtType> supertypes,
|
||||
@NotNull SourceElement source
|
||||
) {
|
||||
super(LockBasedStorageManager.NO_LOCKS, containingDeclaration, name, source);
|
||||
@@ -56,7 +56,7 @@ public class ClassDescriptorImpl extends ClassDescriptorBase {
|
||||
}
|
||||
|
||||
public final void initialize(
|
||||
@NotNull JetScope unsubstitutedMemberScope,
|
||||
@NotNull KtScope unsubstitutedMemberScope,
|
||||
@NotNull Set<ConstructorDescriptor> constructors,
|
||||
@Nullable ConstructorDescriptor primaryConstructor
|
||||
) {
|
||||
@@ -89,13 +89,13 @@ public class ClassDescriptorImpl extends ClassDescriptorBase {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JetScope getUnsubstitutedMemberScope() {
|
||||
public KtScope getUnsubstitutedMemberScope() {
|
||||
return unsubstitutedMemberScope;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JetScope getStaticScope() {
|
||||
public KtScope getStaticScope() {
|
||||
return staticScope;
|
||||
}
|
||||
|
||||
|
||||
+12
-12
@@ -28,13 +28,13 @@ import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.resolve.DescriptorFactory;
|
||||
import org.jetbrains.kotlin.resolve.OverridingUtil;
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter;
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope;
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScopeImpl;
|
||||
import org.jetbrains.kotlin.resolve.scopes.KtScope;
|
||||
import org.jetbrains.kotlin.resolve.scopes.KtScopeImpl;
|
||||
import org.jetbrains.kotlin.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.JetType;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.TypeConstructor;
|
||||
import org.jetbrains.kotlin.types.TypeConstructorImpl;
|
||||
import org.jetbrains.kotlin.utils.Printer;
|
||||
@@ -47,8 +47,8 @@ import java.util.Set;
|
||||
public class EnumEntrySyntheticClassDescriptor extends ClassDescriptorBase {
|
||||
private final TypeConstructor typeConstructor;
|
||||
private final ConstructorDescriptor primaryConstructor;
|
||||
private final JetScope scope;
|
||||
private final JetScope staticScope = new StaticScopeForKotlinClass(this);
|
||||
private final KtScope scope;
|
||||
private final KtScope staticScope = new StaticScopeForKotlinClass(this);
|
||||
private final NotNullLazyValue<Collection<Name>> enumMemberNames;
|
||||
|
||||
/**
|
||||
@@ -63,7 +63,7 @@ public class EnumEntrySyntheticClassDescriptor extends ClassDescriptorBase {
|
||||
@NotNull NotNullLazyValue<Collection<Name>> enumMemberNames,
|
||||
@NotNull SourceElement source
|
||||
) {
|
||||
JetType enumType = enumClass.getDefaultType();
|
||||
KtType 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 JetType supertype,
|
||||
@NotNull KtType supertype,
|
||||
@NotNull Name name,
|
||||
@NotNull NotNullLazyValue<Collection<Name>> enumMemberNames,
|
||||
@NotNull SourceElement source
|
||||
@@ -93,13 +93,13 @@ public class EnumEntrySyntheticClassDescriptor extends ClassDescriptorBase {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JetScope getUnsubstitutedMemberScope() {
|
||||
public KtScope getUnsubstitutedMemberScope() {
|
||||
return scope;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JetScope getStaticScope() {
|
||||
public KtScope getStaticScope() {
|
||||
return staticScope;
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ public class EnumEntrySyntheticClassDescriptor extends ClassDescriptorBase {
|
||||
return "enum entry " + getName();
|
||||
}
|
||||
|
||||
private class EnumEntryScope extends JetScopeImpl {
|
||||
private class EnumEntryScope extends KtScopeImpl {
|
||||
private final MemoizedFunctionToNotNull<Name, Collection<FunctionDescriptor>> functions;
|
||||
private final MemoizedFunctionToNotNull<Name, Collection<PropertyDescriptor>> properties;
|
||||
private final NotNullLazyValue<Collection<DeclarationDescriptor>> allDescriptors;
|
||||
@@ -224,8 +224,8 @@ public class EnumEntrySyntheticClassDescriptor extends ClassDescriptorBase {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private JetScope getSupertypeScope() {
|
||||
Collection<JetType> supertype = getTypeConstructor().getSupertypes();
|
||||
private KtScope getSupertypeScope() {
|
||||
Collection<KtType> 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();
|
||||
}
|
||||
|
||||
+15
-14
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.descriptors.impl;
|
||||
|
||||
import kotlin.reflect.jvm.internal.impl.types.JetType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.descriptors.*;
|
||||
@@ -23,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.JetType;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.TypeSubstitutor;
|
||||
import org.jetbrains.kotlin.types.Variance;
|
||||
import org.jetbrains.kotlin.utils.CollectionsKt;
|
||||
@@ -37,7 +38,7 @@ import java.util.Set;
|
||||
public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRootImpl implements FunctionDescriptor {
|
||||
private List<TypeParameterDescriptor> typeParameters;
|
||||
private List<ValueParameterDescriptor> unsubstitutedValueParameters;
|
||||
private JetType unsubstitutedReturnType;
|
||||
private KtType unsubstitutedReturnType;
|
||||
private ReceiverParameterDescriptor extensionReceiverParameter;
|
||||
private ReceiverParameterDescriptor dispatchReceiverParameter;
|
||||
private Modality modality;
|
||||
@@ -66,11 +67,11 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
||||
|
||||
@NotNull
|
||||
public FunctionDescriptorImpl initialize(
|
||||
@Nullable JetType receiverParameterType,
|
||||
@Nullable KtType receiverParameterType,
|
||||
@Nullable ReceiverParameterDescriptor dispatchReceiverParameter,
|
||||
@NotNull List<? extends TypeParameterDescriptor> typeParameters,
|
||||
@NotNull List<ValueParameterDescriptor> unsubstitutedValueParameters,
|
||||
@Nullable JetType unsubstitutedReturnType,
|
||||
@Nullable KtType unsubstitutedReturnType,
|
||||
@Nullable Modality modality,
|
||||
@NotNull Visibility visibility
|
||||
) {
|
||||
@@ -125,7 +126,7 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
||||
this.isTailrec = isTailrec;
|
||||
}
|
||||
|
||||
public void setReturnType(@NotNull JetType unsubstitutedReturnType) {
|
||||
public void setReturnType(@NotNull KtType unsubstitutedReturnType) {
|
||||
if (this.unsubstitutedReturnType != null) {
|
||||
// TODO: uncomment and fix tests
|
||||
//throw new IllegalStateException("returnType already set");
|
||||
@@ -228,7 +229,7 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetType getReturnType() {
|
||||
public KtType getReturnType() {
|
||||
return unsubstitutedReturnType;
|
||||
}
|
||||
|
||||
@@ -275,7 +276,7 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected JetType getExtensionReceiverParameterType() {
|
||||
protected KtType getExtensionReceiverParameterType() {
|
||||
if (extensionReceiverParameter == null) return null;
|
||||
return extensionReceiverParameter.getType();
|
||||
}
|
||||
@@ -295,8 +296,8 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
||||
boolean copyOverrides,
|
||||
@NotNull Kind kind,
|
||||
@NotNull List<ValueParameterDescriptor> newValueParameterDescriptors,
|
||||
@Nullable JetType newExtensionReceiverParameterType,
|
||||
@NotNull JetType newReturnType
|
||||
@Nullable KtType newExtensionReceiverParameterType,
|
||||
@NotNull KtType newReturnType
|
||||
) {
|
||||
FunctionDescriptorImpl substitutedDescriptor = createSubstitutedCopy(newOwner, original, kind);
|
||||
|
||||
@@ -306,7 +307,7 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
||||
originalTypeParameters, originalSubstitutor.getSubstitution(), substitutedDescriptor, substitutedTypeParameters
|
||||
);
|
||||
|
||||
JetType substitutedReceiverParameterType = null;
|
||||
KtType substitutedReceiverParameterType = null;
|
||||
if (newExtensionReceiverParameterType != null) {
|
||||
substitutedReceiverParameterType = substitutor.substitute(newExtensionReceiverParameterType, Variance.IN_VARIANCE);
|
||||
if (substitutedReceiverParameterType == null) {
|
||||
@@ -339,7 +340,7 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
||||
return null;
|
||||
}
|
||||
|
||||
JetType substitutedReturnType = substitutor.substitute(newReturnType, Variance.OUT_VARIANCE);
|
||||
KtType substitutedReturnType = substitutor.substitute(newReturnType, Variance.OUT_VARIANCE);
|
||||
if (substitutedReturnType == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -389,9 +390,9 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
||||
List<ValueParameterDescriptor> result = new ArrayList<ValueParameterDescriptor>(unsubstitutedValueParameters.size());
|
||||
for (ValueParameterDescriptor unsubstitutedValueParameter : unsubstitutedValueParameters) {
|
||||
// TODO : Lazy?
|
||||
JetType substitutedType = substitutor.substitute(unsubstitutedValueParameter.getType(), Variance.IN_VARIANCE);
|
||||
JetType varargElementType = unsubstitutedValueParameter.getVarargElementType();
|
||||
JetType substituteVarargElementType =
|
||||
KtType substitutedType = substitutor.substitute(unsubstitutedValueParameter.getType(), Variance.IN_VARIANCE);
|
||||
KtType varargElementType = unsubstitutedValueParameter.getVarargElementType();
|
||||
KtType substituteVarargElementType =
|
||||
varargElementType == null ? null : substitutor.substitute(varargElementType, Variance.IN_VARIANCE);
|
||||
if (substitutedType == null) return null;
|
||||
result.add(
|
||||
|
||||
+3
-3
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.descriptors.PackageViewDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.resolve.scopes.ChainedScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.KtScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.LazyScopeAdapter
|
||||
import org.jetbrains.kotlin.storage.StorageManager
|
||||
import org.jetbrains.kotlin.storage.getValue
|
||||
@@ -39,9 +39,9 @@ public class LazyPackageViewDescriptorImpl(
|
||||
module.packageFragmentProvider.getPackageFragments(fqName)
|
||||
}
|
||||
|
||||
override val memberScope: JetScope = LazyScopeAdapter(storageManager.createLazyValue {
|
||||
override val memberScope: KtScope = LazyScopeAdapter(storageManager.createLazyValue {
|
||||
if (fragments.isEmpty()) {
|
||||
JetScope.Empty
|
||||
KtScope.Empty
|
||||
}
|
||||
else {
|
||||
val scopes = fragments.map { it.getMemberScope() } + SubpackagesScope(module, fqName)
|
||||
|
||||
+14
-14
@@ -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.resolve.scopes.JetScope;
|
||||
import org.jetbrains.kotlin.resolve.scopes.KtScope;
|
||||
import org.jetbrains.kotlin.resolve.scopes.SubstitutingScope;
|
||||
import org.jetbrains.kotlin.types.*;
|
||||
|
||||
@@ -68,9 +68,9 @@ public class LazySubstitutingClassDescriptor implements ClassDescriptor {
|
||||
if (typeConstructor == null) {
|
||||
TypeSubstitutor substitutor = getSubstitutor();
|
||||
|
||||
Collection<JetType> originalSupertypes = originalTypeConstructor.getSupertypes();
|
||||
Collection<JetType> supertypes = new ArrayList<JetType>(originalSupertypes.size());
|
||||
for (JetType supertype : originalSupertypes) {
|
||||
Collection<KtType> originalSupertypes = originalTypeConstructor.getSupertypes();
|
||||
Collection<KtType> supertypes = new ArrayList<KtType>(originalSupertypes.size());
|
||||
for (KtType supertype : originalSupertypes) {
|
||||
supertypes.add(substitutor.substitute(supertype, Variance.INVARIANT));
|
||||
}
|
||||
|
||||
@@ -89,8 +89,8 @@ public class LazySubstitutingClassDescriptor implements ClassDescriptor {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JetScope getMemberScope(@NotNull List<? extends TypeProjection> typeArguments) {
|
||||
JetScope memberScope = original.getMemberScope(typeArguments);
|
||||
public KtScope getMemberScope(@NotNull List<? extends TypeProjection> typeArguments) {
|
||||
KtScope memberScope = original.getMemberScope(typeArguments);
|
||||
if (originalSubstitutor.isEmpty()) {
|
||||
return memberScope;
|
||||
}
|
||||
@@ -99,8 +99,8 @@ public class LazySubstitutingClassDescriptor implements ClassDescriptor {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JetScope getMemberScope(@NotNull TypeSubstitution typeSubstitution) {
|
||||
JetScope memberScope = original.getMemberScope(typeSubstitution);
|
||||
public KtScope getMemberScope(@NotNull TypeSubstitution typeSubstitution) {
|
||||
KtScope memberScope = original.getMemberScope(typeSubstitution);
|
||||
if (originalSubstitutor.isEmpty()) {
|
||||
return memberScope;
|
||||
}
|
||||
@@ -109,8 +109,8 @@ public class LazySubstitutingClassDescriptor implements ClassDescriptor {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JetScope getUnsubstitutedMemberScope() {
|
||||
JetScope memberScope = original.getUnsubstitutedMemberScope();
|
||||
public KtScope getUnsubstitutedMemberScope() {
|
||||
KtScope memberScope = original.getUnsubstitutedMemberScope();
|
||||
if (originalSubstitutor.isEmpty()) {
|
||||
return memberScope;
|
||||
}
|
||||
@@ -119,15 +119,15 @@ public class LazySubstitutingClassDescriptor implements ClassDescriptor {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JetScope getStaticScope() {
|
||||
public KtScope getStaticScope() {
|
||||
return original.getStaticScope();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JetType getDefaultType() {
|
||||
public KtType getDefaultType() {
|
||||
List<TypeProjection> typeProjections = TypeUtils.getDefaultTypeProjections(getTypeConstructor().getParameters());
|
||||
return JetTypeImpl.create(
|
||||
return KtTypeImpl.create(
|
||||
getAnnotations(),
|
||||
this,
|
||||
false,
|
||||
@@ -233,7 +233,7 @@ public class LazySubstitutingClassDescriptor implements ClassDescriptor {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JetScope getUnsubstitutedInnerClassesScope() {
|
||||
public KtScope getUnsubstitutedInnerClassesScope() {
|
||||
return original.getUnsubstitutedInnerClassesScope();
|
||||
}
|
||||
|
||||
|
||||
+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.JetType;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
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 JetType outType,
|
||||
@NotNull KtType outType,
|
||||
@ReadOnly @NotNull List<? extends TypeParameterDescriptor> typeParameters,
|
||||
@Nullable ReceiverParameterDescriptor dispatchReceiverParameter,
|
||||
@Nullable JetType receiverType
|
||||
@Nullable KtType receiverType
|
||||
) {
|
||||
ReceiverParameterDescriptor extensionReceiverParameter = DescriptorFactory.createExtensionReceiverParameterForCallable(this, receiverType);
|
||||
setType(outType, typeParameters, dispatchReceiverParameter, extensionReceiverParameter);
|
||||
}
|
||||
|
||||
public void setType(
|
||||
@NotNull JetType outType,
|
||||
@NotNull KtType 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 JetType getReturnType() {
|
||||
public KtType getReturnType() {
|
||||
return getType();
|
||||
}
|
||||
|
||||
@@ -227,8 +227,8 @@ public class PropertyDescriptorImpl extends VariableDescriptorWithInitializerImp
|
||||
originalTypeParameters, originalSubstitutor.getSubstitution(), substitutedDescriptor, substitutedTypeParameters
|
||||
);
|
||||
|
||||
JetType originalOutType = getType();
|
||||
JetType outType = substitutor.substitute(originalOutType, Variance.OUT_VARIANCE);
|
||||
KtType originalOutType = getType();
|
||||
KtType 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;
|
||||
}
|
||||
|
||||
JetType substitutedReceiverType;
|
||||
KtType 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) {
|
||||
JetType returnType = getter.getReturnType();
|
||||
KtType 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.JetType;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class PropertyGetterDescriptorImpl extends PropertyAccessorDescriptorImpl implements PropertyGetterDescriptor {
|
||||
private JetType returnType;
|
||||
private KtType returnType;
|
||||
|
||||
@NotNull
|
||||
private final PropertyGetterDescriptor original;
|
||||
@@ -51,7 +51,7 @@ public class PropertyGetterDescriptorImpl extends PropertyAccessorDescriptorImpl
|
||||
this.original = original != null ? original : this;
|
||||
}
|
||||
|
||||
public void initialize(JetType returnType) {
|
||||
public void initialize(KtType returnType) {
|
||||
this.returnType = returnType == null ? getCorrespondingProperty().getType() : returnType;
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ public class PropertyGetterDescriptorImpl extends PropertyAccessorDescriptorImpl
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetType getReturnType() {
|
||||
public KtType 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.JetType;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
|
||||
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 JetType type
|
||||
@NotNull KtType 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 JetType getReturnType() {
|
||||
public KtType 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.JetType;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
|
||||
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 JetType returnType) {
|
||||
@NotNull KtType 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.JetType;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
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 JetType receiverParameterType,
|
||||
@Nullable KtType receiverParameterType,
|
||||
@Nullable ReceiverParameterDescriptor dispatchReceiverParameter,
|
||||
@NotNull List<? extends TypeParameterDescriptor> typeParameters,
|
||||
@NotNull List<ValueParameterDescriptor> unsubstitutedValueParameters,
|
||||
@Nullable JetType unsubstitutedReturnType,
|
||||
@Nullable KtType unsubstitutedReturnType,
|
||||
@Nullable Modality modality,
|
||||
@NotNull Visibility visibility
|
||||
) {
|
||||
|
||||
@@ -23,13 +23,13 @@ import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindExclude
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScopeImpl
|
||||
import org.jetbrains.kotlin.resolve.scopes.KtScopeImpl
|
||||
import org.jetbrains.kotlin.utils.Printer
|
||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
import org.jetbrains.kotlin.utils.sure
|
||||
import java.util.ArrayList
|
||||
|
||||
public class SubpackagesScope(private val moduleDescriptor: ModuleDescriptor, private val fqName: FqName) : JetScopeImpl() {
|
||||
public class SubpackagesScope(private val moduleDescriptor: ModuleDescriptor, private val fqName: FqName) : KtScopeImpl() {
|
||||
override fun getContainingDeclaration(): DeclarationDescriptor {
|
||||
return moduleDescriptor.getPackage(fqName)
|
||||
}
|
||||
|
||||
+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.JetType;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
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<JetType> upperBounds = SmartSet.create();
|
||||
private final Set<KtType> upperBounds = SmartSet.create();
|
||||
private boolean initialized = false;
|
||||
|
||||
private TypeParameterDescriptorImpl(
|
||||
@@ -113,12 +113,12 @@ public class TypeParameterDescriptorImpl extends AbstractTypeParameterDescriptor
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
public void addUpperBound(@NotNull JetType bound) {
|
||||
public void addUpperBound(@NotNull KtType bound) {
|
||||
checkUninitialized();
|
||||
doAddUpperBound(bound);
|
||||
}
|
||||
|
||||
private void doAddUpperBound(JetType bound) {
|
||||
private void doAddUpperBound(KtType bound) {
|
||||
upperBounds.add(bound); // TODO : Duplicates?
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ public class TypeParameterDescriptorImpl extends AbstractTypeParameterDescriptor
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected Set<JetType> resolveUpperBounds() {
|
||||
protected Set<KtType> 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.JetType;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
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 JetType varargElementType;
|
||||
private final KtType 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 JetType outType,
|
||||
@NotNull KtType outType,
|
||||
boolean declaresDefaultValue,
|
||||
boolean isCrossinline,
|
||||
boolean isNoinline,
|
||||
@Nullable JetType varargElementType,
|
||||
@Nullable KtType varargElementType,
|
||||
@NotNull SourceElement source
|
||||
) {
|
||||
super(containingDeclaration, annotations, name, outType, source);
|
||||
@@ -87,7 +87,7 @@ public class ValueParameterDescriptorImpl extends VariableDescriptorImpl impleme
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public JetType getVarargElementType() {
|
||||
public KtType 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.JetType;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class VariableDescriptorImpl extends DeclarationDescriptorNonRootImpl implements VariableDescriptor {
|
||||
protected JetType outType;
|
||||
protected KtType outType;
|
||||
|
||||
public VariableDescriptorImpl(
|
||||
@NotNull DeclarationDescriptor containingDeclaration,
|
||||
@NotNull Annotations annotations,
|
||||
@NotNull Name name,
|
||||
@Nullable JetType outType,
|
||||
@Nullable KtType outType,
|
||||
@NotNull SourceElement source
|
||||
) {
|
||||
super(containingDeclaration, annotations, name, source);
|
||||
@@ -44,11 +44,11 @@ public abstract class VariableDescriptorImpl extends DeclarationDescriptorNonRoo
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JetType getType() {
|
||||
public KtType getType() {
|
||||
return outType;
|
||||
}
|
||||
|
||||
public void setOutType(JetType outType) {
|
||||
public void setOutType(KtType outType) {
|
||||
assert this.outType == null;
|
||||
this.outType = outType;
|
||||
}
|
||||
@@ -99,7 +99,7 @@ public abstract class VariableDescriptorImpl extends DeclarationDescriptorNonRoo
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JetType getReturnType() {
|
||||
public KtType 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.JetType;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
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 JetType outType,
|
||||
@Nullable KtType 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.JetType
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.TypeCapability
|
||||
|
||||
public interface CustomFlexibleRendering : TypeCapability {
|
||||
public fun renderInflexible(type: JetType, renderer: DescriptorRenderer): String?
|
||||
public fun renderInflexible(type: KtType, 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.JetType
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
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: JetType): String
|
||||
public abstract fun renderType(type: KtType): 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: (JetType) -> JetType
|
||||
public var typeNormalizer: (KtType) -> KtType
|
||||
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: JetType): String {
|
||||
override fun renderType(type: KtType): String {
|
||||
return renderNormalizedType(typeNormalizer(type))
|
||||
}
|
||||
|
||||
private fun renderNormalizedType(type: JetType): String {
|
||||
private fun renderNormalizedType(type: KtType): String {
|
||||
if (type is LazyType && debugMode) {
|
||||
return type.toString()
|
||||
}
|
||||
@@ -172,13 +172,13 @@ internal class DescriptorRendererImpl(
|
||||
return renderInflexibleType(type)
|
||||
}
|
||||
|
||||
private fun renderFlexibleTypeWithBothBounds(lower: JetType, upper: JetType): String {
|
||||
private fun renderFlexibleTypeWithBothBounds(lower: KtType, upper: KtType): String {
|
||||
return renderFlexibleTypeWithBothBounds(renderNormalizedType(lower), renderNormalizedType(upper))
|
||||
}
|
||||
|
||||
private fun renderFlexibleTypeWithBothBounds(lower: String, upper: String) = "($lower..$upper)"
|
||||
|
||||
private fun renderInflexibleType(type: JetType): String {
|
||||
private fun renderInflexibleType(type: KtType): 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: JetType): Boolean {
|
||||
private fun shouldRenderAsPrettyFunctionType(type: KtType): Boolean {
|
||||
return prettyFunctionTypes && KotlinBuiltIns.isExactFunctionOrExtensionFunctionType(type)
|
||||
&& type.getArguments().none { it.isStarProjection() }
|
||||
}
|
||||
|
||||
private fun renderFlexibleType(type: JetType): String {
|
||||
private fun renderFlexibleType(type: KtType): String {
|
||||
val lower = type.flexibility().lowerBound
|
||||
val upper = type.flexibility().upperBound
|
||||
|
||||
@@ -246,7 +246,7 @@ internal class DescriptorRendererImpl(
|
||||
}.toString()
|
||||
}
|
||||
|
||||
private fun renderDefaultType(type: JetType): String {
|
||||
private fun renderDefaultType(type: KtType): String {
|
||||
val sb = StringBuilder()
|
||||
|
||||
renderAnnotations(type, sb, /* needBrackets = */ true)
|
||||
@@ -290,7 +290,7 @@ internal class DescriptorRendererImpl(
|
||||
}.joinTo(builder, ", ")
|
||||
}
|
||||
|
||||
private fun renderFunctionType(type: JetType): String {
|
||||
private fun renderFunctionType(type: KtType): 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 JetType) excludedTypeAnnotationClasses else excludedAnnotationClasses
|
||||
val excluded = if (annotated is KtType) 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.JetType
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
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<(JetType) -> JetType>({ it })
|
||||
override var typeNormalizer by property<(KtType) -> KtType>({ 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.JetType;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.Variance;
|
||||
|
||||
import java.util.Collections;
|
||||
@@ -141,13 +141,13 @@ public class DescriptorFactory {
|
||||
/* lateInit = */ false, /* isConst = */ false
|
||||
);
|
||||
|
||||
JetType type = getBuiltIns(enumClass).getArrayType(Variance.INVARIANT, enumClass.getDefaultType());
|
||||
KtType 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, (JetType) null);
|
||||
values.setType(type, Collections.<TypeParameterDescriptor>emptyList(), null, (KtType) null);
|
||||
|
||||
return values;
|
||||
}
|
||||
@@ -173,7 +173,7 @@ public class DescriptorFactory {
|
||||
@Nullable
|
||||
public static ReceiverParameterDescriptor createExtensionReceiverParameterForCallable(
|
||||
@NotNull CallableDescriptor owner,
|
||||
@Nullable JetType receiverParameterType
|
||||
@Nullable KtType receiverParameterType
|
||||
) {
|
||||
return receiverParameterType == null
|
||||
? null
|
||||
|
||||
@@ -36,12 +36,12 @@ import org.jetbrains.kotlin.resolve.constants.ConstantValue;
|
||||
import org.jetbrains.kotlin.resolve.constants.StringValue;
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter;
|
||||
import org.jetbrains.kotlin.resolve.scopes.FilteringScope;
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope;
|
||||
import org.jetbrains.kotlin.resolve.scopes.KtScope;
|
||||
import org.jetbrains.kotlin.types.ErrorUtils;
|
||||
import org.jetbrains.kotlin.types.JetType;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.LazyType;
|
||||
import org.jetbrains.kotlin.types.TypeConstructor;
|
||||
import org.jetbrains.kotlin.types.checker.JetTypeChecker;
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -244,7 +244,7 @@ public class DescriptorUtils {
|
||||
}
|
||||
|
||||
public static boolean isDirectSubclass(@NotNull ClassDescriptor subClass, @NotNull ClassDescriptor superClass) {
|
||||
for (JetType superType : subClass.getTypeConstructor().getSupertypes()) {
|
||||
for (KtType 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 JetType type, @NotNull DeclarationDescriptor other) {
|
||||
private static boolean isSameClass(@NotNull KtType 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 JetType type, @NotNull DeclarationDescriptor superClass) {
|
||||
private static boolean isSubtypeOfClass(@NotNull KtType type, @NotNull DeclarationDescriptor superClass) {
|
||||
if (isSameClass(type, superClass)) return true;
|
||||
for (JetType superType : type.getConstructor().getSupertypes()) {
|
||||
for (KtType 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<JetType> superclassTypes = classDescriptor.getTypeConstructor().getSupertypes();
|
||||
Collection<KtType> superclassTypes = classDescriptor.getTypeConstructor().getSupertypes();
|
||||
List<ClassDescriptor> superClassDescriptors = new ArrayList<ClassDescriptor>();
|
||||
for (JetType type : superclassTypes) {
|
||||
for (KtType type : superclassTypes) {
|
||||
ClassDescriptor result = getClassDescriptorForType(type);
|
||||
if (!isAny(result)) {
|
||||
superClassDescriptors.add(result);
|
||||
@@ -361,9 +361,9 @@ public class DescriptorUtils {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static JetType getSuperClassType(@NotNull ClassDescriptor classDescriptor) {
|
||||
Collection<JetType> superclassTypes = classDescriptor.getTypeConstructor().getSupertypes();
|
||||
for (JetType type : superclassTypes) {
|
||||
public static KtType getSuperClassType(@NotNull ClassDescriptor classDescriptor) {
|
||||
Collection<KtType> superclassTypes = classDescriptor.getTypeConstructor().getSupertypes();
|
||||
for (KtType 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<JetType> superclassTypes = classDescriptor.getTypeConstructor().getSupertypes();
|
||||
for (JetType type : superclassTypes) {
|
||||
Collection<KtType> superclassTypes = classDescriptor.getTypeConstructor().getSupertypes();
|
||||
for (KtType 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 JetType type) {
|
||||
public static ClassDescriptor getClassDescriptorForType(@NotNull KtType type) {
|
||||
return getClassDescriptorForTypeConstructor(type.getConstructor());
|
||||
}
|
||||
|
||||
@@ -422,7 +422,7 @@ public class DescriptorUtils {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static JetType getReceiverParameterType(@Nullable ReceiverParameterDescriptor receiverParameterDescriptor) {
|
||||
public static KtType getReceiverParameterType(@Nullable ReceiverParameterDescriptor receiverParameterDescriptor) {
|
||||
return receiverParameterDescriptor == null ? null : receiverParameterDescriptor.getType();
|
||||
}
|
||||
|
||||
@@ -437,8 +437,8 @@ public class DescriptorUtils {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static JetScope getStaticNestedClassesScope(@NotNull ClassDescriptor descriptor) {
|
||||
JetScope innerClassesScope = descriptor.getUnsubstitutedInnerClassesScope();
|
||||
public static KtScope getStaticNestedClassesScope(@NotNull ClassDescriptor descriptor) {
|
||||
KtScope innerClassesScope = descriptor.getUnsubstitutedInnerClassesScope();
|
||||
return new FilteringScope(innerClassesScope, new Function1<DeclarationDescriptor, Boolean>() {
|
||||
@Override
|
||||
public Boolean invoke(DeclarationDescriptor descriptor) {
|
||||
@@ -474,16 +474,16 @@ public class DescriptorUtils {
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
public static boolean shouldRecordInitializerForProperty(@NotNull VariableDescriptor variable, @NotNull JetType type) {
|
||||
public static boolean shouldRecordInitializerForProperty(@NotNull VariableDescriptor variable, @NotNull KtType type) {
|
||||
if (variable.isVar() || type.isError()) return false;
|
||||
|
||||
if (type instanceof LazyType || type.isMarkedNullable()) return true;
|
||||
|
||||
KotlinBuiltIns builtIns = getBuiltIns(variable);
|
||||
return KotlinBuiltIns.isPrimitiveType(type) ||
|
||||
JetTypeChecker.DEFAULT.equalTypes(builtIns.getStringType(), type) ||
|
||||
JetTypeChecker.DEFAULT.equalTypes(builtIns.getNumber().getDefaultType(), type) ||
|
||||
JetTypeChecker.DEFAULT.equalTypes(builtIns.getAnyType(), type);
|
||||
KotlinTypeChecker.DEFAULT.equalTypes(builtIns.getStringType(), type) ||
|
||||
KotlinTypeChecker.DEFAULT.equalTypes(builtIns.getNumber().getDefaultType(), type) ||
|
||||
KotlinTypeChecker.DEFAULT.equalTypes(builtIns.getAnyType(), type);
|
||||
}
|
||||
|
||||
public static boolean classCanHaveAbstractMembers(@NotNull ClassDescriptor classDescriptor) {
|
||||
@@ -636,7 +636,7 @@ public class DescriptorUtils {
|
||||
result.add(fqName);
|
||||
}
|
||||
|
||||
for (DeclarationDescriptor descriptor : packageView.getMemberScope().getDescriptors(DescriptorKindFilter.PACKAGES, JetScope.Companion.getALL_NAME_FILTER())) {
|
||||
for (DeclarationDescriptor descriptor : packageView.getMemberScope().getDescriptors(DescriptorKindFilter.PACKAGES, KtScope.Companion.getALL_NAME_FILTER())) {
|
||||
if (descriptor instanceof PackageViewDescriptor) {
|
||||
getSubPackagesFqNames((PackageViewDescriptor) descriptor, result);
|
||||
}
|
||||
|
||||
@@ -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.JetType
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
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: JetType?
|
||||
public val ClassDescriptor.classObjectType: KtType?
|
||||
get() {
|
||||
val correspondingDescriptor = when (this.getKind()) {
|
||||
OBJECT -> this
|
||||
|
||||
@@ -27,9 +27,9 @@ 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.JetType;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.TypeConstructor;
|
||||
import org.jetbrains.kotlin.types.checker.JetTypeChecker;
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
|
||||
import org.jetbrains.kotlin.utils.DFS;
|
||||
|
||||
import java.util.*;
|
||||
@@ -44,7 +44,7 @@ public class OverridingUtil {
|
||||
ExternalOverridabilityCondition.class.getClassLoader()
|
||||
));
|
||||
|
||||
public static final OverridingUtil DEFAULT = new OverridingUtil(new JetTypeChecker.TypeConstructorEquality() {
|
||||
public static final OverridingUtil DEFAULT = new OverridingUtil(new KotlinTypeChecker.TypeConstructorEquality() {
|
||||
@Override
|
||||
public boolean equals(@NotNull TypeConstructor a, @NotNull TypeConstructor b) {
|
||||
return a.equals(b);
|
||||
@@ -52,13 +52,13 @@ public class OverridingUtil {
|
||||
});
|
||||
|
||||
@NotNull
|
||||
public static OverridingUtil createWithEqualityAxioms(@NotNull JetTypeChecker.TypeConstructorEquality equalityAxioms) {
|
||||
public static OverridingUtil createWithEqualityAxioms(@NotNull KotlinTypeChecker.TypeConstructorEquality equalityAxioms) {
|
||||
return new OverridingUtil(equalityAxioms);
|
||||
}
|
||||
|
||||
private final JetTypeChecker.TypeConstructorEquality equalityAxioms;
|
||||
private final KotlinTypeChecker.TypeConstructorEquality equalityAxioms;
|
||||
|
||||
private OverridingUtil(JetTypeChecker.TypeConstructorEquality axioms) {
|
||||
private OverridingUtil(KotlinTypeChecker.TypeConstructorEquality axioms) {
|
||||
equalityAxioms = axioms;
|
||||
}
|
||||
|
||||
@@ -98,18 +98,18 @@ public class OverridingUtil {
|
||||
return receiverAndParameterResult;
|
||||
}
|
||||
|
||||
List<JetType> superValueParameters = compiledValueParameters(superDescriptor);
|
||||
List<JetType> subValueParameters = compiledValueParameters(subDescriptor);
|
||||
List<KtType> superValueParameters = compiledValueParameters(superDescriptor);
|
||||
List<KtType> 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) {
|
||||
JetType superValueParameterType = getUpperBound(superValueParameters.get(i));
|
||||
JetType subValueParameterType = getUpperBound(subValueParameters.get(i));
|
||||
KtType superValueParameterType = getUpperBound(superValueParameters.get(i));
|
||||
KtType subValueParameterType = getUpperBound(subValueParameters.get(i));
|
||||
// TODO: compare erasure
|
||||
if (!JetTypeChecker.DEFAULT.equalTypes(superValueParameterType, subValueParameterType)) {
|
||||
if (!KotlinTypeChecker.DEFAULT.equalTypes(superValueParameterType, subValueParameterType)) {
|
||||
return OverrideCompatibilityInfo.typeParameterNumberMismatch();
|
||||
}
|
||||
}
|
||||
@@ -123,7 +123,7 @@ public class OverridingUtil {
|
||||
matchingTypeConstructors.put(superTypeParameter.getTypeConstructor(), subTypeParameter.getTypeConstructor());
|
||||
}
|
||||
|
||||
JetTypeChecker.TypeConstructorEquality localEqualityAxioms = new JetTypeChecker.TypeConstructorEquality() {
|
||||
KotlinTypeChecker.TypeConstructorEquality localEqualityAxioms = new KotlinTypeChecker.TypeConstructorEquality() {
|
||||
@Override
|
||||
public boolean equals(@NotNull TypeConstructor a, @NotNull TypeConstructor b) {
|
||||
if (equalityAxioms.equals(a, b)) return true;
|
||||
@@ -147,8 +147,8 @@ public class OverridingUtil {
|
||||
}
|
||||
|
||||
for (int i = 0, unsubstitutedValueParametersSize = superValueParameters.size(); i < unsubstitutedValueParametersSize; i++) {
|
||||
JetType superValueParameter = superValueParameters.get(i);
|
||||
JetType subValueParameter = subValueParameters.get(i);
|
||||
KtType superValueParameter = superValueParameters.get(i);
|
||||
KtType subValueParameter = subValueParameters.get(i);
|
||||
|
||||
if (!areTypesEquivalent(superValueParameter, subValueParameter, localEqualityAxioms)) {
|
||||
return OverrideCompatibilityInfo.valueParameterTypeMismatch(superValueParameter, subValueParameter, INCOMPATIBLE);
|
||||
@@ -156,12 +156,12 @@ public class OverridingUtil {
|
||||
}
|
||||
|
||||
if (checkReturnType) {
|
||||
JetType superReturnType = superDescriptor.getReturnType();
|
||||
JetType subReturnType = subDescriptor.getReturnType();
|
||||
KtType superReturnType = superDescriptor.getReturnType();
|
||||
KtType subReturnType = subDescriptor.getReturnType();
|
||||
|
||||
if (superReturnType != null && subReturnType != null) {
|
||||
boolean bothErrors = subReturnType.isError() && superReturnType.isError();
|
||||
if (!bothErrors && !JetTypeChecker.withAxioms(localEqualityAxioms).isSubtypeOf(subReturnType, superReturnType)) {
|
||||
if (!bothErrors && !KotlinTypeChecker.withAxioms(localEqualityAxioms).isSubtypeOf(subReturnType, superReturnType)) {
|
||||
return OverrideCompatibilityInfo.returnTypeMismatch(superReturnType, subReturnType);
|
||||
}
|
||||
}
|
||||
@@ -194,20 +194,20 @@ public class OverridingUtil {
|
||||
}
|
||||
|
||||
private static boolean areTypesEquivalent(
|
||||
@NotNull JetType typeInSuper,
|
||||
@NotNull JetType typeInSub,
|
||||
@NotNull JetTypeChecker.TypeConstructorEquality axioms
|
||||
@NotNull KtType typeInSuper,
|
||||
@NotNull KtType typeInSub,
|
||||
@NotNull KotlinTypeChecker.TypeConstructorEquality axioms
|
||||
) {
|
||||
boolean bothErrors = typeInSuper.isError() && typeInSub.isError();
|
||||
if (!bothErrors && !JetTypeChecker.withAxioms(axioms).equalTypes(typeInSuper, typeInSub)) {
|
||||
if (!bothErrors && !KotlinTypeChecker.withAxioms(axioms).equalTypes(typeInSuper, typeInSub)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static List<JetType> compiledValueParameters(CallableDescriptor callableDescriptor) {
|
||||
static List<KtType> compiledValueParameters(CallableDescriptor callableDescriptor) {
|
||||
ReceiverParameterDescriptor receiverParameter = callableDescriptor.getExtensionReceiverParameter();
|
||||
ArrayList<JetType> parameters = new ArrayList<JetType>();
|
||||
ArrayList<KtType> parameters = new ArrayList<KtType>();
|
||||
if (receiverParameter != null) {
|
||||
parameters.add(receiverParameter.getType());
|
||||
}
|
||||
@@ -217,7 +217,7 @@ public class OverridingUtil {
|
||||
return parameters;
|
||||
}
|
||||
|
||||
static JetType getUpperBound(JetType type) {
|
||||
static KtType getUpperBound(KtType type) {
|
||||
if (type.getConstructor().getDeclarationDescriptor() instanceof ClassDescriptor) {
|
||||
return type;
|
||||
}
|
||||
@@ -297,12 +297,12 @@ public class OverridingUtil {
|
||||
if (a instanceof SimpleFunctionDescriptor) {
|
||||
assert b instanceof SimpleFunctionDescriptor : "b is " + b.getClass();
|
||||
|
||||
JetType aReturnType = a.getReturnType();
|
||||
KtType aReturnType = a.getReturnType();
|
||||
assert aReturnType != null;
|
||||
JetType bReturnType = b.getReturnType();
|
||||
KtType bReturnType = b.getReturnType();
|
||||
assert bReturnType != null;
|
||||
|
||||
return JetTypeChecker.DEFAULT.isSubtypeOf(aReturnType, bReturnType);
|
||||
return KotlinTypeChecker.DEFAULT.isSubtypeOf(aReturnType, bReturnType);
|
||||
}
|
||||
if (a instanceof PropertyDescriptor) {
|
||||
assert b instanceof PropertyDescriptor : "b is " + b.getClass();
|
||||
@@ -312,7 +312,7 @@ public class OverridingUtil {
|
||||
}
|
||||
|
||||
// both vals
|
||||
return JetTypeChecker.DEFAULT.isSubtypeOf(((PropertyDescriptor) a).getType(), ((PropertyDescriptor) b).getType());
|
||||
return KotlinTypeChecker.DEFAULT.isSubtypeOf(((PropertyDescriptor) a).getType(), ((PropertyDescriptor) b).getType());
|
||||
}
|
||||
throw new IllegalArgumentException("Unexpected callable: " + a.getClass());
|
||||
}
|
||||
@@ -569,7 +569,7 @@ public class OverridingUtil {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static OverrideCompatibilityInfo valueParameterTypeMismatch(JetType superValueParameter, JetType subValueParameter, Result result) {
|
||||
public static OverrideCompatibilityInfo valueParameterTypeMismatch(KtType superValueParameter, KtType subValueParameter, Result result) {
|
||||
return new OverrideCompatibilityInfo(result, "valueParameterTypeMismatch"); // TODO
|
||||
}
|
||||
|
||||
@@ -579,7 +579,7 @@ public class OverridingUtil {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static OverrideCompatibilityInfo returnTypeMismatch(JetType substitutedSuperReturnType, JetType unsubstitutedSubReturnType) {
|
||||
public static OverrideCompatibilityInfo returnTypeMismatch(KtType substitutedSuperReturnType, KtType unsubstitutedSubReturnType) {
|
||||
return new OverrideCompatibilityInfo(Result.CONFLICT, "returnTypeMismatch: " + unsubstitutedSubReturnType + " >< " + substitutedSuperReturnType); // TODO
|
||||
}
|
||||
|
||||
|
||||
@@ -19,15 +19,15 @@ package org.jetbrains.kotlin.resolve.descriptorUtil
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.types.JetType
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
|
||||
private val NO_INFER_ANNOTATION_FQ_NAME = FqName("kotlin.internal.NoInfer")
|
||||
|
||||
public fun JetType.hasNoInferAnnotation(): Boolean = annotations.hasAnnotation(NO_INFER_ANNOTATION_FQ_NAME)
|
||||
public fun KtType.hasNoInferAnnotation(): Boolean = annotations.hasAnnotation(NO_INFER_ANNOTATION_FQ_NAME)
|
||||
|
||||
private val EXACT_ANNOTATION_FQ_NAME = FqName("kotlin.internal.Exact")
|
||||
|
||||
public fun JetType.hasExactAnnotation(): Boolean = annotations.hasAnnotation(EXACT_ANNOTATION_FQ_NAME)
|
||||
public fun KtType.hasExactAnnotation(): Boolean = annotations.hasAnnotation(EXACT_ANNOTATION_FQ_NAME)
|
||||
|
||||
private val LOW_PRIORITY_IN_OVERLOAD_RESOLUTION_FQ_NAME = FqName("kotlin.internal.LowPriorityInOverloadResolution")
|
||||
|
||||
|
||||
+9
-9
@@ -35,7 +35,7 @@ public class CapturedTypeConstructor(
|
||||
|
||||
override fun getParameters(): List<TypeParameterDescriptor> = listOf()
|
||||
|
||||
override fun getSupertypes(): Collection<JetType> {
|
||||
override fun getSupertypes(): Collection<KtType> {
|
||||
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)
|
||||
JetTypeImpl.create(Annotations.EMPTY, CapturedTypeConstructor(typeProjection), false, listOf(), scope)
|
||||
KtTypeImpl.create(Annotations.EMPTY, CapturedTypeConstructor(typeProjection), false, listOf(), scope)
|
||||
}
|
||||
|
||||
override fun getDelegate(): JetType = delegateType
|
||||
override fun getDelegate(): KtType = 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: JetType
|
||||
override val subTypeRepresentative: KtType
|
||||
get() = representative(OUT_VARIANCE, builtIns.nullableAnyType)
|
||||
|
||||
override val superTypeRepresentative: JetType
|
||||
override val superTypeRepresentative: KtType
|
||||
get() = representative(IN_VARIANCE, builtIns.nothingType)
|
||||
|
||||
private fun representative(variance: Variance, default: JetType) =
|
||||
private fun representative(variance: Variance, default: KtType) =
|
||||
if (typeProjection.getProjectionKind() == variance) typeProjection.getType() else default
|
||||
|
||||
override fun sameTypeConstructor(type: JetType) = delegateType.getConstructor() === type.getConstructor()
|
||||
override fun sameTypeConstructor(type: KtType) = delegateType.getConstructor() === type.getConstructor()
|
||||
|
||||
override fun toString() = "Captured($typeProjection)"
|
||||
}
|
||||
|
||||
public fun createCapturedType(typeProjection: TypeProjection): JetType = CapturedType(typeProjection)
|
||||
public fun createCapturedType(typeProjection: TypeProjection): KtType = CapturedType(typeProjection)
|
||||
|
||||
public fun JetType.isCaptured(): Boolean = getConstructor() is CapturedTypeConstructor
|
||||
public fun KtType.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.JetType
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
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: JetType?, subjectType: JetType, constraintPosition: ConstraintPosition)
|
||||
public fun addSubtypeConstraint(constrainingType: KtType?, subjectType: KtType, 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: JetType?, subjectType: JetType, constraintPosition: ConstraintPosition)
|
||||
public fun addSupertypeConstraint(constrainingType: KtType?, subjectType: KtType, constraintPosition: ConstraintPosition)
|
||||
|
||||
public fun getStatus(): ConstraintSystemStatus
|
||||
|
||||
|
||||
+36
-36
@@ -32,10 +32,10 @@ import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.derivedFr
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.hasNoInferAnnotation
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.hasExactAnnotation
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.hasOnlyInputTypesAnnotation
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.KtScope
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.TypeUtils.DONT_CARE
|
||||
import org.jetbrains.kotlin.types.checker.JetTypeChecker
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
|
||||
import org.jetbrains.kotlin.types.checker.TypeCheckingProcedure
|
||||
import org.jetbrains.kotlin.types.checker.TypeCheckingProcedureCallbacks
|
||||
import org.jetbrains.kotlin.types.typeUtil.builtIns
|
||||
@@ -46,7 +46,7 @@ import java.util.*
|
||||
|
||||
public class ConstraintSystemImpl : ConstraintSystem {
|
||||
|
||||
data class Constraint(val kind: ConstraintKind, val subtype: JetType, val superType: JetType, val position: ConstraintPosition)
|
||||
data class Constraint(val kind: ConstraintKind, val subtype: KtType, val superType: KtType, val position: ConstraintPosition)
|
||||
|
||||
public enum class ConstraintKind {
|
||||
SUB_TYPE,
|
||||
@@ -61,7 +61,7 @@ public class ConstraintSystemImpl : ConstraintSystem {
|
||||
get() = if (externalTypeParameters.isEmpty()) allTypeParameterBounds
|
||||
else allTypeParameterBounds.filter { !externalTypeParameters.contains(it.key) }
|
||||
|
||||
private val cachedTypeForVariable = HashMap<TypeParameterDescriptor, JetType>()
|
||||
private val cachedTypeForVariable = HashMap<TypeParameterDescriptor, KtType>()
|
||||
|
||||
private val usedInBounds = HashMap<TypeParameterDescriptor, MutableList<TypeBounds.Bound>>()
|
||||
|
||||
@@ -165,16 +165,16 @@ public class ConstraintSystemImpl : ConstraintSystem {
|
||||
}
|
||||
}
|
||||
|
||||
val TypeParameterDescriptor.correspondingType: JetType
|
||||
val TypeParameterDescriptor.correspondingType: KtType
|
||||
get() = cachedTypeForVariable.getOrPut(this) {
|
||||
JetTypeImpl.create(Annotations.EMPTY, this.getTypeConstructor(), false, listOf(), JetScope.Empty)
|
||||
KtTypeImpl.create(Annotations.EMPTY, this.getTypeConstructor(), false, listOf(), KtScope.Empty)
|
||||
}
|
||||
|
||||
fun JetType.isProper() = !TypeUtils.containsSpecialType(this) {
|
||||
fun KtType.isProper() = !TypeUtils.containsSpecialType(this) {
|
||||
type -> type.getConstructor().getDeclarationDescriptor() in getAllTypeVariables()
|
||||
}
|
||||
|
||||
fun JetType.getNestedTypeVariables(original: Boolean = true): List<TypeParameterDescriptor> {
|
||||
fun KtType.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: JetType?, subjectType: JetType, constraintPosition: ConstraintPosition) {
|
||||
override fun addSupertypeConstraint(constrainingType: KtType?, subjectType: KtType, 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: JetType?, subjectType: JetType, constraintPosition: ConstraintPosition) {
|
||||
override fun addSubtypeConstraint(constrainingType: KtType?, subjectType: KtType, constraintPosition: ConstraintPosition) {
|
||||
val newSubjectType = originalToVariablesSubstitutor.substitute(subjectType, Variance.INVARIANT)
|
||||
addConstraint(SUB_TYPE, constrainingType, newSubjectType, ConstraintContext(constraintPosition, initial = true))
|
||||
}
|
||||
|
||||
fun addConstraint(
|
||||
constraintKind: ConstraintKind,
|
||||
subType: JetType?,
|
||||
superType: JetType?,
|
||||
subType: KtType?,
|
||||
superType: KtType?,
|
||||
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: JetType, b: JetType, typeCheckingProcedure: TypeCheckingProcedure): Boolean {
|
||||
override fun assertEqualTypes(a: KtType, b: KtType, 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: JetType, supertype: JetType, typeCheckingProcedure: TypeCheckingProcedure): Boolean {
|
||||
override fun assertSubtype(subtype: KtType, supertype: KtType, typeCheckingProcedure: TypeCheckingProcedure): Boolean {
|
||||
depth++
|
||||
doAddConstraint(SUB_TYPE, subtype, supertype, newConstraintContext, typeCheckingProcedure)
|
||||
depth--
|
||||
return true
|
||||
}
|
||||
|
||||
override fun capture(typeVariable: JetType, typeProjection: TypeProjection): Boolean {
|
||||
override fun capture(typeVariable: KtType, 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: JetType, supertype: JetType): Boolean {
|
||||
override fun noCorrespondingSupertype(subtype: KtType, supertype: KtType): 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: JetType?, constraintPosition: ConstraintPosition): Boolean {
|
||||
private fun isErrorOrSpecialType(type: KtType?, 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: JetType?,
|
||||
superType: JetType?,
|
||||
subType: KtType?,
|
||||
superType: KtType?,
|
||||
constraintContext: ConstraintContext,
|
||||
typeCheckingProcedure: TypeCheckingProcedure
|
||||
) {
|
||||
@@ -317,7 +317,7 @@ public class ConstraintSystemImpl : ConstraintSystem {
|
||||
subType
|
||||
}
|
||||
|
||||
fun simplifyConstraint(subType: JetType, superType: JetType) {
|
||||
fun simplifyConstraint(subType: KtType, superType: KtType) {
|
||||
if (isMyTypeVariable(subType)) {
|
||||
generateTypeParameterBound(subType, superType, constraintKind.toBound(), constraintContext)
|
||||
return
|
||||
@@ -348,7 +348,7 @@ public class ConstraintSystemImpl : ConstraintSystem {
|
||||
|
||||
fun addBound(
|
||||
typeVariable: TypeParameterDescriptor,
|
||||
constrainingType: JetType,
|
||||
constrainingType: KtType,
|
||||
kind: TypeBounds.BoundKind,
|
||||
constraintContext: ConstraintContext
|
||||
) {
|
||||
@@ -370,8 +370,8 @@ public class ConstraintSystemImpl : ConstraintSystem {
|
||||
}
|
||||
|
||||
private fun generateTypeParameterBound(
|
||||
parameterType: JetType,
|
||||
constrainingType: JetType,
|
||||
parameterType: KtType,
|
||||
constrainingType: KtType,
|
||||
boundKind: TypeBounds.BoundKind,
|
||||
constraintContext: ConstraintContext
|
||||
) {
|
||||
@@ -414,7 +414,7 @@ public class ConstraintSystemImpl : ConstraintSystem {
|
||||
}
|
||||
|
||||
private fun generateTypeParameterCaptureConstraint(
|
||||
parameterType: JetType,
|
||||
parameterType: KtType,
|
||||
constrainingTypeProjection: TypeProjection,
|
||||
constraintContext: ConstraintContext
|
||||
) {
|
||||
@@ -452,9 +452,9 @@ public class ConstraintSystemImpl : ConstraintSystem {
|
||||
|
||||
fun isMyTypeVariable(typeVariable: TypeParameterDescriptor) = allTypeParameterBounds.contains(typeVariable)
|
||||
|
||||
fun isMyTypeVariable(type: JetType): Boolean = getMyTypeVariable(type) != null
|
||||
fun isMyTypeVariable(type: KtType): Boolean = getMyTypeVariable(type) != null
|
||||
|
||||
fun getMyTypeVariable(type: JetType): TypeParameterDescriptor? {
|
||||
fun getMyTypeVariable(type: KtType): 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: JetType, superType: JetType, position: ConstraintPosition) {
|
||||
private fun storeInitialConstraint(constraintKind: ConstraintKind, subType: KtType, superType: KtType, position: ConstraintPosition) {
|
||||
initialConstraints.add(Constraint(constraintKind, subType, superType, position))
|
||||
}
|
||||
|
||||
private fun satisfyInitialConstraints(): Boolean {
|
||||
fun JetType.substitute(): JetType? {
|
||||
fun KtType.substitute(): KtType? {
|
||||
val substitutor = getSubstitutor(substituteOriginal = false) { TypeProjectionImpl(ErrorUtils.createUninferredParameterType(it)) }
|
||||
return substitutor.substitute(this, Variance.INVARIANT) ?: return null
|
||||
}
|
||||
@@ -489,8 +489,8 @@ public class ConstraintSystemImpl : ConstraintSystem {
|
||||
} ?: return false
|
||||
val resultSuperType = constraint.superType.substitute() ?: return false
|
||||
when (constraint.kind) {
|
||||
SUB_TYPE -> JetTypeChecker.DEFAULT.isSubtypeOf(resultSubType, resultSuperType)
|
||||
EQUAL -> JetTypeChecker.DEFAULT.equalTypes(resultSubType, resultSuperType)
|
||||
SUB_TYPE -> KotlinTypeChecker.DEFAULT.isSubtypeOf(resultSubType, resultSuperType)
|
||||
EQUAL -> KotlinTypeChecker.DEFAULT.equalTypes(resultSubType, resultSuperType)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -518,9 +518,9 @@ public class ConstraintSystemImpl : ConstraintSystem {
|
||||
}
|
||||
|
||||
fun createTypeForFunctionPlaceholder(
|
||||
functionPlaceholder: JetType,
|
||||
expectedType: JetType
|
||||
): JetType {
|
||||
functionPlaceholder: KtType,
|
||||
expectedType: KtType
|
||||
): KtType {
|
||||
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<JetType>()
|
||||
val result = arrayListOf<KtType>()
|
||||
(1..functionArgumentsSize).forEach { result.add(DONT_CARE) }
|
||||
result
|
||||
}
|
||||
@@ -547,7 +547,7 @@ private fun TypeSubstitutor.setApproximateCapturedTypes(): TypeSubstitutor {
|
||||
}
|
||||
|
||||
private class SubstitutionWithCapturedTypeApproximation(val substitution: TypeSubstitution) : TypeSubstitution() {
|
||||
override fun get(key: JetType) = substitution[key]
|
||||
override fun get(key: KtType) = substitution[key]
|
||||
override fun isEmpty() = substitution.isEmpty()
|
||||
override fun approximateCapturedTypes() = true
|
||||
}
|
||||
@@ -570,7 +570,7 @@ public fun createTypeSubstitutor(conversion: (TypeParameterDescriptor) -> TypePa
|
||||
if (descriptor !is TypeParameterDescriptor) return null
|
||||
val typeParameterDescriptor = conversion(descriptor) ?: return null
|
||||
|
||||
val type = JetTypeImpl.create(Annotations.EMPTY, typeParameterDescriptor.getTypeConstructor(), false, listOf(), JetScope.Empty)
|
||||
val type = KtTypeImpl.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.JetType
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
|
||||
public interface TypeBounds {
|
||||
@@ -32,10 +32,10 @@ public interface TypeBounds {
|
||||
|
||||
public val bounds: Collection<Bound>
|
||||
|
||||
public val value: JetType?
|
||||
public val value: KtType?
|
||||
get() = if (values.size() == 1) values.first() else null
|
||||
|
||||
public val values: Collection<JetType>
|
||||
public val values: Collection<KtType>
|
||||
|
||||
public enum class BoundKind {
|
||||
LOWER_BOUND,
|
||||
@@ -45,7 +45,7 @@ public interface TypeBounds {
|
||||
|
||||
public class Bound(
|
||||
public val typeVariable: TypeParameterDescriptor,
|
||||
public val constrainingType: JetType,
|
||||
public val constrainingType: KtType,
|
||||
public val kind: BoundKind,
|
||||
public val position: ConstraintPosition,
|
||||
public val isProper: Boolean,
|
||||
|
||||
+14
-16
@@ -19,14 +19,12 @@ package org.jetbrains.kotlin.resolve.calls.inference
|
||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.TypeBounds.Bound
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.TypeBounds.BoundKind
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.TypeBounds.BoundKind.EXACT_BOUND
|
||||
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.TypeBounds.BoundKind.*
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPosition
|
||||
import org.jetbrains.kotlin.resolve.constants.IntegerValueTypeConstructor
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.hasOnlyInputTypesAnnotation
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.checker.JetTypeChecker
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
|
||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
import java.util.*
|
||||
|
||||
@@ -36,7 +34,7 @@ public class TypeBoundsImpl(
|
||||
) : TypeBounds {
|
||||
override val bounds = ArrayList<Bound>()
|
||||
|
||||
private var resultValues: Collection<JetType>? = null
|
||||
private var resultValues: Collection<KtType>? = null
|
||||
|
||||
var isFixed: Boolean = false
|
||||
private set
|
||||
@@ -53,12 +51,12 @@ public class TypeBoundsImpl(
|
||||
bounds.add(bound)
|
||||
}
|
||||
|
||||
private fun filterBounds(bounds: Collection<Bound>, kind: BoundKind): Set<JetType> {
|
||||
private fun filterBounds(bounds: Collection<Bound>, kind: BoundKind): Set<KtType> {
|
||||
return filterBounds(bounds, kind, null)
|
||||
}
|
||||
|
||||
private fun filterBounds(bounds: Collection<Bound>, kind: BoundKind, errorValues: MutableCollection<JetType>?): Set<JetType> {
|
||||
val result = LinkedHashSet<JetType>()
|
||||
private fun filterBounds(bounds: Collection<Bound>, kind: BoundKind, errorValues: MutableCollection<KtType>?): Set<KtType> {
|
||||
val result = LinkedHashSet<KtType>()
|
||||
for (bound in bounds) {
|
||||
if (bound.kind == kind) {
|
||||
if (!ErrorUtils.containsErrorType(bound.constrainingType)) {
|
||||
@@ -78,7 +76,7 @@ public class TypeBoundsImpl(
|
||||
return result
|
||||
}
|
||||
|
||||
override val values: Collection<JetType>
|
||||
override val values: Collection<KtType>
|
||||
get() {
|
||||
if (resultValues == null) {
|
||||
resultValues = computeValues()
|
||||
@@ -86,8 +84,8 @@ public class TypeBoundsImpl(
|
||||
return resultValues!!
|
||||
}
|
||||
|
||||
private fun computeValues(): Collection<JetType> {
|
||||
val values = LinkedHashSet<JetType>()
|
||||
private fun computeValues(): Collection<KtType> {
|
||||
val values = LinkedHashSet<KtType>()
|
||||
val bounds = bounds.filter { it.isProper }
|
||||
|
||||
if (bounds.isEmpty()) {
|
||||
@@ -135,7 +133,7 @@ public class TypeBoundsImpl(
|
||||
|
||||
val upperBounds = filterBounds(bounds, TypeBounds.BoundKind.UPPER_BOUND, values)
|
||||
if (upperBounds.isNotEmpty()) {
|
||||
val intersectionOfUpperBounds = TypeIntersector.intersectTypes(JetTypeChecker.DEFAULT, upperBounds)
|
||||
val intersectionOfUpperBounds = TypeIntersector.intersectTypes(KotlinTypeChecker.DEFAULT, upperBounds)
|
||||
if (intersectionOfUpperBounds != null && tryPossibleAnswer(bounds, intersectionOfUpperBounds)) {
|
||||
return setOf(intersectionOfUpperBounds)
|
||||
}
|
||||
@@ -148,7 +146,7 @@ public class TypeBoundsImpl(
|
||||
return values
|
||||
}
|
||||
|
||||
private fun tryPossibleAnswer(bounds: Collection<Bound>, possibleAnswer: JetType?): Boolean {
|
||||
private fun tryPossibleAnswer(bounds: Collection<Bound>, possibleAnswer: KtType?): Boolean {
|
||||
if (possibleAnswer == null) return false
|
||||
// a captured type might be an answer
|
||||
if (!possibleAnswer.getConstructor().isDenotable() && !possibleAnswer.isCaptured()) return false
|
||||
@@ -160,15 +158,15 @@ public class TypeBoundsImpl(
|
||||
|
||||
for (bound in bounds) {
|
||||
when (bound.kind) {
|
||||
LOWER_BOUND -> if (!JetTypeChecker.DEFAULT.isSubtypeOf(bound.constrainingType, possibleAnswer)) {
|
||||
LOWER_BOUND -> if (!KotlinTypeChecker.DEFAULT.isSubtypeOf(bound.constrainingType, possibleAnswer)) {
|
||||
return false
|
||||
}
|
||||
|
||||
UPPER_BOUND -> if (!JetTypeChecker.DEFAULT.isSubtypeOf(possibleAnswer, bound.constrainingType)) {
|
||||
UPPER_BOUND -> if (!KotlinTypeChecker.DEFAULT.isSubtypeOf(possibleAnswer, bound.constrainingType)) {
|
||||
return false
|
||||
}
|
||||
|
||||
EXACT_BOUND -> if (!JetTypeChecker.DEFAULT.equalTypes(bound.constrainingType, possibleAnswer)) {
|
||||
EXACT_BOUND -> if (!KotlinTypeChecker.DEFAULT.equalTypes(bound.constrainingType, possibleAnswer)) {
|
||||
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: JetType, newBoundKind: BoundKind) {
|
||||
fun addNewBound(newConstrainingType: KtType, 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 JetType.containsConstrainingTypeWithoutProjection() = this.getNestedArguments().any {
|
||||
fun KtType.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: JetType): ConstantValue<T>
|
||||
public fun toConstantValue(expectedType: KtType): ConstantValue<T>
|
||||
|
||||
public fun getValue(expectedType: JetType): T = toConstantValue(expectedType).value
|
||||
public fun getValue(expectedType: KtType): 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: JetType = constantValue.type
|
||||
public val type: KtType = constantValue.type
|
||||
|
||||
override fun toConstantValue(expectedType: JetType): ConstantValue<T> = constantValue
|
||||
override fun toConstantValue(expectedType: KtType): 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: JetType): ConstantValue<Number> {
|
||||
override fun toConstantValue(expectedType: KtType): ConstantValue<Number> {
|
||||
val factory = ConstantValueFactory(builtIns)
|
||||
val type = getType(expectedType)
|
||||
return when {
|
||||
@@ -84,12 +84,12 @@ public class IntegerValueTypeConstant(
|
||||
}
|
||||
}
|
||||
|
||||
val unknownIntegerType = JetTypeImpl.create(
|
||||
val unknownIntegerType = KtTypeImpl.create(
|
||||
Annotations.EMPTY, typeConstructor, false, emptyList<TypeProjection>(),
|
||||
ErrorUtils.createErrorScope("Scope for number value type (" + typeConstructor.toString() + ")", true)
|
||||
)
|
||||
|
||||
public fun getType(expectedType: JetType): JetType = TypeUtils.getPrimitiveNumberType(typeConstructor, expectedType)
|
||||
public fun getType(expectedType: KtType): KtType = 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.JetType
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
|
||||
public class ConstantValueFactory(
|
||||
@@ -51,12 +51,12 @@ public class ConstantValueFactory(
|
||||
|
||||
fun createArrayValue(
|
||||
value: List<ConstantValue<*>>,
|
||||
type: JetType
|
||||
type: KtType
|
||||
) = ArrayValue(value, type, builtins)
|
||||
|
||||
fun createAnnotationValue(value: AnnotationDescriptor) = AnnotationValue(value)
|
||||
|
||||
fun createKClassValue(type: JetType) = KClassValue(type)
|
||||
fun createKClassValue(type: KtType) = KClassValue(type)
|
||||
|
||||
fun createConstantValue(
|
||||
value: Any?
|
||||
@@ -79,7 +79,7 @@ public class ConstantValueFactory(
|
||||
|
||||
public fun createIntegerConstantValue(
|
||||
value: Long,
|
||||
expectedType: JetType
|
||||
expectedType: KtType
|
||||
): 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.JetType
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
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<JetType>(4)
|
||||
private val supertypes = ArrayList<KtType>(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: JetType) {
|
||||
private fun checkBoundsAndAddSuperType(value: Long, minValue: Long, maxValue: Long, kotlinType: KtType) {
|
||||
if (value >= minValue && value <= maxValue) {
|
||||
supertypes.add(kotlinType)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getSupertypes(): Collection<JetType> = supertypes
|
||||
override fun getSupertypes(): Collection<KtType> = 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.JetType
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.utils.sure
|
||||
|
||||
public abstract class ConstantValue<out T>(public open val value: T) {
|
||||
public abstract val type: JetType
|
||||
public abstract val type: KtType
|
||||
|
||||
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: JetType
|
||||
override val type: KtType
|
||||
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: JetType,
|
||||
override val type: KtType,
|
||||
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: JetType
|
||||
public val elementType: KtType
|
||||
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: JetType
|
||||
override val type: KtType
|
||||
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: JetType) :
|
||||
ConstantValue<JetType>(type) {
|
||||
override val value: JetType
|
||||
public class KClassValue(override val type: KtType) :
|
||||
ConstantValue<KtType>(type) {
|
||||
override val value: KtType
|
||||
get() = type.getArguments().single().getType()
|
||||
|
||||
override fun <R, D> accept(visitor: AnnotationArgumentVisitor<R, D>, data: D) = visitor.visitKClassValue(this, data)
|
||||
|
||||
@@ -19,16 +19,16 @@ 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.JetType
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.utils.Printer
|
||||
|
||||
/**
|
||||
* Introduces a simple wrapper for internal scope.
|
||||
*/
|
||||
public abstract class AbstractScopeAdapter : JetScope {
|
||||
protected abstract val workerScope: JetScope
|
||||
public abstract class AbstractScopeAdapter : KtScope {
|
||||
protected abstract val workerScope: KtScope
|
||||
|
||||
public fun getActualScope(): JetScope =
|
||||
public fun getActualScope(): KtScope =
|
||||
if (workerScope is AbstractScopeAdapter)
|
||||
(workerScope as AbstractScopeAdapter).getActualScope()
|
||||
else
|
||||
@@ -54,19 +54,19 @@ public abstract class AbstractScopeAdapter : JetScope {
|
||||
return workerScope.getProperties(name, location)
|
||||
}
|
||||
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name, location: LookupLocation): Collection<PropertyDescriptor> {
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KtType>, name: Name, location: LookupLocation): Collection<PropertyDescriptor> {
|
||||
return workerScope.getSyntheticExtensionProperties(receiverTypes, name, location)
|
||||
}
|
||||
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>, name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<KtType>, name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
|
||||
return workerScope.getSyntheticExtensionFunctions(receiverTypes, name, location)
|
||||
}
|
||||
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>): Collection<PropertyDescriptor> {
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KtType>): Collection<PropertyDescriptor> {
|
||||
return workerScope.getSyntheticExtensionProperties(receiverTypes)
|
||||
}
|
||||
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>): Collection<FunctionDescriptor> {
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<KtType>): 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.JetType
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.util.collectionUtils.getFirstMatch
|
||||
import org.jetbrains.kotlin.util.collectionUtils.getFromAllScopes
|
||||
import org.jetbrains.kotlin.utils.Printer
|
||||
@@ -28,8 +28,8 @@ import java.util.ArrayList
|
||||
public open class ChainedScope(
|
||||
private val containingDeclaration: DeclarationDescriptor?/* it's nullable as a hack for TypeUtils.intersect() */,
|
||||
private val debugName: String,
|
||||
vararg scopes: JetScope
|
||||
) : JetScope {
|
||||
vararg scopes: KtScope
|
||||
) : KtScope {
|
||||
private val scopeChain = scopes.clone()
|
||||
private var implicitReceiverHierarchy: List<ReceiverParameterDescriptor>? = null
|
||||
|
||||
@@ -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<JetType>, name: Name, location: LookupLocation): Collection<PropertyDescriptor>
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KtType>, name: Name, location: LookupLocation): Collection<PropertyDescriptor>
|
||||
= getFromAllScopes(scopeChain) { it.getSyntheticExtensionProperties(receiverTypes, name, location) }
|
||||
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>, name: Name, location: LookupLocation): Collection<FunctionDescriptor>
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<KtType>, name: Name, location: LookupLocation): Collection<FunctionDescriptor>
|
||||
= getFromAllScopes(scopeChain) { it.getSyntheticExtensionFunctions(receiverTypes, name, location) }
|
||||
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>): Collection<PropertyDescriptor>
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KtType>): Collection<PropertyDescriptor>
|
||||
= getFromAllScopes(scopeChain) { it.getSyntheticExtensionProperties(receiverTypes) }
|
||||
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>): Collection<FunctionDescriptor>
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<KtType>): Collection<FunctionDescriptor>
|
||||
= getFromAllScopes(scopeChain) { it.getSyntheticExtensionFunctions(receiverTypes) }
|
||||
|
||||
override fun getImplicitReceiversHierarchy(): List<ReceiverParameterDescriptor> {
|
||||
|
||||
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.utils.Printer
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
|
||||
|
||||
public class ExplicitImportsScope(private val descriptors: Collection<DeclarationDescriptor>) : JetScopeImpl() {
|
||||
public class ExplicitImportsScope(private val descriptors: Collection<DeclarationDescriptor>) : KtScopeImpl() {
|
||||
override fun getClassifier(name: Name, location: LookupLocation) = descriptors.filter { it.getName() == name }.firstIsInstanceOrNull<ClassifierDescriptor>()
|
||||
|
||||
override fun getPackage(name: Name)= descriptors.filter { it.getName() == name }.firstIsInstanceOrNull<PackageViewDescriptor>()
|
||||
|
||||
@@ -21,10 +21,10 @@ 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.JetType
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.utils.Printer
|
||||
|
||||
public class FilteringScope(private val workerScope: JetScope, private val predicate: (DeclarationDescriptor) -> Boolean) : JetScope {
|
||||
public class FilteringScope(private val workerScope: KtScope, private val predicate: (DeclarationDescriptor) -> Boolean) : KtScope {
|
||||
|
||||
override fun getFunctions(name: Name, location: LookupLocation) = workerScope.getFunctions(name, location).filter(predicate)
|
||||
|
||||
@@ -39,16 +39,16 @@ public class FilteringScope(private val workerScope: JetScope, private val predi
|
||||
|
||||
override fun getProperties(name: Name, location: LookupLocation) = workerScope.getProperties(name, location).filter(predicate)
|
||||
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name, location: LookupLocation): Collection<PropertyDescriptor>
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KtType>, name: Name, location: LookupLocation): Collection<PropertyDescriptor>
|
||||
= workerScope.getSyntheticExtensionProperties(receiverTypes, name, location).filter(predicate)
|
||||
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>, name: Name, location: LookupLocation): Collection<FunctionDescriptor>
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<KtType>, name: Name, location: LookupLocation): Collection<FunctionDescriptor>
|
||||
= workerScope.getSyntheticExtensionFunctions(receiverTypes, name, location).filter(predicate)
|
||||
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>): Collection<PropertyDescriptor>
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KtType>): Collection<PropertyDescriptor>
|
||||
= workerScope.getSyntheticExtensionProperties(receiverTypes).filter(predicate)
|
||||
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>): Collection<FunctionDescriptor>
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<KtType>): Collection<FunctionDescriptor>
|
||||
= workerScope.getSyntheticExtensionFunctions(receiverTypes).filter(predicate)
|
||||
|
||||
override fun getLocalVariable(name: Name) = filterDescriptor(workerScope.getLocalVariable(name))
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.incremental.components.LookupLocation
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.utils.Printer
|
||||
|
||||
public class InnerClassesScopeWrapper(val workerScope: JetScope) : JetScopeImpl() {
|
||||
public class InnerClassesScopeWrapper(val workerScope: KtScope) : KtScopeImpl() {
|
||||
override fun getContainingDeclaration(): DeclarationDescriptor {
|
||||
return workerScope.getContainingDeclaration()
|
||||
}
|
||||
|
||||
+8
-8
@@ -20,12 +20,12 @@ 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.JetType
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.utils.Printer
|
||||
import org.jetbrains.kotlin.utils.toReadOnlyList
|
||||
import java.lang.reflect.Modifier
|
||||
|
||||
public interface JetScope {
|
||||
public interface KtScope {
|
||||
|
||||
public fun getClassifier(name: Name, location: LookupLocation): ClassifierDescriptor?
|
||||
|
||||
@@ -37,11 +37,11 @@ public interface JetScope {
|
||||
|
||||
public fun getFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor>
|
||||
|
||||
public fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name, location: LookupLocation): Collection<PropertyDescriptor>
|
||||
public fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>, 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<JetType>): Collection<PropertyDescriptor>
|
||||
public fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>): Collection<FunctionDescriptor>
|
||||
public fun getSyntheticExtensionProperties(receiverTypes: Collection<KtType>): Collection<PropertyDescriptor>
|
||||
public fun getSyntheticExtensionFunctions(receiverTypes: Collection<KtType>): Collection<FunctionDescriptor>
|
||||
|
||||
public fun getContainingDeclaration(): DeclarationDescriptor
|
||||
|
||||
@@ -79,7 +79,7 @@ public interface JetScope {
|
||||
*/
|
||||
public fun printScopeStructure(p: Printer)
|
||||
|
||||
public object Empty : JetScopeImpl() {
|
||||
public object Empty : KtScopeImpl() {
|
||||
override fun getContainingDeclaration(): DeclarationDescriptor {
|
||||
throw UnsupportedOperationException("Don't take containing declaration of the Empty scope")
|
||||
}
|
||||
@@ -99,7 +99,7 @@ public interface JetScope {
|
||||
/**
|
||||
* The same as getDescriptors(kindFilter, nameFilter) but the result is guaranteed to be filtered by kind and name.
|
||||
*/
|
||||
public fun JetScope.getDescriptorsFiltered(
|
||||
public fun KtScope.getDescriptorsFiltered(
|
||||
kindFilter: DescriptorKindFilter = DescriptorKindFilter.ALL,
|
||||
nameFilter: (Name) -> Boolean = { true }
|
||||
): Collection<DeclarationDescriptor> {
|
||||
+6
-6
@@ -19,10 +19,10 @@ 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.JetType
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.utils.Printer
|
||||
|
||||
public abstract class JetScopeImpl : JetScope {
|
||||
public abstract class KtScopeImpl : KtScope {
|
||||
override fun getClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? = null
|
||||
|
||||
override fun getProperties(name: Name, location: LookupLocation): Collection<VariableDescriptor> = emptyList()
|
||||
@@ -33,11 +33,11 @@ public abstract class JetScopeImpl : JetScope {
|
||||
|
||||
override fun getFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor> = emptyList()
|
||||
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name, location: LookupLocation): Collection<PropertyDescriptor> = emptyList()
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>, 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<JetType>): Collection<PropertyDescriptor> = emptyList()
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>): Collection<FunctionDescriptor> = emptyList()
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KtType>): Collection<PropertyDescriptor> = emptyList()
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<KtType>): Collection<FunctionDescriptor> = emptyList()
|
||||
|
||||
override fun getDeclarationsByLabel(labelName: Name): Collection<DeclarationDescriptor> = emptyList()
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.resolve.scopes
|
||||
|
||||
import org.jetbrains.kotlin.storage.NotNullLazyValue
|
||||
|
||||
public class LazyScopeAdapter(private val scope: NotNullLazyValue<JetScope>) : AbstractScopeAdapter() {
|
||||
override val workerScope: JetScope
|
||||
public class LazyScopeAdapter(private val scope: NotNullLazyValue<KtScope>) : AbstractScopeAdapter() {
|
||||
override val workerScope: KtScope
|
||||
get() = scope()
|
||||
}
|
||||
|
||||
@@ -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.JetType
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.utils.Printer
|
||||
|
||||
// see ScopeUtils.kt in the frontend module
|
||||
@@ -58,14 +58,14 @@ public interface FileScope: LexicalScope {
|
||||
|
||||
fun getPackage(name: Name): PackageViewDescriptor?
|
||||
|
||||
public fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name, location: LookupLocation): Collection<PropertyDescriptor>
|
||||
public fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>, 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<JetType>): Collection<PropertyDescriptor>
|
||||
public fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>): Collection<FunctionDescriptor>
|
||||
public fun getSyntheticExtensionProperties(receiverTypes: Collection<KtType>): Collection<PropertyDescriptor>
|
||||
public fun getSyntheticExtensionFunctions(receiverTypes: Collection<KtType>): Collection<FunctionDescriptor>
|
||||
|
||||
public fun getDescriptors(
|
||||
kindFilter: DescriptorKindFilter = DescriptorKindFilter.ALL,
|
||||
nameFilter: (Name) -> Boolean = JetScope.ALL_NAME_FILTER
|
||||
nameFilter: (Name) -> Boolean = KtScope.ALL_NAME_FILTER
|
||||
): Collection<DeclarationDescriptor>
|
||||
}
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ import java.util.ArrayList
|
||||
|
||||
public class StaticScopeForKotlinClass(
|
||||
private val containingClass: ClassDescriptor
|
||||
) : JetScopeImpl() {
|
||||
) : KtScopeImpl() {
|
||||
override fun getClassifier(name: Name, location: LookupLocation) = null // TODO
|
||||
|
||||
private val functions: List<FunctionDescriptor> by lazy {
|
||||
|
||||
@@ -22,13 +22,13 @@ 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.JetType
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.TypeSubstitutor
|
||||
import org.jetbrains.kotlin.utils.Printer
|
||||
import org.jetbrains.kotlin.utils.newHashSetWithExpectedSize
|
||||
import java.util.HashMap
|
||||
|
||||
public class SubstitutingScope(private val workerScope: JetScope, private val substitutor: TypeSubstitutor) : JetScope {
|
||||
public class SubstitutingScope(private val workerScope: KtScope, private val substitutor: TypeSubstitutor) : KtScope {
|
||||
|
||||
private var substitutedDescriptors: MutableMap<DeclarationDescriptor, DeclarationDescriptor?>? = null
|
||||
|
||||
@@ -71,16 +71,16 @@ public class SubstitutingScope(private val workerScope: JetScope, private val su
|
||||
|
||||
override fun getFunctions(name: Name, location: LookupLocation) = substitute(workerScope.getFunctions(name, location))
|
||||
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name, location: LookupLocation): Collection<PropertyDescriptor>
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KtType>, name: Name, location: LookupLocation): Collection<PropertyDescriptor>
|
||||
= substitute(workerScope.getSyntheticExtensionProperties(receiverTypes, name, location))
|
||||
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>, name: Name, location: LookupLocation): Collection<FunctionDescriptor>
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<KtType>, name: Name, location: LookupLocation): Collection<FunctionDescriptor>
|
||||
= substitute(workerScope.getSyntheticExtensionFunctions(receiverTypes, name, location))
|
||||
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>): Collection<PropertyDescriptor>
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KtType>): Collection<PropertyDescriptor>
|
||||
= substitute(workerScope.getSyntheticExtensionProperties(receiverTypes))
|
||||
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>): Collection<FunctionDescriptor>
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<KtType>): 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.JetType;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
|
||||
public abstract class AbstractReceiverValue implements ReceiverValue {
|
||||
protected final JetType receiverType;
|
||||
protected final KtType receiverType;
|
||||
|
||||
public AbstractReceiverValue(@NotNull JetType receiverType) {
|
||||
public AbstractReceiverValue(@NotNull KtType receiverType) {
|
||||
this.receiverType = receiverType;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public JetType getType() {
|
||||
public KtType 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.JetType;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
|
||||
public class ClassReceiver implements ThisReceiver {
|
||||
|
||||
@@ -35,7 +35,7 @@ public class ClassReceiver implements ThisReceiver {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JetType getType() {
|
||||
public KtType 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.JetType;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
|
||||
public class ExtensionReceiver extends AbstractReceiverValue implements ThisReceiver {
|
||||
|
||||
private final CallableDescriptor descriptor;
|
||||
|
||||
public ExtensionReceiver(@NotNull CallableDescriptor callableDescriptor, @NotNull JetType receiverType) {
|
||||
public ExtensionReceiver(@NotNull CallableDescriptor callableDescriptor, @NotNull KtType 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.JetType;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
|
||||
public interface ReceiverValue {
|
||||
ReceiverValue NO_RECEIVER = new ReceiverValue() {
|
||||
@NotNull
|
||||
@Override
|
||||
public JetType getType() {
|
||||
public KtType getType() {
|
||||
throw new UnsupportedOperationException("NO_RECEIVER.getType()");
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public interface ReceiverValue {
|
||||
ReceiverValue IRRELEVANT_RECEIVER = new ReceiverValue() {
|
||||
@NotNull
|
||||
@Override
|
||||
public JetType getType() {
|
||||
public KtType getType() {
|
||||
throw new UnsupportedOperationException("IRRELEVANT_RECEIVER.getType()");
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public interface ReceiverValue {
|
||||
};
|
||||
|
||||
@NotNull
|
||||
JetType getType();
|
||||
KtType 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.JetType;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
|
||||
/**
|
||||
* 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 JetType type) {
|
||||
public TransientReceiver(@NotNull KtType type) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user