rename Kt to Kotlin in KtType, KtIcons
This commit is contained in:
@@ -27,7 +27,7 @@ import org.jetbrains.kotlin.resolve.calls.context.CallResolutionContext
|
||||
import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
|
||||
import org.jetbrains.kotlin.types.upperIfFlexible
|
||||
@@ -36,20 +36,20 @@ public class RuntimeAssertionInfo(public val needNotNullAssertion: Boolean, publ
|
||||
public interface DataFlowExtras {
|
||||
class OnlyMessage(message: String) : DataFlowExtras {
|
||||
override val canBeNull: Boolean get() = true
|
||||
override val possibleTypes: Set<KtType> get() = setOf()
|
||||
override val possibleTypes: Set<KotlinType> get() = setOf()
|
||||
override val presentableText: String = message
|
||||
}
|
||||
|
||||
val canBeNull: Boolean
|
||||
val possibleTypes: Set<KtType>
|
||||
val possibleTypes: Set<KotlinType>
|
||||
val presentableText: String
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
public fun create(
|
||||
expectedType: KtType,
|
||||
expressionType: KtType,
|
||||
expectedType: KotlinType,
|
||||
expressionType: KotlinType,
|
||||
dataFlowExtras: DataFlowExtras
|
||||
): RuntimeAssertionInfo? {
|
||||
fun assertNotNull(): Boolean {
|
||||
@@ -78,13 +78,13 @@ public class RuntimeAssertionInfo(public val needNotNullAssertion: Boolean, publ
|
||||
null
|
||||
}
|
||||
|
||||
private fun KtType.hasEnhancedNullability()
|
||||
private fun KotlinType.hasEnhancedNullability()
|
||||
= getAnnotations().findAnnotation(JvmAnnotationNames.ENHANCED_NULLABILITY_ANNOTATION) != null
|
||||
}
|
||||
}
|
||||
|
||||
public object RuntimeAssertionsTypeChecker : AdditionalTypeChecker {
|
||||
override fun checkType(expression: KtExpression, expressionType: KtType, expressionTypeWithSmartCast: KtType, c: ResolutionContext<*>) {
|
||||
override fun checkType(expression: KtExpression, expressionType: KotlinType, expressionTypeWithSmartCast: KotlinType, c: ResolutionContext<*>) {
|
||||
if (TypeUtils.noExpectedType(c.expectedType)) return
|
||||
|
||||
val assertionInfo = RuntimeAssertionInfo.create(
|
||||
@@ -93,7 +93,7 @@ public object RuntimeAssertionsTypeChecker : AdditionalTypeChecker {
|
||||
object : RuntimeAssertionInfo.DataFlowExtras {
|
||||
override val canBeNull: Boolean
|
||||
get() = c.dataFlowInfo.getNullability(dataFlowValue).canBeNull()
|
||||
override val possibleTypes: Set<KtType>
|
||||
override val possibleTypes: Set<KotlinType>
|
||||
get() = c.dataFlowInfo.getPossibleTypes(dataFlowValue)
|
||||
override val presentableText: String
|
||||
get() = StringUtil.trimMiddle(expression.getText(), 50)
|
||||
|
||||
+6
-6
@@ -33,7 +33,7 @@ import org.jetbrains.kotlin.resolve.jvm.JavaDescriptorResolverKt;
|
||||
import org.jetbrains.kotlin.resolve.jvm.kotlinSignature.AlternativeFieldSignatureData;
|
||||
import org.jetbrains.kotlin.resolve.jvm.kotlinSignature.AlternativeMethodSignatureData;
|
||||
import org.jetbrains.kotlin.resolve.jvm.kotlinSignature.SignaturesPropagationData;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -55,8 +55,8 @@ public class TraceBasedExternalSignatureResolver implements ExternalSignatureRes
|
||||
public PropagatedMethodSignature resolvePropagatedSignature(
|
||||
@NotNull JavaMethod method,
|
||||
@NotNull ClassDescriptor owner,
|
||||
@NotNull KtType returnType,
|
||||
@Nullable KtType receiverType,
|
||||
@NotNull KotlinType returnType,
|
||||
@Nullable KotlinType receiverType,
|
||||
@NotNull List<ValueParameterDescriptor> valueParameters,
|
||||
@NotNull List<TypeParameterDescriptor> typeParameters
|
||||
) {
|
||||
@@ -72,8 +72,8 @@ public class TraceBasedExternalSignatureResolver implements ExternalSignatureRes
|
||||
public AlternativeMethodSignature resolveAlternativeMethodSignature(
|
||||
@NotNull JavaMember methodOrConstructor,
|
||||
boolean hasSuperMethods,
|
||||
@Nullable KtType returnType,
|
||||
@Nullable KtType receiverType,
|
||||
@Nullable KotlinType returnType,
|
||||
@Nullable KotlinType receiverType,
|
||||
@NotNull List<ValueParameterDescriptor> valueParameters,
|
||||
@NotNull List<TypeParameterDescriptor> typeParameters,
|
||||
boolean hasStableParameterNames
|
||||
@@ -102,7 +102,7 @@ public class TraceBasedExternalSignatureResolver implements ExternalSignatureRes
|
||||
@NotNull
|
||||
public AlternativeFieldSignature resolveAlternativeFieldSignature(
|
||||
@NotNull JavaField field,
|
||||
@NotNull KtType returnType,
|
||||
@NotNull KotlinType returnType,
|
||||
boolean isVar
|
||||
) {
|
||||
AlternativeFieldSignatureData data = new AlternativeFieldSignatureData(field, returnType, project, isVar);
|
||||
|
||||
+6
-6
@@ -21,7 +21,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl;
|
||||
import org.jetbrains.kotlin.resolve.ExternalOverridabilityCondition;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.TypeSubstitutor;
|
||||
import org.jetbrains.kotlin.types.TypeUtils;
|
||||
|
||||
@@ -57,7 +57,7 @@ public class SamAdapterOverridabilityCondition implements ExternalOverridability
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean differentClasses(@NotNull KtType type1, @NotNull KtType type2) {
|
||||
private static boolean differentClasses(@NotNull KotlinType type1, @NotNull KotlinType type2) {
|
||||
DeclarationDescriptor declarationDescriptor1 = type1.getConstructor().getDeclarationDescriptor();
|
||||
if (declarationDescriptor1 == null) return true; // No class, classes are not equal
|
||||
DeclarationDescriptor declarationDescriptor2 = type2.getConstructor().getDeclarationDescriptor();
|
||||
@@ -100,7 +100,7 @@ public class SamAdapterOverridabilityCondition implements ExternalOverridability
|
||||
@Nullable
|
||||
private static SamAdapterInfo getNearestDeclarationOrSynthesized(
|
||||
@NotNull SimpleFunctionDescriptor samAdapter,
|
||||
@NotNull KtType ownerType
|
||||
@NotNull KotlinType ownerType
|
||||
) {
|
||||
if (samAdapter.getKind() != CallableMemberDescriptor.Kind.FAKE_OVERRIDE) {
|
||||
return new SamAdapterInfo(samAdapter, ownerType);
|
||||
@@ -109,7 +109,7 @@ public class SamAdapterOverridabilityCondition implements ExternalOverridability
|
||||
for (CallableMemberDescriptor overridden : samAdapter.getOverriddenDescriptors()) {
|
||||
ClassDescriptor containingClass = (ClassDescriptor) overridden.getContainingDeclaration();
|
||||
|
||||
for (KtType immediateSupertype : TypeUtils.getImmediateSupertypes(ownerType)) {
|
||||
for (KotlinType immediateSupertype : TypeUtils.getImmediateSupertypes(ownerType)) {
|
||||
if (containingClass != immediateSupertype.getConstructor().getDeclarationDescriptor()) {
|
||||
continue;
|
||||
}
|
||||
@@ -126,9 +126,9 @@ public class SamAdapterOverridabilityCondition implements ExternalOverridability
|
||||
|
||||
private static class SamAdapterInfo {
|
||||
private final SimpleFunctionDescriptor samAdapter;
|
||||
private final KtType ownerType;
|
||||
private final KotlinType ownerType;
|
||||
|
||||
private SamAdapterInfo(@NotNull SimpleFunctionDescriptor samAdapter, @NotNull KtType ownerType) {
|
||||
private SamAdapterInfo(@NotNull SimpleFunctionDescriptor samAdapter, @NotNull KotlinType ownerType) {
|
||||
this.samAdapter = samAdapter;
|
||||
this.ownerType = ownerType;
|
||||
}
|
||||
|
||||
+3
-3
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.load.java.descriptors.*
|
||||
import org.jetbrains.kotlin.load.java.lazy.descriptors.LazyJavaClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaMethod
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.load.java.sources.JavaSourceElement
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaClass
|
||||
import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor
|
||||
@@ -51,7 +51,7 @@ public object SamConversionResolverImpl : SamConversionResolver {
|
||||
override fun resolveFunctionTypeIfSamInterface(
|
||||
classDescriptor: JavaClassDescriptor,
|
||||
resolveMethod: (JavaMethod) -> FunctionDescriptor
|
||||
): KtType? {
|
||||
): KotlinType? {
|
||||
val jClass = (classDescriptor.getSource() as? JavaSourceElement)?.javaElement as? JavaClass ?: return null
|
||||
val samInterfaceMethod = SingleAbstractMethodUtils.getSamInterfaceMethod(jClass) ?: return null
|
||||
val abstractMethod = if (jClass.getFqName() == samInterfaceMethod.getContainingClass().getFqName()) {
|
||||
@@ -63,7 +63,7 @@ public object SamConversionResolverImpl : SamConversionResolver {
|
||||
return SingleAbstractMethodUtils.getFunctionTypeForAbstractMethod(abstractMethod)
|
||||
}
|
||||
|
||||
private fun findFunctionWithMostSpecificReturnType(supertypes: Set<KtType>): SimpleFunctionDescriptor {
|
||||
private fun findFunctionWithMostSpecificReturnType(supertypes: Set<KotlinType>): SimpleFunctionDescriptor {
|
||||
val candidates = ArrayList<SimpleFunctionDescriptor>(supertypes.size())
|
||||
for (supertype in supertypes) {
|
||||
val abstractMembers = SingleAbstractMethodUtils.getAbstractMembers(supertype)
|
||||
|
||||
+25
-25
@@ -43,7 +43,7 @@ public class SingleAbstractMethodUtils {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static List<CallableMemberDescriptor> getAbstractMembers(@NotNull KtType type) {
|
||||
public static List<CallableMemberDescriptor> getAbstractMembers(@NotNull KotlinType type) {
|
||||
List<CallableMemberDescriptor> abstractMembers = new ArrayList<CallableMemberDescriptor>();
|
||||
for (DeclarationDescriptor member : type.getMemberScope().getAllDescriptors()) {
|
||||
if (member instanceof CallableMemberDescriptor && ((CallableMemberDescriptor) member).getModality() == Modality.ABSTRACT) {
|
||||
@@ -53,7 +53,7 @@ public class SingleAbstractMethodUtils {
|
||||
return abstractMembers;
|
||||
}
|
||||
|
||||
private static KtType fixProjections(@NotNull KtType functionType) {
|
||||
private static KotlinType fixProjections(@NotNull KotlinType functionType) {
|
||||
//removes redundant projection kinds and detects conflicts
|
||||
|
||||
List<TypeParameterDescriptor> typeParameters = functionType.getConstructor().getParameters();
|
||||
@@ -76,7 +76,7 @@ public class SingleAbstractMethodUtils {
|
||||
}
|
||||
ClassifierDescriptor classifier = functionType.getConstructor().getDeclarationDescriptor();
|
||||
assert classifier instanceof ClassDescriptor : "Not class: " + classifier;
|
||||
return KtTypeImpl.create(
|
||||
return KotlinTypeImpl.create(
|
||||
functionType.getAnnotations(),
|
||||
functionType.getConstructor(),
|
||||
functionType.isMarkedNullable(),
|
||||
@@ -86,21 +86,21 @@ public class SingleAbstractMethodUtils {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static KtType getFunctionTypeForSamType(@NotNull KtType samType) {
|
||||
public static KotlinType getFunctionTypeForSamType(@NotNull KotlinType samType) {
|
||||
// e.g. samType == Comparator<String>?
|
||||
|
||||
ClassifierDescriptor classifier = samType.getConstructor().getDeclarationDescriptor();
|
||||
if (classifier instanceof JavaClassDescriptor) {
|
||||
// Function2<T, T, Int>
|
||||
KtType functionTypeDefault = ((JavaClassDescriptor) classifier).getFunctionTypeForSamInterface();
|
||||
KotlinType functionTypeDefault = ((JavaClassDescriptor) classifier).getFunctionTypeForSamInterface();
|
||||
|
||||
if (functionTypeDefault != null) {
|
||||
// Function2<String, String, Int>?
|
||||
KtType substitute = TypeSubstitutor.create(samType).substitute(functionTypeDefault, Variance.INVARIANT);
|
||||
KotlinType substitute = TypeSubstitutor.create(samType).substitute(functionTypeDefault, Variance.INVARIANT);
|
||||
|
||||
if (substitute == null) return null;
|
||||
|
||||
KtType type = fixProjections(substitute);
|
||||
KotlinType type = fixProjections(substitute);
|
||||
if (type == null) return null;
|
||||
|
||||
if (JavaDescriptorResolverKt.getPLATFORM_TYPES() && FlexibleTypesKt.isNullabilityFlexible(samType)) {
|
||||
@@ -114,11 +114,11 @@ public class SingleAbstractMethodUtils {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static KtType getFunctionTypeForAbstractMethod(@NotNull FunctionDescriptor function) {
|
||||
KtType returnType = function.getReturnType();
|
||||
public static KotlinType getFunctionTypeForAbstractMethod(@NotNull FunctionDescriptor function) {
|
||||
KotlinType returnType = function.getReturnType();
|
||||
assert returnType != null : "function is not initialized: " + function;
|
||||
List<ValueParameterDescriptor> valueParameters = function.getValueParameters();
|
||||
List<KtType> parameterTypes = new ArrayList<KtType>(valueParameters.size());
|
||||
List<KotlinType> parameterTypes = new ArrayList<KotlinType>(valueParameters.size());
|
||||
for (ValueParameterDescriptor parameter : valueParameters) {
|
||||
parameterTypes.add(parameter.getType());
|
||||
}
|
||||
@@ -151,9 +151,9 @@ public class SingleAbstractMethodUtils {
|
||||
|
||||
TypeParameters typeParameters = recreateAndInitializeTypeParameters(samInterface.getTypeConstructor().getParameters(), result);
|
||||
|
||||
KtType parameterTypeUnsubstituted = getFunctionTypeForSamType(samInterface.getDefaultType());
|
||||
KotlinType parameterTypeUnsubstituted = getFunctionTypeForSamType(samInterface.getDefaultType());
|
||||
assert parameterTypeUnsubstituted != null : "couldn't get function type for SAM type " + samInterface.getDefaultType();
|
||||
KtType parameterType = typeParameters.substitutor.substitute(parameterTypeUnsubstituted, Variance.IN_VARIANCE);
|
||||
KotlinType parameterType = typeParameters.substitutor.substitute(parameterTypeUnsubstituted, Variance.IN_VARIANCE);
|
||||
assert parameterType != null : "couldn't substitute type: " + parameterTypeUnsubstituted +
|
||||
", substitutor = " + typeParameters.substitutor;
|
||||
ValueParameterDescriptor parameter = new ValueParameterDescriptorImpl(
|
||||
@@ -163,7 +163,7 @@ public class SingleAbstractMethodUtils {
|
||||
/* isNoinline = */ false,
|
||||
null, SourceElement.NO_SOURCE);
|
||||
|
||||
KtType returnType = typeParameters.substitutor.substitute(samInterface.getDefaultType(), Variance.OUT_VARIANCE);
|
||||
KotlinType returnType = typeParameters.substitutor.substitute(samInterface.getDefaultType(), Variance.OUT_VARIANCE);
|
||||
assert returnType != null : "couldn't substitute type: " + samInterface.getDefaultType() +
|
||||
", substitutor = " + typeParameters.substitutor;
|
||||
|
||||
@@ -180,7 +180,7 @@ public class SingleAbstractMethodUtils {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static boolean isSamType(@NotNull KtType type) {
|
||||
public static boolean isSamType(@NotNull KotlinType type) {
|
||||
return getFunctionTypeForSamType(type) != null;
|
||||
}
|
||||
|
||||
@@ -201,7 +201,7 @@ public class SingleAbstractMethodUtils {
|
||||
public void initialize(
|
||||
@NotNull List<TypeParameterDescriptor> typeParameters,
|
||||
@NotNull List<ValueParameterDescriptor> valueParameters,
|
||||
@NotNull KtType returnType
|
||||
@NotNull KotlinType returnType
|
||||
) {
|
||||
result.initialize(
|
||||
null,
|
||||
@@ -224,7 +224,7 @@ public class SingleAbstractMethodUtils {
|
||||
public void initialize(
|
||||
@NotNull List<TypeParameterDescriptor> typeParameters,
|
||||
@NotNull List<ValueParameterDescriptor> valueParameters,
|
||||
@NotNull KtType returnType
|
||||
@NotNull KotlinType returnType
|
||||
) {
|
||||
result.initialize(typeParameters, valueParameters, original.getVisibility());
|
||||
result.setReturnType(returnType);
|
||||
@@ -240,11 +240,11 @@ public class SingleAbstractMethodUtils {
|
||||
) {
|
||||
TypeParameters typeParameters = recreateAndInitializeTypeParameters(original.getTypeParameters(), adapter);
|
||||
|
||||
KtType returnTypeUnsubstituted = original.getReturnType();
|
||||
KotlinType returnTypeUnsubstituted = original.getReturnType();
|
||||
assert returnTypeUnsubstituted != null : "Creating SAM adapter for not initialized original: " + original;
|
||||
|
||||
TypeSubstitutor substitutor = typeParameters.substitutor;
|
||||
KtType returnType = substitutor.substitute(returnTypeUnsubstituted, Variance.INVARIANT);
|
||||
KotlinType returnType = substitutor.substitute(returnTypeUnsubstituted, Variance.INVARIANT);
|
||||
assert returnType != null : "couldn't substitute type: " + returnTypeUnsubstituted +
|
||||
", substitutor = " + substitutor;
|
||||
|
||||
@@ -264,10 +264,10 @@ public class SingleAbstractMethodUtils {
|
||||
List<ValueParameterDescriptor> originalValueParameters = original.getValueParameters();
|
||||
List<ValueParameterDescriptor> valueParameters = new ArrayList<ValueParameterDescriptor>(originalValueParameters.size());
|
||||
for (ValueParameterDescriptor originalParam : originalValueParameters) {
|
||||
KtType originalType = originalParam.getType();
|
||||
KtType functionType = getFunctionTypeForSamType(originalType);
|
||||
KtType newTypeUnsubstituted = functionType != null ? functionType : originalType;
|
||||
KtType newType = substitutor.substitute(newTypeUnsubstituted, Variance.IN_VARIANCE);
|
||||
KotlinType originalType = originalParam.getType();
|
||||
KotlinType functionType = getFunctionTypeForSamType(originalType);
|
||||
KotlinType newTypeUnsubstituted = functionType != null ? functionType : originalType;
|
||||
KotlinType newType = substitutor.substitute(newTypeUnsubstituted, Variance.IN_VARIANCE);
|
||||
assert newType != null : "couldn't substitute type: " + newTypeUnsubstituted + ", substitutor = " + substitutor;
|
||||
|
||||
ValueParameterDescriptor newParam = new ValueParameterDescriptorImpl(
|
||||
@@ -295,8 +295,8 @@ public class SingleAbstractMethodUtils {
|
||||
TypeParameterDescriptor traitTypeParameter = mapEntry.getKey();
|
||||
TypeParameterDescriptorImpl funTypeParameter = mapEntry.getValue();
|
||||
|
||||
for (KtType upperBound : traitTypeParameter.getUpperBounds()) {
|
||||
KtType upperBoundSubstituted = typeParametersSubstitutor.substitute(upperBound, Variance.INVARIANT);
|
||||
for (KotlinType upperBound : traitTypeParameter.getUpperBounds()) {
|
||||
KotlinType upperBoundSubstituted = typeParametersSubstitutor.substitute(upperBound, Variance.INVARIANT);
|
||||
assert upperBoundSubstituted != null : "couldn't substitute type: " + upperBound + ", substitutor = " + typeParametersSubstitutor;
|
||||
funTypeParameter.addUpperBound(upperBoundSubstituted);
|
||||
}
|
||||
@@ -345,7 +345,7 @@ public class SingleAbstractMethodUtils {
|
||||
public abstract void initialize(
|
||||
@NotNull List<TypeParameterDescriptor> typeParameters,
|
||||
@NotNull List<ValueParameterDescriptor> valueParameters,
|
||||
@NotNull KtType returnType
|
||||
@NotNull KotlinType returnType
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ import org.jetbrains.kotlin.resolve.calls.model.ExpressionValueArgument
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedValueArgument
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
import java.lang.annotation.Target
|
||||
|
||||
|
||||
+2
-2
@@ -25,7 +25,7 @@ import org.jetbrains.kotlin.resolve.calls.checkers.CallChecker
|
||||
import org.jetbrains.kotlin.resolve.calls.context.BasicCallResolutionContext
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm
|
||||
import org.jetbrains.kotlin.types.KtTypeImpl
|
||||
import org.jetbrains.kotlin.types.KotlinTypeImpl
|
||||
import org.jetbrains.kotlin.types.TypeProjectionImpl
|
||||
|
||||
public class JavaClassOnCompanionChecker : CallChecker {
|
||||
@@ -42,7 +42,7 @@ public class JavaClassOnCompanionChecker : CallChecker {
|
||||
if (companionObject.isCompanionObject) {
|
||||
val containingClass = companionObject.containingDeclaration as ClassDescriptor
|
||||
val javaLangClass = actualType.constructor.declarationDescriptor as? ClassDescriptor ?: return
|
||||
val expectedType = KtTypeImpl.create(
|
||||
val expectedType = KotlinTypeImpl.create(
|
||||
Annotations.EMPTY, javaLangClass, actualType.isMarkedNullable,
|
||||
listOf(TypeProjectionImpl(containingClass.defaultType))
|
||||
)
|
||||
|
||||
+6
-6
@@ -36,14 +36,14 @@ import org.jetbrains.kotlin.resolve.calls.smartcasts.Nullability
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
import org.jetbrains.kotlin.types.expressions.SenselessComparisonChecker
|
||||
import org.jetbrains.kotlin.types.flexibility
|
||||
import org.jetbrains.kotlin.types.isFlexible
|
||||
|
||||
public class JavaNullabilityWarningsChecker : AdditionalTypeChecker {
|
||||
private fun KtType.mayBeNull(): ErrorsJvm.NullabilityInformationSource? {
|
||||
private fun KotlinType.mayBeNull(): ErrorsJvm.NullabilityInformationSource? {
|
||||
if (!isError() && !isFlexible() && TypeUtils.isNullableType(this)) return ErrorsJvm.NullabilityInformationSource.KOTLIN
|
||||
|
||||
if (isFlexible() && TypeUtils.isNullableType(flexibility().lowerBound)) return ErrorsJvm.NullabilityInformationSource.KOTLIN
|
||||
@@ -52,7 +52,7 @@ public class JavaNullabilityWarningsChecker : AdditionalTypeChecker {
|
||||
return null
|
||||
}
|
||||
|
||||
private fun KtType.mustNotBeNull(): ErrorsJvm.NullabilityInformationSource? {
|
||||
private fun KotlinType.mustNotBeNull(): ErrorsJvm.NullabilityInformationSource? {
|
||||
if (!isError() && !isFlexible() && !TypeUtils.isNullableType(this)) return ErrorsJvm.NullabilityInformationSource.KOTLIN
|
||||
|
||||
if (isFlexible() && !TypeUtils.isNullableType(flexibility().upperBound)) return ErrorsJvm.NullabilityInformationSource.KOTLIN
|
||||
@@ -62,8 +62,8 @@ public class JavaNullabilityWarningsChecker : AdditionalTypeChecker {
|
||||
}
|
||||
|
||||
private fun doCheckType(
|
||||
expressionType: KtType,
|
||||
expectedType: KtType,
|
||||
expressionType: KotlinType,
|
||||
expectedType: KotlinType,
|
||||
dataFlowValue: DataFlowValue,
|
||||
dataFlowInfo: DataFlowInfo,
|
||||
reportWarning: (expectedMustNotBeNull: ErrorsJvm.NullabilityInformationSource, actualMayBeNull: ErrorsJvm.NullabilityInformationSource) -> Unit
|
||||
@@ -85,7 +85,7 @@ public class JavaNullabilityWarningsChecker : AdditionalTypeChecker {
|
||||
}
|
||||
}
|
||||
|
||||
override fun checkType(expression: KtExpression, expressionType: KtType, expressionTypeWithSmartCast: KtType, c: ResolutionContext<*>) {
|
||||
override fun checkType(expression: KtExpression, expressionType: KotlinType, expressionTypeWithSmartCast: KotlinType, c: ResolutionContext<*>) {
|
||||
doCheckType(
|
||||
expressionType,
|
||||
c.expectedType,
|
||||
|
||||
+2
-2
@@ -30,12 +30,12 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.classId
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.getAnnotationRetention
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.isRepeatableAnnotation
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
|
||||
public object RepeatableAnnotationChecker: AdditionalAnnotationChecker {
|
||||
override fun checkEntries(entries: List<KtAnnotationEntry>, actualTargets: List<KotlinTarget>, trace: BindingTrace) {
|
||||
val entryTypesWithAnnotations = hashMapOf<KtType, MutableList<AnnotationUseSiteTarget?>>()
|
||||
val entryTypesWithAnnotations = hashMapOf<KotlinType, MutableList<AnnotationUseSiteTarget?>>()
|
||||
|
||||
for (entry in entries) {
|
||||
val descriptor = trace.get(BindingContext.ANNOTATION, entry) ?: continue
|
||||
|
||||
+3
-3
@@ -27,7 +27,7 @@ import org.jetbrains.kotlin.psi.KtAnnotationEntry;
|
||||
import org.jetbrains.kotlin.psi.KtDeclaration;
|
||||
import org.jetbrains.kotlin.psi.KtElement;
|
||||
import org.jetbrains.kotlin.psi.KtExpression;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
import static org.jetbrains.kotlin.diagnostics.PositioningStrategies.*;
|
||||
import static org.jetbrains.kotlin.diagnostics.Severity.ERROR;
|
||||
@@ -74,8 +74,8 @@ public interface ErrorsJvm {
|
||||
|
||||
DiagnosticFactory0<KtElement> NO_REFLECTION_IN_CLASS_PATH = DiagnosticFactory0.create(WARNING);
|
||||
|
||||
DiagnosticFactory2<KtElement, KtType, KtType> JAVA_CLASS_ON_COMPANION = DiagnosticFactory2.create(WARNING);
|
||||
DiagnosticFactory2<KtExpression, KtType, KtType> JAVA_TYPE_MISMATCH = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory2<KtElement, KotlinType, KotlinType> JAVA_CLASS_ON_COMPANION = DiagnosticFactory2.create(WARNING);
|
||||
DiagnosticFactory2<KtExpression, KotlinType, KotlinType> JAVA_TYPE_MISMATCH = DiagnosticFactory2.create(ERROR);
|
||||
|
||||
DiagnosticFactory2<PsiElement, String, String> DUPLICATE_CLASS_NAMES = DiagnosticFactory2.create(ERROR);
|
||||
|
||||
|
||||
+4
-4
@@ -24,16 +24,16 @@ import org.jetbrains.kotlin.descriptors.impl.TypeParameterDescriptorImpl;
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaField;
|
||||
import org.jetbrains.kotlin.psi.KtProperty;
|
||||
import org.jetbrains.kotlin.psi.KtPsiFactoryKt;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class AlternativeFieldSignatureData extends ElementAlternativeSignatureData {
|
||||
private KtType altReturnType;
|
||||
private KotlinType altReturnType;
|
||||
|
||||
public AlternativeFieldSignatureData(
|
||||
@NotNull JavaField field,
|
||||
@NotNull KtType originalReturnType,
|
||||
@NotNull KotlinType originalReturnType,
|
||||
@NotNull Project project,
|
||||
boolean isVar
|
||||
) {
|
||||
@@ -59,7 +59,7 @@ public class AlternativeFieldSignatureData extends ElementAlternativeSignatureDa
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public KtType getReturnType() {
|
||||
public KotlinType getReturnType() {
|
||||
checkForErrors();
|
||||
return altReturnType;
|
||||
}
|
||||
|
||||
+14
-14
@@ -32,7 +32,7 @@ import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.psi.*;
|
||||
import org.jetbrains.kotlin.resolve.jvm.JavaDescriptorResolverKt;
|
||||
import org.jetbrains.kotlin.resolve.jvm.JavaResolverUtils;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.TypeSubstitutor;
|
||||
import org.jetbrains.kotlin.types.TypeUtils;
|
||||
import org.jetbrains.kotlin.types.Variance;
|
||||
@@ -52,17 +52,17 @@ public class AlternativeMethodSignatureData extends ElementAlternativeSignatureD
|
||||
private final KtNamedFunction altFunDeclaration;
|
||||
|
||||
private List<ValueParameterDescriptor> altValueParameters;
|
||||
private KtType altReturnType;
|
||||
private KotlinType altReturnType;
|
||||
private List<TypeParameterDescriptor> altTypeParameters;
|
||||
|
||||
private Map<TypeParameterDescriptor, TypeParameterDescriptorImpl> originalToAltTypeParameters;
|
||||
|
||||
public AlternativeMethodSignatureData(
|
||||
@NotNull JavaMember methodOrConstructor,
|
||||
@Nullable KtType receiverType,
|
||||
@Nullable KotlinType receiverType,
|
||||
@NotNull Project project,
|
||||
@NotNull List<ValueParameterDescriptor> valueParameters,
|
||||
@Nullable KtType originalReturnType,
|
||||
@Nullable KotlinType originalReturnType,
|
||||
@NotNull List<TypeParameterDescriptor> methodTypeParameters,
|
||||
boolean hasSuperMethods
|
||||
) {
|
||||
@@ -119,7 +119,7 @@ public class AlternativeMethodSignatureData extends ElementAlternativeSignatureD
|
||||
private void checkParameterAndReturnTypesForOverridingMethods(
|
||||
@NotNull List<ValueParameterDescriptor> valueParameters,
|
||||
@NotNull List<TypeParameterDescriptor> methodTypeParameters,
|
||||
@Nullable KtType returnType
|
||||
@Nullable KotlinType returnType
|
||||
) {
|
||||
if (JavaDescriptorResolverKt.getPLATFORM_TYPES()) return;
|
||||
TypeSubstitutor substitutor = JavaResolverUtils.createSubstitutorForTypeParameters(originalToAltTypeParameters);
|
||||
@@ -128,7 +128,7 @@ public class AlternativeMethodSignatureData extends ElementAlternativeSignatureD
|
||||
int index = parameter.getIndex();
|
||||
ValueParameterDescriptor altParameter = altValueParameters.get(index);
|
||||
|
||||
KtType substituted = substitutor.substitute(parameter.getType(), Variance.INVARIANT);
|
||||
KotlinType substituted = substitutor.substitute(parameter.getType(), Variance.INVARIANT);
|
||||
assert substituted != null;
|
||||
|
||||
if (!TypeUtils.equalTypes(substituted, altParameter.getType())) {
|
||||
@@ -143,7 +143,7 @@ public class AlternativeMethodSignatureData extends ElementAlternativeSignatureD
|
||||
for (TypeParameterDescriptor parameter : methodTypeParameters) {
|
||||
int index = parameter.getIndex();
|
||||
|
||||
KtType substituted = substitutor.substitute(parameter.getUpperBoundsAsType(), Variance.INVARIANT);
|
||||
KotlinType substituted = substitutor.substitute(parameter.getUpperBoundsAsType(), Variance.INVARIANT);
|
||||
assert substituted != null;
|
||||
|
||||
if (!TypeUtils.equalTypes(substituted, altTypeParameters.get(index).getUpperBoundsAsType())) {
|
||||
@@ -154,7 +154,7 @@ public class AlternativeMethodSignatureData extends ElementAlternativeSignatureD
|
||||
}
|
||||
|
||||
if (returnType != null) {
|
||||
KtType substitutedReturnType = substitutor.substitute(returnType, Variance.INVARIANT);
|
||||
KotlinType substitutedReturnType = substitutor.substitute(returnType, Variance.INVARIANT);
|
||||
assert substitutedReturnType != null;
|
||||
|
||||
if (!KotlinTypeChecker.DEFAULT.isSubtypeOf(altReturnType, substitutedReturnType)) {
|
||||
@@ -171,7 +171,7 @@ public class AlternativeMethodSignatureData extends ElementAlternativeSignatureD
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public KtType getReturnType() {
|
||||
public KotlinType getReturnType() {
|
||||
checkForErrors();
|
||||
return altReturnType;
|
||||
}
|
||||
@@ -197,10 +197,10 @@ public class AlternativeMethodSignatureData extends ElementAlternativeSignatureD
|
||||
KtTypeElement alternativeTypeElement = annotationValueParameter.getTypeReference().getTypeElement();
|
||||
assert alternativeTypeElement != null;
|
||||
|
||||
KtType alternativeType;
|
||||
KtType alternativeVarargElementType;
|
||||
KotlinType alternativeType;
|
||||
KotlinType alternativeVarargElementType;
|
||||
|
||||
KtType originalParamVarargElementType = originalParameterDescriptor.getVarargElementType();
|
||||
KotlinType originalParamVarargElementType = originalParameterDescriptor.getVarargElementType();
|
||||
if (originalParamVarargElementType == null) {
|
||||
if (annotationValueParameter.isVarArg()) {
|
||||
throw new AlternativeSignatureMismatchException("Parameter in method signature is not vararg, but in alternative signature it is vararg");
|
||||
@@ -253,7 +253,7 @@ public class AlternativeMethodSignatureData extends ElementAlternativeSignatureD
|
||||
TypeParameterDescriptorImpl altParamDescriptor = originalToAltTypeParameters.get(originalTypeParamDescriptor);
|
||||
KtTypeParameter altTypeParameter = altFunDeclaration.getTypeParameters().get(i);
|
||||
|
||||
Set<KtType> originalUpperBounds = originalTypeParamDescriptor.getUpperBounds();
|
||||
Set<KotlinType> originalUpperBounds = originalTypeParamDescriptor.getUpperBounds();
|
||||
List<KtTypeReference> altUpperBounds = getUpperBounds(altFunDeclaration, altTypeParameter);
|
||||
if (altUpperBounds.size() != originalUpperBounds.size()) {
|
||||
if (altUpperBounds.isEmpty()
|
||||
@@ -274,7 +274,7 @@ public class AlternativeMethodSignatureData extends ElementAlternativeSignatureD
|
||||
}
|
||||
else {
|
||||
int upperBoundIndex = 0;
|
||||
for (KtType upperBound : originalUpperBounds) {
|
||||
for (KotlinType upperBound : originalUpperBounds) {
|
||||
|
||||
KtTypeElement altTypeElement = altUpperBounds.get(upperBoundIndex).getTypeElement();
|
||||
assert altTypeElement != null;
|
||||
|
||||
+3
-3
@@ -27,7 +27,7 @@ import org.jetbrains.kotlin.psi.KtTypeElement;
|
||||
import org.jetbrains.kotlin.psi.KtTypeReference;
|
||||
import org.jetbrains.kotlin.renderer.DescriptorRenderer;
|
||||
import org.jetbrains.kotlin.resolve.AnalyzingUtils;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -86,8 +86,8 @@ public abstract class ElementAlternativeSignatureData {
|
||||
}
|
||||
}
|
||||
|
||||
protected static KtType computeReturnType(
|
||||
@NotNull KtType originalType,
|
||||
protected static KotlinType computeReturnType(
|
||||
@NotNull KotlinType originalType,
|
||||
@Nullable KtTypeReference altReturnTypeReference,
|
||||
@NotNull Map<TypeParameterDescriptor, TypeParameterDescriptorImpl> originalToAltTypeParameters) {
|
||||
if (altReturnTypeReference == null) {
|
||||
|
||||
+7
-7
@@ -25,8 +25,8 @@ import org.jetbrains.kotlin.descriptors.ClassifierDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor;
|
||||
import org.jetbrains.kotlin.renderer.DescriptorRenderer;
|
||||
import org.jetbrains.kotlin.resolve.scopes.KtScope;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KtTypeImpl;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.KotlinTypeImpl;
|
||||
import org.jetbrains.kotlin.types.TypeProjectionImpl;
|
||||
import org.jetbrains.kotlin.types.Variance;
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
|
||||
@@ -41,7 +41,7 @@ class PropagationHeuristics {
|
||||
// Checks for case when method returning Super[] is overridden with method returning Sub[]
|
||||
static void checkArrayInReturnType(
|
||||
@NotNull SignaturesPropagationData data,
|
||||
@NotNull KtType type,
|
||||
@NotNull KotlinType type,
|
||||
@NotNull List<SignaturesPropagationData.TypeAndVariance> typesFromSuper
|
||||
) {
|
||||
List<SignaturesPropagationData.TypeAndVariance> arrayTypesFromSuper = ContainerUtil
|
||||
@@ -55,14 +55,14 @@ class PropagationHeuristics {
|
||||
assert type.getArguments().size() == 1;
|
||||
if (type.getArguments().get(0).getProjectionKind() == Variance.INVARIANT) {
|
||||
for (SignaturesPropagationData.TypeAndVariance typeAndVariance : arrayTypesFromSuper) {
|
||||
KtType arrayTypeFromSuper = typeAndVariance.type;
|
||||
KotlinType arrayTypeFromSuper = typeAndVariance.type;
|
||||
assert arrayTypeFromSuper.getArguments().size() == 1;
|
||||
KtType elementTypeInSuper = arrayTypeFromSuper.getArguments().get(0).getType();
|
||||
KtType elementType = type.getArguments().get(0).getType();
|
||||
KotlinType elementTypeInSuper = arrayTypeFromSuper.getArguments().get(0).getType();
|
||||
KotlinType elementType = type.getArguments().get(0).getType();
|
||||
|
||||
if (KotlinTypeChecker.DEFAULT.isSubtypeOf(elementType, elementTypeInSuper)
|
||||
&& !KotlinTypeChecker.DEFAULT.equalTypes(elementType, elementTypeInSuper)) {
|
||||
KtTypeImpl betterTypeInSuper = KtTypeImpl.create(
|
||||
KotlinTypeImpl betterTypeInSuper = KotlinTypeImpl.create(
|
||||
arrayTypeFromSuper.getAnnotations(),
|
||||
arrayTypeFromSuper.getConstructor(),
|
||||
arrayTypeFromSuper.isMarkedNullable(),
|
||||
|
||||
+43
-43
@@ -66,7 +66,7 @@ public class SignaturesPropagationData {
|
||||
private final List<TypeParameterDescriptor> modifiedTypeParameters;
|
||||
private final ValueParameters modifiedValueParameters;
|
||||
|
||||
private final KtType modifiedReturnType;
|
||||
private final KotlinType modifiedReturnType;
|
||||
private final List<String> signatureErrors = Lists.newArrayList();
|
||||
private final List<FunctionDescriptor> superFunctions;
|
||||
private final Map<TypeParameterDescriptor, TypeParameterDescriptorImpl> autoTypeParameterToModified;
|
||||
@@ -74,8 +74,8 @@ public class SignaturesPropagationData {
|
||||
|
||||
public SignaturesPropagationData(
|
||||
@NotNull ClassDescriptor containingClass,
|
||||
@NotNull KtType autoReturnType, // type built by JavaTypeTransformer from Java signature and @NotNull annotations
|
||||
@Nullable KtType receiverType,
|
||||
@NotNull KotlinType autoReturnType, // type built by JavaTypeTransformer from Java signature and @NotNull annotations
|
||||
@Nullable KotlinType receiverType,
|
||||
@NotNull List<ValueParameterDescriptor> autoValueParameters, // descriptors built by parameters resolver
|
||||
@NotNull List<TypeParameterDescriptor> autoTypeParameters, // descriptors built by signature resolver
|
||||
@NotNull JavaMethod method
|
||||
@@ -97,8 +97,8 @@ public class SignaturesPropagationData {
|
||||
@NotNull
|
||||
private static JavaMethodDescriptor createAutoMethodDescriptor(
|
||||
@NotNull ClassDescriptor containingClass,
|
||||
@NotNull JavaMethod method, KtType autoReturnType,
|
||||
@Nullable KtType receiverType,
|
||||
@NotNull JavaMethod method, KotlinType autoReturnType,
|
||||
@Nullable KotlinType receiverType,
|
||||
@NotNull List<ValueParameterDescriptor> autoValueParameters,
|
||||
@NotNull List<TypeParameterDescriptor> autoTypeParameters
|
||||
) {
|
||||
@@ -125,7 +125,7 @@ public class SignaturesPropagationData {
|
||||
return modifiedTypeParameters;
|
||||
}
|
||||
|
||||
public KtType getModifiedReceiverType() {
|
||||
public KotlinType getModifiedReceiverType() {
|
||||
return modifiedValueParameters.receiverType;
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ public class SignaturesPropagationData {
|
||||
return modifiedValueParameters.hasStableParameterNames;
|
||||
}
|
||||
|
||||
public KtType getModifiedReturnType() {
|
||||
public KotlinType getModifiedReturnType() {
|
||||
return modifiedReturnType;
|
||||
}
|
||||
|
||||
@@ -153,8 +153,8 @@ public class SignaturesPropagationData {
|
||||
signatureErrors.add(error);
|
||||
}
|
||||
|
||||
private KtType modifyReturnTypeAccordingToSuperMethods(
|
||||
@NotNull KtType autoType // type built by JavaTypeTransformer
|
||||
private KotlinType modifyReturnTypeAccordingToSuperMethods(
|
||||
@NotNull KotlinType autoType // type built by JavaTypeTransformer
|
||||
) {
|
||||
if (JavaDescriptorResolverKt.getPLATFORM_TYPES()) return autoType;
|
||||
|
||||
@@ -179,24 +179,24 @@ public class SignaturesPropagationData {
|
||||
int index = autoParameter.getIndex();
|
||||
TypeParameterDescriptorImpl modifiedTypeParameter = autoTypeParameterToModified.get(autoParameter);
|
||||
|
||||
List<Iterator<KtType>> upperBoundFromSuperFunctionsIterators = Lists.newArrayList();
|
||||
List<Iterator<KotlinType>> upperBoundFromSuperFunctionsIterators = Lists.newArrayList();
|
||||
for (FunctionDescriptor superFunction : superFunctions) {
|
||||
upperBoundFromSuperFunctionsIterators.add(superFunction.getTypeParameters().get(index).getUpperBounds().iterator());
|
||||
}
|
||||
|
||||
for (KtType autoUpperBound : autoParameter.getUpperBounds()) {
|
||||
for (KotlinType autoUpperBound : autoParameter.getUpperBounds()) {
|
||||
List<TypeAndVariance> upperBoundsFromSuperFunctions = Lists.newArrayList();
|
||||
|
||||
for (Iterator<KtType> iterator : upperBoundFromSuperFunctionsIterators) {
|
||||
for (Iterator<KotlinType> iterator : upperBoundFromSuperFunctionsIterators) {
|
||||
assert iterator.hasNext();
|
||||
upperBoundsFromSuperFunctions.add(new TypeAndVariance(iterator.next(), INVARIANT));
|
||||
}
|
||||
|
||||
KtType modifiedUpperBound = modifyTypeAccordingToSuperMethods(autoUpperBound, upperBoundsFromSuperFunctions, UPPER_BOUND);
|
||||
KotlinType modifiedUpperBound = modifyTypeAccordingToSuperMethods(autoUpperBound, upperBoundsFromSuperFunctions, UPPER_BOUND);
|
||||
modifiedTypeParameter.addUpperBound(modifiedUpperBound);
|
||||
}
|
||||
|
||||
for (Iterator<KtType> iterator : upperBoundFromSuperFunctionsIterators) {
|
||||
for (Iterator<KotlinType> iterator : upperBoundFromSuperFunctionsIterators) {
|
||||
assert !iterator.hasNext();
|
||||
}
|
||||
|
||||
@@ -208,14 +208,14 @@ public class SignaturesPropagationData {
|
||||
}
|
||||
|
||||
private ValueParameters modifyValueParametersAccordingToSuperMethods(
|
||||
@Nullable KtType receiverType,
|
||||
@Nullable KotlinType receiverType,
|
||||
@NotNull List<ValueParameterDescriptor> parameters // descriptors built by parameters resolver
|
||||
) {
|
||||
assert receiverType == null : "Parameters before propagation have receiver type," +
|
||||
" but propagation should be disabled for functions compiled from Kotlin in class: " +
|
||||
DescriptorUtils.getFqName(containingClass);
|
||||
|
||||
KtType resultReceiverType = null;
|
||||
KotlinType resultReceiverType = null;
|
||||
List<ValueParameterDescriptor> resultParameters = new ArrayList<ValueParameterDescriptor>(parameters.size());
|
||||
|
||||
boolean shouldBeExtension = checkIfShouldBeExtension();
|
||||
@@ -239,9 +239,9 @@ public class SignaturesPropagationData {
|
||||
|
||||
VarargCheckResult varargCheckResult = checkVarargInSuperFunctions(originalParam);
|
||||
|
||||
KtType altType = modifyTypeAccordingToSuperMethods(varargCheckResult.parameterType,
|
||||
convertToTypeVarianceList(typesFromSuperMethods),
|
||||
MEMBER_SIGNATURE_CONTRAVARIANT);
|
||||
KotlinType altType = modifyTypeAccordingToSuperMethods(varargCheckResult.parameterType,
|
||||
convertToTypeVarianceList(typesFromSuperMethods),
|
||||
MEMBER_SIGNATURE_CONTRAVARIANT);
|
||||
|
||||
if (shouldBeExtension && originalIndex == 0) {
|
||||
resultReceiverType = altType;
|
||||
@@ -304,7 +304,7 @@ public class SignaturesPropagationData {
|
||||
// TODO: Add propagation for other kotlin descriptors (KT-3621)
|
||||
Name name = method.getName();
|
||||
JvmMethodSignature autoSignature = SIGNATURE_MAPPER.mapToJvmMethodSignature(autoMethodDescriptor);
|
||||
for (KtType supertype : containingClass.getTypeConstructor().getSupertypes()) {
|
||||
for (KotlinType supertype : containingClass.getTypeConstructor().getSupertypes()) {
|
||||
Collection<FunctionDescriptor> superFunctionCandidates = supertype.getMemberScope().getFunctions(name, NoLookupLocation.WHEN_GET_SUPER_MEMBERS);
|
||||
for (FunctionDescriptor candidate : superFunctionCandidates) {
|
||||
JvmMethodSignature candidateSignature = SIGNATURE_MAPPER.mapToJvmMethodSignature(candidate);
|
||||
@@ -365,8 +365,8 @@ public class SignaturesPropagationData {
|
||||
}
|
||||
}
|
||||
|
||||
KtType originalVarargElementType = originalParam.getVarargElementType();
|
||||
KtType originalType = originalParam.getType();
|
||||
KotlinType originalVarargElementType = originalParam.getVarargElementType();
|
||||
KotlinType originalType = originalParam.getType();
|
||||
|
||||
if (someSupersVararg && someSupersNotVararg) {
|
||||
reportError("Incompatible super methods: some have vararg parameter, some have not");
|
||||
@@ -389,8 +389,8 @@ public class SignaturesPropagationData {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private KtType modifyTypeAccordingToSuperMethods(
|
||||
@NotNull KtType autoType,
|
||||
private KotlinType modifyTypeAccordingToSuperMethods(
|
||||
@NotNull KotlinType autoType,
|
||||
@NotNull List<TypeAndVariance> typesFromSuper,
|
||||
@NotNull TypeUsage howThisTypeIsUsed
|
||||
) {
|
||||
@@ -409,11 +409,11 @@ public class SignaturesPropagationData {
|
||||
resultScope = autoType.getMemberScope();
|
||||
}
|
||||
|
||||
KtType type = KtTypeImpl.create(autoType.getAnnotations(),
|
||||
resultClassifier.getTypeConstructor(),
|
||||
resultNullable,
|
||||
resultArguments,
|
||||
resultScope);
|
||||
KotlinType type = KotlinTypeImpl.create(autoType.getAnnotations(),
|
||||
resultClassifier.getTypeConstructor(),
|
||||
resultNullable,
|
||||
resultArguments,
|
||||
resultScope);
|
||||
|
||||
PropagationHeuristics.checkArrayInReturnType(this, type, typesFromSuper);
|
||||
return type;
|
||||
@@ -421,7 +421,7 @@ public class SignaturesPropagationData {
|
||||
|
||||
@NotNull
|
||||
private List<TypeProjection> getTypeArgsOfType(
|
||||
@NotNull KtType autoType,
|
||||
@NotNull KotlinType autoType,
|
||||
@NotNull ClassifierDescriptor classifier,
|
||||
@NotNull List<TypeAndVariance> typesFromSuper
|
||||
) {
|
||||
@@ -444,11 +444,11 @@ public class SignaturesPropagationData {
|
||||
for (TypeParameterDescriptor parameter : classifier.getTypeConstructor().getParameters()) {
|
||||
TypeProjection argument = autoArguments.get(parameter.getIndex());
|
||||
|
||||
KtType argumentType = argument.getType();
|
||||
KotlinType argumentType = argument.getType();
|
||||
List<TypeProjectionAndVariance> projectionsFromSuper = typeArgumentsFromSuper.get(parameter.getIndex());
|
||||
List<TypeAndVariance> argTypesFromSuper = getTypes(projectionsFromSuper);
|
||||
|
||||
KtType type = modifyTypeAccordingToSuperMethods(argumentType, argTypesFromSuper, TYPE_ARGUMENT);
|
||||
KotlinType type = modifyTypeAccordingToSuperMethods(argumentType, argTypesFromSuper, TYPE_ARGUMENT);
|
||||
Variance projectionKind = calculateArgumentProjectionKindFromSuper(argument, projectionsFromSuper);
|
||||
|
||||
resultArguments.add(new TypeProjectionImpl(projectionKind, type));
|
||||
@@ -567,7 +567,7 @@ public class SignaturesPropagationData {
|
||||
}
|
||||
|
||||
private boolean typeMustBeNullable(
|
||||
@NotNull KtType autoType,
|
||||
@NotNull KotlinType autoType,
|
||||
@NotNull List<TypeAndVariance> typesFromSuper,
|
||||
@NotNull TypeUsage howThisTypeIsUsed
|
||||
) {
|
||||
@@ -611,7 +611,7 @@ public class SignaturesPropagationData {
|
||||
|
||||
@NotNull
|
||||
private ClassifierDescriptor modifyTypeClassifier(
|
||||
@NotNull KtType autoType,
|
||||
@NotNull KotlinType autoType,
|
||||
@NotNull List<TypeAndVariance> typesFromSuper
|
||||
) {
|
||||
ClassifierDescriptor classifier = autoType.getConstructor().getDeclarationDescriptor();
|
||||
@@ -666,15 +666,15 @@ public class SignaturesPropagationData {
|
||||
return fixed != null ? fixed : classifier;
|
||||
}
|
||||
|
||||
private static boolean isArrayType(@NotNull KtType type) {
|
||||
private static boolean isArrayType(@NotNull KotlinType type) {
|
||||
return KotlinBuiltIns.isArray(type) || KotlinBuiltIns.isPrimitiveArray(type);
|
||||
}
|
||||
|
||||
private static class VarargCheckResult {
|
||||
public final KtType parameterType;
|
||||
public final KotlinType parameterType;
|
||||
public final boolean isVararg;
|
||||
|
||||
public VarargCheckResult(KtType parameterType, boolean isVararg) {
|
||||
public VarargCheckResult(KotlinType parameterType, boolean isVararg) {
|
||||
this.parameterType = parameterType;
|
||||
this.isVararg = isVararg;
|
||||
}
|
||||
@@ -695,10 +695,10 @@ public class SignaturesPropagationData {
|
||||
}
|
||||
|
||||
static class TypeAndVariance {
|
||||
public final KtType type;
|
||||
public final KotlinType type;
|
||||
public final Variance varianceOfPosition;
|
||||
|
||||
public TypeAndVariance(KtType type, Variance varianceOfPosition) {
|
||||
public TypeAndVariance(KotlinType type, Variance varianceOfPosition) {
|
||||
this.type = type;
|
||||
this.varianceOfPosition = varianceOfPosition;
|
||||
}
|
||||
@@ -709,22 +709,22 @@ public class SignaturesPropagationData {
|
||||
}
|
||||
|
||||
private static class TypeAndName {
|
||||
public final KtType type;
|
||||
public final KotlinType type;
|
||||
public final Name name;
|
||||
|
||||
public TypeAndName(KtType type, Name name) {
|
||||
public TypeAndName(KotlinType type, Name name) {
|
||||
this.type = type;
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
||||
private static class ValueParameters {
|
||||
private final KtType receiverType;
|
||||
private final KotlinType receiverType;
|
||||
private final List<ValueParameterDescriptor> descriptors;
|
||||
private final boolean hasStableParameterNames;
|
||||
|
||||
public ValueParameters(
|
||||
@Nullable KtType receiverType,
|
||||
@Nullable KotlinType receiverType,
|
||||
@NotNull List<ValueParameterDescriptor> descriptors,
|
||||
boolean hasStableParameterNames
|
||||
) {
|
||||
|
||||
+14
-14
@@ -42,16 +42,16 @@ import java.util.*;
|
||||
import static org.jetbrains.kotlin.load.java.components.TypeUsage.TYPE_ARGUMENT;
|
||||
import static org.jetbrains.kotlin.types.Variance.INVARIANT;
|
||||
|
||||
public class TypeTransformingVisitor extends KtVisitor<KtType, Void> {
|
||||
public class TypeTransformingVisitor extends KtVisitor<KotlinType, Void> {
|
||||
private static boolean strictMode = false;
|
||||
|
||||
private final KtType originalType;
|
||||
private final KotlinType originalType;
|
||||
private final Map<TypeParameterDescriptor, TypeParameterDescriptorImpl> originalToAltTypeParameters;
|
||||
|
||||
private final TypeUsage typeUsage;
|
||||
|
||||
private TypeTransformingVisitor(
|
||||
KtType originalType,
|
||||
KotlinType originalType,
|
||||
Map<TypeParameterDescriptor, TypeParameterDescriptorImpl> originalToAltTypeParameters,
|
||||
TypeUsage typeUsage
|
||||
) {
|
||||
@@ -61,19 +61,19 @@ public class TypeTransformingVisitor extends KtVisitor<KtType, Void> {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static KtType computeType(
|
||||
public static KotlinType computeType(
|
||||
@NotNull KtTypeElement alternativeTypeElement,
|
||||
@NotNull KtType originalType,
|
||||
@NotNull KotlinType originalType,
|
||||
@NotNull Map<TypeParameterDescriptor, TypeParameterDescriptorImpl> originalToAltTypeParameters,
|
||||
@NotNull TypeUsage typeUsage
|
||||
) {
|
||||
KtType computedType = alternativeTypeElement.accept(new TypeTransformingVisitor(originalType, originalToAltTypeParameters, typeUsage), null);
|
||||
KotlinType computedType = alternativeTypeElement.accept(new TypeTransformingVisitor(originalType, originalToAltTypeParameters, typeUsage), null);
|
||||
assert (computedType != null);
|
||||
return computedType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KtType visitNullableType(@NotNull KtNullableType nullableType, Void aVoid) {
|
||||
public KotlinType visitNullableType(@NotNull KtNullableType nullableType, Void aVoid) {
|
||||
if (!TypeUtils.isNullableType(originalType) && typeUsage != TYPE_ARGUMENT) {
|
||||
throw new AlternativeSignatureMismatchException("Auto type '%s' is not-null, while type in alternative signature is nullable: '%s'",
|
||||
DescriptorRenderer.FQ_NAMES_IN_TYPES.renderType(originalType), nullableType.getText());
|
||||
@@ -84,7 +84,7 @@ public class TypeTransformingVisitor extends KtVisitor<KtType, Void> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public KtType visitFunctionType(@NotNull KtFunctionType type, Void data) {
|
||||
public KotlinType visitFunctionType(@NotNull KtFunctionType type, Void data) {
|
||||
KotlinBuiltIns builtIns = JvmPlatform.INSTANCE$.getBuiltIns();
|
||||
return visitCommonType(type.getReceiverTypeReference() == null
|
||||
? builtIns.getFunction(type.getParameters().size())
|
||||
@@ -92,7 +92,7 @@ public class TypeTransformingVisitor extends KtVisitor<KtType, Void> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public KtType visitUserType(@NotNull KtUserType type, Void data) {
|
||||
public KotlinType visitUserType(@NotNull KtUserType type, Void data) {
|
||||
KtUserType qualifier = type.getQualifier();
|
||||
|
||||
//noinspection ConstantConditions
|
||||
@@ -102,12 +102,12 @@ public class TypeTransformingVisitor extends KtVisitor<KtType, Void> {
|
||||
return visitCommonType(longName, type);
|
||||
}
|
||||
|
||||
private KtType visitCommonType(@NotNull ClassDescriptor classDescriptor, @NotNull KtTypeElement type) {
|
||||
private KotlinType visitCommonType(@NotNull ClassDescriptor classDescriptor, @NotNull KtTypeElement type) {
|
||||
return visitCommonType(DescriptorUtils.getFqNameSafe(classDescriptor).asString(), type);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private KtType visitCommonType(@NotNull String qualifiedName, @NotNull KtTypeElement type) {
|
||||
private KotlinType visitCommonType(@NotNull String qualifiedName, @NotNull KtTypeElement type) {
|
||||
if (originalType.isError()) {
|
||||
return originalType;
|
||||
}
|
||||
@@ -159,7 +159,7 @@ public class TypeTransformingVisitor extends KtVisitor<KtType, Void> {
|
||||
throw new AssertionError("Unexpected class of type constructor classifier "
|
||||
+ (typeConstructorClassifier == null ? "null" : typeConstructorClassifier.getClass().getName()));
|
||||
}
|
||||
return KtTypeImpl.create(originalType.getAnnotations(), typeConstructor, false, altArguments, memberScope);
|
||||
return KotlinTypeImpl.create(originalType.getAnnotations(), typeConstructor, false, altArguments, memberScope);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -183,7 +183,7 @@ public class TypeTransformingVisitor extends KtVisitor<KtType, Void> {
|
||||
assert argumentAlternativeTypeElement != null;
|
||||
|
||||
TypeParameterDescriptor parameter = typeConstructor.getParameters().get(i);
|
||||
KtType alternativeArgumentType = computeType(argumentAlternativeTypeElement, originalArgument.getType(), originalToAltTypeParameters, TYPE_ARGUMENT);
|
||||
KotlinType alternativeArgumentType = computeType(argumentAlternativeTypeElement, originalArgument.getType(), originalToAltTypeParameters, TYPE_ARGUMENT);
|
||||
Variance projectionKind = originalArgument.getProjectionKind();
|
||||
Variance altProjectionKind;
|
||||
if (type instanceof KtUserType) {
|
||||
@@ -234,7 +234,7 @@ public class TypeTransformingVisitor extends KtVisitor<KtType, Void> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public KtType visitSelfType(@NotNull KtSelfType type, Void data) {
|
||||
public KotlinType visitSelfType(@NotNull KtSelfType type, Void data) {
|
||||
throw new UnsupportedOperationException("Self-types are not supported yet");
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -39,8 +39,8 @@ public object JavaGenericVarianceViolationTypeChecker : AdditionalTypeChecker {
|
||||
// JavaClass.fillWithDefaultObjects(x) // using `x` after this call may lead to CCE
|
||||
override fun checkType(
|
||||
expression: KtExpression,
|
||||
expressionType: KtType,
|
||||
expressionTypeWithSmartCast: KtType,
|
||||
expressionType: KotlinType,
|
||||
expressionTypeWithSmartCast: KotlinType,
|
||||
c: ResolutionContext<*>
|
||||
) {
|
||||
val expectedType = c.expectedType
|
||||
|
||||
+3
-3
@@ -129,7 +129,7 @@ class JavaSyntheticPropertiesScope(storageManager: StorageManager) : KtScopeImpl
|
||||
return null
|
||||
}
|
||||
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KtType>, name: Name, location: LookupLocation): Collection<PropertyDescriptor> {
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KotlinType>, name: Name, location: LookupLocation): Collection<PropertyDescriptor> {
|
||||
//TODO: use location parameter!
|
||||
|
||||
var result: SmartList<PropertyDescriptor>? = null
|
||||
@@ -161,7 +161,7 @@ class JavaSyntheticPropertiesScope(storageManager: StorageManager) : KtScopeImpl
|
||||
return result
|
||||
}
|
||||
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KtType>): Collection<PropertyDescriptor> {
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KotlinType>): Collection<PropertyDescriptor> {
|
||||
val result = ArrayList<PropertyDescriptor>()
|
||||
val processedTypes = HashSet<TypeConstructor>()
|
||||
receiverTypes.forEach { result.collectSyntheticProperties(it.constructor, processedTypes) }
|
||||
@@ -252,7 +252,7 @@ class JavaSyntheticPropertiesScope(storageManager: StorageManager) : KtScopeImpl
|
||||
private set
|
||||
|
||||
companion object {
|
||||
fun create(ownerClass: ClassDescriptor, getMethod: FunctionDescriptor, setMethod: FunctionDescriptor?, name: Name, type: KtType): MyPropertyDescriptor {
|
||||
fun create(ownerClass: ClassDescriptor, getMethod: FunctionDescriptor, setMethod: FunctionDescriptor?, name: Name, type: KotlinType): MyPropertyDescriptor {
|
||||
val visibility = syntheticExtensionVisibility(getMethod)
|
||||
val descriptor = MyPropertyDescriptor(DescriptorUtils.getContainingModule(ownerClass),
|
||||
null,
|
||||
|
||||
+4
-4
@@ -52,7 +52,7 @@ class SamAdapterFunctionsScope(storageManager: StorageManager) : KtScope by KtSc
|
||||
return MyFunctionDescriptor.create(enhancedFunction)
|
||||
}
|
||||
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<KtType>, name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<KotlinType>, name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
|
||||
var result: SmartList<FunctionDescriptor>? = null
|
||||
for (type in receiverTypes) {
|
||||
for (function in type.memberScope.getFunctions(name, location)) {
|
||||
@@ -72,7 +72,7 @@ class SamAdapterFunctionsScope(storageManager: StorageManager) : KtScope by KtSc
|
||||
}
|
||||
}
|
||||
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<KtType>): Collection<FunctionDescriptor> {
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<KotlinType>): Collection<FunctionDescriptor> {
|
||||
return receiverTypes.flatMapTo(LinkedHashSet<FunctionDescriptor>()) { type ->
|
||||
type.memberScope.getDescriptors(DescriptorKindFilter.FUNCTIONS)
|
||||
.filterIsInstance<FunctionDescriptor>()
|
||||
@@ -156,8 +156,8 @@ class SamAdapterFunctionsScope(storageManager: StorageManager) : KtScope by KtSc
|
||||
copyOverrides: Boolean,
|
||||
kind: CallableMemberDescriptor.Kind,
|
||||
newValueParameterDescriptors: MutableList<ValueParameterDescriptor>,
|
||||
newExtensionReceiverParameterType: KtType?,
|
||||
newReturnType: KtType
|
||||
newExtensionReceiverParameterType: KotlinType?,
|
||||
newReturnType: KotlinType
|
||||
): FunctionDescriptor? {
|
||||
val descriptor = super<SimpleFunctionDescriptorImpl>.doSubstitute(
|
||||
originalSubstitutor, newOwner, newModality, newVisibility,
|
||||
|
||||
Reference in New Issue
Block a user