Make KotlinType.isError extension instead of member
This commit is contained in:
@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext
|
|||||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory
|
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
import org.jetbrains.kotlin.types.TypeUtils
|
import org.jetbrains.kotlin.types.TypeUtils
|
||||||
|
import org.jetbrains.kotlin.types.isError
|
||||||
|
|
||||||
class RuntimeAssertionInfo(val needNotNullAssertion: Boolean, val message: String) {
|
class RuntimeAssertionInfo(val needNotNullAssertion: Boolean, val message: String) {
|
||||||
interface DataFlowExtras {
|
interface DataFlowExtras {
|
||||||
|
|||||||
+2
-1
@@ -28,6 +28,7 @@ import org.jetbrains.kotlin.diagnostics.DiagnosticFactory;
|
|||||||
import org.jetbrains.kotlin.diagnostics.Errors;
|
import org.jetbrains.kotlin.diagnostics.Errors;
|
||||||
import org.jetbrains.kotlin.resolve.VarianceConflictDiagnosticData;
|
import org.jetbrains.kotlin.resolve.VarianceConflictDiagnosticData;
|
||||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.SinceKotlinInfo;
|
import org.jetbrains.kotlin.serialization.deserialization.descriptors.SinceKotlinInfo;
|
||||||
|
import org.jetbrains.kotlin.types.KotlinTypeKt;
|
||||||
import org.jetbrains.kotlin.util.MappedExtensionProvider;
|
import org.jetbrains.kotlin.util.MappedExtensionProvider;
|
||||||
import org.jetbrains.kotlin.util.OperatorNameConventions;
|
import org.jetbrains.kotlin.util.OperatorNameConventions;
|
||||||
|
|
||||||
@@ -696,7 +697,7 @@ public class DefaultErrorMessages {
|
|||||||
MAP.put(FUNCTION_EXPECTED, "Expression ''{0}''{1} cannot be invoked as a function. " +
|
MAP.put(FUNCTION_EXPECTED, "Expression ''{0}''{1} cannot be invoked as a function. " +
|
||||||
"The function ''" + OperatorNameConventions.INVOKE.asString() + "()'' is not found",
|
"The function ''" + OperatorNameConventions.INVOKE.asString() + "()'' is not found",
|
||||||
ELEMENT_TEXT, (type, context) -> {
|
ELEMENT_TEXT, (type, context) -> {
|
||||||
if (type.isError()) return "";
|
if (KotlinTypeKt.isError(type)) return "";
|
||||||
return " of type '" + RENDER_TYPE.render(type, context) + "'";
|
return " of type '" + RENDER_TYPE.render(type, context) + "'";
|
||||||
});
|
});
|
||||||
MAP.put(FUNCTION_CALL_EXPECTED, "Function invocation ''{0}({1})'' expected", ELEMENT_TEXT,
|
MAP.put(FUNCTION_CALL_EXPECTED, "Function invocation ''{0}({1})'' expected", ELEMENT_TEXT,
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ import org.jetbrains.kotlin.resolve.inline.InlineUtil
|
|||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
import org.jetbrains.kotlin.types.TypeUtils
|
import org.jetbrains.kotlin.types.TypeUtils
|
||||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils
|
import org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils
|
||||||
|
import org.jetbrains.kotlin.types.isError
|
||||||
|
|
||||||
class AnnotationChecker(private val additionalCheckers: Iterable<AdditionalAnnotationChecker>) {
|
class AnnotationChecker(private val additionalCheckers: Iterable<AdditionalAnnotationChecker>) {
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import org.jetbrains.kotlin.resolve.OverridingUtil.OverrideCompatibilityInfo.Res
|
|||||||
import org.jetbrains.kotlin.resolve.lazy.DelegationFilter
|
import org.jetbrains.kotlin.resolve.lazy.DelegationFilter
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
import org.jetbrains.kotlin.types.isDynamic
|
import org.jetbrains.kotlin.types.isDynamic
|
||||||
|
import org.jetbrains.kotlin.types.isError
|
||||||
import org.jetbrains.kotlin.utils.keysToMapExceptNulls
|
import org.jetbrains.kotlin.utils.keysToMapExceptNulls
|
||||||
|
|
||||||
class DelegationResolver<T : CallableMemberDescriptor> private constructor(
|
class DelegationResolver<T : CallableMemberDescriptor> private constructor(
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ public class DescriptorResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void addValidSupertype(List<KotlinType> supertypes, KotlinType declaredSupertype) {
|
private static void addValidSupertype(List<KotlinType> supertypes, KotlinType declaredSupertype) {
|
||||||
if (!declaredSupertype.isError()) {
|
if (!KotlinTypeKt.isError(declaredSupertype)) {
|
||||||
supertypes.add(declaredSupertype);
|
supertypes.add(declaredSupertype);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -251,7 +251,7 @@ public class DescriptorResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If we have an abbreviated type (written with a type alias), it still can contain type projections in top-level arguments.
|
// If we have an abbreviated type (written with a type alias), it still can contain type projections in top-level arguments.
|
||||||
if (!type.isError() && SpecialTypesKt.getAbbreviatedType(type) != null && !hasProjectionsInWrittenArguments) {
|
if (!KotlinTypeKt.isError(type) && SpecialTypesKt.getAbbreviatedType(type) != null && !hasProjectionsInWrittenArguments) {
|
||||||
// Only interface inheritance should be checked here.
|
// Only interface inheritance should be checked here.
|
||||||
// Corresponding check for classes is performed for type alias constructor calls in CandidateResolver.
|
// Corresponding check for classes is performed for type alias constructor calls in CandidateResolver.
|
||||||
if (TypeUtilsKt.isInterface(type) && TypeUtilsKt.containsTypeProjectionsInTopLevelArguments(type)) {
|
if (TypeUtilsKt.isInterface(type) && TypeUtilsKt.containsTypeProjectionsInTopLevelArguments(type)) {
|
||||||
@@ -566,7 +566,7 @@ public class DescriptorResolver {
|
|||||||
KotlinType upperBound = request.upperBoundType;
|
KotlinType upperBound = request.upperBoundType;
|
||||||
KtTypeReference upperBoundElement = request.upperBound;
|
KtTypeReference upperBoundElement = request.upperBound;
|
||||||
|
|
||||||
if (!upperBound.isError()) {
|
if (!KotlinTypeKt.isError(upperBound)) {
|
||||||
if (!allBounds.add(new Pair<>(typeParameterName, upperBound.getConstructor()))) {
|
if (!allBounds.add(new Pair<>(typeParameterName, upperBound.getConstructor()))) {
|
||||||
trace.report(REPEATED_BOUND.on(upperBoundElement));
|
trace.report(REPEATED_BOUND.on(upperBoundElement));
|
||||||
}
|
}
|
||||||
@@ -1154,7 +1154,7 @@ public class DescriptorResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void checkBounds(@NotNull KtTypeReference typeReference, @NotNull KotlinType type, @NotNull BindingTrace trace) {
|
public static void checkBounds(@NotNull KtTypeReference typeReference, @NotNull KotlinType type, @NotNull BindingTrace trace) {
|
||||||
if (type.isError()) return;
|
if (KotlinTypeKt.isError(type)) return;
|
||||||
|
|
||||||
KtTypeElement typeElement = typeReference.getTypeElement();
|
KtTypeElement typeElement = typeReference.getTypeElement();
|
||||||
if (typeElement == null) return;
|
if (typeElement == null) return;
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import org.jetbrains.kotlin.diagnostics.DiagnosticSink.DO_NOTHING
|
|||||||
import org.jetbrains.kotlin.diagnostics.Errors
|
import org.jetbrains.kotlin.diagnostics.Errors
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
import org.jetbrains.kotlin.types.TypeUtils
|
import org.jetbrains.kotlin.types.TypeUtils
|
||||||
|
import org.jetbrains.kotlin.types.isError
|
||||||
|
|
||||||
// Checker for all seven EXPOSED_* errors
|
// Checker for all seven EXPOSED_* errors
|
||||||
// All functions return true if everything is OK, or false in case of any errors
|
// All functions return true if everything is OK, or false in case of any errors
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import org.jetbrains.kotlin.resolve.calls.results.isSignatureNotLessSpecific
|
|||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.hasHidesMembersAnnotation
|
import org.jetbrains.kotlin.resolve.descriptorUtil.hasHidesMembersAnnotation
|
||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.isExtension
|
import org.jetbrains.kotlin.resolve.descriptorUtil.isExtension
|
||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.varargParameterPosition
|
import org.jetbrains.kotlin.resolve.descriptorUtil.varargParameterPosition
|
||||||
|
import org.jetbrains.kotlin.types.isError
|
||||||
import org.jetbrains.kotlin.util.OperatorNameConventions
|
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||||
|
|
||||||
class ShadowedExtensionChecker(val typeSpecificityComparator: TypeSpecificityComparator, val trace: DiagnosticSink) {
|
class ShadowedExtensionChecker(val typeSpecificityComparator: TypeSpecificityComparator, val trace: DiagnosticSink) {
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ import org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil;
|
|||||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope;
|
import org.jetbrains.kotlin.resolve.scopes.LexicalScope;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver;
|
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver;
|
||||||
import org.jetbrains.kotlin.types.KotlinType;
|
import org.jetbrains.kotlin.types.KotlinType;
|
||||||
|
import org.jetbrains.kotlin.types.KotlinTypeKt;
|
||||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingContext;
|
import org.jetbrains.kotlin.types.expressions.ExpressionTypingContext;
|
||||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices;
|
import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices;
|
||||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingVisitorDispatcher;
|
import org.jetbrains.kotlin.types.expressions.ExpressionTypingVisitorDispatcher;
|
||||||
@@ -328,7 +329,7 @@ public class CallResolver {
|
|||||||
return checkArgumentTypesAndFail(context); // No type there
|
return checkArgumentTypesAndFail(context); // No type there
|
||||||
}
|
}
|
||||||
KotlinType constructedType = typeResolver.resolveType(context.scope, typeReference, context.trace, true);
|
KotlinType constructedType = typeResolver.resolveType(context.scope, typeReference, context.trace, true);
|
||||||
if (constructedType.isError()) {
|
if (KotlinTypeKt.isError(constructedType)) {
|
||||||
return checkArgumentTypesAndFail(context);
|
return checkArgumentTypesAndFail(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -28,7 +28,6 @@ import org.jetbrains.kotlin.psi.*
|
|||||||
import org.jetbrains.kotlin.psi.psiUtil.before
|
import org.jetbrains.kotlin.psi.psiUtil.before
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext
|
import org.jetbrains.kotlin.resolve.BindingContext
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext.*
|
import org.jetbrains.kotlin.resolve.BindingContext.*
|
||||||
import org.jetbrains.kotlin.resolve.BindingTrace
|
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||||
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
|
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
|
||||||
import org.jetbrains.kotlin.resolve.calls.callUtil.isSafeCall
|
import org.jetbrains.kotlin.resolve.calls.callUtil.isSafeCall
|
||||||
@@ -43,6 +42,7 @@ import org.jetbrains.kotlin.resolve.scopes.receivers.TransientReceiver
|
|||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils
|
import org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils
|
||||||
import org.jetbrains.kotlin.types.expressions.PreliminaryDeclarationVisitor
|
import org.jetbrains.kotlin.types.expressions.PreliminaryDeclarationVisitor
|
||||||
|
import org.jetbrains.kotlin.types.isError
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is intended to create data flow values for different kind of expressions.
|
* This class is intended to create data flow values for different kind of expressions.
|
||||||
|
|||||||
+1
@@ -23,6 +23,7 @@ import org.jetbrains.kotlin.config.LanguageVersionSettings
|
|||||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.Nullability.NOT_NULL
|
import org.jetbrains.kotlin.resolve.calls.smartcasts.Nullability.NOT_NULL
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
import org.jetbrains.kotlin.types.TypeUtils
|
import org.jetbrains.kotlin.types.TypeUtils
|
||||||
|
import org.jetbrains.kotlin.types.isError
|
||||||
import org.jetbrains.kotlin.types.isFlexible
|
import org.jetbrains.kotlin.types.isFlexible
|
||||||
import org.jetbrains.kotlin.types.typeUtil.isSubtypeOf
|
import org.jetbrains.kotlin.types.typeUtil.isSubtypeOf
|
||||||
import org.jetbrains.kotlin.utils.newLinkedHashSetWithExpectedSize
|
import org.jetbrains.kotlin.utils.newLinkedHashSetWithExpectedSize
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import org.jetbrains.kotlin.resolve.calls.CallTransformer
|
|||||||
import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext
|
import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext
|
||||||
import org.jetbrains.kotlin.resolve.calls.model.*
|
import org.jetbrains.kotlin.resolve.calls.model.*
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
|
import org.jetbrains.kotlin.types.isError
|
||||||
import org.jetbrains.kotlin.utils.sure
|
import org.jetbrains.kotlin.utils.sure
|
||||||
|
|
||||||
// resolved call
|
// resolved call
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import org.jetbrains.kotlin.lexer.KtTokens
|
|||||||
import org.jetbrains.kotlin.psi.KtDeclaration
|
import org.jetbrains.kotlin.psi.KtDeclaration
|
||||||
import org.jetbrains.kotlin.psi.KtProperty
|
import org.jetbrains.kotlin.psi.KtProperty
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext
|
import org.jetbrains.kotlin.resolve.BindingContext
|
||||||
|
import org.jetbrains.kotlin.types.isError
|
||||||
|
|
||||||
object ConstModifierChecker : SimpleDeclarationChecker {
|
object ConstModifierChecker : SimpleDeclarationChecker {
|
||||||
override fun check(
|
override fun check(
|
||||||
|
|||||||
+2
-1
@@ -30,6 +30,7 @@ import org.jetbrains.kotlin.psi.KtElement;
|
|||||||
import org.jetbrains.kotlin.resolve.BindingTrace;
|
import org.jetbrains.kotlin.resolve.BindingTrace;
|
||||||
import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext;
|
import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext;
|
||||||
import org.jetbrains.kotlin.types.KotlinType;
|
import org.jetbrains.kotlin.types.KotlinType;
|
||||||
|
import org.jetbrains.kotlin.types.KotlinTypeKt;
|
||||||
import org.jetbrains.kotlin.types.TypeUtils;
|
import org.jetbrains.kotlin.types.TypeUtils;
|
||||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
|
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
|
||||||
|
|
||||||
@@ -277,7 +278,7 @@ public class CompileTimeConstantChecker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static boolean noExpectedTypeOrError(KotlinType expectedType) {
|
private static boolean noExpectedTypeOrError(KotlinType expectedType) {
|
||||||
return TypeUtils.noExpectedType(expectedType) || expectedType.isError();
|
return TypeUtils.noExpectedType(expectedType) || KotlinTypeKt.isError(expectedType);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean reportConstantExpectedTypeMismatch(
|
private boolean reportConstantExpectedTypeMismatch(
|
||||||
|
|||||||
+4
-3
@@ -45,6 +45,7 @@ import org.jetbrains.kotlin.types.TypeUtils
|
|||||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
|
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
|
||||||
import org.jetbrains.kotlin.types.expressions.DoubleColonLHS
|
import org.jetbrains.kotlin.types.expressions.DoubleColonLHS
|
||||||
import org.jetbrains.kotlin.types.expressions.OperatorConventions
|
import org.jetbrains.kotlin.types.expressions.OperatorConventions
|
||||||
|
import org.jetbrains.kotlin.types.isError
|
||||||
import org.jetbrains.kotlin.types.typeUtil.isSubtypeOf
|
import org.jetbrains.kotlin.types.typeUtil.isSubtypeOf
|
||||||
import org.jetbrains.kotlin.util.OperatorNameConventions
|
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||||
import java.math.BigInteger
|
import java.math.BigInteger
|
||||||
@@ -733,9 +734,9 @@ private class ConstantExpressionEvaluatorVisitor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun visitClassLiteralExpression(expression: KtClassLiteralExpression, expectedType: KotlinType?): CompileTimeConstant<*>? {
|
override fun visitClassLiteralExpression(expression: KtClassLiteralExpression, expectedType: KotlinType?): CompileTimeConstant<*>? {
|
||||||
val jetType = trace.getType(expression)!!
|
val type = trace.getType(expression)!!
|
||||||
if (jetType.isError) return null
|
if (type.isError) return null
|
||||||
return KClassValue(jetType).wrap()
|
return KClassValue(type).wrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun resolveArguments(valueArguments: List<ValueArgument>, expectedType: KotlinType): List<CompileTimeConstant<*>?> {
|
private fun resolveArguments(valueArguments: List<ValueArgument>, expectedType: KotlinType): List<CompileTimeConstant<*>?> {
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import org.jetbrains.kotlin.resolve.lazy.LazyEntity
|
|||||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope
|
import org.jetbrains.kotlin.resolve.scopes.LexicalScope
|
||||||
import org.jetbrains.kotlin.resolve.source.toSourceElement
|
import org.jetbrains.kotlin.resolve.source.toSourceElement
|
||||||
import org.jetbrains.kotlin.storage.StorageManager
|
import org.jetbrains.kotlin.storage.StorageManager
|
||||||
|
import org.jetbrains.kotlin.types.isError
|
||||||
|
|
||||||
abstract class LazyAnnotationsContext(
|
abstract class LazyAnnotationsContext(
|
||||||
val annotationResolver: AnnotationResolver,
|
val annotationResolver: AnnotationResolver,
|
||||||
|
|||||||
+2
-5
@@ -52,10 +52,7 @@ import org.jetbrains.kotlin.storage.MemoizedFunctionToNotNull;
|
|||||||
import org.jetbrains.kotlin.storage.NotNullLazyValue;
|
import org.jetbrains.kotlin.storage.NotNullLazyValue;
|
||||||
import org.jetbrains.kotlin.storage.NullableLazyValue;
|
import org.jetbrains.kotlin.storage.NullableLazyValue;
|
||||||
import org.jetbrains.kotlin.storage.StorageManager;
|
import org.jetbrains.kotlin.storage.StorageManager;
|
||||||
import org.jetbrains.kotlin.types.AbstractClassTypeConstructor;
|
import org.jetbrains.kotlin.types.*;
|
||||||
import org.jetbrains.kotlin.types.KotlinType;
|
|
||||||
import org.jetbrains.kotlin.types.TypeConstructor;
|
|
||||||
import org.jetbrains.kotlin.types.TypeUtils;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@@ -70,7 +67,7 @@ import static org.jetbrains.kotlin.resolve.ModifiersChecker.*;
|
|||||||
|
|
||||||
public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDescriptorWithResolutionScopes, LazyEntity {
|
public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDescriptorWithResolutionScopes, LazyEntity {
|
||||||
private static final Function1<KotlinType, Boolean> VALID_SUPERTYPE = type -> {
|
private static final Function1<KotlinType, Boolean> VALID_SUPERTYPE = type -> {
|
||||||
assert !type.isError() : "Error types must be filtered out in DescriptorResolver";
|
assert !KotlinTypeKt.isError(type) : "Error types must be filtered out in DescriptorResolver";
|
||||||
return TypeUtils.getClassDescriptor(type) != null;
|
return TypeUtils.getClassDescriptor(type) != null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+1
-4
@@ -29,10 +29,7 @@ import org.jetbrains.kotlin.storage.NotNullLazyValue
|
|||||||
import org.jetbrains.kotlin.storage.NullableLazyValue
|
import org.jetbrains.kotlin.storage.NullableLazyValue
|
||||||
import org.jetbrains.kotlin.storage.StorageManager
|
import org.jetbrains.kotlin.storage.StorageManager
|
||||||
import org.jetbrains.kotlin.storage.getValue
|
import org.jetbrains.kotlin.storage.getValue
|
||||||
import org.jetbrains.kotlin.types.SimpleType
|
import org.jetbrains.kotlin.types.*
|
||||||
import org.jetbrains.kotlin.types.TypeSubstitutor
|
|
||||||
import org.jetbrains.kotlin.types.Variance
|
|
||||||
import org.jetbrains.kotlin.types.asSimpleType
|
|
||||||
|
|
||||||
class LazyTypeAliasDescriptor(
|
class LazyTypeAliasDescriptor(
|
||||||
override val storageManager: StorageManager,
|
override val storageManager: StorageManager,
|
||||||
|
|||||||
+2
-1
@@ -28,6 +28,7 @@ import org.jetbrains.kotlin.resolve.lazy.LazyClassContext;
|
|||||||
import org.jetbrains.kotlin.resolve.lazy.LazyEntity;
|
import org.jetbrains.kotlin.resolve.lazy.LazyEntity;
|
||||||
import org.jetbrains.kotlin.resolve.source.KotlinSourceElementKt;
|
import org.jetbrains.kotlin.resolve.source.KotlinSourceElementKt;
|
||||||
import org.jetbrains.kotlin.types.KotlinType;
|
import org.jetbrains.kotlin.types.KotlinType;
|
||||||
|
import org.jetbrains.kotlin.types.KotlinTypeKt;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@@ -76,7 +77,7 @@ public class LazyTypeParameterDescriptor extends AbstractLazyTypeParameterDescri
|
|||||||
|
|
||||||
for (KtTypeReference typeReference : getAllUpperBounds()) {
|
for (KtTypeReference typeReference : getAllUpperBounds()) {
|
||||||
KotlinType resolvedType = resolveBoundType(typeReference);
|
KotlinType resolvedType = resolveBoundType(typeReference);
|
||||||
if (!resolvedType.isError()) {
|
if (!KotlinTypeKt.isError(resolvedType)) {
|
||||||
upperBounds.add(resolvedType);
|
upperBounds.add(resolvedType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ public class CommonSupertypes {
|
|||||||
if (KotlinBuiltIns.isNothingOrNullableNothing(type)) {
|
if (KotlinBuiltIns.isNothingOrNullableNothing(type)) {
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
}
|
}
|
||||||
if (type.isError()) {
|
if (KotlinTypeKt.isError(type)) {
|
||||||
return ErrorUtils.createErrorType("Supertype of error type " + type);
|
return ErrorUtils.createErrorType("Supertype of error type " + type);
|
||||||
}
|
}
|
||||||
nullable |= type.isMarkedNullable();
|
nullable |= type.isMarkedNullable();
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ public class TypeIntersector {
|
|||||||
boolean allNullable = true;
|
boolean allNullable = true;
|
||||||
List<KotlinType> nullabilityStripped = new ArrayList<>(types.size());
|
List<KotlinType> nullabilityStripped = new ArrayList<>(types.size());
|
||||||
for (KotlinType type : types) {
|
for (KotlinType type : types) {
|
||||||
if (type.isError()) continue;
|
if (KotlinTypeKt.isError(type)) continue;
|
||||||
|
|
||||||
if (KotlinBuiltIns.isNothingOrNullableNothing(type)) {
|
if (KotlinBuiltIns.isNothingOrNullableNothing(type)) {
|
||||||
nothingOrNullableNothing = type;
|
nothingOrNullableNothing = type;
|
||||||
|
|||||||
+5
-5
@@ -144,7 +144,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
@Nullable KotlinType type
|
@Nullable KotlinType type
|
||||||
) {
|
) {
|
||||||
// Receivers are normally analyzed at resolve, with an exception of KT-10175
|
// Receivers are normally analyzed at resolve, with an exception of KT-10175
|
||||||
if (type != null && !type.isError() && !isLValueOrUnsafeReceiver(expression)) {
|
if (type != null && !KotlinTypeKt.isError(type) && !isLValueOrUnsafeReceiver(expression)) {
|
||||||
DataFlowValue dataFlowValue = DataFlowValueFactory.createDataFlowValue(expression, type, context);
|
DataFlowValue dataFlowValue = DataFlowValueFactory.createDataFlowValue(expression, type, context);
|
||||||
Nullability nullability = context.dataFlowInfo.getStableNullability(dataFlowValue);
|
Nullability nullability = context.dataFlowInfo.getStableNullability(dataFlowValue);
|
||||||
if (!nullability.canBeNonNull() && nullability.canBeNull()) {
|
if (!nullability.canBeNonNull() && nullability.canBeNull()) {
|
||||||
@@ -362,7 +362,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
KotlinType targetType,
|
KotlinType targetType,
|
||||||
ExpressionTypingContext context
|
ExpressionTypingContext context
|
||||||
) {
|
) {
|
||||||
if (actualType == null || noExpectedType(targetType) || targetType.isError()) return;
|
if (actualType == null || noExpectedType(targetType) || KotlinTypeKt.isError(targetType)) return;
|
||||||
|
|
||||||
if (DynamicTypesKt.isDynamic(targetType)) {
|
if (DynamicTypesKt.isDynamic(targetType)) {
|
||||||
KtTypeReference right = expression.getRight();
|
KtTypeReference right = expression.getRight();
|
||||||
@@ -565,7 +565,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
boolean validClassifier = classifierCandidate != null && !ErrorUtils.isError(classifierCandidate);
|
boolean validClassifier = classifierCandidate != null && !ErrorUtils.isError(classifierCandidate);
|
||||||
boolean validType = supertype != null && !supertype.isError();
|
boolean validType = supertype != null && !KotlinTypeKt.isError(supertype);
|
||||||
if (result == null && (validClassifier || validType)) {
|
if (result == null && (validClassifier || validType)) {
|
||||||
context.trace.report(NOT_A_SUPERTYPE.on(superTypeQualifier));
|
context.trace.report(NOT_A_SUPERTYPE.on(superTypeQualifier));
|
||||||
}
|
}
|
||||||
@@ -963,7 +963,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
) {
|
) {
|
||||||
if (ktType == null) return false;
|
if (ktType == null) return false;
|
||||||
|
|
||||||
if (ktType.isError() && !ErrorUtils.isUninferredParameter(ktType)) return false;
|
if (KotlinTypeKt.isError(ktType) && !ErrorUtils.isUninferredParameter(ktType)) return false;
|
||||||
|
|
||||||
if (!TypeUtils.isNullableType(ktType)) return true;
|
if (!TypeUtils.isNullableType(ktType)) return true;
|
||||||
|
|
||||||
@@ -1235,7 +1235,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
KotlinTypeInfo typeInfo = getTypeInfoForBinaryCall(OperatorNameConventions.COMPARE_TO, context, expression);
|
KotlinTypeInfo typeInfo = getTypeInfoForBinaryCall(OperatorNameConventions.COMPARE_TO, context, expression);
|
||||||
KotlinType compareToReturnType = typeInfo.getType();
|
KotlinType compareToReturnType = typeInfo.getType();
|
||||||
KotlinType type = null;
|
KotlinType type = null;
|
||||||
if (compareToReturnType != null && !compareToReturnType.isError()) {
|
if (compareToReturnType != null && !KotlinTypeKt.isError(compareToReturnType)) {
|
||||||
if (KotlinTypeChecker.DEFAULT.equalTypes(components.builtIns.getIntType(), compareToReturnType)) {
|
if (KotlinTypeChecker.DEFAULT.equalTypes(components.builtIns.getIntType(), compareToReturnType)) {
|
||||||
type = components.builtIns.getBooleanType();
|
type = components.builtIns.getBooleanType();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ import org.jetbrains.kotlin.resolve.calls.smartcasts.*;
|
|||||||
import org.jetbrains.kotlin.resolve.constants.*;
|
import org.jetbrains.kotlin.resolve.constants.*;
|
||||||
import org.jetbrains.kotlin.resolve.constants.evaluate.ConstantExpressionEvaluator;
|
import org.jetbrains.kotlin.resolve.constants.evaluate.ConstantExpressionEvaluator;
|
||||||
import org.jetbrains.kotlin.types.KotlinType;
|
import org.jetbrains.kotlin.types.KotlinType;
|
||||||
|
import org.jetbrains.kotlin.types.KotlinTypeKt;
|
||||||
import org.jetbrains.kotlin.types.TypeConstructor;
|
import org.jetbrains.kotlin.types.TypeConstructor;
|
||||||
import org.jetbrains.kotlin.types.TypeUtils;
|
import org.jetbrains.kotlin.types.TypeUtils;
|
||||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
|
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
|
||||||
@@ -326,7 +327,8 @@ public class DataFlowAnalyzer {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public KotlinType checkStatementType(@NotNull KtExpression expression, @NotNull ResolutionContext context) {
|
public KotlinType checkStatementType(@NotNull KtExpression expression, @NotNull ResolutionContext context) {
|
||||||
if (!noExpectedType(context.expectedType) && !KotlinBuiltIns.isUnit(context.expectedType) && !context.expectedType.isError()) {
|
if (!noExpectedType(context.expectedType) && !KotlinBuiltIns.isUnit(context.expectedType) &&
|
||||||
|
!KotlinTypeKt.isError(context.expectedType)) {
|
||||||
context.trace.report(EXPECTED_TYPE_MISMATCH.on(expression, context.expectedType));
|
context.trace.report(EXPECTED_TYPE_MISMATCH.on(expression, context.expectedType));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -43,6 +43,7 @@ import org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil;
|
|||||||
import org.jetbrains.kotlin.resolve.scopes.LexicalWritableScope;
|
import org.jetbrains.kotlin.resolve.scopes.LexicalWritableScope;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver;
|
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver;
|
||||||
import org.jetbrains.kotlin.types.KotlinType;
|
import org.jetbrains.kotlin.types.KotlinType;
|
||||||
|
import org.jetbrains.kotlin.types.KotlinTypeKt;
|
||||||
import org.jetbrains.kotlin.types.TypeUtils;
|
import org.jetbrains.kotlin.types.TypeUtils;
|
||||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
|
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
|
||||||
import org.jetbrains.kotlin.types.expressions.typeInfoFactory.TypeInfoFactoryKt;
|
import org.jetbrains.kotlin.types.expressions.typeInfoFactory.TypeInfoFactoryKt;
|
||||||
@@ -89,7 +90,7 @@ public class ExpressionTypingVisitorForStatements extends ExpressionTypingVisito
|
|||||||
@NotNull ExpressionTypingContext context
|
@NotNull ExpressionTypingContext context
|
||||||
) {
|
) {
|
||||||
if (assignmentType != null && !KotlinBuiltIns.isUnit(assignmentType) && !noExpectedType(context.expectedType) &&
|
if (assignmentType != null && !KotlinBuiltIns.isUnit(assignmentType) && !noExpectedType(context.expectedType) &&
|
||||||
!context.expectedType.isError() && TypeUtils.equalTypes(context.expectedType, assignmentType)) {
|
!KotlinTypeKt.isError(context.expectedType) && TypeUtils.equalTypes(context.expectedType, assignmentType)) {
|
||||||
context.trace.report(Errors.ASSIGNMENT_TYPE_MISMATCH.on(expression, context.expectedType));
|
context.trace.report(Errors.ASSIGNMENT_TYPE_MISMATCH.on(expression, context.expectedType));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-7
@@ -16,15 +16,17 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.types.expressions
|
package org.jetbrains.kotlin.types.expressions
|
||||||
|
|
||||||
import org.jetbrains.kotlin.psi.*
|
|
||||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory
|
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
|
||||||
import org.jetbrains.kotlin.lexer.KtTokens
|
|
||||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.Nullability
|
|
||||||
import org.jetbrains.kotlin.diagnostics.Errors
|
import org.jetbrains.kotlin.diagnostics.Errors
|
||||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValue
|
import org.jetbrains.kotlin.lexer.KtTokens
|
||||||
import org.jetbrains.kotlin.resolve.BindingTrace
|
import org.jetbrains.kotlin.psi.KtBinaryExpression
|
||||||
|
import org.jetbrains.kotlin.psi.KtExpression
|
||||||
|
import org.jetbrains.kotlin.psi.KtPsiUtil
|
||||||
import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext
|
import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext
|
||||||
|
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValue
|
||||||
|
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory
|
||||||
|
import org.jetbrains.kotlin.resolve.calls.smartcasts.Nullability
|
||||||
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
|
import org.jetbrains.kotlin.types.isError
|
||||||
|
|
||||||
object SenselessComparisonChecker {
|
object SenselessComparisonChecker {
|
||||||
@JvmStatic fun checkSenselessComparisonWithNull(
|
@JvmStatic fun checkSenselessComparisonWithNull(
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.incremental.record
|
|||||||
import org.jetbrains.kotlin.psi.KtExpression
|
import org.jetbrains.kotlin.psi.KtExpression
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
|
import org.jetbrains.kotlin.types.isError
|
||||||
import org.jetbrains.kotlin.types.typeUtil.isUnit
|
import org.jetbrains.kotlin.types.typeUtil.isUnit
|
||||||
|
|
||||||
fun LookupTracker.record(expression: KtExpression, type: KotlinType) {
|
fun LookupTracker.record(expression: KtExpression, type: KotlinType) {
|
||||||
|
|||||||
+1
@@ -29,6 +29,7 @@ import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid
|
|||||||
import org.jetbrains.kotlin.psi2ir.containsNull
|
import org.jetbrains.kotlin.psi2ir.containsNull
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
|
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
|
||||||
|
import org.jetbrains.kotlin.types.isError
|
||||||
import org.jetbrains.kotlin.types.isNullabilityFlexible
|
import org.jetbrains.kotlin.types.isNullabilityFlexible
|
||||||
import org.jetbrains.kotlin.types.typeUtil.makeNotNullable
|
import org.jetbrains.kotlin.types.typeUtil.makeNotNullable
|
||||||
import org.jetbrains.kotlin.types.upperIfFlexible
|
import org.jetbrains.kotlin.types.upperIfFlexible
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import org.jetbrains.kotlin.incremental.components.NoLookupLocation;
|
|||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope;
|
import org.jetbrains.kotlin.resolve.scopes.MemberScope;
|
||||||
import org.jetbrains.kotlin.types.KotlinType;
|
import org.jetbrains.kotlin.types.KotlinType;
|
||||||
|
import org.jetbrains.kotlin.types.KotlinTypeKt;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
|
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
@@ -101,7 +102,7 @@ public class DescriptorValidator {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!allowErrorTypes && type.isError()) {
|
if (!allowErrorTypes && KotlinTypeKt.isError(type)) {
|
||||||
report(collector, descriptor, "Error type: " + type);
|
report(collector, descriptor, "Error type: " + type);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -166,7 +167,7 @@ public class DescriptorValidator {
|
|||||||
KotlinType expected,
|
KotlinType expected,
|
||||||
KotlinType actual
|
KotlinType actual
|
||||||
) {
|
) {
|
||||||
if (expected.isError() && actual.isError()) {
|
if (KotlinTypeKt.isError(expected) && KotlinTypeKt.isError(actual)) {
|
||||||
assertEquals(descriptor, collector, name, expected.toString(), actual.toString());
|
assertEquals(descriptor, collector, name, expected.toString(), actual.toString());
|
||||||
}
|
}
|
||||||
else if (!expected.equals(actual)) {
|
else if (!expected.equals(actual)) {
|
||||||
|
|||||||
@@ -537,16 +537,10 @@ public class KotlinTypeCheckerTest extends KotlinTestWithEnvironment {
|
|||||||
Project project = getProject();
|
Project project = getProject();
|
||||||
KtExpression ktExpression = KtPsiFactoryKt.KtPsiFactory(project).createExpression(expression);
|
KtExpression ktExpression = KtPsiFactoryKt.KtPsiFactory(project).createExpression(expression);
|
||||||
KotlinType type = expressionTypingServices.getType(scopeWithImports, ktExpression, TypeUtils.NO_EXPECTED_TYPE, DataFlowInfoFactory.EMPTY, KotlinTestUtils.DUMMY_TRACE);
|
KotlinType type = expressionTypingServices.getType(scopeWithImports, ktExpression, TypeUtils.NO_EXPECTED_TYPE, DataFlowInfoFactory.EMPTY, KotlinTestUtils.DUMMY_TRACE);
|
||||||
|
assertNotNull(type);
|
||||||
assertTrue(type + " != " + expectedType, type.equals(expectedType));
|
assertTrue(type + " != " + expectedType, type.equals(expectedType));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertErrorType(String expression) {
|
|
||||||
Project project = getProject();
|
|
||||||
KtExpression ktExpression = KtPsiFactoryKt.KtPsiFactory(project).createExpression(expression);
|
|
||||||
KotlinType type = expressionTypingServices.safeGetType(scopeWithImports, ktExpression, TypeUtils.NO_EXPECTED_TYPE, DataFlowInfoFactory.EMPTY, KotlinTestUtils.DUMMY_TRACE);
|
|
||||||
assertTrue("Error type expected but " + type + " returned", type.isError());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void assertType(String contextType, String expression, String expectedType) {
|
private void assertType(String contextType, String expression, String expectedType) {
|
||||||
KotlinType thisType = makeType(contextType);
|
KotlinType thisType = makeType(contextType);
|
||||||
ReceiverParameterDescriptorImpl receiverParameterDescriptor = new ReceiverParameterDescriptorImpl(
|
ReceiverParameterDescriptorImpl receiverParameterDescriptor = new ReceiverParameterDescriptorImpl(
|
||||||
|
|||||||
-3
@@ -243,7 +243,4 @@ internal class NotNullTypeParameter(override val delegate: SimpleType) : CustomT
|
|||||||
override fun replaceAnnotations(newAnnotations: Annotations) = NotNullTypeParameter(delegate.replaceAnnotations(newAnnotations))
|
override fun replaceAnnotations(newAnnotations: Annotations) = NotNullTypeParameter(delegate.replaceAnnotations(newAnnotations))
|
||||||
override fun makeNullableAsSpecified(newNullability: Boolean) =
|
override fun makeNullableAsSpecified(newNullability: Boolean) =
|
||||||
if (newNullability) delegate.makeNullableAsSpecified(true) else this
|
if (newNullability) delegate.makeNullableAsSpecified(true) else this
|
||||||
|
|
||||||
override val isError: Boolean
|
|
||||||
get() = false
|
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-7
@@ -23,10 +23,7 @@ import org.jetbrains.kotlin.name.Name
|
|||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
|
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
|
||||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
||||||
import org.jetbrains.kotlin.storage.StorageManager
|
import org.jetbrains.kotlin.storage.StorageManager
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.*
|
||||||
import org.jetbrains.kotlin.types.SimpleType
|
|
||||||
import org.jetbrains.kotlin.types.TypeConstructor
|
|
||||||
import org.jetbrains.kotlin.types.TypeUtils
|
|
||||||
|
|
||||||
abstract class AbstractTypeAliasDescriptor(
|
abstract class AbstractTypeAliasDescriptor(
|
||||||
containingDeclaration: DeclarationDescriptor,
|
containingDeclaration: DeclarationDescriptor,
|
||||||
@@ -53,9 +50,9 @@ abstract class AbstractTypeAliasDescriptor(
|
|||||||
// NB: it's ok to use underlyingType here, since referenced inner type aliases also capture type parameters.
|
// NB: it's ok to use underlyingType here, since referenced inner type aliases also capture type parameters.
|
||||||
// Using expandedType looks "proper", but in fact will cause a recursion in expandedType resolution,
|
// Using expandedType looks "proper", but in fact will cause a recursion in expandedType resolution,
|
||||||
// which will silently produce wrong result.
|
// which will silently produce wrong result.
|
||||||
TypeUtils.contains(underlyingType) {
|
TypeUtils.contains(underlyingType) { type ->
|
||||||
!it.isError && run {
|
!type.isError && run {
|
||||||
val constructorDescriptor = it.constructor.declarationDescriptor
|
val constructorDescriptor = type.constructor.declarationDescriptor
|
||||||
constructorDescriptor is TypeParameterDescriptor &&
|
constructorDescriptor is TypeParameterDescriptor &&
|
||||||
constructorDescriptor.containingDeclaration != this@AbstractTypeAliasDescriptor
|
constructorDescriptor.containingDeclaration != this@AbstractTypeAliasDescriptor
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-5
@@ -23,10 +23,7 @@ import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
|||||||
import org.jetbrains.kotlin.name.Name;
|
import org.jetbrains.kotlin.name.Name;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope;
|
import org.jetbrains.kotlin.resolve.scopes.MemberScope;
|
||||||
import org.jetbrains.kotlin.storage.LockBasedStorageManager;
|
import org.jetbrains.kotlin.storage.LockBasedStorageManager;
|
||||||
import org.jetbrains.kotlin.types.ClassTypeConstructorImpl;
|
import org.jetbrains.kotlin.types.*;
|
||||||
import org.jetbrains.kotlin.types.KotlinType;
|
|
||||||
import org.jetbrains.kotlin.types.TypeConstructor;
|
|
||||||
import org.jetbrains.kotlin.types.TypeUtils;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@@ -126,7 +123,7 @@ public class MutableClassDescriptor extends ClassDescriptorBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addSupertype(@NotNull KotlinType supertype) {
|
public void addSupertype(@NotNull KotlinType supertype) {
|
||||||
assert !supertype.isError() : "Error types must be filtered out in DescriptorResolver";
|
assert !KotlinTypeKt.isError(supertype) : "Error types must be filtered out in DescriptorResolver";
|
||||||
if (TypeUtils.getClassDescriptor(supertype) != null) {
|
if (TypeUtils.getClassDescriptor(supertype) != null) {
|
||||||
// See the Errors.SUPERTYPE_NOT_A_CLASS_OR_INTERFACE
|
// See the Errors.SUPERTYPE_NOT_A_CLASS_OR_INTERFACE
|
||||||
supertypes.add(supertype);
|
supertypes.add(supertype);
|
||||||
|
|||||||
+6
-2
@@ -19,12 +19,16 @@ package org.jetbrains.kotlin.descriptors.impl;
|
|||||||
import kotlin.jvm.functions.Function1;
|
import kotlin.jvm.functions.Function1;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.kotlin.descriptors.*;
|
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
|
||||||
|
import org.jetbrains.kotlin.descriptors.SourceElement;
|
||||||
|
import org.jetbrains.kotlin.descriptors.SupertypeLoopChecker;
|
||||||
|
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor;
|
||||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
||||||
import org.jetbrains.kotlin.name.Name;
|
import org.jetbrains.kotlin.name.Name;
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
||||||
import org.jetbrains.kotlin.storage.LockBasedStorageManager;
|
import org.jetbrains.kotlin.storage.LockBasedStorageManager;
|
||||||
import org.jetbrains.kotlin.types.KotlinType;
|
import org.jetbrains.kotlin.types.KotlinType;
|
||||||
|
import org.jetbrains.kotlin.types.KotlinTypeKt;
|
||||||
import org.jetbrains.kotlin.types.Variance;
|
import org.jetbrains.kotlin.types.Variance;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -126,7 +130,7 @@ public class TypeParameterDescriptorImpl extends AbstractTypeParameterDescriptor
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void doAddUpperBound(KotlinType bound) {
|
private void doAddUpperBound(KotlinType bound) {
|
||||||
if (bound.isError()) return;
|
if (KotlinTypeKt.isError(bound)) return;
|
||||||
upperBounds.add(bound); // TODO : Duplicates?
|
upperBounds.add(bound); // TODO : Duplicates?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,10 +33,7 @@ import org.jetbrains.kotlin.resolve.constants.ConstantValue;
|
|||||||
import org.jetbrains.kotlin.resolve.constants.StringValue;
|
import org.jetbrains.kotlin.resolve.constants.StringValue;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter;
|
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope;
|
import org.jetbrains.kotlin.resolve.scopes.MemberScope;
|
||||||
import org.jetbrains.kotlin.types.ErrorUtils;
|
import org.jetbrains.kotlin.types.*;
|
||||||
import org.jetbrains.kotlin.types.KotlinType;
|
|
||||||
import org.jetbrains.kotlin.types.TypeConstructor;
|
|
||||||
import org.jetbrains.kotlin.types.TypeUtils;
|
|
||||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
|
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -449,7 +446,7 @@ public class DescriptorUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean shouldRecordInitializerForProperty(@NotNull VariableDescriptor variable, @NotNull KotlinType type) {
|
public static boolean shouldRecordInitializerForProperty(@NotNull VariableDescriptor variable, @NotNull KotlinType type) {
|
||||||
if (variable.isVar() || type.isError()) return false;
|
if (variable.isVar() || KotlinTypeKt.isError(type)) return false;
|
||||||
|
|
||||||
if (TypeUtils.acceptsNullable(type)) return true;
|
if (TypeUtils.acceptsNullable(type)) return true;
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import org.jetbrains.kotlin.descriptors.impl.PropertyDescriptorImpl;
|
|||||||
import org.jetbrains.kotlin.name.Name;
|
import org.jetbrains.kotlin.name.Name;
|
||||||
import org.jetbrains.kotlin.types.FlexibleTypesKt;
|
import org.jetbrains.kotlin.types.FlexibleTypesKt;
|
||||||
import org.jetbrains.kotlin.types.KotlinType;
|
import org.jetbrains.kotlin.types.KotlinType;
|
||||||
|
import org.jetbrains.kotlin.types.KotlinTypeKt;
|
||||||
import org.jetbrains.kotlin.types.TypeConstructor;
|
import org.jetbrains.kotlin.types.TypeConstructor;
|
||||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
|
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
|
||||||
import org.jetbrains.kotlin.types.checker.KotlinTypeCheckerImpl;
|
import org.jetbrains.kotlin.types.checker.KotlinTypeCheckerImpl;
|
||||||
@@ -270,7 +271,7 @@ public class OverridingUtil {
|
|||||||
KotlinType subReturnType = subDescriptor.getReturnType();
|
KotlinType subReturnType = subDescriptor.getReturnType();
|
||||||
|
|
||||||
if (superReturnType != null && subReturnType != null) {
|
if (superReturnType != null && subReturnType != null) {
|
||||||
boolean bothErrors = subReturnType.isError() && superReturnType.isError();
|
boolean bothErrors = KotlinTypeKt.isError(subReturnType) && KotlinTypeKt.isError(superReturnType);
|
||||||
if (!bothErrors && !typeChecker.isSubtypeOf(subReturnType, superReturnType)) {
|
if (!bothErrors && !typeChecker.isSubtypeOf(subReturnType, superReturnType)) {
|
||||||
return OverrideCompatibilityInfo.conflict("Return type mismatch");
|
return OverrideCompatibilityInfo.conflict("Return type mismatch");
|
||||||
}
|
}
|
||||||
@@ -353,7 +354,7 @@ public class OverridingUtil {
|
|||||||
@NotNull KotlinType typeInSub,
|
@NotNull KotlinType typeInSub,
|
||||||
@NotNull KotlinTypeChecker typeChecker
|
@NotNull KotlinTypeChecker typeChecker
|
||||||
) {
|
) {
|
||||||
boolean bothErrors = typeInSuper.isError() && typeInSub.isError();
|
boolean bothErrors = KotlinTypeKt.isError(typeInSuper) && KotlinTypeKt.isError(typeInSub);
|
||||||
return bothErrors || typeChecker.equalTypes(typeInSuper, typeInSub);
|
return bothErrors || typeChecker.equalTypes(typeInSuper, typeInSub);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-3
@@ -65,14 +65,12 @@ class CapturedType(
|
|||||||
override val isMarkedNullable: Boolean = false,
|
override val isMarkedNullable: Boolean = false,
|
||||||
override val annotations: Annotations = Annotations.EMPTY
|
override val annotations: Annotations = Annotations.EMPTY
|
||||||
): SimpleType(), SubtypingRepresentatives {
|
): SimpleType(), SubtypingRepresentatives {
|
||||||
|
|
||||||
override val arguments: List<TypeProjection>
|
override val arguments: List<TypeProjection>
|
||||||
get() = listOf()
|
get() = listOf()
|
||||||
|
|
||||||
override val memberScope: MemberScope
|
override val memberScope: MemberScope
|
||||||
get() = ErrorUtils.createErrorScope(
|
get() = ErrorUtils.createErrorScope(
|
||||||
"No member resolution should be done on captured type, it used only during constraint system resolution", true)
|
"No member resolution should be done on captured type, it used only during constraint system resolution", true)
|
||||||
override val isError: Boolean
|
|
||||||
get() = false
|
|
||||||
|
|
||||||
override val subTypeRepresentative: KotlinType
|
override val subTypeRepresentative: KotlinType
|
||||||
get() = representative(OUT_VARIANCE, builtIns.nullableAnyType)
|
get() = representative(OUT_VARIANCE, builtIns.nullableAnyType)
|
||||||
|
|||||||
@@ -470,7 +470,7 @@ public class ErrorUtils {
|
|||||||
|
|
||||||
public static boolean containsErrorType(@Nullable KotlinType type) {
|
public static boolean containsErrorType(@Nullable KotlinType type) {
|
||||||
if (type == null) return false;
|
if (type == null) return false;
|
||||||
if (type.isError()) return true;
|
if (KotlinTypeKt.isError(type)) return true;
|
||||||
for (TypeProjection projection : type.getArguments()) {
|
for (TypeProjection projection : type.getArguments()) {
|
||||||
if (!projection.isStarProjection() && containsErrorType(projection.getType())) return true;
|
if (!projection.isStarProjection() && containsErrorType(projection.getType())) return true;
|
||||||
}
|
}
|
||||||
@@ -486,7 +486,7 @@ public class ErrorUtils {
|
|||||||
return candidate instanceof ErrorClassDescriptor;
|
return candidate instanceof ErrorClassDescriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ErrorTypeImpl extends SimpleType {
|
public static class ErrorTypeImpl extends SimpleType {
|
||||||
private final TypeConstructor constructor;
|
private final TypeConstructor constructor;
|
||||||
private final MemberScope memberScope;
|
private final MemberScope memberScope;
|
||||||
private final List<TypeProjection> arguments;
|
private final List<TypeProjection> arguments;
|
||||||
@@ -531,17 +531,13 @@ public class ErrorUtils {
|
|||||||
return memberScope;
|
return memberScope;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isError() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public Annotations getAnnotations() {
|
public Annotations getAnnotations() {
|
||||||
return Annotations.Companion.getEMPTY();
|
return Annotations.Companion.getEMPTY();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return constructor.toString() + (arguments.isEmpty() ? "" : joinToString(arguments, ", ", "<", ">", -1, "...", null));
|
return constructor.toString() + (arguments.isEmpty() ? "" : joinToString(arguments, ", ", "<", ">", -1, "...", null));
|
||||||
|
|||||||
@@ -46,7 +46,6 @@ sealed class KotlinType : Annotated {
|
|||||||
abstract val arguments: List<TypeProjection>
|
abstract val arguments: List<TypeProjection>
|
||||||
abstract val isMarkedNullable: Boolean
|
abstract val isMarkedNullable: Boolean
|
||||||
abstract val memberScope: MemberScope
|
abstract val memberScope: MemberScope
|
||||||
abstract val isError: Boolean
|
|
||||||
|
|
||||||
abstract fun unwrap(): UnwrappedType
|
abstract fun unwrap(): UnwrappedType
|
||||||
|
|
||||||
@@ -67,7 +66,7 @@ sealed class KotlinType : Annotated {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class WrappedType() : KotlinType() {
|
abstract class WrappedType : KotlinType() {
|
||||||
open fun isComputed(): Boolean = true
|
open fun isComputed(): Boolean = true
|
||||||
protected abstract val delegate: KotlinType
|
protected abstract val delegate: KotlinType
|
||||||
|
|
||||||
@@ -76,7 +75,6 @@ abstract class WrappedType() : KotlinType() {
|
|||||||
override val arguments: List<TypeProjection> get() = delegate.arguments
|
override val arguments: List<TypeProjection> get() = delegate.arguments
|
||||||
override val isMarkedNullable: Boolean get() = delegate.isMarkedNullable
|
override val isMarkedNullable: Boolean get() = delegate.isMarkedNullable
|
||||||
override val memberScope: MemberScope get() = delegate.memberScope
|
override val memberScope: MemberScope get() = delegate.memberScope
|
||||||
override val isError: Boolean get() = delegate.isError
|
|
||||||
|
|
||||||
override final fun unwrap(): UnwrappedType {
|
override final fun unwrap(): UnwrappedType {
|
||||||
var result = delegate
|
var result = delegate
|
||||||
@@ -156,8 +154,13 @@ abstract class FlexibleType(val lowerBound: SimpleType, val upperBound: SimpleTy
|
|||||||
override val arguments: List<TypeProjection> get() = delegate.arguments
|
override val arguments: List<TypeProjection> get() = delegate.arguments
|
||||||
override val isMarkedNullable: Boolean get() = delegate.isMarkedNullable
|
override val isMarkedNullable: Boolean get() = delegate.isMarkedNullable
|
||||||
override val memberScope: MemberScope get() = delegate.memberScope
|
override val memberScope: MemberScope get() = delegate.memberScope
|
||||||
override val isError: Boolean get() = delegate.isError // todo should be false?
|
|
||||||
|
|
||||||
override fun toString(): String = DescriptorRenderer.DEBUG_TEXT.renderType(this)
|
override fun toString(): String = DescriptorRenderer.DEBUG_TEXT.renderType(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val KotlinType.isError: Boolean
|
||||||
|
get() {
|
||||||
|
val unwrapped = unwrap()
|
||||||
|
return unwrapped is ErrorUtils.ErrorTypeImpl ||
|
||||||
|
(unwrapped is FlexibleType && unwrapped.delegate is ErrorUtils.ErrorTypeImpl)
|
||||||
|
}
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
|||||||
import org.jetbrains.kotlin.descriptors.TypeAliasDescriptor
|
import org.jetbrains.kotlin.descriptors.TypeAliasDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||||
import org.jetbrains.kotlin.name.Name
|
|
||||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
||||||
import java.lang.IllegalStateException
|
import java.lang.IllegalStateException
|
||||||
|
|
||||||
@@ -75,11 +74,11 @@ private class SimpleTypeImpl(
|
|||||||
override val isMarkedNullable: Boolean,
|
override val isMarkedNullable: Boolean,
|
||||||
override val memberScope: MemberScope
|
override val memberScope: MemberScope
|
||||||
) : SimpleType() {
|
) : SimpleType() {
|
||||||
override fun replaceAnnotations(newAnnotations: Annotations) = SimpleTypeImpl(newAnnotations, constructor, arguments, isMarkedNullable, memberScope)
|
override fun replaceAnnotations(newAnnotations: Annotations) =
|
||||||
override fun makeNullableAsSpecified(newNullability: Boolean) = SimpleTypeImpl(annotations, constructor, arguments, newNullability, memberScope)
|
SimpleTypeImpl(newAnnotations, constructor, arguments, isMarkedNullable, memberScope)
|
||||||
|
|
||||||
override val isError: Boolean
|
override fun makeNullableAsSpecified(newNullability: Boolean) =
|
||||||
get() = false
|
SimpleTypeImpl(annotations, constructor, arguments, newNullability, memberScope)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
if (memberScope is ErrorUtils.ErrorScope) {
|
if (memberScope is ErrorUtils.ErrorScope) {
|
||||||
|
|||||||
@@ -38,8 +38,6 @@ class AbbreviatedType(override val delegate: SimpleType, val abbreviation: Simpl
|
|||||||
|
|
||||||
override fun makeNullableAsSpecified(newNullability: Boolean)
|
override fun makeNullableAsSpecified(newNullability: Boolean)
|
||||||
= AbbreviatedType(delegate.makeNullableAsSpecified(newNullability), abbreviation.makeNullableAsSpecified(newNullability))
|
= AbbreviatedType(delegate.makeNullableAsSpecified(newNullability), abbreviation.makeNullableAsSpecified(newNullability))
|
||||||
|
|
||||||
override val isError: Boolean get() = false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun KotlinType.getAbbreviatedType(): AbbreviatedType? = unwrap() as? AbbreviatedType
|
fun KotlinType.getAbbreviatedType(): AbbreviatedType? = unwrap() as? AbbreviatedType
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ public class TypeSubstitutor {
|
|||||||
return new TypeProjectionImpl(substitutedProjectionKind, substitutedFlexibleType);
|
return new TypeProjectionImpl(substitutedProjectionKind, substitutedFlexibleType);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (KotlinBuiltIns.isNothing(type) || type.isError()) return originalProjection;
|
if (KotlinBuiltIns.isNothing(type) || KotlinTypeKt.isError(type)) return originalProjection;
|
||||||
|
|
||||||
if (replacement != null) {
|
if (replacement != null) {
|
||||||
VarianceConflictType varianceConflict = conflictType(originalProjectionKind, replacement.getProjectionKind());
|
VarianceConflictType varianceConflict = conflictType(originalProjectionKind, replacement.getProjectionKind());
|
||||||
|
|||||||
@@ -49,11 +49,6 @@ public class TypeUtils {
|
|||||||
throw new IllegalStateException(name);
|
throw new IllegalStateException(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isError() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public SimpleType replaceAnnotations(@NotNull Annotations newAnnotations) {
|
public SimpleType replaceAnnotations(@NotNull Annotations newAnnotations) {
|
||||||
@@ -66,6 +61,7 @@ public class TypeUtils {
|
|||||||
throw new IllegalStateException(name);
|
throw new IllegalStateException(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return name;
|
return name;
|
||||||
@@ -444,7 +440,7 @@ public class TypeUtils {
|
|||||||
@NotNull IntegerValueTypeConstructor numberValueTypeConstructor,
|
@NotNull IntegerValueTypeConstructor numberValueTypeConstructor,
|
||||||
@NotNull KotlinType expectedType
|
@NotNull KotlinType expectedType
|
||||||
) {
|
) {
|
||||||
if (noExpectedType(expectedType) || expectedType.isError()) {
|
if (noExpectedType(expectedType) || KotlinTypeKt.isError(expectedType)) {
|
||||||
return getDefaultPrimitiveNumberType(numberValueTypeConstructor);
|
return getDefaultPrimitiveNumberType(numberValueTypeConstructor);
|
||||||
}
|
}
|
||||||
for (KotlinType primitiveNumberType : numberValueTypeConstructor.getSupertypes()) {
|
for (KotlinType primitiveNumberType : numberValueTypeConstructor.getSupertypes()) {
|
||||||
|
|||||||
@@ -86,13 +86,13 @@ class NewCapturedType(
|
|||||||
override val annotations: Annotations = Annotations.EMPTY,
|
override val annotations: Annotations = Annotations.EMPTY,
|
||||||
override val isMarkedNullable: Boolean = false
|
override val isMarkedNullable: Boolean = false
|
||||||
): SimpleType() {
|
): SimpleType() {
|
||||||
|
constructor(captureStatus: CaptureStatus, lowerType: UnwrappedType?, projection: TypeProjection) :
|
||||||
constructor(captureStatus: CaptureStatus, lowerType: UnwrappedType?, projection: TypeProjection): this(captureStatus, NewCapturedTypeConstructor(projection), lowerType)
|
this(captureStatus, NewCapturedTypeConstructor(projection), lowerType)
|
||||||
|
|
||||||
override val arguments: List<TypeProjection> get() = listOf()
|
override val arguments: List<TypeProjection> get() = listOf()
|
||||||
|
|
||||||
override val memberScope: MemberScope // todo what about foo().bar() where foo() return captured type?
|
override val memberScope: MemberScope // todo what about foo().bar() where foo() return captured type?
|
||||||
get() = ErrorUtils.createErrorScope("No member resolution should be done on captured type!", true)
|
get() = ErrorUtils.createErrorScope("No member resolution should be done on captured type!", true)
|
||||||
override val isError: Boolean get() = false
|
|
||||||
|
|
||||||
override fun replaceAnnotations(newAnnotations: Annotations) =
|
override fun replaceAnnotations(newAnnotations: Annotations) =
|
||||||
NewCapturedType(captureStatus, constructor, lowerType, newAnnotations, isMarkedNullable)
|
NewCapturedType(captureStatus, constructor, lowerType, newAnnotations, isMarkedNullable)
|
||||||
|
|||||||
@@ -65,7 +65,8 @@ public class TypeCheckingProcedure {
|
|||||||
if (type1 == type2) return true;
|
if (type1 == type2) return true;
|
||||||
if (FlexibleTypesKt.isFlexible(type1)) {
|
if (FlexibleTypesKt.isFlexible(type1)) {
|
||||||
if (FlexibleTypesKt.isFlexible(type2)) {
|
if (FlexibleTypesKt.isFlexible(type2)) {
|
||||||
return !type1.isError() && !type2.isError() && isSubtypeOf(type1, type2) && isSubtypeOf(type2, type1);
|
return !KotlinTypeKt.isError(type1) && !KotlinTypeKt.isError(type2) &&
|
||||||
|
isSubtypeOf(type1, type2) && isSubtypeOf(type2, type1);
|
||||||
}
|
}
|
||||||
return heterogeneousEquivalence(type2, type1);
|
return heterogeneousEquivalence(type2, type1);
|
||||||
}
|
}
|
||||||
@@ -194,7 +195,7 @@ public class TypeCheckingProcedure {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isSubtypeOfForRepresentatives(KotlinType subtype, KotlinType supertype) {
|
private boolean isSubtypeOfForRepresentatives(KotlinType subtype, KotlinType supertype) {
|
||||||
if (subtype.isError() || supertype.isError()) {
|
if (KotlinTypeKt.isError(subtype) || KotlinTypeKt.isError(supertype)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -239,7 +240,7 @@ public class TypeCheckingProcedure {
|
|||||||
|
|
||||||
if (capture(subArgument, superArgument, parameter)) continue;
|
if (capture(subArgument, superArgument, parameter)) continue;
|
||||||
|
|
||||||
boolean argumentIsErrorType = subArgument.getType().isError() || superArgument.getType().isError();
|
boolean argumentIsErrorType = KotlinTypeKt.isError(subArgument.getType()) || KotlinTypeKt.isError(superArgument.getType());
|
||||||
if (!argumentIsErrorType && parameter.getVariance() == INVARIANT &&
|
if (!argumentIsErrorType && parameter.getVariance() == INVARIANT &&
|
||||||
subArgument.getProjectionKind() == INVARIANT && superArgument.getProjectionKind() == INVARIANT) {
|
subArgument.getProjectionKind() == INVARIANT && superArgument.getProjectionKind() == INVARIANT) {
|
||||||
if (!constraints.assertEqualTypes(subArgument.getType(), superArgument.getType(), this)) return false;
|
if (!constraints.assertEqualTypes(subArgument.getType(), superArgument.getType(), this)) return false;
|
||||||
|
|||||||
+1
-4
@@ -27,10 +27,7 @@ import org.jetbrains.kotlin.serialization.deserialization.IncompatibleVersionErr
|
|||||||
import org.jetbrains.kotlin.serialization.deserialization.NameResolver
|
import org.jetbrains.kotlin.serialization.deserialization.NameResolver
|
||||||
import org.jetbrains.kotlin.serialization.deserialization.TypeTable
|
import org.jetbrains.kotlin.serialization.deserialization.TypeTable
|
||||||
import org.jetbrains.kotlin.storage.StorageManager
|
import org.jetbrains.kotlin.storage.StorageManager
|
||||||
import org.jetbrains.kotlin.types.SimpleType
|
import org.jetbrains.kotlin.types.*
|
||||||
import org.jetbrains.kotlin.types.TypeSubstitutor
|
|
||||||
import org.jetbrains.kotlin.types.Variance
|
|
||||||
import org.jetbrains.kotlin.types.asSimpleType
|
|
||||||
|
|
||||||
interface DeserializedMemberDescriptor : MemberDescriptor {
|
interface DeserializedMemberDescriptor : MemberDescriptor {
|
||||||
val proto: MessageLite
|
val proto: MessageLite
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ import org.jetbrains.kotlin.resolve.BindingContext
|
|||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||||
import org.jetbrains.kotlin.resolve.inline.InlineUtil
|
import org.jetbrains.kotlin.resolve.inline.InlineUtil
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
|
import org.jetbrains.kotlin.types.isError
|
||||||
import org.jetbrains.kotlin.types.typeUtil.TypeNullability
|
import org.jetbrains.kotlin.types.typeUtil.TypeNullability
|
||||||
import org.jetbrains.kotlin.types.typeUtil.nullability
|
import org.jetbrains.kotlin.types.typeUtil.nullability
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|||||||
+1
@@ -44,6 +44,7 @@ import org.jetbrains.kotlin.resolve.BindingContext
|
|||||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||||
import org.jetbrains.kotlin.resolve.scopes.utils.collectDescriptorsFiltered
|
import org.jetbrains.kotlin.resolve.scopes.utils.collectDescriptorsFiltered
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
|
import org.jetbrains.kotlin.types.isError
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class ParameterNameAndTypeCompletion(
|
class ParameterNameAndTypeCompletion(
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ import org.jetbrains.kotlin.resolve.DescriptorUtils
|
|||||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
import org.jetbrains.kotlin.types.TypeUtils
|
import org.jetbrains.kotlin.types.TypeUtils
|
||||||
|
import org.jetbrains.kotlin.types.isError
|
||||||
import org.jetbrains.kotlin.types.typeUtil.isBooleanOrNullableBoolean
|
import org.jetbrains.kotlin.types.typeUtil.isBooleanOrNullableBoolean
|
||||||
import org.jetbrains.kotlin.types.typeUtil.makeNotNullable
|
import org.jetbrains.kotlin.types.typeUtil.makeNotNullable
|
||||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ import org.jetbrains.kotlin.resolve.OverridingUtil
|
|||||||
import org.jetbrains.kotlin.resolve.calls.callUtil.getValueArgumentsInParentheses
|
import org.jetbrains.kotlin.resolve.calls.callUtil.getValueArgumentsInParentheses
|
||||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
|
import org.jetbrains.kotlin.types.isError
|
||||||
|
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
inline fun <reified T: PsiElement> PsiElement.replaced(newElement: T): T {
|
inline fun <reified T: PsiElement> PsiElement.replaced(newElement: T): T {
|
||||||
|
|||||||
@@ -27,7 +27,10 @@ import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
|
|||||||
import org.jetbrains.kotlin.idea.caches.resolve.resolveImportReference
|
import org.jetbrains.kotlin.idea.caches.resolve.resolveImportReference
|
||||||
import org.jetbrains.kotlin.idea.core.*
|
import org.jetbrains.kotlin.idea.core.*
|
||||||
import org.jetbrains.kotlin.idea.intentions.RemoveExplicitTypeArgumentsIntention
|
import org.jetbrains.kotlin.idea.intentions.RemoveExplicitTypeArgumentsIntention
|
||||||
import org.jetbrains.kotlin.idea.util.*
|
import org.jetbrains.kotlin.idea.util.CommentSaver
|
||||||
|
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers
|
||||||
|
import org.jetbrains.kotlin.idea.util.ImportInsertHelper
|
||||||
|
import org.jetbrains.kotlin.idea.util.getResolutionScope
|
||||||
import org.jetbrains.kotlin.lexer.KtTokens
|
import org.jetbrains.kotlin.lexer.KtTokens
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.*
|
import org.jetbrains.kotlin.psi.psiUtil.*
|
||||||
@@ -41,6 +44,7 @@ import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
|||||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope
|
import org.jetbrains.kotlin.resolve.scopes.LexicalScope
|
||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ImplicitReceiver
|
import org.jetbrains.kotlin.resolve.scopes.receivers.ImplicitReceiver
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
|
import org.jetbrains.kotlin.types.isError
|
||||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
|
|||||||
+3
-2
@@ -28,12 +28,13 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
import org.jetbrains.kotlin.descriptors.VariableDescriptor;
|
import org.jetbrains.kotlin.descriptors.VariableDescriptor;
|
||||||
import org.jetbrains.kotlin.idea.caches.resolve.ResolutionUtils;
|
import org.jetbrains.kotlin.idea.caches.resolve.ResolutionUtils;
|
||||||
import org.jetbrains.kotlin.idea.codeInsight.CodeInsightUtils;
|
import org.jetbrains.kotlin.idea.codeInsight.CodeInsightUtils;
|
||||||
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers;
|
|
||||||
import org.jetbrains.kotlin.idea.core.ShortenReferences;
|
import org.jetbrains.kotlin.idea.core.ShortenReferences;
|
||||||
|
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers;
|
||||||
import org.jetbrains.kotlin.psi.*;
|
import org.jetbrains.kotlin.psi.*;
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
import org.jetbrains.kotlin.resolve.BindingContext;
|
||||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode;
|
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode;
|
||||||
import org.jetbrains.kotlin.types.KotlinType;
|
import org.jetbrains.kotlin.types.KotlinType;
|
||||||
|
import org.jetbrains.kotlin.types.KotlinTypeKt;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -130,7 +131,7 @@ public class MoveDeclarationsOutHelper {
|
|||||||
if (typeRef != null) {
|
if (typeRef != null) {
|
||||||
typeString = typeRef.getText();
|
typeString = typeRef.getText();
|
||||||
}
|
}
|
||||||
else if (!propertyType.isError()) {
|
else if (!KotlinTypeKt.isError(propertyType)) {
|
||||||
typeString = IdeDescriptorRenderers.SOURCE_CODE.renderType(propertyType);
|
typeString = IdeDescriptorRenderers.SOURCE_CODE.renderType(propertyType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ import org.jetbrains.kotlin.asJava.toLightClass
|
|||||||
import org.jetbrains.kotlin.asJava.toLightMethods
|
import org.jetbrains.kotlin.asJava.toLightMethods
|
||||||
import org.jetbrains.kotlin.descriptors.*
|
import org.jetbrains.kotlin.descriptors.*
|
||||||
import org.jetbrains.kotlin.descriptors.annotations.Annotated
|
import org.jetbrains.kotlin.descriptors.annotations.Annotated
|
||||||
|
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
|
||||||
import org.jetbrains.kotlin.idea.caches.resolve.findModuleDescriptor
|
import org.jetbrains.kotlin.idea.caches.resolve.findModuleDescriptor
|
||||||
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny
|
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny
|
||||||
import org.jetbrains.kotlin.idea.core.toDescriptor
|
import org.jetbrains.kotlin.idea.core.toDescriptor
|
||||||
@@ -67,6 +68,8 @@ import org.jetbrains.kotlin.lexer.KtTokens
|
|||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.*
|
import org.jetbrains.kotlin.psi.psiUtil.*
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||||
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
|
import org.jetbrains.kotlin.types.isError
|
||||||
import org.jetbrains.kotlin.util.findCallableMemberBySignature
|
import org.jetbrains.kotlin.util.findCallableMemberBySignature
|
||||||
import java.awt.GridBagConstraints
|
import java.awt.GridBagConstraints
|
||||||
import java.awt.GridBagLayout
|
import java.awt.GridBagLayout
|
||||||
@@ -114,9 +117,11 @@ class UnusedSymbolInspection : AbstractKotlinInspection() {
|
|||||||
// variation of IDEA's AnnotationUtil.checkAnnotatedUsingPatterns()
|
// variation of IDEA's AnnotationUtil.checkAnnotatedUsingPatterns()
|
||||||
private fun checkAnnotatedUsingPatterns(annotated: Annotated, annotationPatterns: Collection<String>): Boolean {
|
private fun checkAnnotatedUsingPatterns(annotated: Annotated, annotationPatterns: Collection<String>): Boolean {
|
||||||
val annotationsPresent = annotated.annotations
|
val annotationsPresent = annotated.annotations
|
||||||
.map { it.type }
|
.map(AnnotationDescriptor::getType)
|
||||||
.filter { !it.isError }
|
.filterNot(KotlinType::isError)
|
||||||
.mapNotNull { it.constructor.declarationDescriptor?.let { DescriptorUtils.getFqName(it).asString() } }
|
.mapNotNull { it.constructor.declarationDescriptor?.let { descriptor ->
|
||||||
|
DescriptorUtils.getFqName(descriptor).asString()
|
||||||
|
} }
|
||||||
|
|
||||||
if (annotationsPresent.isEmpty()) return false
|
if (annotationsPresent.isEmpty()) return false
|
||||||
|
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
|||||||
import org.jetbrains.kotlin.resolve.scopes.utils.findVariable
|
import org.jetbrains.kotlin.resolve.scopes.utils.findVariable
|
||||||
import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor
|
import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor
|
||||||
import org.jetbrains.kotlin.types.expressions.OperatorConventions
|
import org.jetbrains.kotlin.types.expressions.OperatorConventions
|
||||||
|
import org.jetbrains.kotlin.types.isError
|
||||||
import org.jetbrains.kotlin.types.typeUtil.supertypes
|
import org.jetbrains.kotlin.types.typeUtil.supertypes
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
|
|||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.hasDefaultValue
|
import org.jetbrains.kotlin.resolve.descriptorUtil.hasDefaultValue
|
||||||
import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor
|
import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor
|
||||||
import org.jetbrains.kotlin.types.isDynamic
|
import org.jetbrains.kotlin.types.isDynamic
|
||||||
|
import org.jetbrains.kotlin.types.isError
|
||||||
import org.jetbrains.kotlin.types.typeUtil.isTypeParameter
|
import org.jetbrains.kotlin.types.typeUtil.isTypeParameter
|
||||||
import org.jetbrains.kotlin.types.typeUtil.isUnit
|
import org.jetbrains.kotlin.types.typeUtil.isUnit
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import org.jetbrains.kotlin.psi.*
|
|||||||
import org.jetbrains.kotlin.resolve.BindingContext
|
import org.jetbrains.kotlin.resolve.BindingContext
|
||||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
|
import org.jetbrains.kotlin.types.isError
|
||||||
import org.jetbrains.kotlin.types.typeUtil.isNothing
|
import org.jetbrains.kotlin.types.typeUtil.isNothing
|
||||||
import org.jetbrains.kotlin.types.typeUtil.isUnit
|
import org.jetbrains.kotlin.types.typeUtil.isUnit
|
||||||
import java.lang.RuntimeException
|
import java.lang.RuntimeException
|
||||||
|
|||||||
+5
-1
@@ -29,8 +29,12 @@ import org.jetbrains.kotlin.idea.intentions.branchedTransformations.expressionCo
|
|||||||
import org.jetbrains.kotlin.idea.util.CommentSaver
|
import org.jetbrains.kotlin.idea.util.CommentSaver
|
||||||
import org.jetbrains.kotlin.lexer.KtTokens
|
import org.jetbrains.kotlin.lexer.KtTokens
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.*
|
import org.jetbrains.kotlin.psi.psiUtil.PsiChildRange
|
||||||
|
import org.jetbrains.kotlin.psi.psiUtil.endOffset
|
||||||
|
import org.jetbrains.kotlin.psi.psiUtil.siblings
|
||||||
|
import org.jetbrains.kotlin.psi.psiUtil.startOffset
|
||||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||||
|
import org.jetbrains.kotlin.types.isError
|
||||||
import org.jetbrains.kotlin.types.typeUtil.isNothing
|
import org.jetbrains.kotlin.types.typeUtil.isNothing
|
||||||
import org.jetbrains.kotlin.types.typeUtil.makeNotNullable
|
import org.jetbrains.kotlin.types.typeUtil.makeNotNullable
|
||||||
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
|
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
|
||||||
|
|||||||
@@ -19,13 +19,14 @@ package org.jetbrains.kotlin.idea.intentions
|
|||||||
import com.intellij.codeInsight.intention.LowPriorityAction
|
import com.intellij.codeInsight.intention.LowPriorityAction
|
||||||
import com.intellij.openapi.editor.Editor
|
import com.intellij.openapi.editor.Editor
|
||||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||||
|
import org.jetbrains.kotlin.idea.core.ShortenReferences
|
||||||
import org.jetbrains.kotlin.idea.core.replaced
|
import org.jetbrains.kotlin.idea.core.replaced
|
||||||
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers
|
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers
|
||||||
import org.jetbrains.kotlin.idea.core.ShortenReferences
|
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.getParentOfType
|
import org.jetbrains.kotlin.psi.psiUtil.getParentOfType
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext
|
import org.jetbrains.kotlin.resolve.BindingContext
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
|
import org.jetbrains.kotlin.types.isError
|
||||||
|
|
||||||
class ReconstructTypeInCastOrIsIntention : SelfTargetingOffsetIndependentIntention<KtTypeReference>(KtTypeReference::class.java, "Replace by reconstructed type"), LowPriorityAction {
|
class ReconstructTypeInCastOrIsIntention : SelfTargetingOffsetIndependentIntention<KtTypeReference>(KtTypeReference::class.java, "Replace by reconstructed type"), LowPriorityAction {
|
||||||
override fun isApplicableTo(element: KtTypeReference): Boolean {
|
override fun isApplicableTo(element: KtTypeReference): Boolean {
|
||||||
|
|||||||
+1
@@ -28,6 +28,7 @@ import org.jetbrains.kotlin.psi.KtPsiFactory
|
|||||||
import org.jetbrains.kotlin.psi.psiUtil.endOffset
|
import org.jetbrains.kotlin.psi.psiUtil.endOffset
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext
|
import org.jetbrains.kotlin.resolve.BindingContext
|
||||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||||
|
import org.jetbrains.kotlin.types.isError
|
||||||
|
|
||||||
class SpecifyExplicitLambdaSignatureIntention : SelfTargetingIntention<KtLambdaExpression>(KtLambdaExpression::class.java, "Specify explicit lambda signature"), LowPriorityAction {
|
class SpecifyExplicitLambdaSignatureIntention : SelfTargetingIntention<KtLambdaExpression>(KtLambdaExpression::class.java, "Specify explicit lambda signature"), LowPriorityAction {
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ import org.jetbrains.kotlin.resolve.calls.util.DelegatingCall
|
|||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.hasDefaultValue
|
import org.jetbrains.kotlin.resolve.descriptorUtil.hasDefaultValue
|
||||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
|
import org.jetbrains.kotlin.types.isError
|
||||||
import org.jetbrains.kotlin.types.typeUtil.containsError
|
import org.jetbrains.kotlin.types.typeUtil.containsError
|
||||||
import java.awt.Color
|
import java.awt.Color
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ import org.jetbrains.kotlin.psi.psiUtil.getParentOfType
|
|||||||
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
|
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
|
||||||
import org.jetbrains.kotlin.resolve.calls.model.ArgumentMatch
|
import org.jetbrains.kotlin.resolve.calls.model.ArgumentMatch
|
||||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||||
|
import org.jetbrains.kotlin.types.isError
|
||||||
|
|
||||||
class AddNameToArgumentFix(argument: KtValueArgument) : KotlinQuickFixAction<KtValueArgument>(argument) {
|
class AddNameToArgumentFix(argument: KtValueArgument) : KotlinQuickFixAction<KtValueArgument>(argument) {
|
||||||
override fun isAvailable(project: Project, editor: Editor?, file: PsiFile): Boolean {
|
override fun isAvailable(project: Project, editor: Editor?, file: PsiFile): Boolean {
|
||||||
|
|||||||
@@ -22,21 +22,19 @@ import com.intellij.psi.PsiFile
|
|||||||
import org.jetbrains.kotlin.descriptors.VariableDescriptor
|
import org.jetbrains.kotlin.descriptors.VariableDescriptor
|
||||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||||
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny
|
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny
|
||||||
|
import org.jetbrains.kotlin.idea.core.ShortenReferences
|
||||||
import org.jetbrains.kotlin.idea.core.replaced
|
import org.jetbrains.kotlin.idea.core.replaced
|
||||||
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers
|
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers
|
||||||
import org.jetbrains.kotlin.idea.core.ShortenReferences
|
|
||||||
import org.jetbrains.kotlin.psi.KtFile
|
import org.jetbrains.kotlin.psi.KtFile
|
||||||
import org.jetbrains.kotlin.psi.KtPropertyAccessor
|
import org.jetbrains.kotlin.psi.KtPropertyAccessor
|
||||||
import org.jetbrains.kotlin.psi.KtPsiFactory
|
import org.jetbrains.kotlin.psi.KtPsiFactory
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType
|
import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
|
import org.jetbrains.kotlin.types.isError
|
||||||
|
|
||||||
class ChangeAccessorTypeFix(element: KtPropertyAccessor) : KotlinQuickFixAction<KtPropertyAccessor>(element) {
|
class ChangeAccessorTypeFix(element: KtPropertyAccessor) : KotlinQuickFixAction<KtPropertyAccessor>(element) {
|
||||||
private fun getType(): KotlinType? {
|
private fun getType(): KotlinType? =
|
||||||
val type = (element!!.property.resolveToDescriptorIfAny() as? VariableDescriptor)?.type ?: return null
|
(element!!.property.resolveToDescriptorIfAny() as? VariableDescriptor)?.type?.takeUnless(KotlinType::isError)
|
||||||
if (type.isError) return null
|
|
||||||
return type
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun isAvailable(project: Project, editor: Editor?, file: PsiFile) = super.isAvailable(project, editor, file) && getType() != null
|
override fun isAvailable(project: Project, editor: Editor?, file: PsiFile) = super.isAvailable(project, editor, file) && getType() != null
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import org.jetbrains.kotlin.idea.core.quickfix.QuickFixUtil;
|
|||||||
import org.jetbrains.kotlin.idea.intentions.SpecifyTypeExplicitlyIntention;
|
import org.jetbrains.kotlin.idea.intentions.SpecifyTypeExplicitlyIntention;
|
||||||
import org.jetbrains.kotlin.psi.*;
|
import org.jetbrains.kotlin.psi.*;
|
||||||
import org.jetbrains.kotlin.types.KotlinType;
|
import org.jetbrains.kotlin.types.KotlinType;
|
||||||
|
import org.jetbrains.kotlin.types.KotlinTypeKt;
|
||||||
|
|
||||||
public class RemovePartsFromPropertyFix extends KotlinQuickFixAction<KtProperty> {
|
public class RemovePartsFromPropertyFix extends KotlinQuickFixAction<KtProperty> {
|
||||||
private final boolean removeInitializer;
|
private final boolean removeInitializer;
|
||||||
@@ -88,7 +89,7 @@ public class RemovePartsFromPropertyFix extends KotlinQuickFixAction<KtProperty>
|
|||||||
if (!super.isAvailable(project, editor, file)) return false;
|
if (!super.isAvailable(project, editor, file)) return false;
|
||||||
|
|
||||||
KotlinType type = QuickFixUtil.getDeclarationReturnType(getElement());
|
KotlinType type = QuickFixUtil.getDeclarationReturnType(getElement());
|
||||||
return type != null && !type.isError();
|
return type != null && !KotlinTypeKt.isError(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import org.jetbrains.kotlin.idea.intentions.SpecifyTypeExplicitlyIntention
|
|||||||
import org.jetbrains.kotlin.psi.KtCallableDeclaration
|
import org.jetbrains.kotlin.psi.KtCallableDeclaration
|
||||||
import org.jetbrains.kotlin.psi.KtNamedFunction
|
import org.jetbrains.kotlin.psi.KtNamedFunction
|
||||||
import org.jetbrains.kotlin.psi.KtProperty
|
import org.jetbrains.kotlin.psi.KtProperty
|
||||||
|
import org.jetbrains.kotlin.types.isError
|
||||||
|
|
||||||
class SpecifyTypeExplicitlyFix : PsiElementBaseIntentionAction() {
|
class SpecifyTypeExplicitlyFix : PsiElementBaseIntentionAction() {
|
||||||
override fun getFamilyName() = "Specify type explicitly"
|
override fun getFamilyName() = "Specify type explicitly"
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ import org.jetbrains.kotlin.resolve.BindingContext
|
|||||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
import org.jetbrains.kotlin.types.TypeConstructorSubstitution
|
import org.jetbrains.kotlin.types.TypeConstructorSubstitution
|
||||||
|
import org.jetbrains.kotlin.types.isError
|
||||||
import org.jetbrains.kotlin.types.typeUtil.isSubtypeOf
|
import org.jetbrains.kotlin.types.typeUtil.isSubtypeOf
|
||||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|||||||
+1
@@ -25,6 +25,7 @@ import org.jetbrains.kotlin.idea.quickfix.createFromUsage.callableBuilder.Parame
|
|||||||
import org.jetbrains.kotlin.idea.quickfix.createFromUsage.callableBuilder.TypeInfo
|
import org.jetbrains.kotlin.idea.quickfix.createFromUsage.callableBuilder.TypeInfo
|
||||||
import org.jetbrains.kotlin.psi.KtCallExpression
|
import org.jetbrains.kotlin.psi.KtCallExpression
|
||||||
import org.jetbrains.kotlin.types.Variance
|
import org.jetbrains.kotlin.types.Variance
|
||||||
|
import org.jetbrains.kotlin.types.isError
|
||||||
import org.jetbrains.kotlin.util.OperatorNameConventions
|
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||||
|
|
||||||
object CreateInvokeFunctionActionFactory : CreateCallableMemberFromUsageFactory<KtCallExpression>() {
|
object CreateInvokeFunctionActionFactory : CreateCallableMemberFromUsageFactory<KtCallExpression>() {
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
|
|||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||||
import org.jetbrains.kotlin.resolve.jvm.annotations.findJvmOverloadsAnnotation
|
import org.jetbrains.kotlin.resolve.jvm.annotations.findJvmOverloadsAnnotation
|
||||||
import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform
|
import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform
|
||||||
|
import org.jetbrains.kotlin.types.isError
|
||||||
import org.jetbrains.kotlin.types.typeUtil.isUnit
|
import org.jetbrains.kotlin.types.typeUtil.isUnit
|
||||||
import org.jetbrains.kotlin.utils.keysToMap
|
import org.jetbrains.kotlin.utils.keysToMap
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
|
|||||||
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
|
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
|
||||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ImplicitReceiver
|
import org.jetbrains.kotlin.resolve.scopes.receivers.ImplicitReceiver
|
||||||
|
import org.jetbrains.kotlin.types.isError
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class KotlinParameterInfo @JvmOverloads constructor (
|
class KotlinParameterInfo @JvmOverloads constructor (
|
||||||
|
|||||||
+1
-1
@@ -53,10 +53,10 @@ import org.jetbrains.kotlin.idea.refactoring.changeSignature.*
|
|||||||
import org.jetbrains.kotlin.idea.refactoring.changeSignature.KotlinMethodDescriptor.Kind
|
import org.jetbrains.kotlin.idea.refactoring.changeSignature.KotlinMethodDescriptor.Kind
|
||||||
import org.jetbrains.kotlin.idea.refactoring.validateElement
|
import org.jetbrains.kotlin.idea.refactoring.validateElement
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.parents
|
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.parentsWithSelf
|
import org.jetbrains.kotlin.psi.psiUtil.parentsWithSelf
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext
|
import org.jetbrains.kotlin.resolve.BindingContext
|
||||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||||
|
import org.jetbrains.kotlin.types.isError
|
||||||
import java.awt.BorderLayout
|
import java.awt.BorderLayout
|
||||||
import java.awt.Font
|
import java.awt.Font
|
||||||
import java.awt.Toolkit
|
import java.awt.Toolkit
|
||||||
|
|||||||
+1
-1
@@ -35,7 +35,6 @@ import org.jetbrains.kotlin.idea.refactoring.introduce.extractionEngine.OutputVa
|
|||||||
import org.jetbrains.kotlin.idea.refactoring.isMultiLine
|
import org.jetbrains.kotlin.idea.refactoring.isMultiLine
|
||||||
import org.jetbrains.kotlin.idea.refactoring.removeTemplateEntryBracesIfPossible
|
import org.jetbrains.kotlin.idea.refactoring.removeTemplateEntryBracesIfPossible
|
||||||
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers
|
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers
|
||||||
import org.jetbrains.kotlin.idea.core.ShortenReferences
|
|
||||||
import org.jetbrains.kotlin.idea.util.psi.patternMatching.*
|
import org.jetbrains.kotlin.idea.util.psi.patternMatching.*
|
||||||
import org.jetbrains.kotlin.idea.util.psi.patternMatching.UnificationResult.StronglyMatched
|
import org.jetbrains.kotlin.idea.util.psi.patternMatching.UnificationResult.StronglyMatched
|
||||||
import org.jetbrains.kotlin.idea.util.psi.patternMatching.UnificationResult.WeaklyMatched
|
import org.jetbrains.kotlin.idea.util.psi.patternMatching.UnificationResult.WeaklyMatched
|
||||||
@@ -49,6 +48,7 @@ import org.jetbrains.kotlin.renderer.DescriptorRenderer
|
|||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||||
import org.jetbrains.kotlin.resolve.calls.callUtil.getCalleeExpressionIfAny
|
import org.jetbrains.kotlin.resolve.calls.callUtil.getCalleeExpressionIfAny
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
|
import org.jetbrains.kotlin.types.isError
|
||||||
import org.jetbrains.kotlin.types.isFlexible
|
import org.jetbrains.kotlin.types.isFlexible
|
||||||
import org.jetbrains.kotlin.types.typeUtil.builtIns
|
import org.jetbrains.kotlin.types.typeUtil.builtIns
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ import org.jetbrains.kotlin.resolve.DescriptorUtils
|
|||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
|
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
|
||||||
import org.jetbrains.kotlin.types.TypeSubstitutor
|
import org.jetbrains.kotlin.types.TypeSubstitutor
|
||||||
import org.jetbrains.kotlin.types.Variance
|
import org.jetbrains.kotlin.types.Variance
|
||||||
|
import org.jetbrains.kotlin.types.isError
|
||||||
import org.jetbrains.kotlin.types.typeUtil.isUnit
|
import org.jetbrains.kotlin.types.typeUtil.isUnit
|
||||||
|
|
||||||
fun KtProperty.mustBeAbstractInInterface() =
|
fun KtProperty.mustBeAbstractInInterface() =
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import org.jetbrains.kotlin.psi.*
|
|||||||
import org.jetbrains.kotlin.resolve.BindingContext
|
import org.jetbrains.kotlin.resolve.BindingContext
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
import org.jetbrains.kotlin.types.Variance
|
import org.jetbrains.kotlin.types.Variance
|
||||||
|
import org.jetbrains.kotlin.types.isError
|
||||||
|
|
||||||
internal fun convertKtType(
|
internal fun convertKtType(
|
||||||
reference: KtTypeReference?,
|
reference: KtTypeReference?,
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
|
|||||||
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
|
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
|
||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
|
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
|
import org.jetbrains.kotlin.types.isError
|
||||||
import org.jetbrains.uast.*
|
import org.jetbrains.uast.*
|
||||||
import java.lang.ref.WeakReference
|
import java.lang.ref.WeakReference
|
||||||
import java.text.StringCharacterIterator
|
import java.text.StringCharacterIterator
|
||||||
|
|||||||
Reference in New Issue
Block a user