rename Kt to Kotlin in KtType, KtIcons
This commit is contained in:
@@ -56,7 +56,7 @@ import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver;
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ThisReceiver;
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.TransientReceiver;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.expressions.OperatorConventions;
|
||||
|
||||
import java.util.*;
|
||||
@@ -109,7 +109,7 @@ public class JetControlFlowProcessor {
|
||||
CallableDescriptor subroutineDescriptor = (CallableDescriptor) trace.get(BindingContext.DECLARATION_TO_DESCRIPTOR, subroutine);
|
||||
if (subroutineDescriptor == null) return;
|
||||
|
||||
KtType returnType = subroutineDescriptor.getReturnType();
|
||||
KotlinType returnType = subroutineDescriptor.getReturnType();
|
||||
if (returnType != null && KotlinBuiltIns.isUnit(returnType) && subroutineDescriptor instanceof AnonymousFunctionDescriptor) return;
|
||||
|
||||
PseudoValue returnValue = builder.getBoundValue(bodyExpression);
|
||||
@@ -199,7 +199,7 @@ public class JetControlFlowProcessor {
|
||||
return;
|
||||
}
|
||||
|
||||
KtType type = trace.getBindingContext().getType(expression);
|
||||
KotlinType type = trace.getBindingContext().getType(expression);
|
||||
if (type != null && KotlinBuiltIns.isNothing(type)) {
|
||||
builder.jumpToError(expression);
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilKt;
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.kotlin.resolve.calls.resolvedCallUtil.ResolvedCallUtilKt;
|
||||
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.expressions.ExpressionTypingUtils;
|
||||
|
||||
import java.util.*;
|
||||
@@ -129,7 +129,7 @@ public class JetFlowInformationProvider {
|
||||
markWhenWithoutElse();
|
||||
}
|
||||
|
||||
public void checkFunction(@Nullable KtType expectedReturnType) {
|
||||
public void checkFunction(@Nullable KotlinType expectedReturnType) {
|
||||
UnreachableCode unreachableCode = collectUnreachableCode();
|
||||
reportUnreachableCode(unreachableCode);
|
||||
|
||||
@@ -208,7 +208,7 @@ public class JetFlowInformationProvider {
|
||||
|
||||
CallableDescriptor functionDescriptor =
|
||||
(CallableDescriptor) trace.getBindingContext().get(BindingContext.DECLARATION_TO_DESCRIPTOR, localDeclaration);
|
||||
KtType expectedType = functionDescriptor != null ? functionDescriptor.getReturnType() : null;
|
||||
KotlinType expectedType = functionDescriptor != null ? functionDescriptor.getReturnType() : null;
|
||||
|
||||
JetFlowInformationProvider providerForLocalDeclaration =
|
||||
new JetFlowInformationProvider(localDeclaration, trace, localDeclarationInstruction.getBody());
|
||||
@@ -218,7 +218,7 @@ public class JetFlowInformationProvider {
|
||||
}
|
||||
}
|
||||
|
||||
public void checkDefiniteReturn(final @NotNull KtType expectedReturnType, @NotNull final UnreachableCode unreachableCode) {
|
||||
public void checkDefiniteReturn(final @NotNull KotlinType expectedReturnType, @NotNull final UnreachableCode unreachableCode) {
|
||||
assert subroutine instanceof KtDeclarationWithBody;
|
||||
KtDeclarationWithBody function = (KtDeclarationWithBody) subroutine;
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ import org.jetbrains.kotlin.resolve.CompileTimeConstantUtils;
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
||||
import org.jetbrains.kotlin.resolve.bindingContextUtil.BindingContextUtilsKt;
|
||||
import org.jetbrains.kotlin.types.FlexibleTypesKt;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.TypeUtils;
|
||||
|
||||
import java.util.HashSet;
|
||||
@@ -41,7 +41,7 @@ public final class WhenChecker {
|
||||
}
|
||||
|
||||
public static boolean mustHaveElse(@NotNull KtWhenExpression expression, @NotNull BindingTrace trace) {
|
||||
KtType expectedType = trace.get(BindingContext.EXPECTED_EXPRESSION_TYPE, expression);
|
||||
KotlinType expectedType = trace.get(BindingContext.EXPECTED_EXPRESSION_TYPE, expression);
|
||||
boolean isUnit = expectedType != null && KotlinBuiltIns.isUnit(expectedType);
|
||||
// Some "statements" are actually expressions returned from lambdas, their expected types are non-null
|
||||
boolean isStatement = BindingContextUtilsKt.isUsedAsStatement(expression, trace.getBindingContext()) && expectedType == null;
|
||||
@@ -54,7 +54,7 @@ public final class WhenChecker {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static ClassDescriptor getClassDescriptorOfTypeIfEnum(@Nullable KtType type) {
|
||||
public static ClassDescriptor getClassDescriptorOfTypeIfEnum(@Nullable KotlinType type) {
|
||||
if (type == null) return null;
|
||||
ClassDescriptor classDescriptor = TypeUtils.getClassDescriptor(type);
|
||||
if (classDescriptor == null) return null;
|
||||
@@ -64,7 +64,7 @@ public final class WhenChecker {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static KtType whenSubjectType(@NotNull KtWhenExpression expression, @NotNull BindingContext context) {
|
||||
private static KotlinType whenSubjectType(@NotNull KtWhenExpression expression, @NotNull BindingContext context) {
|
||||
KtExpression subjectExpression = expression.getSubjectExpression();
|
||||
return subjectExpression == null ? null : context.getType(subjectExpression);
|
||||
}
|
||||
@@ -136,7 +136,7 @@ public final class WhenChecker {
|
||||
*/
|
||||
private static boolean isNullableTypeWithoutPossibleSmartCast(
|
||||
@Nullable KtExpression expression,
|
||||
@NotNull KtType type,
|
||||
@NotNull KotlinType type,
|
||||
@NotNull BindingContext context
|
||||
) {
|
||||
if (expression == null) return false; // Normally should not happen
|
||||
@@ -152,7 +152,7 @@ public final class WhenChecker {
|
||||
}
|
||||
|
||||
public static boolean isWhenExhaustive(@NotNull KtWhenExpression expression, @NotNull BindingTrace trace) {
|
||||
KtType type = whenSubjectType(expression, trace.getBindingContext());
|
||||
KotlinType type = whenSubjectType(expression, trace.getBindingContext());
|
||||
if (type == null) return false;
|
||||
ClassDescriptor enumClassDescriptor = getClassDescriptorOfTypeIfEnum(type);
|
||||
|
||||
@@ -196,7 +196,7 @@ public final class WhenChecker {
|
||||
ClassDescriptor checkedDescriptor = null;
|
||||
if (condition instanceof KtWhenConditionIsPattern) {
|
||||
KtWhenConditionIsPattern conditionIsPattern = (KtWhenConditionIsPattern) condition;
|
||||
KtType checkedType = trace.get(BindingContext.TYPE, conditionIsPattern.getTypeReference());
|
||||
KotlinType checkedType = trace.get(BindingContext.TYPE, conditionIsPattern.getTypeReference());
|
||||
if (checkedType != null) {
|
||||
checkedDescriptor = TypeUtils.getClassDescriptor(checkedType);
|
||||
}
|
||||
@@ -243,7 +243,7 @@ public final class WhenChecker {
|
||||
if (condition instanceof KtWhenConditionWithExpression) {
|
||||
KtWhenConditionWithExpression conditionWithExpression = (KtWhenConditionWithExpression) condition;
|
||||
if (conditionWithExpression.getExpression() != null) {
|
||||
KtType type = trace.getBindingContext().getType(conditionWithExpression.getExpression());
|
||||
KotlinType type = trace.getBindingContext().getType(conditionWithExpression.getExpression());
|
||||
if (type != null && KotlinBuiltIns.isNothingOrNullableNothing(type)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
+2
-2
@@ -31,7 +31,7 @@ import org.jetbrains.kotlin.psi.*;
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant;
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -476,7 +476,7 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd
|
||||
@NotNull Map<PseudoValue, ReceiverValue> receiverValues,
|
||||
@NotNull Map<PseudoValue, ValueParameterDescriptor> arguments
|
||||
) {
|
||||
KtType returnType = resolvedCall.getResultingDescriptor().getReturnType();
|
||||
KotlinType returnType = resolvedCall.getResultingDescriptor().getReturnType();
|
||||
CallInstruction instruction = new CallInstruction(
|
||||
valueElement,
|
||||
getCurrentScope(),
|
||||
|
||||
@@ -35,7 +35,7 @@ import org.jetbrains.kotlin.resolve.BindingContextUtils;
|
||||
import org.jetbrains.kotlin.resolve.BindingTrace;
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.kotlin.resolve.calls.resolvedCallUtil.ResolvedCallUtilKt;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.util.slicedMap.ReadOnlySlice;
|
||||
import org.jetbrains.kotlin.util.slicedMap.WritableSlice;
|
||||
|
||||
@@ -72,12 +72,12 @@ public class PseudocodeUtil {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public KtType getType(@NotNull KtExpression expression) {
|
||||
public KotlinType getType(@NotNull KtExpression expression) {
|
||||
return bindingContext.getType(expression);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recordType(@NotNull KtExpression expression, @Nullable KtType type) {
|
||||
public void recordType(@NotNull KtExpression expression, @Nullable KotlinType type) {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,39 +19,39 @@ package org.jetbrains.kotlin.cfg.pseudocode
|
||||
import com.intellij.util.SmartFMap
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.renderer.DescriptorRenderer
|
||||
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
|
||||
|
||||
public interface TypePredicate: (KtType) -> Boolean {
|
||||
override fun invoke(typeToCheck: KtType): Boolean
|
||||
public interface TypePredicate: (KotlinType) -> Boolean {
|
||||
override fun invoke(typeToCheck: KotlinType): Boolean
|
||||
}
|
||||
|
||||
public data class SingleType(val targetType: KtType): TypePredicate {
|
||||
override fun invoke(typeToCheck: KtType): Boolean = KotlinTypeChecker.DEFAULT.equalTypes(typeToCheck, targetType)
|
||||
public data class SingleType(val targetType: KotlinType): TypePredicate {
|
||||
override fun invoke(typeToCheck: KotlinType): Boolean = KotlinTypeChecker.DEFAULT.equalTypes(typeToCheck, targetType)
|
||||
override fun toString(): String = targetType.render()
|
||||
}
|
||||
|
||||
public data class AllSubtypes(val upperBound: KtType): TypePredicate {
|
||||
override fun invoke(typeToCheck: KtType): Boolean = KotlinTypeChecker.DEFAULT.isSubtypeOf(typeToCheck, upperBound)
|
||||
public data class AllSubtypes(val upperBound: KotlinType): TypePredicate {
|
||||
override fun invoke(typeToCheck: KotlinType): Boolean = KotlinTypeChecker.DEFAULT.isSubtypeOf(typeToCheck, upperBound)
|
||||
|
||||
override fun toString(): String = "{<: ${upperBound.render()}}"
|
||||
}
|
||||
|
||||
public data class ForAllTypes(val typeSets: List<TypePredicate>): TypePredicate {
|
||||
override fun invoke(typeToCheck: KtType): Boolean = typeSets.all { it(typeToCheck) }
|
||||
override fun invoke(typeToCheck: KotlinType): Boolean = typeSets.all { it(typeToCheck) }
|
||||
|
||||
override fun toString(): String = "AND{${typeSets.joinToString(", ")}}"
|
||||
}
|
||||
|
||||
public data class ForSomeType(val typeSets: List<TypePredicate>): TypePredicate {
|
||||
override fun invoke(typeToCheck: KtType): Boolean = typeSets.any { it(typeToCheck) }
|
||||
override fun invoke(typeToCheck: KotlinType): Boolean = typeSets.any { it(typeToCheck) }
|
||||
|
||||
override fun toString(): String = "OR{${typeSets.joinToString(", ")}}"
|
||||
}
|
||||
|
||||
public object AllTypes : TypePredicate {
|
||||
override fun invoke(typeToCheck: KtType): Boolean = true
|
||||
override fun invoke(typeToCheck: KotlinType): Boolean = true
|
||||
|
||||
override fun toString(): String = "*"
|
||||
}
|
||||
@@ -71,7 +71,7 @@ public fun or(predicates: Collection<TypePredicate>): TypePredicate? =
|
||||
else -> ForSomeType(predicates.toList())
|
||||
}
|
||||
|
||||
fun KtType.getSubtypesPredicate(): TypePredicate {
|
||||
fun KotlinType.getSubtypesPredicate(): TypePredicate {
|
||||
return when {
|
||||
KotlinBuiltIns.isAnyOrNullableAny(this) && isMarkedNullable() -> AllTypes
|
||||
TypeUtils.canHaveSubtypes(KotlinTypeChecker.DEFAULT, this) -> AllSubtypes(this)
|
||||
@@ -80,7 +80,7 @@ fun KtType.getSubtypesPredicate(): TypePredicate {
|
||||
}
|
||||
|
||||
|
||||
private fun KtType.render(): String = DescriptorRenderer.SHORT_NAMES_IN_TYPES.renderType(this)
|
||||
private fun KotlinType.render(): String = DescriptorRenderer.SHORT_NAMES_IN_TYPES.renderType(this)
|
||||
|
||||
public fun <T> TypePredicate.expectedTypeFor(keys: Iterable<T>): Map<T, TypePredicate> =
|
||||
keys.fold(SmartFMap.emptyMap<T, TypePredicate>()) { map, key -> map.plus(key, this) }
|
||||
|
||||
@@ -46,7 +46,7 @@ import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind
|
||||
import org.jetbrains.kotlin.resolve.calls.tasks.ResolutionCandidate
|
||||
import org.jetbrains.kotlin.resolve.calls.tasks.TracingStrategy
|
||||
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 java.util.*
|
||||
|
||||
@@ -77,7 +77,7 @@ public fun getExpectedTypePredicate(
|
||||
val pseudocode = value.createdAt?.owner ?: return AllTypes
|
||||
val typePredicates = LinkedHashSet<TypePredicate?>()
|
||||
|
||||
fun addSubtypesOf(jetType: KtType?) = typePredicates.add(jetType?.getSubtypesPredicate())
|
||||
fun addSubtypesOf(jetType: KotlinType?) = typePredicates.add(jetType?.getSubtypesPredicate())
|
||||
|
||||
fun addByExplicitReceiver(resolvedCall: ResolvedCall<*>?) {
|
||||
val receiverValue = (resolvedCall ?: return).getExplicitReceiverValue()
|
||||
|
||||
@@ -38,7 +38,7 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilKt;
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.kotlin.resolve.calls.tasks.DynamicCallsKt;
|
||||
import org.jetbrains.kotlin.types.ErrorUtils;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.util.slicedMap.WritableSlice;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -196,7 +196,7 @@ public class DebugInfoUtil {
|
||||
// if 'foo' in 'foo[i]' is unresolved it means 'foo[i]' is unresolved (otherwise 'foo[i]' is marked as 'missing unresolved')
|
||||
markedWithError = true;
|
||||
}
|
||||
KtType expressionType = bindingContext.getType(expression);
|
||||
KotlinType expressionType = bindingContext.getType(expression);
|
||||
DiagnosticFactory<?> factory = markedWithErrorElements.get(expression);
|
||||
if (declarationDescriptor != null &&
|
||||
(ErrorUtils.isError(declarationDescriptor) || ErrorUtils.containsErrorType(expressionType))) {
|
||||
|
||||
+2
-2
@@ -21,7 +21,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.TypeSubstitutor;
|
||||
|
||||
public class LocalVariableDescriptor extends VariableDescriptorWithInitializerImpl {
|
||||
@@ -29,7 +29,7 @@ public class LocalVariableDescriptor extends VariableDescriptorWithInitializerIm
|
||||
@NotNull DeclarationDescriptor containingDeclaration,
|
||||
@NotNull Annotations annotations,
|
||||
@NotNull Name name,
|
||||
@Nullable KtType type,
|
||||
@Nullable KotlinType type,
|
||||
boolean mutable,
|
||||
@NotNull SourceElement source
|
||||
) {
|
||||
|
||||
@@ -30,7 +30,7 @@ import org.jetbrains.kotlin.psi.*;
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.InferenceErrorData;
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.kotlin.resolve.varianceChecker.VarianceChecker.VarianceConflictDiagnosticData;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
@@ -91,7 +91,7 @@ public interface Errors {
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
DiagnosticFactory0<KtTypeProjection> PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT = DiagnosticFactory0.create(ERROR, VARIANCE_IN_PROJECTION);
|
||||
DiagnosticFactory2<KtTypeReference, KtType, KtType> UPPER_BOUND_VIOLATED = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory2<KtTypeReference, KotlinType, KotlinType> UPPER_BOUND_VIOLATED = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory0<KtNullableType> REDUNDANT_NULLABLE = DiagnosticFactory0.create(WARNING, NULLABLE_TYPE);
|
||||
DiagnosticFactory1<KtElement, Integer> WRONG_NUMBER_OF_TYPE_ARGUMENTS = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory2<KtTypeReference, Integer, String> NO_TYPE_ARGUMENTS_ON_RHS = DiagnosticFactory2.create(ERROR);
|
||||
@@ -148,7 +148,7 @@ public interface Errors {
|
||||
DiagnosticFactory0<PsiElement> CONST_VAL_NOT_TOP_LEVEL_OR_OBJECT = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<PsiElement> CONST_VAL_WITH_GETTER = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<PsiElement> CONST_VAL_WITH_DELEGATE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, KtType> TYPE_CANT_BE_USED_FOR_CONST_VAL = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, KotlinType> TYPE_CANT_BE_USED_FOR_CONST_VAL = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory0<PsiElement> CONST_VAL_WITHOUT_INITIALIZER = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtExpression> CONST_VAL_WITH_NON_CONST_INITIALIZER = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
@@ -180,9 +180,9 @@ public interface Errors {
|
||||
|
||||
DiagnosticFactory0<KtTypeReference> MANY_CLASSES_IN_SUPERTYPE_LIST = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtTypeReference> SUPERTYPE_APPEARS_TWICE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory3<KtDelegationSpecifierList, TypeParameterDescriptor, ClassDescriptor, Collection<KtType>>
|
||||
DiagnosticFactory3<KtDelegationSpecifierList, TypeParameterDescriptor, ClassDescriptor, Collection<KotlinType>>
|
||||
INCONSISTENT_TYPE_PARAMETER_VALUES = DiagnosticFactory3.create(ERROR);
|
||||
DiagnosticFactory3<KtTypeParameter, TypeParameterDescriptor, ClassDescriptor, Collection<KtType>>
|
||||
DiagnosticFactory3<KtTypeParameter, TypeParameterDescriptor, ClassDescriptor, Collection<KotlinType>>
|
||||
INCONSISTENT_TYPE_PARAMETER_BOUNDS = DiagnosticFactory3.create(ERROR);
|
||||
|
||||
|
||||
@@ -253,7 +253,7 @@ public interface Errors {
|
||||
|
||||
// Type parameter declarations
|
||||
|
||||
DiagnosticFactory1<KtTypeReference, KtType> FINAL_UPPER_BOUND = DiagnosticFactory1.create(WARNING);
|
||||
DiagnosticFactory1<KtTypeReference, KotlinType> FINAL_UPPER_BOUND = DiagnosticFactory1.create(WARNING);
|
||||
DiagnosticFactory0<KtTypeReference> DYNAMIC_UPPER_BOUND = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory1<KtNamedDeclaration, TypeParameterDescriptor> CONFLICTING_UPPER_BOUNDS =
|
||||
@@ -322,7 +322,7 @@ public interface Errors {
|
||||
DiagnosticFactory2.create(ERROR, DECLARATION_NAME);
|
||||
|
||||
|
||||
DiagnosticFactory1<KtNamedDeclaration, Collection<KtType>> AMBIGUOUS_ANONYMOUS_TYPE_INFERRED =
|
||||
DiagnosticFactory1<KtNamedDeclaration, Collection<KotlinType>> AMBIGUOUS_ANONYMOUS_TYPE_INFERRED =
|
||||
DiagnosticFactory1.create(ERROR, DECLARATION_SIGNATURE);
|
||||
|
||||
// Property-specific
|
||||
@@ -334,7 +334,7 @@ public interface Errors {
|
||||
DiagnosticFactory0<PsiElement> GETTER_VISIBILITY_DIFFERS_FROM_PROPERTY_VISIBILITY = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<PsiElement> PRIVATE_SETTER_ON_NON_PRIVATE_LATE_INIT_VAR = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<PsiElement> ACCESSOR_VISIBILITY_FOR_ABSTRACT_PROPERTY = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory2<KtTypeReference, KtType, KtType> WRONG_GETTER_RETURN_TYPE = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory2<KtTypeReference, KotlinType, KotlinType> WRONG_GETTER_RETURN_TYPE = DiagnosticFactory2.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<KtModifierListOwner>
|
||||
ABSTRACT_PROPERTY_IN_PRIMARY_CONSTRUCTOR_PARAMETERS = DiagnosticFactory0.create(ERROR, ABSTRACT_MODIFIER);
|
||||
@@ -370,7 +370,7 @@ public interface Errors {
|
||||
|
||||
DiagnosticFactory0<KtExpression> SETTER_PARAMETER_WITH_DEFAULT_VALUE = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory2<KtTypeReference, KtType, KtType> WRONG_SETTER_PARAMETER_TYPE = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory2<KtTypeReference, KotlinType, KotlinType> WRONG_SETTER_PARAMETER_TYPE = DiagnosticFactory2.create(ERROR);
|
||||
|
||||
// Function-specific
|
||||
|
||||
@@ -452,7 +452,7 @@ public interface Errors {
|
||||
|
||||
DiagnosticFactory1<KtElement, ValueParameterDescriptor> NO_VALUE_FOR_PARAMETER = DiagnosticFactory1.create(ERROR, VALUE_ARGUMENTS);
|
||||
|
||||
DiagnosticFactory1<KtExpression, KtType> MISSING_RECEIVER = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtExpression, KotlinType> MISSING_RECEIVER = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory0<KtExpression> NO_RECEIVER_ALLOWED = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
// Call resolution
|
||||
@@ -461,7 +461,7 @@ public interface Errors {
|
||||
|
||||
DiagnosticFactory0<PsiElement> SAFE_CALL_IN_QUALIFIER = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory2<KtExpression, KtExpression, KtType> FUNCTION_EXPECTED = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory2<KtExpression, KtExpression, KotlinType> FUNCTION_EXPECTED = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory2<KtExpression, KtExpression, Boolean> FUNCTION_CALL_EXPECTED = DiagnosticFactory2.create(ERROR, CALL_EXPRESSION);
|
||||
|
||||
DiagnosticFactory0<PsiElement> NON_TAIL_RECURSIVE_CALL = DiagnosticFactory0.create(WARNING, CALL_EXPRESSION);
|
||||
@@ -478,7 +478,7 @@ public interface Errors {
|
||||
DiagnosticFactory1<PsiElement, KtExpression> INVOKE_EXTENSION_ON_NOT_EXTENSION_FUNCTION = DiagnosticFactory1.create(ERROR);
|
||||
|
||||
DiagnosticFactory1<PsiElement, TypeParameterDescriptor> TYPE_PARAMETER_AS_REIFIED = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, KtType> REIFIED_TYPE_FORBIDDEN_SUBSTITUTION = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, KotlinType> REIFIED_TYPE_FORBIDDEN_SUBSTITUTION = DiagnosticFactory1.create(ERROR);
|
||||
|
||||
// Type inference
|
||||
|
||||
@@ -491,7 +491,7 @@ public interface Errors {
|
||||
DiagnosticFactory0<PsiElement> TYPE_INFERENCE_INCORPORATION_ERROR = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, TypeParameterDescriptor> TYPE_INFERENCE_ONLY_INPUT_TYPES = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, InferenceErrorData> TYPE_INFERENCE_UPPER_BOUND_VIOLATED = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory2<KtElement, KtType, KtType> TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory2<KtElement, KotlinType, KotlinType> TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH = DiagnosticFactory2.create(ERROR);
|
||||
|
||||
// Reflection
|
||||
|
||||
@@ -506,9 +506,9 @@ public interface Errors {
|
||||
// Multi-declarations
|
||||
|
||||
DiagnosticFactory0<KtMultiDeclaration> INITIALIZER_REQUIRED_FOR_MULTIDECLARATION = DiagnosticFactory0.create(ERROR, DEFAULT);
|
||||
DiagnosticFactory2<KtExpression, Name, KtType> COMPONENT_FUNCTION_MISSING = DiagnosticFactory2.create(ERROR, DEFAULT);
|
||||
DiagnosticFactory2<KtExpression, Name, KotlinType> COMPONENT_FUNCTION_MISSING = DiagnosticFactory2.create(ERROR, DEFAULT);
|
||||
DiagnosticFactory2<KtExpression, Name, Collection<? extends ResolvedCall<?>>> COMPONENT_FUNCTION_AMBIGUITY = DiagnosticFactory2.create(ERROR, DEFAULT);
|
||||
DiagnosticFactory3<KtExpression, Name, KtType, KtType> COMPONENT_FUNCTION_RETURN_TYPE_MISMATCH = DiagnosticFactory3.create(ERROR, DEFAULT);
|
||||
DiagnosticFactory3<KtExpression, Name, KotlinType, KotlinType> COMPONENT_FUNCTION_RETURN_TYPE_MISMATCH = DiagnosticFactory3.create(ERROR, DEFAULT);
|
||||
|
||||
// Super calls
|
||||
|
||||
@@ -535,30 +535,30 @@ public interface Errors {
|
||||
ASSIGN_OPERATOR_AMBIGUITY = DiagnosticFactory1.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<KtSimpleNameExpression> EQUALS_MISSING = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory3<KtBinaryExpression, KtSimpleNameExpression, KtType, KtType> EQUALITY_NOT_APPLICABLE =
|
||||
DiagnosticFactory3<KtBinaryExpression, KtSimpleNameExpression, KotlinType, KotlinType> EQUALITY_NOT_APPLICABLE =
|
||||
DiagnosticFactory3.create(ERROR);
|
||||
|
||||
|
||||
DiagnosticFactory1<KtExpression, KtType> HAS_NEXT_MISSING = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtExpression, KtType> HAS_NEXT_FUNCTION_AMBIGUITY = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtExpression, KtType> HAS_NEXT_FUNCTION_NONE_APPLICABLE = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtExpression, KtType> HAS_NEXT_FUNCTION_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtExpression, KotlinType> HAS_NEXT_MISSING = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtExpression, KotlinType> HAS_NEXT_FUNCTION_AMBIGUITY = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtExpression, KotlinType> HAS_NEXT_FUNCTION_NONE_APPLICABLE = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtExpression, KotlinType> HAS_NEXT_FUNCTION_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR);
|
||||
|
||||
DiagnosticFactory1<KtExpression, KtType> NEXT_AMBIGUITY = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtExpression, KtType> NEXT_MISSING = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtExpression, KtType> NEXT_NONE_APPLICABLE = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtExpression, KotlinType> NEXT_AMBIGUITY = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtExpression, KotlinType> NEXT_MISSING = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtExpression, KotlinType> NEXT_NONE_APPLICABLE = DiagnosticFactory1.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<KtExpression> ITERATOR_MISSING = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, Collection<? extends ResolvedCall<?>>> ITERATOR_AMBIGUITY = DiagnosticFactory1.create(ERROR);
|
||||
|
||||
DiagnosticFactory2<KtExpression, String, KtType> DELEGATE_SPECIAL_FUNCTION_MISSING = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory3<PsiElement, FunctionDescriptor, KtType, String> DELEGATE_RESOLVED_TO_DEPRECATED_CONVENTION = DiagnosticFactory3.create(WARNING);
|
||||
DiagnosticFactory2<KtExpression, String, KotlinType> DELEGATE_SPECIAL_FUNCTION_MISSING = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory3<PsiElement, FunctionDescriptor, KotlinType, String> DELEGATE_RESOLVED_TO_DEPRECATED_CONVENTION = DiagnosticFactory3.create(WARNING);
|
||||
DiagnosticFactory2<KtExpression, String, Collection<? extends ResolvedCall<?>>> DELEGATE_SPECIAL_FUNCTION_AMBIGUITY = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory2<KtExpression, String, Collection<? extends ResolvedCall<?>>> DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory3<KtExpression, String, KtType, KtType> DELEGATE_SPECIAL_FUNCTION_RETURN_TYPE_MISMATCH = DiagnosticFactory3.create(ERROR);
|
||||
DiagnosticFactory3<KtExpression, String, KotlinType, KotlinType> DELEGATE_SPECIAL_FUNCTION_RETURN_TYPE_MISMATCH = DiagnosticFactory3.create(ERROR);
|
||||
DiagnosticFactory2<KtExpression, String, Collection<? extends ResolvedCall<?>>> DELEGATE_PD_METHOD_NONE_APPLICABLE = DiagnosticFactory2.create(WARNING);
|
||||
|
||||
DiagnosticFactory1<KtSimpleNameExpression, KtType> COMPARE_TO_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtSimpleNameExpression, KotlinType> COMPARE_TO_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<PsiElement> UNDERSCORE_IS_RESERVED = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, String> INVALID_CHARACTERS = DiagnosticFactory1.create(ERROR);
|
||||
@@ -616,14 +616,14 @@ public interface Errors {
|
||||
|
||||
// Nullability
|
||||
|
||||
DiagnosticFactory1<PsiElement, KtType> UNSAFE_CALL = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, KotlinType> UNSAFE_CALL = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory3<KtExpression, String, String, String> UNSAFE_INFIX_CALL = DiagnosticFactory3.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, KtType> UNNECESSARY_SAFE_CALL = DiagnosticFactory1.create(WARNING);
|
||||
DiagnosticFactory1<PsiElement, KotlinType> UNNECESSARY_SAFE_CALL = DiagnosticFactory1.create(WARNING);
|
||||
DiagnosticFactory0<PsiElement> UNEXPECTED_SAFE_CALL = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, KtType> UNNECESSARY_NOT_NULL_ASSERTION = DiagnosticFactory1.create(WARNING);
|
||||
DiagnosticFactory1<PsiElement, KotlinType> UNNECESSARY_NOT_NULL_ASSERTION = DiagnosticFactory1.create(WARNING);
|
||||
DiagnosticFactory0<PsiElement> NOT_NULL_ASSERTION_ON_FUNCTION_LITERAL = DiagnosticFactory0.create(WARNING);
|
||||
|
||||
DiagnosticFactory1<KtBinaryExpression, KtType> USELESS_ELVIS = DiagnosticFactory1.create(WARNING, PositioningStrategies.USELESS_ELVIS);
|
||||
DiagnosticFactory1<KtBinaryExpression, KotlinType> USELESS_ELVIS = DiagnosticFactory1.create(WARNING, PositioningStrategies.USELESS_ELVIS);
|
||||
DiagnosticFactory0<PsiElement> USELESS_ELVIS_ON_FUNCTION_LITERAL = DiagnosticFactory0.create(WARNING);
|
||||
|
||||
// Compile-time values
|
||||
@@ -633,27 +633,27 @@ public interface Errors {
|
||||
DiagnosticFactory0<KtConstantExpression> WRONG_LONG_SUFFIX = DiagnosticFactory0.create(ERROR, LONG_LITERAL_SUFFIX);
|
||||
DiagnosticFactory0<KtConstantExpression> INT_LITERAL_OUT_OF_RANGE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtConstantExpression> FLOAT_LITERAL_OUT_OF_RANGE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory2<KtConstantExpression, String, KtType> CONSTANT_EXPECTED_TYPE_MISMATCH = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory2<KtConstantExpression, String, KotlinType> CONSTANT_EXPECTED_TYPE_MISMATCH = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory0<KtConstantExpression> INCORRECT_CHARACTER_LITERAL = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtConstantExpression> EMPTY_CHARACTER_LITERAL = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory1<KtConstantExpression, KtConstantExpression> TOO_MANY_CHARACTERS_IN_CHARACTER_LITERAL = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtElement, KtElement> ILLEGAL_ESCAPE = DiagnosticFactory1.create(ERROR, CUT_CHAR_QUOTES);
|
||||
DiagnosticFactory1<KtConstantExpression, KtType> NULL_FOR_NONNULL_TYPE = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtConstantExpression, KotlinType> NULL_FOR_NONNULL_TYPE = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory0<KtEscapeStringTemplateEntry> ILLEGAL_ESCAPE_SEQUENCE = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
// Casts and is-checks
|
||||
|
||||
DiagnosticFactory1<KtElement, KtType> CANNOT_CHECK_FOR_ERASED = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory2<KtBinaryExpressionWithTypeRHS, KtType, KtType> UNCHECKED_CAST = DiagnosticFactory2.create(WARNING);
|
||||
DiagnosticFactory1<KtElement, KotlinType> CANNOT_CHECK_FOR_ERASED = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory2<KtBinaryExpressionWithTypeRHS, KotlinType, KotlinType> UNCHECKED_CAST = DiagnosticFactory2.create(WARNING);
|
||||
|
||||
DiagnosticFactory0<KtBinaryExpressionWithTypeRHS> USELESS_CAST = DiagnosticFactory0.create(WARNING, AS_TYPE);
|
||||
DiagnosticFactory0<KtSimpleNameExpression> CAST_NEVER_SUCCEEDS = DiagnosticFactory0.create(WARNING);
|
||||
DiagnosticFactory0<KtTypeReference> DYNAMIC_NOT_ALLOWED = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtTypeReference> IS_ENUM_ENTRY = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory1<KtExpression, KtType> IMPLICIT_CAST_TO_UNIT_OR_ANY = DiagnosticFactory1.create(WARNING);
|
||||
DiagnosticFactory1<KtExpression, KotlinType> IMPLICIT_CAST_TO_UNIT_OR_ANY = DiagnosticFactory1.create(WARNING);
|
||||
|
||||
DiagnosticFactory2<KtExpression, KtType, String> SMARTCAST_IMPOSSIBLE = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory2<KtExpression, KotlinType, String> SMARTCAST_IMPOSSIBLE = DiagnosticFactory2.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<KtNullableType> USELESS_NULLABLE_CHECK = DiagnosticFactory0.create(WARNING, NULLABLE_TYPE);
|
||||
|
||||
@@ -686,20 +686,20 @@ public interface Errors {
|
||||
|
||||
// Type mismatch
|
||||
|
||||
DiagnosticFactory2<KtExpression, KtType, KtType> TYPE_MISMATCH = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory1<KtExpression, KtType> RETURN_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtExpression, KtType> EXPECTED_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtBinaryExpression, KtType> ASSIGNMENT_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory2<KtTypeReference, KtType, KtType> TYPE_MISMATCH_IN_FOR_LOOP = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory1<KtElement, KtType> TYPE_MISMATCH_IN_CONDITION = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory3<KtExpression, String, KtType, KtType> RESULT_TYPE_MISMATCH = DiagnosticFactory3.create(ERROR);
|
||||
DiagnosticFactory2<KtExpression, KotlinType, KotlinType> TYPE_MISMATCH = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory1<KtExpression, KotlinType> RETURN_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtExpression, KotlinType> EXPECTED_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtBinaryExpression, KotlinType> ASSIGNMENT_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory2<KtTypeReference, KotlinType, KotlinType> TYPE_MISMATCH_IN_FOR_LOOP = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory1<KtElement, KotlinType> TYPE_MISMATCH_IN_CONDITION = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory3<KtExpression, String, KotlinType, KotlinType> RESULT_TYPE_MISMATCH = DiagnosticFactory3.create(ERROR);
|
||||
DiagnosticFactory0<KtWhenConditionInRange> TYPE_MISMATCH_IN_RANGE = DiagnosticFactory0.create(ERROR, WHEN_CONDITION_IN_RANGE);
|
||||
|
||||
DiagnosticFactory1<KtParameter, KtType> EXPECTED_PARAMETER_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory2<KtFunction, Integer, List<KtType>> EXPECTED_PARAMETERS_NUMBER_MISMATCH =
|
||||
DiagnosticFactory1<KtParameter, KotlinType> EXPECTED_PARAMETER_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory2<KtFunction, Integer, List<KotlinType>> EXPECTED_PARAMETERS_NUMBER_MISMATCH =
|
||||
DiagnosticFactory2.create(ERROR, FUNCTION_PARAMETERS);
|
||||
|
||||
DiagnosticFactory2<KtElement, KtType, KtType> INCOMPATIBLE_TYPES = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory2<KtElement, KotlinType, KotlinType> INCOMPATIBLE_TYPES = DiagnosticFactory2.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<PsiElement> IMPLICIT_NOTHING_RETURN_TYPE = DiagnosticFactory0.create(WARNING);
|
||||
|
||||
|
||||
+3
-3
@@ -33,7 +33,7 @@ import org.jetbrains.kotlin.renderer.DescriptorRendererOptions;
|
||||
import org.jetbrains.kotlin.renderer.MultiRenderer;
|
||||
import org.jetbrains.kotlin.renderer.Renderer;
|
||||
import org.jetbrains.kotlin.resolve.varianceChecker.VarianceChecker.VarianceConflictDiagnosticData;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.util.MappedExtensionProvider;
|
||||
import org.jetbrains.kotlin.util.OperatorNameConventions;
|
||||
|
||||
@@ -566,10 +566,10 @@ public class DefaultErrorMessages {
|
||||
|
||||
MAP.put(FUNCTION_EXPECTED, "Expression ''{0}''{1} cannot be invoked as a function. " +
|
||||
"The function '" + OperatorNameConventions.INVOKE.asString() + "()' is not found",
|
||||
ELEMENT_TEXT, new Renderer<KtType>() {
|
||||
ELEMENT_TEXT, new Renderer<KotlinType>() {
|
||||
@NotNull
|
||||
@Override
|
||||
public String render(@NotNull KtType type) {
|
||||
public String render(@NotNull KotlinType type) {
|
||||
if (type.isError()) return "";
|
||||
return " of type '" + RENDER_TYPE.render(type) + "'";
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.Constrain
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind.RECEIVER_POSITION
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind.VALUE_PARAMETER_POSITION
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
|
||||
@@ -93,7 +93,7 @@ public object Renderers {
|
||||
|
||||
public val RENDER_CLASS_OR_OBJECT_NAME: Renderer<ClassDescriptor> = Renderer { it.renderKindWithName() }
|
||||
|
||||
public val RENDER_TYPE: Renderer<KtType> = Renderer { DescriptorRenderer.FQ_NAMES_IN_TYPES.renderType(it) }
|
||||
public val RENDER_TYPE: Renderer<KotlinType> = Renderer { DescriptorRenderer.FQ_NAMES_IN_TYPES.renderType(it) }
|
||||
|
||||
public val RENDER_POSITION_VARIANCE: Renderer<Variance> = Renderer {
|
||||
variance: Variance ->
|
||||
@@ -179,7 +179,7 @@ public object Renderers {
|
||||
val receiverType = DescriptorUtils.getReceiverParameterType(substitutedDescriptor.getExtensionReceiverParameter())
|
||||
|
||||
val errorPositions = Sets.newHashSet<ConstraintPosition>()
|
||||
val parameterTypes = Lists.newArrayList<KtType>()
|
||||
val parameterTypes = Lists.newArrayList<KotlinType>()
|
||||
for (valueParameterDescriptor in substitutedDescriptor.getValueParameters()) {
|
||||
parameterTypes.add(valueParameterDescriptor.getType())
|
||||
if (valueParameterDescriptor.getIndex() >= inferenceErrorData.valueArgumentsTypes.size()) continue
|
||||
@@ -279,7 +279,7 @@ public object Renderers {
|
||||
.table(newTable()
|
||||
.descriptor(inferenceErrorData.descriptor))
|
||||
|
||||
var violatedUpperBound: KtType? = null
|
||||
var violatedUpperBound: KotlinType? = null
|
||||
for (upperBound in typeParameterDescriptor.getUpperBounds()) {
|
||||
val upperBoundWithSubstitutedInferredTypes = systemWithoutWeakConstraints.getResultingSubstitutor().substitute(upperBound, Variance.INVARIANT)
|
||||
if (upperBoundWithSubstitutedInferredTypes != null
|
||||
@@ -356,9 +356,9 @@ public object Renderers {
|
||||
}.toString()
|
||||
}
|
||||
|
||||
private fun renderTypes(types: Collection<KtType>) = StringUtil.join(types, { RENDER_TYPE.render(it) }, ", ")
|
||||
private fun renderTypes(types: Collection<KotlinType>) = StringUtil.join(types, { RENDER_TYPE.render(it) }, ", ")
|
||||
|
||||
public val RENDER_COLLECTION_OF_TYPES: Renderer<Collection<KtType>> = Renderer { renderTypes(it) }
|
||||
public val RENDER_COLLECTION_OF_TYPES: Renderer<Collection<KotlinType>> = Renderer { renderTypes(it) }
|
||||
|
||||
private fun renderConstraintSystem(constraintSystem: ConstraintSystem, renderTypeBounds: Renderer<TypeBounds>): String {
|
||||
val typeVariables = constraintSystem.getTypeVariables()
|
||||
|
||||
+11
-11
@@ -29,7 +29,7 @@ import org.jetbrains.kotlin.diagnostics.rendering.TabledDescriptorRenderer.TextR
|
||||
import org.jetbrains.kotlin.renderer.DescriptorRenderer;
|
||||
import org.jetbrains.kotlin.renderer.Renderer;
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPosition;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
@@ -50,11 +50,11 @@ public class TabledDescriptorRenderer {
|
||||
}
|
||||
|
||||
public static class FunctionArgumentsRow implements TableRow {
|
||||
public final KtType receiverType;
|
||||
public final List<KtType> argumentTypes;
|
||||
public final KotlinType receiverType;
|
||||
public final List<KotlinType> argumentTypes;
|
||||
public final Predicate<ConstraintPosition> isErrorPosition;
|
||||
|
||||
public FunctionArgumentsRow(KtType receiverType, List<KtType> argumentTypes, Predicate<ConstraintPosition> isErrorPosition) {
|
||||
public FunctionArgumentsRow(KotlinType receiverType, List<KotlinType> argumentTypes, Predicate<ConstraintPosition> isErrorPosition) {
|
||||
this.receiverType = receiverType;
|
||||
this.argumentTypes = argumentTypes;
|
||||
this.isErrorPosition = isErrorPosition;
|
||||
@@ -68,13 +68,13 @@ public class TabledDescriptorRenderer {
|
||||
return this;
|
||||
}
|
||||
|
||||
public TableRenderer functionArgumentTypeList(@Nullable KtType receiverType, @NotNull List<KtType> argumentTypes) {
|
||||
public TableRenderer functionArgumentTypeList(@Nullable KotlinType receiverType, @NotNull List<KotlinType> argumentTypes) {
|
||||
|
||||
return functionArgumentTypeList(receiverType, argumentTypes, Predicates.<ConstraintPosition>alwaysFalse());
|
||||
}
|
||||
|
||||
public TableRenderer functionArgumentTypeList(@Nullable KtType receiverType,
|
||||
@NotNull List<KtType> argumentTypes,
|
||||
public TableRenderer functionArgumentTypeList(@Nullable KotlinType receiverType,
|
||||
@NotNull List<KotlinType> argumentTypes,
|
||||
@NotNull Predicate<ConstraintPosition> isErrorPosition) {
|
||||
rows.add(new FunctionArgumentsRow(receiverType, argumentTypes, isErrorPosition));
|
||||
return this;
|
||||
@@ -156,7 +156,7 @@ public class TabledDescriptorRenderer {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Renderer<KtType> getTypeRenderer() {
|
||||
public Renderer<KotlinType> getTypeRenderer() {
|
||||
return Renderers.RENDER_TYPE;
|
||||
}
|
||||
|
||||
@@ -183,7 +183,7 @@ public class TabledDescriptorRenderer {
|
||||
}
|
||||
}
|
||||
|
||||
private void renderFunctionArguments(@Nullable KtType receiverType, @NotNull List<KtType> argumentTypes, StringBuilder result) {
|
||||
private void renderFunctionArguments(@Nullable KotlinType receiverType, @NotNull List<KotlinType> argumentTypes, StringBuilder result) {
|
||||
boolean hasReceiver = receiverType != null;
|
||||
if (hasReceiver) {
|
||||
result.append("receiver: ");
|
||||
@@ -196,8 +196,8 @@ public class TabledDescriptorRenderer {
|
||||
}
|
||||
|
||||
result.append("(");
|
||||
for (Iterator<KtType> iterator = argumentTypes.iterator(); iterator.hasNext(); ) {
|
||||
KtType argumentType = iterator.next();
|
||||
for (Iterator<KotlinType> iterator = argumentTypes.iterator(); iterator.hasNext(); ) {
|
||||
KotlinType argumentType = iterator.next();
|
||||
String renderedArgument = getTypeRenderer().render(argumentType);
|
||||
|
||||
result.append(renderedArgument);
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.jetbrains.kotlin.psi.KtNamedFunction;
|
||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
||||
import org.jetbrains.kotlin.resolve.annotations.AnnotationUtilKt;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.TypeProjection;
|
||||
import org.jetbrains.kotlin.types.Variance;
|
||||
|
||||
@@ -89,13 +89,13 @@ public class MainFunctionDetector {
|
||||
if (parameters.size() != 1) return false;
|
||||
|
||||
ValueParameterDescriptor parameter = parameters.get(0);
|
||||
KtType parameterType = parameter.getType();
|
||||
KotlinType parameterType = parameter.getType();
|
||||
if (!KotlinBuiltIns.isArray(parameterType)) return false;
|
||||
|
||||
List<TypeProjection> typeArguments = parameterType.getArguments();
|
||||
if (typeArguments.size() != 1) return false;
|
||||
|
||||
KtType typeArgument = typeArguments.get(0).getType();
|
||||
KotlinType typeArgument = typeArguments.get(0).getType();
|
||||
if (!KotlinBuiltIns.isString(typeArgument)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ import com.intellij.psi.search.GlobalSearchScope
|
||||
import com.intellij.psi.tree.IElementType
|
||||
import com.intellij.testFramework.LightVirtualFile
|
||||
import org.jetbrains.kotlin.idea.KotlinFileType
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.check
|
||||
import java.util.*
|
||||
|
||||
@@ -131,7 +131,7 @@ public abstract class KtCodeFragment(
|
||||
|
||||
companion object {
|
||||
public val IMPORT_SEPARATOR: String = ","
|
||||
public val RUNTIME_TYPE_EVALUATOR: Key<Function1<KtExpression, KtType?>> = Key.create("RUNTIME_TYPE_EVALUATOR")
|
||||
public val RUNTIME_TYPE_EVALUATOR: Key<Function1<KtExpression, KotlinType?>> = Key.create("RUNTIME_TYPE_EVALUATOR")
|
||||
public val ADDITIONAL_CONTEXT_FOR_LAMBDA: Key<Function0<KtElement?>> = Key.create("ADDITIONAL_CONTEXT_FOR_LAMBDA")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import com.intellij.openapi.util.Key
|
||||
import org.jetbrains.kotlin.psi.KtCodeFragment
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.psi.KtTypeReference
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
public val SUPPRESS_DIAGNOSTICS_IN_DEBUG_MODE: Key<Boolean> = Key.create<Boolean>("SUPPRESS_DIAGNOSTICS_IN_DEBUG_MODE")
|
||||
|
||||
@@ -36,10 +36,10 @@ public var KtFile.suppressDiagnosticsInDebugMode: Boolean
|
||||
|
||||
public val DEBUG_TYPE_REFERENCE_STRING: String = "DebugTypeKotlinRulezzzz"
|
||||
|
||||
public val DEBUG_TYPE_INFO: Key<KtType> = Key.create<KtType>("DEBUG_TYPE_INFO")
|
||||
public var KtTypeReference.debugTypeInfo: KtType?
|
||||
public val DEBUG_TYPE_INFO: Key<KotlinType> = Key.create<KotlinType>("DEBUG_TYPE_INFO")
|
||||
public var KtTypeReference.debugTypeInfo: KotlinType?
|
||||
get() = getUserData(DEBUG_TYPE_INFO)
|
||||
set(type: KtType?) {
|
||||
set(type: KotlinType?) {
|
||||
if (type != null && this.getText() == DEBUG_TYPE_REFERENCE_STRING) {
|
||||
putUserData(DEBUG_TYPE_INFO, type)
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ import org.jetbrains.kotlin.incremental.components.LookupLocation
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||
import org.jetbrains.kotlin.resolve.scopes.KtScope
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.utils.Printer
|
||||
|
||||
class AllUnderImportsScope(descriptor: DeclarationDescriptor) : KtScope {
|
||||
@@ -51,19 +51,19 @@ class AllUnderImportsScope(descriptor: DeclarationDescriptor) : KtScope {
|
||||
return scopes.flatMap { it.getFunctions(name, location) }
|
||||
}
|
||||
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KtType>, name: Name, location: LookupLocation): Collection<PropertyDescriptor> {
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KotlinType>, name: Name, location: LookupLocation): Collection<PropertyDescriptor> {
|
||||
return scopes.flatMap { it.getSyntheticExtensionProperties(receiverTypes, name, location) }
|
||||
}
|
||||
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<KtType>, name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<KotlinType>, name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
|
||||
return scopes.flatMap { it.getSyntheticExtensionFunctions(receiverTypes, name, location) }
|
||||
}
|
||||
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KtType>): Collection<PropertyDescriptor> {
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KotlinType>): Collection<PropertyDescriptor> {
|
||||
return scopes.flatMap { it.getSyntheticExtensionProperties(receiverTypes) }
|
||||
}
|
||||
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<KtType>): Collection<FunctionDescriptor> {
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<KotlinType>): Collection<FunctionDescriptor> {
|
||||
return scopes.flatMap { it.getSyntheticExtensionFunctions(receiverTypes) }
|
||||
}
|
||||
|
||||
|
||||
@@ -18,15 +18,15 @@ package org.jetbrains.kotlin.resolve;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
public class AnalyzerScriptParameter {
|
||||
@NotNull
|
||||
private final Name name;
|
||||
@NotNull
|
||||
private final KtType type;
|
||||
private final KotlinType type;
|
||||
|
||||
public AnalyzerScriptParameter(@NotNull Name name, @NotNull KtType type) {
|
||||
public AnalyzerScriptParameter(@NotNull Name name, @NotNull KotlinType type) {
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
}
|
||||
@@ -37,7 +37,7 @@ public class AnalyzerScriptParameter {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public KtType getType() {
|
||||
public KotlinType getType() {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getAnnotationEntries
|
||||
import org.jetbrains.kotlin.resolve.constants.ArrayValue
|
||||
import org.jetbrains.kotlin.resolve.constants.EnumValue
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.isRepeatableAnnotation
|
||||
import org.jetbrains.kotlin.descriptors.annotations.KotlinTarget.*
|
||||
@@ -71,7 +71,7 @@ public class AnnotationChecker(private val additionalCheckers: Iterable<Addition
|
||||
}
|
||||
|
||||
private fun checkEntries(entries: List<KtAnnotationEntry>, actualTargets: TargetList, trace: BindingTrace) {
|
||||
val entryTypesWithAnnotations = hashMapOf<KtType, MutableList<AnnotationUseSiteTarget?>>()
|
||||
val entryTypesWithAnnotations = hashMapOf<KotlinType, MutableList<AnnotationUseSiteTarget?>>()
|
||||
|
||||
for (entry in entries) {
|
||||
checkAnnotationEntry(entry, actualTargets, trace)
|
||||
|
||||
@@ -36,7 +36,7 @@ import org.jetbrains.kotlin.resolve.scopes.LexicalScope;
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
|
||||
import org.jetbrains.kotlin.storage.StorageManager;
|
||||
import org.jetbrains.kotlin.types.ErrorUtils;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.ArrayList;
|
||||
@@ -147,13 +147,13 @@ public class AnnotationResolver {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public KtType resolveAnnotationType(@NotNull LexicalScope scope, @NotNull KtAnnotationEntry entryElement, @NotNull BindingTrace trace) {
|
||||
public KotlinType resolveAnnotationType(@NotNull LexicalScope scope, @NotNull KtAnnotationEntry entryElement, @NotNull BindingTrace trace) {
|
||||
KtTypeReference typeReference = entryElement.getTypeReference();
|
||||
if (typeReference == null) {
|
||||
return ErrorUtils.createErrorType("No type reference: " + entryElement.getText());
|
||||
}
|
||||
|
||||
KtType type = typeResolver.resolveType(scope, typeReference, trace, true);
|
||||
KotlinType type = typeResolver.resolveType(scope, typeReference, trace, true);
|
||||
if (!(type.getConstructor().getDeclarationDescriptor() instanceof ClassDescriptor)) {
|
||||
return ErrorUtils.createErrorType("Not an annotation: " + type);
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ import org.jetbrains.kotlin.resolve.scopes.KtScope;
|
||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope;
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.Qualifier;
|
||||
import org.jetbrains.kotlin.types.DeferredType;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.expressions.CaptureKind;
|
||||
import org.jetbrains.kotlin.types.expressions.JetTypeInfo;
|
||||
import org.jetbrains.kotlin.types.expressions.PreliminaryDeclarationVisitor;
|
||||
@@ -77,7 +77,7 @@ public interface BindingContext {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public KtType getType(@NotNull KtExpression expression) {
|
||||
public KotlinType getType(@NotNull KtExpression expression) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -91,10 +91,10 @@ public interface BindingContext {
|
||||
|
||||
WritableSlice<KtExpression, CompileTimeConstant<?>> COMPILE_TIME_VALUE = Slices.createSimpleSlice();
|
||||
|
||||
WritableSlice<KtTypeReference, KtType> TYPE = Slices.createSimpleSlice();
|
||||
WritableSlice<KtTypeReference, KotlinType> TYPE = Slices.createSimpleSlice();
|
||||
WritableSlice<KtExpression, JetTypeInfo> EXPRESSION_TYPE_INFO = new BasicWritableSlice<KtExpression, JetTypeInfo>(DO_NOTHING);
|
||||
WritableSlice<KtExpression, KtType> EXPECTED_EXPRESSION_TYPE = new BasicWritableSlice<KtExpression, KtType>(DO_NOTHING);
|
||||
WritableSlice<KtFunction, KtType> EXPECTED_RETURN_TYPE = new BasicWritableSlice<KtFunction, KtType>(DO_NOTHING);
|
||||
WritableSlice<KtExpression, KotlinType> EXPECTED_EXPRESSION_TYPE = new BasicWritableSlice<KtExpression, KotlinType>(DO_NOTHING);
|
||||
WritableSlice<KtFunction, KotlinType> EXPECTED_RETURN_TYPE = new BasicWritableSlice<KtFunction, KotlinType>(DO_NOTHING);
|
||||
WritableSlice<KtExpression, DataFlowInfo> DATAFLOW_INFO_AFTER_CONDITION = Slices.createSimpleSlice();
|
||||
|
||||
/**
|
||||
@@ -131,7 +131,7 @@ public interface BindingContext {
|
||||
WritableSlice<KtExpression, ResolvedCall<FunctionDescriptor>> INDEXED_LVALUE_GET = Slices.createSimpleSlice();
|
||||
WritableSlice<KtExpression, ResolvedCall<FunctionDescriptor>> INDEXED_LVALUE_SET = Slices.createSimpleSlice();
|
||||
|
||||
WritableSlice<KtExpression, KtType> SMARTCAST = Slices.createSimpleSlice();
|
||||
WritableSlice<KtExpression, KotlinType> SMARTCAST = Slices.createSimpleSlice();
|
||||
|
||||
WritableSlice<KtWhenExpression, Boolean> EXHAUSTIVE_WHEN = Slices.createSimpleSlice();
|
||||
|
||||
@@ -256,7 +256,7 @@ public interface BindingContext {
|
||||
<K, V> ImmutableMap<K, V> getSliceContents(@NotNull ReadOnlySlice<K, V> slice);
|
||||
|
||||
@Nullable
|
||||
KtType getType(@NotNull KtExpression expression);
|
||||
KotlinType getType(@NotNull KtExpression expression);
|
||||
|
||||
void addOwnDataTo(@NotNull BindingTrace trace, boolean commitDiagnostics);
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.kotlin.resolve.calls.model.VariableAsFunctionResolvedCall;
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
|
||||
import org.jetbrains.kotlin.resolve.diagnostics.MutableDiagnosticsWithSuppression;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.TypeUtils;
|
||||
import org.jetbrains.kotlin.types.expressions.JetTypeInfo;
|
||||
import org.jetbrains.kotlin.types.expressions.typeInfoFactory.TypeInfoFactoryKt;
|
||||
@@ -81,11 +81,11 @@ public class BindingContextUtils {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static KtType getTypeNotNull(
|
||||
public static KotlinType getTypeNotNull(
|
||||
@NotNull BindingContext bindingContext,
|
||||
@NotNull KtExpression expression
|
||||
) {
|
||||
KtType result = bindingContext.getType(expression);
|
||||
KotlinType result = bindingContext.getType(expression);
|
||||
if (result == null) {
|
||||
throw new IllegalStateException("Type must be not null for " + expression);
|
||||
}
|
||||
@@ -140,8 +140,8 @@ public class BindingContextUtils {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static KtType updateRecordedType(
|
||||
@Nullable KtType type,
|
||||
public static KotlinType updateRecordedType(
|
||||
@Nullable KotlinType type,
|
||||
@NotNull KtExpression expression,
|
||||
@NotNull BindingTrace trace,
|
||||
boolean shouldBeMadeNullable
|
||||
|
||||
@@ -20,7 +20,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticSink;
|
||||
import org.jetbrains.kotlin.psi.KtExpression;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.util.slicedMap.ReadOnlySlice;
|
||||
import org.jetbrains.kotlin.util.slicedMap.WritableSlice;
|
||||
|
||||
@@ -47,11 +47,11 @@ public interface BindingTrace extends DiagnosticSink {
|
||||
* Expression type should be taken from EXPRESSION_TYPE_INFO slice
|
||||
*/
|
||||
@Nullable
|
||||
KtType getType(@NotNull KtExpression expression);
|
||||
KotlinType getType(@NotNull KtExpression expression);
|
||||
|
||||
/**
|
||||
* Expression type should be recorded into EXPRESSION_TYPE_INFO slice
|
||||
* (either updated old or a new one)
|
||||
*/
|
||||
void recordType(@NotNull KtExpression expression, @Nullable KtType type);
|
||||
void recordType(@NotNull KtExpression expression, @Nullable KotlinType type);
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.jetbrains.kotlin.diagnostics.Diagnostic;
|
||||
import org.jetbrains.kotlin.psi.KtExpression;
|
||||
import org.jetbrains.kotlin.resolve.diagnostics.Diagnostics;
|
||||
import org.jetbrains.kotlin.resolve.diagnostics.MutableDiagnosticsWithSuppression;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.expressions.JetTypeInfo;
|
||||
import org.jetbrains.kotlin.types.expressions.typeInfoFactory.TypeInfoFactoryKt;
|
||||
import org.jetbrains.kotlin.util.slicedMap.*;
|
||||
@@ -67,7 +67,7 @@ public class BindingTraceContext implements BindingTrace {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public KtType getType(@NotNull KtExpression expression) {
|
||||
public KotlinType getType(@NotNull KtExpression expression) {
|
||||
return BindingTraceContext.this.getType(expression);
|
||||
}
|
||||
|
||||
@@ -131,13 +131,13 @@ public class BindingTraceContext implements BindingTrace {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public KtType getType(@NotNull KtExpression expression) {
|
||||
public KotlinType getType(@NotNull KtExpression expression) {
|
||||
JetTypeInfo typeInfo = get(BindingContext.EXPRESSION_TYPE_INFO, expression);
|
||||
return typeInfo != null ? typeInfo.getType() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recordType(@NotNull KtExpression expression, @Nullable KtType type) {
|
||||
public void recordType(@NotNull KtExpression expression, @Nullable KotlinType type) {
|
||||
JetTypeInfo typeInfo = get(BindingContext.EXPRESSION_TYPE_INFO, expression);
|
||||
typeInfo = typeInfo != null ? typeInfo.replaceType(type) : TypeInfoFactoryKt.createTypeInfo(type);
|
||||
record(BindingContext.EXPRESSION_TYPE_INFO, expression, typeInfo);
|
||||
|
||||
@@ -262,10 +262,10 @@ public class BodyResolver {
|
||||
: FunctionDescriptorUtil.getFunctionInnerScope(scopeForSupertypeResolution, primaryConstructor, trace);
|
||||
final ExpressionTypingServices typeInferrer = expressionTypingServices; // TODO : flow
|
||||
|
||||
final Map<KtTypeReference, KtType> supertypes = Maps.newLinkedHashMap();
|
||||
final Map<KtTypeReference, KotlinType> supertypes = Maps.newLinkedHashMap();
|
||||
final ResolvedCall<?>[] primaryConstructorDelegationCall = new ResolvedCall[1];
|
||||
KtVisitorVoid visitor = new KtVisitorVoid() {
|
||||
private void recordSupertype(KtTypeReference typeReference, KtType supertype) {
|
||||
private void recordSupertype(KtTypeReference typeReference, KotlinType supertype) {
|
||||
if (supertype == null) return;
|
||||
supertypes.put(typeReference, supertype);
|
||||
}
|
||||
@@ -275,7 +275,7 @@ public class BodyResolver {
|
||||
if (descriptor.getKind() == ClassKind.INTERFACE) {
|
||||
trace.report(DELEGATION_IN_INTERFACE.on(specifier));
|
||||
}
|
||||
KtType supertype = trace.getBindingContext().get(BindingContext.TYPE, specifier.getTypeReference());
|
||||
KotlinType supertype = trace.getBindingContext().get(BindingContext.TYPE, specifier.getTypeReference());
|
||||
recordSupertype(specifier.getTypeReference(), supertype);
|
||||
if (supertype != null) {
|
||||
DeclarationDescriptor declarationDescriptor = supertype.getConstructor().getDeclarationDescriptor();
|
||||
@@ -289,7 +289,7 @@ public class BodyResolver {
|
||||
KtExpression delegateExpression = specifier.getDelegateExpression();
|
||||
if (delegateExpression != null) {
|
||||
LexicalScope scope = scopeForConstructor == null ? scopeForMemberResolution : scopeForConstructor;
|
||||
KtType expectedType = supertype != null ? supertype : NO_EXPECTED_TYPE;
|
||||
KotlinType expectedType = supertype != null ? supertype : NO_EXPECTED_TYPE;
|
||||
typeInferrer.getType(scope, delegateExpression, expectedType, outerDataFlowInfo, trace);
|
||||
}
|
||||
if (primaryConstructor == null) {
|
||||
@@ -317,7 +317,7 @@ public class BodyResolver {
|
||||
trace, scopeForConstructor,
|
||||
CallMaker.makeCall(ReceiverValue.NO_RECEIVER, null, call), NO_EXPECTED_TYPE, outerDataFlowInfo, false);
|
||||
if (results.isSuccess()) {
|
||||
KtType supertype = results.getResultingDescriptor().getReturnType();
|
||||
KotlinType supertype = results.getResultingDescriptor().getReturnType();
|
||||
recordSupertype(typeReference, supertype);
|
||||
ClassDescriptor classDescriptor = TypeUtils.getClassDescriptor(supertype);
|
||||
if (classDescriptor != null) {
|
||||
@@ -342,7 +342,7 @@ public class BodyResolver {
|
||||
@Override
|
||||
public void visitDelegationToSuperClassSpecifier(@NotNull KtDelegatorToSuperClass specifier) {
|
||||
KtTypeReference typeReference = specifier.getTypeReference();
|
||||
KtType supertype = trace.getBindingContext().get(BindingContext.TYPE, typeReference);
|
||||
KotlinType supertype = trace.getBindingContext().get(BindingContext.TYPE, typeReference);
|
||||
recordSupertype(typeReference, supertype);
|
||||
if (supertype == null) return;
|
||||
ClassDescriptor superClass = TypeUtils.getClassDescriptor(supertype);
|
||||
@@ -419,15 +419,15 @@ public class BodyResolver {
|
||||
|
||||
private void checkSupertypeList(
|
||||
@NotNull ClassDescriptor supertypeOwner,
|
||||
@NotNull Map<KtTypeReference, KtType> supertypes,
|
||||
@NotNull Map<KtTypeReference, KotlinType> supertypes,
|
||||
@NotNull KtClassOrObject jetClass
|
||||
) {
|
||||
Set<TypeConstructor> allowedFinalSupertypes = getAllowedFinalSupertypes(supertypeOwner, jetClass);
|
||||
Set<TypeConstructor> typeConstructors = Sets.newHashSet();
|
||||
boolean classAppeared = false;
|
||||
for (Map.Entry<KtTypeReference, KtType> entry : supertypes.entrySet()) {
|
||||
for (Map.Entry<KtTypeReference, KotlinType> entry : supertypes.entrySet()) {
|
||||
KtTypeReference typeReference = entry.getKey();
|
||||
KtType supertype = entry.getValue();
|
||||
KotlinType supertype = entry.getValue();
|
||||
|
||||
KtTypeElement typeElement = typeReference.getTypeElement();
|
||||
if (typeElement instanceof KtFunctionType) {
|
||||
@@ -709,7 +709,7 @@ public class BodyResolver {
|
||||
LexicalScope accessorScope = JetScopeUtils.makeScopeForPropertyAccessor(
|
||||
propertyDescriptor, parentScopeForAccessor, trace);
|
||||
|
||||
KtType delegateType = delegatedPropertyResolver.resolveDelegateExpression(
|
||||
KotlinType delegateType = delegatedPropertyResolver.resolveDelegateExpression(
|
||||
delegateExpression, jetProperty, propertyDescriptor, propertyDeclarationInnerScope, accessorScope, trace,
|
||||
outerDataFlowInfo);
|
||||
|
||||
@@ -734,7 +734,7 @@ public class BodyResolver {
|
||||
) {
|
||||
LexicalScope propertyDeclarationInnerScope = JetScopeUtils.getPropertyDeclarationInnerScopeForInitializer(
|
||||
propertyDescriptor, scope, propertyDescriptor.getTypeParameters(), null, trace);
|
||||
KtType expectedTypeForInitializer = property.getTypeReference() != null ? propertyDescriptor.getType() : NO_EXPECTED_TYPE;
|
||||
KotlinType expectedTypeForInitializer = property.getTypeReference() != null ? propertyDescriptor.getType() : NO_EXPECTED_TYPE;
|
||||
if (propertyDescriptor.getCompileTimeInitializer() == null) {
|
||||
expressionTypingServices.getType(propertyDeclarationInnerScope, initializer, expectedTypeForInitializer,
|
||||
outerDataFlowInfo, trace);
|
||||
@@ -850,7 +850,7 @@ public class BodyResolver {
|
||||
valueParameterResolver.resolveValueParameters(valueParameters, valueParameterDescriptors, scope, outerDataFlowInfo, trace);
|
||||
}
|
||||
|
||||
private static void computeDeferredType(KtType type) {
|
||||
private static void computeDeferredType(KotlinType type) {
|
||||
// handle type inference loop: function or property body contains a reference to itself
|
||||
// fun f() = { f() }
|
||||
// val x = x
|
||||
|
||||
@@ -35,7 +35,7 @@ import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant;
|
||||
import org.jetbrains.kotlin.resolve.constants.ConstantValue;
|
||||
import org.jetbrains.kotlin.resolve.constants.TypedCompileTimeConstant;
|
||||
import org.jetbrains.kotlin.resolve.constants.evaluate.ConstantExpressionEvaluator;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.TypeProjection;
|
||||
import org.jetbrains.kotlin.types.TypeUtils;
|
||||
|
||||
@@ -60,7 +60,7 @@ public class CompileTimeConstantUtils {
|
||||
for (KtParameter parameter : parameters) {
|
||||
VariableDescriptor parameterDescriptor = trace.getBindingContext().get(VALUE_PARAMETER, parameter);
|
||||
if (parameterDescriptor == null) continue;
|
||||
KtType parameterType = parameterDescriptor.getType();
|
||||
KotlinType parameterType = parameterDescriptor.getType();
|
||||
KtTypeReference typeReference = parameter.getTypeReference();
|
||||
if (typeReference != null) {
|
||||
if (parameterType.isMarkedNullable()) {
|
||||
@@ -73,7 +73,7 @@ public class CompileTimeConstantUtils {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isAcceptableTypeForAnnotationParameter(@NotNull KtType parameterType) {
|
||||
private static boolean isAcceptableTypeForAnnotationParameter(@NotNull KotlinType parameterType) {
|
||||
ClassDescriptor typeDescriptor = TypeUtils.getClassDescriptor(parameterType);
|
||||
if (typeDescriptor == null) {
|
||||
return false;
|
||||
@@ -91,7 +91,7 @@ public class CompileTimeConstantUtils {
|
||||
if (KotlinBuiltIns.isArray(parameterType)) {
|
||||
List<TypeProjection> arguments = parameterType.getArguments();
|
||||
if (arguments.size() == 1) {
|
||||
KtType arrayType = arguments.get(0).getType();
|
||||
KotlinType arrayType = arguments.get(0).getType();
|
||||
if (arrayType.isMarkedNullable()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -24,12 +24,12 @@ import com.intellij.psi.PsiElement
|
||||
import com.intellij.openapi.util.ModificationTracker
|
||||
import org.jetbrains.kotlin.psi.KtExpression
|
||||
import org.jetbrains.kotlin.resolve.diagnostics.Diagnostics
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
public class CompositeBindingContext private constructor(
|
||||
private val delegates: List<BindingContext>
|
||||
) : BindingContext {
|
||||
override fun getType(expression: KtExpression): KtType? {
|
||||
override fun getType(expression: KtExpression): KotlinType? {
|
||||
return delegates.asSequence().map { it.getType(expression) }.firstOrNull { it != null }
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.jetbrains.kotlin.descriptors.PropertyAccessorDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor;
|
||||
import org.jetbrains.kotlin.psi.*;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -52,7 +52,7 @@ public class ControlFlowAnalyzer {
|
||||
for (Map.Entry<KtNamedFunction, SimpleFunctionDescriptor> entry : c.getFunctions().entrySet()) {
|
||||
KtNamedFunction function = entry.getKey();
|
||||
SimpleFunctionDescriptor functionDescriptor = entry.getValue();
|
||||
KtType expectedReturnType = !function.hasBlockBody() && !function.hasDeclaredReturnType()
|
||||
KotlinType expectedReturnType = !function.hasBlockBody() && !function.hasDeclaredReturnType()
|
||||
? NO_EXPECTED_TYPE
|
||||
: functionDescriptor.getReturnType();
|
||||
checkFunction(c, function, expectedReturnType);
|
||||
@@ -87,12 +87,12 @@ public class ControlFlowAnalyzer {
|
||||
? propertyDescriptor.getGetter()
|
||||
: propertyDescriptor.getSetter();
|
||||
assert accessorDescriptor != null : "no property accessor descriptor " + accessor.getText();
|
||||
KtType returnType = accessorDescriptor.getReturnType();
|
||||
KotlinType returnType = accessorDescriptor.getReturnType();
|
||||
checkFunction(c, accessor, returnType);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkFunction(@NotNull BodiesResolveContext c, @NotNull KtDeclarationWithBody function, @Nullable KtType expectedReturnType) {
|
||||
private void checkFunction(@NotNull BodiesResolveContext c, @NotNull KtDeclarationWithBody function, @Nullable KotlinType expectedReturnType) {
|
||||
if (!function.hasBody()) return;
|
||||
JetFlowInformationProvider flowInformationProvider = new JetFlowInformationProvider(function, trace);
|
||||
if (c.getTopDownAnalysisMode().isLocalDeclarations()) {
|
||||
|
||||
@@ -168,7 +168,7 @@ public class DeclarationsChecker {
|
||||
|
||||
private void checkBoundsForTypeInClassHeader(@Nullable KtTypeReference typeReference) {
|
||||
if (typeReference != null) {
|
||||
KtType type = trace.getBindingContext().get(TYPE, typeReference);
|
||||
KotlinType type = trace.getBindingContext().get(TYPE, typeReference);
|
||||
if (type != null) {
|
||||
DescriptorResolver.checkBounds(typeReference, type, trace);
|
||||
}
|
||||
@@ -177,7 +177,7 @@ public class DeclarationsChecker {
|
||||
|
||||
private void checkFinalUpperBounds(@Nullable KtTypeReference typeReference) {
|
||||
if (typeReference != null) {
|
||||
KtType type = trace.getBindingContext().get(TYPE, typeReference);
|
||||
KotlinType type = trace.getBindingContext().get(TYPE, typeReference);
|
||||
if (type != null) {
|
||||
DescriptorResolver.checkUpperBoundType(typeReference, type, trace);
|
||||
}
|
||||
@@ -213,7 +213,7 @@ public class DeclarationsChecker {
|
||||
TypeParameterDescriptor typeParameterDescriptor = (TypeParameterDescriptor) declarationDescriptor;
|
||||
|
||||
// Immediate arguments of supertypes cannot be projected
|
||||
Set<KtType> conflictingTypes = Sets.newLinkedHashSet();
|
||||
Set<KotlinType> conflictingTypes = Sets.newLinkedHashSet();
|
||||
for (TypeProjection projection : projections) {
|
||||
conflictingTypes.add(projection.getType());
|
||||
}
|
||||
@@ -254,7 +254,7 @@ public class DeclarationsChecker {
|
||||
int i = 0;
|
||||
for (TypeParameterDescriptor typeParameterDescriptor : classDescriptor.getTypeConstructor().getParameters()) {
|
||||
if (i >= typeParameterList.size()) return;
|
||||
for (KtType upperBound : typeParameterDescriptor.getUpperBounds()) {
|
||||
for (KotlinType upperBound : typeParameterDescriptor.getUpperBounds()) {
|
||||
EffectiveVisibility upperBoundVisibility = EffectiveVisibility.Companion.forType(upperBound);
|
||||
if (!upperBoundVisibility.sameOrMorePermissive(classVisibility)) {
|
||||
KtTypeParameter typeParameter = typeParameterList.get(i);
|
||||
@@ -271,7 +271,7 @@ public class DeclarationsChecker {
|
||||
boolean isInterface = classDescriptor.getKind() == ClassKind.INTERFACE;
|
||||
List<KtDelegationSpecifier> delegationList = klass.getDelegationSpecifiers();
|
||||
int i = -1;
|
||||
for (KtType superType : classDescriptor.getTypeConstructor().getSupertypes()) {
|
||||
for (KotlinType superType : classDescriptor.getTypeConstructor().getSupertypes()) {
|
||||
i++;
|
||||
if (i >= delegationList.size()) return;
|
||||
ClassDescriptor superDescriptor = TypeUtils.getClassDescriptor(superType);
|
||||
@@ -294,10 +294,10 @@ public class DeclarationsChecker {
|
||||
}
|
||||
}
|
||||
|
||||
private static void removeDuplicateTypes(Set<KtType> conflictingTypes) {
|
||||
for (Iterator<KtType> iterator = conflictingTypes.iterator(); iterator.hasNext(); ) {
|
||||
KtType type = iterator.next();
|
||||
for (KtType otherType : conflictingTypes) {
|
||||
private static void removeDuplicateTypes(Set<KotlinType> conflictingTypes) {
|
||||
for (Iterator<KotlinType> iterator = conflictingTypes.iterator(); iterator.hasNext(); ) {
|
||||
KotlinType type = iterator.next();
|
||||
for (KotlinType otherType : conflictingTypes) {
|
||||
boolean subtypeOf = KotlinTypeChecker.DEFAULT.equalTypes(type, otherType);
|
||||
if (type != otherType && subtypeOf) {
|
||||
iterator.remove();
|
||||
@@ -524,9 +524,9 @@ public class DeclarationsChecker {
|
||||
ReceiverParameterDescriptor receiverParameter = descriptor.getExtensionReceiverParameter();
|
||||
if (receiverParameter == null) return false;
|
||||
|
||||
return TypeUtils.containsSpecialType(receiverParameter.getType(), new Function1<KtType, Boolean>() {
|
||||
return TypeUtils.containsSpecialType(receiverParameter.getType(), new Function1<KotlinType, Boolean>() {
|
||||
@Override
|
||||
public Boolean invoke(KtType type) {
|
||||
public Boolean invoke(KotlinType type) {
|
||||
return parameter.equals(type.getConstructor().getDeclarationDescriptor());
|
||||
}
|
||||
});
|
||||
@@ -545,7 +545,7 @@ public class DeclarationsChecker {
|
||||
boolean returnTypeIsNullable = true;
|
||||
boolean returnTypeIsPrimitive = true;
|
||||
|
||||
KtType returnType = propertyDescriptor.getReturnType();
|
||||
KotlinType returnType = propertyDescriptor.getReturnType();
|
||||
if (returnType != null) {
|
||||
returnTypeIsNullable = TypeUtils.isNullableType(returnType);
|
||||
returnTypeIsPrimitive = KotlinBuiltIns.isPrimitiveType(returnType);
|
||||
|
||||
@@ -37,7 +37,7 @@ import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver;
|
||||
import org.jetbrains.kotlin.resolve.validation.OperatorValidator;
|
||||
import org.jetbrains.kotlin.resolve.validation.SymbolUsageValidator;
|
||||
import org.jetbrains.kotlin.types.DeferredType;
|
||||
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.expressions.ExpressionTypingContext;
|
||||
@@ -83,10 +83,10 @@ public class DelegatedPropertyResolver {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public KtType getDelegatedPropertyGetMethodReturnType(
|
||||
public KotlinType getDelegatedPropertyGetMethodReturnType(
|
||||
@NotNull PropertyDescriptor propertyDescriptor,
|
||||
@NotNull KtExpression delegateExpression,
|
||||
@NotNull KtType delegateType,
|
||||
@NotNull KotlinType delegateType,
|
||||
@NotNull BindingTrace trace,
|
||||
@NotNull LexicalScope scope
|
||||
) {
|
||||
@@ -99,13 +99,13 @@ public class DelegatedPropertyResolver {
|
||||
public void resolveDelegatedPropertyGetMethod(
|
||||
@NotNull PropertyDescriptor propertyDescriptor,
|
||||
@NotNull KtExpression delegateExpression,
|
||||
@NotNull KtType delegateType,
|
||||
@NotNull KotlinType delegateType,
|
||||
@NotNull BindingTrace trace,
|
||||
@NotNull LexicalScope scope
|
||||
) {
|
||||
KtType returnType = getDelegatedPropertyGetMethodReturnType(
|
||||
KotlinType returnType = getDelegatedPropertyGetMethodReturnType(
|
||||
propertyDescriptor, delegateExpression, delegateType, trace, scope);
|
||||
KtType propertyType = propertyDescriptor.getType();
|
||||
KotlinType propertyType = propertyDescriptor.getType();
|
||||
|
||||
/* Do not check return type of get() method of delegate for properties with DeferredType because property type is taken from it */
|
||||
if (!(propertyType instanceof DeferredType) && returnType != null && !KotlinTypeChecker.DEFAULT.isSubtypeOf(returnType, propertyType)) {
|
||||
@@ -119,7 +119,7 @@ public class DelegatedPropertyResolver {
|
||||
public void resolveDelegatedPropertySetMethod(
|
||||
@NotNull PropertyDescriptor propertyDescriptor,
|
||||
@NotNull KtExpression delegateExpression,
|
||||
@NotNull KtType delegateType,
|
||||
@NotNull KotlinType delegateType,
|
||||
@NotNull BindingTrace trace,
|
||||
@NotNull LexicalScope scope
|
||||
) {
|
||||
@@ -134,7 +134,7 @@ public class DelegatedPropertyResolver {
|
||||
public void resolveDelegatedPropertyPDMethod(
|
||||
@NotNull PropertyDescriptor propertyDescriptor,
|
||||
@NotNull KtExpression delegateExpression,
|
||||
@NotNull KtType delegateType,
|
||||
@NotNull KotlinType delegateType,
|
||||
@NotNull BindingTrace trace,
|
||||
@NotNull LexicalScope scope
|
||||
) {
|
||||
@@ -172,7 +172,7 @@ public class DelegatedPropertyResolver {
|
||||
private void resolveDelegatedPropertyConventionMethod(
|
||||
@NotNull PropertyDescriptor propertyDescriptor,
|
||||
@NotNull KtExpression delegateExpression,
|
||||
@NotNull KtType delegateType,
|
||||
@NotNull KotlinType delegateType,
|
||||
@NotNull BindingTrace trace,
|
||||
@NotNull LexicalScope scope,
|
||||
boolean isGet
|
||||
@@ -231,7 +231,7 @@ public class DelegatedPropertyResolver {
|
||||
public OverloadResolutionResults<FunctionDescriptor> getDelegatedPropertyConventionMethod(
|
||||
@NotNull PropertyDescriptor propertyDescriptor,
|
||||
@NotNull KtExpression delegateExpression,
|
||||
@NotNull KtType delegateType,
|
||||
@NotNull KotlinType delegateType,
|
||||
@NotNull BindingTrace trace,
|
||||
@NotNull LexicalScope scope,
|
||||
boolean isGet,
|
||||
@@ -240,7 +240,7 @@ public class DelegatedPropertyResolver {
|
||||
PropertyAccessorDescriptor accessor = isGet ? propertyDescriptor.getGetter() : propertyDescriptor.getSetter();
|
||||
assert accessor != null : "Delegated property should have getter/setter " + propertyDescriptor + " " + delegateExpression.getText();
|
||||
|
||||
KtType expectedType = isComplete && isGet && !(propertyDescriptor.getType() instanceof DeferredType)
|
||||
KotlinType expectedType = isComplete && isGet && !(propertyDescriptor.getType() instanceof DeferredType)
|
||||
? propertyDescriptor.getType() : TypeUtils.NO_EXPECTED_TYPE;
|
||||
|
||||
ExpressionTypingContext context = ExpressionTypingContext.newContext(
|
||||
@@ -305,7 +305,7 @@ public class DelegatedPropertyResolver {
|
||||
assert calleeExpression != null : "CalleeExpression should exists for fake call of convention method";
|
||||
StringBuilder builder = new StringBuilder(calleeExpression.getText());
|
||||
builder.append("(");
|
||||
List<KtType> argumentTypes = Lists.newArrayList();
|
||||
List<KotlinType> argumentTypes = Lists.newArrayList();
|
||||
for (ValueArgument argument : call.getValueArguments()) {
|
||||
argumentTypes.add(context.getType(argument.getArgumentExpression()));
|
||||
|
||||
@@ -316,7 +316,7 @@ public class DelegatedPropertyResolver {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public KtType resolveDelegateExpression(
|
||||
public KotlinType resolveDelegateExpression(
|
||||
@NotNull KtExpression delegateExpression,
|
||||
@NotNull KtProperty jetProperty,
|
||||
@NotNull PropertyDescriptor propertyDescriptor,
|
||||
@@ -332,8 +332,8 @@ public class DelegatedPropertyResolver {
|
||||
if (calleeExpression != null) {
|
||||
traceToResolveDelegatedProperty.record(CONSTRAINT_SYSTEM_COMPLETER, calleeExpression, completer);
|
||||
}
|
||||
KtType delegateType = expressionTypingServices.safeGetType(propertyDeclarationInnerScope, delegateExpression, NO_EXPECTED_TYPE,
|
||||
dataFlowInfo, traceToResolveDelegatedProperty);
|
||||
KotlinType delegateType = expressionTypingServices.safeGetType(propertyDeclarationInnerScope, delegateExpression, NO_EXPECTED_TYPE,
|
||||
dataFlowInfo, traceToResolveDelegatedProperty);
|
||||
traceToResolveDelegatedProperty.commit(new TraceEntryFilter() {
|
||||
@Override
|
||||
public boolean accept(@Nullable WritableSlice<?, ?> slice, Object key) {
|
||||
@@ -351,13 +351,13 @@ public class DelegatedPropertyResolver {
|
||||
@NotNull final LexicalScope accessorScope,
|
||||
@NotNull final BindingTrace trace
|
||||
) {
|
||||
final KtType expectedType = property.getTypeReference() != null ? propertyDescriptor.getType() : NO_EXPECTED_TYPE;
|
||||
final KotlinType expectedType = property.getTypeReference() != null ? propertyDescriptor.getType() : NO_EXPECTED_TYPE;
|
||||
return new ConstraintSystemCompleter() {
|
||||
@Override
|
||||
public void completeConstraintSystem(
|
||||
@NotNull ConstraintSystem constraintSystem, @NotNull ResolvedCall<?> resolvedCall
|
||||
) {
|
||||
KtType returnType = resolvedCall.getCandidateDescriptor().getReturnType();
|
||||
KotlinType returnType = resolvedCall.getCandidateDescriptor().getReturnType();
|
||||
if (returnType == null) return;
|
||||
|
||||
TemporaryBindingTrace traceToResolveConventionMethods =
|
||||
@@ -370,7 +370,7 @@ public class DelegatedPropertyResolver {
|
||||
|
||||
if (conventionMethodFound(getMethodResults)) {
|
||||
FunctionDescriptor descriptor = getMethodResults.getResultingDescriptor();
|
||||
KtType returnTypeOfGetMethod = descriptor.getReturnType();
|
||||
KotlinType returnTypeOfGetMethod = descriptor.getReturnType();
|
||||
if (returnTypeOfGetMethod != null) {
|
||||
constraintSystem.addSupertypeConstraint(expectedType, returnTypeOfGetMethod, FROM_COMPLETER.position());
|
||||
}
|
||||
@@ -413,7 +413,7 @@ public class DelegatedPropertyResolver {
|
||||
private void addConstraintForThisValue(ConstraintSystem constraintSystem, FunctionDescriptor resultingDescriptor) {
|
||||
ReceiverParameterDescriptor extensionReceiver = propertyDescriptor.getExtensionReceiverParameter();
|
||||
ReceiverParameterDescriptor dispatchReceiver = propertyDescriptor.getDispatchReceiverParameter();
|
||||
KtType typeOfThis =
|
||||
KotlinType typeOfThis =
|
||||
extensionReceiver != null ? extensionReceiver.getType() :
|
||||
dispatchReceiver != null ? dispatchReceiver.getType() :
|
||||
builtIns.getNullableNothingType();
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.jetbrains.kotlin.diagnostics.Diagnostic;
|
||||
import org.jetbrains.kotlin.psi.KtExpression;
|
||||
import org.jetbrains.kotlin.resolve.diagnostics.Diagnostics;
|
||||
import org.jetbrains.kotlin.resolve.diagnostics.MutableDiagnosticsWithSuppression;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.expressions.JetTypeInfo;
|
||||
import org.jetbrains.kotlin.types.expressions.typeInfoFactory.TypeInfoFactoryKt;
|
||||
import org.jetbrains.kotlin.util.slicedMap.*;
|
||||
@@ -58,7 +58,7 @@ public class DelegatingBindingTrace implements BindingTrace {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public KtType getType(@NotNull KtExpression expression) {
|
||||
public KotlinType getType(@NotNull KtExpression expression) {
|
||||
return DelegatingBindingTrace.this.getType(expression);
|
||||
}
|
||||
|
||||
@@ -139,13 +139,13 @@ public class DelegatingBindingTrace implements BindingTrace {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public KtType getType(@NotNull KtExpression expression) {
|
||||
public KotlinType getType(@NotNull KtExpression expression) {
|
||||
JetTypeInfo typeInfo = get(BindingContext.EXPRESSION_TYPE_INFO, expression);
|
||||
return typeInfo != null ? typeInfo.getType() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recordType(@NotNull KtExpression expression, @Nullable KtType type) {
|
||||
public void recordType(@NotNull KtExpression expression, @Nullable KotlinType type) {
|
||||
JetTypeInfo typeInfo = get(BindingContext.EXPRESSION_TYPE_INFO, expression);
|
||||
if (typeInfo == null) {
|
||||
typeInfo = TypeInfoFactoryKt.createTypeInfo(type);
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.jetbrains.kotlin.psi.KtClassOrObject;
|
||||
import org.jetbrains.kotlin.psi.KtDelegationSpecifier;
|
||||
import org.jetbrains.kotlin.psi.KtDelegatorByExpressionSpecifier;
|
||||
import org.jetbrains.kotlin.psi.KtTypeReference;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.TypeUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -88,7 +88,7 @@ public final class DelegationResolver<T extends CallableMemberDescriptor> {
|
||||
if (typeReference == null) {
|
||||
continue;
|
||||
}
|
||||
KtType delegatedTraitType = typeResolver.resolve(typeReference);
|
||||
KotlinType delegatedTraitType = typeResolver.resolve(typeReference);
|
||||
if (delegatedTraitType == null || delegatedTraitType.isError()) {
|
||||
continue;
|
||||
}
|
||||
@@ -101,7 +101,7 @@ public final class DelegationResolver<T extends CallableMemberDescriptor> {
|
||||
@NotNull
|
||||
private Collection<T> generateDelegatesForTrait(
|
||||
@NotNull Collection<T> existingDelegates,
|
||||
@NotNull KtType delegatedTraitType
|
||||
@NotNull KotlinType delegatedTraitType
|
||||
) {
|
||||
Collection<T> result = new HashSet<T>();
|
||||
Collection<T> candidates = generateDelegationCandidates(delegatedTraitType);
|
||||
@@ -120,7 +120,7 @@ public final class DelegationResolver<T extends CallableMemberDescriptor> {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Collection<T> generateDelegationCandidates(@NotNull KtType delegatedTraitType) {
|
||||
private Collection<T> generateDelegationCandidates(@NotNull KotlinType delegatedTraitType) {
|
||||
Collection<T> descriptorsToDelegate = overridableMembersNotFromSuperClassOfTrait(delegatedTraitType);
|
||||
Collection<T> result = new ArrayList<T>(descriptorsToDelegate.size());
|
||||
for (T memberDescriptor : descriptorsToDelegate) {
|
||||
@@ -156,7 +156,7 @@ public final class DelegationResolver<T extends CallableMemberDescriptor> {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Collection<T> overridableMembersNotFromSuperClassOfTrait(@NotNull KtType trait) {
|
||||
private Collection<T> overridableMembersNotFromSuperClassOfTrait(@NotNull KotlinType trait) {
|
||||
final Collection<T> membersToSkip = getMembersFromClassSupertypeOfTrait(trait);
|
||||
return Collections2.filter(
|
||||
memberExtractor.getMembersByType(trait),
|
||||
@@ -182,9 +182,9 @@ public final class DelegationResolver<T extends CallableMemberDescriptor> {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Collection<T> getMembersFromClassSupertypeOfTrait(@NotNull KtType traitType) {
|
||||
KtType classSupertype = null;
|
||||
for (KtType supertype : TypeUtils.getAllSupertypes(traitType)) {
|
||||
private Collection<T> getMembersFromClassSupertypeOfTrait(@NotNull KotlinType traitType) {
|
||||
KotlinType classSupertype = null;
|
||||
for (KotlinType supertype : TypeUtils.getAllSupertypes(traitType)) {
|
||||
if (isNotTrait(supertype.getConstructor().getDeclarationDescriptor())) {
|
||||
classSupertype = supertype;
|
||||
break;
|
||||
@@ -203,11 +203,11 @@ public final class DelegationResolver<T extends CallableMemberDescriptor> {
|
||||
|
||||
public interface MemberExtractor<T extends CallableMemberDescriptor> {
|
||||
@NotNull
|
||||
Collection<T> getMembersByType(@NotNull KtType type);
|
||||
Collection<T> getMembersByType(@NotNull KotlinType type);
|
||||
}
|
||||
|
||||
public interface TypeResolver {
|
||||
@Nullable
|
||||
KtType resolve(@NotNull KtTypeReference reference);
|
||||
KotlinType resolve(@NotNull KtTypeReference reference);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,20 +96,20 @@ public class DescriptorResolver {
|
||||
this.constantExpressionEvaluator = constantExpressionEvaluator;
|
||||
}
|
||||
|
||||
public List<KtType> resolveSupertypes(
|
||||
public List<KotlinType> resolveSupertypes(
|
||||
@NotNull LexicalScope scope,
|
||||
@NotNull ClassDescriptor classDescriptor,
|
||||
@NotNull KtClassOrObject jetClass,
|
||||
BindingTrace trace
|
||||
) {
|
||||
List<KtType> supertypes = Lists.newArrayList();
|
||||
List<KotlinType> supertypes = Lists.newArrayList();
|
||||
List<KtDelegationSpecifier> delegationSpecifiers = jetClass.getDelegationSpecifiers();
|
||||
Collection<KtType> declaredSupertypes = resolveDelegationSpecifiers(
|
||||
Collection<KotlinType> declaredSupertypes = resolveDelegationSpecifiers(
|
||||
scope,
|
||||
delegationSpecifiers,
|
||||
typeResolver, trace, false);
|
||||
|
||||
for (KtType declaredSupertype : declaredSupertypes) {
|
||||
for (KotlinType declaredSupertype : declaredSupertypes) {
|
||||
addValidSupertype(supertypes, declaredSupertype);
|
||||
}
|
||||
|
||||
@@ -118,21 +118,21 @@ public class DescriptorResolver {
|
||||
}
|
||||
|
||||
if (supertypes.isEmpty()) {
|
||||
KtType defaultSupertype = getDefaultSupertype(jetClass, trace, classDescriptor.getKind() == ClassKind.ANNOTATION_CLASS);
|
||||
KotlinType defaultSupertype = getDefaultSupertype(jetClass, trace, classDescriptor.getKind() == ClassKind.ANNOTATION_CLASS);
|
||||
addValidSupertype(supertypes, defaultSupertype);
|
||||
}
|
||||
|
||||
return supertypes;
|
||||
}
|
||||
|
||||
private static void addValidSupertype(List<KtType> supertypes, KtType declaredSupertype) {
|
||||
private static void addValidSupertype(List<KotlinType> supertypes, KotlinType declaredSupertype) {
|
||||
if (!declaredSupertype.isError()) {
|
||||
supertypes.add(declaredSupertype);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean containsClass(Collection<KtType> result) {
|
||||
for (KtType type : result) {
|
||||
private boolean containsClass(Collection<KotlinType> result) {
|
||||
for (KotlinType type : result) {
|
||||
ClassifierDescriptor descriptor = type.getConstructor().getDeclarationDescriptor();
|
||||
if (descriptor instanceof ClassDescriptor && ((ClassDescriptor) descriptor).getKind() != ClassKind.INTERFACE) {
|
||||
return true;
|
||||
@@ -141,7 +141,7 @@ public class DescriptorResolver {
|
||||
return false;
|
||||
}
|
||||
|
||||
private KtType getDefaultSupertype(KtClassOrObject jetClass, BindingTrace trace, boolean isAnnotation) {
|
||||
private KotlinType getDefaultSupertype(KtClassOrObject jetClass, BindingTrace trace, boolean isAnnotation) {
|
||||
// TODO : beautify
|
||||
if (jetClass instanceof KtEnumEntry) {
|
||||
KtClassOrObject parent = KtStubbedPsiUtil.getContainingDeclaration(jetClass, KtClassOrObject.class);
|
||||
@@ -160,7 +160,7 @@ public class DescriptorResolver {
|
||||
return builtIns.getAnyType();
|
||||
}
|
||||
|
||||
public Collection<KtType> resolveDelegationSpecifiers(
|
||||
public Collection<KotlinType> resolveDelegationSpecifiers(
|
||||
LexicalScope extensibleScope,
|
||||
List<KtDelegationSpecifier> delegationSpecifiers,
|
||||
@NotNull TypeResolver resolver,
|
||||
@@ -170,11 +170,11 @@ public class DescriptorResolver {
|
||||
if (delegationSpecifiers.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
Collection<KtType> result = Lists.newArrayList();
|
||||
Collection<KotlinType> result = Lists.newArrayList();
|
||||
for (KtDelegationSpecifier delegationSpecifier : delegationSpecifiers) {
|
||||
KtTypeReference typeReference = delegationSpecifier.getTypeReference();
|
||||
if (typeReference != null) {
|
||||
KtType supertype = resolver.resolveType(extensibleScope, typeReference, trace, checkBounds);
|
||||
KotlinType supertype = resolver.resolveType(extensibleScope, typeReference, trace, checkBounds);
|
||||
if (DynamicTypesKt.isDynamic(supertype)) {
|
||||
trace.report(DYNAMIC_SUPERTYPE.on(typeReference));
|
||||
}
|
||||
@@ -225,7 +225,7 @@ public class DescriptorResolver {
|
||||
@NotNull BindingTrace trace
|
||||
) {
|
||||
Name functionName = DataClassUtilsKt.createComponentName(parameterIndex);
|
||||
KtType returnType = property.getType();
|
||||
KotlinType returnType = property.getType();
|
||||
|
||||
SimpleFunctionDescriptorImpl functionDescriptor = SimpleFunctionDescriptorImpl.create(
|
||||
classDescriptor,
|
||||
@@ -257,7 +257,7 @@ public class DescriptorResolver {
|
||||
@NotNull ClassDescriptor classDescriptor,
|
||||
@NotNull BindingTrace trace
|
||||
) {
|
||||
KtType returnType = classDescriptor.getDefaultType();
|
||||
KotlinType returnType = classDescriptor.getDefaultType();
|
||||
|
||||
SimpleFunctionDescriptorImpl functionDescriptor = SimpleFunctionDescriptorImpl.create(
|
||||
classDescriptor,
|
||||
@@ -333,10 +333,10 @@ public class DescriptorResolver {
|
||||
|
||||
@NotNull
|
||||
public ValueParameterDescriptorImpl resolveValueParameterDescriptor(
|
||||
LexicalScope scope, FunctionDescriptor owner, KtParameter valueParameter, int index, KtType type, BindingTrace trace
|
||||
LexicalScope scope, FunctionDescriptor owner, KtParameter valueParameter, int index, KotlinType type, BindingTrace trace
|
||||
) {
|
||||
KtType varargElementType = null;
|
||||
KtType variableType = type;
|
||||
KotlinType varargElementType = null;
|
||||
KotlinType variableType = type;
|
||||
if (valueParameter.hasModifier(VARARG_KEYWORD)) {
|
||||
varargElementType = type;
|
||||
variableType = getVarargParameterType(type);
|
||||
@@ -378,8 +378,8 @@ public class DescriptorResolver {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private KtType getVarargParameterType(@NotNull KtType elementType) {
|
||||
KtType primitiveArrayType = builtIns.getPrimitiveArrayJetTypeByPrimitiveJetType(elementType);
|
||||
private KotlinType getVarargParameterType(@NotNull KotlinType elementType) {
|
||||
KotlinType primitiveArrayType = builtIns.getPrimitiveArrayJetTypeByPrimitiveJetType(elementType);
|
||||
if (primitiveArrayType != null) {
|
||||
return primitiveArrayType;
|
||||
}
|
||||
@@ -449,21 +449,21 @@ public class DescriptorResolver {
|
||||
|
||||
static final class UpperBoundCheckerTask {
|
||||
KtTypeReference upperBound;
|
||||
KtType upperBoundType;
|
||||
KotlinType upperBoundType;
|
||||
|
||||
private UpperBoundCheckerTask(KtTypeReference upperBound, KtType upperBoundType) {
|
||||
private UpperBoundCheckerTask(KtTypeReference upperBound, KotlinType upperBoundType) {
|
||||
this.upperBound = upperBound;
|
||||
this.upperBoundType = upperBoundType;
|
||||
}
|
||||
}
|
||||
|
||||
public KtType resolveTypeParameterExtendsBound(
|
||||
public KotlinType resolveTypeParameterExtendsBound(
|
||||
@NotNull TypeParameterDescriptor typeParameterDescriptor,
|
||||
@NotNull KtTypeReference extendsBound,
|
||||
LexicalScope scope,
|
||||
BindingTrace trace
|
||||
) {
|
||||
KtType type = typeResolver.resolveType(scope, extendsBound, trace, false);
|
||||
KotlinType type = typeResolver.resolveType(scope, extendsBound, trace, false);
|
||||
if (type.getConstructor().equals(typeParameterDescriptor.getTypeConstructor())) {
|
||||
trace.report(Errors.CYCLIC_GENERIC_UPPER_BOUND.on(extendsBound));
|
||||
type = ErrorUtils.createErrorType("Cyclic upper bound: " + type);
|
||||
@@ -490,7 +490,7 @@ public class DescriptorResolver {
|
||||
|
||||
KtTypeReference extendsBound = jetTypeParameter.getExtendsBound();
|
||||
if (extendsBound != null) {
|
||||
KtType type = resolveTypeParameterExtendsBound(typeParameterDescriptor, extendsBound, scope, trace);
|
||||
KotlinType type = resolveTypeParameterExtendsBound(typeParameterDescriptor, extendsBound, scope, trace);
|
||||
typeParameterDescriptor.addUpperBound(type);
|
||||
deferredUpperBoundCheckerTasks.add(new UpperBoundCheckerTask(extendsBound, type));
|
||||
}
|
||||
@@ -503,7 +503,7 @@ public class DescriptorResolver {
|
||||
Name referencedName = subjectTypeParameterName.getReferencedNameAsName();
|
||||
TypeParameterDescriptorImpl typeParameterDescriptor = parameterByName.get(referencedName);
|
||||
KtTypeReference boundTypeReference = constraint.getBoundTypeReference();
|
||||
KtType bound = null;
|
||||
KotlinType bound = null;
|
||||
if (boundTypeReference != null) {
|
||||
bound = typeResolver.resolveType(scope, boundTypeReference, trace, false);
|
||||
deferredUpperBoundCheckerTasks.add(new UpperBoundCheckerTask(boundTypeReference, bound));
|
||||
@@ -577,7 +577,7 @@ public class DescriptorResolver {
|
||||
|
||||
public static void checkUpperBoundType(
|
||||
KtTypeReference upperBound,
|
||||
@NotNull KtType upperBoundType,
|
||||
@NotNull KotlinType upperBoundType,
|
||||
BindingTrace trace
|
||||
) {
|
||||
if (!TypeUtils.canHaveSubtypes(KotlinTypeChecker.DEFAULT, upperBoundType)) {
|
||||
@@ -598,13 +598,13 @@ public class DescriptorResolver {
|
||||
@NotNull KtParameter parameter,
|
||||
BindingTrace trace
|
||||
) {
|
||||
KtType type = resolveParameterType(scope, parameter, trace);
|
||||
KotlinType type = resolveParameterType(scope, parameter, trace);
|
||||
return resolveLocalVariableDescriptor(parameter, type, trace, scope);
|
||||
}
|
||||
|
||||
private KtType resolveParameterType(LexicalScope scope, KtParameter parameter, BindingTrace trace) {
|
||||
private KotlinType resolveParameterType(LexicalScope scope, KtParameter parameter, BindingTrace trace) {
|
||||
KtTypeReference typeReference = parameter.getTypeReference();
|
||||
KtType type;
|
||||
KotlinType type;
|
||||
if (typeReference != null) {
|
||||
type = typeResolver.resolveType(scope, typeReference, trace, true);
|
||||
}
|
||||
@@ -620,7 +620,7 @@ public class DescriptorResolver {
|
||||
|
||||
public VariableDescriptor resolveLocalVariableDescriptor(
|
||||
@NotNull KtParameter parameter,
|
||||
@NotNull KtType type,
|
||||
@NotNull KotlinType type,
|
||||
BindingTrace trace,
|
||||
@NotNull LexicalScope scope
|
||||
) {
|
||||
@@ -647,7 +647,7 @@ public class DescriptorResolver {
|
||||
) {
|
||||
DeclarationDescriptor containingDeclaration = scope.getOwnerDescriptor();
|
||||
VariableDescriptor result;
|
||||
KtType type;
|
||||
KotlinType type;
|
||||
// SCRIPT: Create property descriptors
|
||||
if (KtPsiUtil.isScriptDeclaration(variable)) {
|
||||
PropertyDescriptorImpl propertyDescriptor = PropertyDescriptorImpl.create(
|
||||
@@ -666,7 +666,7 @@ public class DescriptorResolver {
|
||||
type = getVariableType(propertyDescriptor, scope, variable, dataFlowInfo, false, trace);
|
||||
|
||||
ReceiverParameterDescriptor receiverParameter = ((ScriptDescriptor) containingDeclaration).getThisAsReceiverParameter();
|
||||
propertyDescriptor.setType(type, Collections.<TypeParameterDescriptor>emptyList(), receiverParameter, (KtType) null);
|
||||
propertyDescriptor.setType(type, Collections.<TypeParameterDescriptor>emptyList(), receiverParameter, (KotlinType) null);
|
||||
initializeWithDefaultGetterSetter(propertyDescriptor);
|
||||
trace.record(BindingContext.VARIABLE, variable, propertyDescriptor);
|
||||
result = propertyDescriptor;
|
||||
@@ -702,7 +702,7 @@ public class DescriptorResolver {
|
||||
public LocalVariableDescriptor resolveLocalVariableDescriptorWithType(
|
||||
@NotNull LexicalScope scope,
|
||||
@NotNull KtVariableDeclaration variable,
|
||||
@Nullable KtType type,
|
||||
@Nullable KotlinType type,
|
||||
@NotNull BindingTrace trace
|
||||
) {
|
||||
LocalVariableDescriptor variableDescriptor = new LocalVariableDescriptor(
|
||||
@@ -765,7 +765,7 @@ public class DescriptorResolver {
|
||||
|
||||
List<TypeParameterDescriptorImpl> typeParameterDescriptors;
|
||||
LexicalScope scopeWithTypeParameters;
|
||||
KtType receiverType = null;
|
||||
KotlinType receiverType = null;
|
||||
|
||||
{
|
||||
List<KtTypeParameter> typeParameters = property.getTypeParameters();
|
||||
@@ -798,7 +798,7 @@ public class DescriptorResolver {
|
||||
LexicalScope propertyScope = JetScopeUtils.getPropertyDeclarationInnerScope(propertyDescriptor, scope, typeParameterDescriptors,
|
||||
implicitInitializerReceiver, trace);
|
||||
|
||||
KtType type = getVariableType(propertyDescriptor, propertyScope, property, dataFlowInfo, true, trace);
|
||||
KotlinType type = getVariableType(propertyDescriptor, propertyScope, property, dataFlowInfo, true, trace);
|
||||
|
||||
propertyDescriptor.setType(type, typeParameterDescriptors, getDispatchReceiverParameterIfNeeded(containingDeclaration),
|
||||
receiverDescriptor);
|
||||
@@ -831,7 +831,7 @@ public class DescriptorResolver {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private KtType getVariableType(
|
||||
private KotlinType getVariableType(
|
||||
@NotNull final VariableDescriptorWithInitializerImpl variableDescriptor,
|
||||
@NotNull final LexicalScope scope,
|
||||
@NotNull final KtVariableDeclaration variable,
|
||||
@@ -850,9 +850,9 @@ public class DescriptorResolver {
|
||||
return DeferredType.createRecursionIntolerant(
|
||||
storageManager,
|
||||
trace,
|
||||
new Function0<KtType>() {
|
||||
new Function0<KotlinType>() {
|
||||
@Override
|
||||
public KtType invoke() {
|
||||
public KotlinType invoke() {
|
||||
return resolveDelegatedPropertyType(property, (PropertyDescriptor) variableDescriptor, scope,
|
||||
property.getDelegateExpression(), dataFlowInfo, trace);
|
||||
}
|
||||
@@ -869,11 +869,12 @@ public class DescriptorResolver {
|
||||
return DeferredType.createRecursionIntolerant(
|
||||
storageManager,
|
||||
trace,
|
||||
new Function0<KtType>() {
|
||||
new Function0<KotlinType>() {
|
||||
@Override
|
||||
public KtType invoke() {
|
||||
public KotlinType invoke() {
|
||||
PreliminaryDeclarationVisitor.Companion.createForDeclaration(variable, trace);
|
||||
KtType initializerType = resolveInitializerType(scope, variable.getInitializer(), dataFlowInfo, trace);
|
||||
KotlinType
|
||||
initializerType = resolveInitializerType(scope, variable.getInitializer(), dataFlowInfo, trace);
|
||||
setConstantForVariableIfNeeded(variableDescriptor, scope, variable, dataFlowInfo, initializerType, trace);
|
||||
return transformAnonymousTypeIfNeeded(variableDescriptor, variable, initializerType, trace);
|
||||
}
|
||||
@@ -881,14 +882,14 @@ public class DescriptorResolver {
|
||||
);
|
||||
}
|
||||
else {
|
||||
KtType initializerType = resolveInitializerType(scope, variable.getInitializer(), dataFlowInfo, trace);
|
||||
KotlinType initializerType = resolveInitializerType(scope, variable.getInitializer(), dataFlowInfo, trace);
|
||||
setConstantForVariableIfNeeded(variableDescriptor, scope, variable, dataFlowInfo, initializerType, trace);
|
||||
return initializerType;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
KtType type = typeResolver.resolveType(scope, propertyTypeRef, trace, true);
|
||||
KotlinType type = typeResolver.resolveType(scope, propertyTypeRef, trace, true);
|
||||
setConstantForVariableIfNeeded(variableDescriptor, scope, variable, dataFlowInfo, type, trace);
|
||||
return type;
|
||||
}
|
||||
@@ -899,7 +900,7 @@ public class DescriptorResolver {
|
||||
@NotNull final LexicalScope scope,
|
||||
@NotNull final KtVariableDeclaration variable,
|
||||
@NotNull final DataFlowInfo dataFlowInfo,
|
||||
@NotNull final KtType variableType,
|
||||
@NotNull final KotlinType variableType,
|
||||
@NotNull final BindingTrace trace
|
||||
) {
|
||||
if (!shouldRecordInitializerForProperty(variableDescriptor, variableType)) return;
|
||||
@@ -912,7 +913,7 @@ public class DescriptorResolver {
|
||||
@Override
|
||||
public ConstantValue<?> invoke() {
|
||||
KtExpression initializer = variable.getInitializer();
|
||||
KtType initializerType = expressionTypingServices.safeGetType(scope, initializer, variableType, dataFlowInfo, trace);
|
||||
KotlinType initializerType = expressionTypingServices.safeGetType(scope, initializer, variableType, dataFlowInfo, trace);
|
||||
CompileTimeConstant<?> constant = constantExpressionEvaluator.evaluateExpression(initializer, trace, initializerType);
|
||||
|
||||
if (constant == null) return null;
|
||||
@@ -928,7 +929,7 @@ public class DescriptorResolver {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private KtType resolveDelegatedPropertyType(
|
||||
private KotlinType resolveDelegatedPropertyType(
|
||||
@NotNull KtProperty property,
|
||||
@NotNull PropertyDescriptor propertyDescriptor,
|
||||
@NotNull LexicalScope scope,
|
||||
@@ -938,11 +939,11 @@ public class DescriptorResolver {
|
||||
) {
|
||||
LexicalScope accessorScope = JetScopeUtils.makeScopeForPropertyAccessor(propertyDescriptor, scope, trace);
|
||||
|
||||
KtType type = delegatedPropertyResolver.resolveDelegateExpression(
|
||||
KotlinType type = delegatedPropertyResolver.resolveDelegateExpression(
|
||||
delegateExpression, property, propertyDescriptor, scope, accessorScope, trace, dataFlowInfo);
|
||||
|
||||
if (type != null) {
|
||||
KtType getterReturnType = delegatedPropertyResolver
|
||||
KotlinType getterReturnType = delegatedPropertyResolver
|
||||
.getDelegatedPropertyGetMethodReturnType(propertyDescriptor, delegateExpression, type, trace, accessorScope);
|
||||
if (getterReturnType != null) {
|
||||
return getterReturnType;
|
||||
@@ -952,10 +953,10 @@ public class DescriptorResolver {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
/*package*/ static KtType transformAnonymousTypeIfNeeded(
|
||||
/*package*/ static KotlinType transformAnonymousTypeIfNeeded(
|
||||
@NotNull DeclarationDescriptorWithVisibility descriptor,
|
||||
@NotNull KtNamedDeclaration declaration,
|
||||
@NotNull KtType type,
|
||||
@NotNull KotlinType type,
|
||||
@NotNull BindingTrace trace
|
||||
) {
|
||||
ClassifierDescriptor classifier = type.getConstructor().getDeclarationDescriptor();
|
||||
@@ -977,7 +978,7 @@ public class DescriptorResolver {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private KtType resolveInitializerType(
|
||||
private KotlinType resolveInitializerType(
|
||||
@NotNull LexicalScope scope,
|
||||
@NotNull KtExpression initializer,
|
||||
@NotNull DataFlowInfo dataFlowInfo,
|
||||
@@ -1015,14 +1016,14 @@ public class DescriptorResolver {
|
||||
trace.report(SETTER_PARAMETER_WITH_DEFAULT_VALUE.on(parameter.getDefaultValue()));
|
||||
}
|
||||
|
||||
KtType type;
|
||||
KotlinType type;
|
||||
KtTypeReference typeReference = parameter.getTypeReference();
|
||||
if (typeReference == null) {
|
||||
type = propertyDescriptor.getType(); // TODO : this maybe unknown at this point
|
||||
}
|
||||
else {
|
||||
type = typeResolver.resolveType(scope, typeReference, trace, true);
|
||||
KtType inType = propertyDescriptor.getType();
|
||||
KotlinType inType = propertyDescriptor.getType();
|
||||
if (inType != null) {
|
||||
if (!TypeUtils.equalTypes(type, inType)) {
|
||||
trace.report(WRONG_SETTER_PARAMETER_TYPE.on(typeReference, inType, type));
|
||||
@@ -1073,8 +1074,8 @@ public class DescriptorResolver {
|
||||
annotationSplitter.getAnnotationsForTarget(PROPERTY_GETTER),
|
||||
annotationResolver.resolveAnnotationsWithoutArguments(scope, getter.getModifierList(), trace)));
|
||||
|
||||
KtType outType = propertyDescriptor.getType();
|
||||
KtType returnType = outType;
|
||||
KotlinType outType = propertyDescriptor.getType();
|
||||
KotlinType returnType = outType;
|
||||
KtTypeReference returnTypeReference = getter.getReturnTypeReference();
|
||||
if (returnTypeReference != null) {
|
||||
returnType = typeResolver.resolveType(scope, returnTypeReference, trace, true);
|
||||
@@ -1108,7 +1109,7 @@ public class DescriptorResolver {
|
||||
@NotNull LexicalScope scope,
|
||||
@NotNull KtParameter parameter, final BindingTrace trace
|
||||
) {
|
||||
KtType type = resolveParameterType(scope, parameter, trace);
|
||||
KotlinType type = resolveParameterType(scope, parameter, trace);
|
||||
Name name = parameter.getNameAsSafeName();
|
||||
boolean isMutable = parameter.isMutable();
|
||||
KtModifierList modifierList = parameter.getModifierList();
|
||||
@@ -1165,7 +1166,7 @@ public class DescriptorResolver {
|
||||
return propertyDescriptor;
|
||||
}
|
||||
|
||||
public static void checkBounds(@NotNull KtTypeReference typeReference, @NotNull KtType type, @NotNull BindingTrace trace) {
|
||||
public static void checkBounds(@NotNull KtTypeReference typeReference, @NotNull KotlinType type, @NotNull BindingTrace trace) {
|
||||
if (type.isError()) return;
|
||||
|
||||
KtTypeElement typeElement = typeReference.getTypeElement();
|
||||
@@ -1197,7 +1198,7 @@ public class DescriptorResolver {
|
||||
|
||||
if (jetTypeArgument == null) continue;
|
||||
|
||||
KtType typeArgument = arguments.get(i).getType();
|
||||
KotlinType typeArgument = arguments.get(i).getType();
|
||||
checkBounds(jetTypeArgument, typeArgument, trace);
|
||||
|
||||
TypeParameterDescriptor typeParameterDescriptor = parameters.get(i);
|
||||
@@ -1207,13 +1208,13 @@ public class DescriptorResolver {
|
||||
|
||||
public static void checkBounds(
|
||||
@NotNull KtTypeReference jetTypeArgument,
|
||||
@NotNull KtType typeArgument,
|
||||
@NotNull KotlinType typeArgument,
|
||||
@NotNull TypeParameterDescriptor typeParameterDescriptor,
|
||||
@NotNull TypeSubstitutor substitutor,
|
||||
@NotNull BindingTrace trace
|
||||
) {
|
||||
for (KtType bound : typeParameterDescriptor.getUpperBounds()) {
|
||||
KtType substitutedBound = substitutor.safeSubstitute(bound, Variance.INVARIANT);
|
||||
for (KotlinType bound : typeParameterDescriptor.getUpperBounds()) {
|
||||
KotlinType substitutedBound = substitutor.safeSubstitute(bound, Variance.INVARIANT);
|
||||
if (!KotlinTypeChecker.DEFAULT.isSubtypeOf(typeArgument, substitutedBound)) {
|
||||
trace.report(UPPER_BOUND_VIOLATED.on(jetTypeArgument, substitutedBound, typeArgument));
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ import org.jetbrains.kotlin.resolve.source.toSourceElement
|
||||
import org.jetbrains.kotlin.storage.StorageManager
|
||||
import org.jetbrains.kotlin.types.DeferredType
|
||||
import org.jetbrains.kotlin.types.ErrorUtils
|
||||
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.expressions.ExpressionTypingServices
|
||||
@@ -84,7 +84,7 @@ class FunctionDescriptorResolver(
|
||||
function: KtNamedFunction,
|
||||
trace: BindingTrace,
|
||||
dataFlowInfo: DataFlowInfo,
|
||||
expectedFunctionType: KtType
|
||||
expectedFunctionType: KotlinType
|
||||
): SimpleFunctionDescriptor = resolveFunctionDescriptor(
|
||||
::FunctionExpressionDescriptor, containingDescriptor, scope, function, trace, dataFlowInfo, expectedFunctionType)
|
||||
|
||||
@@ -95,7 +95,7 @@ class FunctionDescriptorResolver(
|
||||
function: KtNamedFunction,
|
||||
trace: BindingTrace,
|
||||
dataFlowInfo: DataFlowInfo,
|
||||
expectedFunctionType: KtType
|
||||
expectedFunctionType: KotlinType
|
||||
): SimpleFunctionDescriptor {
|
||||
val functionDescriptor = functionConstructor(
|
||||
containingDescriptor,
|
||||
@@ -143,7 +143,7 @@ class FunctionDescriptorResolver(
|
||||
function: KtFunction,
|
||||
functionDescriptor: SimpleFunctionDescriptorImpl,
|
||||
trace: BindingTrace,
|
||||
expectedFunctionType: KtType
|
||||
expectedFunctionType: KotlinType
|
||||
) {
|
||||
val innerScope = LexicalWritableScope(scope, functionDescriptor, true, null,
|
||||
TraceBasedRedeclarationHandler(trace), "Function descriptor header scope")
|
||||
@@ -194,7 +194,7 @@ class FunctionDescriptorResolver(
|
||||
functionDescriptor: SimpleFunctionDescriptorImpl,
|
||||
innerScope: LexicalWritableScope,
|
||||
trace: BindingTrace,
|
||||
expectedFunctionType: KtType
|
||||
expectedFunctionType: KotlinType
|
||||
): List<ValueParameterDescriptor> {
|
||||
val expectedValueParameters = expectedFunctionType.getValueParameters(functionDescriptor)
|
||||
if (expectedValueParameters != null) {
|
||||
@@ -225,11 +225,11 @@ class FunctionDescriptorResolver(
|
||||
)
|
||||
}
|
||||
|
||||
private fun KtType.functionTypeExpected() = !TypeUtils.noExpectedType(this) && KotlinBuiltIns.isFunctionOrExtensionFunctionType(this)
|
||||
private fun KtType.getReceiverType(): KtType? =
|
||||
private fun KotlinType.functionTypeExpected() = !TypeUtils.noExpectedType(this) && KotlinBuiltIns.isFunctionOrExtensionFunctionType(this)
|
||||
private fun KotlinType.getReceiverType(): KotlinType? =
|
||||
if (functionTypeExpected()) KotlinBuiltIns.getReceiverType(this) else null
|
||||
|
||||
private fun KtType.getValueParameters(owner: FunctionDescriptor): List<ValueParameterDescriptor>? =
|
||||
private fun KotlinType.getValueParameters(owner: FunctionDescriptor): List<ValueParameterDescriptor>? =
|
||||
if (functionTypeExpected()) KotlinBuiltIns.getValueParameters(owner, this) else null
|
||||
|
||||
public fun resolvePrimaryConstructorDescriptor(
|
||||
@@ -322,7 +322,7 @@ class FunctionDescriptorResolver(
|
||||
val typeReference = valueParameter.getTypeReference()
|
||||
val expectedType = expectedValueParameters?.let { if (i < it.size()) it[i].getType() else null }
|
||||
|
||||
val type: KtType
|
||||
val type: KotlinType
|
||||
if (typeReference != null) {
|
||||
type = typeResolver.resolveType(parameterScope, typeReference, trace, true)
|
||||
if (expectedType != null && !TypeUtils.noExpectedType(expectedType)) {
|
||||
|
||||
@@ -38,7 +38,7 @@ public class FunctionDescriptorUtil {
|
||||
private static final TypeSubstitutor MAKE_TYPE_PARAMETERS_FRESH = TypeSubstitutor.create(new TypeSubstitution() {
|
||||
|
||||
@Override
|
||||
public TypeProjection get(@NotNull KtType key) {
|
||||
public TypeProjection get(@NotNull KotlinType key) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ public class FunctionDescriptorUtil {
|
||||
|
||||
public static TypeSubstitution createSubstitution(
|
||||
@NotNull FunctionDescriptor functionDescriptor,
|
||||
@NotNull List<KtType> typeArguments
|
||||
@NotNull List<KotlinType> typeArguments
|
||||
) {
|
||||
if (functionDescriptor.getTypeParameters().isEmpty()) return TypeSubstitution.getEMPTY();
|
||||
|
||||
@@ -90,7 +90,7 @@ public class FunctionDescriptorUtil {
|
||||
|
||||
public static void initializeFromFunctionType(
|
||||
@NotNull FunctionDescriptorImpl functionDescriptor,
|
||||
@NotNull KtType functionType,
|
||||
@NotNull KotlinType functionType,
|
||||
@Nullable ReceiverParameterDescriptor dispatchReceiverParameter,
|
||||
@NotNull Modality modality,
|
||||
@NotNull Visibility visibility
|
||||
@@ -129,7 +129,7 @@ public class FunctionDescriptorUtil {
|
||||
List<ValueParameterDescriptor> parameters = new ArrayList<ValueParameterDescriptor>(newParameters.size());
|
||||
int idx = 0;
|
||||
for (ValueParameterDescriptor parameter : newParameters) {
|
||||
KtType returnType = parameter.getReturnType();
|
||||
KotlinType returnType = parameter.getReturnType();
|
||||
assert returnType != null;
|
||||
|
||||
parameters.add(
|
||||
|
||||
@@ -21,7 +21,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic;
|
||||
import org.jetbrains.kotlin.psi.KtExpression;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.util.slicedMap.ReadOnlySlice;
|
||||
import org.jetbrains.kotlin.util.slicedMap.WritableSlice;
|
||||
|
||||
@@ -78,12 +78,12 @@ public class ObservableBindingTrace implements BindingTrace {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public KtType getType(@NotNull KtExpression expression) {
|
||||
public KotlinType getType(@NotNull KtExpression expression) {
|
||||
return originalTrace.getType(expression);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recordType(@NotNull KtExpression expression, @Nullable KtType type) {
|
||||
public void recordType(@NotNull KtExpression expression, @Nullable KotlinType type) {
|
||||
originalTrace.recordType(expression, type);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ import org.jetbrains.kotlin.descriptors.CallableDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.ConstructorDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.TypeCapabilitiesKt;
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
|
||||
|
||||
@@ -65,12 +65,12 @@ public class OverloadUtil {
|
||||
return receiverAndParameterResult;
|
||||
}
|
||||
|
||||
List<KtType> superValueParameters = OverridingUtil.compiledValueParameters(superDescriptor);
|
||||
List<KtType> subValueParameters = OverridingUtil.compiledValueParameters(subDescriptor);
|
||||
List<KotlinType> superValueParameters = OverridingUtil.compiledValueParameters(superDescriptor);
|
||||
List<KotlinType> subValueParameters = OverridingUtil.compiledValueParameters(subDescriptor);
|
||||
|
||||
for (int i = 0; i < superValueParameters.size(); ++i) {
|
||||
KtType superValueParameterType = OverridingUtil.getUpperBound(superValueParameters.get(i));
|
||||
KtType subValueParameterType = OverridingUtil.getUpperBound(subValueParameters.get(i));
|
||||
KotlinType superValueParameterType = OverridingUtil.getUpperBound(superValueParameters.get(i));
|
||||
KotlinType subValueParameterType = OverridingUtil.getUpperBound(subValueParameters.get(i));
|
||||
if (!KotlinTypeChecker.DEFAULT.equalTypes(superValueParameterType, subValueParameterType)
|
||||
|| TypeCapabilitiesKt.oneMoreSpecificThanAnother(subValueParameterType, superValueParameterType)) {
|
||||
return OverridingUtil.OverrideCompatibilityInfo
|
||||
|
||||
@@ -235,13 +235,13 @@ public class OverrideResolver {
|
||||
|
||||
private static List<CallableMemberDescriptor> getCallableMembersFromSupertypes(ClassDescriptor classDescriptor) {
|
||||
Set<CallableMemberDescriptor> r = Sets.newLinkedHashSet();
|
||||
for (KtType supertype : classDescriptor.getTypeConstructor().getSupertypes()) {
|
||||
for (KotlinType supertype : classDescriptor.getTypeConstructor().getSupertypes()) {
|
||||
r.addAll(getCallableMembersFromType(supertype));
|
||||
}
|
||||
return new ArrayList<CallableMemberDescriptor>(r);
|
||||
}
|
||||
|
||||
private static List<CallableMemberDescriptor> getCallableMembersFromType(KtType type) {
|
||||
private static List<CallableMemberDescriptor> getCallableMembersFromType(KotlinType type) {
|
||||
List<CallableMemberDescriptor> r = Lists.newArrayList();
|
||||
for (DeclarationDescriptor decl : type.getMemberScope().getAllDescriptors()) {
|
||||
if (decl instanceof PropertyDescriptor || decl instanceof SimpleFunctionDescriptor) {
|
||||
@@ -687,13 +687,13 @@ public class OverrideResolver {
|
||||
TypeSubstitutor typeSubstitutor = prepareTypeSubstitutor(superDescriptor, subDescriptor);
|
||||
if (typeSubstitutor == null) return false;
|
||||
|
||||
KtType superReturnType = superDescriptor.getReturnType();
|
||||
KotlinType superReturnType = superDescriptor.getReturnType();
|
||||
assert superReturnType != null;
|
||||
|
||||
KtType subReturnType = subDescriptor.getReturnType();
|
||||
KotlinType subReturnType = subDescriptor.getReturnType();
|
||||
assert subReturnType != null;
|
||||
|
||||
KtType substitutedSuperReturnType = typeSubstitutor.substitute(superReturnType, Variance.OUT_VARIANCE);
|
||||
KotlinType substitutedSuperReturnType = typeSubstitutor.substitute(superReturnType, Variance.OUT_VARIANCE);
|
||||
assert substitutedSuperReturnType != null;
|
||||
|
||||
return KotlinTypeChecker.DEFAULT.isSubtypeOf(subReturnType, substitutedSuperReturnType);
|
||||
@@ -725,7 +725,7 @@ public class OverrideResolver {
|
||||
|
||||
if (!superDescriptor.isVar()) return true;
|
||||
|
||||
KtType substitutedSuperReturnType = typeSubstitutor.substitute(superDescriptor.getType(), Variance.OUT_VARIANCE);
|
||||
KotlinType substitutedSuperReturnType = typeSubstitutor.substitute(superDescriptor.getType(), Variance.OUT_VARIANCE);
|
||||
assert substitutedSuperReturnType != null;
|
||||
return KotlinTypeChecker.DEFAULT.equalTypes(subDescriptor.getType(), substitutedSuperReturnType);
|
||||
}
|
||||
@@ -792,7 +792,7 @@ public class OverrideResolver {
|
||||
@NotNull CallableMemberDescriptor declared,
|
||||
@NotNull ClassDescriptor declaringClass
|
||||
) {
|
||||
for (KtType supertype : declaringClass.getTypeConstructor().getSupertypes()) {
|
||||
for (KotlinType supertype : declaringClass.getTypeConstructor().getSupertypes()) {
|
||||
Set<CallableMemberDescriptor> all = Sets.newLinkedHashSet();
|
||||
all.addAll(supertype.getMemberScope().getFunctions(declared.getName(), NoLookupLocation.UNSORTED));
|
||||
//noinspection unchecked
|
||||
|
||||
@@ -48,15 +48,15 @@ public class PossiblyBareType {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static PossiblyBareType type(@NotNull KtType actualType) {
|
||||
public static PossiblyBareType type(@NotNull KotlinType actualType) {
|
||||
return new PossiblyBareType(actualType, null, false);
|
||||
}
|
||||
|
||||
private final KtType actualType;
|
||||
private final KotlinType actualType;
|
||||
private final TypeConstructor bareTypeConstructor;
|
||||
private final boolean nullable;
|
||||
|
||||
private PossiblyBareType(@Nullable KtType actualType, @Nullable TypeConstructor bareTypeConstructor, boolean nullable) {
|
||||
private PossiblyBareType(@Nullable KotlinType actualType, @Nullable TypeConstructor bareTypeConstructor, boolean nullable) {
|
||||
this.actualType = actualType;
|
||||
this.bareTypeConstructor = bareTypeConstructor;
|
||||
this.nullable = nullable;
|
||||
@@ -67,7 +67,7 @@ public class PossiblyBareType {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public KtType getActualType() {
|
||||
public KotlinType getActualType() {
|
||||
//noinspection ConstantConditions
|
||||
return actualType;
|
||||
}
|
||||
@@ -95,18 +95,18 @@ public class PossiblyBareType {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public TypeReconstructionResult reconstruct(@NotNull KtType subjectType) {
|
||||
public TypeReconstructionResult reconstruct(@NotNull KotlinType subjectType) {
|
||||
if (!isBare()) return new TypeReconstructionResult(getActualType(), true);
|
||||
|
||||
TypeReconstructionResult reconstructionResult = CastDiagnosticsUtil.findStaticallyKnownSubtype(
|
||||
TypeUtils.makeNotNullable(subjectType),
|
||||
getBareTypeConstructor()
|
||||
);
|
||||
KtType type = reconstructionResult.getResultingType();
|
||||
KotlinType type = reconstructionResult.getResultingType();
|
||||
// No need to make an absent type nullable
|
||||
if (type == null) return reconstructionResult;
|
||||
|
||||
KtType resultingType = TypeUtils.makeNullableAsSpecified(type, isBareTypeNullable());
|
||||
KotlinType resultingType = TypeUtils.makeNullableAsSpecified(type, isBareTypeNullable());
|
||||
return new TypeReconstructionResult(resultingType, reconstructionResult.isAllArgumentsInferred());
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.psi.KtScript;
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
|
||||
import org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil;
|
||||
import org.jetbrains.kotlin.types.ErrorUtils;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.expressions.CoercionStrategy;
|
||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingContext;
|
||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices;
|
||||
@@ -52,7 +52,7 @@ public class ScriptBodyResolver {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public KtType resolveScriptReturnType(
|
||||
public KotlinType resolveScriptReturnType(
|
||||
@NotNull KtScript script,
|
||||
@NotNull ScriptDescriptor scriptDescriptor,
|
||||
@NotNull BindingTrace trace
|
||||
@@ -65,7 +65,7 @@ public class ScriptBodyResolver {
|
||||
NO_EXPECTED_TYPE
|
||||
);
|
||||
PreliminaryDeclarationVisitor.Companion.createForDeclaration(script, trace);
|
||||
KtType returnType = expressionTypingServices.getBlockReturnedType(script.getBlockExpression(), CoercionStrategy.NO_COERCION, context).getType();
|
||||
KotlinType returnType = expressionTypingServices.getBlockReturnedType(script.getBlockExpression(), CoercionStrategy.NO_COERCION, context).getType();
|
||||
if (returnType == null) {
|
||||
returnType = ErrorUtils.createErrorType("getBlockReturnedType returned null");
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.resolve.typeBinding
|
||||
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.psi.KtTypeElement
|
||||
@@ -30,7 +30,7 @@ import org.jetbrains.kotlin.types.TypeProjectionImpl
|
||||
|
||||
interface TypeBinding<out P : PsiElement> {
|
||||
val psiElement: P
|
||||
val jetType: KtType
|
||||
val jetType: KotlinType
|
||||
fun getArgumentBindings(): List<TypeArgumentBinding<P>?>
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ private class TypeArgumentBindingImpl<out P: PsiElement>(
|
||||
private class ExplicitTypeBinding(
|
||||
private val trace: BindingContext,
|
||||
override val psiElement: KtTypeElement,
|
||||
override val jetType: KtType
|
||||
override val jetType: KotlinType
|
||||
) : TypeBinding<KtTypeElement> {
|
||||
|
||||
override fun getArgumentBindings(): List<TypeArgumentBinding<KtTypeElement>?> {
|
||||
@@ -111,7 +111,7 @@ private class ExplicitTypeBinding(
|
||||
private class NoTypeElementBinding<out P : PsiElement>(
|
||||
private val trace: BindingContext,
|
||||
override val psiElement: P,
|
||||
override val jetType: KtType
|
||||
override val jetType: KotlinType
|
||||
): TypeBinding<P> {
|
||||
|
||||
override fun getArgumentBindings(): List<TypeArgumentBinding<P>?> {
|
||||
|
||||
@@ -62,12 +62,12 @@ public class TypeResolver(
|
||||
}
|
||||
}
|
||||
|
||||
public fun resolveType(scope: LexicalScope, typeReference: KtTypeReference, trace: BindingTrace, checkBounds: Boolean): KtType {
|
||||
public fun resolveType(scope: LexicalScope, typeReference: KtTypeReference, trace: BindingTrace, checkBounds: Boolean): KotlinType {
|
||||
// bare types are not allowed
|
||||
return resolveType(TypeResolutionContext(scope, trace, checkBounds, false), typeReference)
|
||||
}
|
||||
|
||||
private fun resolveType(c: TypeResolutionContext, typeReference: KtTypeReference): KtType {
|
||||
private fun resolveType(c: TypeResolutionContext, typeReference: KtTypeReference): KotlinType {
|
||||
assert(!c.allowBareTypes) { "Use resolvePossiblyBareType() when bare types are allowed" }
|
||||
return resolvePossiblyBareType(c, typeReference).getActualType()
|
||||
}
|
||||
@@ -136,7 +136,7 @@ public class TypeResolver(
|
||||
*
|
||||
* todo: find another way after release
|
||||
*/
|
||||
private fun forceResolveTypeContents(type: KtType) {
|
||||
private fun forceResolveTypeContents(type: KotlinType) {
|
||||
type.annotations // force read type annotations
|
||||
if (type.isFlexible()) {
|
||||
forceResolveTypeContents(type.flexibility().lowerBound)
|
||||
@@ -180,7 +180,7 @@ public class TypeResolver(
|
||||
result = if (scopeForTypeParameter is ErrorUtils.ErrorScope)
|
||||
type(ErrorUtils.createErrorType("?"))
|
||||
else
|
||||
type(KtTypeImpl.create(
|
||||
type(KotlinTypeImpl.create(
|
||||
annotations,
|
||||
classifierDescriptor.getTypeConstructor(),
|
||||
TypeUtils.hasNullableLowerBound(classifierDescriptor),
|
||||
@@ -234,7 +234,7 @@ public class TypeResolver(
|
||||
)
|
||||
return
|
||||
}
|
||||
val resultingType = KtTypeImpl.create(annotations, classifierDescriptor, false, arguments)
|
||||
val resultingType = KotlinTypeImpl.create(annotations, classifierDescriptor, false, arguments)
|
||||
result = type(resultingType)
|
||||
if (c.checkBounds) {
|
||||
val substitutor = TypeSubstitutor.create(resultingType)
|
||||
|
||||
@@ -32,7 +32,7 @@ import org.jetbrains.kotlin.resolve.typeBinding.createTypeBindingForReturnType
|
||||
import org.jetbrains.kotlin.psi.KtCallableDeclaration
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
import org.jetbrains.kotlin.resolve.TopDownAnalysisContext
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.psi.KtClass
|
||||
import org.jetbrains.kotlin.psi.KtTypeReference
|
||||
import org.jetbrains.kotlin.types.Variance.*
|
||||
@@ -74,7 +74,7 @@ class VarianceChecker(private val trace: BindingTrace) {
|
||||
}
|
||||
|
||||
class VarianceConflictDiagnosticData(
|
||||
val containingType: KtType,
|
||||
val containingType: KotlinType,
|
||||
val typeParameter: TypeParameterDescriptor,
|
||||
val occurrencePosition: Variance
|
||||
)
|
||||
@@ -158,7 +158,7 @@ class VarianceChecker(private val trace: BindingTrace) {
|
||||
private fun TypeBinding<PsiElement>.checkTypePosition(position: Variance, diagnosticSink: DiagnosticSink)
|
||||
= checkTypePosition(jetType, position, diagnosticSink)
|
||||
|
||||
private fun TypeBinding<PsiElement>.checkTypePosition(containingType: KtType, position: Variance, diagnosticSink: DiagnosticSink): Boolean {
|
||||
private fun TypeBinding<PsiElement>.checkTypePosition(containingType: KotlinType, position: Variance, diagnosticSink: DiagnosticSink): Boolean {
|
||||
val classifierDescriptor = jetType.getConstructor().getDeclarationDescriptor()
|
||||
if (classifierDescriptor is TypeParameterDescriptor) {
|
||||
val declarationVariance = classifierDescriptor.getVariance()
|
||||
|
||||
+17
-17
@@ -46,7 +46,7 @@ import org.jetbrains.kotlin.resolve.scopes.receivers.TransientReceiver
|
||||
import org.jetbrains.kotlin.resolve.scopes.utils.memberScopeAsFileScope
|
||||
import org.jetbrains.kotlin.resolve.source.toSourceElement
|
||||
import org.jetbrains.kotlin.types.FunctionPlaceholders
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils
|
||||
import org.jetbrains.kotlin.utils.ThrowingList
|
||||
@@ -55,7 +55,7 @@ public fun resolveCallableReferenceReceiverType(
|
||||
callableReferenceExpression: KtCallableReferenceExpression,
|
||||
context: ResolutionContext<*>,
|
||||
typeResolver: TypeResolver
|
||||
): KtType? =
|
||||
): KotlinType? =
|
||||
callableReferenceExpression.typeReference?.let {
|
||||
typeResolver.resolveType(context.scope, it, context.trace, false)
|
||||
}
|
||||
@@ -93,7 +93,7 @@ private fun OverloadResolutionResults<*>.isSomething(): Boolean = !isNothing()
|
||||
|
||||
public fun resolvePossiblyAmbiguousCallableReference(
|
||||
callableReferenceExpression: KtCallableReferenceExpression,
|
||||
lhsType: KtType?,
|
||||
lhsType: KotlinType?,
|
||||
context: ResolutionContext<*>,
|
||||
resolutionMode: ResolveArgumentsMode,
|
||||
callResolver: CallResolver
|
||||
@@ -142,7 +142,7 @@ public fun resolvePossiblyAmbiguousCallableReference(
|
||||
|
||||
public fun resolveCallableReferenceTarget(
|
||||
callableReferenceExpression: KtCallableReferenceExpression,
|
||||
lhsType: KtType?,
|
||||
lhsType: KotlinType?,
|
||||
context: ResolutionContext<*>,
|
||||
resolvedToSomething: BooleanArray,
|
||||
callResolver: CallResolver
|
||||
@@ -164,9 +164,9 @@ public fun resolveCallableReferenceTarget(
|
||||
|
||||
private fun createReflectionTypeForFunction(
|
||||
descriptor: FunctionDescriptor,
|
||||
receiverType: KtType?,
|
||||
receiverType: KotlinType?,
|
||||
reflectionTypes: ReflectionTypes
|
||||
): KtType? {
|
||||
): KotlinType? {
|
||||
val returnType = descriptor.getReturnType() ?: return null
|
||||
val valueParametersTypes = ExpressionTypingUtils.getValueParametersTypes(descriptor.getValueParameters())
|
||||
return reflectionTypes.getKFunctionType(Annotations.EMPTY, receiverType, valueParametersTypes, returnType)
|
||||
@@ -174,13 +174,13 @@ private fun createReflectionTypeForFunction(
|
||||
|
||||
private fun createReflectionTypeForProperty(
|
||||
descriptor: PropertyDescriptor,
|
||||
receiverType: KtType?,
|
||||
receiverType: KotlinType?,
|
||||
reflectionTypes: ReflectionTypes
|
||||
): KtType {
|
||||
): KotlinType {
|
||||
return reflectionTypes.getKPropertyType(Annotations.EMPTY, receiverType, descriptor.getType(), descriptor.isVar())
|
||||
}
|
||||
|
||||
private fun bindFunctionReference(expression: KtCallableReferenceExpression, referenceType: KtType, context: ResolutionContext<*>) {
|
||||
private fun bindFunctionReference(expression: KtCallableReferenceExpression, referenceType: KotlinType, context: ResolutionContext<*>) {
|
||||
val functionDescriptor = AnonymousFunctionDescriptor(
|
||||
context.scope.ownerDescriptor,
|
||||
Annotations.EMPTY,
|
||||
@@ -192,7 +192,7 @@ private fun bindFunctionReference(expression: KtCallableReferenceExpression, ref
|
||||
context.trace.record(BindingContext.FUNCTION, expression, functionDescriptor)
|
||||
}
|
||||
|
||||
private fun bindPropertyReference(expression: KtCallableReferenceExpression, referenceType: KtType, context: ResolutionContext<*>) {
|
||||
private fun bindPropertyReference(expression: KtCallableReferenceExpression, referenceType: KotlinType, context: ResolutionContext<*>) {
|
||||
val localVariable = LocalVariableDescriptor(context.scope.ownerDescriptor, Annotations.EMPTY, Name.special("<anonymous>"),
|
||||
referenceType, /* mutable = */ false, expression.toSourceElement())
|
||||
|
||||
@@ -201,11 +201,11 @@ private fun bindPropertyReference(expression: KtCallableReferenceExpression, ref
|
||||
|
||||
private fun createReflectionTypeForCallableDescriptor(
|
||||
descriptor: CallableDescriptor,
|
||||
lhsType: KtType?,
|
||||
lhsType: KotlinType?,
|
||||
reflectionTypes: ReflectionTypes,
|
||||
trace: BindingTrace?,
|
||||
reportOn: KtExpression?
|
||||
): KtType? {
|
||||
): KotlinType? {
|
||||
val extensionReceiver = descriptor.extensionReceiverParameter
|
||||
val dispatchReceiver = descriptor.dispatchReceiverParameter?.let { dispatchReceiver ->
|
||||
// See CallableDescriptor#getOwnerForEffectiveDispatchReceiverParameter
|
||||
@@ -245,16 +245,16 @@ private fun createReflectionTypeForCallableDescriptor(
|
||||
public fun getReflectionTypeForCandidateDescriptor(
|
||||
descriptor: CallableDescriptor,
|
||||
reflectionTypes: ReflectionTypes
|
||||
): KtType? =
|
||||
): KotlinType? =
|
||||
createReflectionTypeForCallableDescriptor(descriptor, null, reflectionTypes, null, null)
|
||||
|
||||
public fun createReflectionTypeForResolvedCallableReference(
|
||||
reference: KtCallableReferenceExpression,
|
||||
lhsType: KtType?,
|
||||
lhsType: KotlinType?,
|
||||
descriptor: CallableDescriptor,
|
||||
context: ResolutionContext<*>,
|
||||
reflectionTypes: ReflectionTypes
|
||||
): KtType? {
|
||||
): KotlinType? {
|
||||
val type = createReflectionTypeForCallableDescriptor(
|
||||
descriptor, lhsType, reflectionTypes, context.trace, reference.getCallableReference()
|
||||
) ?: return null
|
||||
@@ -271,14 +271,14 @@ public fun createReflectionTypeForResolvedCallableReference(
|
||||
|
||||
public fun getResolvedCallableReferenceShapeType(
|
||||
reference: KtCallableReferenceExpression,
|
||||
lhsType: KtType?,
|
||||
lhsType: KotlinType?,
|
||||
overloadResolutionResults: OverloadResolutionResults<CallableDescriptor>?,
|
||||
context: ResolutionContext<*>,
|
||||
expectedTypeUnknown: Boolean,
|
||||
reflectionTypes: ReflectionTypes,
|
||||
builtIns: KotlinBuiltIns,
|
||||
functionPlaceholders: FunctionPlaceholders
|
||||
): KtType? =
|
||||
): KotlinType? =
|
||||
when {
|
||||
overloadResolutionResults == null ->
|
||||
null
|
||||
|
||||
+19
-19
@@ -47,7 +47,7 @@ import org.jetbrains.kotlin.resolve.scopes.receivers.QualifierReceiver;
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
|
||||
import org.jetbrains.kotlin.types.FunctionPlaceholders;
|
||||
import org.jetbrains.kotlin.types.FunctionPlaceholdersKt;
|
||||
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.expressions.ExpressionTypingServices;
|
||||
@@ -94,11 +94,11 @@ public class ArgumentTypeResolver {
|
||||
}
|
||||
|
||||
public static boolean isSubtypeOfForArgumentType(
|
||||
@NotNull KtType actualType,
|
||||
@NotNull KtType expectedType
|
||||
@NotNull KotlinType actualType,
|
||||
@NotNull KotlinType expectedType
|
||||
) {
|
||||
if (FunctionPlaceholdersKt.isFunctionPlaceholder(actualType)) {
|
||||
KtType functionType = ConstraintSystemImplKt.createTypeForFunctionPlaceholder(actualType, expectedType);
|
||||
KotlinType functionType = ConstraintSystemImplKt.createTypeForFunctionPlaceholder(actualType, expectedType);
|
||||
return KotlinTypeChecker.DEFAULT.isSubtypeOf(functionType, expectedType);
|
||||
}
|
||||
return KotlinTypeChecker.DEFAULT.isSubtypeOf(actualType, expectedType);
|
||||
@@ -231,19 +231,19 @@ public class ArgumentTypeResolver {
|
||||
@NotNull ResolveArgumentsMode resolveArgumentsMode
|
||||
) {
|
||||
if (resolveArgumentsMode == SHAPE_FUNCTION_ARGUMENTS) {
|
||||
KtType type = getShapeTypeOfCallableReference(callableReferenceExpression, context, true);
|
||||
KotlinType type = getShapeTypeOfCallableReference(callableReferenceExpression, context, true);
|
||||
return TypeInfoFactoryKt.createTypeInfo(type);
|
||||
}
|
||||
return expressionTypingServices.getTypeInfo(expression, context.replaceContextDependency(INDEPENDENT));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public KtType getShapeTypeOfCallableReference(
|
||||
public KotlinType getShapeTypeOfCallableReference(
|
||||
@NotNull KtCallableReferenceExpression callableReferenceExpression,
|
||||
@NotNull CallResolutionContext<?> context,
|
||||
boolean expectedTypeIsUnknown
|
||||
) {
|
||||
KtType receiverType =
|
||||
KotlinType receiverType =
|
||||
CallableReferencesResolutionUtilsKt.resolveCallableReferenceReceiverType(callableReferenceExpression, context, typeResolver);
|
||||
OverloadResolutionResults<CallableDescriptor> overloadResolutionResults =
|
||||
CallableReferencesResolutionUtilsKt.resolvePossiblyAmbiguousCallableReference(
|
||||
@@ -262,14 +262,14 @@ public class ArgumentTypeResolver {
|
||||
@NotNull ResolveArgumentsMode resolveArgumentsMode
|
||||
) {
|
||||
if (resolveArgumentsMode == SHAPE_FUNCTION_ARGUMENTS) {
|
||||
KtType type = getShapeTypeOfFunctionLiteral(functionLiteral, context.scope, context.trace, true);
|
||||
KotlinType type = getShapeTypeOfFunctionLiteral(functionLiteral, context.scope, context.trace, true);
|
||||
return TypeInfoFactoryKt.createTypeInfo(type, context);
|
||||
}
|
||||
return expressionTypingServices.getTypeInfo(expression, context.replaceContextDependency(INDEPENDENT));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public KtType getShapeTypeOfFunctionLiteral(
|
||||
public KotlinType getShapeTypeOfFunctionLiteral(
|
||||
@NotNull KtFunction function,
|
||||
@NotNull LexicalScope scope,
|
||||
@NotNull BindingTrace trace,
|
||||
@@ -279,19 +279,19 @@ public class ArgumentTypeResolver {
|
||||
if (function.getValueParameterList() == null && isFunctionLiteral) {
|
||||
return expectedTypeIsUnknown
|
||||
? functionPlaceholders
|
||||
.createFunctionPlaceholderType(Collections.<KtType>emptyList(), /* hasDeclaredArguments = */ false)
|
||||
: builtIns.getFunctionType(Annotations.Companion.getEMPTY(), null, Collections.<KtType>emptyList(), DONT_CARE);
|
||||
.createFunctionPlaceholderType(Collections.<KotlinType>emptyList(), /* hasDeclaredArguments = */ false)
|
||||
: builtIns.getFunctionType(Annotations.Companion.getEMPTY(), null, Collections.<KotlinType>emptyList(), DONT_CARE);
|
||||
}
|
||||
List<KtParameter> valueParameters = function.getValueParameters();
|
||||
TemporaryBindingTrace temporaryTrace = TemporaryBindingTrace.create(
|
||||
trace, "trace to resolve function literal parameter types");
|
||||
List<KtType> parameterTypes = Lists.newArrayList();
|
||||
List<KotlinType> parameterTypes = Lists.newArrayList();
|
||||
for (KtParameter parameter : valueParameters) {
|
||||
parameterTypes.add(resolveTypeRefWithDefault(parameter.getTypeReference(), scope, temporaryTrace, DONT_CARE));
|
||||
}
|
||||
KtType returnType = resolveTypeRefWithDefault(function.getTypeReference(), scope, temporaryTrace, DONT_CARE);
|
||||
KotlinType returnType = resolveTypeRefWithDefault(function.getTypeReference(), scope, temporaryTrace, DONT_CARE);
|
||||
assert returnType != null;
|
||||
KtType receiverType = resolveTypeRefWithDefault(function.getReceiverTypeReference(), scope, temporaryTrace, null);
|
||||
KotlinType receiverType = resolveTypeRefWithDefault(function.getReceiverTypeReference(), scope, temporaryTrace, null);
|
||||
|
||||
return expectedTypeIsUnknown && isFunctionLiteral
|
||||
? functionPlaceholders.createFunctionPlaceholderType(parameterTypes, /* hasDeclaredArguments = */ true)
|
||||
@@ -299,11 +299,11 @@ public class ArgumentTypeResolver {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public KtType resolveTypeRefWithDefault(
|
||||
public KotlinType resolveTypeRefWithDefault(
|
||||
@Nullable KtTypeReference returnTypeRef,
|
||||
@NotNull LexicalScope scope,
|
||||
@NotNull BindingTrace trace,
|
||||
@Nullable KtType defaultValue
|
||||
@Nullable KotlinType defaultValue
|
||||
) {
|
||||
if (returnTypeRef != null) {
|
||||
return typeResolver.resolveType(scope, returnTypeRef, trace, true);
|
||||
@@ -347,15 +347,15 @@ public class ArgumentTypeResolver {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public KtType updateResultArgumentTypeIfNotDenotable(
|
||||
public KotlinType updateResultArgumentTypeIfNotDenotable(
|
||||
@NotNull ResolutionContext context,
|
||||
@NotNull KtExpression expression
|
||||
) {
|
||||
KtType type = context.trace.getType(expression);
|
||||
KotlinType type = context.trace.getType(expression);
|
||||
if (type != null && !type.getConstructor().isDenotable()) {
|
||||
if (type.getConstructor() instanceof IntegerValueTypeConstructor) {
|
||||
IntegerValueTypeConstructor constructor = (IntegerValueTypeConstructor) type.getConstructor();
|
||||
KtType primitiveType = TypeUtils.getPrimitiveNumberType(constructor, context.expectedType);
|
||||
KotlinType primitiveType = TypeUtils.getPrimitiveNumberType(constructor, context.expectedType);
|
||||
constantExpressionEvaluator.updateNumberType(primitiveType, expression, context.statementFilter, context.trace);
|
||||
return primitiveType;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo
|
||||
import org.jetbrains.kotlin.resolve.calls.tasks.TracingStrategy
|
||||
import org.jetbrains.kotlin.resolve.validation.SymbolUsageValidator
|
||||
import org.jetbrains.kotlin.types.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
import org.jetbrains.kotlin.types.expressions.DataFlowAnalyzer
|
||||
import java.util.*
|
||||
@@ -136,7 +136,7 @@ public class CallCompleter(
|
||||
}
|
||||
|
||||
private fun <D : CallableDescriptor> MutableResolvedCall<D>.completeConstraintSystem(
|
||||
expectedType: KtType,
|
||||
expectedType: KotlinType,
|
||||
trace: BindingTrace
|
||||
) {
|
||||
fun updateSystemIfSuccessful(update: (ConstraintSystemImpl) -> Boolean) {
|
||||
@@ -240,7 +240,7 @@ public class CallCompleter(
|
||||
val deparenthesized = KtPsiUtil.getLastElementDeparenthesized(expression, context.statementFilter) ?: return
|
||||
|
||||
val recordedType = expression.let { context.trace.getType(it) }
|
||||
var updatedType: KtType? = recordedType
|
||||
var updatedType: KotlinType? = recordedType
|
||||
|
||||
val results = completeCallForArgument(deparenthesized, context)
|
||||
if (results != null && results.isSingleResult()) {
|
||||
@@ -288,11 +288,11 @@ public class CallCompleter(
|
||||
}
|
||||
|
||||
private fun updateRecordedTypeForArgument(
|
||||
updatedType: KtType?,
|
||||
recordedType: KtType?,
|
||||
updatedType: KotlinType?,
|
||||
recordedType: KotlinType?,
|
||||
argumentExpression: KtExpression,
|
||||
trace: BindingTrace
|
||||
): KtType? {
|
||||
): KotlinType? {
|
||||
//workaround for KT-8218
|
||||
if ((!ErrorUtils.containsErrorType(recordedType) && recordedType == updatedType) || updatedType == null) return updatedType
|
||||
|
||||
|
||||
+8
-8
@@ -43,7 +43,7 @@ import org.jetbrains.kotlin.resolve.constants.evaluate.ConstantExpressionEvaluat
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.*;
|
||||
import org.jetbrains.kotlin.resolve.validation.SymbolUsageValidator;
|
||||
import org.jetbrains.kotlin.types.ErrorUtils;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.TypeUtils;
|
||||
import org.jetbrains.kotlin.types.expressions.DataFlowAnalyzer;
|
||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingContext;
|
||||
@@ -103,7 +103,7 @@ public class CallExpressionResolver {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private KtType getVariableType(
|
||||
private KotlinType getVariableType(
|
||||
@NotNull KtSimpleNameExpression nameExpression, @NotNull ReceiverValue receiver,
|
||||
@Nullable ASTNode callOperationNode, @NotNull ExpressionTypingContext context, @NotNull boolean[] result
|
||||
) {
|
||||
@@ -149,7 +149,7 @@ public class CallExpressionResolver {
|
||||
|
||||
TemporaryTraceAndCache temporaryForVariable = TemporaryTraceAndCache.create(
|
||||
context, "trace to resolve as variable", nameExpression);
|
||||
KtType type =
|
||||
KotlinType type =
|
||||
getVariableType(nameExpression, receiver, callOperationNode, context.replaceTraceAndCache(temporaryForVariable), result);
|
||||
// TODO: for a safe call, it's necessary to set receiver != null here, as inside ArgumentTypeResolver.analyzeArgumentsAndRecordTypes
|
||||
// Unfortunately it provokes problems with x?.y!!.foo() with the following x!!.bar():
|
||||
@@ -236,7 +236,7 @@ public class CallExpressionResolver {
|
||||
}
|
||||
}
|
||||
|
||||
KtType type = functionDescriptor.getReturnType();
|
||||
KotlinType type = functionDescriptor.getReturnType();
|
||||
// Extracting jump out possible and jump point flow info from arguments, if any
|
||||
List<? extends ValueArgument> arguments = callExpression.getValueArguments();
|
||||
DataFlowInfo resultFlowInfo = resolvedCall.getDataFlowInfoForArguments().getResultInfo();
|
||||
@@ -257,8 +257,8 @@ public class CallExpressionResolver {
|
||||
if (calleeExpression instanceof KtSimpleNameExpression && callExpression.getTypeArgumentList() == null) {
|
||||
TemporaryTraceAndCache temporaryForVariable = TemporaryTraceAndCache.create(
|
||||
context, "trace to resolve as variable with 'invoke' call", callExpression);
|
||||
KtType type = getVariableType((KtSimpleNameExpression) calleeExpression, receiver, callOperationNode,
|
||||
context.replaceTraceAndCache(temporaryForVariable), result);
|
||||
KotlinType type = getVariableType((KtSimpleNameExpression) calleeExpression, receiver, callOperationNode,
|
||||
context.replaceTraceAndCache(temporaryForVariable), result);
|
||||
Qualifier qualifier = temporaryForVariable.trace.get(BindingContext.QUALIFIER, calleeExpression);
|
||||
if (result[0] && (qualifier == null || qualifier.getPackageView() == null)) {
|
||||
temporaryForVariable.commit();
|
||||
@@ -350,7 +350,7 @@ public class CallExpressionResolver {
|
||||
replaceInsideCallChain(true); // Enter call chain
|
||||
// Visit receiver (x in x.y or x?.z) here. Recursion is possible.
|
||||
JetTypeInfo receiverTypeInfo = expressionTypingServices.getTypeInfo(receiverExpression, contextForReceiver);
|
||||
KtType receiverType = receiverTypeInfo.getType();
|
||||
KotlinType receiverType = receiverTypeInfo.getType();
|
||||
QualifierReceiver qualifierReceiver = (QualifierReceiver) context.trace.get(BindingContext.QUALIFIER, receiverExpression);
|
||||
|
||||
if (receiverType == null) receiverType = ErrorUtils.createErrorType("Type for " + expression.getText());
|
||||
@@ -363,7 +363,7 @@ public class CallExpressionResolver {
|
||||
// Visit selector (y in x.y) here. Recursion is also possible.
|
||||
JetTypeInfo selectorReturnTypeInfo = getSelectorReturnTypeInfo(
|
||||
receiver, expression.getOperationTokenNode(), selectorExpression, context);
|
||||
KtType selectorReturnType = selectorReturnTypeInfo.getType();
|
||||
KotlinType selectorReturnType = selectorReturnTypeInfo.getType();
|
||||
|
||||
resolveDeferredReceiverInQualifiedExpression(qualifierReceiver, expression, context);
|
||||
checkNestedClassAccess(expression, context);
|
||||
|
||||
@@ -51,7 +51,7 @@ import org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil;
|
||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope;
|
||||
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.TypeSubstitutor;
|
||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingContext;
|
||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices;
|
||||
@@ -264,7 +264,7 @@ public class CallResolver {
|
||||
@NotNull BindingTrace trace,
|
||||
@NotNull LexicalScope scope,
|
||||
@NotNull Call call,
|
||||
@NotNull KtType expectedType,
|
||||
@NotNull KotlinType expectedType,
|
||||
@NotNull DataFlowInfo dataFlowInfo,
|
||||
boolean isAnnotationContext
|
||||
) {
|
||||
@@ -311,16 +311,16 @@ public class CallResolver {
|
||||
}
|
||||
|
||||
// Here we handle the case where the callee expression must be something of type function, e.g. (foo.bar())(1, 2)
|
||||
KtType expectedType = NO_EXPECTED_TYPE;
|
||||
KotlinType expectedType = NO_EXPECTED_TYPE;
|
||||
if (calleeExpression instanceof KtFunctionLiteralExpression) {
|
||||
int parameterNumber = ((KtFunctionLiteralExpression) calleeExpression).getValueParameters().size();
|
||||
List<KtType> parameterTypes = new ArrayList<KtType>(parameterNumber);
|
||||
List<KotlinType> parameterTypes = new ArrayList<KotlinType>(parameterNumber);
|
||||
for (int i = 0; i < parameterNumber; i++) {
|
||||
parameterTypes.add(NO_EXPECTED_TYPE);
|
||||
}
|
||||
expectedType = builtIns.getFunctionType(Annotations.Companion.getEMPTY(), null, parameterTypes, context.expectedType);
|
||||
}
|
||||
KtType calleeType = expressionTypingServices.safeGetType(
|
||||
KotlinType calleeType = expressionTypingServices.safeGetType(
|
||||
context.scope, calleeExpression, expectedType, context.dataFlowInfo, context.trace);
|
||||
ExpressionReceiver expressionReceiver = new ExpressionReceiver(calleeExpression, calleeType);
|
||||
|
||||
@@ -343,7 +343,7 @@ public class CallResolver {
|
||||
if (functionReference == null || typeReference == null) {
|
||||
return checkArgumentTypesAndFail(context); // No type there
|
||||
}
|
||||
KtType constructedType = typeResolver.resolveType(context.scope, typeReference, context.trace, true);
|
||||
KotlinType constructedType = typeResolver.resolveType(context.scope, typeReference, context.trace, true);
|
||||
if (constructedType.isError()) {
|
||||
return checkArgumentTypesAndFail(context);
|
||||
}
|
||||
@@ -436,9 +436,9 @@ public class CallResolver {
|
||||
((ClassDescriptor) delegateClassDescriptor.getContainingDeclaration()).
|
||||
getThisAsReceiverParameter().getValue();
|
||||
|
||||
KtType expectedType = isThisCall ?
|
||||
calleeConstructor.getContainingDeclaration().getDefaultType() :
|
||||
DescriptorUtils.getSuperClassType(currentClassDescriptor);
|
||||
KotlinType expectedType = isThisCall ?
|
||||
calleeConstructor.getContainingDeclaration().getDefaultType() :
|
||||
DescriptorUtils.getSuperClassType(currentClassDescriptor);
|
||||
|
||||
TypeSubstitutor knownTypeParametersSubstitutor = TypeSubstitutor.create(expectedType);
|
||||
for (CallableDescriptor descriptor : constructors) {
|
||||
@@ -565,7 +565,7 @@ public class CallResolver {
|
||||
context.trace.report(PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT.on(projection));
|
||||
ModifierCheckerCore.INSTANCE.check(projection, context.trace, null);
|
||||
}
|
||||
KtType type = argumentTypeResolver.resolveTypeRefWithDefault(
|
||||
KotlinType type = argumentTypeResolver.resolveTypeRefWithDefault(
|
||||
projection.getTypeReference(), context.scope, context.trace,
|
||||
null);
|
||||
if (type != null) {
|
||||
|
||||
@@ -40,19 +40,19 @@ public enum class ResolveArgumentsMode {
|
||||
}
|
||||
|
||||
|
||||
public fun hasUnknownFunctionParameter(type: KtType): Boolean {
|
||||
public fun hasUnknownFunctionParameter(type: KotlinType): Boolean {
|
||||
assert(ReflectionTypes.isCallableType(type)) { "type $type is not a function or property" }
|
||||
return getParameterArgumentsOfCallableType(type).any {
|
||||
TypeUtils.containsSpecialType(it.getType(), DONT_CARE) || ErrorUtils.containsUninferredParameter(it.getType())
|
||||
}
|
||||
}
|
||||
|
||||
public fun hasUnknownReturnType(type: KtType): Boolean {
|
||||
public fun hasUnknownReturnType(type: KotlinType): Boolean {
|
||||
assert(ReflectionTypes.isCallableType(type)) { "type $type is not a function or property" }
|
||||
return ErrorUtils.containsErrorType(getReturnTypeForCallable(type))
|
||||
}
|
||||
|
||||
public fun replaceReturnTypeByUnknown(type: KtType): KtType {
|
||||
public fun replaceReturnTypeByUnknown(type: KotlinType): KotlinType {
|
||||
assert(ReflectionTypes.isCallableType(type)) { "type $type is not a function or property" }
|
||||
val newArguments = Lists.newArrayList<TypeProjection>()
|
||||
newArguments.addAll(getParameterArgumentsOfCallableType(type))
|
||||
@@ -60,13 +60,13 @@ public fun replaceReturnTypeByUnknown(type: KtType): KtType {
|
||||
return replaceTypeArguments(type, newArguments)
|
||||
}
|
||||
|
||||
private fun replaceTypeArguments(type: KtType, newArguments: List<TypeProjection>) =
|
||||
KtTypeImpl.create(type.getAnnotations(), type.getConstructor(), type.isMarkedNullable(), newArguments, type.getMemberScope())
|
||||
private fun replaceTypeArguments(type: KotlinType, newArguments: List<TypeProjection>) =
|
||||
KotlinTypeImpl.create(type.getAnnotations(), type.getConstructor(), type.isMarkedNullable(), newArguments, type.getMemberScope())
|
||||
|
||||
private fun getParameterArgumentsOfCallableType(type: KtType) =
|
||||
private fun getParameterArgumentsOfCallableType(type: KotlinType) =
|
||||
type.getArguments().dropLast(1)
|
||||
|
||||
private fun getReturnTypeForCallable(type: KtType) =
|
||||
private fun getReturnTypeForCallable(type: KotlinType) =
|
||||
type.getArguments().last().getType()
|
||||
|
||||
private fun CallableDescriptor.hasReturnTypeDependentOnUninferredParams(constraintSystem: ConstraintSystem): Boolean {
|
||||
@@ -86,7 +86,7 @@ public fun CallableDescriptor.hasInferredReturnType(constraintSystem: Constraint
|
||||
return true
|
||||
}
|
||||
|
||||
public fun getErasedReceiverType(receiverParameterDescriptor: ReceiverParameterDescriptor, descriptor: CallableDescriptor): KtType {
|
||||
public fun getErasedReceiverType(receiverParameterDescriptor: ReceiverParameterDescriptor, descriptor: CallableDescriptor): KotlinType {
|
||||
var receiverType = receiverParameterDescriptor.getType()
|
||||
for (typeParameter in descriptor.getTypeParameters()) {
|
||||
if (typeParameter.getTypeConstructor() == receiverType.getConstructor()) {
|
||||
@@ -97,7 +97,7 @@ public fun getErasedReceiverType(receiverParameterDescriptor: ReceiverParameterD
|
||||
for (typeProjection in receiverType.getArguments()) {
|
||||
fakeTypeArguments.add(TypeProjectionImpl(typeProjection.getProjectionKind(), DONT_CARE))
|
||||
}
|
||||
return KtTypeImpl.create(receiverType.getAnnotations(), receiverType.getConstructor(), receiverType.isMarkedNullable(), fakeTypeArguments,
|
||||
return KotlinTypeImpl.create(receiverType.getAnnotations(), receiverType.getConstructor(), receiverType.isMarkedNullable(), fakeTypeArguments,
|
||||
ErrorUtils.createErrorScope("Error scope for erased receiver type", /*throwExceptions=*/true))
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ public fun getSuperCallExpression(call: Call): KtSuperExpression? {
|
||||
return (call.getExplicitReceiver() as? ExpressionReceiver)?.getExpression() as? KtSuperExpression
|
||||
}
|
||||
|
||||
public fun getEffectiveExpectedType(parameterDescriptor: ValueParameterDescriptor, argument: ValueArgument): KtType {
|
||||
public fun getEffectiveExpectedType(parameterDescriptor: ValueParameterDescriptor, argument: ValueArgument): KotlinType {
|
||||
if (argument.getSpreadElement() != null) {
|
||||
if (parameterDescriptor.getVarargElementType() == null) {
|
||||
// Spread argument passed to a non-vararg parameter, an error is already reported by ValueArgumentsToParametersMapper
|
||||
|
||||
@@ -45,7 +45,7 @@ import org.jetbrains.kotlin.resolve.calls.tasks.TracingStrategyForInvoke;
|
||||
import org.jetbrains.kotlin.resolve.calls.util.DelegatingCall;
|
||||
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.util.OperatorNameConventions;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -225,7 +225,7 @@ public class CallTransformer<D extends CallableDescriptor, F extends D> {
|
||||
}
|
||||
|
||||
assert descriptor instanceof VariableDescriptor;
|
||||
KtType returnType = descriptor.getReturnType();
|
||||
KotlinType returnType = descriptor.getReturnType();
|
||||
if (returnType == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ public class CandidateResolver(
|
||||
if (!jetTypeArguments.isEmpty()) {
|
||||
// Explicit type arguments passed
|
||||
|
||||
val typeArguments = ArrayList<KtType>()
|
||||
val typeArguments = ArrayList<KotlinType>()
|
||||
for (projection in jetTypeArguments) {
|
||||
val type = projection.typeReference?.let { trace.bindingContext.get(BindingContext.TYPE, it) }
|
||||
?: ErrorUtils.createErrorType("Star projection in a call")
|
||||
@@ -312,7 +312,7 @@ public class CandidateResolver(
|
||||
candidateCall: MutableResolvedCall<D>,
|
||||
resolveFunctionArgumentBodies: ResolveArgumentsMode): ValueArgumentsCheckingResult {
|
||||
var resultStatus = SUCCESS
|
||||
val argumentTypes = Lists.newArrayList<KtType>()
|
||||
val argumentTypes = Lists.newArrayList<KotlinType>()
|
||||
val infoForArguments = candidateCall.getDataFlowInfoForArguments()
|
||||
for (entry in candidateCall.getValueArguments().entrySet()) {
|
||||
val parameterDescriptor = entry.getKey()
|
||||
@@ -331,7 +331,7 @@ public class CandidateResolver(
|
||||
infoForArguments.updateInfo(argument, typeInfoForCall.dataFlowInfo)
|
||||
|
||||
var matchStatus = ArgumentMatchStatus.SUCCESS
|
||||
var resultingType: KtType? = type
|
||||
var resultingType: KotlinType? = type
|
||||
if (type == null || (type.isError() && !type.isFunctionPlaceholder)) {
|
||||
matchStatus = ArgumentMatchStatus.ARGUMENT_HAS_NO_TYPE
|
||||
}
|
||||
@@ -359,9 +359,9 @@ public class CandidateResolver(
|
||||
|
||||
private fun smartCastValueArgumentTypeIfPossible(
|
||||
expression: KtExpression,
|
||||
expectedType: KtType,
|
||||
actualType: KtType,
|
||||
context: ResolutionContext<*>): KtType? {
|
||||
expectedType: KotlinType,
|
||||
actualType: KotlinType,
|
||||
context: ResolutionContext<*>): KotlinType? {
|
||||
val receiverToCast = ExpressionReceiver(KtPsiUtil.safeDeparenthesize(expression), actualType)
|
||||
val variants = smartCastManager.getSmartCastVariantsExcludingReceiver(context, receiverToCast)
|
||||
for (possibleType in variants) {
|
||||
@@ -482,11 +482,11 @@ public class CandidateResolver(
|
||||
return SUCCESS
|
||||
}
|
||||
|
||||
public inner class ValueArgumentsCheckingResult(public val status: ResolutionStatus, public val argumentTypes: List<KtType>)
|
||||
public inner class ValueArgumentsCheckingResult(public val status: ResolutionStatus, public val argumentTypes: List<KotlinType>)
|
||||
|
||||
private fun checkGenericBoundsInAFunctionCall(
|
||||
jetTypeArguments: List<KtTypeProjection>,
|
||||
typeArguments: List<KtType>,
|
||||
typeArguments: List<KotlinType>,
|
||||
functionDescriptor: CallableDescriptor,
|
||||
substitutor: TypeSubstitutor,
|
||||
trace: BindingTrace) {
|
||||
|
||||
+8
-8
@@ -94,7 +94,7 @@ class GenericCandidateResolver(
|
||||
val receiverArgument = candidateCall.getExtensionReceiver()
|
||||
val receiverParameter = candidate.getExtensionReceiverParameter()
|
||||
if (receiverArgument.exists() && receiverParameter != null) {
|
||||
var receiverType: KtType? = if (context.candidateCall.isSafeCall())
|
||||
var receiverType: KotlinType? = if (context.candidateCall.isSafeCall())
|
||||
TypeUtils.makeNotNullable(receiverArgument.getType())
|
||||
else
|
||||
receiverArgument.getType()
|
||||
@@ -144,7 +144,7 @@ class GenericCandidateResolver(
|
||||
constraintPosition: ConstraintPosition,
|
||||
constraintSystem: ConstraintSystem,
|
||||
context: CallCandidateResolutionContext<*>,
|
||||
effectiveExpectedType: KtType
|
||||
effectiveExpectedType: KotlinType
|
||||
): Boolean {
|
||||
val resolutionResults = getResolutionResultsCachedData(argumentExpression, context)?.resolutionResults
|
||||
if (resolutionResults == null || !resolutionResults.isSingleResult()) return false
|
||||
@@ -175,10 +175,10 @@ class GenericCandidateResolver(
|
||||
}
|
||||
|
||||
private fun updateResultTypeForSmartCasts(
|
||||
type: KtType?,
|
||||
type: KotlinType?,
|
||||
argumentExpression: KtExpression?,
|
||||
context: ResolutionContext<*>
|
||||
): KtType? {
|
||||
): KotlinType? {
|
||||
val deparenthesizedArgument = KtPsiUtil.getLastElementDeparenthesized(argumentExpression, context.statementFilter)
|
||||
if (deparenthesizedArgument == null || type == null) return type
|
||||
|
||||
@@ -287,8 +287,8 @@ class GenericCandidateResolver(
|
||||
callableReference: KtCallableReferenceExpression,
|
||||
constraintSystem: ConstraintSystem,
|
||||
context: CallCandidateResolutionContext<D>,
|
||||
effectiveExpectedType: KtType
|
||||
): KtType? {
|
||||
effectiveExpectedType: KotlinType
|
||||
): KotlinType? {
|
||||
val substitutedType = constraintSystem.getCurrentSubstitutor().substitute(effectiveExpectedType, Variance.INVARIANT)
|
||||
if (substitutedType != null && !TypeUtils.isDontCarePlaceholder(substitutedType))
|
||||
return substitutedType
|
||||
@@ -303,9 +303,9 @@ class GenericCandidateResolver(
|
||||
private fun <D : CallableDescriptor> getResolvedTypeForCallableReference(
|
||||
callableReference: KtCallableReferenceExpression,
|
||||
context: CallCandidateResolutionContext<D>,
|
||||
expectedType: KtType,
|
||||
expectedType: KotlinType,
|
||||
valueArgument: ValueArgument
|
||||
): KtType? {
|
||||
): KotlinType? {
|
||||
val dataFlowInfoForArgument = context.candidateCall.getDataFlowInfoForArguments().getInfo(valueArgument)
|
||||
val expectedTypeWithoutReturnType = if (!hasUnknownReturnType(expectedType)) replaceReturnTypeByUnknown(expectedType) else expectedType
|
||||
val newContext = context
|
||||
|
||||
+2
-2
@@ -21,10 +21,10 @@ import org.jetbrains.kotlin.psi.KtExpression
|
||||
import org.jetbrains.kotlin.resolve.calls.context.CallResolutionContext
|
||||
import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
public interface AdditionalTypeChecker {
|
||||
fun checkType(expression: KtExpression, expressionType: KtType, expressionTypeWithSmartCast: KtType, c: ResolutionContext<*>)
|
||||
fun checkType(expression: KtExpression, expressionType: KotlinType, expressionTypeWithSmartCast: KotlinType, c: ResolutionContext<*>)
|
||||
fun checkReceiver(
|
||||
receiverParameter: ReceiverParameterDescriptor,
|
||||
receiverArgument: ReceiverValue,
|
||||
|
||||
+4
-4
@@ -25,7 +25,7 @@ import org.jetbrains.kotlin.diagnostics.Errors;
|
||||
import org.jetbrains.kotlin.psi.KtExpression;
|
||||
import org.jetbrains.kotlin.resolve.calls.context.BasicCallResolutionContext;
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.typeUtil.TypeUtilsKt;
|
||||
|
||||
import java.util.Map;
|
||||
@@ -35,10 +35,10 @@ public class ReifiedTypeParameterSubstitutionChecker implements CallChecker {
|
||||
public <F extends CallableDescriptor> void check(
|
||||
@NotNull ResolvedCall<F> resolvedCall, @NotNull BasicCallResolutionContext context
|
||||
) {
|
||||
Map<TypeParameterDescriptor, KtType> typeArguments = resolvedCall.getTypeArguments();
|
||||
for (Map.Entry<TypeParameterDescriptor, KtType> entry : typeArguments.entrySet()) {
|
||||
Map<TypeParameterDescriptor, KotlinType> typeArguments = resolvedCall.getTypeArguments();
|
||||
for (Map.Entry<TypeParameterDescriptor, KotlinType> entry : typeArguments.entrySet()) {
|
||||
TypeParameterDescriptor parameter = entry.getKey();
|
||||
KtType argument = entry.getValue();
|
||||
KotlinType argument = entry.getValue();
|
||||
ClassifierDescriptor argumentDeclarationDescription = argument.getConstructor().getDeclarationDescriptor();
|
||||
|
||||
if (parameter.isReified()) {
|
||||
|
||||
+4
-4
@@ -26,14 +26,14 @@ import org.jetbrains.kotlin.resolve.calls.model.MutableDataFlowInfoForArguments;
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
|
||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
public class BasicCallResolutionContext extends CallResolutionContext<BasicCallResolutionContext> {
|
||||
private BasicCallResolutionContext(
|
||||
@NotNull BindingTrace trace,
|
||||
@NotNull LexicalScope scope,
|
||||
@NotNull Call call,
|
||||
@NotNull KtType expectedType,
|
||||
@NotNull KotlinType expectedType,
|
||||
@NotNull DataFlowInfo dataFlowInfo,
|
||||
@NotNull ContextDependency contextDependency,
|
||||
@NotNull CheckArgumentTypesMode checkArguments,
|
||||
@@ -54,7 +54,7 @@ public class BasicCallResolutionContext extends CallResolutionContext<BasicCallR
|
||||
@NotNull BindingTrace trace,
|
||||
@NotNull LexicalScope scope,
|
||||
@NotNull Call call,
|
||||
@NotNull KtType expectedType,
|
||||
@NotNull KotlinType expectedType,
|
||||
@NotNull DataFlowInfo dataFlowInfo,
|
||||
@NotNull ContextDependency contextDependency,
|
||||
@NotNull CheckArgumentTypesMode checkArguments,
|
||||
@@ -90,7 +90,7 @@ public class BasicCallResolutionContext extends CallResolutionContext<BasicCallR
|
||||
@NotNull BindingTrace trace,
|
||||
@NotNull LexicalScope scope,
|
||||
@NotNull DataFlowInfo dataFlowInfo,
|
||||
@NotNull KtType expectedType,
|
||||
@NotNull KotlinType expectedType,
|
||||
@NotNull ContextDependency contextDependency,
|
||||
@NotNull ResolutionResultsCache resolutionResultsCache,
|
||||
@NotNull StatementFilter statementFilter,
|
||||
|
||||
+3
-3
@@ -29,7 +29,7 @@ import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
|
||||
import org.jetbrains.kotlin.resolve.calls.tasks.TracingStrategy;
|
||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope;
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
public final class CallCandidateResolutionContext<D extends CallableDescriptor> extends CallResolutionContext<CallCandidateResolutionContext<D>> {
|
||||
@NotNull
|
||||
@@ -47,7 +47,7 @@ public final class CallCandidateResolutionContext<D extends CallableDescriptor>
|
||||
@NotNull BindingTrace trace,
|
||||
@NotNull LexicalScope scope,
|
||||
@NotNull Call call,
|
||||
@NotNull KtType expectedType,
|
||||
@NotNull KotlinType expectedType,
|
||||
@NotNull DataFlowInfo dataFlowInfo,
|
||||
@NotNull ContextDependency contextDependency,
|
||||
@NotNull CheckArgumentTypesMode checkArguments,
|
||||
@@ -99,7 +99,7 @@ public final class CallCandidateResolutionContext<D extends CallableDescriptor>
|
||||
@NotNull BindingTrace trace,
|
||||
@NotNull LexicalScope scope,
|
||||
@NotNull DataFlowInfo dataFlowInfo,
|
||||
@NotNull KtType expectedType,
|
||||
@NotNull KotlinType expectedType,
|
||||
@NotNull ContextDependency contextDependency,
|
||||
@NotNull ResolutionResultsCache resolutionResultsCache,
|
||||
@NotNull StatementFilter statementFilter,
|
||||
|
||||
+2
-2
@@ -26,7 +26,7 @@ import org.jetbrains.kotlin.resolve.calls.model.DataFlowInfoForArgumentsImpl;
|
||||
import org.jetbrains.kotlin.resolve.calls.model.MutableDataFlowInfoForArguments;
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
|
||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
public abstract class CallResolutionContext<Context extends CallResolutionContext<Context>> extends ResolutionContext<Context> {
|
||||
@NotNull
|
||||
@@ -40,7 +40,7 @@ public abstract class CallResolutionContext<Context extends CallResolutionContex
|
||||
@NotNull BindingTrace trace,
|
||||
@NotNull LexicalScope scope,
|
||||
@NotNull Call call,
|
||||
@NotNull KtType expectedType,
|
||||
@NotNull KotlinType expectedType,
|
||||
@NotNull DataFlowInfo dataFlowInfo,
|
||||
@NotNull ContextDependency contextDependency,
|
||||
@NotNull CheckArgumentTypesMode checkArguments,
|
||||
|
||||
+5
-5
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.resolve.StatementFilter;
|
||||
import org.jetbrains.kotlin.resolve.calls.checkers.CallChecker;
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
|
||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.TypeUtils;
|
||||
|
||||
/**
|
||||
@@ -38,7 +38,7 @@ public abstract class ResolutionContext<Context extends ResolutionContext<Contex
|
||||
@NotNull
|
||||
public final LexicalScope scope;
|
||||
@NotNull
|
||||
public final KtType expectedType;
|
||||
public final KotlinType expectedType;
|
||||
@NotNull
|
||||
public final DataFlowInfo dataFlowInfo;
|
||||
@NotNull
|
||||
@@ -60,7 +60,7 @@ public abstract class ResolutionContext<Context extends ResolutionContext<Contex
|
||||
protected ResolutionContext(
|
||||
@NotNull BindingTrace trace,
|
||||
@NotNull LexicalScope scope,
|
||||
@NotNull KtType expectedType,
|
||||
@NotNull KotlinType expectedType,
|
||||
@NotNull DataFlowInfo dataFlowInfo,
|
||||
@NotNull ContextDependency contextDependency,
|
||||
@NotNull ResolutionResultsCache resolutionResultsCache,
|
||||
@@ -87,7 +87,7 @@ public abstract class ResolutionContext<Context extends ResolutionContext<Contex
|
||||
@NotNull BindingTrace trace,
|
||||
@NotNull LexicalScope scope,
|
||||
@NotNull DataFlowInfo dataFlowInfo,
|
||||
@NotNull KtType expectedType,
|
||||
@NotNull KotlinType expectedType,
|
||||
@NotNull ContextDependency contextDependency,
|
||||
@NotNull ResolutionResultsCache resolutionResultsCache,
|
||||
@NotNull StatementFilter statementFilter,
|
||||
@@ -116,7 +116,7 @@ public abstract class ResolutionContext<Context extends ResolutionContext<Contex
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Context replaceExpectedType(@Nullable KtType newExpectedType) {
|
||||
public Context replaceExpectedType(@Nullable KotlinType newExpectedType) {
|
||||
if (newExpectedType == null) return replaceExpectedType(TypeUtils.NO_EXPECTED_TYPE);
|
||||
if (expectedType == newExpectedType) return self();
|
||||
return create(trace, scope, dataFlowInfo, newExpectedType, contextDependency, resolutionResultsCache, statementFilter,
|
||||
|
||||
+2
-2
@@ -17,7 +17,7 @@
|
||||
package org.jetbrains.kotlin.resolve.calls.inference;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
|
||||
@@ -40,7 +40,7 @@ public enum ConstraintType implements Comparable<ConstraintType> {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public SubtypingConstraint assertSubtyping(@NotNull KtType subtype, @NotNull KtType supertype) {
|
||||
public SubtypingConstraint assertSubtyping(@NotNull KotlinType subtype, @NotNull KotlinType supertype) {
|
||||
return new SubtypingConstraint(this, subtype, supertype);
|
||||
}
|
||||
|
||||
|
||||
+8
-8
@@ -45,10 +45,10 @@ public class ConstraintsUtil {
|
||||
TypeParameterDescriptor firstConflictingParameter = getFirstConflictingParameter(constraintSystem);
|
||||
if (firstConflictingParameter == null) return Collections.emptyList();
|
||||
|
||||
Collection<KtType> conflictingTypes = constraintSystem.getTypeBounds(firstConflictingParameter).getValues();
|
||||
Collection<KotlinType> conflictingTypes = constraintSystem.getTypeBounds(firstConflictingParameter).getValues();
|
||||
|
||||
List<Map<TypeConstructor, TypeProjection>> substitutionContexts = Lists.newArrayList();
|
||||
for (KtType type : conflictingTypes) {
|
||||
for (KotlinType type : conflictingTypes) {
|
||||
Map<TypeConstructor, TypeProjection> context = Maps.newLinkedHashMap();
|
||||
context.put(firstConflictingParameter.getTypeConstructor(), new TypeProjectionImpl(type));
|
||||
substitutionContexts.add(context);
|
||||
@@ -57,7 +57,7 @@ public class ConstraintsUtil {
|
||||
for (TypeParameterDescriptor typeParameter : constraintSystem.getTypeVariables()) {
|
||||
if (typeParameter == firstConflictingParameter) continue;
|
||||
|
||||
KtType safeType = getSafeValue(constraintSystem, typeParameter);
|
||||
KotlinType safeType = getSafeValue(constraintSystem, typeParameter);
|
||||
for (Map<TypeConstructor, TypeProjection> context : substitutionContexts) {
|
||||
TypeProjection typeProjection = new TypeProjectionImpl(safeType);
|
||||
context.put(typeParameter.getTypeConstructor(), typeProjection);
|
||||
@@ -71,8 +71,8 @@ public class ConstraintsUtil {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static KtType getSafeValue(@NotNull ConstraintSystem constraintSystem, @NotNull TypeParameterDescriptor typeParameter) {
|
||||
KtType type = constraintSystem.getTypeBounds(typeParameter).getValue();
|
||||
public static KotlinType getSafeValue(@NotNull ConstraintSystem constraintSystem, @NotNull TypeParameterDescriptor typeParameter) {
|
||||
KotlinType type = constraintSystem.getTypeBounds(typeParameter).getValue();
|
||||
if (type != null) {
|
||||
return type;
|
||||
}
|
||||
@@ -85,13 +85,13 @@ public class ConstraintsUtil {
|
||||
@NotNull TypeParameterDescriptor typeParameter,
|
||||
boolean substituteOtherTypeParametersInBound
|
||||
) {
|
||||
KtType type = constraintSystem.getTypeBounds(typeParameter).getValue();
|
||||
KotlinType type = constraintSystem.getTypeBounds(typeParameter).getValue();
|
||||
if (type == null) return true;
|
||||
for (KtType upperBound : typeParameter.getUpperBounds()) {
|
||||
for (KotlinType upperBound : typeParameter.getUpperBounds()) {
|
||||
if (!substituteOtherTypeParametersInBound && TypeUtils.dependsOnTypeParameters(upperBound, constraintSystem.getTypeVariables())) {
|
||||
continue;
|
||||
}
|
||||
KtType substitutedUpperBound = constraintSystem.getResultingSubstitutor().substitute(upperBound, Variance.INVARIANT);
|
||||
KotlinType substitutedUpperBound = constraintSystem.getResultingSubstitutor().substitute(upperBound, Variance.INVARIANT);
|
||||
|
||||
assert substitutedUpperBound != null : "We wanted to substitute projections as a result for " + typeParameter;
|
||||
if (!KotlinTypeChecker.DEFAULT.isSubtypeOf(type, substitutedUpperBound)) {
|
||||
|
||||
+6
-6
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.resolve.calls.inference;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -29,16 +29,16 @@ public class InferenceErrorData {
|
||||
@NotNull
|
||||
public final ConstraintSystem constraintSystem;
|
||||
@Nullable
|
||||
public final KtType receiverArgumentType;
|
||||
public final KotlinType receiverArgumentType;
|
||||
@NotNull
|
||||
public final KtType expectedType;
|
||||
public final KotlinType expectedType;
|
||||
@NotNull
|
||||
public final List<KtType> valueArgumentsTypes;
|
||||
public final List<KotlinType> valueArgumentsTypes;
|
||||
|
||||
|
||||
private InferenceErrorData(
|
||||
@NotNull CallableDescriptor descriptor, @NotNull ConstraintSystem constraintSystem,
|
||||
@NotNull List<KtType> valueArgumentsTypes, @Nullable KtType receiverArgumentType, @NotNull KtType expectedType
|
||||
@NotNull List<KotlinType> valueArgumentsTypes, @Nullable KotlinType receiverArgumentType, @NotNull KotlinType expectedType
|
||||
) {
|
||||
this.descriptor = descriptor;
|
||||
this.constraintSystem = constraintSystem;
|
||||
@@ -49,7 +49,7 @@ public class InferenceErrorData {
|
||||
|
||||
@NotNull
|
||||
public static InferenceErrorData create(@NotNull CallableDescriptor descriptor, @NotNull ConstraintSystem constraintSystem,
|
||||
@NotNull List<KtType> valueArgumentsTypes, @Nullable KtType receiverArgumentType, @NotNull KtType expectedType) {
|
||||
@NotNull List<KotlinType> valueArgumentsTypes, @Nullable KotlinType receiverArgumentType, @NotNull KotlinType expectedType) {
|
||||
return new InferenceErrorData(descriptor, constraintSystem, valueArgumentsTypes, receiverArgumentType, expectedType);
|
||||
}
|
||||
}
|
||||
|
||||
+6
-6
@@ -17,26 +17,26 @@
|
||||
package org.jetbrains.kotlin.resolve.calls.inference;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
public class SubtypingConstraint {
|
||||
private final ConstraintType type;
|
||||
private final KtType subtype;
|
||||
private final KtType supertype;
|
||||
private final KotlinType subtype;
|
||||
private final KotlinType supertype;
|
||||
|
||||
public SubtypingConstraint(@NotNull ConstraintType type, @NotNull KtType subtype, @NotNull KtType supertype) {
|
||||
public SubtypingConstraint(@NotNull ConstraintType type, @NotNull KotlinType subtype, @NotNull KotlinType supertype) {
|
||||
this.type = type;
|
||||
this.subtype = subtype;
|
||||
this.supertype = supertype;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public KtType getSubtype() {
|
||||
public KotlinType getSubtype() {
|
||||
return subtype;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public KtType getSupertype() {
|
||||
public KotlinType getSupertype() {
|
||||
return supertype;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -26,7 +26,7 @@ import org.jetbrains.kotlin.psi.ValueArgument;
|
||||
import org.jetbrains.kotlin.resolve.calls.results.ResolutionStatus;
|
||||
import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind;
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -100,7 +100,7 @@ public abstract class DelegatingResolvedCall<D extends CallableDescriptor> imple
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Map<TypeParameterDescriptor, KtType> getTypeArguments() {
|
||||
public Map<TypeParameterDescriptor, KotlinType> getTypeArguments() {
|
||||
return resolvedCall.getTypeArguments();
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.jetbrains.kotlin.psi.ValueArgument;
|
||||
import org.jetbrains.kotlin.resolve.calls.results.ResolutionStatus;
|
||||
import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind;
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -73,7 +73,7 @@ public interface ResolvedCall<D extends CallableDescriptor> {
|
||||
|
||||
/** What's substituted for type parameters */
|
||||
@NotNull
|
||||
Map<TypeParameterDescriptor, KtType> getTypeArguments();
|
||||
Map<TypeParameterDescriptor, KotlinType> getTypeArguments();
|
||||
|
||||
/** Data flow info for each argument and the result data flow info */
|
||||
@NotNull
|
||||
|
||||
+3
-3
@@ -35,7 +35,7 @@ import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind;
|
||||
import org.jetbrains.kotlin.resolve.calls.tasks.ResolutionCandidate;
|
||||
import org.jetbrains.kotlin.resolve.calls.tasks.TracingStrategy;
|
||||
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.TypeProjection;
|
||||
import org.jetbrains.kotlin.types.TypeSubstitutor;
|
||||
|
||||
@@ -81,7 +81,7 @@ public class ResolvedCallImpl<D extends CallableDescriptor> implements MutableRe
|
||||
private final ExplicitReceiverKind explicitReceiverKind;
|
||||
private final TypeSubstitutor knownTypeParametersSubstitutor;
|
||||
|
||||
private final Map<TypeParameterDescriptor, KtType> typeArguments = Maps.newLinkedHashMap();
|
||||
private final Map<TypeParameterDescriptor, KotlinType> typeArguments = Maps.newLinkedHashMap();
|
||||
private final Map<ValueParameterDescriptor, ResolvedValueArgument> valueArguments = Maps.newLinkedHashMap();
|
||||
private final MutableDataFlowInfoForArguments dataFlowInfoForArguments;
|
||||
private final Map<ValueArgument, ArgumentMatchImpl> argumentToParameterMap = Maps.newHashMap();
|
||||
@@ -287,7 +287,7 @@ public class ResolvedCallImpl<D extends CallableDescriptor> implements MutableRe
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Map<TypeParameterDescriptor, KtType> getTypeArguments() {
|
||||
public Map<TypeParameterDescriptor, KotlinType> getTypeArguments() {
|
||||
return typeArguments;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.descriptors.CallableDescriptor;
|
||||
import org.jetbrains.kotlin.resolve.calls.context.ContextDependency;
|
||||
import org.jetbrains.kotlin.resolve.calls.model.MutableResolvedCall;
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@@ -37,7 +37,7 @@ public class OverloadResolutionResultsUtil {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static <D extends CallableDescriptor> KtType getResultingType(
|
||||
public static <D extends CallableDescriptor> KotlinType getResultingType(
|
||||
@NotNull OverloadResolutionResults<D> results,
|
||||
@NotNull ContextDependency contextDependency
|
||||
) {
|
||||
|
||||
+16
-16
@@ -164,8 +164,8 @@ public class OverloadingConflictResolver {
|
||||
ValueParameterDescriptor fParam = fParams.get(i);
|
||||
ValueParameterDescriptor gParam = gParams.get(i);
|
||||
|
||||
KtType fParamType = fParam.getType();
|
||||
KtType gParamType = gParam.getType();
|
||||
KotlinType fParamType = fParam.getType();
|
||||
KotlinType gParamType = gParam.getType();
|
||||
|
||||
if (!typeMoreSpecific(fParamType, gParamType)) {
|
||||
return false;
|
||||
@@ -180,8 +180,8 @@ public class OverloadingConflictResolver {
|
||||
ValueParameterDescriptor fParam = fParams.get(i);
|
||||
ValueParameterDescriptor gParam = gParams.get(i);
|
||||
|
||||
KtType fParamType = fParam.getType();
|
||||
KtType gParamType = gParam.getType();
|
||||
KotlinType fParamType = fParam.getType();
|
||||
KotlinType gParamType = gParam.getType();
|
||||
|
||||
if (!typeMoreSpecific(fParamType, gParamType)) {
|
||||
return false;
|
||||
@@ -195,7 +195,7 @@ public class OverloadingConflictResolver {
|
||||
// here we check that typeOf(a) < elementTypeOf(vf) and elementTypeOf(vg) < elementTypeOf(vf)
|
||||
if (fSize < gSize) {
|
||||
ValueParameterDescriptor fParam = fParams.get(fSize - 1);
|
||||
KtType fParamType = fParam.getVarargElementType();
|
||||
KotlinType fParamType = fParam.getVarargElementType();
|
||||
assert fParamType != null : "fIsVararg guarantees this";
|
||||
for (int i = fSize - 1; i < gSize; i++) {
|
||||
ValueParameterDescriptor gParam = gParams.get(i);
|
||||
@@ -206,7 +206,7 @@ public class OverloadingConflictResolver {
|
||||
}
|
||||
else {
|
||||
ValueParameterDescriptor gParam = gParams.get(gSize - 1);
|
||||
KtType gParamType = gParam.getVarargElementType();
|
||||
KotlinType gParamType = gParam.getVarargElementType();
|
||||
assert gParamType != null : "gIsVararg guarantees this";
|
||||
for (int i = gSize - 1; i < fSize; i++) {
|
||||
ValueParameterDescriptor fParam = fParams.get(i);
|
||||
@@ -221,8 +221,8 @@ public class OverloadingConflictResolver {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static KtType getVarargElementTypeOrType(@NotNull ValueParameterDescriptor parameterDescriptor) {
|
||||
KtType varargElementType = parameterDescriptor.getVarargElementType();
|
||||
private static KotlinType getVarargElementTypeOrType(@NotNull ValueParameterDescriptor parameterDescriptor) {
|
||||
KotlinType varargElementType = parameterDescriptor.getVarargElementType();
|
||||
if (varargElementType != null) {
|
||||
return varargElementType;
|
||||
}
|
||||
@@ -238,7 +238,7 @@ public class OverloadingConflictResolver {
|
||||
return !f.getOriginal().getTypeParameters().isEmpty();
|
||||
}
|
||||
|
||||
private boolean typeMoreSpecific(@NotNull KtType specific, @NotNull KtType general) {
|
||||
private boolean typeMoreSpecific(@NotNull KotlinType specific, @NotNull KotlinType general) {
|
||||
boolean isSubtype = KotlinTypeChecker.DEFAULT.isSubtypeOf(specific, general) ||
|
||||
numericTypeMoreSpecific(specific, general);
|
||||
|
||||
@@ -253,13 +253,13 @@ public class OverloadingConflictResolver {
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean numericTypeMoreSpecific(@NotNull KtType specific, @NotNull KtType general) {
|
||||
KtType _double = builtIns.getDoubleType();
|
||||
KtType _float = builtIns.getFloatType();
|
||||
KtType _long = builtIns.getLongType();
|
||||
KtType _int = builtIns.getIntType();
|
||||
KtType _byte = builtIns.getByteType();
|
||||
KtType _short = builtIns.getShortType();
|
||||
private boolean numericTypeMoreSpecific(@NotNull KotlinType specific, @NotNull KotlinType general) {
|
||||
KotlinType _double = builtIns.getDoubleType();
|
||||
KotlinType _float = builtIns.getFloatType();
|
||||
KotlinType _long = builtIns.getLongType();
|
||||
KotlinType _int = builtIns.getIntType();
|
||||
KotlinType _byte = builtIns.getByteType();
|
||||
KotlinType _short = builtIns.getShortType();
|
||||
|
||||
if (TypeUtils.equalTypes(specific, _double) && TypeUtils.equalTypes(general, _float)) return true;
|
||||
if (TypeUtils.equalTypes(specific, _int)) {
|
||||
|
||||
+4
-4
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.resolve.calls.smartcasts;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.SetMultimap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@@ -35,7 +35,7 @@ public interface DataFlowInfo {
|
||||
Map<DataFlowValue, Nullability> getCompleteNullabilityInfo();
|
||||
|
||||
@NotNull
|
||||
SetMultimap<DataFlowValue, KtType> getCompleteTypeInfo();
|
||||
SetMultimap<DataFlowValue, KotlinType> getCompleteTypeInfo();
|
||||
|
||||
@NotNull
|
||||
Nullability getNullability(@NotNull DataFlowValue key);
|
||||
@@ -45,7 +45,7 @@ public interface DataFlowInfo {
|
||||
* are NOT included. So it's quite possible to get an empty set here.
|
||||
*/
|
||||
@NotNull
|
||||
Set<KtType> getPossibleTypes(@NotNull DataFlowValue key);
|
||||
Set<KotlinType> getPossibleTypes(@NotNull DataFlowValue key);
|
||||
|
||||
/**
|
||||
* Call this function to clear all data flow information about
|
||||
@@ -73,7 +73,7 @@ public interface DataFlowInfo {
|
||||
DataFlowInfo disequate(@NotNull DataFlowValue a, @NotNull DataFlowValue b);
|
||||
|
||||
@NotNull
|
||||
DataFlowInfo establishSubtyping(@NotNull DataFlowValue value, @NotNull KtType type);
|
||||
DataFlowInfo establishSubtyping(@NotNull DataFlowValue value, @NotNull KotlinType type);
|
||||
|
||||
/**
|
||||
* Call this function to add data flow information from other to this and return sum as the result
|
||||
|
||||
+2
-2
@@ -18,13 +18,13 @@ package org.jetbrains.kotlin.resolve.calls.smartcasts
|
||||
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.types.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
/**
|
||||
* This class describes an arbitrary object which has some value in data flow analysis.
|
||||
* In general case it's some r-value.
|
||||
*/
|
||||
class DataFlowValue(val id: Any?, val type: KtType, val kind: DataFlowValue.Kind, val immanentNullability: Nullability) {
|
||||
class DataFlowValue(val id: Any?, val type: KotlinType, val kind: DataFlowValue.Kind, val immanentNullability: Nullability) {
|
||||
|
||||
enum class Kind(private val str: String) {
|
||||
// Smart casts are completely safe
|
||||
|
||||
+7
-7
@@ -36,7 +36,7 @@ import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt;
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValue.Kind;
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.*;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.TypeUtils;
|
||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils;
|
||||
import org.jetbrains.kotlin.types.expressions.PreliminaryDeclarationVisitor;
|
||||
@@ -59,7 +59,7 @@ public class DataFlowValueFactory {
|
||||
@NotNull
|
||||
public static DataFlowValue createDataFlowValue(
|
||||
@NotNull KtExpression expression,
|
||||
@NotNull KtType type,
|
||||
@NotNull KotlinType type,
|
||||
@NotNull ResolutionContext resolutionContext
|
||||
) {
|
||||
return createDataFlowValue(expression, type, resolutionContext.trace.getBindingContext(),
|
||||
@@ -69,7 +69,7 @@ public class DataFlowValueFactory {
|
||||
@NotNull
|
||||
public static DataFlowValue createDataFlowValue(
|
||||
@NotNull KtExpression expression,
|
||||
@NotNull KtType type,
|
||||
@NotNull KotlinType type,
|
||||
@NotNull BindingContext bindingContext,
|
||||
@NotNull DeclarationDescriptor containingDeclarationOrModule
|
||||
) {
|
||||
@@ -105,7 +105,7 @@ public class DataFlowValueFactory {
|
||||
|
||||
@NotNull
|
||||
public static DataFlowValue createDataFlowValue(@NotNull ThisReceiver receiver) {
|
||||
KtType type = receiver.getType();
|
||||
KotlinType type = receiver.getType();
|
||||
return new DataFlowValue(receiver, type, STABLE_VALUE, getImmanentNullability(type));
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ public class DataFlowValueFactory {
|
||||
) {
|
||||
if (receiverValue instanceof TransientReceiver || receiverValue instanceof ScriptReceiver) {
|
||||
// SCRIPT: smartcasts data flow
|
||||
KtType type = receiverValue.getType();
|
||||
KotlinType type = receiverValue.getType();
|
||||
return new DataFlowValue(receiverValue, type, STABLE_VALUE, getImmanentNullability(type));
|
||||
}
|
||||
else if (receiverValue instanceof ClassReceiver || receiverValue instanceof ExtensionReceiver) {
|
||||
@@ -153,7 +153,7 @@ public class DataFlowValueFactory {
|
||||
@NotNull BindingContext bindingContext,
|
||||
@Nullable ModuleDescriptor usageContainingModule
|
||||
) {
|
||||
KtType type = variableDescriptor.getType();
|
||||
KotlinType type = variableDescriptor.getType();
|
||||
return new DataFlowValue(variableDescriptor, type,
|
||||
variableKind(variableDescriptor, usageContainingModule,
|
||||
bindingContext, property),
|
||||
@@ -161,7 +161,7 @@ public class DataFlowValueFactory {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Nullability getImmanentNullability(@NotNull KtType type) {
|
||||
private static Nullability getImmanentNullability(@NotNull KotlinType type) {
|
||||
return TypeUtils.isNullableType(type) ? Nullability.UNKNOWN : Nullability.NOT_NULL;
|
||||
}
|
||||
|
||||
|
||||
+28
-28
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.resolve.calls.smartcasts;
|
||||
import com.google.common.collect.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.TypeUtils;
|
||||
|
||||
import java.util.HashSet;
|
||||
@@ -31,7 +31,7 @@ import static org.jetbrains.kotlin.resolve.calls.smartcasts.Nullability.NOT_NULL
|
||||
|
||||
/* package */ class DelegatingDataFlowInfo implements DataFlowInfo {
|
||||
private static final ImmutableMap<DataFlowValue, Nullability> EMPTY_NULLABILITY_INFO = ImmutableMap.of();
|
||||
private static final SetMultimap<DataFlowValue, KtType> EMPTY_TYPE_INFO = newTypeInfo();
|
||||
private static final SetMultimap<DataFlowValue, KotlinType> EMPTY_TYPE_INFO = newTypeInfo();
|
||||
|
||||
@Nullable
|
||||
private final DataFlowInfo parent;
|
||||
@@ -41,7 +41,7 @@ import static org.jetbrains.kotlin.resolve.calls.smartcasts.Nullability.NOT_NULL
|
||||
|
||||
// Also immutable
|
||||
@NotNull
|
||||
private final SetMultimap<DataFlowValue, KtType> typeInfo;
|
||||
private final SetMultimap<DataFlowValue, KotlinType> typeInfo;
|
||||
|
||||
/**
|
||||
* Value for which type info was cleared or reassigned at this point
|
||||
@@ -53,7 +53,7 @@ import static org.jetbrains.kotlin.resolve.calls.smartcasts.Nullability.NOT_NULL
|
||||
/* package */ DelegatingDataFlowInfo(
|
||||
@Nullable DataFlowInfo parent,
|
||||
@NotNull ImmutableMap<DataFlowValue, Nullability> nullabilityInfo,
|
||||
@NotNull SetMultimap<DataFlowValue, KtType> typeInfo
|
||||
@NotNull SetMultimap<DataFlowValue, KotlinType> typeInfo
|
||||
) {
|
||||
this(parent, nullabilityInfo, typeInfo, null);
|
||||
}
|
||||
@@ -61,7 +61,7 @@ import static org.jetbrains.kotlin.resolve.calls.smartcasts.Nullability.NOT_NULL
|
||||
/* package */ DelegatingDataFlowInfo(
|
||||
@Nullable DataFlowInfo parent,
|
||||
@NotNull ImmutableMap<DataFlowValue, Nullability> nullabilityInfo,
|
||||
@NotNull SetMultimap<DataFlowValue, KtType> typeInfo,
|
||||
@NotNull SetMultimap<DataFlowValue, KotlinType> typeInfo,
|
||||
@Nullable DataFlowValue valueWithGivenTypeInfo
|
||||
) {
|
||||
this.parent = parent;
|
||||
@@ -90,8 +90,8 @@ import static org.jetbrains.kotlin.resolve.calls.smartcasts.Nullability.NOT_NULL
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public SetMultimap<DataFlowValue, KtType> getCompleteTypeInfo() {
|
||||
SetMultimap<DataFlowValue, KtType> result = newTypeInfo();
|
||||
public SetMultimap<DataFlowValue, KotlinType> getCompleteTypeInfo() {
|
||||
SetMultimap<DataFlowValue, KotlinType> result = newTypeInfo();
|
||||
Set<DataFlowValue> withGivenTypeInfo = new HashSet<DataFlowValue>();
|
||||
DelegatingDataFlowInfo info = this;
|
||||
while (info != null) {
|
||||
@@ -130,18 +130,18 @@ import static org.jetbrains.kotlin.resolve.calls.smartcasts.Nullability.NOT_NULL
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Set<KtType> getPossibleTypes(@NotNull DataFlowValue key) {
|
||||
KtType originalType = key.getType();
|
||||
Set<KtType> types = collectTypesFromMeAndParents(key);
|
||||
public Set<KotlinType> getPossibleTypes(@NotNull DataFlowValue key) {
|
||||
KotlinType originalType = key.getType();
|
||||
Set<KotlinType> types = collectTypesFromMeAndParents(key);
|
||||
if (getNullability(key).canBeNull()) {
|
||||
return types;
|
||||
}
|
||||
|
||||
Set<KtType> enrichedTypes = Sets.newHashSetWithExpectedSize(types.size() + 1);
|
||||
Set<KotlinType> enrichedTypes = Sets.newHashSetWithExpectedSize(types.size() + 1);
|
||||
if (originalType.isMarkedNullable()) {
|
||||
enrichedTypes.add(TypeUtils.makeNotNullable(originalType));
|
||||
}
|
||||
for (KtType type : types) {
|
||||
for (KotlinType type : types) {
|
||||
enrichedTypes.add(TypeUtils.makeNotNullable(type));
|
||||
}
|
||||
|
||||
@@ -174,8 +174,8 @@ import static org.jetbrains.kotlin.resolve.calls.smartcasts.Nullability.NOT_NULL
|
||||
Nullability nullabilityOfB = getNullability(b);
|
||||
putNullability(nullability, a, nullabilityOfB);
|
||||
|
||||
SetMultimap<DataFlowValue, KtType> newTypeInfo = newTypeInfo();
|
||||
Set<KtType> typesForB = collectTypesFromMeAndParents(b);
|
||||
SetMultimap<DataFlowValue, KotlinType> newTypeInfo = newTypeInfo();
|
||||
Set<KotlinType> typesForB = collectTypesFromMeAndParents(b);
|
||||
// Own type of B must be recorded separately, e.g. for a constant
|
||||
// But if its type is the same as A or it's null, there is no reason to do it
|
||||
// because usually null type or own type are not saved in this set
|
||||
@@ -203,7 +203,7 @@ import static org.jetbrains.kotlin.resolve.calls.smartcasts.Nullability.NOT_NULL
|
||||
changed |= putNullability(builder, a, nullabilityOfA.refine(nullabilityOfB));
|
||||
changed |= putNullability(builder, b, nullabilityOfB.refine(nullabilityOfA));
|
||||
|
||||
SetMultimap<DataFlowValue, KtType> newTypeInfo = newTypeInfo();
|
||||
SetMultimap<DataFlowValue, KotlinType> newTypeInfo = newTypeInfo();
|
||||
newTypeInfo.putAll(a, collectTypesFromMeAndParents(b));
|
||||
newTypeInfo.putAll(b, collectTypesFromMeAndParents(a));
|
||||
changed |= !newTypeInfo.isEmpty();
|
||||
@@ -218,8 +218,8 @@ import static org.jetbrains.kotlin.resolve.calls.smartcasts.Nullability.NOT_NULL
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Set<KtType> collectTypesFromMeAndParents(@NotNull DataFlowValue value) {
|
||||
Set<KtType> types = new LinkedHashSet<KtType>();
|
||||
private Set<KotlinType> collectTypesFromMeAndParents(@NotNull DataFlowValue value) {
|
||||
Set<KotlinType> types = new LinkedHashSet<KotlinType>();
|
||||
|
||||
DataFlowInfo current = this;
|
||||
while (current != null) {
|
||||
@@ -257,12 +257,12 @@ import static org.jetbrains.kotlin.resolve.calls.smartcasts.Nullability.NOT_NULL
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public DataFlowInfo establishSubtyping(@NotNull DataFlowValue value, @NotNull KtType type) {
|
||||
public DataFlowInfo establishSubtyping(@NotNull DataFlowValue value, @NotNull KotlinType type) {
|
||||
if (value.getType().equals(type)) return this;
|
||||
if (getPossibleTypes(value).contains(type)) return this;
|
||||
ImmutableMap<DataFlowValue, Nullability> newNullabilityInfo =
|
||||
type.isMarkedNullable() ? EMPTY_NULLABILITY_INFO : ImmutableMap.of(value, NOT_NULL);
|
||||
SetMultimap<DataFlowValue, KtType> newTypeInfo = ImmutableSetMultimap.of(value, type);
|
||||
SetMultimap<DataFlowValue, KotlinType> newTypeInfo = ImmutableSetMultimap.of(value, type);
|
||||
return new DelegatingDataFlowInfo(this, newNullabilityInfo, newTypeInfo);
|
||||
}
|
||||
|
||||
@@ -287,8 +287,8 @@ import static org.jetbrains.kotlin.resolve.calls.smartcasts.Nullability.NOT_NULL
|
||||
}
|
||||
}
|
||||
|
||||
SetMultimap<DataFlowValue, KtType> myTypeInfo = getCompleteTypeInfo();
|
||||
SetMultimap<DataFlowValue, KtType> otherTypeInfo = other.getCompleteTypeInfo();
|
||||
SetMultimap<DataFlowValue, KotlinType> myTypeInfo = getCompleteTypeInfo();
|
||||
SetMultimap<DataFlowValue, KotlinType> otherTypeInfo = other.getCompleteTypeInfo();
|
||||
if (nullabilityMapBuilder.isEmpty() && containsAll(myTypeInfo, otherTypeInfo)) {
|
||||
return this;
|
||||
}
|
||||
@@ -296,7 +296,7 @@ import static org.jetbrains.kotlin.resolve.calls.smartcasts.Nullability.NOT_NULL
|
||||
return new DelegatingDataFlowInfo(this, ImmutableMap.copyOf(nullabilityMapBuilder), otherTypeInfo);
|
||||
}
|
||||
|
||||
private static boolean containsAll(SetMultimap<DataFlowValue, KtType> first, SetMultimap<DataFlowValue, KtType> second) {
|
||||
private static boolean containsAll(SetMultimap<DataFlowValue, KotlinType> first, SetMultimap<DataFlowValue, KotlinType> second) {
|
||||
return first.entries().containsAll(second.entries());
|
||||
}
|
||||
|
||||
@@ -318,13 +318,13 @@ import static org.jetbrains.kotlin.resolve.calls.smartcasts.Nullability.NOT_NULL
|
||||
nullabilityMapBuilder.put(key, thisFlags.or(otherFlags));
|
||||
}
|
||||
|
||||
SetMultimap<DataFlowValue, KtType> myTypeInfo = getCompleteTypeInfo();
|
||||
SetMultimap<DataFlowValue, KtType> otherTypeInfo = other.getCompleteTypeInfo();
|
||||
SetMultimap<DataFlowValue, KtType> newTypeInfo = newTypeInfo();
|
||||
SetMultimap<DataFlowValue, KotlinType> myTypeInfo = getCompleteTypeInfo();
|
||||
SetMultimap<DataFlowValue, KotlinType> otherTypeInfo = other.getCompleteTypeInfo();
|
||||
SetMultimap<DataFlowValue, KotlinType> newTypeInfo = newTypeInfo();
|
||||
|
||||
for (DataFlowValue key : Sets.intersection(myTypeInfo.keySet(), otherTypeInfo.keySet())) {
|
||||
Set<KtType> thisTypes = myTypeInfo.get(key);
|
||||
Set<KtType> otherTypes = otherTypeInfo.get(key);
|
||||
Set<KotlinType> thisTypes = myTypeInfo.get(key);
|
||||
Set<KotlinType> otherTypes = otherTypeInfo.get(key);
|
||||
newTypeInfo.putAll(key, Sets.intersection(thisTypes, otherTypes));
|
||||
}
|
||||
|
||||
@@ -336,7 +336,7 @@ import static org.jetbrains.kotlin.resolve.calls.smartcasts.Nullability.NOT_NULL
|
||||
}
|
||||
|
||||
@NotNull
|
||||
/* package */ static SetMultimap<DataFlowValue, KtType> newTypeInfo() {
|
||||
/* package */ static SetMultimap<DataFlowValue, KotlinType> newTypeInfo() {
|
||||
return LinkedHashMultimap.create();
|
||||
}
|
||||
|
||||
|
||||
+25
-25
@@ -29,7 +29,7 @@ import org.jetbrains.kotlin.resolve.BindingTrace;
|
||||
import org.jetbrains.kotlin.resolve.calls.ArgumentTypeResolver;
|
||||
import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext;
|
||||
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.TypeIntersector;
|
||||
import org.jetbrains.kotlin.types.TypeUtils;
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
|
||||
@@ -44,7 +44,7 @@ import static org.jetbrains.kotlin.resolve.BindingContext.SMARTCAST;
|
||||
public class SmartCastManager {
|
||||
|
||||
@NotNull
|
||||
public List<KtType> getSmartCastVariants(
|
||||
public List<KotlinType> getSmartCastVariants(
|
||||
@NotNull ReceiverValue receiverToCast,
|
||||
@NotNull ResolutionContext context
|
||||
) {
|
||||
@@ -52,33 +52,33 @@ public class SmartCastManager {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<KtType> getSmartCastVariants(
|
||||
public List<KotlinType> getSmartCastVariants(
|
||||
@NotNull ReceiverValue receiverToCast,
|
||||
@NotNull BindingContext bindingContext,
|
||||
@NotNull DeclarationDescriptor containingDeclarationOrModule,
|
||||
@NotNull DataFlowInfo dataFlowInfo
|
||||
) {
|
||||
List<KtType> variants = Lists.newArrayList();
|
||||
List<KotlinType> variants = Lists.newArrayList();
|
||||
variants.add(receiverToCast.getType());
|
||||
variants.addAll(getSmartCastVariantsExcludingReceiver(bindingContext, containingDeclarationOrModule, dataFlowInfo, receiverToCast));
|
||||
return variants;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<KtType> getSmartCastVariantsWithLessSpecificExcluded(
|
||||
public List<KotlinType> getSmartCastVariantsWithLessSpecificExcluded(
|
||||
@NotNull ReceiverValue receiverToCast,
|
||||
@NotNull BindingContext bindingContext,
|
||||
@NotNull DeclarationDescriptor containingDeclarationOrModule,
|
||||
@NotNull DataFlowInfo dataFlowInfo
|
||||
) {
|
||||
final List<KtType> variants = getSmartCastVariants(receiverToCast, bindingContext,
|
||||
containingDeclarationOrModule, dataFlowInfo);
|
||||
return CollectionsKt.filter(variants, new Function1<KtType, Boolean>() {
|
||||
final List<KotlinType> variants = getSmartCastVariants(receiverToCast, bindingContext,
|
||||
containingDeclarationOrModule, dataFlowInfo);
|
||||
return CollectionsKt.filter(variants, new Function1<KotlinType, Boolean>() {
|
||||
@Override
|
||||
public Boolean invoke(final KtType type) {
|
||||
return !CollectionsKt.any(variants, new Function1<KtType, Boolean>() {
|
||||
public Boolean invoke(final KotlinType type) {
|
||||
return !CollectionsKt.any(variants, new Function1<KotlinType, Boolean>() {
|
||||
@Override
|
||||
public Boolean invoke(KtType another) {
|
||||
public Boolean invoke(KotlinType another) {
|
||||
return another != type && KotlinTypeChecker.DEFAULT.isSubtypeOf(another, type);
|
||||
}
|
||||
});
|
||||
@@ -90,7 +90,7 @@ public class SmartCastManager {
|
||||
* @return variants @param receiverToCast may be cast to according to context dataFlowInfo, receiverToCast itself is NOT included
|
||||
*/
|
||||
@NotNull
|
||||
public Collection<KtType> getSmartCastVariantsExcludingReceiver(
|
||||
public Collection<KotlinType> getSmartCastVariantsExcludingReceiver(
|
||||
@NotNull ResolutionContext context,
|
||||
@NotNull ReceiverValue receiverToCast
|
||||
) {
|
||||
@@ -104,7 +104,7 @@ public class SmartCastManager {
|
||||
* @return variants @param receiverToCast may be cast to according to @param dataFlowInfo, @param receiverToCast itself is NOT included
|
||||
*/
|
||||
@NotNull
|
||||
public Collection<KtType> getSmartCastVariantsExcludingReceiver(
|
||||
public Collection<KotlinType> getSmartCastVariantsExcludingReceiver(
|
||||
@NotNull BindingContext bindingContext,
|
||||
@NotNull DeclarationDescriptor containingDeclarationOrModule,
|
||||
@NotNull DataFlowInfo dataFlowInfo,
|
||||
@@ -119,27 +119,27 @@ public class SmartCastManager {
|
||||
|
||||
public boolean isSubTypeBySmartCastIgnoringNullability(
|
||||
@NotNull ReceiverValue receiverArgument,
|
||||
@NotNull KtType receiverParameterType,
|
||||
@NotNull KotlinType receiverParameterType,
|
||||
@NotNull ResolutionContext context
|
||||
) {
|
||||
List<KtType> smartCastTypes = getSmartCastVariants(receiverArgument, context);
|
||||
List<KotlinType> smartCastTypes = getSmartCastVariants(receiverArgument, context);
|
||||
return getSmartCastSubType(TypeUtils.makeNullable(receiverParameterType), smartCastTypes) != null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private KtType getSmartCastSubType(
|
||||
@NotNull KtType receiverParameterType,
|
||||
@NotNull Collection<KtType> smartCastTypes
|
||||
private KotlinType getSmartCastSubType(
|
||||
@NotNull KotlinType receiverParameterType,
|
||||
@NotNull Collection<KotlinType> smartCastTypes
|
||||
) {
|
||||
Set<KtType> subTypes = Sets.newHashSet();
|
||||
for (KtType smartCastType : smartCastTypes) {
|
||||
Set<KotlinType> subTypes = Sets.newHashSet();
|
||||
for (KotlinType smartCastType : smartCastTypes) {
|
||||
if (ArgumentTypeResolver.isSubtypeOfForArgumentType(smartCastType, receiverParameterType)) {
|
||||
subTypes.add(smartCastType);
|
||||
}
|
||||
}
|
||||
if (subTypes.isEmpty()) return null;
|
||||
|
||||
KtType intersection = TypeIntersector.intersectTypes(KotlinTypeChecker.DEFAULT, subTypes);
|
||||
KotlinType intersection = TypeIntersector.intersectTypes(KotlinTypeChecker.DEFAULT, subTypes);
|
||||
if (intersection == null || !intersection.getConstructor().isDenotable()) {
|
||||
return receiverParameterType;
|
||||
}
|
||||
@@ -148,7 +148,7 @@ public class SmartCastManager {
|
||||
|
||||
private static void recordCastOrError(
|
||||
@NotNull KtExpression expression,
|
||||
@NotNull KtType type,
|
||||
@NotNull KotlinType type,
|
||||
@NotNull BindingTrace trace,
|
||||
boolean canBeCast,
|
||||
boolean recordExpressionType
|
||||
@@ -169,12 +169,12 @@ public class SmartCastManager {
|
||||
@Nullable
|
||||
public SmartCastResult checkAndRecordPossibleCast(
|
||||
@NotNull DataFlowValue dataFlowValue,
|
||||
@NotNull KtType expectedType,
|
||||
@NotNull KotlinType expectedType,
|
||||
@Nullable KtExpression expression,
|
||||
@NotNull ResolutionContext c,
|
||||
boolean recordExpressionType
|
||||
) {
|
||||
for (KtType possibleType : c.dataFlowInfo.getPossibleTypes(dataFlowValue)) {
|
||||
for (KotlinType possibleType : c.dataFlowInfo.getPossibleTypes(dataFlowValue)) {
|
||||
if (ArgumentTypeResolver.isSubtypeOfForArgumentType(possibleType, expectedType)) {
|
||||
if (expression != null) {
|
||||
recordCastOrError(expression, possibleType, c.trace, dataFlowValue.isPredictable(), recordExpressionType);
|
||||
@@ -198,7 +198,7 @@ public class SmartCastManager {
|
||||
// E.g. in case x!! when x has type of T where T is type parameter with nullable upper bounds
|
||||
// x!! is immanently not null (see DataFlowValueFactory.createDataFlowValue for expression)
|
||||
boolean immanentlyNotNull = !dataFlowValue.getImmanentNullability().canBeNull();
|
||||
KtType nullableExpectedType = TypeUtils.makeNullable(expectedType);
|
||||
KotlinType nullableExpectedType = TypeUtils.makeNullable(expectedType);
|
||||
|
||||
if (ArgumentTypeResolver.isSubtypeOfForArgumentType(dataFlowValue.getType(), nullableExpectedType)) {
|
||||
if (!immanentlyNotNull) {
|
||||
|
||||
+2
-2
@@ -16,6 +16,6 @@
|
||||
|
||||
package org.jetbrains.kotlin.resolve.calls.smartcasts
|
||||
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
public class SmartCastResult(public val resultType: KtType, public val isCorrect: Boolean)
|
||||
public class SmartCastResult(public val resultType: KotlinType, public val isCorrect: Boolean)
|
||||
|
||||
+5
-5
@@ -37,7 +37,7 @@ import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt;
|
||||
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.Variance;
|
||||
import org.jetbrains.kotlin.types.expressions.OperatorConventions;
|
||||
|
||||
@@ -158,7 +158,7 @@ public abstract class AbstractTracingStrategy implements TracingStrategy {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unsafeCall(@NotNull BindingTrace trace, @NotNull KtType type, boolean isCallForImplicitInvoke) {
|
||||
public void unsafeCall(@NotNull BindingTrace trace, @NotNull KotlinType type, boolean isCallForImplicitInvoke) {
|
||||
ASTNode callOperationNode = call.getCallOperationNode();
|
||||
if (callOperationNode != null && !isCallForImplicitInvoke) {
|
||||
trace.report(UNSAFE_CALL.on(callOperationNode.getPsi(), type));
|
||||
@@ -186,7 +186,7 @@ public abstract class AbstractTracingStrategy implements TracingStrategy {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unnecessarySafeCall(@NotNull BindingTrace trace, @NotNull KtType type) {
|
||||
public void unnecessarySafeCall(@NotNull BindingTrace trace, @NotNull KotlinType type) {
|
||||
ASTNode callOperationNode = call.getCallOperationNode();
|
||||
assert callOperationNode != null;
|
||||
ReceiverValue explicitReceiver = call.getExplicitReceiver();
|
||||
@@ -215,12 +215,12 @@ public abstract class AbstractTracingStrategy implements TracingStrategy {
|
||||
return;
|
||||
}
|
||||
if (status.hasOnlyErrorsDerivedFrom(EXPECTED_TYPE_POSITION)) {
|
||||
KtType declaredReturnType = data.descriptor.getReturnType();
|
||||
KotlinType declaredReturnType = data.descriptor.getReturnType();
|
||||
if (declaredReturnType == null) return;
|
||||
|
||||
ConstraintSystem systemWithoutExpectedTypeConstraint =
|
||||
((ConstraintSystemImpl) constraintSystem).filterConstraintsOut(EXPECTED_TYPE_POSITION);
|
||||
KtType substitutedReturnType = systemWithoutExpectedTypeConstraint.getResultingSubstitutor().substitute(
|
||||
KotlinType substitutedReturnType = systemWithoutExpectedTypeConstraint.getResultingSubstitutor().substitute(
|
||||
declaredReturnType, Variance.OUT_VARIANCE);
|
||||
assert substitutedReturnType != null; //todo
|
||||
|
||||
|
||||
+16
-16
@@ -32,7 +32,7 @@ import org.jetbrains.kotlin.resolve.scopes.LexicalScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.utils.collectAllFromMeAndParent
|
||||
import org.jetbrains.kotlin.resolve.scopes.utils.getLocalVariable
|
||||
import org.jetbrains.kotlin.types.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||
import org.jetbrains.kotlin.utils.singletonOrEmptyList
|
||||
|
||||
@@ -45,11 +45,11 @@ public interface CallableDescriptorCollector<D : CallableDescriptor> {
|
||||
// todo this is hack for static members priority
|
||||
public fun getStaticInheritanceByName(lexicalScope: LexicalScope, name: Name, location: LookupLocation): Collection<D>
|
||||
|
||||
public fun getMembersByName(receiver: KtType, name: Name, location: LookupLocation): Collection<D>
|
||||
public fun getMembersByName(receiver: KotlinType, name: Name, location: LookupLocation): Collection<D>
|
||||
|
||||
public fun getStaticMembersByName(receiver: KtType, name: Name, location: LookupLocation): Collection<D>
|
||||
public fun getStaticMembersByName(receiver: KotlinType, name: Name, location: LookupLocation): Collection<D>
|
||||
|
||||
public fun getExtensionsByName(scope: KtScope, name: Name, receiverTypes: Collection<KtType>, location: LookupLocation): Collection<D>
|
||||
public fun getExtensionsByName(scope: KtScope, name: Name, receiverTypes: Collection<KotlinType>, location: LookupLocation): Collection<D>
|
||||
}
|
||||
|
||||
private fun <D : CallableDescriptor> CallableDescriptorCollector<D>.withDefaultFilter() = filtered { !LibrarySourceHacks.shouldSkip(it) }
|
||||
@@ -107,7 +107,7 @@ private object FunctionCollector : CallableDescriptorCollector<FunctionDescripto
|
||||
return scope.getFunctions(name, location).filter { it.extensionReceiverParameter == null } + getConstructors(scope, name, location)
|
||||
}
|
||||
|
||||
override fun getMembersByName(receiver: KtType, name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
|
||||
override fun getMembersByName(receiver: KotlinType, name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
|
||||
val receiverScope = receiver.memberScope
|
||||
val members = receiverScope.getFunctions(name, location)
|
||||
val constructors = getConstructors(receiverScope, name, location, { !isStaticNestedClass(it) })
|
||||
@@ -125,11 +125,11 @@ private object FunctionCollector : CallableDescriptorCollector<FunctionDescripto
|
||||
return members + constructors
|
||||
}
|
||||
|
||||
override fun getStaticMembersByName(receiver: KtType, name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
|
||||
override fun getStaticMembersByName(receiver: KotlinType, name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
|
||||
return getConstructors(receiver.memberScope, name, location, { isStaticNestedClass(it) })
|
||||
}
|
||||
|
||||
override fun getExtensionsByName(scope: KtScope, name: Name, receiverTypes: Collection<KtType>, location: LookupLocation): Collection<FunctionDescriptor> {
|
||||
override fun getExtensionsByName(scope: KtScope, name: Name, receiverTypes: Collection<KotlinType>, location: LookupLocation): Collection<FunctionDescriptor> {
|
||||
val functions = scope.getFunctions(name, location)
|
||||
val (extensions, nonExtensions) = functions.partition { it.extensionReceiverParameter != null }
|
||||
val syntheticExtensions = scope.getSyntheticExtensionFunctions(receiverTypes, name, location)
|
||||
@@ -199,18 +199,18 @@ private object VariableCollector : CallableDescriptorCollector<VariableDescripto
|
||||
return if (fakeDescriptor != null) properties + fakeDescriptor else properties
|
||||
}
|
||||
|
||||
override fun getMembersByName(receiver: KtType, name: Name, location: LookupLocation): Collection<VariableDescriptor> {
|
||||
override fun getMembersByName(receiver: KotlinType, name: Name, location: LookupLocation): Collection<VariableDescriptor> {
|
||||
val memberScope = receiver.memberScope
|
||||
val properties = memberScope.getProperties(name, location)
|
||||
val fakeDescriptor = getFakeDescriptorForObject(memberScope, name, location)
|
||||
return if (fakeDescriptor != null) properties + fakeDescriptor else properties
|
||||
}
|
||||
|
||||
override fun getStaticMembersByName(receiver: KtType, name: Name, location: LookupLocation): Collection<VariableDescriptor> {
|
||||
override fun getStaticMembersByName(receiver: KotlinType, name: Name, location: LookupLocation): Collection<VariableDescriptor> {
|
||||
return listOf()
|
||||
}
|
||||
|
||||
override fun getExtensionsByName(scope: KtScope, name: Name, receiverTypes: Collection<KtType>, location: LookupLocation): Collection<VariableDescriptor> {
|
||||
override fun getExtensionsByName(scope: KtScope, name: Name, receiverTypes: Collection<KotlinType>, location: LookupLocation): Collection<VariableDescriptor> {
|
||||
// property may have an extension function type, we check the applicability later to avoid an early computing of deferred types
|
||||
return scope.getLocalVariable(name).singletonOrEmptyList() +
|
||||
scope.getProperties(name, location) +
|
||||
@@ -236,15 +236,15 @@ private object PropertyCollector : CallableDescriptorCollector<VariableDescripto
|
||||
return filterProperties(VARIABLES_COLLECTOR.getNonExtensionsByName(scope, name, location))
|
||||
}
|
||||
|
||||
override fun getMembersByName(receiver: KtType, name: Name, location: LookupLocation): Collection<VariableDescriptor> {
|
||||
override fun getMembersByName(receiver: KotlinType, name: Name, location: LookupLocation): Collection<VariableDescriptor> {
|
||||
return filterProperties(VARIABLES_COLLECTOR.getMembersByName(receiver, name, location))
|
||||
}
|
||||
|
||||
override fun getStaticMembersByName(receiver: KtType, name: Name, location: LookupLocation): Collection<VariableDescriptor> {
|
||||
override fun getStaticMembersByName(receiver: KotlinType, name: Name, location: LookupLocation): Collection<VariableDescriptor> {
|
||||
return filterProperties(VARIABLES_COLLECTOR.getStaticMembersByName(receiver, name, location))
|
||||
}
|
||||
|
||||
override fun getExtensionsByName(scope: KtScope, name: Name, receiverTypes: Collection<KtType>, location: LookupLocation): Collection<VariableDescriptor> {
|
||||
override fun getExtensionsByName(scope: KtScope, name: Name, receiverTypes: Collection<KotlinType>, location: LookupLocation): Collection<VariableDescriptor> {
|
||||
return filterProperties(VARIABLES_COLLECTOR.getExtensionsByName(scope, name, receiverTypes, location))
|
||||
}
|
||||
|
||||
@@ -266,15 +266,15 @@ private fun <D : CallableDescriptor> CallableDescriptorCollector<D>.filtered(fil
|
||||
return delegate.getNonExtensionsByName(scope, name, location).filter(filter)
|
||||
}
|
||||
|
||||
override fun getMembersByName(receiver: KtType, name: Name, location: LookupLocation): Collection<D> {
|
||||
override fun getMembersByName(receiver: KotlinType, name: Name, location: LookupLocation): Collection<D> {
|
||||
return delegate.getMembersByName(receiver, name, location).filter(filter)
|
||||
}
|
||||
|
||||
override fun getStaticMembersByName(receiver: KtType, name: Name, location: LookupLocation): Collection<D> {
|
||||
override fun getStaticMembersByName(receiver: KotlinType, name: Name, location: LookupLocation): Collection<D> {
|
||||
return delegate.getStaticMembersByName(receiver, name, location).filter(filter)
|
||||
}
|
||||
|
||||
override fun getExtensionsByName(scope: KtScope, name: Name, receiverTypes: Collection<KtType>, location: LookupLocation): Collection<D> {
|
||||
override fun getExtensionsByName(scope: KtScope, name: Name, receiverTypes: Collection<KotlinType>, location: LookupLocation): Collection<D> {
|
||||
return delegate.getExtensionsByName(scope, name, receiverTypes, location).filter(filter)
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ import org.jetbrains.kotlin.resolve.calls.model.MutableDataFlowInfoForArguments;
|
||||
import org.jetbrains.kotlin.resolve.calls.model.MutableResolvedCall;
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
|
||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@@ -48,7 +48,7 @@ public class ResolutionTask<D extends CallableDescriptor, F extends D> extends C
|
||||
@NotNull BindingTrace trace,
|
||||
@NotNull LexicalScope scope,
|
||||
@NotNull Call call,
|
||||
@NotNull KtType expectedType,
|
||||
@NotNull KotlinType expectedType,
|
||||
@NotNull DataFlowInfo dataFlowInfo,
|
||||
@NotNull ContextDependency contextDependency,
|
||||
@NotNull CheckArgumentTypesMode checkArguments,
|
||||
@@ -101,7 +101,7 @@ public class ResolutionTask<D extends CallableDescriptor, F extends D> extends C
|
||||
@NotNull BindingTrace trace,
|
||||
@NotNull LexicalScope scope,
|
||||
@NotNull DataFlowInfo dataFlowInfo,
|
||||
@NotNull KtType expectedType,
|
||||
@NotNull KotlinType expectedType,
|
||||
@NotNull ContextDependency contextDependency,
|
||||
@NotNull ResolutionResultsCache resolutionResultsCache,
|
||||
@NotNull StatementFilter statementFilter,
|
||||
|
||||
@@ -50,7 +50,7 @@ import org.jetbrains.kotlin.resolve.scopes.utils.memberScopeAsFileScope
|
||||
import org.jetbrains.kotlin.resolve.validation.InfixValidator
|
||||
import org.jetbrains.kotlin.storage.StorageManager
|
||||
import org.jetbrains.kotlin.types.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
|
||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils
|
||||
import org.jetbrains.kotlin.types.isDynamic
|
||||
@@ -144,7 +144,7 @@ public class TaskPrioritizer(
|
||||
val value: ReceiverValue,
|
||||
private val context: ResolutionContext<*>
|
||||
) {
|
||||
val types: Collection<KtType> by lazy { smartCastManager.getSmartCastVariants(value, context) }
|
||||
val types: Collection<KotlinType> by lazy { smartCastManager.getSmartCastVariants(value, context) }
|
||||
}
|
||||
|
||||
private fun <D : CallableDescriptor, F : D> addCandidatesForExplicitReceiver(
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.resolve.BindingTrace;
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.InferenceErrorData;
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@@ -89,10 +89,10 @@ public interface TracingStrategy {
|
||||
) {}
|
||||
|
||||
@Override
|
||||
public void unsafeCall(@NotNull BindingTrace trace, @NotNull KtType type, boolean isCallForImplicitInvoke) {}
|
||||
public void unsafeCall(@NotNull BindingTrace trace, @NotNull KotlinType type, boolean isCallForImplicitInvoke) {}
|
||||
|
||||
@Override
|
||||
public void unnecessarySafeCall(@NotNull BindingTrace trace, @NotNull KtType type) {}
|
||||
public void unnecessarySafeCall(@NotNull BindingTrace trace, @NotNull KotlinType type) {}
|
||||
|
||||
@Override
|
||||
public void invisibleMember(@NotNull BindingTrace trace, @NotNull DeclarationDescriptorWithVisibility descriptor) {}
|
||||
@@ -145,9 +145,9 @@ public interface TracingStrategy {
|
||||
@NotNull ExplicitReceiverKind explicitReceiverKind
|
||||
);
|
||||
|
||||
void unsafeCall(@NotNull BindingTrace trace, @NotNull KtType type, boolean isCallForImplicitInvoke);
|
||||
void unsafeCall(@NotNull BindingTrace trace, @NotNull KotlinType type, boolean isCallForImplicitInvoke);
|
||||
|
||||
void unnecessarySafeCall(@NotNull BindingTrace trace, @NotNull KtType type);
|
||||
void unnecessarySafeCall(@NotNull BindingTrace trace, @NotNull KotlinType type);
|
||||
|
||||
void invisibleMember(@NotNull BindingTrace trace, @NotNull DeclarationDescriptorWithVisibility descriptor);
|
||||
|
||||
|
||||
+3
-3
@@ -32,7 +32,7 @@ import org.jetbrains.kotlin.resolve.calls.inference.InferenceErrorData
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
||||
import org.jetbrains.kotlin.types.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
|
||||
public class TracingStrategyForImplicitConstructorDelegationCall(
|
||||
@@ -109,11 +109,11 @@ public class TracingStrategyForImplicitConstructorDelegationCall(
|
||||
unexpectedError("nestedClassAccessViaInstanceReference")
|
||||
}
|
||||
|
||||
override fun unsafeCall(trace: BindingTrace, type: KtType, isCallForImplicitInvoke: Boolean) {
|
||||
override fun unsafeCall(trace: BindingTrace, type: KotlinType, isCallForImplicitInvoke: Boolean) {
|
||||
unexpectedError("unsafeCall")
|
||||
}
|
||||
|
||||
override fun unnecessarySafeCall(trace: BindingTrace, type: KtType) {
|
||||
override fun unnecessarySafeCall(trace: BindingTrace, type: KotlinType) {
|
||||
unexpectedError("unnecessarySafeCall")
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -27,7 +27,7 @@ import org.jetbrains.kotlin.psi.KtSimpleNameExpression;
|
||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
||||
import org.jetbrains.kotlin.resolve.BindingTrace;
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@@ -37,12 +37,12 @@ import static org.jetbrains.kotlin.resolve.BindingContext.CALL;
|
||||
import static org.jetbrains.kotlin.resolve.BindingContext.RESOLVED_CALL;
|
||||
|
||||
public class TracingStrategyForInvoke extends AbstractTracingStrategy {
|
||||
private final KtType calleeType;
|
||||
private final KotlinType calleeType;
|
||||
|
||||
public TracingStrategyForInvoke(
|
||||
@NotNull KtExpression reference,
|
||||
@NotNull Call call,
|
||||
@NotNull KtType calleeType
|
||||
@NotNull KotlinType calleeType
|
||||
) {
|
||||
super(reference, call);
|
||||
this.calleeType = calleeType;
|
||||
|
||||
@@ -31,7 +31,7 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
|
||||
import org.jetbrains.kotlin.resolve.scopes.KtScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.KtScopeImpl
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.TransientReceiver
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
import org.jetbrains.kotlin.types.createDynamicType
|
||||
import org.jetbrains.kotlin.types.expressions.OperatorConventions
|
||||
@@ -103,7 +103,7 @@ class DynamicCallableDescriptors(private val builtIns: KotlinBuiltIns) {
|
||||
dynamicType,
|
||||
createTypeParameters(propertyDescriptor, call),
|
||||
createDynamicDispatchReceiverParameter(propertyDescriptor),
|
||||
null as KtType?
|
||||
null as KotlinType?
|
||||
)
|
||||
|
||||
val getter = DescriptorFactory.createDefaultGetter(propertyDescriptor, Annotations.EMPTY)
|
||||
@@ -155,7 +155,7 @@ class DynamicCallableDescriptors(private val builtIns: KotlinBuiltIns) {
|
||||
private fun createValueParameters(owner: FunctionDescriptor, call: Call): List<ValueParameterDescriptor> {
|
||||
val parameters = ArrayList<ValueParameterDescriptor>()
|
||||
|
||||
fun addParameter(arg : ValueArgument, outType: KtType, varargElementType: KtType?) {
|
||||
fun addParameter(arg : ValueArgument, outType: KotlinType, varargElementType: KotlinType?) {
|
||||
val index = parameters.size()
|
||||
|
||||
parameters.add(ValueParameterDescriptorImpl(
|
||||
@@ -173,7 +173,7 @@ class DynamicCallableDescriptors(private val builtIns: KotlinBuiltIns) {
|
||||
))
|
||||
}
|
||||
|
||||
fun getFunctionType(funLiteralExpr: KtFunctionLiteralExpression): KtType {
|
||||
fun getFunctionType(funLiteralExpr: KtFunctionLiteralExpression): KotlinType {
|
||||
val funLiteral = funLiteralExpr.getFunctionLiteral()
|
||||
|
||||
val receiverType = funLiteral.getReceiverTypeReference()?.let { dynamicType }
|
||||
@@ -183,8 +183,8 @@ class DynamicCallableDescriptors(private val builtIns: KotlinBuiltIns) {
|
||||
}
|
||||
|
||||
for (arg in call.getValueArguments()) {
|
||||
val outType: KtType
|
||||
val varargElementType: KtType?
|
||||
val outType: KotlinType
|
||||
val varargElementType: KotlinType?
|
||||
var hasSpreadOperator = false
|
||||
|
||||
val argExpression = KtPsiUtil.deparenthesize(arg.getArgumentExpression())
|
||||
@@ -229,7 +229,7 @@ public fun DeclarationDescriptor.isDynamic(): Boolean {
|
||||
}
|
||||
|
||||
class CollectorForDynamicReceivers<D: CallableDescriptor>(val delegate: CallableDescriptorCollector<D>) : CallableDescriptorCollector<D> by delegate {
|
||||
override fun getExtensionsByName(scope: KtScope, name: Name, receiverTypes: Collection<KtType>, location: LookupLocation): Collection<D> {
|
||||
override fun getExtensionsByName(scope: KtScope, name: Name, receiverTypes: Collection<KotlinType>, location: LookupLocation): Collection<D> {
|
||||
return delegate.getExtensionsByName(scope, name, receiverTypes, location).filter {
|
||||
it.getExtensionReceiverParameter()?.getType()?.isDynamic() ?: false
|
||||
}
|
||||
|
||||
+3
-3
@@ -20,7 +20,7 @@ import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.classObjectType
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.getClassObjectReferenceTarget
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.hasClassObjectType
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import java.util.Collections
|
||||
|
||||
public class FakeCallableDescriptorForObject(
|
||||
@@ -44,7 +44,7 @@ public class FakeCallableDescriptorForObject(
|
||||
|
||||
override fun getValueParameters(): List<ValueParameterDescriptor> = Collections.emptyList()
|
||||
|
||||
override fun getReturnType(): KtType? = getType()
|
||||
override fun getReturnType(): KotlinType? = getType()
|
||||
|
||||
override fun hasSynthesizedParameterNames() = false
|
||||
|
||||
@@ -52,7 +52,7 @@ public class FakeCallableDescriptorForObject(
|
||||
|
||||
override fun getOverriddenDescriptors(): Set<CallableDescriptor> = Collections.emptySet()
|
||||
|
||||
override fun getType(): KtType = classDescriptor.classObjectType!!
|
||||
override fun getType(): KotlinType = classDescriptor.classObjectType!!
|
||||
|
||||
override fun isVar() = false
|
||||
|
||||
|
||||
+10
-10
@@ -27,7 +27,7 @@ import org.jetbrains.kotlin.diagnostics.DiagnosticFactory;
|
||||
import org.jetbrains.kotlin.psi.KtConstantExpression;
|
||||
import org.jetbrains.kotlin.psi.KtElement;
|
||||
import org.jetbrains.kotlin.resolve.BindingTrace;
|
||||
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;
|
||||
|
||||
@@ -57,7 +57,7 @@ public class CompileTimeConstantChecker {
|
||||
public boolean checkConstantExpressionType(
|
||||
@Nullable ConstantValue<?> compileTimeConstant,
|
||||
@NotNull KtConstantExpression expression,
|
||||
@NotNull KtType expectedType
|
||||
@NotNull KotlinType expectedType
|
||||
) {
|
||||
IElementType elementType = expression.getNode().getElementType();
|
||||
|
||||
@@ -81,7 +81,7 @@ public class CompileTimeConstantChecker {
|
||||
|
||||
private boolean checkIntegerValue(
|
||||
@Nullable ConstantValue<?> value,
|
||||
@NotNull KtType expectedType,
|
||||
@NotNull KotlinType expectedType,
|
||||
@NotNull KtConstantExpression expression
|
||||
) {
|
||||
if (value == null) {
|
||||
@@ -93,7 +93,7 @@ public class CompileTimeConstantChecker {
|
||||
}
|
||||
|
||||
if (!noExpectedTypeOrError(expectedType)) {
|
||||
KtType valueType = value.getType();
|
||||
KotlinType valueType = value.getType();
|
||||
if (!KotlinTypeChecker.DEFAULT.isSubtypeOf(valueType, expectedType)) {
|
||||
return reportError(CONSTANT_EXPECTED_TYPE_MISMATCH.on(expression, "integer", expectedType));
|
||||
}
|
||||
@@ -103,14 +103,14 @@ public class CompileTimeConstantChecker {
|
||||
|
||||
private boolean checkFloatValue(
|
||||
@Nullable ConstantValue<?> value,
|
||||
@NotNull KtType expectedType,
|
||||
@NotNull KotlinType expectedType,
|
||||
@NotNull KtConstantExpression expression
|
||||
) {
|
||||
if (value == null) {
|
||||
return reportError(FLOAT_LITERAL_OUT_OF_RANGE.on(expression));
|
||||
}
|
||||
if (!noExpectedTypeOrError(expectedType)) {
|
||||
KtType valueType = value.getType();
|
||||
KotlinType valueType = value.getType();
|
||||
if (!KotlinTypeChecker.DEFAULT.isSubtypeOf(valueType, expectedType)) {
|
||||
return reportError(CONSTANT_EXPECTED_TYPE_MISMATCH.on(expression, "floating-point", expectedType));
|
||||
}
|
||||
@@ -119,7 +119,7 @@ public class CompileTimeConstantChecker {
|
||||
}
|
||||
|
||||
private boolean checkBooleanValue(
|
||||
@NotNull KtType expectedType,
|
||||
@NotNull KotlinType expectedType,
|
||||
@NotNull KtConstantExpression expression
|
||||
) {
|
||||
if (!noExpectedTypeOrError(expectedType)
|
||||
@@ -129,7 +129,7 @@ public class CompileTimeConstantChecker {
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean checkCharValue(ConstantValue<?> constant, KtType expectedType, KtConstantExpression expression) {
|
||||
private boolean checkCharValue(ConstantValue<?> constant, KotlinType expectedType, KtConstantExpression expression) {
|
||||
if (!noExpectedTypeOrError(expectedType)
|
||||
&& !KotlinTypeChecker.DEFAULT.isSubtypeOf(builtIns.getCharType(), expectedType)) {
|
||||
return reportError(CONSTANT_EXPECTED_TYPE_MISMATCH.on(expression, "character", expectedType));
|
||||
@@ -146,7 +146,7 @@ public class CompileTimeConstantChecker {
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean checkNullValue(@NotNull KtType expectedType, @NotNull KtConstantExpression expression) {
|
||||
private boolean checkNullValue(@NotNull KotlinType expectedType, @NotNull KtConstantExpression expression) {
|
||||
if (!noExpectedTypeOrError(expectedType) && !TypeUtils.acceptsNullable(expectedType)) {
|
||||
return reportError(NULL_FOR_NONNULL_TYPE.on(expression, expectedType));
|
||||
}
|
||||
@@ -269,7 +269,7 @@ public class CompileTimeConstantChecker {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean noExpectedTypeOrError(KtType expectedType) {
|
||||
public static boolean noExpectedTypeOrError(KotlinType expectedType) {
|
||||
return TypeUtils.noExpectedType(expectedType) || expectedType.isError();
|
||||
}
|
||||
|
||||
|
||||
+30
-30
@@ -31,7 +31,7 @@ import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedValueArgument
|
||||
import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind
|
||||
import org.jetbrains.kotlin.resolve.constants.*
|
||||
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.expressions.OperatorConventions
|
||||
@@ -45,7 +45,7 @@ public class ConstantExpressionEvaluator(
|
||||
internal val constantValueFactory = ConstantValueFactory(builtIns)
|
||||
|
||||
public fun updateNumberType(
|
||||
numberType: KtType,
|
||||
numberType: KotlinType,
|
||||
expression: KtExpression?,
|
||||
statementFilter: StatementFilter,
|
||||
trace: BindingTrace
|
||||
@@ -102,7 +102,7 @@ public class ConstantExpressionEvaluator(
|
||||
|
||||
private fun checkCompileTimeConstant(
|
||||
argumentExpression: KtExpression,
|
||||
expectedType: KtType,
|
||||
expectedType: KotlinType,
|
||||
trace: BindingTrace
|
||||
) {
|
||||
val expressionType = trace.getType(argumentExpression)
|
||||
@@ -145,7 +145,7 @@ public class ConstantExpressionEvaluator(
|
||||
private fun getArgumentExpressionsForArrayCall(
|
||||
expression: KtCallExpression,
|
||||
trace: BindingTrace
|
||||
): Pair<List<KtExpression>, KtType?>? {
|
||||
): Pair<List<KtExpression>, KotlinType?>? {
|
||||
val resolvedCall = expression.getResolvedCall(trace.getBindingContext())
|
||||
if (resolvedCall == null || !CompileTimeConstantUtils.isArrayMethodCall(resolvedCall)) {
|
||||
return null
|
||||
@@ -163,7 +163,7 @@ public class ConstantExpressionEvaluator(
|
||||
}
|
||||
}
|
||||
|
||||
return Pair<List<KtExpression>, KtType>(result, elementType)
|
||||
return Pair<List<KtExpression>, KotlinType>(result, elementType)
|
||||
}
|
||||
|
||||
private fun hasSpread(argument: ResolvedValueArgument): Boolean {
|
||||
@@ -173,7 +173,7 @@ public class ConstantExpressionEvaluator(
|
||||
|
||||
private fun resolveAnnotationValueArguments(
|
||||
resolvedValueArgument: ResolvedValueArgument,
|
||||
expectedType: KtType,
|
||||
expectedType: KotlinType,
|
||||
trace: BindingTrace): List<CompileTimeConstant<*>> {
|
||||
val constants = ArrayList<CompileTimeConstant<*>>()
|
||||
for (argument in resolvedValueArgument.getArguments()) {
|
||||
@@ -194,7 +194,7 @@ public class ConstantExpressionEvaluator(
|
||||
public fun evaluateExpression(
|
||||
expression: KtExpression,
|
||||
trace: BindingTrace,
|
||||
expectedType: KtType? = TypeUtils.NO_EXPECTED_TYPE
|
||||
expectedType: KotlinType? = TypeUtils.NO_EXPECTED_TYPE
|
||||
): CompileTimeConstant<*>? {
|
||||
val visitor = ConstantExpressionEvaluatorVisitor(this, trace)
|
||||
val constant = visitor.evaluate(expression, expectedType) ?: return null
|
||||
@@ -204,7 +204,7 @@ public class ConstantExpressionEvaluator(
|
||||
public fun evaluateToConstantValue(
|
||||
expression: KtExpression,
|
||||
trace: BindingTrace,
|
||||
expectedType: KtType
|
||||
expectedType: KotlinType
|
||||
): ConstantValue<*>? {
|
||||
return evaluateExpression(expression, trace, expectedType)?.toConstantValue(expectedType)
|
||||
}
|
||||
@@ -227,11 +227,11 @@ public class ConstantExpressionEvaluator(
|
||||
private class ConstantExpressionEvaluatorVisitor(
|
||||
private val constantExpressionEvaluator: ConstantExpressionEvaluator,
|
||||
private val trace: BindingTrace
|
||||
) : KtVisitor<CompileTimeConstant<*>?, KtType>() {
|
||||
) : KtVisitor<CompileTimeConstant<*>?, KotlinType>() {
|
||||
|
||||
private val factory = constantExpressionEvaluator.constantValueFactory
|
||||
|
||||
fun evaluate(expression: KtExpression, expectedType: KtType?): CompileTimeConstant<*>? {
|
||||
fun evaluate(expression: KtExpression, expectedType: KotlinType?): CompileTimeConstant<*>? {
|
||||
val recordedCompileTimeConstant = ConstantExpressionEvaluator.getPossiblyErrorConstant(expression, trace.getBindingContext())
|
||||
if (recordedCompileTimeConstant != null) {
|
||||
return recordedCompileTimeConstant
|
||||
@@ -272,7 +272,7 @@ private class ConstantExpressionEvaluatorVisitor(
|
||||
override fun visitEscapeStringTemplateEntry(entry: KtEscapeStringTemplateEntry, data: Nothing?) = factory.createStringValue(entry.getUnescapedValue()).wrap()
|
||||
}
|
||||
|
||||
override fun visitConstantExpression(expression: KtConstantExpression, expectedType: KtType?): CompileTimeConstant<*>? {
|
||||
override fun visitConstantExpression(expression: KtConstantExpression, expectedType: KotlinType?): CompileTimeConstant<*>? {
|
||||
val text = expression.getText() ?: return null
|
||||
|
||||
val nodeElementType = expression.getNode().getElementType()
|
||||
@@ -290,7 +290,7 @@ private class ConstantExpressionEvaluatorVisitor(
|
||||
return createConstant(result, expectedType, CompileTimeConstant.Parameters(true, !isLongWithSuffix(), false, usesNonConstValAsConstant = false))
|
||||
}
|
||||
|
||||
override fun visitParenthesizedExpression(expression: KtParenthesizedExpression, expectedType: KtType?): CompileTimeConstant<*>? {
|
||||
override fun visitParenthesizedExpression(expression: KtParenthesizedExpression, expectedType: KotlinType?): CompileTimeConstant<*>? {
|
||||
val deparenthesizedExpression = KtPsiUtil.deparenthesize(expression)
|
||||
if (deparenthesizedExpression != null && deparenthesizedExpression != expression) {
|
||||
return evaluate(deparenthesizedExpression, expectedType)
|
||||
@@ -298,7 +298,7 @@ private class ConstantExpressionEvaluatorVisitor(
|
||||
return null
|
||||
}
|
||||
|
||||
override fun visitLabeledExpression(expression: KtLabeledExpression, expectedType: KtType?): CompileTimeConstant<*>? {
|
||||
override fun visitLabeledExpression(expression: KtLabeledExpression, expectedType: KotlinType?): CompileTimeConstant<*>? {
|
||||
val baseExpression = expression.getBaseExpression()
|
||||
if (baseExpression != null) {
|
||||
return evaluate(baseExpression, expectedType)
|
||||
@@ -306,7 +306,7 @@ private class ConstantExpressionEvaluatorVisitor(
|
||||
return null
|
||||
}
|
||||
|
||||
override fun visitStringTemplateExpression(expression: KtStringTemplateExpression, expectedType: KtType?): CompileTimeConstant<*>? {
|
||||
override fun visitStringTemplateExpression(expression: KtStringTemplateExpression, expectedType: KotlinType?): CompileTimeConstant<*>? {
|
||||
val sb = StringBuilder()
|
||||
var interupted = false
|
||||
var canBeUsedInAnnotation = true
|
||||
@@ -339,10 +339,10 @@ private class ConstantExpressionEvaluatorVisitor(
|
||||
else null
|
||||
}
|
||||
|
||||
override fun visitBinaryWithTypeRHSExpression(expression: KtBinaryExpressionWithTypeRHS, expectedType: KtType?): CompileTimeConstant<*>? =
|
||||
override fun visitBinaryWithTypeRHSExpression(expression: KtBinaryExpressionWithTypeRHS, expectedType: KotlinType?): CompileTimeConstant<*>? =
|
||||
evaluate(expression.getLeft(), expectedType)
|
||||
|
||||
override fun visitBinaryExpression(expression: KtBinaryExpression, expectedType: KtType?): CompileTimeConstant<*>? {
|
||||
override fun visitBinaryExpression(expression: KtBinaryExpression, expectedType: KotlinType?): CompileTimeConstant<*>? {
|
||||
val leftExpression = expression.getLeft() ?: return null
|
||||
|
||||
val operationToken = expression.getOperationToken()
|
||||
@@ -379,7 +379,7 @@ private class ConstantExpressionEvaluatorVisitor(
|
||||
}
|
||||
}
|
||||
|
||||
private fun evaluateCall(callExpression: KtExpression, receiverExpression: KtExpression, expectedType: KtType?): CompileTimeConstant<*>? {
|
||||
private fun evaluateCall(callExpression: KtExpression, receiverExpression: KtExpression, expectedType: KotlinType?): CompileTimeConstant<*>? {
|
||||
val resolvedCall = callExpression.getResolvedCall(trace.getBindingContext())
|
||||
if (resolvedCall == null) return null
|
||||
|
||||
@@ -501,14 +501,14 @@ private class ConstantExpressionEvaluatorVisitor(
|
||||
return false
|
||||
}
|
||||
|
||||
override fun visitUnaryExpression(expression: KtUnaryExpression, expectedType: KtType?): CompileTimeConstant<*>? {
|
||||
override fun visitUnaryExpression(expression: KtUnaryExpression, expectedType: KotlinType?): CompileTimeConstant<*>? {
|
||||
val leftExpression = expression.getBaseExpression()
|
||||
if (leftExpression == null) return null
|
||||
|
||||
return evaluateCall(expression.getOperationReference(), leftExpression, expectedType)
|
||||
}
|
||||
|
||||
override fun visitSimpleNameExpression(expression: KtSimpleNameExpression, expectedType: KtType?): CompileTimeConstant<*>? {
|
||||
override fun visitSimpleNameExpression(expression: KtSimpleNameExpression, expectedType: KotlinType?): CompileTimeConstant<*>? {
|
||||
val enumDescriptor = trace.getBindingContext().get(BindingContext.REFERENCE_TARGET, expression);
|
||||
if (enumDescriptor != null && DescriptorUtils.isEnumEntry(enumDescriptor)) {
|
||||
return factory.createEnumValue(enumDescriptor as ClassDescriptor).wrap()
|
||||
@@ -547,7 +547,7 @@ private class ConstantExpressionEvaluatorVisitor(
|
||||
return false
|
||||
}
|
||||
|
||||
override fun visitQualifiedExpression(expression: KtQualifiedExpression, expectedType: KtType?): CompileTimeConstant<*>? {
|
||||
override fun visitQualifiedExpression(expression: KtQualifiedExpression, expectedType: KotlinType?): CompileTimeConstant<*>? {
|
||||
val selectorExpression = expression.getSelectorExpression()
|
||||
// 1.toInt(); 1.plus(1);
|
||||
if (selectorExpression is KtCallExpression) {
|
||||
@@ -578,7 +578,7 @@ private class ConstantExpressionEvaluatorVisitor(
|
||||
return null
|
||||
}
|
||||
|
||||
override fun visitCallExpression(expression: KtCallExpression, expectedType: KtType?): CompileTimeConstant<*>? {
|
||||
override fun visitCallExpression(expression: KtCallExpression, expectedType: KotlinType?): CompileTimeConstant<*>? {
|
||||
val call = expression.getResolvedCall(trace.getBindingContext())
|
||||
if (call == null) return null
|
||||
|
||||
@@ -613,13 +613,13 @@ private class ConstantExpressionEvaluatorVisitor(
|
||||
return null
|
||||
}
|
||||
|
||||
override fun visitClassLiteralExpression(expression: KtClassLiteralExpression, expectedType: KtType?): CompileTimeConstant<*>? {
|
||||
override fun visitClassLiteralExpression(expression: KtClassLiteralExpression, expectedType: KotlinType?): CompileTimeConstant<*>? {
|
||||
val jetType = trace.getType(expression)!!
|
||||
if (jetType.isError()) return null
|
||||
return KClassValue(jetType).wrap()
|
||||
}
|
||||
|
||||
private fun resolveArguments(valueArguments: List<ValueArgument>, expectedType: KtType): List<CompileTimeConstant<*>> {
|
||||
private fun resolveArguments(valueArguments: List<ValueArgument>, expectedType: KotlinType): List<CompileTimeConstant<*>> {
|
||||
val constants = arrayListOf<CompileTimeConstant<*>>()
|
||||
for (argument in valueArguments) {
|
||||
val argumentExpression = argument.getArgumentExpression()
|
||||
@@ -633,7 +633,7 @@ private class ConstantExpressionEvaluatorVisitor(
|
||||
return constants
|
||||
}
|
||||
|
||||
override fun visitJetElement(element: KtElement, expectedType: KtType?): CompileTimeConstant<*>? {
|
||||
override fun visitJetElement(element: KtElement, expectedType: KotlinType?): CompileTimeConstant<*>? {
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -662,7 +662,7 @@ private class ConstantExpressionEvaluatorVisitor(
|
||||
}
|
||||
|
||||
|
||||
private fun getCompileTimeType(c: KtType): CompileTimeType<out Any>? {
|
||||
private fun getCompileTimeType(c: KotlinType): CompileTimeType<out Any>? {
|
||||
val builtIns = constantExpressionEvaluator.builtIns
|
||||
return when (TypeUtils.makeNotNullable(c)) {
|
||||
builtIns.intType -> INT
|
||||
@@ -679,7 +679,7 @@ private class ConstantExpressionEvaluatorVisitor(
|
||||
}
|
||||
}
|
||||
|
||||
private fun createOperationArgument(expression: KtExpression, expressionType: KtType, compileTimeType: CompileTimeType<*>): OperationArgument? {
|
||||
private fun createOperationArgument(expression: KtExpression, expressionType: KotlinType, compileTimeType: CompileTimeType<*>): OperationArgument? {
|
||||
val compileTimeConstant = constantExpressionEvaluator.evaluateExpression(expression, trace, expressionType) ?: return null
|
||||
val evaluationResult = compileTimeConstant.getValue(expressionType) ?: return null
|
||||
return OperationArgument(evaluationResult, compileTimeType, expression)
|
||||
@@ -687,7 +687,7 @@ private class ConstantExpressionEvaluatorVisitor(
|
||||
|
||||
private fun createConstant(
|
||||
value: Any?,
|
||||
expectedType: KtType?,
|
||||
expectedType: KotlinType?,
|
||||
parameters: CompileTimeConstant.Parameters
|
||||
): CompileTimeConstant<*>? {
|
||||
return if (parameters.isPure) {
|
||||
@@ -701,7 +701,7 @@ private class ConstantExpressionEvaluatorVisitor(
|
||||
private fun createCompileTimeConstant(
|
||||
value: Any?,
|
||||
parameters: CompileTimeConstant.Parameters,
|
||||
expectedType: KtType
|
||||
expectedType: KotlinType
|
||||
): CompileTimeConstant<*>? {
|
||||
return when (value) {
|
||||
is Byte, is Short, is Int, is Long -> createIntegerCompileTimeConstant((value as Number).toLong(), parameters, expectedType)
|
||||
@@ -712,7 +712,7 @@ private class ConstantExpressionEvaluatorVisitor(
|
||||
private fun createIntegerCompileTimeConstant(
|
||||
value: Long,
|
||||
parameters: CompileTimeConstant.Parameters,
|
||||
expectedType: KtType
|
||||
expectedType: KotlinType
|
||||
): CompileTimeConstant<*>? {
|
||||
if (TypeUtils.noExpectedType(expectedType) || expectedType.isError()) {
|
||||
return IntegerValueTypeConstant(value, constantExpressionEvaluator.builtIns, parameters)
|
||||
@@ -833,7 +833,7 @@ private fun createCompileTimeConstantForCompareTo(result: Any?, operationReferen
|
||||
|
||||
fun isIntegerType(value: Any?) = value is Byte || value is Short || value is Int || value is Long
|
||||
|
||||
private fun getReceiverExpressionType(resolvedCall: ResolvedCall<*>): KtType? {
|
||||
private fun getReceiverExpressionType(resolvedCall: ResolvedCall<*>): KotlinType? {
|
||||
return when (resolvedCall.getExplicitReceiverKind()) {
|
||||
ExplicitReceiverKind.DISPATCH_RECEIVER -> resolvedCall.getDispatchReceiver().getType()
|
||||
ExplicitReceiverKind.EXTENSION_RECEIVER -> resolvedCall.getExtensionReceiver().getType()
|
||||
|
||||
@@ -47,8 +47,8 @@ public class ForceResolveUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static void forceResolveAllContents(@NotNull Collection<KtType> types) {
|
||||
for (KtType type : types) {
|
||||
public static void forceResolveAllContents(@NotNull Collection<KotlinType> types) {
|
||||
for (KotlinType type : types) {
|
||||
forceResolveAllContents(type);
|
||||
}
|
||||
}
|
||||
@@ -87,7 +87,7 @@ public class ForceResolveUtil {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static KtType forceResolveAllContents(@Nullable KtType type) {
|
||||
public static KotlinType forceResolveAllContents(@Nullable KotlinType type) {
|
||||
if (type == null) return null;
|
||||
|
||||
forceResolveAllContents(type.getAnnotations());
|
||||
|
||||
@@ -33,7 +33,7 @@ import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||
import org.jetbrains.kotlin.resolve.scopes.KtScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
||||
import org.jetbrains.kotlin.storage.StorageManager
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.util.collectionUtils.concat
|
||||
import org.jetbrains.kotlin.utils.Printer
|
||||
import java.util.*
|
||||
@@ -202,17 +202,17 @@ class LazyImportScope(
|
||||
return importResolver.collectFromImports(name) { scope, name -> scope.getFunctions(name, location) }
|
||||
}
|
||||
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KtType>, name: Name, location: LookupLocation): Collection<PropertyDescriptor> {
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KotlinType>, name: Name, location: LookupLocation): Collection<PropertyDescriptor> {
|
||||
if (filteringKind == FilteringKind.INVISIBLE_CLASSES) return listOf()
|
||||
return importResolver.collectFromImports(name) { scope, name -> scope.getSyntheticExtensionProperties(receiverTypes, name, location) }
|
||||
}
|
||||
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<KtType>, name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<KotlinType>, name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
|
||||
if (filteringKind == FilteringKind.INVISIBLE_CLASSES) return listOf()
|
||||
return importResolver.collectFromImports(name) { scope, name -> scope.getSyntheticExtensionFunctions(receiverTypes, name, location) }
|
||||
}
|
||||
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KtType>): Collection<PropertyDescriptor> {
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KotlinType>): Collection<PropertyDescriptor> {
|
||||
// we do not perform any filtering by visibility here because all descriptors from both visible/invisible filter scopes are to be added anyway
|
||||
if (filteringKind == FilteringKind.INVISIBLE_CLASSES) return listOf()
|
||||
|
||||
@@ -223,7 +223,7 @@ class LazyImportScope(
|
||||
}
|
||||
}
|
||||
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<KtType>): Collection<FunctionDescriptor> {
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<KotlinType>): Collection<FunctionDescriptor> {
|
||||
// we do not perform any filtering by visibility here because all descriptors from both visible/invisible filter scopes are to be added anyway
|
||||
if (filteringKind == FilteringKind.INVISIBLE_CLASSES) return listOf()
|
||||
|
||||
|
||||
+19
-19
@@ -55,7 +55,7 @@ import org.jetbrains.kotlin.storage.NotNullLazyValue;
|
||||
import org.jetbrains.kotlin.storage.NullableLazyValue;
|
||||
import org.jetbrains.kotlin.storage.StorageManager;
|
||||
import org.jetbrains.kotlin.types.AbstractClassTypeConstructor;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.TypeConstructor;
|
||||
import org.jetbrains.kotlin.types.TypeUtils;
|
||||
|
||||
@@ -68,9 +68,9 @@ import static org.jetbrains.kotlin.resolve.BindingContext.TYPE;
|
||||
import static org.jetbrains.kotlin.resolve.ModifiersChecker.*;
|
||||
|
||||
public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDescriptorWithResolutionScopes, LazyEntity {
|
||||
private static final Predicate<KtType> VALID_SUPERTYPE = new Predicate<KtType>() {
|
||||
private static final Predicate<KotlinType> VALID_SUPERTYPE = new Predicate<KotlinType>() {
|
||||
@Override
|
||||
public boolean apply(KtType type) {
|
||||
public boolean apply(KotlinType type) {
|
||||
assert !type.isError() : "Error types must be filtered out in DescriptorResolver";
|
||||
return TypeUtils.getClassDescriptor(type) != null;
|
||||
}
|
||||
@@ -488,21 +488,21 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
||||
|
||||
private static class Supertypes {
|
||||
@Mutable
|
||||
public final Collection<KtType> trueSupertypes;
|
||||
public final Collection<KotlinType> trueSupertypes;
|
||||
@Mutable
|
||||
public final Collection<KtType> cyclicSupertypes;
|
||||
public final Collection<KotlinType> cyclicSupertypes;
|
||||
|
||||
private Supertypes(@Mutable @NotNull Collection<KtType> trueSupertypes) {
|
||||
this(trueSupertypes, new ArrayList<KtType>(0));
|
||||
private Supertypes(@Mutable @NotNull Collection<KotlinType> trueSupertypes) {
|
||||
this(trueSupertypes, new ArrayList<KotlinType>(0));
|
||||
}
|
||||
|
||||
private Supertypes(@Mutable @NotNull Collection<KtType> trueSupertypes, @Mutable @NotNull Collection<KtType> cyclicSupertypes) {
|
||||
private Supertypes(@Mutable @NotNull Collection<KotlinType> trueSupertypes, @Mutable @NotNull Collection<KotlinType> cyclicSupertypes) {
|
||||
this.trueSupertypes = trueSupertypes;
|
||||
this.cyclicSupertypes = cyclicSupertypes;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Collection<KtType> getAllSupertypes() {
|
||||
public Collection<KotlinType> getAllSupertypes() {
|
||||
return CollectionsKt.plus(trueSupertypes, cyclicSupertypes);
|
||||
}
|
||||
}
|
||||
@@ -513,7 +513,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
||||
@Override
|
||||
public Supertypes invoke() {
|
||||
if (KotlinBuiltIns.isSpecialClassWithNoSupertypes(LazyClassDescriptor.this)) {
|
||||
return new Supertypes(Collections.<KtType>emptyList());
|
||||
return new Supertypes(Collections.<KotlinType>emptyList());
|
||||
}
|
||||
|
||||
KtClassOrObject classOrObject = declarationProvider.getOwnerInfo().getCorrespondingClassOrObject();
|
||||
@@ -521,7 +521,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
||||
return new Supertypes(Collections.singleton(c.getModuleDescriptor().getBuiltIns().getAnyType()));
|
||||
}
|
||||
|
||||
List<KtType> allSupertypes = c.getDescriptorResolver()
|
||||
List<KotlinType> allSupertypes = c.getDescriptorResolver()
|
||||
.resolveSupertypes(getScopeForClassHeaderResolution(), LazyClassDescriptor.this, classOrObject,
|
||||
c.getTrace());
|
||||
|
||||
@@ -531,7 +531,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
||||
new Function1<Boolean, Supertypes>() {
|
||||
@Override
|
||||
public Supertypes invoke(Boolean firstTime) {
|
||||
return new Supertypes(Collections.<KtType>emptyList());
|
||||
return new Supertypes(Collections.<KotlinType>emptyList());
|
||||
}
|
||||
},
|
||||
new Function1<Supertypes, Unit>() {
|
||||
@@ -581,13 +581,13 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<KtType> getSupertypes() {
|
||||
public Collection<KotlinType> getSupertypes() {
|
||||
return supertypes.invoke().trueSupertypes;
|
||||
}
|
||||
|
||||
private void findAndDisconnectLoopsInTypeHierarchy(Supertypes supertypes) {
|
||||
for (Iterator<KtType> iterator = supertypes.trueSupertypes.iterator(); iterator.hasNext(); ) {
|
||||
KtType supertype = iterator.next();
|
||||
for (Iterator<KotlinType> iterator = supertypes.trueSupertypes.iterator(); iterator.hasNext(); ) {
|
||||
KotlinType supertype = iterator.next();
|
||||
if (isReachable(supertype.getConstructor(), this, new HashSet<TypeConstructor>())) {
|
||||
iterator.remove();
|
||||
supertypes.cyclicSupertypes.add(supertype);
|
||||
@@ -614,7 +614,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
||||
for (KtDelegationSpecifier delegationSpecifier : classOrObject.getDelegationSpecifiers()) {
|
||||
KtTypeReference typeReference = delegationSpecifier.getTypeReference();
|
||||
if (typeReference == null) continue;
|
||||
KtType supertype = trace.get(TYPE, typeReference);
|
||||
KotlinType supertype = trace.get(TYPE, typeReference);
|
||||
if (supertype != null && supertype.getConstructor() == superclass.getTypeConstructor()) {
|
||||
elementToMark = typeReference;
|
||||
}
|
||||
@@ -634,7 +634,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
||||
|
||||
private boolean isReachable(TypeConstructor from, TypeConstructor to, Set<TypeConstructor> visited) {
|
||||
if (!visited.add(from)) return false;
|
||||
for (KtType supertype : getNeighbors(from)) {
|
||||
for (KotlinType supertype : getNeighbors(from)) {
|
||||
TypeConstructor supertypeConstructor = supertype.getConstructor();
|
||||
if (supertypeConstructor == to) {
|
||||
return true;
|
||||
@@ -646,9 +646,9 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
||||
return false;
|
||||
}
|
||||
|
||||
private Collection<KtType> getNeighbors(TypeConstructor from) {
|
||||
private Collection<KotlinType> getNeighbors(TypeConstructor from) {
|
||||
// Supertypes + type for container
|
||||
Collection<KtType> neighbours = new ArrayList<KtType>(
|
||||
Collection<KotlinType> neighbours = new ArrayList<KotlinType>(
|
||||
from instanceof LazyClassTypeConstructor
|
||||
? ((LazyClassTypeConstructor) from).supertypes.invoke().getAllSupertypes()
|
||||
: from.getSupertypes()
|
||||
|
||||
+4
-4
@@ -40,7 +40,7 @@ import org.jetbrains.kotlin.resolve.varianceChecker.VarianceChecker
|
||||
import org.jetbrains.kotlin.storage.NotNullLazyValue
|
||||
import org.jetbrains.kotlin.storage.NullableLazyValue
|
||||
import org.jetbrains.kotlin.types.DeferredType
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import java.util.*
|
||||
|
||||
public open class LazyClassMemberScope(
|
||||
@@ -85,7 +85,7 @@ public open class LazyClassMemberScope(
|
||||
}
|
||||
|
||||
private interface MemberExtractor<T : CallableMemberDescriptor> {
|
||||
public fun extract(extractFrom: KtType, name: Name): Collection<T>
|
||||
public fun extract(extractFrom: KotlinType, name: Name): Collection<T>
|
||||
}
|
||||
|
||||
private val primaryConstructor: NullableLazyValue<ConstructorDescriptor>
|
||||
@@ -315,13 +315,13 @@ public open class LazyClassMemberScope(
|
||||
|
||||
companion object {
|
||||
private val EXTRACT_FUNCTIONS: MemberExtractor<FunctionDescriptor> = object : MemberExtractor<FunctionDescriptor> {
|
||||
override fun extract(extractFrom: KtType, name: Name): Collection<FunctionDescriptor> {
|
||||
override fun extract(extractFrom: KotlinType, name: Name): Collection<FunctionDescriptor> {
|
||||
return extractFrom.memberScope.getFunctions(name, NoLookupLocation.FOR_ALREADY_TRACKED)
|
||||
}
|
||||
}
|
||||
|
||||
private val EXTRACT_PROPERTIES: MemberExtractor<PropertyDescriptor> = object : MemberExtractor<PropertyDescriptor> {
|
||||
override fun extract(extractFrom: KtType, name: Name): Collection<PropertyDescriptor> {
|
||||
override fun extract(extractFrom: KotlinType, name: Name): Collection<PropertyDescriptor> {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return extractFrom.memberScope.getProperties(name, NoLookupLocation.FOR_ALREADY_TRACKED) as Collection<PropertyDescriptor>
|
||||
}
|
||||
|
||||
+7
-7
@@ -26,7 +26,7 @@ import org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil;
|
||||
import org.jetbrains.kotlin.resolve.lazy.LazyClassContext;
|
||||
import org.jetbrains.kotlin.resolve.lazy.LazyEntity;
|
||||
import org.jetbrains.kotlin.resolve.source.KotlinSourceElementKt;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@@ -57,14 +57,14 @@ public class LazyTypeParameterDescriptor extends AbstractLazyTypeParameterDescri
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected Set<KtType> resolveUpperBounds() {
|
||||
Set<KtType> upperBounds = Sets.newLinkedHashSet();
|
||||
protected Set<KotlinType> resolveUpperBounds() {
|
||||
Set<KotlinType> upperBounds = Sets.newLinkedHashSet();
|
||||
|
||||
KtTypeParameter jetTypeParameter = this.jetTypeParameter;
|
||||
|
||||
KtTypeReference extendsBound = jetTypeParameter.getExtendsBound();
|
||||
if (extendsBound != null) {
|
||||
KtType boundType = c.getDescriptorResolver().resolveTypeParameterExtendsBound(
|
||||
KotlinType boundType = c.getDescriptorResolver().resolveTypeParameterExtendsBound(
|
||||
this, extendsBound, getContainingDeclaration().getScopeForClassHeaderResolution(), c.getTrace());
|
||||
upperBounds.add(boundType);
|
||||
}
|
||||
@@ -78,7 +78,7 @@ public class LazyTypeParameterDescriptor extends AbstractLazyTypeParameterDescri
|
||||
return upperBounds;
|
||||
}
|
||||
|
||||
private void resolveUpperBoundsFromWhereClause(Set<KtType> upperBounds) {
|
||||
private void resolveUpperBoundsFromWhereClause(Set<KotlinType> upperBounds) {
|
||||
KtClassOrObject classOrObject = KtStubbedPsiUtil.getPsiOrStubParent(jetTypeParameter, KtClassOrObject.class, true);
|
||||
if (classOrObject instanceof KtClass) {
|
||||
KtClass ktClass = (KtClass) classOrObject;
|
||||
@@ -90,7 +90,7 @@ public class LazyTypeParameterDescriptor extends AbstractLazyTypeParameterDescri
|
||||
|
||||
KtTypeReference boundTypeReference = jetTypeConstraint.getBoundTypeReference();
|
||||
if (boundTypeReference != null) {
|
||||
KtType boundType = resolveBoundType(boundTypeReference);
|
||||
KotlinType boundType = resolveBoundType(boundTypeReference);
|
||||
upperBounds.add(boundType);
|
||||
}
|
||||
}
|
||||
@@ -100,7 +100,7 @@ public class LazyTypeParameterDescriptor extends AbstractLazyTypeParameterDescri
|
||||
|
||||
}
|
||||
|
||||
private KtType resolveBoundType(@NotNull KtTypeReference boundTypeReference) {
|
||||
private KotlinType resolveBoundType(@NotNull KtTypeReference boundTypeReference) {
|
||||
return c.getTypeResolver()
|
||||
.resolveType(getContainingDeclaration().getScopeForClassHeaderResolution(), boundTypeReference,
|
||||
c.getTrace(), false);
|
||||
|
||||
+2
-2
@@ -18,13 +18,13 @@ package org.jetbrains.kotlin.resolve.scopes.receivers;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.psi.KtExpression;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
public class ExpressionReceiver extends AbstractReceiverValue implements ReceiverValue {
|
||||
|
||||
private final KtExpression expression;
|
||||
|
||||
public ExpressionReceiver(@NotNull KtExpression expression, @NotNull KtType type) {
|
||||
public ExpressionReceiver(@NotNull KtExpression expression, @NotNull KotlinType type) {
|
||||
super(type);
|
||||
this.expression = expression;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ import org.jetbrains.kotlin.resolve.scopes.FilteringScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.KtScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.utils.asJetScope
|
||||
import org.jetbrains.kotlin.resolve.validation.SymbolUsageValidator
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingContext
|
||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
import java.util.*
|
||||
@@ -102,7 +102,7 @@ class QualifierReceiver (
|
||||
return ChainedScope(descriptor, "Static scope for " + name + " as package or class or object", *scopes.toTypedArray())
|
||||
}
|
||||
|
||||
override fun getType(): KtType = throw IllegalStateException("No type corresponds to QualifierReceiver '$this'")
|
||||
override fun getType(): KotlinType = throw IllegalStateException("No type corresponds to QualifierReceiver '$this'")
|
||||
|
||||
override fun exists() = true
|
||||
|
||||
@@ -136,7 +136,7 @@ fun createQualifier(
|
||||
fun QualifierReceiver.resolveAsStandaloneExpression(
|
||||
context: ExpressionTypingContext,
|
||||
symbolUsageValidator: SymbolUsageValidator
|
||||
): KtType? {
|
||||
): KotlinType? {
|
||||
resolveAndRecordReferenceTarget(context, symbolUsageValidator, selector = null)
|
||||
if (classifier is TypeParameterDescriptor) {
|
||||
context.trace.report(TYPE_PARAMETER_IS_NOT_AN_EXPRESSION.on(referenceExpression, classifier))
|
||||
|
||||
+2
-2
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.resolve.scopes.receivers;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.descriptors.ScriptDescriptor;
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
// SCRIPT: script receiver
|
||||
public class ScriptReceiver implements ThisReceiver {
|
||||
@@ -40,7 +40,7 @@ public class ScriptReceiver implements ThisReceiver {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public KtType getType() {
|
||||
public KotlinType getType() {
|
||||
// not sure
|
||||
return DescriptorUtilsKt.getBuiltIns(scriptDescriptor).getAnyType();
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.lazy.LazyFileScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.*
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.util.collectionUtils.concat
|
||||
import org.jetbrains.kotlin.utils.Printer
|
||||
|
||||
@@ -155,16 +155,16 @@ private class LexicalToJetScopeAdapter(lexicalScope: LexicalScope): KtScope {
|
||||
it.getDeclaredFunctions(name, location)
|
||||
}
|
||||
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KtType>, name: Name, location: LookupLocation)
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KotlinType>, name: Name, location: LookupLocation)
|
||||
= lexicalScope.getFileScope().getSyntheticExtensionProperties(receiverTypes, name, location)
|
||||
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<KtType>, name: Name, location: LookupLocation)
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<KotlinType>, name: Name, location: LookupLocation)
|
||||
= lexicalScope.getFileScope().getSyntheticExtensionFunctions(receiverTypes, name, location)
|
||||
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KtType>)
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KotlinType>)
|
||||
= lexicalScope.getFileScope().getSyntheticExtensionProperties(receiverTypes)
|
||||
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<KtType>)
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<KotlinType>)
|
||||
= lexicalScope.getFileScope().getSyntheticExtensionFunctions(receiverTypes)
|
||||
|
||||
override fun getContainingDeclaration() = lexicalScope.ownerDescriptor
|
||||
@@ -200,16 +200,16 @@ private class LexicalToJetScopeAdapter(lexicalScope: LexicalScope): KtScope {
|
||||
private class MemberScopeToFileScopeAdapter(val memberScope: KtScope) : FileScope {
|
||||
override fun getPackage(name: Name): PackageViewDescriptor? = memberScope.getPackage(name)
|
||||
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KtType>, name: Name, location: LookupLocation)
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KotlinType>, name: Name, location: LookupLocation)
|
||||
= memberScope.getSyntheticExtensionProperties(receiverTypes, name, location)
|
||||
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<KtType>, name: Name, location: LookupLocation)
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<KotlinType>, name: Name, location: LookupLocation)
|
||||
= memberScope.getSyntheticExtensionFunctions(receiverTypes, name, location)
|
||||
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KtType>)
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KotlinType>)
|
||||
= memberScope.getSyntheticExtensionProperties(receiverTypes)
|
||||
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<KtType>)
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<KotlinType>)
|
||||
= memberScope.getSyntheticExtensionFunctions(receiverTypes)
|
||||
|
||||
override fun getDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean)
|
||||
|
||||
+4
-4
@@ -26,7 +26,7 @@ import org.jetbrains.kotlin.resolve.TraceEntryFilter
|
||||
import org.jetbrains.kotlin.resolve.diagnostics.Diagnostics
|
||||
import com.intellij.util.containers.ContainerUtil
|
||||
import org.jetbrains.kotlin.psi.KtExpression
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
public class LockBasedLazyResolveStorageManager(private val storageManager: StorageManager): StorageManager by storageManager, LazyResolveStorageManager {
|
||||
override fun <K, V : Any> createSoftlyRetainedMemoizedFunction(compute: Function1<K, V>) =
|
||||
@@ -39,7 +39,7 @@ public class LockBasedLazyResolveStorageManager(private val storageManager: Stor
|
||||
LockProtectedTrace(storageManager, originalTrace)
|
||||
|
||||
private class LockProtectedContext(private val storageManager: StorageManager, private val context: BindingContext) : BindingContext {
|
||||
override fun getType(expression: KtExpression): KtType? = storageManager.compute { context.getType(expression) }
|
||||
override fun getType(expression: KtExpression): KotlinType? = storageManager.compute { context.getType(expression) }
|
||||
|
||||
override fun getDiagnostics(): Diagnostics = storageManager.compute { context.getDiagnostics() }
|
||||
|
||||
@@ -56,11 +56,11 @@ public class LockBasedLazyResolveStorageManager(private val storageManager: Stor
|
||||
}
|
||||
|
||||
private class LockProtectedTrace(private val storageManager: StorageManager, private val trace: BindingTrace) : BindingTrace {
|
||||
override fun recordType(expression: KtExpression, type: KtType?) {
|
||||
override fun recordType(expression: KtExpression, type: KotlinType?) {
|
||||
storageManager.compute { trace.recordType(expression, type) }
|
||||
}
|
||||
|
||||
override fun getType(expression: KtExpression): KtType? = storageManager.compute { trace.getType(expression) }
|
||||
override fun getType(expression: KtExpression): KotlinType? = storageManager.compute { trace.getType(expression) }
|
||||
|
||||
private val context: BindingContext = LockProtectedContext(storageManager, trace.getBindingContext())
|
||||
|
||||
|
||||
@@ -30,9 +30,9 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class BoundsSubstitutor {
|
||||
private static final Function<TypeProjection,KtType> PROJECTIONS_TO_TYPES = new Function<TypeProjection, KtType>() {
|
||||
private static final Function<TypeProjection,KotlinType> PROJECTIONS_TO_TYPES = new Function<TypeProjection, KotlinType>() {
|
||||
@Override
|
||||
public KtType apply(TypeProjection projection) {
|
||||
public KotlinType apply(TypeProjection projection) {
|
||||
return projection.getType();
|
||||
}
|
||||
};
|
||||
@@ -60,8 +60,8 @@ public class BoundsSubstitutor {
|
||||
|
||||
// todo assert: no loops
|
||||
for (TypeParameterDescriptor descriptor : topologicallySortTypeParameters(typeParameters)) {
|
||||
KtType upperBoundsAsType = descriptor.getUpperBoundsAsType();
|
||||
KtType substitutedUpperBoundsAsType = substitutor.substitute(upperBoundsAsType, Variance.INVARIANT);
|
||||
KotlinType upperBoundsAsType = descriptor.getUpperBoundsAsType();
|
||||
KotlinType substitutedUpperBoundsAsType = substitutor.substitute(upperBoundsAsType, Variance.INVARIANT);
|
||||
mutableSubstitution.put(descriptor.getTypeConstructor(), new TypeProjectionImpl(substitutedUpperBoundsAsType));
|
||||
}
|
||||
|
||||
@@ -96,16 +96,16 @@ public class BoundsSubstitutor {
|
||||
) {
|
||||
return DFS.dfs(
|
||||
current.getUpperBounds(),
|
||||
new DFS.Neighbors<KtType>() {
|
||||
new DFS.Neighbors<KotlinType>() {
|
||||
@NotNull
|
||||
@Override
|
||||
public Iterable<KtType> getNeighbors(KtType current) {
|
||||
public Iterable<KotlinType> getNeighbors(KotlinType current) {
|
||||
return Collections2.transform(current.getArguments(), PROJECTIONS_TO_TYPES);
|
||||
}
|
||||
},
|
||||
new DFS.NodeHandlerWithListResult<KtType, TypeParameterDescriptor>() {
|
||||
new DFS.NodeHandlerWithListResult<KotlinType, TypeParameterDescriptor>() {
|
||||
@Override
|
||||
public boolean beforeChildren(KtType current) {
|
||||
public boolean beforeChildren(KotlinType current) {
|
||||
ClassifierDescriptor declarationDescriptor = current.getConstructor().getDeclarationDescriptor();
|
||||
// typeParameters in a list, but it contains very few elements, so it's fine to call contains() on it
|
||||
//noinspection SuspiciousMethodCalls
|
||||
|
||||
@@ -39,8 +39,8 @@ public class CastDiagnosticsUtil {
|
||||
// As this method produces a warning, it must be _complete_ (not sound), i.e. every time it says "cast impossible",
|
||||
// it must be really impossible
|
||||
public static boolean isCastPossible(
|
||||
@NotNull KtType lhsType,
|
||||
@NotNull KtType rhsType,
|
||||
@NotNull KotlinType lhsType,
|
||||
@NotNull KotlinType rhsType,
|
||||
@NotNull PlatformToKotlinClassMap platformToKotlinClassMap
|
||||
) {
|
||||
if (KotlinBuiltIns.isNullableNothing(lhsType) && !TypeUtils.isNullableType(rhsType)) return false;
|
||||
@@ -62,12 +62,12 @@ public class CastDiagnosticsUtil {
|
||||
* Due to limitations in PlatformToKotlinClassMap, we only consider mapping of platform classes to Kotlin classed
|
||||
* (i.e. java.lang.String -> kotlin.String) and ignore mappings that go the other way.
|
||||
*/
|
||||
private static boolean isRelated(@NotNull KtType a, @NotNull KtType b, @NotNull PlatformToKotlinClassMap platformToKotlinClassMap) {
|
||||
List<KtType> aTypes = mapToPlatformIndependentTypes(TypeUtils.makeNotNullable(a), platformToKotlinClassMap);
|
||||
List<KtType> bTypes = mapToPlatformIndependentTypes(TypeUtils.makeNotNullable(b), platformToKotlinClassMap);
|
||||
private static boolean isRelated(@NotNull KotlinType a, @NotNull KotlinType b, @NotNull PlatformToKotlinClassMap platformToKotlinClassMap) {
|
||||
List<KotlinType> aTypes = mapToPlatformIndependentTypes(TypeUtils.makeNotNullable(a), platformToKotlinClassMap);
|
||||
List<KotlinType> bTypes = mapToPlatformIndependentTypes(TypeUtils.makeNotNullable(b), platformToKotlinClassMap);
|
||||
|
||||
for (KtType aType : aTypes) {
|
||||
for (KtType bType : bTypes) {
|
||||
for (KotlinType aType : aTypes) {
|
||||
for (KotlinType bType : bTypes) {
|
||||
if (KotlinTypeChecker.DEFAULT.isSubtypeOf(aType, bType)) return true;
|
||||
if (KotlinTypeChecker.DEFAULT.isSubtypeOf(bType, aType)) return true;
|
||||
}
|
||||
@@ -76,8 +76,8 @@ public class CastDiagnosticsUtil {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static List<KtType> mapToPlatformIndependentTypes(
|
||||
@NotNull KtType type,
|
||||
private static List<KotlinType> mapToPlatformIndependentTypes(
|
||||
@NotNull KotlinType type,
|
||||
@NotNull PlatformToKotlinClassMap platformToKotlinClassMap
|
||||
) {
|
||||
ClassifierDescriptor descriptor = type.getConstructor().getDeclarationDescriptor();
|
||||
@@ -87,21 +87,21 @@ public class CastDiagnosticsUtil {
|
||||
Collection<ClassDescriptor> kotlinClasses = platformToKotlinClassMap.mapPlatformClass(originalClass);
|
||||
if (kotlinClasses.isEmpty()) return Collections.singletonList(type);
|
||||
|
||||
List<KtType> result = Lists.newArrayListWithCapacity(2);
|
||||
List<KotlinType> result = Lists.newArrayListWithCapacity(2);
|
||||
result.add(type);
|
||||
for (ClassDescriptor classDescriptor : kotlinClasses) {
|
||||
KtType kotlinType = TypeUtils.substituteProjectionsForParameters(classDescriptor, type.getArguments());
|
||||
KotlinType kotlinType = TypeUtils.substituteProjectionsForParameters(classDescriptor, type.getArguments());
|
||||
result.add(kotlinType);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static boolean isFinal(@NotNull KtType type) {
|
||||
private static boolean isFinal(@NotNull KotlinType type) {
|
||||
return !TypeUtils.canHaveSubtypes(KotlinTypeChecker.DEFAULT, type);
|
||||
}
|
||||
|
||||
private static boolean isTrait(@NotNull KtType type) {
|
||||
private static boolean isTrait(@NotNull KotlinType type) {
|
||||
ClassifierDescriptor descriptor = type.getConstructor().getDeclarationDescriptor();
|
||||
return descriptor instanceof ClassDescriptor && ((ClassDescriptor) descriptor).getKind() == ClassKind.INTERFACE;
|
||||
}
|
||||
@@ -110,7 +110,7 @@ public class CastDiagnosticsUtil {
|
||||
* Check if cast from supertype to subtype is erased.
|
||||
* It is an error in "is" statement and warning in "as".
|
||||
*/
|
||||
public static boolean isCastErased(@NotNull KtType supertype, @NotNull KtType subtype, @NotNull KotlinTypeChecker typeChecker) {
|
||||
public static boolean isCastErased(@NotNull KotlinType supertype, @NotNull KotlinType subtype, @NotNull KotlinTypeChecker typeChecker) {
|
||||
// cast between T and T? is always OK
|
||||
if (supertype.isMarkedNullable() || subtype.isMarkedNullable()) {
|
||||
return isCastErased(TypeUtils.makeNotNullable(supertype), TypeUtils.makeNotNullable(subtype), typeChecker);
|
||||
@@ -126,7 +126,7 @@ public class CastDiagnosticsUtil {
|
||||
// NOTE: this does not account for 'as Array<List<T>>'
|
||||
if (allParametersReified(subtype)) return false;
|
||||
|
||||
KtType staticallyKnownSubtype = findStaticallyKnownSubtype(supertype, subtype.getConstructor()).getResultingType();
|
||||
KotlinType staticallyKnownSubtype = findStaticallyKnownSubtype(supertype, subtype.getConstructor()).getResultingType();
|
||||
|
||||
// If the substitution failed, it means that the result is an impossible type, e.g. something like Out<in Foo>
|
||||
// In this case, we can't guarantee anything, so the cast is considered to be erased
|
||||
@@ -153,18 +153,18 @@ public class CastDiagnosticsUtil {
|
||||
* subtype = List<...>
|
||||
* result = List<*>, some arguments were not inferred, replaced with '*'
|
||||
*/
|
||||
public static TypeReconstructionResult findStaticallyKnownSubtype(@NotNull KtType supertype, @NotNull TypeConstructor subtypeConstructor) {
|
||||
public static TypeReconstructionResult findStaticallyKnownSubtype(@NotNull KotlinType supertype, @NotNull TypeConstructor subtypeConstructor) {
|
||||
assert !supertype.isMarkedNullable() : "This method only makes sense for non-nullable types";
|
||||
|
||||
// Assume we are casting an expression of type Collection<Foo> to List<Bar>
|
||||
// First, let's make List<T>, where T is a type variable
|
||||
ClassifierDescriptor descriptor = subtypeConstructor.getDeclarationDescriptor();
|
||||
assert descriptor != null : "Can't create default type for " + subtypeConstructor;
|
||||
KtType subtypeWithVariables = descriptor.getDefaultType();
|
||||
KotlinType subtypeWithVariables = descriptor.getDefaultType();
|
||||
|
||||
// Now, let's find a supertype of List<T> that is a Collection of something,
|
||||
// in this case it will be Collection<T>
|
||||
KtType supertypeWithVariables = TypeCheckingProcedure.findCorrespondingSupertype(subtypeWithVariables, supertype);
|
||||
KotlinType supertypeWithVariables = TypeCheckingProcedure.findCorrespondingSupertype(subtypeWithVariables, supertype);
|
||||
|
||||
final List<TypeParameterDescriptor> variables = subtypeWithVariables.getConstructor().getParameters();
|
||||
|
||||
@@ -204,12 +204,12 @@ public class CastDiagnosticsUtil {
|
||||
|
||||
// At this point we have values for all type parameters of List
|
||||
// Let's make a type by substituting them: List<T> -> List<Foo>
|
||||
KtType substituted = TypeSubstitutor.create(substitution).substitute(subtypeWithVariables, Variance.INVARIANT);
|
||||
KotlinType substituted = TypeSubstitutor.create(substitution).substitute(subtypeWithVariables, Variance.INVARIANT);
|
||||
|
||||
return new TypeReconstructionResult(substituted, allArgumentsInferred);
|
||||
}
|
||||
|
||||
private static boolean allParametersReified(KtType subtype) {
|
||||
private static boolean allParametersReified(KotlinType subtype) {
|
||||
for (TypeParameterDescriptor parameterDescriptor : subtype.getConstructor().getParameters()) {
|
||||
if (!parameterDescriptor.isReified()) return false;
|
||||
}
|
||||
|
||||
@@ -36,9 +36,9 @@ public class DeferredType extends DelegatingType implements LazyType {
|
||||
}
|
||||
};
|
||||
|
||||
private static final Function1<Boolean,KtType> RECURSION_PREVENTER = new Function1<Boolean, KtType>() {
|
||||
private static final Function1<Boolean,KotlinType> RECURSION_PREVENTER = new Function1<Boolean, KotlinType>() {
|
||||
@Override
|
||||
public KtType invoke(Boolean firstTime) {
|
||||
public KotlinType invoke(Boolean firstTime) {
|
||||
if (firstTime) throw new ReenteringLazyValueComputationException();
|
||||
return ErrorUtils.createErrorType("Recursive dependency");
|
||||
}
|
||||
@@ -48,7 +48,7 @@ public class DeferredType extends DelegatingType implements LazyType {
|
||||
public static DeferredType create(
|
||||
@NotNull StorageManager storageManager,
|
||||
@NotNull BindingTrace trace,
|
||||
@NotNull Function0<KtType> compute
|
||||
@NotNull Function0<KotlinType> compute
|
||||
) {
|
||||
DeferredType deferredType = new DeferredType(storageManager.createLazyValue(compute));
|
||||
trace.record(DEFERRED_TYPE, new Box<DeferredType>(deferredType));
|
||||
@@ -59,7 +59,7 @@ public class DeferredType extends DelegatingType implements LazyType {
|
||||
public static DeferredType createRecursionIntolerant(
|
||||
@NotNull StorageManager storageManager,
|
||||
@NotNull BindingTrace trace,
|
||||
@NotNull Function0<KtType> compute
|
||||
@NotNull Function0<KotlinType> compute
|
||||
) {
|
||||
//noinspection unchecked
|
||||
DeferredType deferredType = new DeferredType(storageManager.createLazyValueWithPostCompute(
|
||||
@@ -71,9 +71,9 @@ public class DeferredType extends DelegatingType implements LazyType {
|
||||
return deferredType;
|
||||
}
|
||||
|
||||
private final NotNullLazyValue<KtType> lazyValue;
|
||||
private final NotNullLazyValue<KotlinType> lazyValue;
|
||||
|
||||
private DeferredType(@NotNull NotNullLazyValue<KtType> lazyValue) {
|
||||
private DeferredType(@NotNull NotNullLazyValue<KotlinType> lazyValue) {
|
||||
this.lazyValue = lazyValue;
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ public class DeferredType extends DelegatingType implements LazyType {
|
||||
}
|
||||
|
||||
@Override
|
||||
public KtType getDelegate() {
|
||||
public KotlinType getDelegate() {
|
||||
return lazyValue.invoke();
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ public class SubstitutionUtils {
|
||||
* Builds a context with all the supertypes' parameters substituted
|
||||
*/
|
||||
@NotNull
|
||||
public static TypeSubstitutor buildDeepSubstitutor(@NotNull KtType type) {
|
||||
public static TypeSubstitutor buildDeepSubstitutor(@NotNull KotlinType type) {
|
||||
Map<TypeConstructor, TypeProjection> substitution = Maps.newHashMap();
|
||||
TypeSubstitutor typeSubstitutor = TypeSubstitutor.create(substitution);
|
||||
// we use the mutability of the map here
|
||||
@@ -57,7 +57,7 @@ public class SubstitutionUtils {
|
||||
F declared in MyFooCollection -> out CharSequence
|
||||
*/
|
||||
@NotNull
|
||||
public static Multimap<TypeConstructor, TypeProjection> buildDeepSubstitutionMultimap(@NotNull KtType type) {
|
||||
public static Multimap<TypeConstructor, TypeProjection> buildDeepSubstitutionMultimap(@NotNull KotlinType type) {
|
||||
Multimap<TypeConstructor, TypeProjection> fullSubstitution = LinkedHashMultimap.create();
|
||||
Map<TypeConstructor, TypeProjection> substitution = Maps.newHashMap();
|
||||
TypeSubstitutor typeSubstitutor = TypeSubstitutor.create(substitution);
|
||||
@@ -68,7 +68,7 @@ public class SubstitutionUtils {
|
||||
|
||||
// we use the mutability of the substitution map here
|
||||
private static void fillInDeepSubstitutor(
|
||||
@NotNull KtType context,
|
||||
@NotNull KotlinType context,
|
||||
@NotNull TypeSubstitutor substitutor,
|
||||
@NotNull Map<TypeConstructor, TypeProjection> substitution,
|
||||
@Nullable Multimap<TypeConstructor, TypeProjection> fullSubstitution
|
||||
@@ -92,7 +92,7 @@ public class SubstitutionUtils {
|
||||
}
|
||||
}
|
||||
if (KotlinBuiltIns.isNothingOrNullableNothing(context)) return;
|
||||
for (KtType supertype : context.getConstructor().getSupertypes()) {
|
||||
for (KotlinType supertype : context.getConstructor().getSupertypes()) {
|
||||
fillInDeepSubstitutor(supertype, substitutor, substitution, fullSubstitution);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,16 +19,16 @@ package org.jetbrains.kotlin.types;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class TypeReconstructionResult {
|
||||
private final KtType resultingType;
|
||||
private final KotlinType resultingType;
|
||||
private final boolean allArgumentsInferred;
|
||||
|
||||
public TypeReconstructionResult(@Nullable KtType resultingType, boolean allArgumentsInferred) {
|
||||
public TypeReconstructionResult(@Nullable KotlinType resultingType, boolean allArgumentsInferred) {
|
||||
this.resultingType = resultingType;
|
||||
this.allArgumentsInferred = allArgumentsInferred;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public KtType getResultingType() {
|
||||
public KotlinType getResultingType() {
|
||||
return resultingType;
|
||||
}
|
||||
|
||||
|
||||
@@ -63,8 +63,8 @@ public class TypeUnifier {
|
||||
Predicate<TypeConstructor> isVariable,
|
||||
UnificationResultImpl result
|
||||
) {
|
||||
KtType known = knownProjection.getType();
|
||||
KtType withVariables = projectWithVariables.getType();
|
||||
KotlinType known = knownProjection.getType();
|
||||
KotlinType withVariables = projectWithVariables.getType();
|
||||
|
||||
// in Foo ~ in X => Foo ~ X
|
||||
Variance knownProjectionKind = knownProjection.getProjectionKind();
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user