diff --git a/compiler/backend-common/src/org/jetbrains/kotlin/backend/common/CodegenUtil.java b/compiler/backend-common/src/org/jetbrains/kotlin/backend/common/CodegenUtil.java index 95125017cf9..c3f3f16c3a8 100644 --- a/compiler/backend-common/src/org/jetbrains/kotlin/backend/common/CodegenUtil.java +++ b/compiler/backend-common/src/org/jetbrains/kotlin/backend/common/CodegenUtil.java @@ -32,7 +32,7 @@ import org.jetbrains.kotlin.resolve.calls.callResolverUtil.CallResolverUtilKt; import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilKt; import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall; import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.TypeUtils; import org.jetbrains.kotlin.types.checker.KotlinTypeChecker; @@ -141,7 +141,7 @@ public class CodegenUtil { @NotNull public static ClassDescriptor getSuperClassByDelegationSpecifier(@NotNull KtDelegationSpecifier specifier, @NotNull BindingContext bindingContext) { - KtType superType = bindingContext.get(BindingContext.TYPE, specifier.getTypeReference()); + KotlinType superType = bindingContext.get(BindingContext.TYPE, specifier.getTypeReference()); assert superType != null : "superType should not be null: " + specifier.getText(); ClassDescriptor superClassDescriptor = (ClassDescriptor) superType.getConstructor().getDeclarationDescriptor(); @@ -164,13 +164,13 @@ public class CodegenUtil { return true; } - private static boolean rawTypeMatches(KtType type, ClassifierDescriptor classifier) { + private static boolean rawTypeMatches(KotlinType type, ClassifierDescriptor classifier) { return type.getConstructor().equals(classifier.getTypeConstructor()); } public static boolean isEnumValueOfMethod(@NotNull FunctionDescriptor functionDescriptor) { List methodTypeParameters = functionDescriptor.getValueParameters(); - KtType nullableString = TypeUtils.makeNullable(DescriptorUtilsKt.getBuiltIns(functionDescriptor).getStringType()); + KotlinType nullableString = TypeUtils.makeNullable(DescriptorUtilsKt.getBuiltIns(functionDescriptor).getStringType()); return DescriptorUtils.ENUM_VALUE_OF.equals(functionDescriptor.getName()) && methodTypeParameters.size() == 1 && KotlinTypeChecker.DEFAULT.isSubtypeOf(methodTypeParameters.get(0).getType(), nullableString); diff --git a/compiler/backend-common/src/org/jetbrains/kotlin/backend/common/CodegenUtilKt.kt b/compiler/backend-common/src/org/jetbrains/kotlin/backend/common/CodegenUtilKt.kt index e80b74e0c1d..86d71b543eb 100644 --- a/compiler/backend-common/src/org/jetbrains/kotlin/backend/common/CodegenUtilKt.kt +++ b/compiler/backend-common/src/org/jetbrains/kotlin/backend/common/CodegenUtilKt.kt @@ -22,7 +22,7 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.incremental.components.NoLookupLocation import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.MemberComparator -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.isDynamic import org.jetbrains.kotlin.utils.keysToMapExceptNulls import java.util.Comparator @@ -38,7 +38,7 @@ public object CodegenUtilKt { public fun getDelegates( descriptor: ClassDescriptor, toTrait: ClassDescriptor, - delegateExpressionType: KtType? = null + delegateExpressionType: KotlinType? = null ): Map { if (delegateExpressionType?.isDynamic() ?: false) return mapOf(); diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/AccessorForConstructorDescriptor.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/AccessorForConstructorDescriptor.kt index eac7f44874b..95fd072455b 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/AccessorForConstructorDescriptor.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/AccessorForConstructorDescriptor.kt @@ -20,7 +20,7 @@ import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.psi.KtSuperExpression import org.jetbrains.kotlin.resolve.DescriptorUtils -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType public class AccessorForConstructorDescriptor( private val calleeDescriptor: ConstructorDescriptor, @@ -35,7 +35,7 @@ public class AccessorForConstructorDescriptor( override fun isPrimary(): Boolean = false - override fun getReturnType(): KtType = super.getReturnType()!! + override fun getReturnType(): KotlinType = super.getReturnType()!! override fun getSuperCallExpression(): KtSuperExpression? = superCallExpression diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/AccessorForPropertyBackingFieldInOuterClass.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/AccessorForPropertyBackingFieldInOuterClass.java index 4b1baa5746e..daf898032d4 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/AccessorForPropertyBackingFieldInOuterClass.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/AccessorForPropertyBackingFieldInOuterClass.java @@ -20,13 +20,13 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.descriptors.DeclarationDescriptor; import org.jetbrains.kotlin.descriptors.PropertyDescriptor; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; public class AccessorForPropertyBackingFieldInOuterClass extends AccessorForPropertyDescriptor { public AccessorForPropertyBackingFieldInOuterClass( @NotNull PropertyDescriptor property, @NotNull DeclarationDescriptor containingDeclaration, - @Nullable KtType delegationType, + @Nullable KotlinType delegationType, @NotNull String nameSuffix ) { super(property, delegationType != null ? delegationType : property.getType(), null, null, containingDeclaration, null, nameSuffix); diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/AccessorForPropertyDescriptor.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/AccessorForPropertyDescriptor.java index 8e0507d4e59..d7df0fdc654 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/AccessorForPropertyDescriptor.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/AccessorForPropertyDescriptor.java @@ -27,7 +27,7 @@ import org.jetbrains.kotlin.descriptors.impl.TypeParameterDescriptorImpl; import org.jetbrains.kotlin.name.Name; import org.jetbrains.kotlin.psi.KtSuperExpression; import org.jetbrains.kotlin.resolve.DescriptorUtils; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import java.util.Collections; @@ -48,8 +48,8 @@ public class AccessorForPropertyDescriptor extends PropertyDescriptorImpl implem protected AccessorForPropertyDescriptor( @NotNull PropertyDescriptor original, - @NotNull KtType propertyType, - @Nullable KtType receiverType, + @NotNull KotlinType propertyType, + @Nullable KotlinType receiverType, @Nullable ReceiverParameterDescriptor dispatchReceiverParameter, @NotNull DeclarationDescriptor containingDeclaration, @Nullable KtSuperExpression superCallExpression, diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/AnnotationCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/AnnotationCodegen.java index 4c8b7bd5b5b..316daa11035 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/AnnotationCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/AnnotationCodegen.java @@ -157,7 +157,7 @@ public abstract class AnnotationCodegen { return false; } - private void generateNullabilityAnnotation(@Nullable KtType type, @NotNull Set annotationDescriptorsAlreadyPresent) { + private void generateNullabilityAnnotation(@Nullable KotlinType type, @NotNull Set annotationDescriptorsAlreadyPresent) { if (type == null) return; if (isBareTypeParameterWithNullableUpperBound(type)) { @@ -253,12 +253,12 @@ public abstract class AnnotationCodegen { } } - private static boolean isBareTypeParameterWithNullableUpperBound(@NotNull KtType type) { + private static boolean isBareTypeParameterWithNullableUpperBound(@NotNull KotlinType type) { ClassifierDescriptor classifier = type.getConstructor().getDeclarationDescriptor(); return !type.isMarkedNullable() && classifier instanceof TypeParameterDescriptor && TypeUtils.hasNullableSuperType(type); } - public void generateAnnotationDefaultValue(@NotNull ConstantValue value, @NotNull KtType expectedType) { + public void generateAnnotationDefaultValue(@NotNull ConstantValue value, @NotNull KotlinType expectedType) { AnnotationVisitor visitor = visitAnnotation(null, false); // Parameters are unimportant genCompileTimeValue(null, value, visitor); visitor.visitEnd(); @@ -418,7 +418,7 @@ public abstract class AnnotationCodegen { for (ConstantValue value : values) { if (value instanceof EnumValue) { ClassDescriptor enumEntry = ((EnumValue) value).getValue(); - KtType classObjectType = DescriptorUtilsKt.getClassObjectType(enumEntry); + KotlinType classObjectType = DescriptorUtilsKt.getClassObjectType(enumEntry); if (classObjectType != null) { if ("java/lang/annotation/ElementType".equals(typeMapper.mapType(classObjectType).getInternalName())) { result.add(ElementType.valueOf(enumEntry.getName().asString())); @@ -446,7 +446,7 @@ public abstract class AnnotationCodegen { ConstantValue compileTimeConstant = valueArguments.iterator().next(); if (compileTimeConstant instanceof EnumValue) { ClassDescriptor enumEntry = ((EnumValue) compileTimeConstant).getValue(); - KtType classObjectType = DescriptorUtilsKt.getClassObjectType(enumEntry); + KotlinType classObjectType = DescriptorUtilsKt.getClassObjectType(enumEntry); if (classObjectType != null) { if ("java/lang/annotation/RetentionPolicy".equals(typeMapper.mapType(classObjectType).getInternalName())) { return RetentionPolicy.valueOf(enumEntry.getName().asString()); diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/AsmUtil.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/AsmUtil.java index a6954c2eccf..bab08db40f4 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/AsmUtil.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/AsmUtil.java @@ -52,7 +52,7 @@ import org.jetbrains.kotlin.serialization.DescriptorSerializer; import org.jetbrains.kotlin.serialization.jvm.BitEncoding; import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor; import org.jetbrains.kotlin.types.FlexibleTypesKt; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.org.objectweb.asm.*; import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter; import org.jetbrains.org.objectweb.asm.commons.Method; @@ -432,7 +432,7 @@ public class AsmUtil { allFields.add(Pair.create(CAPTURED_THIS_FIELD, typeMapper.mapType(captureThis))); } - KtType captureReceiverType = closure.getCaptureReceiverType(); + KotlinType captureReceiverType = closure.getCaptureReceiverType(); if (captureReceiverType != null) { allFields.add(Pair.create(CAPTURED_RECEIVER_FIELD, typeMapper.mapType(captureReceiverType))); } @@ -638,7 +638,7 @@ public class AsmUtil { @NotNull CallableDescriptor parameter, @NotNull String name ) { - KtType type = parameter.getReturnType(); + KotlinType type = parameter.getReturnType(); if (type == null || isNullableType(type)) return; int index = frameMap.getIndex(parameter); @@ -672,7 +672,7 @@ public class AsmUtil { if (!isDeclaredInJava(descriptor)) return false; - KtType type = descriptor.getReturnType(); + KotlinType type = descriptor.getReturnType(); if (type == null || isNullableType(FlexibleTypesKt.lowerIfFlexible(type))) return false; Type asmType = state.getTypeMapper().mapReturnType(descriptor); diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ClosureCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ClosureCodegen.java index a2f8b3e8f06..91c9490946c 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ClosureCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ClosureCodegen.java @@ -43,7 +43,7 @@ import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOriginKt; import org.jetbrains.kotlin.resolve.scopes.KtScope; import org.jetbrains.kotlin.serialization.DescriptorSerializer; import org.jetbrains.kotlin.serialization.ProtoBuf; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.util.OperatorNameConventions; import org.jetbrains.kotlin.utils.FunctionsKt; import org.jetbrains.org.objectweb.asm.AnnotationVisitor; @@ -70,8 +70,8 @@ public class ClosureCodegen extends MemberCodegen { private final FunctionDescriptor funDescriptor; private final ClassDescriptor classDescriptor; private final SamType samType; - private final KtType superClassType; - private final List superInterfaceTypes; + private final KotlinType superClassType; + private final List superInterfaceTypes; private final FunctionDescriptor functionReferenceTarget; private final FunctionGenerationStrategy strategy; private final CalculatedClosure closure; @@ -100,10 +100,10 @@ public class ClosureCodegen extends MemberCodegen { this.strategy = strategy; if (samType == null) { - this.superInterfaceTypes = new ArrayList(); + this.superInterfaceTypes = new ArrayList(); - KtType superClassType = null; - for (KtType supertype : classDescriptor.getTypeConstructor().getSupertypes()) { + KotlinType superClassType = null; + for (KotlinType supertype : classDescriptor.getTypeConstructor().getSupertypes()) { ClassifierDescriptor classifier = supertype.getConstructor().getDeclarationDescriptor(); if (DescriptorUtils.isInterface(classifier)) { superInterfaceTypes.add(supertype); @@ -141,7 +141,7 @@ public class ClosureCodegen extends MemberCodegen { sw.writeSuperclassEnd(); String[] superInterfaceAsmTypes = new String[superInterfaceTypes.size()]; for (int i = 0; i < superInterfaceTypes.size(); i++) { - KtType superInterfaceType = superInterfaceTypes.get(i); + KotlinType superInterfaceType = superInterfaceTypes.get(i); sw.writeInterface(); superInterfaceAsmTypes[i] = typeMapper.mapSupertype(superInterfaceType, sw).getInternalName(); sw.writeInterfaceEnd(); @@ -428,7 +428,7 @@ public class ClosureCodegen extends MemberCodegen { Type type = typeMapper.mapType(captureThis); args.add(FieldInfo.createForHiddenField(ownerType, type, CAPTURED_THIS_FIELD)); } - KtType captureReceiverType = closure.getCaptureReceiverType(); + KotlinType captureReceiverType = closure.getCaptureReceiverType(); if (captureReceiverType != null) { args.add(FieldInfo.createForHiddenField(ownerType, typeMapper.mapType(captureReceiverType), CAPTURED_RECEIVER_FIELD)); } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/CollectionStubMethodGenerator.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/CollectionStubMethodGenerator.kt index 645840b22a4..8fdaa4bd1f5 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/CollectionStubMethodGenerator.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/CollectionStubMethodGenerator.kt @@ -187,7 +187,7 @@ class CollectionStubMethodGenerator( return ourSuperCollectionClasses.filter { klass -> klass.readOnlyClass !in redundantClasses } } - private fun Collection.classes(): Collection = + private fun Collection.classes(): Collection = this.map { it.getConstructor().getDeclarationDescriptor() as ClassDescriptor } private fun findFakeOverridesForMethodsFromMutableCollection( @@ -213,7 +213,7 @@ class CollectionStubMethodGenerator( return result } - private fun Collection.findMostSpecificTypeForClass(klass: ClassDescriptor): KtType { + private fun Collection.findMostSpecificTypeForClass(klass: ClassDescriptor): KotlinType { val types = this.filter { it.getConstructor().getDeclarationDescriptor() == klass } if (types.isEmpty()) error("No supertype of $klass in $this") if (types.size() == 1) return types.first() @@ -239,8 +239,8 @@ class CollectionStubMethodGenerator( return this.getOverriddenDescriptors().firstOrNull { it.getContainingDeclaration() == classDescriptor } } - private fun newType(classDescriptor: ClassDescriptor, typeArguments: List): KtType { - return KtTypeImpl.create(Annotations.EMPTY, classDescriptor, false, typeArguments) + private fun newType(classDescriptor: ClassDescriptor, typeArguments: List): KotlinType { + return KotlinTypeImpl.create(Annotations.EMPTY, classDescriptor, false, typeArguments) } private fun FunctionDescriptor.signature(): JvmMethodSignature = typeMapper.mapSignature(this) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java index 6fab26b15f3..7f2c4f3e471 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java @@ -80,7 +80,7 @@ import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterSignature import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature; import org.jetbrains.kotlin.resolve.scopes.receivers.*; import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.TypeProjection; import org.jetbrains.kotlin.types.TypeUtils; import org.jetbrains.kotlin.types.checker.KotlinTypeChecker; @@ -225,7 +225,7 @@ public class ExpressionCodegen extends KtVisitor impleme } private static void addReifiedParametersFromSignature(@NotNull MemberCodegen member, @NotNull ClassDescriptor descriptor) { - for (KtType type : descriptor.getTypeConstructor().getSupertypes()) { + for (KotlinType type : descriptor.getTypeConstructor().getSupertypes()) { for (TypeProjection supertypeArgument : type.getArguments()) { TypeParameterDescriptor parameterDescriptor = TypeUtils.getTypeParameterDescriptorOrNull(supertypeArgument.getType()); if (parameterDescriptor != null && parameterDescriptor.isReified()) { @@ -377,18 +377,18 @@ public class ExpressionCodegen extends KtVisitor impleme } @NotNull - private Type asmType(@NotNull KtType type) { + private Type asmType(@NotNull KotlinType type) { return typeMapper.mapType(type); } @NotNull public Type expressionType(@Nullable KtExpression expression) { - KtType type = expressionJetType(expression); + KotlinType type = expressionJetType(expression); return type == null ? Type.VOID_TYPE : asmType(type); } @Nullable - public KtType expressionJetType(@Nullable KtExpression expression) { + public KotlinType expressionJetType(@Nullable KtExpression expression) { return expression != null ? bindingContext.getType(expression) : null; } @@ -543,7 +543,7 @@ public class ExpressionCodegen extends KtVisitor impleme KtExpression loopRange = forExpression.getLoopRange(); assert loopRange != null; - KtType loopRangeType = bindingContext.getType(loopRange); + KotlinType loopRangeType = bindingContext.getType(loopRange); assert loopRangeType != null; Type asmLoopRangeType = asmType(loopRangeType); if (asmLoopRangeType.getSort() == Type.ARRAY) { @@ -604,7 +604,7 @@ public class ExpressionCodegen extends KtVisitor impleme private final Label bodyEnd = new Label(); private final List leaveVariableTasks = Lists.newArrayList(); - protected final KtType elementType; + protected final KotlinType elementType; protected final Type asmElementType; protected int loopParameterVar; @@ -616,7 +616,7 @@ public class ExpressionCodegen extends KtVisitor impleme } @NotNull - private KtType getElementType(KtForExpression forExpression) { + private KotlinType getElementType(KtForExpression forExpression) { KtExpression loopRange = forExpression.getLoopRange(); assert loopRange != null; ResolvedCall nextCall = getNotNull(bindingContext, @@ -765,7 +765,7 @@ public class ExpressionCodegen extends KtVisitor impleme LOOP_RANGE_ITERATOR_RESOLVED_CALL, loopRange, "No .iterator() function " + DiagnosticUtils.atLocation(loopRange)); - KtType iteratorType = iteratorCall.getResultingDescriptor().getReturnType(); + KotlinType iteratorType = iteratorCall.getResultingDescriptor().getReturnType(); assert iteratorType != null; this.asmTypeForIterator = asmType(iteratorType); @@ -802,7 +802,7 @@ public class ExpressionCodegen extends KtVisitor impleme result.put(result.type, v); FunctionDescriptor hasNext = hasNextCall.getResultingDescriptor(); - KtType type = hasNext.getReturnType(); + KotlinType type = hasNext.getReturnType(); assert type != null && KotlinTypeChecker.DEFAULT.isSubtypeOf(type, DescriptorUtilsKt.getBuiltIns(hasNext).getBooleanType()); Type asmType = asmType(type); @@ -827,7 +827,7 @@ public class ExpressionCodegen extends KtVisitor impleme private class ForInArrayLoopGenerator extends AbstractForLoopGenerator { private int indexVar; private int arrayVar; - private final KtType loopRangeType; + private final KotlinType loopRangeType; private ForInArrayLoopGenerator(@NotNull KtForExpression forExpression) { super(forExpression); @@ -1042,7 +1042,7 @@ public class ExpressionCodegen extends KtVisitor impleme @Override protected void storeRangeStartAndEnd() { - KtType loopRangeType = bindingContext.getType(forExpression.getLoopRange()); + KotlinType loopRangeType = bindingContext.getType(forExpression.getLoopRange()); assert loopRangeType != null; Type asmLoopRangeType = asmType(loopRangeType); gen(forExpression.getLoopRange(), asmLoopRangeType); @@ -1074,7 +1074,7 @@ public class ExpressionCodegen extends KtVisitor impleme incrementVar = createLoopTempVariable(asmElementType); - KtType loopRangeType = bindingContext.getType(forExpression.getLoopRange()); + KotlinType loopRangeType = bindingContext.getType(forExpression.getLoopRange()); assert loopRangeType != null; Type asmLoopRangeType = asmType(loopRangeType); @@ -1308,7 +1308,7 @@ public class ExpressionCodegen extends KtVisitor impleme if (compileTimeValue == null) { return null; } - KtType expectedType = bindingContext.getType(expression); + KotlinType expectedType = bindingContext.getType(expression); return compileTimeValue.toConstantValue(expectedType); } @@ -1515,7 +1515,7 @@ public class ExpressionCodegen extends KtVisitor impleme } } - KtType captureReceiver = closure.getCaptureReceiverType(); + KotlinType captureReceiver = closure.getCaptureReceiverType(); if (captureReceiver != null) { Type asmType = typeMapper.mapType(captureReceiver); StackValue.Local capturedReceiver = StackValue.local(AsmUtil.getReceiverIndex(context, context.getContextDescriptor()), asmType); @@ -1998,7 +1998,7 @@ public class ExpressionCodegen extends KtVisitor impleme Collection codegenExtensions = ExpressionCodegenExtension.Companion.getInstances(state.getProject()); if (!codegenExtensions.isEmpty() && resolvedCall != null) { ExpressionCodegenExtension.Context context = new ExpressionCodegenExtension.Context(typeMapper, v); - KtType returnType = propertyDescriptor.getReturnType(); + KotlinType returnType = propertyDescriptor.getReturnType(); for (ExpressionCodegenExtension extension : codegenExtensions) { if (returnType != null) { StackValue value = extension.applyProperty(receiver, resolvedCall, context); @@ -2103,7 +2103,7 @@ public class ExpressionCodegen extends KtVisitor impleme private StackValue stackValueForLocal(DeclarationDescriptor descriptor, int index) { if (descriptor instanceof VariableDescriptor) { Type sharedVarType = typeMapper.getSharedVarType(descriptor); - KtType outType = ((VariableDescriptor) descriptor).getType(); + KotlinType outType = ((VariableDescriptor) descriptor).getType(); if (sharedVarType != null) { return StackValue.shared(index, asmType(outType)); } @@ -2126,7 +2126,7 @@ public class ExpressionCodegen extends KtVisitor impleme } @Nullable - private static KtType getPropertyDelegateType(@NotNull PropertyDescriptor descriptor, @NotNull BindingContext bindingContext) { + private static KotlinType getPropertyDelegateType(@NotNull PropertyDescriptor descriptor, @NotNull BindingContext bindingContext) { PropertyGetterDescriptor getter = descriptor.getGetter(); if (getter != null) { Call call = bindingContext.get(DELEGATED_PROPERTY_CALL, getter); @@ -2164,7 +2164,7 @@ public class ExpressionCodegen extends KtVisitor impleme boolean isSuper = superExpression != null; boolean isExtensionProperty = propertyDescriptor.getExtensionReceiverParameter() != null; - KtType delegateType = getPropertyDelegateType(propertyDescriptor, bindingContext); + KotlinType delegateType = getPropertyDelegateType(propertyDescriptor, bindingContext); boolean isDelegatedProperty = delegateType != null; CallableMethod callableGetter = null; @@ -2504,13 +2504,13 @@ public class ExpressionCodegen extends KtVisitor impleme @NotNull private CallGenerator getOrCreateCallGenerator(@NotNull ResolvedCall resolvedCall) { - Map typeArguments = resolvedCall.getTypeArguments(); + Map typeArguments = resolvedCall.getTypeArguments(); ReifiedTypeParameterMappings mappings = new ReifiedTypeParameterMappings(); - for (Map.Entry entry : typeArguments.entrySet()) { + for (Map.Entry entry : typeArguments.entrySet()) { TypeParameterDescriptor key = entry.getKey(); if (!key.isReified()) continue; - KtType type = entry.getValue(); + KotlinType type = entry.getValue(); TypeParameterDescriptor parameterDescriptor = TypeUtils.getTypeParameterDescriptorOrNull(type); if (parameterDescriptor == null) { // type is not generic @@ -2667,7 +2667,7 @@ public class ExpressionCodegen extends KtVisitor impleme } - public void genVarargs(@NotNull VarargValueArgument valueArgument, @NotNull KtType outType) { + public void genVarargs(@NotNull VarargValueArgument valueArgument, @NotNull KotlinType outType) { Type type = asmType(outType); assert type.getSort() == Type.ARRAY; Type elementType = correctElementType(type); @@ -2761,7 +2761,7 @@ public class ExpressionCodegen extends KtVisitor impleme @Override public StackValue visitClassLiteralExpression(@NotNull KtClassLiteralExpression expression, StackValue data) { - KtType type = bindingContext.getType(expression); + KotlinType type = bindingContext.getType(expression); assert type != null; assert state.getReflectionTypes().getKClass().getTypeConstructor().equals(type.getConstructor()) @@ -2813,7 +2813,7 @@ public class ExpressionCodegen extends KtVisitor impleme } @NotNull - public static StackValue generateClassLiteralReference(@NotNull final JetTypeMapper typeMapper, @NotNull final KtType type) { + public static StackValue generateClassLiteralReference(@NotNull final JetTypeMapper typeMapper, @NotNull final KotlinType type) { return StackValue.operation(K_CLASS_TYPE, new Function1() { @Override public Unit invoke(InstructionAdapter v) { @@ -3312,7 +3312,7 @@ public class ExpressionCodegen extends KtVisitor impleme KtExpression initializer = multiDeclaration.getInitializer(); if (initializer == null) return StackValue.none(); - KtType initializerType = bindingContext.getType(initializer); + KotlinType initializerType = bindingContext.getType(initializer); assert initializerType != null; Type initializerAsmType = asmType(initializerType); @@ -3427,7 +3427,7 @@ public class ExpressionCodegen extends KtVisitor impleme }); } - public StackValue generateNewArray(@NotNull KtCallExpression expression, @NotNull final KtType arrayType) { + public StackValue generateNewArray(@NotNull KtCallExpression expression, @NotNull final KotlinType arrayType) { assert expression.getValueArguments().size() == 1 : "Size argument expected"; final KtExpression sizeExpression = expression.getValueArguments().get(0).getArgumentExpression(); @@ -3443,9 +3443,9 @@ public class ExpressionCodegen extends KtVisitor impleme }); } - public void newArrayInstruction(@NotNull KtType arrayType) { + public void newArrayInstruction(@NotNull KotlinType arrayType) { if (KotlinBuiltIns.isArray(arrayType)) { - KtType elementJetType = arrayType.getArguments().get(0).getType(); + KotlinType elementJetType = arrayType.getArguments().get(0).getType(); putReifierMarkerIfTypeIsReifiedParameter( elementJetType, ReifiedTypeInliner.NEW_ARRAY_MARKER_METHOD_NAME @@ -3461,7 +3461,7 @@ public class ExpressionCodegen extends KtVisitor impleme @Override public StackValue visitArrayAccessExpression(@NotNull KtArrayAccessExpression expression, StackValue receiver) { KtExpression array = expression.getArrayExpression(); - KtType type = array != null ? bindingContext.getType(array) : null; + KotlinType type = array != null ? bindingContext.getType(array) : null; Type arrayType = expressionType(array); List indices = expression.getIndexExpressions(); FunctionDescriptor operationDescriptor = (FunctionDescriptor) bindingContext.get(REFERENCE_TARGET, expression); @@ -3472,7 +3472,7 @@ public class ExpressionCodegen extends KtVisitor impleme assert type != null; Type elementType; if (KotlinBuiltIns.isArray(type)) { - KtType jetElementType = type.getArguments().get(0).getType(); + KotlinType jetElementType = type.getArguments().get(0).getType(); elementType = boxType(asmType(jetElementType)); } else { @@ -3564,7 +3564,7 @@ The "returned" value of try expression with no finally is either the last expres (or blocks). */ - KtType jetType = bindingContext.getType(expression); + KotlinType jetType = bindingContext.getType(expression); assert jetType != null; final Type expectedAsmType = isStatement ? Type.VOID_TYPE : asmType(jetType); @@ -3706,7 +3706,7 @@ The "returned" value of try expression with no finally is either the last expres KtExpression left = expression.getLeft(); final IElementType opToken = expression.getOperationReference().getReferencedNameElementType(); - final KtType rightType = bindingContext.get(TYPE, expression.getRight()); + final KotlinType rightType = bindingContext.get(TYPE, expression.getRight()); assert rightType != null; final StackValue value = genQualified(receiver, left); @@ -3756,7 +3756,7 @@ The "returned" value of try expression with no finally is either the last expres if (expressionToMatch != null) { Type subjectType = expressionToMatch.type; markStartLineNumber(patternExpression); - KtType condJetType = bindingContext.getType(patternExpression); + KotlinType condJetType = bindingContext.getType(patternExpression); Type condType; if (isNumberPrimitive(subjectType) || subjectType.getSort() == Type.BOOLEAN) { assert condJetType != null; @@ -3777,13 +3777,13 @@ The "returned" value of try expression with no finally is either the last expres } private StackValue generateIsCheck(StackValue expressionToMatch, KtTypeReference typeReference, boolean negated) { - KtType jetType = bindingContext.get(TYPE, typeReference); + KotlinType jetType = bindingContext.get(TYPE, typeReference); markStartLineNumber(typeReference); StackValue value = generateInstanceOf(expressionToMatch, jetType, false); return negated ? StackValue.not(value) : value; } - private StackValue generateInstanceOf(final StackValue expressionToGen, final KtType jetType, final boolean leaveExpressionOnStack) { + private StackValue generateInstanceOf(final StackValue expressionToGen, final KotlinType jetType, final boolean leaveExpressionOnStack) { return StackValue.operation(Type.BOOLEAN_TYPE, new Function1() { @Override public Unit invoke(InstructionAdapter v) { @@ -3812,14 +3812,14 @@ The "returned" value of try expression with no finally is either the last expres }); } - private void generateInstanceOfInstruction(@NotNull KtType jetType) { + private void generateInstanceOfInstruction(@NotNull KotlinType jetType) { Type type = boxType(asmType(jetType)); putReifierMarkerIfTypeIsReifiedParameter(jetType, ReifiedTypeInliner.INSTANCEOF_MARKER_METHOD_NAME); TypeIntrinsics.instanceOf(v, jetType, type); } @NotNull - private StackValue generateCheckCastInstruction(@NotNull KtType jetType, boolean safeAs) { + private StackValue generateCheckCastInstruction(@NotNull KotlinType jetType, boolean safeAs) { Type type = boxType(asmType(jetType)); putReifierMarkerIfTypeIsReifiedParameter(jetType, safeAs ? ReifiedTypeInliner.SAFE_CHECKCAST_MARKER_METHOD_NAME @@ -3828,7 +3828,7 @@ The "returned" value of try expression with no finally is either the last expres return StackValue.onStack(type); } - public void putReifierMarkerIfTypeIsReifiedParameter(@NotNull KtType type, @NotNull String markerMethodName) { + public void putReifierMarkerIfTypeIsReifiedParameter(@NotNull KotlinType type, @NotNull String markerMethodName) { TypeParameterDescriptor typeParameterDescriptor = TypeUtils.getTypeParameterDescriptorOrNull(type); if (typeParameterDescriptor != null && typeParameterDescriptor.isReified()) { if (typeParameterDescriptor.getContainingDeclaration() != context.getContextDescriptor()) { @@ -3962,7 +3962,7 @@ The "returned" value of try expression with no finally is either the last expres if (rangeExpression instanceof KtBinaryExpression) { KtBinaryExpression binaryExpression = (KtBinaryExpression) rangeExpression; if (binaryExpression.getOperationReference().getReferencedNameElementType() == KtTokens.RANGE) { - KtType jetType = bindingContext.getType(rangeExpression); + KotlinType jetType = bindingContext.getType(rangeExpression); assert jetType != null; DeclarationDescriptor descriptor = jetType.getConstructor().getDeclarationDescriptor(); return DescriptorUtilsKt.getBuiltIns(descriptor).getIntegralRanges().contains(descriptor); diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionCodegen.java index 6f3448f3fd2..4a6fef4ccfb 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionCodegen.java @@ -57,7 +57,7 @@ import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOriginKt; import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterKind; import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterSignature; import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.org.objectweb.asm.*; import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter; import org.jetbrains.org.objectweb.asm.commons.Method; @@ -887,7 +887,7 @@ public class FunctionCodegen { iv.load(1, OBJECT_TYPE); - KtType jetType = descriptor.getValueParameters().get(0).getType(); + KotlinType jetType = descriptor.getValueParameters().get(0).getType(); // TODO: reuse logic from ExpressionCodegen if (jetType.isMarkedNullable()) { diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ImplementationBodyCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ImplementationBodyCodegen.java index e8ca703bfbd..1bba7edee86 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ImplementationBodyCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ImplementationBodyCodegen.java @@ -66,7 +66,7 @@ import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue; import org.jetbrains.kotlin.resolve.scopes.receivers.ThisReceiver; import org.jetbrains.kotlin.serialization.DescriptorSerializer; import org.jetbrains.kotlin.serialization.ProtoBuf; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.checker.KotlinTypeChecker; import org.jetbrains.org.objectweb.asm.*; import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter; @@ -91,7 +91,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { private static final String ENUM_VALUES_FIELD_NAME = "$VALUES"; private Type superClassAsmType; @Nullable // null means java/lang/Object - private KtType superClassType; + private KotlinType superClassType; private final Type classAsmType; private final boolean isLocal; @@ -316,7 +316,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { LinkedHashSet superInterfaces = new LinkedHashSet(); Set kotlinMarkerInterfaces = new LinkedHashSet(); - for (KtType supertype : descriptor.getTypeConstructor().getSupertypes()) { + for (KotlinType supertype : descriptor.getTypeConstructor().getSupertypes()) { if (isJvmInterface(supertype.getConstructor().getDeclarationDescriptor())) { sw.writeInterface(); Type jvmInterfaceType = typeMapper.mapSupertype(supertype, sw); @@ -352,7 +352,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { return; } - for (KtType supertype : descriptor.getTypeConstructor().getSupertypes()) { + for (KotlinType supertype : descriptor.getTypeConstructor().getSupertypes()) { ClassifierDescriptor superClass = supertype.getConstructor().getDeclarationDescriptor(); if (superClass != null && !isJvmInterface(superClass)) { superClassAsmType = typeMapper.mapClass(superClass); @@ -421,11 +421,11 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { continue; } - KtType returnType = function.getReturnType(); + KotlinType returnType = function.getReturnType(); assert returnType != null : function.toString(); - KtType paramType = function.getValueParameters().get(0).getType(); + KotlinType paramType = function.getValueParameters().get(0).getType(); if (KotlinBuiltIns.isArray(returnType) && KotlinBuiltIns.isArray(paramType)) { - KtType elementType = function.getTypeParameters().get(0).getDefaultType(); + KotlinType elementType = function.getTypeParameters().get(0).getDefaultType(); if (KotlinTypeChecker.DEFAULT.equalTypes(elementType, DescriptorUtilsKt.getBuiltIns(descriptor).getArrayElementType(returnType)) && KotlinTypeChecker.DEFAULT.equalTypes(elementType, DescriptorUtilsKt .getBuiltIns(descriptor).getArrayElementType(paramType))) { @@ -738,7 +738,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { iv.getfield(classAsmType.getInternalName(), CAPTURED_THIS_FIELD, type.getDescriptor()); } - KtType captureReceiver = closure.getCaptureReceiverType(); + KotlinType captureReceiver = closure.getCaptureReceiverType(); if (captureReceiver != null) { iv.load(0, classAsmType); Type type = typeMapper.mapType(captureReceiver); @@ -1150,7 +1150,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { result.addField((KtDelegatorByExpressionSpecifier) specifier, propertyDescriptor); } else { - KtType expressionType = expression != null ? bindingContext.getType(expression) : null; + KotlinType expressionType = expression != null ? bindingContext.getType(expression) : null; Type asmType = expressionType != null ? typeMapper.mapType(expressionType) : typeMapper.mapType(getSuperClass(specifier)); result.addField((KtDelegatorByExpressionSpecifier) specifier, asmType, "$delegate_" + n); @@ -1610,7 +1610,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { DelegationFieldsInfo.Field field = delegationFieldsInfo.getInfo((KtDelegatorByExpressionSpecifier) specifier); generateDelegateField(field); KtExpression delegateExpression = ((KtDelegatorByExpressionSpecifier) specifier).getDelegateExpression(); - KtType delegateExpressionType = delegateExpression != null ? bindingContext.getType(delegateExpression) : null; + KotlinType delegateExpressionType = delegateExpression != null ? bindingContext.getType(delegateExpression) : null; generateDelegates(getSuperClass(specifier), delegateExpressionType, field); } } @@ -1623,7 +1623,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { fieldInfo.name, fieldInfo.type.getDescriptor(), /*TODO*/null, null); } - protected void generateDelegates(ClassDescriptor toTrait, KtType delegateExpressionType, DelegationFieldsInfo.Field field) { + protected void generateDelegates(ClassDescriptor toTrait, KotlinType delegateExpressionType, DelegationFieldsInfo.Field field) { for (Map.Entry entry : CodegenUtilKt.getDelegates(descriptor, toTrait, delegateExpressionType).entrySet()) { CallableMemberDescriptor callableMemberDescriptor = entry.getKey(); CallableDescriptor delegateTo = entry.getValue(); diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/JvmCodegenUtil.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/JvmCodegenUtil.java index 8ade6373421..bdff9c99bbf 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/JvmCodegenUtil.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/JvmCodegenUtil.java @@ -43,7 +43,7 @@ import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils; import org.jetbrains.kotlin.resolve.DescriptorUtils; import org.jetbrains.kotlin.resolve.inline.InlineUtil; import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedCallableMemberDescriptor; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.org.objectweb.asm.AnnotationVisitor; import java.io.File; @@ -64,7 +64,7 @@ public class JvmCodegenUtil { return false; } - public static boolean isJvmInterface(KtType type) { + public static boolean isJvmInterface(KotlinType type) { return isJvmInterface(type.getConstructor().getDeclarationDescriptor()); } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/JvmRuntimeTypes.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/JvmRuntimeTypes.java index 570c398be69..5e56b62c58f 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/JvmRuntimeTypes.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/JvmRuntimeTypes.java @@ -27,7 +27,7 @@ import org.jetbrains.kotlin.resolve.TargetPlatformKt; import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt; import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform; import org.jetbrains.kotlin.storage.LockBasedStorageManager; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils; import java.util.*; @@ -72,11 +72,11 @@ public class JvmRuntimeTypes { } @NotNull - public Collection getSupertypesForClosure(@NotNull FunctionDescriptor descriptor) { + public Collection getSupertypesForClosure(@NotNull FunctionDescriptor descriptor) { ReceiverParameterDescriptor receiverParameter = descriptor.getExtensionReceiverParameter(); //noinspection ConstantConditions - KtType functionType = DescriptorUtilsKt.getBuiltIns(descriptor).getFunctionType( + KotlinType functionType = DescriptorUtilsKt.getBuiltIns(descriptor).getFunctionType( Annotations.Companion.getEMPTY(), receiverParameter == null ? null : receiverParameter.getType(), ExpressionTypingUtils.getValueParametersTypes(descriptor.getValueParameters()), @@ -87,15 +87,15 @@ public class JvmRuntimeTypes { } @NotNull - public Collection getSupertypesForFunctionReference(@NotNull FunctionDescriptor descriptor) { + public Collection getSupertypesForFunctionReference(@NotNull FunctionDescriptor descriptor) { ReceiverParameterDescriptor extensionReceiver = descriptor.getExtensionReceiverParameter(); ReceiverParameterDescriptor dispatchReceiver = descriptor.getDispatchReceiverParameter(); - KtType receiverType = + KotlinType receiverType = extensionReceiver != null ? extensionReceiver.getType() : dispatchReceiver != null ? dispatchReceiver.getType() : null; //noinspection ConstantConditions - KtType functionType = DescriptorUtilsKt.getBuiltIns(descriptor).getFunctionType( + KotlinType functionType = DescriptorUtilsKt.getBuiltIns(descriptor).getFunctionType( Annotations.Companion.getEMPTY(), receiverType, ExpressionTypingUtils.getValueParametersTypes(descriptor.getValueParameters()), @@ -106,7 +106,7 @@ public class JvmRuntimeTypes { } @NotNull - public KtType getSupertypeForPropertyReference(@NotNull PropertyDescriptor descriptor) { + public KotlinType getSupertypeForPropertyReference(@NotNull PropertyDescriptor descriptor) { int arity = (descriptor.getExtensionReceiverParameter() != null ? 1 : 0) + (descriptor.getDispatchReceiverParameter() != null ? 1 : 0); return (descriptor.isVar() ? mutablePropertyReferences : propertyReferences).get(arity).getDefaultType(); diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/MemberCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/MemberCodegen.java index f462cc16d59..3d2ddeb6c5c 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/MemberCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/MemberCodegen.java @@ -51,7 +51,7 @@ import org.jetbrains.kotlin.resolve.source.KotlinSourceElementKt; import org.jetbrains.kotlin.storage.LockBasedStorageManager; import org.jetbrains.kotlin.storage.NotNullLazyValue; import org.jetbrains.kotlin.types.ErrorUtils; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.org.objectweb.asm.Label; import org.jetbrains.org.objectweb.asm.MethodVisitor; import org.jetbrains.org.objectweb.asm.Type; @@ -413,7 +413,7 @@ public abstract class MemberCodegen typeParameters; - private final Collection supertypes = new ArrayList(); + private final Collection supertypes = new ArrayList(); public MutableClassDescriptor( @NotNull DeclarationDescriptor containingDeclaration, @@ -116,7 +116,7 @@ public class MutableClassDescriptor extends ClassDescriptorBase implements Class return typeConstructor; } - public void addSupertype(@NotNull KtType supertype) { + public void addSupertype(@NotNull KotlinType supertype) { assert !supertype.isError() : "Error types must be filtered out in DescriptorResolver"; if (TypeUtils.getClassDescriptor(supertype) != null) { // See the Errors.SUPERTYPE_NOT_A_CLASS_OR_INTERFACE diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/PropertyCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/PropertyCodegen.java index 59c079bb215..c23680fe9a1 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/PropertyCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/PropertyCodegen.java @@ -44,7 +44,7 @@ import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature; import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedPropertyDescriptor; import org.jetbrains.kotlin.storage.LockBasedStorageManager; import org.jetbrains.kotlin.types.ErrorUtils; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.org.objectweb.asm.FieldVisitor; import org.jetbrains.org.objectweb.asm.MethodVisitor; import org.jetbrains.org.objectweb.asm.Opcodes; @@ -275,7 +275,7 @@ public class PropertyCodegen { KtNamedDeclaration element, PropertyDescriptor propertyDescriptor, boolean isDelegate, - KtType jetType, + KotlinType jetType, Object defaultValue, Annotations annotations ) { @@ -362,7 +362,7 @@ public class PropertyCodegen { private void generatePropertyDelegateAccess(KtProperty p, PropertyDescriptor propertyDescriptor, Annotations annotations) { KtExpression delegateExpression = p.getDelegateExpression(); - KtType delegateType = delegateExpression != null ? bindingContext.getType(p.getDelegateExpression()) : null; + KotlinType delegateType = delegateExpression != null ? bindingContext.getType(p.getDelegateExpression()) : null; if (delegateType == null) { // If delegate expression is unresolved reference delegateType = ErrorUtils.createErrorType("Delegate type"); diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/RangeCodegenUtil.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/RangeCodegenUtil.java index 6767405f458..0299c90bf70 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/RangeCodegenUtil.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/RangeCodegenUtil.java @@ -27,7 +27,7 @@ import org.jetbrains.kotlin.name.FqNameUnsafe; import org.jetbrains.kotlin.name.Name; import org.jetbrains.kotlin.psi.*; import org.jetbrains.kotlin.resolve.DescriptorUtils; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import java.util.List; @@ -53,11 +53,11 @@ public class RangeCodegenUtil { private RangeCodegenUtil() {} - public static boolean isRange(KtType rangeType) { + public static boolean isRange(KotlinType rangeType) { return !rangeType.isMarkedNullable() && getPrimitiveRangeElementType(rangeType) != null; } - public static boolean isProgression(KtType rangeType) { + public static boolean isProgression(KotlinType rangeType) { return !rangeType.isMarkedNullable() && getPrimitiveProgressionElementType(rangeType) != null; } @@ -92,18 +92,18 @@ public class RangeCodegenUtil { } @Nullable - private static PrimitiveType getPrimitiveRangeElementType(KtType rangeType) { + private static PrimitiveType getPrimitiveRangeElementType(KotlinType rangeType) { return getPrimitiveRangeOrProgressionElementType(rangeType, RANGE_TO_ELEMENT_TYPE); } @Nullable - private static PrimitiveType getPrimitiveProgressionElementType(KtType rangeType) { + private static PrimitiveType getPrimitiveProgressionElementType(KotlinType rangeType) { return getPrimitiveRangeOrProgressionElementType(rangeType, PROGRESSION_TO_ELEMENT_TYPE); } @Nullable private static PrimitiveType getPrimitiveRangeOrProgressionElementType( - @NotNull KtType rangeOrProgression, + @NotNull KotlinType rangeOrProgression, @NotNull ImmutableMap map ) { ClassifierDescriptor declarationDescriptor = rangeOrProgression.getConstructor().getDeclarationDescriptor(); diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/SamType.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/SamType.java index 69a9225e85d..3f961111231 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/SamType.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/SamType.java @@ -21,22 +21,22 @@ import org.jetbrains.kotlin.descriptors.ClassifierDescriptor; import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor; import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor; import org.jetbrains.kotlin.load.java.sam.SingleAbstractMethodUtils; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; public class SamType { - public static SamType create(@NotNull KtType originalType) { + public static SamType create(@NotNull KotlinType originalType) { if (!SingleAbstractMethodUtils.isSamType(originalType)) return null; return new SamType(originalType); } - private final KtType type; + private final KotlinType type; - private SamType(@NotNull KtType type) { + private SamType(@NotNull KotlinType type) { this.type = type; } @NotNull - public KtType getType() { + public KotlinType getType() { return type; } @@ -48,7 +48,7 @@ public class SamType { } @NotNull - public KtType getKotlinFunctionType() { + public KotlinType getKotlinFunctionType() { //noinspection ConstantConditions return getJavaClassDescriptor().getFunctionTypeForSamInterface(); } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/SamWrapperCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/SamWrapperCodegen.java index b39706028a0..3ba918ef726 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/SamWrapperCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/SamWrapperCodegen.java @@ -31,7 +31,7 @@ import org.jetbrains.kotlin.name.Name; import org.jetbrains.kotlin.psi.KtFile; import org.jetbrains.kotlin.resolve.DescriptorUtils; import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOriginKt; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.util.OperatorNameConventions; import org.jetbrains.org.objectweb.asm.MethodVisitor; import org.jetbrains.org.objectweb.asm.Type; @@ -64,7 +64,7 @@ public class SamWrapperCodegen { Type asmType = asmTypeByFqNameWithoutInnerClasses(fqName); // e.g. (T, T) -> Int - KtType functionType = samType.getKotlinFunctionType(); + KotlinType functionType = samType.getKotlinFunctionType(); ClassDescriptor classDescriptor = new ClassDescriptorImpl( samType.getJavaClassDescriptor().getContainingDeclaration(), @@ -140,7 +140,7 @@ public class SamWrapperCodegen { Type functionType, ClassBuilder cv, SimpleFunctionDescriptor erasedInterfaceFunction, - KtType functionJetType + KotlinType functionJetType ) { // using root context to avoid creating ClassDescriptor and everything else FunctionCodegen codegen = new FunctionCodegen(state.getRootContext().intoClass( diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/binding/CalculatedClosure.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/binding/CalculatedClosure.java index dfd540142b9..2c2aab70d23 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/binding/CalculatedClosure.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/binding/CalculatedClosure.java @@ -22,7 +22,7 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.codegen.context.EnclosedValueDescriptor; import org.jetbrains.kotlin.descriptors.ClassDescriptor; import org.jetbrains.kotlin.descriptors.DeclarationDescriptor; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.org.objectweb.asm.Type; import java.util.List; @@ -33,7 +33,7 @@ public interface CalculatedClosure { ClassDescriptor getCaptureThis(); @Nullable - KtType getCaptureReceiverType(); + KotlinType getCaptureReceiverType(); @NotNull Map getCaptureVariables(); diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/binding/CodegenAnnotatingVisitor.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/binding/CodegenAnnotatingVisitor.java index c3aa03f4671..569069f03f0 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/binding/CodegenAnnotatingVisitor.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/binding/CodegenAnnotatingVisitor.java @@ -51,7 +51,7 @@ import org.jetbrains.kotlin.resolve.constants.EnumValue; import org.jetbrains.kotlin.resolve.constants.NullValue; import org.jetbrains.kotlin.resolve.scopes.KtScope; import org.jetbrains.kotlin.resolve.source.KotlinSourceElementKt; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.org.objectweb.asm.Type; import java.util.*; @@ -90,7 +90,7 @@ class CodegenAnnotatingVisitor extends KtVisitorVoid { private ClassDescriptor recordClassForCallable( @NotNull KtElement element, @NotNull CallableDescriptor callableDescriptor, - @NotNull Collection supertypes, + @NotNull Collection supertypes, @NotNull String name ) { String simpleName = name.substring(name.lastIndexOf('/') + 1); @@ -275,7 +275,7 @@ class CodegenAnnotatingVisitor extends KtVisitorVoid { if (functionDescriptor == null) return; String name = inventAnonymousClassName(); - Collection supertypes = runtimeTypes.getSupertypesForClosure(functionDescriptor); + Collection supertypes = runtimeTypes.getSupertypesForClosure(functionDescriptor); ClassDescriptor classDescriptor = recordClassForCallable(functionLiteral, functionDescriptor, supertypes, name); recordClosure(classDescriptor, name); @@ -293,7 +293,7 @@ class CodegenAnnotatingVisitor extends KtVisitorVoid { CallableDescriptor target = referencedFunction.getResultingDescriptor(); CallableDescriptor callableDescriptor; - Collection supertypes; + Collection supertypes; if (target instanceof FunctionDescriptor) { callableDescriptor = bindingContext.get(FUNCTION, expression); @@ -345,7 +345,7 @@ class CodegenAnnotatingVisitor extends KtVisitorVoid { if (delegate != null && descriptor instanceof PropertyDescriptor) { PropertyDescriptor propertyDescriptor = (PropertyDescriptor) descriptor; String name = inventAnonymousClassName(); - KtType supertype = runtimeTypes.getSupertypeForPropertyReference(propertyDescriptor); + KotlinType supertype = runtimeTypes.getSupertypeForPropertyReference(propertyDescriptor); ClassDescriptor classDescriptor = recordClassForCallable(delegate, propertyDescriptor, Collections.singleton(supertype), name); recordClosure(classDescriptor, name); } @@ -368,7 +368,7 @@ class CodegenAnnotatingVisitor extends KtVisitorVoid { } else { String name = inventAnonymousClassName(); - Collection supertypes = runtimeTypes.getSupertypesForClosure(functionDescriptor); + Collection supertypes = runtimeTypes.getSupertypesForClosure(functionDescriptor); ClassDescriptor classDescriptor = recordClassForCallable(function, functionDescriptor, supertypes, name); recordClosure(classDescriptor, name); @@ -530,7 +530,7 @@ class CodegenAnnotatingVisitor extends KtVisitorVoid { int fieldNumber = mappings.size(); assert expression.getSubjectExpression() != null : "subject expression should be not null in a valid when by enums"; - KtType type = bindingContext.getType(expression.getSubjectExpression()); + KotlinType type = bindingContext.getType(expression.getSubjectExpression()); assert type != null : "should not be null in a valid when by enums"; ClassDescriptor classDescriptor = (ClassDescriptor) type.getConstructor().getDeclarationDescriptor(); assert classDescriptor != null : "because it's enum"; diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/binding/MutableClosure.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/binding/MutableClosure.java index 619781fb836..142f125afee 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/binding/MutableClosure.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/binding/MutableClosure.java @@ -21,7 +21,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.codegen.context.EnclosedValueDescriptor; import org.jetbrains.kotlin.descriptors.*; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.org.objectweb.asm.Type; import java.util.*; @@ -71,7 +71,7 @@ public final class MutableClosure implements CalculatedClosure { } @Override - public KtType getCaptureReceiverType() { + public KotlinType getCaptureReceiverType() { if (captureReceiver) { ReceiverParameterDescriptor parameter = getEnclosingReceiverDescriptor(); assert parameter != null : "Receiver parameter should exist in " + enclosingFunWithReceiverDescriptor; diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/context/CodegenContext.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/context/CodegenContext.java index b4cf30d59c2..47fe426131b 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/context/CodegenContext.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/context/CodegenContext.java @@ -30,7 +30,7 @@ import org.jetbrains.kotlin.resolve.BindingContext; import org.jetbrains.kotlin.resolve.DescriptorUtils; import org.jetbrains.kotlin.storage.LockBasedStorageManager; import org.jetbrains.kotlin.storage.NullableLazyValue; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.org.objectweb.asm.Type; import java.util.*; @@ -282,7 +282,7 @@ public abstract class CodegenContext { public D getAccessor( @NotNull D possiblySubstitutedDescriptor, boolean isForBackingFieldInOuterClass, - @Nullable KtType delegateType, + @Nullable KotlinType delegateType, @Nullable KtSuperExpression superCallExpression ) { if (accessors == null) { diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/context/LocalLookup.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/context/LocalLookup.java index 8dbda7e6377..8c018ca2242 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/context/LocalLookup.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/context/LocalLookup.java @@ -25,7 +25,7 @@ import org.jetbrains.kotlin.codegen.state.GenerationState; import org.jetbrains.kotlin.descriptors.*; import org.jetbrains.kotlin.load.java.JvmAbi; import org.jetbrains.kotlin.resolve.BindingContext; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.org.objectweb.asm.Type; import static org.jetbrains.kotlin.codegen.AsmUtil.CAPTURED_RECEIVER_FIELD; @@ -139,7 +139,7 @@ public interface LocalLookup { return null; } - KtType receiverType = closure.getEnclosingReceiverDescriptor().getType(); + KotlinType receiverType = closure.getEnclosingReceiverDescriptor().getType(); Type type = state.getTypeMapper().mapType(receiverType); StackValue.StackValueWithSimpleReceiver innerValue = StackValue.field(type, classType, CAPTURED_RECEIVER_FIELD, false, StackValue.LOCAL_0, d); diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/ReifiedTypeInliner.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/ReifiedTypeInliner.kt index 16d0bc33e98..004777f5800 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/ReifiedTypeInliner.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/ReifiedTypeInliner.kt @@ -21,7 +21,7 @@ import org.jetbrains.kotlin.codegen.context.MethodContext import org.jetbrains.kotlin.codegen.intrinsics.IntrinsicMethods import org.jetbrains.kotlin.codegen.intrinsics.TypeIntrinsics import org.jetbrains.kotlin.resolve.DescriptorUtils -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.org.objectweb.asm.MethodVisitor import org.jetbrains.org.objectweb.asm.Opcodes import org.jetbrains.org.objectweb.asm.Type @@ -159,14 +159,14 @@ public class ReifiedTypeInliner(private val parametersMapping: ReifiedTypeParame private fun processNewArray(insn: MethodInsnNode, parameter: Type) = processNextTypeInsn(insn, parameter, Opcodes.ANEWARRAY) - private fun processCheckcast(insn: MethodInsnNode, instructions: InsnList, jetType: KtType, asmType: Type, safe: Boolean) = + private fun processCheckcast(insn: MethodInsnNode, instructions: InsnList, jetType: KotlinType, asmType: Type, safe: Boolean) = rewriteNextTypeInsn(insn, Opcodes.CHECKCAST) { instanceofInsn: AbstractInsnNode -> if (instanceofInsn !is TypeInsnNode) return false TypeIntrinsics.checkcast(instanceofInsn, instructions, jetType, asmType, safe) return true } - private fun processInstanceof(insn: MethodInsnNode, instructions: InsnList, jetType: KtType, asmType: Type) = + private fun processInstanceof(insn: MethodInsnNode, instructions: InsnList, jetType: KotlinType, asmType: Type) = rewriteNextTypeInsn(insn, Opcodes.INSTANCEOF) { instanceofInsn: AbstractInsnNode -> if (instanceofInsn !is TypeInsnNode) return false TypeIntrinsics.instanceOf(instanceofInsn, instructions, jetType, asmType) @@ -213,7 +213,7 @@ public class ReifiedTypeInliner(private val parametersMapping: ReifiedTypeParame public class ReifiedTypeParameterMappings() { private val mappingsByName = hashMapOf() - public fun addParameterMappingToType(name: String, type: KtType, asmType: Type, signature: String) { + public fun addParameterMappingToType(name: String, type: KotlinType, asmType: Type, signature: String) { mappingsByName[name] = ReifiedTypeParameterMapping(name, type, asmType, newName = null, signature = signature) } @@ -227,7 +227,7 @@ public class ReifiedTypeParameterMappings() { } public class ReifiedTypeParameterMapping( - val name: String, val type: KtType?, val asmType: Type?, val newName: String?, val signature: String? + val name: String, val type: KotlinType?, val asmType: Type?, val newName: String?, val signature: String? ) public class ReifiedTypeParametersUsages { diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/KClassJavaProperty.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/KClassJavaProperty.kt index 85874db0e71..e263284fbf6 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/KClassJavaProperty.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/KClassJavaProperty.kt @@ -25,7 +25,7 @@ import org.jetbrains.kotlin.psi.KtClassLiteralExpression import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall import org.jetbrains.kotlin.resolve.jvm.AsmTypes import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.org.objectweb.asm.Type import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter @@ -57,7 +57,7 @@ public class KClassJavaProperty : IntrinsicPropertyGetter() { } } - private fun isReifiedTypeParameter(type: KtType): Boolean { + private fun isReifiedTypeParameter(type: KotlinType): Boolean { val typeDescriptor = type.constructor.declarationDescriptor return typeDescriptor is TypeParameterDescriptor && typeDescriptor.isReified } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/TypeIntrinsics.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/TypeIntrinsics.kt index 47e84639cb3..eaa49e1d9a7 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/TypeIntrinsics.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/TypeIntrinsics.kt @@ -17,7 +17,7 @@ package org.jetbrains.kotlin.codegen.intrinsics import org.jetbrains.kotlin.resolve.DescriptorUtils -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeUtils import org.jetbrains.org.objectweb.asm.Opcodes import org.jetbrains.org.objectweb.asm.Type @@ -26,7 +26,7 @@ import org.jetbrains.org.objectweb.asm.tree.* import kotlin.text.Regex public object TypeIntrinsics { - public @JvmStatic fun instanceOf(v: InstructionAdapter, jetType: KtType, boxedAsmType: Type) { + public @JvmStatic fun instanceOf(v: InstructionAdapter, jetType: KotlinType, boxedAsmType: Type) { val functionTypeArity = getFunctionTypeArity(jetType) if (functionTypeArity >= 0) { v.iconst(functionTypeArity) @@ -57,7 +57,7 @@ public object TypeIntrinsics { LdcInsnNode(Integer(value)) } - public @JvmStatic fun instanceOf(instanceofInsn: TypeInsnNode, instructions: InsnList, jetType: KtType, asmType: Type) { + public @JvmStatic fun instanceOf(instanceofInsn: TypeInsnNode, instructions: InsnList, jetType: KotlinType, asmType: Type) { val functionTypeArity = getFunctionTypeArity(jetType) if (functionTypeArity >= 0) { instructions.insertBefore(instanceofInsn, iconstNode(functionTypeArity)) @@ -78,7 +78,7 @@ public object TypeIntrinsics { instanceofInsn.desc = asmType.internalName } - public @JvmStatic fun checkcast(v: InstructionAdapter, jetType: KtType, asmType: Type, safe: Boolean) { + public @JvmStatic fun checkcast(v: InstructionAdapter, jetType: KotlinType, asmType: Type, safe: Boolean) { if (safe) { v.checkcast(asmType) return @@ -106,7 +106,7 @@ public object TypeIntrinsics { v.checkcast(asmType) } - public @JvmStatic fun checkcast(checkcastInsn: TypeInsnNode, instructions: InsnList, jetType: KtType, asmType: Type, safe: Boolean) { + public @JvmStatic fun checkcast(checkcastInsn: TypeInsnNode, instructions: InsnList, jetType: KotlinType, asmType: Type, safe: Boolean) { if (safe) { checkcastInsn.desc = asmType.internalName return @@ -159,7 +159,7 @@ public object TypeIntrinsics { private val IS_MUTABLE_COLLECTION_METHOD_DESCRIPTOR = Type.getMethodDescriptor(Type.BOOLEAN_TYPE, Type.getObjectType("java/lang/Object")) - private fun getClassFqName(jetType: KtType): String? { + private fun getClassFqName(jetType: KotlinType): String? { val classDescriptor = TypeUtils.getClassDescriptor(jetType) ?: return null return DescriptorUtils.getFqName(classDescriptor).asString() } @@ -169,7 +169,7 @@ public object TypeIntrinsics { /** * @return function type arity (non-negative), or -1 if the given type is not a function type */ - private fun getFunctionTypeArity(jetType: KtType): Int { + private fun getFunctionTypeArity(jetType: KotlinType): Int { val classFqName = getClassFqName(jetType) ?: return -1 val match = KOTLIN_FUNCTION_INTERFACE_REGEX.match(classFqName) ?: return -1 return Integer.valueOf(match.groups[1]!!.value) @@ -182,7 +182,7 @@ public object TypeIntrinsics { invokestatic(INTRINSICS_CLASS, methodName, methodDescriptor, false) } - private fun getIsMutableCollectionMethodName(jetType: KtType): String? = + private fun getIsMutableCollectionMethodName(jetType: KotlinType): String? = IS_MUTABLE_COLLECTION_METHOD_NAME[getClassFqName(jetType)] private val CHECKCAST_METHOD_NAME = hashMapOf( @@ -196,7 +196,7 @@ public object TypeIntrinsics { "kotlin.MutableMap.MutableEntry" to "asMutableMapEntry" ) - private fun getAsMutableCollectionMethodName(jetType: KtType): String? { + private fun getAsMutableCollectionMethodName(jetType: KotlinType): String? { val classDescriptor = TypeUtils.getClassDescriptor(jetType) ?: return null val classFqName = DescriptorUtils.getFqName(classDescriptor).asString() return CHECKCAST_METHOD_NAME[classFqName] diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/serialization/JvmSerializerExtension.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/serialization/JvmSerializerExtension.java index bb20af8aabc..1efe2328e7a 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/serialization/JvmSerializerExtension.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/serialization/JvmSerializerExtension.java @@ -31,7 +31,7 @@ import org.jetbrains.kotlin.serialization.SerializerExtension; import org.jetbrains.kotlin.serialization.StringTable; import org.jetbrains.kotlin.serialization.jvm.JvmProtoBuf; import org.jetbrains.kotlin.serialization.jvm.JvmProtoBufUtil; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.org.objectweb.asm.Type; import org.jetbrains.org.objectweb.asm.commons.Method; @@ -70,7 +70,7 @@ public class JvmSerializerExtension extends SerializerExtension { } @Override - public void serializeType(@NotNull KtType type, @NotNull ProtoBuf.Type.Builder proto) { + public void serializeType(@NotNull KotlinType type, @NotNull ProtoBuf.Type.Builder proto) { // TODO: don't store type annotations in our binary metadata on Java 8, use *TypeAnnotations attributes instead for (AnnotationDescriptor annotation : type.getAnnotations()) { proto.addExtension(JvmProtoBuf.typeAnnotation, annotationSerializer.serializeAnnotation(annotation)); @@ -200,7 +200,7 @@ public class JvmSerializerExtension extends SerializerExtension { sb.append(")"); - KtType returnType = descriptor.getReturnType(); + KotlinType returnType = descriptor.getReturnType(); String returnTypeDesc = returnType == null ? "V" : mapTypeDefault(returnType); if (returnTypeDesc == null) return true; sb.append(returnTypeDesc); @@ -213,7 +213,7 @@ public class JvmSerializerExtension extends SerializerExtension { } @Nullable - private String mapTypeDefault(@NotNull KtType type) { + private String mapTypeDefault(@NotNull KotlinType type) { ClassifierDescriptor classifier = type.getConstructor().getDeclarationDescriptor(); if (!(classifier instanceof ClassDescriptor)) return null; ClassId classId = classId((ClassDescriptor) classifier); diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/JetTypeMapper.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/JetTypeMapper.java index 008091d18e8..051a85750c9 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/JetTypeMapper.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/JetTypeMapper.java @@ -342,7 +342,7 @@ public class JetTypeMapper { @NotNull private Type mapReturnType(@NotNull CallableDescriptor descriptor, @Nullable BothSignatureWriter sw) { - KtType returnType = descriptor.getReturnType(); + KotlinType returnType = descriptor.getReturnType(); assert returnType != null : "Function has no return type: " + descriptor; if (descriptor instanceof ConstructorDescriptor) { @@ -370,17 +370,17 @@ public class JetTypeMapper { } @NotNull - private Type mapType(@NotNull KtType jetType, @NotNull JetTypeMapperMode mode) { + private Type mapType(@NotNull KotlinType jetType, @NotNull JetTypeMapperMode mode) { return mapType(jetType, null, mode); } @NotNull - public Type mapSupertype(@NotNull KtType jetType, @Nullable BothSignatureWriter signatureVisitor) { + public Type mapSupertype(@NotNull KotlinType jetType, @Nullable BothSignatureWriter signatureVisitor) { return mapType(jetType, signatureVisitor, JetTypeMapperMode.SUPER_TYPE); } @NotNull - public Type mapTypeParameter(@NotNull KtType jetType, @Nullable BothSignatureWriter signatureVisitor) { + public Type mapTypeParameter(@NotNull KotlinType jetType, @Nullable BothSignatureWriter signatureVisitor) { return mapType(jetType, signatureVisitor, JetTypeMapperMode.TYPE_PARAMETER); } @@ -390,7 +390,7 @@ public class JetTypeMapper { } @NotNull - public Type mapType(@NotNull KtType jetType) { + public Type mapType(@NotNull KotlinType jetType) { return mapType(jetType, null, JetTypeMapperMode.VALUE); } @@ -415,13 +415,13 @@ public class JetTypeMapper { } @NotNull - private Type mapType(@NotNull KtType jetType, @Nullable BothSignatureWriter signatureVisitor, @NotNull JetTypeMapperMode mode) { + private Type mapType(@NotNull KotlinType jetType, @Nullable BothSignatureWriter signatureVisitor, @NotNull JetTypeMapperMode mode) { return mapType(jetType, signatureVisitor, mode, Variance.INVARIANT); } @NotNull private Type mapType( - @NotNull KtType jetType, + @NotNull KotlinType jetType, @Nullable BothSignatureWriter signatureVisitor, @NotNull JetTypeMapperMode kind, @NotNull Variance howThisTypeIsUsed @@ -450,7 +450,7 @@ public class JetTypeMapper { TypeConstructor constructor = jetType.getConstructor(); DeclarationDescriptor descriptor = constructor.getDeclarationDescriptor(); if (constructor instanceof IntersectionTypeConstructor) { - jetType = CommonSupertypes.commonSupertype(new ArrayList(constructor.getSupertypes())); + jetType = CommonSupertypes.commonSupertype(new ArrayList(constructor.getSupertypes())); } if (descriptor == null) { @@ -473,7 +473,7 @@ public class JetTypeMapper { throw new UnsupportedOperationException("arrays must have one type argument"); } TypeProjection memberProjection = jetType.getArguments().get(0); - KtType memberType = memberProjection.getType(); + KotlinType memberType = memberProjection.getType(); Type arrayElementType; if (memberProjection.getProjectionKind() == Variance.IN_VARIANCE) { @@ -520,7 +520,7 @@ public class JetTypeMapper { } @Nullable - private static Type mapBuiltinType(@NotNull KtType type) { + private static Type mapBuiltinType(@NotNull KotlinType type) { DeclarationDescriptor descriptor = type.getConstructor().getDeclarationDescriptor(); if (!(descriptor instanceof ClassDescriptor)) return null; @@ -583,7 +583,7 @@ public class JetTypeMapper { } @NotNull - private static String generateErrorMessageForErrorType(@NotNull KtType type, @NotNull DeclarationDescriptor descriptor) { + private static String generateErrorMessageForErrorType(@NotNull KotlinType type, @NotNull DeclarationDescriptor descriptor) { PsiElement declarationElement = DescriptorToSourceUtils.descriptorToDeclaration(descriptor); if (declarationElement == null) { @@ -616,7 +616,7 @@ public class JetTypeMapper { private void writeGenericType( BothSignatureWriter signatureVisitor, Type asmType, - KtType jetType, + KotlinType jetType, Variance howThisTypeIsUsed, boolean projectionsAllowed ) { @@ -653,7 +653,7 @@ public class JetTypeMapper { } } - private static boolean hasNothingInArguments(KtType jetType) { + private static boolean hasNothingInArguments(KotlinType jetType) { boolean hasNothingInArguments = CollectionsKt.any(jetType.getArguments(), new Function1() { @Override public Boolean invoke(TypeProjection projection) { @@ -691,7 +691,7 @@ public class JetTypeMapper { } private Type mapKnownAsmType( - KtType jetType, + KotlinType jetType, Type asmType, @Nullable BothSignatureWriter signatureVisitor, @NotNull Variance howThisTypeIsUsed @@ -700,7 +700,7 @@ public class JetTypeMapper { } private Type mapKnownAsmType( - KtType jetType, + KotlinType jetType, Type asmType, @Nullable BothSignatureWriter signatureVisitor, @NotNull Variance howThisTypeIsUsed, @@ -1092,7 +1092,7 @@ public class JetTypeMapper { } @Nullable - public String mapFieldSignature(@NotNull KtType backingFieldType) { + public String mapFieldSignature(@NotNull KotlinType backingFieldType) { BothSignatureWriter sw = new BothSignatureWriter(BothSignatureWriter.Mode.TYPE); mapType(backingFieldType, sw, JetTypeMapperMode.VALUE); return sw.makeJavaGenericSignature(); @@ -1143,7 +1143,7 @@ public class JetTypeMapper { { sw.writeClassBound(); - for (KtType jetType : typeParameterDescriptor.getUpperBounds()) { + for (KotlinType jetType : typeParameterDescriptor.getUpperBounds()) { if (jetType.getConstructor().getDeclarationDescriptor() instanceof ClassDescriptor) { if (!isJvmInterface(jetType)) { mapType(jetType, sw, JetTypeMapperMode.TYPE_PARAMETER); @@ -1159,7 +1159,7 @@ public class JetTypeMapper { } sw.writeClassBoundEnd(); - for (KtType jetType : typeParameterDescriptor.getUpperBounds()) { + for (KotlinType jetType : typeParameterDescriptor.getUpperBounds()) { ClassifierDescriptor classifier = jetType.getConstructor().getDeclarationDescriptor(); if (classifier instanceof ClassDescriptor) { if (isJvmInterface(jetType)) { @@ -1179,11 +1179,11 @@ public class JetTypeMapper { } } - private void writeParameter(@NotNull BothSignatureWriter sw, @NotNull KtType type) { + private void writeParameter(@NotNull BothSignatureWriter sw, @NotNull KotlinType type) { writeParameter(sw, JvmMethodParameterKind.VALUE, type); } - private void writeParameter(@NotNull BothSignatureWriter sw, @NotNull JvmMethodParameterKind kind, @NotNull KtType type) { + private void writeParameter(@NotNull BothSignatureWriter sw, @NotNull JvmMethodParameterKind kind, @NotNull KotlinType type) { sw.writeParameterType(kind); mapType(type, sw, JetTypeMapperMode.VALUE); sw.writeParameterTypeEnd(); @@ -1203,7 +1203,7 @@ public class JetTypeMapper { writeParameter(sw, JvmMethodParameterKind.OUTER, captureThis.getDefaultType()); } - KtType captureReceiverType = closure != null ? closure.getCaptureReceiverType() : null; + KotlinType captureReceiverType = closure != null ? closure.getCaptureReceiverType() : null; if (captureReceiverType != null) { writeParameter(sw, JvmMethodParameterKind.RECEIVER, captureReceiverType); } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/when/SwitchCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/when/SwitchCodegen.java index 3ea541c9250..d0fe2898dfd 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/when/SwitchCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/when/SwitchCodegen.java @@ -24,7 +24,7 @@ import org.jetbrains.kotlin.psi.KtWhenExpression; import org.jetbrains.kotlin.resolve.BindingContext; import org.jetbrains.kotlin.resolve.constants.ConstantValue; import org.jetbrains.kotlin.resolve.constants.NullValue; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.TypeUtils; import org.jetbrains.org.objectweb.asm.Label; import org.jetbrains.org.objectweb.asm.Type; @@ -131,7 +131,7 @@ abstract public class SwitchCodegen { protected void generateNullCheckIfNeeded() { assert expression.getSubjectExpression() != null : "subject expression can't be null"; - KtType subjectJetType = bindingContext.getType(expression.getSubjectExpression()); + KotlinType subjectJetType = bindingContext.getType(expression.getSubjectExpression()); assert subjectJetType != null : "subject type can't be null (i.e. void)"; diff --git a/compiler/builtins-serializer/src/org/jetbrains/kotlin/serialization/builtins/BuiltInsSerializerExtension.kt b/compiler/builtins-serializer/src/org/jetbrains/kotlin/serialization/builtins/BuiltInsSerializerExtension.kt index f13123f6092..a4fdec68992 100644 --- a/compiler/builtins-serializer/src/org/jetbrains/kotlin/serialization/builtins/BuiltInsSerializerExtension.kt +++ b/compiler/builtins-serializer/src/org/jetbrains/kotlin/serialization/builtins/BuiltInsSerializerExtension.kt @@ -20,7 +20,7 @@ import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.resolve.constants.NullValue import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter import org.jetbrains.kotlin.serialization.* -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType public class BuiltInsSerializerExtension : SerializerExtension() { private val stringTable = StringTableImpl() @@ -75,7 +75,7 @@ public class BuiltInsSerializerExtension : SerializerExtension() { } } - override fun serializeType(type: KtType, proto: ProtoBuf.Type.Builder) { + override fun serializeType(type: KotlinType, proto: ProtoBuf.Type.Builder) { for (annotation in type.annotations) { proto.addExtension(BuiltInsProtoBuf.typeAnnotation, annotationSerializer.serializeAnnotation(annotation)) } diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/CommandLineScriptUtils.java b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/CommandLineScriptUtils.java index 790ce1c326b..2303eb615cd 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/CommandLineScriptUtils.java +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/CommandLineScriptUtils.java @@ -20,7 +20,7 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns; import org.jetbrains.kotlin.name.Name; import org.jetbrains.kotlin.resolve.AnalyzerScriptParameter; import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import java.util.Collections; import java.util.List; @@ -35,7 +35,7 @@ public class CommandLineScriptUtils { public static List scriptParameters() { KotlinBuiltIns builtIns = JvmPlatform.INSTANCE$.getBuiltIns(); - KtType arrayOfStrings = builtIns.getArrayType(INVARIANT, builtIns.getStringType()); + KotlinType arrayOfStrings = builtIns.getArrayType(INVARIANT, builtIns.getStringType()); AnalyzerScriptParameter argsParameter = new AnalyzerScriptParameter(ARGS_NAME, arrayOfStrings); return Collections.singletonList(argsParameter); } diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/repl/ReplInterpreter.java b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/repl/ReplInterpreter.java index 133beb4e131..9b6810f26d1 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/repl/ReplInterpreter.java +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/repl/ReplInterpreter.java @@ -69,7 +69,7 @@ import org.jetbrains.kotlin.resolve.lazy.ResolveSession; import org.jetbrains.kotlin.resolve.lazy.data.JetClassLikeInfo; import org.jetbrains.kotlin.resolve.lazy.declarations.*; import org.jetbrains.kotlin.resolve.scopes.KtScope; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.utils.ExceptionUtilsKt; import org.jetbrains.org.objectweb.asm.Type; @@ -356,7 +356,7 @@ public class ReplInterpreter { earlierLines.add(new EarlierLine(line, scriptDescriptor, scriptClass, scriptInstance, scriptClassType)); - KtType returnType = scriptDescriptor.getScriptCodeDescriptor().getReturnType(); + KotlinType returnType = scriptDescriptor.getScriptCodeDescriptor().getReturnType(); return LineResult.successful(rv, returnType != null && KotlinBuiltIns.isUnit(returnType)); } catch (Throwable e) { diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/jvm/RuntimeAssertions.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/jvm/RuntimeAssertions.kt index daafd68357a..13c7ec15186 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/jvm/RuntimeAssertions.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/jvm/RuntimeAssertions.kt @@ -27,7 +27,7 @@ import org.jetbrains.kotlin.resolve.calls.context.CallResolutionContext import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeUtils import org.jetbrains.kotlin.types.checker.KotlinTypeChecker import org.jetbrains.kotlin.types.upperIfFlexible @@ -36,20 +36,20 @@ public class RuntimeAssertionInfo(public val needNotNullAssertion: Boolean, publ public interface DataFlowExtras { class OnlyMessage(message: String) : DataFlowExtras { override val canBeNull: Boolean get() = true - override val possibleTypes: Set get() = setOf() + override val possibleTypes: Set get() = setOf() override val presentableText: String = message } val canBeNull: Boolean - val possibleTypes: Set + val possibleTypes: Set val presentableText: String } companion object { @JvmStatic public fun create( - expectedType: KtType, - expressionType: KtType, + expectedType: KotlinType, + expressionType: KotlinType, dataFlowExtras: DataFlowExtras ): RuntimeAssertionInfo? { fun assertNotNull(): Boolean { @@ -78,13 +78,13 @@ public class RuntimeAssertionInfo(public val needNotNullAssertion: Boolean, publ null } - private fun KtType.hasEnhancedNullability() + private fun KotlinType.hasEnhancedNullability() = getAnnotations().findAnnotation(JvmAnnotationNames.ENHANCED_NULLABILITY_ANNOTATION) != null } } public object RuntimeAssertionsTypeChecker : AdditionalTypeChecker { - override fun checkType(expression: KtExpression, expressionType: KtType, expressionTypeWithSmartCast: KtType, c: ResolutionContext<*>) { + override fun checkType(expression: KtExpression, expressionType: KotlinType, expressionTypeWithSmartCast: KotlinType, c: ResolutionContext<*>) { if (TypeUtils.noExpectedType(c.expectedType)) return val assertionInfo = RuntimeAssertionInfo.create( @@ -93,7 +93,7 @@ public object RuntimeAssertionsTypeChecker : AdditionalTypeChecker { object : RuntimeAssertionInfo.DataFlowExtras { override val canBeNull: Boolean get() = c.dataFlowInfo.getNullability(dataFlowValue).canBeNull() - override val possibleTypes: Set + override val possibleTypes: Set get() = c.dataFlowInfo.getPossibleTypes(dataFlowValue) override val presentableText: String get() = StringUtil.trimMiddle(expression.getText(), 50) diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/TraceBasedExternalSignatureResolver.java b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/TraceBasedExternalSignatureResolver.java index 8779f01e230..4431f27d76f 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/TraceBasedExternalSignatureResolver.java +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/TraceBasedExternalSignatureResolver.java @@ -33,7 +33,7 @@ import org.jetbrains.kotlin.resolve.jvm.JavaDescriptorResolverKt; import org.jetbrains.kotlin.resolve.jvm.kotlinSignature.AlternativeFieldSignatureData; import org.jetbrains.kotlin.resolve.jvm.kotlinSignature.AlternativeMethodSignatureData; import org.jetbrains.kotlin.resolve.jvm.kotlinSignature.SignaturesPropagationData; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import java.util.Collections; import java.util.List; @@ -55,8 +55,8 @@ public class TraceBasedExternalSignatureResolver implements ExternalSignatureRes public PropagatedMethodSignature resolvePropagatedSignature( @NotNull JavaMethod method, @NotNull ClassDescriptor owner, - @NotNull KtType returnType, - @Nullable KtType receiverType, + @NotNull KotlinType returnType, + @Nullable KotlinType receiverType, @NotNull List valueParameters, @NotNull List typeParameters ) { @@ -72,8 +72,8 @@ public class TraceBasedExternalSignatureResolver implements ExternalSignatureRes public AlternativeMethodSignature resolveAlternativeMethodSignature( @NotNull JavaMember methodOrConstructor, boolean hasSuperMethods, - @Nullable KtType returnType, - @Nullable KtType receiverType, + @Nullable KotlinType returnType, + @Nullable KotlinType receiverType, @NotNull List valueParameters, @NotNull List typeParameters, boolean hasStableParameterNames @@ -102,7 +102,7 @@ public class TraceBasedExternalSignatureResolver implements ExternalSignatureRes @NotNull public AlternativeFieldSignature resolveAlternativeFieldSignature( @NotNull JavaField field, - @NotNull KtType returnType, + @NotNull KotlinType returnType, boolean isVar ) { AlternativeFieldSignatureData data = new AlternativeFieldSignatureData(field, returnType, project, isVar); diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SamAdapterOverridabilityCondition.java b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SamAdapterOverridabilityCondition.java index a9cbfd4c12b..b9f3c434c06 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SamAdapterOverridabilityCondition.java +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SamAdapterOverridabilityCondition.java @@ -21,7 +21,7 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.descriptors.*; import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl; import org.jetbrains.kotlin.resolve.ExternalOverridabilityCondition; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.TypeSubstitutor; import org.jetbrains.kotlin.types.TypeUtils; @@ -57,7 +57,7 @@ public class SamAdapterOverridabilityCondition implements ExternalOverridability return true; } - private static boolean differentClasses(@NotNull KtType type1, @NotNull KtType type2) { + private static boolean differentClasses(@NotNull KotlinType type1, @NotNull KotlinType type2) { DeclarationDescriptor declarationDescriptor1 = type1.getConstructor().getDeclarationDescriptor(); if (declarationDescriptor1 == null) return true; // No class, classes are not equal DeclarationDescriptor declarationDescriptor2 = type2.getConstructor().getDeclarationDescriptor(); @@ -100,7 +100,7 @@ public class SamAdapterOverridabilityCondition implements ExternalOverridability @Nullable private static SamAdapterInfo getNearestDeclarationOrSynthesized( @NotNull SimpleFunctionDescriptor samAdapter, - @NotNull KtType ownerType + @NotNull KotlinType ownerType ) { if (samAdapter.getKind() != CallableMemberDescriptor.Kind.FAKE_OVERRIDE) { return new SamAdapterInfo(samAdapter, ownerType); @@ -109,7 +109,7 @@ public class SamAdapterOverridabilityCondition implements ExternalOverridability for (CallableMemberDescriptor overridden : samAdapter.getOverriddenDescriptors()) { ClassDescriptor containingClass = (ClassDescriptor) overridden.getContainingDeclaration(); - for (KtType immediateSupertype : TypeUtils.getImmediateSupertypes(ownerType)) { + for (KotlinType immediateSupertype : TypeUtils.getImmediateSupertypes(ownerType)) { if (containingClass != immediateSupertype.getConstructor().getDeclarationDescriptor()) { continue; } @@ -126,9 +126,9 @@ public class SamAdapterOverridabilityCondition implements ExternalOverridability private static class SamAdapterInfo { private final SimpleFunctionDescriptor samAdapter; - private final KtType ownerType; + private final KotlinType ownerType; - private SamAdapterInfo(@NotNull SimpleFunctionDescriptor samAdapter, @NotNull KtType ownerType) { + private SamAdapterInfo(@NotNull SimpleFunctionDescriptor samAdapter, @NotNull KotlinType ownerType) { this.samAdapter = samAdapter; this.ownerType = ownerType; } diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SamConversionResolverImpl.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SamConversionResolverImpl.kt index fa101aaec77..57544fd50c6 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SamConversionResolverImpl.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SamConversionResolverImpl.kt @@ -23,7 +23,7 @@ import org.jetbrains.kotlin.load.java.descriptors.* import org.jetbrains.kotlin.load.java.lazy.descriptors.LazyJavaClassDescriptor import org.jetbrains.kotlin.descriptors.FunctionDescriptor import org.jetbrains.kotlin.load.java.structure.JavaMethod -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.load.java.sources.JavaSourceElement import org.jetbrains.kotlin.load.java.structure.JavaClass import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor @@ -51,7 +51,7 @@ public object SamConversionResolverImpl : SamConversionResolver { override fun resolveFunctionTypeIfSamInterface( classDescriptor: JavaClassDescriptor, resolveMethod: (JavaMethod) -> FunctionDescriptor - ): KtType? { + ): KotlinType? { val jClass = (classDescriptor.getSource() as? JavaSourceElement)?.javaElement as? JavaClass ?: return null val samInterfaceMethod = SingleAbstractMethodUtils.getSamInterfaceMethod(jClass) ?: return null val abstractMethod = if (jClass.getFqName() == samInterfaceMethod.getContainingClass().getFqName()) { @@ -63,7 +63,7 @@ public object SamConversionResolverImpl : SamConversionResolver { return SingleAbstractMethodUtils.getFunctionTypeForAbstractMethod(abstractMethod) } - private fun findFunctionWithMostSpecificReturnType(supertypes: Set): SimpleFunctionDescriptor { + private fun findFunctionWithMostSpecificReturnType(supertypes: Set): SimpleFunctionDescriptor { val candidates = ArrayList(supertypes.size()) for (supertype in supertypes) { val abstractMembers = SingleAbstractMethodUtils.getAbstractMembers(supertype) diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SingleAbstractMethodUtils.java b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SingleAbstractMethodUtils.java index 7be219b0eaf..8c6da15135c 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SingleAbstractMethodUtils.java +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SingleAbstractMethodUtils.java @@ -43,7 +43,7 @@ public class SingleAbstractMethodUtils { } @NotNull - public static List getAbstractMembers(@NotNull KtType type) { + public static List getAbstractMembers(@NotNull KotlinType type) { List abstractMembers = new ArrayList(); for (DeclarationDescriptor member : type.getMemberScope().getAllDescriptors()) { if (member instanceof CallableMemberDescriptor && ((CallableMemberDescriptor) member).getModality() == Modality.ABSTRACT) { @@ -53,7 +53,7 @@ public class SingleAbstractMethodUtils { return abstractMembers; } - private static KtType fixProjections(@NotNull KtType functionType) { + private static KotlinType fixProjections(@NotNull KotlinType functionType) { //removes redundant projection kinds and detects conflicts List typeParameters = functionType.getConstructor().getParameters(); @@ -76,7 +76,7 @@ public class SingleAbstractMethodUtils { } ClassifierDescriptor classifier = functionType.getConstructor().getDeclarationDescriptor(); assert classifier instanceof ClassDescriptor : "Not class: " + classifier; - return KtTypeImpl.create( + return KotlinTypeImpl.create( functionType.getAnnotations(), functionType.getConstructor(), functionType.isMarkedNullable(), @@ -86,21 +86,21 @@ public class SingleAbstractMethodUtils { } @Nullable - public static KtType getFunctionTypeForSamType(@NotNull KtType samType) { + public static KotlinType getFunctionTypeForSamType(@NotNull KotlinType samType) { // e.g. samType == Comparator? ClassifierDescriptor classifier = samType.getConstructor().getDeclarationDescriptor(); if (classifier instanceof JavaClassDescriptor) { // Function2 - KtType functionTypeDefault = ((JavaClassDescriptor) classifier).getFunctionTypeForSamInterface(); + KotlinType functionTypeDefault = ((JavaClassDescriptor) classifier).getFunctionTypeForSamInterface(); if (functionTypeDefault != null) { // Function2? - KtType substitute = TypeSubstitutor.create(samType).substitute(functionTypeDefault, Variance.INVARIANT); + KotlinType substitute = TypeSubstitutor.create(samType).substitute(functionTypeDefault, Variance.INVARIANT); if (substitute == null) return null; - KtType type = fixProjections(substitute); + KotlinType type = fixProjections(substitute); if (type == null) return null; if (JavaDescriptorResolverKt.getPLATFORM_TYPES() && FlexibleTypesKt.isNullabilityFlexible(samType)) { @@ -114,11 +114,11 @@ public class SingleAbstractMethodUtils { } @NotNull - public static KtType getFunctionTypeForAbstractMethod(@NotNull FunctionDescriptor function) { - KtType returnType = function.getReturnType(); + public static KotlinType getFunctionTypeForAbstractMethod(@NotNull FunctionDescriptor function) { + KotlinType returnType = function.getReturnType(); assert returnType != null : "function is not initialized: " + function; List valueParameters = function.getValueParameters(); - List parameterTypes = new ArrayList(valueParameters.size()); + List parameterTypes = new ArrayList(valueParameters.size()); for (ValueParameterDescriptor parameter : valueParameters) { parameterTypes.add(parameter.getType()); } @@ -151,9 +151,9 @@ public class SingleAbstractMethodUtils { TypeParameters typeParameters = recreateAndInitializeTypeParameters(samInterface.getTypeConstructor().getParameters(), result); - KtType parameterTypeUnsubstituted = getFunctionTypeForSamType(samInterface.getDefaultType()); + KotlinType parameterTypeUnsubstituted = getFunctionTypeForSamType(samInterface.getDefaultType()); assert parameterTypeUnsubstituted != null : "couldn't get function type for SAM type " + samInterface.getDefaultType(); - KtType parameterType = typeParameters.substitutor.substitute(parameterTypeUnsubstituted, Variance.IN_VARIANCE); + KotlinType parameterType = typeParameters.substitutor.substitute(parameterTypeUnsubstituted, Variance.IN_VARIANCE); assert parameterType != null : "couldn't substitute type: " + parameterTypeUnsubstituted + ", substitutor = " + typeParameters.substitutor; ValueParameterDescriptor parameter = new ValueParameterDescriptorImpl( @@ -163,7 +163,7 @@ public class SingleAbstractMethodUtils { /* isNoinline = */ false, null, SourceElement.NO_SOURCE); - KtType returnType = typeParameters.substitutor.substitute(samInterface.getDefaultType(), Variance.OUT_VARIANCE); + KotlinType returnType = typeParameters.substitutor.substitute(samInterface.getDefaultType(), Variance.OUT_VARIANCE); assert returnType != null : "couldn't substitute type: " + samInterface.getDefaultType() + ", substitutor = " + typeParameters.substitutor; @@ -180,7 +180,7 @@ public class SingleAbstractMethodUtils { return result; } - public static boolean isSamType(@NotNull KtType type) { + public static boolean isSamType(@NotNull KotlinType type) { return getFunctionTypeForSamType(type) != null; } @@ -201,7 +201,7 @@ public class SingleAbstractMethodUtils { public void initialize( @NotNull List typeParameters, @NotNull List valueParameters, - @NotNull KtType returnType + @NotNull KotlinType returnType ) { result.initialize( null, @@ -224,7 +224,7 @@ public class SingleAbstractMethodUtils { public void initialize( @NotNull List typeParameters, @NotNull List valueParameters, - @NotNull KtType returnType + @NotNull KotlinType returnType ) { result.initialize(typeParameters, valueParameters, original.getVisibility()); result.setReturnType(returnType); @@ -240,11 +240,11 @@ public class SingleAbstractMethodUtils { ) { TypeParameters typeParameters = recreateAndInitializeTypeParameters(original.getTypeParameters(), adapter); - KtType returnTypeUnsubstituted = original.getReturnType(); + KotlinType returnTypeUnsubstituted = original.getReturnType(); assert returnTypeUnsubstituted != null : "Creating SAM adapter for not initialized original: " + original; TypeSubstitutor substitutor = typeParameters.substitutor; - KtType returnType = substitutor.substitute(returnTypeUnsubstituted, Variance.INVARIANT); + KotlinType returnType = substitutor.substitute(returnTypeUnsubstituted, Variance.INVARIANT); assert returnType != null : "couldn't substitute type: " + returnTypeUnsubstituted + ", substitutor = " + substitutor; @@ -264,10 +264,10 @@ public class SingleAbstractMethodUtils { List originalValueParameters = original.getValueParameters(); List valueParameters = new ArrayList(originalValueParameters.size()); for (ValueParameterDescriptor originalParam : originalValueParameters) { - KtType originalType = originalParam.getType(); - KtType functionType = getFunctionTypeForSamType(originalType); - KtType newTypeUnsubstituted = functionType != null ? functionType : originalType; - KtType newType = substitutor.substitute(newTypeUnsubstituted, Variance.IN_VARIANCE); + KotlinType originalType = originalParam.getType(); + KotlinType functionType = getFunctionTypeForSamType(originalType); + KotlinType newTypeUnsubstituted = functionType != null ? functionType : originalType; + KotlinType newType = substitutor.substitute(newTypeUnsubstituted, Variance.IN_VARIANCE); assert newType != null : "couldn't substitute type: " + newTypeUnsubstituted + ", substitutor = " + substitutor; ValueParameterDescriptor newParam = new ValueParameterDescriptorImpl( @@ -295,8 +295,8 @@ public class SingleAbstractMethodUtils { TypeParameterDescriptor traitTypeParameter = mapEntry.getKey(); TypeParameterDescriptorImpl funTypeParameter = mapEntry.getValue(); - for (KtType upperBound : traitTypeParameter.getUpperBounds()) { - KtType upperBoundSubstituted = typeParametersSubstitutor.substitute(upperBound, Variance.INVARIANT); + for (KotlinType upperBound : traitTypeParameter.getUpperBounds()) { + KotlinType upperBoundSubstituted = typeParametersSubstitutor.substitute(upperBound, Variance.INVARIANT); assert upperBoundSubstituted != null : "couldn't substitute type: " + upperBound + ", substitutor = " + typeParametersSubstitutor; funTypeParameter.addUpperBound(upperBoundSubstituted); } @@ -345,7 +345,7 @@ public class SingleAbstractMethodUtils { public abstract void initialize( @NotNull List typeParameters, @NotNull List valueParameters, - @NotNull KtType returnType + @NotNull KotlinType returnType ); } diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/JavaAnnotationCallChecker.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/JavaAnnotationCallChecker.kt index 78251776b06..ea97fa63d56 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/JavaAnnotationCallChecker.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/JavaAnnotationCallChecker.kt @@ -37,7 +37,7 @@ import org.jetbrains.kotlin.resolve.calls.model.ExpressionValueArgument import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall import org.jetbrains.kotlin.resolve.calls.model.ResolvedValueArgument import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeUtils import java.lang.annotation.Target diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/JavaClassOnCompanionChecker.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/JavaClassOnCompanionChecker.kt index c8844e5d07e..01d3f9d9d1a 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/JavaClassOnCompanionChecker.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/JavaClassOnCompanionChecker.kt @@ -25,7 +25,7 @@ import org.jetbrains.kotlin.resolve.calls.checkers.CallChecker import org.jetbrains.kotlin.resolve.calls.context.BasicCallResolutionContext import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm -import org.jetbrains.kotlin.types.KtTypeImpl +import org.jetbrains.kotlin.types.KotlinTypeImpl import org.jetbrains.kotlin.types.TypeProjectionImpl public class JavaClassOnCompanionChecker : CallChecker { @@ -42,7 +42,7 @@ public class JavaClassOnCompanionChecker : CallChecker { if (companionObject.isCompanionObject) { val containingClass = companionObject.containingDeclaration as ClassDescriptor val javaLangClass = actualType.constructor.declarationDescriptor as? ClassDescriptor ?: return - val expectedType = KtTypeImpl.create( + val expectedType = KotlinTypeImpl.create( Annotations.EMPTY, javaLangClass, actualType.isMarkedNullable, listOf(TypeProjectionImpl(containingClass.defaultType)) ) diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/JavaNullabilityWarningsChecker.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/JavaNullabilityWarningsChecker.kt index ca8c440f4f4..ac729e8d0f4 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/JavaNullabilityWarningsChecker.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/JavaNullabilityWarningsChecker.kt @@ -36,14 +36,14 @@ import org.jetbrains.kotlin.resolve.calls.smartcasts.Nullability import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeUtils import org.jetbrains.kotlin.types.expressions.SenselessComparisonChecker import org.jetbrains.kotlin.types.flexibility import org.jetbrains.kotlin.types.isFlexible public class JavaNullabilityWarningsChecker : AdditionalTypeChecker { - private fun KtType.mayBeNull(): ErrorsJvm.NullabilityInformationSource? { + private fun KotlinType.mayBeNull(): ErrorsJvm.NullabilityInformationSource? { if (!isError() && !isFlexible() && TypeUtils.isNullableType(this)) return ErrorsJvm.NullabilityInformationSource.KOTLIN if (isFlexible() && TypeUtils.isNullableType(flexibility().lowerBound)) return ErrorsJvm.NullabilityInformationSource.KOTLIN @@ -52,7 +52,7 @@ public class JavaNullabilityWarningsChecker : AdditionalTypeChecker { return null } - private fun KtType.mustNotBeNull(): ErrorsJvm.NullabilityInformationSource? { + private fun KotlinType.mustNotBeNull(): ErrorsJvm.NullabilityInformationSource? { if (!isError() && !isFlexible() && !TypeUtils.isNullableType(this)) return ErrorsJvm.NullabilityInformationSource.KOTLIN if (isFlexible() && !TypeUtils.isNullableType(flexibility().upperBound)) return ErrorsJvm.NullabilityInformationSource.KOTLIN @@ -62,8 +62,8 @@ public class JavaNullabilityWarningsChecker : AdditionalTypeChecker { } private fun doCheckType( - expressionType: KtType, - expectedType: KtType, + expressionType: KotlinType, + expectedType: KotlinType, dataFlowValue: DataFlowValue, dataFlowInfo: DataFlowInfo, reportWarning: (expectedMustNotBeNull: ErrorsJvm.NullabilityInformationSource, actualMayBeNull: ErrorsJvm.NullabilityInformationSource) -> Unit @@ -85,7 +85,7 @@ public class JavaNullabilityWarningsChecker : AdditionalTypeChecker { } } - override fun checkType(expression: KtExpression, expressionType: KtType, expressionTypeWithSmartCast: KtType, c: ResolutionContext<*>) { + override fun checkType(expression: KtExpression, expressionType: KotlinType, expressionTypeWithSmartCast: KotlinType, c: ResolutionContext<*>) { doCheckType( expressionType, c.expectedType, diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/annotationCheckers.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/annotationCheckers.kt index 5e0986659aa..d284603eee5 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/annotationCheckers.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/annotationCheckers.kt @@ -30,12 +30,12 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.classId import org.jetbrains.kotlin.resolve.descriptorUtil.getAnnotationRetention import org.jetbrains.kotlin.resolve.descriptorUtil.isRepeatableAnnotation import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeUtils public object RepeatableAnnotationChecker: AdditionalAnnotationChecker { override fun checkEntries(entries: List, actualTargets: List, trace: BindingTrace) { - val entryTypesWithAnnotations = hashMapOf>() + val entryTypesWithAnnotations = hashMapOf>() for (entry in entries) { val descriptor = trace.get(BindingContext.ANNOTATION, entry) ?: continue diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/ErrorsJvm.java b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/ErrorsJvm.java index 92e68a50d7d..39b67a7627b 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/ErrorsJvm.java +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/ErrorsJvm.java @@ -27,7 +27,7 @@ import org.jetbrains.kotlin.psi.KtAnnotationEntry; import org.jetbrains.kotlin.psi.KtDeclaration; import org.jetbrains.kotlin.psi.KtElement; import org.jetbrains.kotlin.psi.KtExpression; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import static org.jetbrains.kotlin.diagnostics.PositioningStrategies.*; import static org.jetbrains.kotlin.diagnostics.Severity.ERROR; @@ -74,8 +74,8 @@ public interface ErrorsJvm { DiagnosticFactory0 NO_REFLECTION_IN_CLASS_PATH = DiagnosticFactory0.create(WARNING); - DiagnosticFactory2 JAVA_CLASS_ON_COMPANION = DiagnosticFactory2.create(WARNING); - DiagnosticFactory2 JAVA_TYPE_MISMATCH = DiagnosticFactory2.create(ERROR); + DiagnosticFactory2 JAVA_CLASS_ON_COMPANION = DiagnosticFactory2.create(WARNING); + DiagnosticFactory2 JAVA_TYPE_MISMATCH = DiagnosticFactory2.create(ERROR); DiagnosticFactory2 DUPLICATE_CLASS_NAMES = DiagnosticFactory2.create(ERROR); diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/kotlinSignature/AlternativeFieldSignatureData.java b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/kotlinSignature/AlternativeFieldSignatureData.java index 9aa5ab354c0..2e668f7c078 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/kotlinSignature/AlternativeFieldSignatureData.java +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/kotlinSignature/AlternativeFieldSignatureData.java @@ -24,16 +24,16 @@ import org.jetbrains.kotlin.descriptors.impl.TypeParameterDescriptorImpl; import org.jetbrains.kotlin.load.java.structure.JavaField; import org.jetbrains.kotlin.psi.KtProperty; import org.jetbrains.kotlin.psi.KtPsiFactoryKt; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import java.util.HashMap; public class AlternativeFieldSignatureData extends ElementAlternativeSignatureData { - private KtType altReturnType; + private KotlinType altReturnType; public AlternativeFieldSignatureData( @NotNull JavaField field, - @NotNull KtType originalReturnType, + @NotNull KotlinType originalReturnType, @NotNull Project project, boolean isVar ) { @@ -59,7 +59,7 @@ public class AlternativeFieldSignatureData extends ElementAlternativeSignatureDa } @NotNull - public KtType getReturnType() { + public KotlinType getReturnType() { checkForErrors(); return altReturnType; } diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/kotlinSignature/AlternativeMethodSignatureData.java b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/kotlinSignature/AlternativeMethodSignatureData.java index a95aa938c44..17b4530054b 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/kotlinSignature/AlternativeMethodSignatureData.java +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/kotlinSignature/AlternativeMethodSignatureData.java @@ -32,7 +32,7 @@ import org.jetbrains.kotlin.name.Name; import org.jetbrains.kotlin.psi.*; import org.jetbrains.kotlin.resolve.jvm.JavaDescriptorResolverKt; import org.jetbrains.kotlin.resolve.jvm.JavaResolverUtils; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.TypeSubstitutor; import org.jetbrains.kotlin.types.TypeUtils; import org.jetbrains.kotlin.types.Variance; @@ -52,17 +52,17 @@ public class AlternativeMethodSignatureData extends ElementAlternativeSignatureD private final KtNamedFunction altFunDeclaration; private List altValueParameters; - private KtType altReturnType; + private KotlinType altReturnType; private List altTypeParameters; private Map originalToAltTypeParameters; public AlternativeMethodSignatureData( @NotNull JavaMember methodOrConstructor, - @Nullable KtType receiverType, + @Nullable KotlinType receiverType, @NotNull Project project, @NotNull List valueParameters, - @Nullable KtType originalReturnType, + @Nullable KotlinType originalReturnType, @NotNull List methodTypeParameters, boolean hasSuperMethods ) { @@ -119,7 +119,7 @@ public class AlternativeMethodSignatureData extends ElementAlternativeSignatureD private void checkParameterAndReturnTypesForOverridingMethods( @NotNull List valueParameters, @NotNull List methodTypeParameters, - @Nullable KtType returnType + @Nullable KotlinType returnType ) { if (JavaDescriptorResolverKt.getPLATFORM_TYPES()) return; TypeSubstitutor substitutor = JavaResolverUtils.createSubstitutorForTypeParameters(originalToAltTypeParameters); @@ -128,7 +128,7 @@ public class AlternativeMethodSignatureData extends ElementAlternativeSignatureD int index = parameter.getIndex(); ValueParameterDescriptor altParameter = altValueParameters.get(index); - KtType substituted = substitutor.substitute(parameter.getType(), Variance.INVARIANT); + KotlinType substituted = substitutor.substitute(parameter.getType(), Variance.INVARIANT); assert substituted != null; if (!TypeUtils.equalTypes(substituted, altParameter.getType())) { @@ -143,7 +143,7 @@ public class AlternativeMethodSignatureData extends ElementAlternativeSignatureD for (TypeParameterDescriptor parameter : methodTypeParameters) { int index = parameter.getIndex(); - KtType substituted = substitutor.substitute(parameter.getUpperBoundsAsType(), Variance.INVARIANT); + KotlinType substituted = substitutor.substitute(parameter.getUpperBoundsAsType(), Variance.INVARIANT); assert substituted != null; if (!TypeUtils.equalTypes(substituted, altTypeParameters.get(index).getUpperBoundsAsType())) { @@ -154,7 +154,7 @@ public class AlternativeMethodSignatureData extends ElementAlternativeSignatureD } if (returnType != null) { - KtType substitutedReturnType = substitutor.substitute(returnType, Variance.INVARIANT); + KotlinType substitutedReturnType = substitutor.substitute(returnType, Variance.INVARIANT); assert substitutedReturnType != null; if (!KotlinTypeChecker.DEFAULT.isSubtypeOf(altReturnType, substitutedReturnType)) { @@ -171,7 +171,7 @@ public class AlternativeMethodSignatureData extends ElementAlternativeSignatureD } @Nullable - public KtType getReturnType() { + public KotlinType getReturnType() { checkForErrors(); return altReturnType; } @@ -197,10 +197,10 @@ public class AlternativeMethodSignatureData extends ElementAlternativeSignatureD KtTypeElement alternativeTypeElement = annotationValueParameter.getTypeReference().getTypeElement(); assert alternativeTypeElement != null; - KtType alternativeType; - KtType alternativeVarargElementType; + KotlinType alternativeType; + KotlinType alternativeVarargElementType; - KtType originalParamVarargElementType = originalParameterDescriptor.getVarargElementType(); + KotlinType originalParamVarargElementType = originalParameterDescriptor.getVarargElementType(); if (originalParamVarargElementType == null) { if (annotationValueParameter.isVarArg()) { throw new AlternativeSignatureMismatchException("Parameter in method signature is not vararg, but in alternative signature it is vararg"); @@ -253,7 +253,7 @@ public class AlternativeMethodSignatureData extends ElementAlternativeSignatureD TypeParameterDescriptorImpl altParamDescriptor = originalToAltTypeParameters.get(originalTypeParamDescriptor); KtTypeParameter altTypeParameter = altFunDeclaration.getTypeParameters().get(i); - Set originalUpperBounds = originalTypeParamDescriptor.getUpperBounds(); + Set originalUpperBounds = originalTypeParamDescriptor.getUpperBounds(); List altUpperBounds = getUpperBounds(altFunDeclaration, altTypeParameter); if (altUpperBounds.size() != originalUpperBounds.size()) { if (altUpperBounds.isEmpty() @@ -274,7 +274,7 @@ public class AlternativeMethodSignatureData extends ElementAlternativeSignatureD } else { int upperBoundIndex = 0; - for (KtType upperBound : originalUpperBounds) { + for (KotlinType upperBound : originalUpperBounds) { KtTypeElement altTypeElement = altUpperBounds.get(upperBoundIndex).getTypeElement(); assert altTypeElement != null; diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/kotlinSignature/ElementAlternativeSignatureData.java b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/kotlinSignature/ElementAlternativeSignatureData.java index a5debafeb78..a3587e75b2d 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/kotlinSignature/ElementAlternativeSignatureData.java +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/kotlinSignature/ElementAlternativeSignatureData.java @@ -27,7 +27,7 @@ import org.jetbrains.kotlin.psi.KtTypeElement; import org.jetbrains.kotlin.psi.KtTypeReference; import org.jetbrains.kotlin.renderer.DescriptorRenderer; import org.jetbrains.kotlin.resolve.AnalyzingUtils; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import java.util.List; import java.util.Map; @@ -86,8 +86,8 @@ public abstract class ElementAlternativeSignatureData { } } - protected static KtType computeReturnType( - @NotNull KtType originalType, + protected static KotlinType computeReturnType( + @NotNull KotlinType originalType, @Nullable KtTypeReference altReturnTypeReference, @NotNull Map originalToAltTypeParameters) { if (altReturnTypeReference == null) { diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/kotlinSignature/PropagationHeuristics.java b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/kotlinSignature/PropagationHeuristics.java index 4dd4fe8b2ed..adefddbbef4 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/kotlinSignature/PropagationHeuristics.java +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/kotlinSignature/PropagationHeuristics.java @@ -25,8 +25,8 @@ import org.jetbrains.kotlin.descriptors.ClassifierDescriptor; import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor; import org.jetbrains.kotlin.renderer.DescriptorRenderer; import org.jetbrains.kotlin.resolve.scopes.KtScope; -import org.jetbrains.kotlin.types.KtType; -import org.jetbrains.kotlin.types.KtTypeImpl; +import org.jetbrains.kotlin.types.KotlinType; +import org.jetbrains.kotlin.types.KotlinTypeImpl; import org.jetbrains.kotlin.types.TypeProjectionImpl; import org.jetbrains.kotlin.types.Variance; import org.jetbrains.kotlin.types.checker.KotlinTypeChecker; @@ -41,7 +41,7 @@ class PropagationHeuristics { // Checks for case when method returning Super[] is overridden with method returning Sub[] static void checkArrayInReturnType( @NotNull SignaturesPropagationData data, - @NotNull KtType type, + @NotNull KotlinType type, @NotNull List typesFromSuper ) { List arrayTypesFromSuper = ContainerUtil @@ -55,14 +55,14 @@ class PropagationHeuristics { assert type.getArguments().size() == 1; if (type.getArguments().get(0).getProjectionKind() == Variance.INVARIANT) { for (SignaturesPropagationData.TypeAndVariance typeAndVariance : arrayTypesFromSuper) { - KtType arrayTypeFromSuper = typeAndVariance.type; + KotlinType arrayTypeFromSuper = typeAndVariance.type; assert arrayTypeFromSuper.getArguments().size() == 1; - KtType elementTypeInSuper = arrayTypeFromSuper.getArguments().get(0).getType(); - KtType elementType = type.getArguments().get(0).getType(); + KotlinType elementTypeInSuper = arrayTypeFromSuper.getArguments().get(0).getType(); + KotlinType elementType = type.getArguments().get(0).getType(); if (KotlinTypeChecker.DEFAULT.isSubtypeOf(elementType, elementTypeInSuper) && !KotlinTypeChecker.DEFAULT.equalTypes(elementType, elementTypeInSuper)) { - KtTypeImpl betterTypeInSuper = KtTypeImpl.create( + KotlinTypeImpl betterTypeInSuper = KotlinTypeImpl.create( arrayTypeFromSuper.getAnnotations(), arrayTypeFromSuper.getConstructor(), arrayTypeFromSuper.isMarkedNullable(), diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/kotlinSignature/SignaturesPropagationData.java b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/kotlinSignature/SignaturesPropagationData.java index bca515c88af..b7201fe1aec 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/kotlinSignature/SignaturesPropagationData.java +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/kotlinSignature/SignaturesPropagationData.java @@ -66,7 +66,7 @@ public class SignaturesPropagationData { private final List modifiedTypeParameters; private final ValueParameters modifiedValueParameters; - private final KtType modifiedReturnType; + private final KotlinType modifiedReturnType; private final List signatureErrors = Lists.newArrayList(); private final List superFunctions; private final Map autoTypeParameterToModified; @@ -74,8 +74,8 @@ public class SignaturesPropagationData { public SignaturesPropagationData( @NotNull ClassDescriptor containingClass, - @NotNull KtType autoReturnType, // type built by JavaTypeTransformer from Java signature and @NotNull annotations - @Nullable KtType receiverType, + @NotNull KotlinType autoReturnType, // type built by JavaTypeTransformer from Java signature and @NotNull annotations + @Nullable KotlinType receiverType, @NotNull List autoValueParameters, // descriptors built by parameters resolver @NotNull List autoTypeParameters, // descriptors built by signature resolver @NotNull JavaMethod method @@ -97,8 +97,8 @@ public class SignaturesPropagationData { @NotNull private static JavaMethodDescriptor createAutoMethodDescriptor( @NotNull ClassDescriptor containingClass, - @NotNull JavaMethod method, KtType autoReturnType, - @Nullable KtType receiverType, + @NotNull JavaMethod method, KotlinType autoReturnType, + @Nullable KotlinType receiverType, @NotNull List autoValueParameters, @NotNull List autoTypeParameters ) { @@ -125,7 +125,7 @@ public class SignaturesPropagationData { return modifiedTypeParameters; } - public KtType getModifiedReceiverType() { + public KotlinType getModifiedReceiverType() { return modifiedValueParameters.receiverType; } @@ -137,7 +137,7 @@ public class SignaturesPropagationData { return modifiedValueParameters.hasStableParameterNames; } - public KtType getModifiedReturnType() { + public KotlinType getModifiedReturnType() { return modifiedReturnType; } @@ -153,8 +153,8 @@ public class SignaturesPropagationData { signatureErrors.add(error); } - private KtType modifyReturnTypeAccordingToSuperMethods( - @NotNull KtType autoType // type built by JavaTypeTransformer + private KotlinType modifyReturnTypeAccordingToSuperMethods( + @NotNull KotlinType autoType // type built by JavaTypeTransformer ) { if (JavaDescriptorResolverKt.getPLATFORM_TYPES()) return autoType; @@ -179,24 +179,24 @@ public class SignaturesPropagationData { int index = autoParameter.getIndex(); TypeParameterDescriptorImpl modifiedTypeParameter = autoTypeParameterToModified.get(autoParameter); - List> upperBoundFromSuperFunctionsIterators = Lists.newArrayList(); + List> upperBoundFromSuperFunctionsIterators = Lists.newArrayList(); for (FunctionDescriptor superFunction : superFunctions) { upperBoundFromSuperFunctionsIterators.add(superFunction.getTypeParameters().get(index).getUpperBounds().iterator()); } - for (KtType autoUpperBound : autoParameter.getUpperBounds()) { + for (KotlinType autoUpperBound : autoParameter.getUpperBounds()) { List upperBoundsFromSuperFunctions = Lists.newArrayList(); - for (Iterator iterator : upperBoundFromSuperFunctionsIterators) { + for (Iterator iterator : upperBoundFromSuperFunctionsIterators) { assert iterator.hasNext(); upperBoundsFromSuperFunctions.add(new TypeAndVariance(iterator.next(), INVARIANT)); } - KtType modifiedUpperBound = modifyTypeAccordingToSuperMethods(autoUpperBound, upperBoundsFromSuperFunctions, UPPER_BOUND); + KotlinType modifiedUpperBound = modifyTypeAccordingToSuperMethods(autoUpperBound, upperBoundsFromSuperFunctions, UPPER_BOUND); modifiedTypeParameter.addUpperBound(modifiedUpperBound); } - for (Iterator iterator : upperBoundFromSuperFunctionsIterators) { + for (Iterator iterator : upperBoundFromSuperFunctionsIterators) { assert !iterator.hasNext(); } @@ -208,14 +208,14 @@ public class SignaturesPropagationData { } private ValueParameters modifyValueParametersAccordingToSuperMethods( - @Nullable KtType receiverType, + @Nullable KotlinType receiverType, @NotNull List parameters // descriptors built by parameters resolver ) { assert receiverType == null : "Parameters before propagation have receiver type," + " but propagation should be disabled for functions compiled from Kotlin in class: " + DescriptorUtils.getFqName(containingClass); - KtType resultReceiverType = null; + KotlinType resultReceiverType = null; List resultParameters = new ArrayList(parameters.size()); boolean shouldBeExtension = checkIfShouldBeExtension(); @@ -239,9 +239,9 @@ public class SignaturesPropagationData { VarargCheckResult varargCheckResult = checkVarargInSuperFunctions(originalParam); - KtType altType = modifyTypeAccordingToSuperMethods(varargCheckResult.parameterType, - convertToTypeVarianceList(typesFromSuperMethods), - MEMBER_SIGNATURE_CONTRAVARIANT); + KotlinType altType = modifyTypeAccordingToSuperMethods(varargCheckResult.parameterType, + convertToTypeVarianceList(typesFromSuperMethods), + MEMBER_SIGNATURE_CONTRAVARIANT); if (shouldBeExtension && originalIndex == 0) { resultReceiverType = altType; @@ -304,7 +304,7 @@ public class SignaturesPropagationData { // TODO: Add propagation for other kotlin descriptors (KT-3621) Name name = method.getName(); JvmMethodSignature autoSignature = SIGNATURE_MAPPER.mapToJvmMethodSignature(autoMethodDescriptor); - for (KtType supertype : containingClass.getTypeConstructor().getSupertypes()) { + for (KotlinType supertype : containingClass.getTypeConstructor().getSupertypes()) { Collection superFunctionCandidates = supertype.getMemberScope().getFunctions(name, NoLookupLocation.WHEN_GET_SUPER_MEMBERS); for (FunctionDescriptor candidate : superFunctionCandidates) { JvmMethodSignature candidateSignature = SIGNATURE_MAPPER.mapToJvmMethodSignature(candidate); @@ -365,8 +365,8 @@ public class SignaturesPropagationData { } } - KtType originalVarargElementType = originalParam.getVarargElementType(); - KtType originalType = originalParam.getType(); + KotlinType originalVarargElementType = originalParam.getVarargElementType(); + KotlinType originalType = originalParam.getType(); if (someSupersVararg && someSupersNotVararg) { reportError("Incompatible super methods: some have vararg parameter, some have not"); @@ -389,8 +389,8 @@ public class SignaturesPropagationData { } @NotNull - private KtType modifyTypeAccordingToSuperMethods( - @NotNull KtType autoType, + private KotlinType modifyTypeAccordingToSuperMethods( + @NotNull KotlinType autoType, @NotNull List typesFromSuper, @NotNull TypeUsage howThisTypeIsUsed ) { @@ -409,11 +409,11 @@ public class SignaturesPropagationData { resultScope = autoType.getMemberScope(); } - KtType type = KtTypeImpl.create(autoType.getAnnotations(), - resultClassifier.getTypeConstructor(), - resultNullable, - resultArguments, - resultScope); + KotlinType type = KotlinTypeImpl.create(autoType.getAnnotations(), + resultClassifier.getTypeConstructor(), + resultNullable, + resultArguments, + resultScope); PropagationHeuristics.checkArrayInReturnType(this, type, typesFromSuper); return type; @@ -421,7 +421,7 @@ public class SignaturesPropagationData { @NotNull private List getTypeArgsOfType( - @NotNull KtType autoType, + @NotNull KotlinType autoType, @NotNull ClassifierDescriptor classifier, @NotNull List typesFromSuper ) { @@ -444,11 +444,11 @@ public class SignaturesPropagationData { for (TypeParameterDescriptor parameter : classifier.getTypeConstructor().getParameters()) { TypeProjection argument = autoArguments.get(parameter.getIndex()); - KtType argumentType = argument.getType(); + KotlinType argumentType = argument.getType(); List projectionsFromSuper = typeArgumentsFromSuper.get(parameter.getIndex()); List argTypesFromSuper = getTypes(projectionsFromSuper); - KtType type = modifyTypeAccordingToSuperMethods(argumentType, argTypesFromSuper, TYPE_ARGUMENT); + KotlinType type = modifyTypeAccordingToSuperMethods(argumentType, argTypesFromSuper, TYPE_ARGUMENT); Variance projectionKind = calculateArgumentProjectionKindFromSuper(argument, projectionsFromSuper); resultArguments.add(new TypeProjectionImpl(projectionKind, type)); @@ -567,7 +567,7 @@ public class SignaturesPropagationData { } private boolean typeMustBeNullable( - @NotNull KtType autoType, + @NotNull KotlinType autoType, @NotNull List typesFromSuper, @NotNull TypeUsage howThisTypeIsUsed ) { @@ -611,7 +611,7 @@ public class SignaturesPropagationData { @NotNull private ClassifierDescriptor modifyTypeClassifier( - @NotNull KtType autoType, + @NotNull KotlinType autoType, @NotNull List typesFromSuper ) { ClassifierDescriptor classifier = autoType.getConstructor().getDeclarationDescriptor(); @@ -666,15 +666,15 @@ public class SignaturesPropagationData { return fixed != null ? fixed : classifier; } - private static boolean isArrayType(@NotNull KtType type) { + private static boolean isArrayType(@NotNull KotlinType type) { return KotlinBuiltIns.isArray(type) || KotlinBuiltIns.isPrimitiveArray(type); } private static class VarargCheckResult { - public final KtType parameterType; + public final KotlinType parameterType; public final boolean isVararg; - public VarargCheckResult(KtType parameterType, boolean isVararg) { + public VarargCheckResult(KotlinType parameterType, boolean isVararg) { this.parameterType = parameterType; this.isVararg = isVararg; } @@ -695,10 +695,10 @@ public class SignaturesPropagationData { } static class TypeAndVariance { - public final KtType type; + public final KotlinType type; public final Variance varianceOfPosition; - public TypeAndVariance(KtType type, Variance varianceOfPosition) { + public TypeAndVariance(KotlinType type, Variance varianceOfPosition) { this.type = type; this.varianceOfPosition = varianceOfPosition; } @@ -709,22 +709,22 @@ public class SignaturesPropagationData { } private static class TypeAndName { - public final KtType type; + public final KotlinType type; public final Name name; - public TypeAndName(KtType type, Name name) { + public TypeAndName(KotlinType type, Name name) { this.type = type; this.name = name; } } private static class ValueParameters { - private final KtType receiverType; + private final KotlinType receiverType; private final List descriptors; private final boolean hasStableParameterNames; public ValueParameters( - @Nullable KtType receiverType, + @Nullable KotlinType receiverType, @NotNull List descriptors, boolean hasStableParameterNames ) { diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/kotlinSignature/TypeTransformingVisitor.java b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/kotlinSignature/TypeTransformingVisitor.java index 52788172454..f33b381e31f 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/kotlinSignature/TypeTransformingVisitor.java +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/kotlinSignature/TypeTransformingVisitor.java @@ -42,16 +42,16 @@ import java.util.*; import static org.jetbrains.kotlin.load.java.components.TypeUsage.TYPE_ARGUMENT; import static org.jetbrains.kotlin.types.Variance.INVARIANT; -public class TypeTransformingVisitor extends KtVisitor { +public class TypeTransformingVisitor extends KtVisitor { private static boolean strictMode = false; - private final KtType originalType; + private final KotlinType originalType; private final Map originalToAltTypeParameters; private final TypeUsage typeUsage; private TypeTransformingVisitor( - KtType originalType, + KotlinType originalType, Map originalToAltTypeParameters, TypeUsage typeUsage ) { @@ -61,19 +61,19 @@ public class TypeTransformingVisitor extends KtVisitor { } @NotNull - public static KtType computeType( + public static KotlinType computeType( @NotNull KtTypeElement alternativeTypeElement, - @NotNull KtType originalType, + @NotNull KotlinType originalType, @NotNull Map originalToAltTypeParameters, @NotNull TypeUsage typeUsage ) { - KtType computedType = alternativeTypeElement.accept(new TypeTransformingVisitor(originalType, originalToAltTypeParameters, typeUsage), null); + KotlinType computedType = alternativeTypeElement.accept(new TypeTransformingVisitor(originalType, originalToAltTypeParameters, typeUsage), null); assert (computedType != null); return computedType; } @Override - public KtType visitNullableType(@NotNull KtNullableType nullableType, Void aVoid) { + public KotlinType visitNullableType(@NotNull KtNullableType nullableType, Void aVoid) { if (!TypeUtils.isNullableType(originalType) && typeUsage != TYPE_ARGUMENT) { throw new AlternativeSignatureMismatchException("Auto type '%s' is not-null, while type in alternative signature is nullable: '%s'", DescriptorRenderer.FQ_NAMES_IN_TYPES.renderType(originalType), nullableType.getText()); @@ -84,7 +84,7 @@ public class TypeTransformingVisitor extends KtVisitor { } @Override - public KtType visitFunctionType(@NotNull KtFunctionType type, Void data) { + public KotlinType visitFunctionType(@NotNull KtFunctionType type, Void data) { KotlinBuiltIns builtIns = JvmPlatform.INSTANCE$.getBuiltIns(); return visitCommonType(type.getReceiverTypeReference() == null ? builtIns.getFunction(type.getParameters().size()) @@ -92,7 +92,7 @@ public class TypeTransformingVisitor extends KtVisitor { } @Override - public KtType visitUserType(@NotNull KtUserType type, Void data) { + public KotlinType visitUserType(@NotNull KtUserType type, Void data) { KtUserType qualifier = type.getQualifier(); //noinspection ConstantConditions @@ -102,12 +102,12 @@ public class TypeTransformingVisitor extends KtVisitor { return visitCommonType(longName, type); } - private KtType visitCommonType(@NotNull ClassDescriptor classDescriptor, @NotNull KtTypeElement type) { + private KotlinType visitCommonType(@NotNull ClassDescriptor classDescriptor, @NotNull KtTypeElement type) { return visitCommonType(DescriptorUtils.getFqNameSafe(classDescriptor).asString(), type); } @NotNull - private KtType visitCommonType(@NotNull String qualifiedName, @NotNull KtTypeElement type) { + private KotlinType visitCommonType(@NotNull String qualifiedName, @NotNull KtTypeElement type) { if (originalType.isError()) { return originalType; } @@ -159,7 +159,7 @@ public class TypeTransformingVisitor extends KtVisitor { throw new AssertionError("Unexpected class of type constructor classifier " + (typeConstructorClassifier == null ? "null" : typeConstructorClassifier.getClass().getName())); } - return KtTypeImpl.create(originalType.getAnnotations(), typeConstructor, false, altArguments, memberScope); + return KotlinTypeImpl.create(originalType.getAnnotations(), typeConstructor, false, altArguments, memberScope); } @NotNull @@ -183,7 +183,7 @@ public class TypeTransformingVisitor extends KtVisitor { assert argumentAlternativeTypeElement != null; TypeParameterDescriptor parameter = typeConstructor.getParameters().get(i); - KtType alternativeArgumentType = computeType(argumentAlternativeTypeElement, originalArgument.getType(), originalToAltTypeParameters, TYPE_ARGUMENT); + KotlinType alternativeArgumentType = computeType(argumentAlternativeTypeElement, originalArgument.getType(), originalToAltTypeParameters, TYPE_ARGUMENT); Variance projectionKind = originalArgument.getProjectionKind(); Variance altProjectionKind; if (type instanceof KtUserType) { @@ -234,7 +234,7 @@ public class TypeTransformingVisitor extends KtVisitor { } @Override - public KtType visitSelfType(@NotNull KtSelfType type, Void data) { + public KotlinType visitSelfType(@NotNull KtSelfType type, Void data) { throw new UnsupportedOperationException("Self-types are not supported yet"); } diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/platform/JavaGenericVarianceViolationTypeChecker.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/platform/JavaGenericVarianceViolationTypeChecker.kt index 5187116d257..7adaa4bdeb1 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/platform/JavaGenericVarianceViolationTypeChecker.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/platform/JavaGenericVarianceViolationTypeChecker.kt @@ -39,8 +39,8 @@ public object JavaGenericVarianceViolationTypeChecker : AdditionalTypeChecker { // JavaClass.fillWithDefaultObjects(x) // using `x` after this call may lead to CCE override fun checkType( expression: KtExpression, - expressionType: KtType, - expressionTypeWithSmartCast: KtType, + expressionType: KotlinType, + expressionTypeWithSmartCast: KotlinType, c: ResolutionContext<*> ) { val expectedType = c.expectedType diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticPropertiesScope.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticPropertiesScope.kt index 16fb42dc27d..2082e73fb6f 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticPropertiesScope.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticPropertiesScope.kt @@ -129,7 +129,7 @@ class JavaSyntheticPropertiesScope(storageManager: StorageManager) : KtScopeImpl return null } - override fun getSyntheticExtensionProperties(receiverTypes: Collection, name: Name, location: LookupLocation): Collection { + override fun getSyntheticExtensionProperties(receiverTypes: Collection, name: Name, location: LookupLocation): Collection { //TODO: use location parameter! var result: SmartList? = null @@ -161,7 +161,7 @@ class JavaSyntheticPropertiesScope(storageManager: StorageManager) : KtScopeImpl return result } - override fun getSyntheticExtensionProperties(receiverTypes: Collection): Collection { + override fun getSyntheticExtensionProperties(receiverTypes: Collection): Collection { val result = ArrayList() val processedTypes = HashSet() receiverTypes.forEach { result.collectSyntheticProperties(it.constructor, processedTypes) } @@ -252,7 +252,7 @@ class JavaSyntheticPropertiesScope(storageManager: StorageManager) : KtScopeImpl private set companion object { - fun create(ownerClass: ClassDescriptor, getMethod: FunctionDescriptor, setMethod: FunctionDescriptor?, name: Name, type: KtType): MyPropertyDescriptor { + fun create(ownerClass: ClassDescriptor, getMethod: FunctionDescriptor, setMethod: FunctionDescriptor?, name: Name, type: KotlinType): MyPropertyDescriptor { val visibility = syntheticExtensionVisibility(getMethod) val descriptor = MyPropertyDescriptor(DescriptorUtils.getContainingModule(ownerClass), null, diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SamAdapterFunctionsScope.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SamAdapterFunctionsScope.kt index acfa49a847d..632b6f1e5e9 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SamAdapterFunctionsScope.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SamAdapterFunctionsScope.kt @@ -52,7 +52,7 @@ class SamAdapterFunctionsScope(storageManager: StorageManager) : KtScope by KtSc return MyFunctionDescriptor.create(enhancedFunction) } - override fun getSyntheticExtensionFunctions(receiverTypes: Collection, name: Name, location: LookupLocation): Collection { + override fun getSyntheticExtensionFunctions(receiverTypes: Collection, name: Name, location: LookupLocation): Collection { var result: SmartList? = null for (type in receiverTypes) { for (function in type.memberScope.getFunctions(name, location)) { @@ -72,7 +72,7 @@ class SamAdapterFunctionsScope(storageManager: StorageManager) : KtScope by KtSc } } - override fun getSyntheticExtensionFunctions(receiverTypes: Collection): Collection { + override fun getSyntheticExtensionFunctions(receiverTypes: Collection): Collection { return receiverTypes.flatMapTo(LinkedHashSet()) { type -> type.memberScope.getDescriptors(DescriptorKindFilter.FUNCTIONS) .filterIsInstance() @@ -156,8 +156,8 @@ class SamAdapterFunctionsScope(storageManager: StorageManager) : KtScope by KtSc copyOverrides: Boolean, kind: CallableMemberDescriptor.Kind, newValueParameterDescriptors: MutableList, - newExtensionReceiverParameterType: KtType?, - newReturnType: KtType + newExtensionReceiverParameterType: KotlinType?, + newReturnType: KotlinType ): FunctionDescriptor? { val descriptor = super.doSubstitute( originalSubstitutor, newOwner, newModality, newVisibility, diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/JetControlFlowProcessor.java b/compiler/frontend/src/org/jetbrains/kotlin/cfg/JetControlFlowProcessor.java index f7fe5068184..b29bb9d75dd 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/JetControlFlowProcessor.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/JetControlFlowProcessor.java @@ -56,7 +56,7 @@ import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver; import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue; import org.jetbrains.kotlin.resolve.scopes.receivers.ThisReceiver; import org.jetbrains.kotlin.resolve.scopes.receivers.TransientReceiver; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.expressions.OperatorConventions; import java.util.*; @@ -109,7 +109,7 @@ public class JetControlFlowProcessor { CallableDescriptor subroutineDescriptor = (CallableDescriptor) trace.get(BindingContext.DECLARATION_TO_DESCRIPTOR, subroutine); if (subroutineDescriptor == null) return; - KtType returnType = subroutineDescriptor.getReturnType(); + KotlinType returnType = subroutineDescriptor.getReturnType(); if (returnType != null && KotlinBuiltIns.isUnit(returnType) && subroutineDescriptor instanceof AnonymousFunctionDescriptor) return; PseudoValue returnValue = builder.getBoundValue(bodyExpression); @@ -199,7 +199,7 @@ public class JetControlFlowProcessor { return; } - KtType type = trace.getBindingContext().getType(expression); + KotlinType type = trace.getBindingContext().getType(expression); if (type != null && KotlinBuiltIns.isNothing(type)) { builder.jumpToError(expression); } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/JetFlowInformationProvider.java b/compiler/frontend/src/org/jetbrains/kotlin/cfg/JetFlowInformationProvider.java index 223327c7b2f..6a8e7bba99e 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/JetFlowInformationProvider.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/JetFlowInformationProvider.java @@ -60,7 +60,7 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilKt; import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall; import org.jetbrains.kotlin.resolve.calls.resolvedCallUtil.ResolvedCallUtilKt; import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils; import java.util.*; @@ -129,7 +129,7 @@ public class JetFlowInformationProvider { markWhenWithoutElse(); } - public void checkFunction(@Nullable KtType expectedReturnType) { + public void checkFunction(@Nullable KotlinType expectedReturnType) { UnreachableCode unreachableCode = collectUnreachableCode(); reportUnreachableCode(unreachableCode); @@ -208,7 +208,7 @@ public class JetFlowInformationProvider { CallableDescriptor functionDescriptor = (CallableDescriptor) trace.getBindingContext().get(BindingContext.DECLARATION_TO_DESCRIPTOR, localDeclaration); - KtType expectedType = functionDescriptor != null ? functionDescriptor.getReturnType() : null; + KotlinType expectedType = functionDescriptor != null ? functionDescriptor.getReturnType() : null; JetFlowInformationProvider providerForLocalDeclaration = new JetFlowInformationProvider(localDeclaration, trace, localDeclarationInstruction.getBody()); @@ -218,7 +218,7 @@ public class JetFlowInformationProvider { } } - public void checkDefiniteReturn(final @NotNull KtType expectedReturnType, @NotNull final UnreachableCode unreachableCode) { + public void checkDefiniteReturn(final @NotNull KotlinType expectedReturnType, @NotNull final UnreachableCode unreachableCode) { assert subroutine instanceof KtDeclarationWithBody; KtDeclarationWithBody function = (KtDeclarationWithBody) subroutine; diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/WhenChecker.java b/compiler/frontend/src/org/jetbrains/kotlin/cfg/WhenChecker.java index 9d3847d9500..928505fb78c 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/WhenChecker.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/WhenChecker.java @@ -27,7 +27,7 @@ import org.jetbrains.kotlin.resolve.CompileTimeConstantUtils; import org.jetbrains.kotlin.resolve.DescriptorUtils; import org.jetbrains.kotlin.resolve.bindingContextUtil.BindingContextUtilsKt; import org.jetbrains.kotlin.types.FlexibleTypesKt; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.TypeUtils; import java.util.HashSet; @@ -41,7 +41,7 @@ public final class WhenChecker { } public static boolean mustHaveElse(@NotNull KtWhenExpression expression, @NotNull BindingTrace trace) { - KtType expectedType = trace.get(BindingContext.EXPECTED_EXPRESSION_TYPE, expression); + KotlinType expectedType = trace.get(BindingContext.EXPECTED_EXPRESSION_TYPE, expression); boolean isUnit = expectedType != null && KotlinBuiltIns.isUnit(expectedType); // Some "statements" are actually expressions returned from lambdas, their expected types are non-null boolean isStatement = BindingContextUtilsKt.isUsedAsStatement(expression, trace.getBindingContext()) && expectedType == null; @@ -54,7 +54,7 @@ public final class WhenChecker { } @Nullable - public static ClassDescriptor getClassDescriptorOfTypeIfEnum(@Nullable KtType type) { + public static ClassDescriptor getClassDescriptorOfTypeIfEnum(@Nullable KotlinType type) { if (type == null) return null; ClassDescriptor classDescriptor = TypeUtils.getClassDescriptor(type); if (classDescriptor == null) return null; @@ -64,7 +64,7 @@ public final class WhenChecker { } @Nullable - private static KtType whenSubjectType(@NotNull KtWhenExpression expression, @NotNull BindingContext context) { + private static KotlinType whenSubjectType(@NotNull KtWhenExpression expression, @NotNull BindingContext context) { KtExpression subjectExpression = expression.getSubjectExpression(); return subjectExpression == null ? null : context.getType(subjectExpression); } @@ -136,7 +136,7 @@ public final class WhenChecker { */ private static boolean isNullableTypeWithoutPossibleSmartCast( @Nullable KtExpression expression, - @NotNull KtType type, + @NotNull KotlinType type, @NotNull BindingContext context ) { if (expression == null) return false; // Normally should not happen @@ -152,7 +152,7 @@ public final class WhenChecker { } public static boolean isWhenExhaustive(@NotNull KtWhenExpression expression, @NotNull BindingTrace trace) { - KtType type = whenSubjectType(expression, trace.getBindingContext()); + KotlinType type = whenSubjectType(expression, trace.getBindingContext()); if (type == null) return false; ClassDescriptor enumClassDescriptor = getClassDescriptorOfTypeIfEnum(type); @@ -196,7 +196,7 @@ public final class WhenChecker { ClassDescriptor checkedDescriptor = null; if (condition instanceof KtWhenConditionIsPattern) { KtWhenConditionIsPattern conditionIsPattern = (KtWhenConditionIsPattern) condition; - KtType checkedType = trace.get(BindingContext.TYPE, conditionIsPattern.getTypeReference()); + KotlinType checkedType = trace.get(BindingContext.TYPE, conditionIsPattern.getTypeReference()); if (checkedType != null) { checkedDescriptor = TypeUtils.getClassDescriptor(checkedType); } @@ -243,7 +243,7 @@ public final class WhenChecker { if (condition instanceof KtWhenConditionWithExpression) { KtWhenConditionWithExpression conditionWithExpression = (KtWhenConditionWithExpression) condition; if (conditionWithExpression.getExpression() != null) { - KtType type = trace.getBindingContext().getType(conditionWithExpression.getExpression()); + KotlinType type = trace.getBindingContext().getType(conditionWithExpression.getExpression()); if (type != null && KotlinBuiltIns.isNothingOrNullableNothing(type)) { return true; } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/JetControlFlowInstructionsGenerator.java b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/JetControlFlowInstructionsGenerator.java index c51115db25f..95aacf721a3 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/JetControlFlowInstructionsGenerator.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/JetControlFlowInstructionsGenerator.java @@ -31,7 +31,7 @@ import org.jetbrains.kotlin.psi.*; import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall; import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant; import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import java.util.*; @@ -476,7 +476,7 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd @NotNull Map receiverValues, @NotNull Map arguments ) { - KtType returnType = resolvedCall.getResultingDescriptor().getReturnType(); + KotlinType returnType = resolvedCall.getResultingDescriptor().getReturnType(); CallInstruction instruction = new CallInstruction( valueElement, getCurrentScope(), diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/PseudocodeUtil.java b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/PseudocodeUtil.java index d3c64603ab1..55b4748a994 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/PseudocodeUtil.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/PseudocodeUtil.java @@ -35,7 +35,7 @@ import org.jetbrains.kotlin.resolve.BindingContextUtils; import org.jetbrains.kotlin.resolve.BindingTrace; import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall; import org.jetbrains.kotlin.resolve.calls.resolvedCallUtil.ResolvedCallUtilKt; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.util.slicedMap.ReadOnlySlice; import org.jetbrains.kotlin.util.slicedMap.WritableSlice; @@ -72,12 +72,12 @@ public class PseudocodeUtil { @Nullable @Override - public KtType getType(@NotNull KtExpression expression) { + public KotlinType getType(@NotNull KtExpression expression) { return bindingContext.getType(expression); } @Override - public void recordType(@NotNull KtExpression expression, @Nullable KtType type) { + public void recordType(@NotNull KtExpression expression, @Nullable KotlinType type) { } @Override diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/TypePredicate.kt b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/TypePredicate.kt index 29d231b3b0a..18bac802570 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/TypePredicate.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/TypePredicate.kt @@ -19,39 +19,39 @@ package org.jetbrains.kotlin.cfg.pseudocode import com.intellij.util.SmartFMap import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.renderer.DescriptorRenderer -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeUtils import org.jetbrains.kotlin.types.checker.KotlinTypeChecker -public interface TypePredicate: (KtType) -> Boolean { - override fun invoke(typeToCheck: KtType): Boolean +public interface TypePredicate: (KotlinType) -> Boolean { + override fun invoke(typeToCheck: KotlinType): Boolean } -public data class SingleType(val targetType: KtType): TypePredicate { - override fun invoke(typeToCheck: KtType): Boolean = KotlinTypeChecker.DEFAULT.equalTypes(typeToCheck, targetType) +public data class SingleType(val targetType: KotlinType): TypePredicate { + override fun invoke(typeToCheck: KotlinType): Boolean = KotlinTypeChecker.DEFAULT.equalTypes(typeToCheck, targetType) override fun toString(): String = targetType.render() } -public data class AllSubtypes(val upperBound: KtType): TypePredicate { - override fun invoke(typeToCheck: KtType): Boolean = KotlinTypeChecker.DEFAULT.isSubtypeOf(typeToCheck, upperBound) +public data class AllSubtypes(val upperBound: KotlinType): TypePredicate { + override fun invoke(typeToCheck: KotlinType): Boolean = KotlinTypeChecker.DEFAULT.isSubtypeOf(typeToCheck, upperBound) override fun toString(): String = "{<: ${upperBound.render()}}" } public data class ForAllTypes(val typeSets: List): TypePredicate { - override fun invoke(typeToCheck: KtType): Boolean = typeSets.all { it(typeToCheck) } + override fun invoke(typeToCheck: KotlinType): Boolean = typeSets.all { it(typeToCheck) } override fun toString(): String = "AND{${typeSets.joinToString(", ")}}" } public data class ForSomeType(val typeSets: List): TypePredicate { - override fun invoke(typeToCheck: KtType): Boolean = typeSets.any { it(typeToCheck) } + override fun invoke(typeToCheck: KotlinType): Boolean = typeSets.any { it(typeToCheck) } override fun toString(): String = "OR{${typeSets.joinToString(", ")}}" } public object AllTypes : TypePredicate { - override fun invoke(typeToCheck: KtType): Boolean = true + override fun invoke(typeToCheck: KotlinType): Boolean = true override fun toString(): String = "*" } @@ -71,7 +71,7 @@ public fun or(predicates: Collection): TypePredicate? = else -> ForSomeType(predicates.toList()) } -fun KtType.getSubtypesPredicate(): TypePredicate { +fun KotlinType.getSubtypesPredicate(): TypePredicate { return when { KotlinBuiltIns.isAnyOrNullableAny(this) && isMarkedNullable() -> AllTypes TypeUtils.canHaveSubtypes(KotlinTypeChecker.DEFAULT, this) -> AllSubtypes(this) @@ -80,7 +80,7 @@ fun KtType.getSubtypesPredicate(): TypePredicate { } -private fun KtType.render(): String = DescriptorRenderer.SHORT_NAMES_IN_TYPES.renderType(this) +private fun KotlinType.render(): String = DescriptorRenderer.SHORT_NAMES_IN_TYPES.renderType(this) public fun TypePredicate.expectedTypeFor(keys: Iterable): Map = keys.fold(SmartFMap.emptyMap()) { map, key -> map.plus(key, this) } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/pseudocodeUtils.kt b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/pseudocodeUtils.kt index b362feaf087..956207fa4bc 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/pseudocodeUtils.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/pseudocodeUtils.kt @@ -46,7 +46,7 @@ import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind import org.jetbrains.kotlin.resolve.calls.tasks.ResolutionCandidate import org.jetbrains.kotlin.resolve.calls.tasks.TracingStrategy import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeUtils import java.util.* @@ -77,7 +77,7 @@ public fun getExpectedTypePredicate( val pseudocode = value.createdAt?.owner ?: return AllTypes val typePredicates = LinkedHashSet() - fun addSubtypesOf(jetType: KtType?) = typePredicates.add(jetType?.getSubtypesPredicate()) + fun addSubtypesOf(jetType: KotlinType?) = typePredicates.add(jetType?.getSubtypesPredicate()) fun addByExplicitReceiver(resolvedCall: ResolvedCall<*>?) { val receiverValue = (resolvedCall ?: return).getExplicitReceiverValue() diff --git a/compiler/frontend/src/org/jetbrains/kotlin/checkers/DebugInfoUtil.java b/compiler/frontend/src/org/jetbrains/kotlin/checkers/DebugInfoUtil.java index f8ba829c6f9..cd9d277b204 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/checkers/DebugInfoUtil.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/checkers/DebugInfoUtil.java @@ -38,7 +38,7 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilKt; import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall; import org.jetbrains.kotlin.resolve.calls.tasks.DynamicCallsKt; import org.jetbrains.kotlin.types.ErrorUtils; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.util.slicedMap.WritableSlice; import java.util.Collection; @@ -196,7 +196,7 @@ public class DebugInfoUtil { // if 'foo' in 'foo[i]' is unresolved it means 'foo[i]' is unresolved (otherwise 'foo[i]' is marked as 'missing unresolved') markedWithError = true; } - KtType expressionType = bindingContext.getType(expression); + KotlinType expressionType = bindingContext.getType(expression); DiagnosticFactory factory = markedWithErrorElements.get(expression); if (declarationDescriptor != null && (ErrorUtils.isError(declarationDescriptor) || ErrorUtils.containsErrorType(expressionType))) { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/descriptors/impl/LocalVariableDescriptor.java b/compiler/frontend/src/org/jetbrains/kotlin/descriptors/impl/LocalVariableDescriptor.java index 0c14ddc010d..a0e89631db7 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/descriptors/impl/LocalVariableDescriptor.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/descriptors/impl/LocalVariableDescriptor.java @@ -21,7 +21,7 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.descriptors.*; import org.jetbrains.kotlin.descriptors.annotations.Annotations; import org.jetbrains.kotlin.name.Name; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.TypeSubstitutor; public class LocalVariableDescriptor extends VariableDescriptorWithInitializerImpl { @@ -29,7 +29,7 @@ public class LocalVariableDescriptor extends VariableDescriptorWithInitializerIm @NotNull DeclarationDescriptor containingDeclaration, @NotNull Annotations annotations, @NotNull Name name, - @Nullable KtType type, + @Nullable KotlinType type, boolean mutable, @NotNull SourceElement source ) { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java index f0e52e5b125..0cd9a0c4d93 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java @@ -30,7 +30,7 @@ import org.jetbrains.kotlin.psi.*; import org.jetbrains.kotlin.resolve.calls.inference.InferenceErrorData; import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall; import org.jetbrains.kotlin.resolve.varianceChecker.VarianceChecker.VarianceConflictDiagnosticData; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import java.lang.reflect.Field; import java.lang.reflect.Modifier; @@ -91,7 +91,7 @@ public interface Errors { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// DiagnosticFactory0 PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT = DiagnosticFactory0.create(ERROR, VARIANCE_IN_PROJECTION); - DiagnosticFactory2 UPPER_BOUND_VIOLATED = DiagnosticFactory2.create(ERROR); + DiagnosticFactory2 UPPER_BOUND_VIOLATED = DiagnosticFactory2.create(ERROR); DiagnosticFactory0 REDUNDANT_NULLABLE = DiagnosticFactory0.create(WARNING, NULLABLE_TYPE); DiagnosticFactory1 WRONG_NUMBER_OF_TYPE_ARGUMENTS = DiagnosticFactory1.create(ERROR); DiagnosticFactory2 NO_TYPE_ARGUMENTS_ON_RHS = DiagnosticFactory2.create(ERROR); @@ -148,7 +148,7 @@ public interface Errors { DiagnosticFactory0 CONST_VAL_NOT_TOP_LEVEL_OR_OBJECT = DiagnosticFactory0.create(ERROR); DiagnosticFactory0 CONST_VAL_WITH_GETTER = DiagnosticFactory0.create(ERROR); DiagnosticFactory0 CONST_VAL_WITH_DELEGATE = DiagnosticFactory0.create(ERROR); - DiagnosticFactory1 TYPE_CANT_BE_USED_FOR_CONST_VAL = DiagnosticFactory1.create(ERROR); + DiagnosticFactory1 TYPE_CANT_BE_USED_FOR_CONST_VAL = DiagnosticFactory1.create(ERROR); DiagnosticFactory0 CONST_VAL_WITHOUT_INITIALIZER = DiagnosticFactory0.create(ERROR); DiagnosticFactory0 CONST_VAL_WITH_NON_CONST_INITIALIZER = DiagnosticFactory0.create(ERROR); @@ -180,9 +180,9 @@ public interface Errors { DiagnosticFactory0 MANY_CLASSES_IN_SUPERTYPE_LIST = DiagnosticFactory0.create(ERROR); DiagnosticFactory0 SUPERTYPE_APPEARS_TWICE = DiagnosticFactory0.create(ERROR); - DiagnosticFactory3> + DiagnosticFactory3> INCONSISTENT_TYPE_PARAMETER_VALUES = DiagnosticFactory3.create(ERROR); - DiagnosticFactory3> + DiagnosticFactory3> INCONSISTENT_TYPE_PARAMETER_BOUNDS = DiagnosticFactory3.create(ERROR); @@ -253,7 +253,7 @@ public interface Errors { // Type parameter declarations - DiagnosticFactory1 FINAL_UPPER_BOUND = DiagnosticFactory1.create(WARNING); + DiagnosticFactory1 FINAL_UPPER_BOUND = DiagnosticFactory1.create(WARNING); DiagnosticFactory0 DYNAMIC_UPPER_BOUND = DiagnosticFactory0.create(ERROR); DiagnosticFactory1 CONFLICTING_UPPER_BOUNDS = @@ -322,7 +322,7 @@ public interface Errors { DiagnosticFactory2.create(ERROR, DECLARATION_NAME); - DiagnosticFactory1> AMBIGUOUS_ANONYMOUS_TYPE_INFERRED = + DiagnosticFactory1> AMBIGUOUS_ANONYMOUS_TYPE_INFERRED = DiagnosticFactory1.create(ERROR, DECLARATION_SIGNATURE); // Property-specific @@ -334,7 +334,7 @@ public interface Errors { DiagnosticFactory0 GETTER_VISIBILITY_DIFFERS_FROM_PROPERTY_VISIBILITY = DiagnosticFactory0.create(ERROR); DiagnosticFactory0 PRIVATE_SETTER_ON_NON_PRIVATE_LATE_INIT_VAR = DiagnosticFactory0.create(ERROR); DiagnosticFactory0 ACCESSOR_VISIBILITY_FOR_ABSTRACT_PROPERTY = DiagnosticFactory0.create(ERROR); - DiagnosticFactory2 WRONG_GETTER_RETURN_TYPE = DiagnosticFactory2.create(ERROR); + DiagnosticFactory2 WRONG_GETTER_RETURN_TYPE = DiagnosticFactory2.create(ERROR); DiagnosticFactory0 ABSTRACT_PROPERTY_IN_PRIMARY_CONSTRUCTOR_PARAMETERS = DiagnosticFactory0.create(ERROR, ABSTRACT_MODIFIER); @@ -370,7 +370,7 @@ public interface Errors { DiagnosticFactory0 SETTER_PARAMETER_WITH_DEFAULT_VALUE = DiagnosticFactory0.create(ERROR); - DiagnosticFactory2 WRONG_SETTER_PARAMETER_TYPE = DiagnosticFactory2.create(ERROR); + DiagnosticFactory2 WRONG_SETTER_PARAMETER_TYPE = DiagnosticFactory2.create(ERROR); // Function-specific @@ -452,7 +452,7 @@ public interface Errors { DiagnosticFactory1 NO_VALUE_FOR_PARAMETER = DiagnosticFactory1.create(ERROR, VALUE_ARGUMENTS); - DiagnosticFactory1 MISSING_RECEIVER = DiagnosticFactory1.create(ERROR); + DiagnosticFactory1 MISSING_RECEIVER = DiagnosticFactory1.create(ERROR); DiagnosticFactory0 NO_RECEIVER_ALLOWED = DiagnosticFactory0.create(ERROR); // Call resolution @@ -461,7 +461,7 @@ public interface Errors { DiagnosticFactory0 SAFE_CALL_IN_QUALIFIER = DiagnosticFactory0.create(ERROR); - DiagnosticFactory2 FUNCTION_EXPECTED = DiagnosticFactory2.create(ERROR); + DiagnosticFactory2 FUNCTION_EXPECTED = DiagnosticFactory2.create(ERROR); DiagnosticFactory2 FUNCTION_CALL_EXPECTED = DiagnosticFactory2.create(ERROR, CALL_EXPRESSION); DiagnosticFactory0 NON_TAIL_RECURSIVE_CALL = DiagnosticFactory0.create(WARNING, CALL_EXPRESSION); @@ -478,7 +478,7 @@ public interface Errors { DiagnosticFactory1 INVOKE_EXTENSION_ON_NOT_EXTENSION_FUNCTION = DiagnosticFactory1.create(ERROR); DiagnosticFactory1 TYPE_PARAMETER_AS_REIFIED = DiagnosticFactory1.create(ERROR); - DiagnosticFactory1 REIFIED_TYPE_FORBIDDEN_SUBSTITUTION = DiagnosticFactory1.create(ERROR); + DiagnosticFactory1 REIFIED_TYPE_FORBIDDEN_SUBSTITUTION = DiagnosticFactory1.create(ERROR); // Type inference @@ -491,7 +491,7 @@ public interface Errors { DiagnosticFactory0 TYPE_INFERENCE_INCORPORATION_ERROR = DiagnosticFactory0.create(ERROR); DiagnosticFactory1 TYPE_INFERENCE_ONLY_INPUT_TYPES = DiagnosticFactory1.create(ERROR); DiagnosticFactory1 TYPE_INFERENCE_UPPER_BOUND_VIOLATED = DiagnosticFactory1.create(ERROR); - DiagnosticFactory2 TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH = DiagnosticFactory2.create(ERROR); + DiagnosticFactory2 TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH = DiagnosticFactory2.create(ERROR); // Reflection @@ -506,9 +506,9 @@ public interface Errors { // Multi-declarations DiagnosticFactory0 INITIALIZER_REQUIRED_FOR_MULTIDECLARATION = DiagnosticFactory0.create(ERROR, DEFAULT); - DiagnosticFactory2 COMPONENT_FUNCTION_MISSING = DiagnosticFactory2.create(ERROR, DEFAULT); + DiagnosticFactory2 COMPONENT_FUNCTION_MISSING = DiagnosticFactory2.create(ERROR, DEFAULT); DiagnosticFactory2>> COMPONENT_FUNCTION_AMBIGUITY = DiagnosticFactory2.create(ERROR, DEFAULT); - DiagnosticFactory3 COMPONENT_FUNCTION_RETURN_TYPE_MISMATCH = DiagnosticFactory3.create(ERROR, DEFAULT); + DiagnosticFactory3 COMPONENT_FUNCTION_RETURN_TYPE_MISMATCH = DiagnosticFactory3.create(ERROR, DEFAULT); // Super calls @@ -535,30 +535,30 @@ public interface Errors { ASSIGN_OPERATOR_AMBIGUITY = DiagnosticFactory1.create(ERROR); DiagnosticFactory0 EQUALS_MISSING = DiagnosticFactory0.create(ERROR); - DiagnosticFactory3 EQUALITY_NOT_APPLICABLE = + DiagnosticFactory3 EQUALITY_NOT_APPLICABLE = DiagnosticFactory3.create(ERROR); - DiagnosticFactory1 HAS_NEXT_MISSING = DiagnosticFactory1.create(ERROR); - DiagnosticFactory1 HAS_NEXT_FUNCTION_AMBIGUITY = DiagnosticFactory1.create(ERROR); - DiagnosticFactory1 HAS_NEXT_FUNCTION_NONE_APPLICABLE = DiagnosticFactory1.create(ERROR); - DiagnosticFactory1 HAS_NEXT_FUNCTION_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR); + DiagnosticFactory1 HAS_NEXT_MISSING = DiagnosticFactory1.create(ERROR); + DiagnosticFactory1 HAS_NEXT_FUNCTION_AMBIGUITY = DiagnosticFactory1.create(ERROR); + DiagnosticFactory1 HAS_NEXT_FUNCTION_NONE_APPLICABLE = DiagnosticFactory1.create(ERROR); + DiagnosticFactory1 HAS_NEXT_FUNCTION_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR); - DiagnosticFactory1 NEXT_AMBIGUITY = DiagnosticFactory1.create(ERROR); - DiagnosticFactory1 NEXT_MISSING = DiagnosticFactory1.create(ERROR); - DiagnosticFactory1 NEXT_NONE_APPLICABLE = DiagnosticFactory1.create(ERROR); + DiagnosticFactory1 NEXT_AMBIGUITY = DiagnosticFactory1.create(ERROR); + DiagnosticFactory1 NEXT_MISSING = DiagnosticFactory1.create(ERROR); + DiagnosticFactory1 NEXT_NONE_APPLICABLE = DiagnosticFactory1.create(ERROR); DiagnosticFactory0 ITERATOR_MISSING = DiagnosticFactory0.create(ERROR); DiagnosticFactory1>> ITERATOR_AMBIGUITY = DiagnosticFactory1.create(ERROR); - DiagnosticFactory2 DELEGATE_SPECIAL_FUNCTION_MISSING = DiagnosticFactory2.create(ERROR); - DiagnosticFactory3 DELEGATE_RESOLVED_TO_DEPRECATED_CONVENTION = DiagnosticFactory3.create(WARNING); + DiagnosticFactory2 DELEGATE_SPECIAL_FUNCTION_MISSING = DiagnosticFactory2.create(ERROR); + DiagnosticFactory3 DELEGATE_RESOLVED_TO_DEPRECATED_CONVENTION = DiagnosticFactory3.create(WARNING); DiagnosticFactory2>> DELEGATE_SPECIAL_FUNCTION_AMBIGUITY = DiagnosticFactory2.create(ERROR); DiagnosticFactory2>> DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE = DiagnosticFactory2.create(ERROR); - DiagnosticFactory3 DELEGATE_SPECIAL_FUNCTION_RETURN_TYPE_MISMATCH = DiagnosticFactory3.create(ERROR); + DiagnosticFactory3 DELEGATE_SPECIAL_FUNCTION_RETURN_TYPE_MISMATCH = DiagnosticFactory3.create(ERROR); DiagnosticFactory2>> DELEGATE_PD_METHOD_NONE_APPLICABLE = DiagnosticFactory2.create(WARNING); - DiagnosticFactory1 COMPARE_TO_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR); + DiagnosticFactory1 COMPARE_TO_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR); DiagnosticFactory0 UNDERSCORE_IS_RESERVED = DiagnosticFactory0.create(ERROR); DiagnosticFactory1 INVALID_CHARACTERS = DiagnosticFactory1.create(ERROR); @@ -616,14 +616,14 @@ public interface Errors { // Nullability - DiagnosticFactory1 UNSAFE_CALL = DiagnosticFactory1.create(ERROR); + DiagnosticFactory1 UNSAFE_CALL = DiagnosticFactory1.create(ERROR); DiagnosticFactory3 UNSAFE_INFIX_CALL = DiagnosticFactory3.create(ERROR); - DiagnosticFactory1 UNNECESSARY_SAFE_CALL = DiagnosticFactory1.create(WARNING); + DiagnosticFactory1 UNNECESSARY_SAFE_CALL = DiagnosticFactory1.create(WARNING); DiagnosticFactory0 UNEXPECTED_SAFE_CALL = DiagnosticFactory0.create(ERROR); - DiagnosticFactory1 UNNECESSARY_NOT_NULL_ASSERTION = DiagnosticFactory1.create(WARNING); + DiagnosticFactory1 UNNECESSARY_NOT_NULL_ASSERTION = DiagnosticFactory1.create(WARNING); DiagnosticFactory0 NOT_NULL_ASSERTION_ON_FUNCTION_LITERAL = DiagnosticFactory0.create(WARNING); - DiagnosticFactory1 USELESS_ELVIS = DiagnosticFactory1.create(WARNING, PositioningStrategies.USELESS_ELVIS); + DiagnosticFactory1 USELESS_ELVIS = DiagnosticFactory1.create(WARNING, PositioningStrategies.USELESS_ELVIS); DiagnosticFactory0 USELESS_ELVIS_ON_FUNCTION_LITERAL = DiagnosticFactory0.create(WARNING); // Compile-time values @@ -633,27 +633,27 @@ public interface Errors { DiagnosticFactory0 WRONG_LONG_SUFFIX = DiagnosticFactory0.create(ERROR, LONG_LITERAL_SUFFIX); DiagnosticFactory0 INT_LITERAL_OUT_OF_RANGE = DiagnosticFactory0.create(ERROR); DiagnosticFactory0 FLOAT_LITERAL_OUT_OF_RANGE = DiagnosticFactory0.create(ERROR); - DiagnosticFactory2 CONSTANT_EXPECTED_TYPE_MISMATCH = DiagnosticFactory2.create(ERROR); + DiagnosticFactory2 CONSTANT_EXPECTED_TYPE_MISMATCH = DiagnosticFactory2.create(ERROR); DiagnosticFactory0 INCORRECT_CHARACTER_LITERAL = DiagnosticFactory0.create(ERROR); DiagnosticFactory0 EMPTY_CHARACTER_LITERAL = DiagnosticFactory0.create(ERROR); DiagnosticFactory1 TOO_MANY_CHARACTERS_IN_CHARACTER_LITERAL = DiagnosticFactory1.create(ERROR); DiagnosticFactory1 ILLEGAL_ESCAPE = DiagnosticFactory1.create(ERROR, CUT_CHAR_QUOTES); - DiagnosticFactory1 NULL_FOR_NONNULL_TYPE = DiagnosticFactory1.create(ERROR); + DiagnosticFactory1 NULL_FOR_NONNULL_TYPE = DiagnosticFactory1.create(ERROR); DiagnosticFactory0 ILLEGAL_ESCAPE_SEQUENCE = DiagnosticFactory0.create(ERROR); // Casts and is-checks - DiagnosticFactory1 CANNOT_CHECK_FOR_ERASED = DiagnosticFactory1.create(ERROR); - DiagnosticFactory2 UNCHECKED_CAST = DiagnosticFactory2.create(WARNING); + DiagnosticFactory1 CANNOT_CHECK_FOR_ERASED = DiagnosticFactory1.create(ERROR); + DiagnosticFactory2 UNCHECKED_CAST = DiagnosticFactory2.create(WARNING); DiagnosticFactory0 USELESS_CAST = DiagnosticFactory0.create(WARNING, AS_TYPE); DiagnosticFactory0 CAST_NEVER_SUCCEEDS = DiagnosticFactory0.create(WARNING); DiagnosticFactory0 DYNAMIC_NOT_ALLOWED = DiagnosticFactory0.create(ERROR); DiagnosticFactory0 IS_ENUM_ENTRY = DiagnosticFactory0.create(ERROR); - DiagnosticFactory1 IMPLICIT_CAST_TO_UNIT_OR_ANY = DiagnosticFactory1.create(WARNING); + DiagnosticFactory1 IMPLICIT_CAST_TO_UNIT_OR_ANY = DiagnosticFactory1.create(WARNING); - DiagnosticFactory2 SMARTCAST_IMPOSSIBLE = DiagnosticFactory2.create(ERROR); + DiagnosticFactory2 SMARTCAST_IMPOSSIBLE = DiagnosticFactory2.create(ERROR); DiagnosticFactory0 USELESS_NULLABLE_CHECK = DiagnosticFactory0.create(WARNING, NULLABLE_TYPE); @@ -686,20 +686,20 @@ public interface Errors { // Type mismatch - DiagnosticFactory2 TYPE_MISMATCH = DiagnosticFactory2.create(ERROR); - DiagnosticFactory1 RETURN_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR); - DiagnosticFactory1 EXPECTED_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR); - DiagnosticFactory1 ASSIGNMENT_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR); - DiagnosticFactory2 TYPE_MISMATCH_IN_FOR_LOOP = DiagnosticFactory2.create(ERROR); - DiagnosticFactory1 TYPE_MISMATCH_IN_CONDITION = DiagnosticFactory1.create(ERROR); - DiagnosticFactory3 RESULT_TYPE_MISMATCH = DiagnosticFactory3.create(ERROR); + DiagnosticFactory2 TYPE_MISMATCH = DiagnosticFactory2.create(ERROR); + DiagnosticFactory1 RETURN_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR); + DiagnosticFactory1 EXPECTED_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR); + DiagnosticFactory1 ASSIGNMENT_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR); + DiagnosticFactory2 TYPE_MISMATCH_IN_FOR_LOOP = DiagnosticFactory2.create(ERROR); + DiagnosticFactory1 TYPE_MISMATCH_IN_CONDITION = DiagnosticFactory1.create(ERROR); + DiagnosticFactory3 RESULT_TYPE_MISMATCH = DiagnosticFactory3.create(ERROR); DiagnosticFactory0 TYPE_MISMATCH_IN_RANGE = DiagnosticFactory0.create(ERROR, WHEN_CONDITION_IN_RANGE); - DiagnosticFactory1 EXPECTED_PARAMETER_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR); - DiagnosticFactory2> EXPECTED_PARAMETERS_NUMBER_MISMATCH = + DiagnosticFactory1 EXPECTED_PARAMETER_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR); + DiagnosticFactory2> EXPECTED_PARAMETERS_NUMBER_MISMATCH = DiagnosticFactory2.create(ERROR, FUNCTION_PARAMETERS); - DiagnosticFactory2 INCOMPATIBLE_TYPES = DiagnosticFactory2.create(ERROR); + DiagnosticFactory2 INCOMPATIBLE_TYPES = DiagnosticFactory2.create(ERROR); DiagnosticFactory0 IMPLICIT_NOTHING_RETURN_TYPE = DiagnosticFactory0.create(WARNING); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java index 04c41833268..f276d26b42f 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java @@ -33,7 +33,7 @@ import org.jetbrains.kotlin.renderer.DescriptorRendererOptions; import org.jetbrains.kotlin.renderer.MultiRenderer; import org.jetbrains.kotlin.renderer.Renderer; import org.jetbrains.kotlin.resolve.varianceChecker.VarianceChecker.VarianceConflictDiagnosticData; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.util.MappedExtensionProvider; import org.jetbrains.kotlin.util.OperatorNameConventions; @@ -566,10 +566,10 @@ public class DefaultErrorMessages { MAP.put(FUNCTION_EXPECTED, "Expression ''{0}''{1} cannot be invoked as a function. " + "The function '" + OperatorNameConventions.INVOKE.asString() + "()' is not found", - ELEMENT_TEXT, new Renderer() { + ELEMENT_TEXT, new Renderer() { @NotNull @Override - public String render(@NotNull KtType type) { + public String render(@NotNull KotlinType type) { if (type.isError()) return ""; return " of type '" + RENDER_TYPE.render(type) + "'"; } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/Renderers.kt b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/Renderers.kt index ad33e953c15..a6812e862c1 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/Renderers.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/Renderers.kt @@ -41,7 +41,7 @@ import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.Constrain import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind.RECEIVER_POSITION import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind.VALUE_PARAMETER_POSITION import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeUtils import org.jetbrains.kotlin.types.Variance import org.jetbrains.kotlin.types.checker.KotlinTypeChecker @@ -93,7 +93,7 @@ public object Renderers { public val RENDER_CLASS_OR_OBJECT_NAME: Renderer = Renderer { it.renderKindWithName() } - public val RENDER_TYPE: Renderer = Renderer { DescriptorRenderer.FQ_NAMES_IN_TYPES.renderType(it) } + public val RENDER_TYPE: Renderer = Renderer { DescriptorRenderer.FQ_NAMES_IN_TYPES.renderType(it) } public val RENDER_POSITION_VARIANCE: Renderer = Renderer { variance: Variance -> @@ -179,7 +179,7 @@ public object Renderers { val receiverType = DescriptorUtils.getReceiverParameterType(substitutedDescriptor.getExtensionReceiverParameter()) val errorPositions = Sets.newHashSet() - val parameterTypes = Lists.newArrayList() + val parameterTypes = Lists.newArrayList() for (valueParameterDescriptor in substitutedDescriptor.getValueParameters()) { parameterTypes.add(valueParameterDescriptor.getType()) if (valueParameterDescriptor.getIndex() >= inferenceErrorData.valueArgumentsTypes.size()) continue @@ -279,7 +279,7 @@ public object Renderers { .table(newTable() .descriptor(inferenceErrorData.descriptor)) - var violatedUpperBound: KtType? = null + var violatedUpperBound: KotlinType? = null for (upperBound in typeParameterDescriptor.getUpperBounds()) { val upperBoundWithSubstitutedInferredTypes = systemWithoutWeakConstraints.getResultingSubstitutor().substitute(upperBound, Variance.INVARIANT) if (upperBoundWithSubstitutedInferredTypes != null @@ -356,9 +356,9 @@ public object Renderers { }.toString() } - private fun renderTypes(types: Collection) = StringUtil.join(types, { RENDER_TYPE.render(it) }, ", ") + private fun renderTypes(types: Collection) = StringUtil.join(types, { RENDER_TYPE.render(it) }, ", ") - public val RENDER_COLLECTION_OF_TYPES: Renderer> = Renderer { renderTypes(it) } + public val RENDER_COLLECTION_OF_TYPES: Renderer> = Renderer { renderTypes(it) } private fun renderConstraintSystem(constraintSystem: ConstraintSystem, renderTypeBounds: Renderer): String { val typeVariables = constraintSystem.getTypeVariables() diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/TabledDescriptorRenderer.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/TabledDescriptorRenderer.java index ddf881963e3..431dee923fa 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/TabledDescriptorRenderer.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/TabledDescriptorRenderer.java @@ -29,7 +29,7 @@ import org.jetbrains.kotlin.diagnostics.rendering.TabledDescriptorRenderer.TextR import org.jetbrains.kotlin.renderer.DescriptorRenderer; import org.jetbrains.kotlin.renderer.Renderer; import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPosition; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import java.util.Iterator; import java.util.List; @@ -50,11 +50,11 @@ public class TabledDescriptorRenderer { } public static class FunctionArgumentsRow implements TableRow { - public final KtType receiverType; - public final List argumentTypes; + public final KotlinType receiverType; + public final List argumentTypes; public final Predicate isErrorPosition; - public FunctionArgumentsRow(KtType receiverType, List argumentTypes, Predicate isErrorPosition) { + public FunctionArgumentsRow(KotlinType receiverType, List argumentTypes, Predicate isErrorPosition) { this.receiverType = receiverType; this.argumentTypes = argumentTypes; this.isErrorPosition = isErrorPosition; @@ -68,13 +68,13 @@ public class TabledDescriptorRenderer { return this; } - public TableRenderer functionArgumentTypeList(@Nullable KtType receiverType, @NotNull List argumentTypes) { + public TableRenderer functionArgumentTypeList(@Nullable KotlinType receiverType, @NotNull List argumentTypes) { return functionArgumentTypeList(receiverType, argumentTypes, Predicates.alwaysFalse()); } - public TableRenderer functionArgumentTypeList(@Nullable KtType receiverType, - @NotNull List argumentTypes, + public TableRenderer functionArgumentTypeList(@Nullable KotlinType receiverType, + @NotNull List argumentTypes, @NotNull Predicate isErrorPosition) { rows.add(new FunctionArgumentsRow(receiverType, argumentTypes, isErrorPosition)); return this; @@ -156,7 +156,7 @@ public class TabledDescriptorRenderer { } @NotNull - public Renderer getTypeRenderer() { + public Renderer getTypeRenderer() { return Renderers.RENDER_TYPE; } @@ -183,7 +183,7 @@ public class TabledDescriptorRenderer { } } - private void renderFunctionArguments(@Nullable KtType receiverType, @NotNull List argumentTypes, StringBuilder result) { + private void renderFunctionArguments(@Nullable KotlinType receiverType, @NotNull List argumentTypes, StringBuilder result) { boolean hasReceiver = receiverType != null; if (hasReceiver) { result.append("receiver: "); @@ -196,8 +196,8 @@ public class TabledDescriptorRenderer { } result.append("("); - for (Iterator iterator = argumentTypes.iterator(); iterator.hasNext(); ) { - KtType argumentType = iterator.next(); + for (Iterator iterator = argumentTypes.iterator(); iterator.hasNext(); ) { + KotlinType argumentType = iterator.next(); String renderedArgument = getTypeRenderer().render(argumentType); result.append(renderedArgument); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/idea/MainFunctionDetector.java b/compiler/frontend/src/org/jetbrains/kotlin/idea/MainFunctionDetector.java index a97edca4dcb..355734551eb 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/idea/MainFunctionDetector.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/idea/MainFunctionDetector.java @@ -28,7 +28,7 @@ import org.jetbrains.kotlin.psi.KtNamedFunction; import org.jetbrains.kotlin.resolve.BindingContext; import org.jetbrains.kotlin.resolve.DescriptorUtils; import org.jetbrains.kotlin.resolve.annotations.AnnotationUtilKt; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.TypeProjection; import org.jetbrains.kotlin.types.Variance; @@ -89,13 +89,13 @@ public class MainFunctionDetector { if (parameters.size() != 1) return false; ValueParameterDescriptor parameter = parameters.get(0); - KtType parameterType = parameter.getType(); + KotlinType parameterType = parameter.getType(); if (!KotlinBuiltIns.isArray(parameterType)) return false; List typeArguments = parameterType.getArguments(); if (typeArguments.size() != 1) return false; - KtType typeArgument = typeArguments.get(0).getType(); + KotlinType typeArgument = typeArguments.get(0).getType(); if (!KotlinBuiltIns.isString(typeArgument)) { return false; } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/KtCodeFragment.kt b/compiler/frontend/src/org/jetbrains/kotlin/psi/KtCodeFragment.kt index 0871d17fc1b..14e9d9249ee 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/KtCodeFragment.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/KtCodeFragment.kt @@ -25,7 +25,7 @@ import com.intellij.psi.search.GlobalSearchScope import com.intellij.psi.tree.IElementType import com.intellij.testFramework.LightVirtualFile import org.jetbrains.kotlin.idea.KotlinFileType -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.utils.addToStdlib.check import java.util.* @@ -131,7 +131,7 @@ public abstract class KtCodeFragment( companion object { public val IMPORT_SEPARATOR: String = "," - public val RUNTIME_TYPE_EVALUATOR: Key> = Key.create("RUNTIME_TYPE_EVALUATOR") + public val RUNTIME_TYPE_EVALUATOR: Key> = Key.create("RUNTIME_TYPE_EVALUATOR") public val ADDITIONAL_CONTEXT_FOR_LAMBDA: Key> = Key.create("ADDITIONAL_CONTEXT_FOR_LAMBDA") } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/codeFragmentUtil.kt b/compiler/frontend/src/org/jetbrains/kotlin/psi/codeFragmentUtil.kt index 80e171f2ff5..7c9f74fc816 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/codeFragmentUtil.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/codeFragmentUtil.kt @@ -20,7 +20,7 @@ import com.intellij.openapi.util.Key import org.jetbrains.kotlin.psi.KtCodeFragment import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.psi.KtTypeReference -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType public val SUPPRESS_DIAGNOSTICS_IN_DEBUG_MODE: Key = Key.create("SUPPRESS_DIAGNOSTICS_IN_DEBUG_MODE") @@ -36,10 +36,10 @@ public var KtFile.suppressDiagnosticsInDebugMode: Boolean public val DEBUG_TYPE_REFERENCE_STRING: String = "DebugTypeKotlinRulezzzz" -public val DEBUG_TYPE_INFO: Key = Key.create("DEBUG_TYPE_INFO") -public var KtTypeReference.debugTypeInfo: KtType? +public val DEBUG_TYPE_INFO: Key = Key.create("DEBUG_TYPE_INFO") +public var KtTypeReference.debugTypeInfo: KotlinType? get() = getUserData(DEBUG_TYPE_INFO) - set(type: KtType?) { + set(type: KotlinType?) { if (type != null && this.getText() == DEBUG_TYPE_REFERENCE_STRING) { putUserData(DEBUG_TYPE_INFO, type) } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/AllUnderImportsScope.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/AllUnderImportsScope.kt index 6dde8e3f7b6..a9acd08360e 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/AllUnderImportsScope.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/AllUnderImportsScope.kt @@ -21,7 +21,7 @@ import org.jetbrains.kotlin.incremental.components.LookupLocation import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter import org.jetbrains.kotlin.resolve.scopes.KtScope -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.utils.Printer class AllUnderImportsScope(descriptor: DeclarationDescriptor) : KtScope { @@ -51,19 +51,19 @@ class AllUnderImportsScope(descriptor: DeclarationDescriptor) : KtScope { return scopes.flatMap { it.getFunctions(name, location) } } - override fun getSyntheticExtensionProperties(receiverTypes: Collection, name: Name, location: LookupLocation): Collection { + override fun getSyntheticExtensionProperties(receiverTypes: Collection, name: Name, location: LookupLocation): Collection { return scopes.flatMap { it.getSyntheticExtensionProperties(receiverTypes, name, location) } } - override fun getSyntheticExtensionFunctions(receiverTypes: Collection, name: Name, location: LookupLocation): Collection { + override fun getSyntheticExtensionFunctions(receiverTypes: Collection, name: Name, location: LookupLocation): Collection { return scopes.flatMap { it.getSyntheticExtensionFunctions(receiverTypes, name, location) } } - override fun getSyntheticExtensionProperties(receiverTypes: Collection): Collection { + override fun getSyntheticExtensionProperties(receiverTypes: Collection): Collection { return scopes.flatMap { it.getSyntheticExtensionProperties(receiverTypes) } } - override fun getSyntheticExtensionFunctions(receiverTypes: Collection): Collection { + override fun getSyntheticExtensionFunctions(receiverTypes: Collection): Collection { return scopes.flatMap { it.getSyntheticExtensionFunctions(receiverTypes) } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnalyzerScriptParameter.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnalyzerScriptParameter.java index a2c798d8b14..8922ae826f3 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnalyzerScriptParameter.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnalyzerScriptParameter.java @@ -18,15 +18,15 @@ package org.jetbrains.kotlin.resolve; import org.jetbrains.annotations.NotNull; import org.jetbrains.kotlin.name.Name; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; public class AnalyzerScriptParameter { @NotNull private final Name name; @NotNull - private final KtType type; + private final KotlinType type; - public AnalyzerScriptParameter(@NotNull Name name, @NotNull KtType type) { + public AnalyzerScriptParameter(@NotNull Name name, @NotNull KotlinType type) { this.name = name; this.type = type; } @@ -37,7 +37,7 @@ public class AnalyzerScriptParameter { } @NotNull - public KtType getType() { + public KotlinType getType() { return type; } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationChecker.kt index c5660bb5174..2b701e14337 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationChecker.kt @@ -25,7 +25,7 @@ import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.getAnnotationEntries import org.jetbrains.kotlin.resolve.constants.ArrayValue import org.jetbrains.kotlin.resolve.constants.EnumValue -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeUtils import org.jetbrains.kotlin.resolve.descriptorUtil.isRepeatableAnnotation import org.jetbrains.kotlin.descriptors.annotations.KotlinTarget.* @@ -71,7 +71,7 @@ public class AnnotationChecker(private val additionalCheckers: Iterable, actualTargets: TargetList, trace: BindingTrace) { - val entryTypesWithAnnotations = hashMapOf>() + val entryTypesWithAnnotations = hashMapOf>() for (entry in entries) { checkAnnotationEntry(entry, actualTargets, trace) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationResolver.java index f58f2aa48b0..2e22dfb4d19 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationResolver.java @@ -36,7 +36,7 @@ import org.jetbrains.kotlin.resolve.scopes.LexicalScope; import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue; import org.jetbrains.kotlin.storage.StorageManager; import org.jetbrains.kotlin.types.ErrorUtils; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import javax.inject.Inject; import java.util.ArrayList; @@ -147,13 +147,13 @@ public class AnnotationResolver { } @NotNull - public KtType resolveAnnotationType(@NotNull LexicalScope scope, @NotNull KtAnnotationEntry entryElement, @NotNull BindingTrace trace) { + public KotlinType resolveAnnotationType(@NotNull LexicalScope scope, @NotNull KtAnnotationEntry entryElement, @NotNull BindingTrace trace) { KtTypeReference typeReference = entryElement.getTypeReference(); if (typeReference == null) { return ErrorUtils.createErrorType("No type reference: " + entryElement.getText()); } - KtType type = typeResolver.resolveType(scope, typeReference, trace, true); + KotlinType type = typeResolver.resolveType(scope, typeReference, trace, true); if (!(type.getConstructor().getDeclarationDescriptor() instanceof ClassDescriptor)) { return ErrorUtils.createErrorType("Not an annotation: " + type); } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/BindingContext.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/BindingContext.java index de37571c90a..fff233154d0 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/BindingContext.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/BindingContext.java @@ -37,7 +37,7 @@ import org.jetbrains.kotlin.resolve.scopes.KtScope; import org.jetbrains.kotlin.resolve.scopes.LexicalScope; import org.jetbrains.kotlin.resolve.scopes.receivers.Qualifier; import org.jetbrains.kotlin.types.DeferredType; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.expressions.CaptureKind; import org.jetbrains.kotlin.types.expressions.JetTypeInfo; import org.jetbrains.kotlin.types.expressions.PreliminaryDeclarationVisitor; @@ -77,7 +77,7 @@ public interface BindingContext { @Nullable @Override - public KtType getType(@NotNull KtExpression expression) { + public KotlinType getType(@NotNull KtExpression expression) { return null; } @@ -91,10 +91,10 @@ public interface BindingContext { WritableSlice> COMPILE_TIME_VALUE = Slices.createSimpleSlice(); - WritableSlice TYPE = Slices.createSimpleSlice(); + WritableSlice TYPE = Slices.createSimpleSlice(); WritableSlice EXPRESSION_TYPE_INFO = new BasicWritableSlice(DO_NOTHING); - WritableSlice EXPECTED_EXPRESSION_TYPE = new BasicWritableSlice(DO_NOTHING); - WritableSlice EXPECTED_RETURN_TYPE = new BasicWritableSlice(DO_NOTHING); + WritableSlice EXPECTED_EXPRESSION_TYPE = new BasicWritableSlice(DO_NOTHING); + WritableSlice EXPECTED_RETURN_TYPE = new BasicWritableSlice(DO_NOTHING); WritableSlice DATAFLOW_INFO_AFTER_CONDITION = Slices.createSimpleSlice(); /** @@ -131,7 +131,7 @@ public interface BindingContext { WritableSlice> INDEXED_LVALUE_GET = Slices.createSimpleSlice(); WritableSlice> INDEXED_LVALUE_SET = Slices.createSimpleSlice(); - WritableSlice SMARTCAST = Slices.createSimpleSlice(); + WritableSlice SMARTCAST = Slices.createSimpleSlice(); WritableSlice EXHAUSTIVE_WHEN = Slices.createSimpleSlice(); @@ -256,7 +256,7 @@ public interface BindingContext { ImmutableMap getSliceContents(@NotNull ReadOnlySlice slice); @Nullable - KtType getType(@NotNull KtExpression expression); + KotlinType getType(@NotNull KtExpression expression); void addOwnDataTo(@NotNull BindingTrace trace, boolean commitDiagnostics); } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/BindingContextUtils.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/BindingContextUtils.java index 7bd3fc39b38..25fc676ac6f 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/BindingContextUtils.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/BindingContextUtils.java @@ -31,7 +31,7 @@ import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall; import org.jetbrains.kotlin.resolve.calls.model.VariableAsFunctionResolvedCall; import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo; import org.jetbrains.kotlin.resolve.diagnostics.MutableDiagnosticsWithSuppression; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.TypeUtils; import org.jetbrains.kotlin.types.expressions.JetTypeInfo; import org.jetbrains.kotlin.types.expressions.typeInfoFactory.TypeInfoFactoryKt; @@ -81,11 +81,11 @@ public class BindingContextUtils { } @NotNull - public static KtType getTypeNotNull( + public static KotlinType getTypeNotNull( @NotNull BindingContext bindingContext, @NotNull KtExpression expression ) { - KtType result = bindingContext.getType(expression); + KotlinType result = bindingContext.getType(expression); if (result == null) { throw new IllegalStateException("Type must be not null for " + expression); } @@ -140,8 +140,8 @@ public class BindingContextUtils { } @Nullable - public static KtType updateRecordedType( - @Nullable KtType type, + public static KotlinType updateRecordedType( + @Nullable KotlinType type, @NotNull KtExpression expression, @NotNull BindingTrace trace, boolean shouldBeMadeNullable diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/BindingTrace.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/BindingTrace.java index ce4578ea1ce..975a6427823 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/BindingTrace.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/BindingTrace.java @@ -20,7 +20,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.diagnostics.DiagnosticSink; import org.jetbrains.kotlin.psi.KtExpression; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.util.slicedMap.ReadOnlySlice; import org.jetbrains.kotlin.util.slicedMap.WritableSlice; @@ -47,11 +47,11 @@ public interface BindingTrace extends DiagnosticSink { * Expression type should be taken from EXPRESSION_TYPE_INFO slice */ @Nullable - KtType getType(@NotNull KtExpression expression); + KotlinType getType(@NotNull KtExpression expression); /** * Expression type should be recorded into EXPRESSION_TYPE_INFO slice * (either updated old or a new one) */ - void recordType(@NotNull KtExpression expression, @Nullable KtType type); + void recordType(@NotNull KtExpression expression, @Nullable KotlinType type); } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/BindingTraceContext.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/BindingTraceContext.java index fbf2f049624..f8edef58ff6 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/BindingTraceContext.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/BindingTraceContext.java @@ -24,7 +24,7 @@ import org.jetbrains.kotlin.diagnostics.Diagnostic; import org.jetbrains.kotlin.psi.KtExpression; import org.jetbrains.kotlin.resolve.diagnostics.Diagnostics; import org.jetbrains.kotlin.resolve.diagnostics.MutableDiagnosticsWithSuppression; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.expressions.JetTypeInfo; import org.jetbrains.kotlin.types.expressions.typeInfoFactory.TypeInfoFactoryKt; import org.jetbrains.kotlin.util.slicedMap.*; @@ -67,7 +67,7 @@ public class BindingTraceContext implements BindingTrace { @Nullable @Override - public KtType getType(@NotNull KtExpression expression) { + public KotlinType getType(@NotNull KtExpression expression) { return BindingTraceContext.this.getType(expression); } @@ -131,13 +131,13 @@ public class BindingTraceContext implements BindingTrace { @Nullable @Override - public KtType getType(@NotNull KtExpression expression) { + public KotlinType getType(@NotNull KtExpression expression) { JetTypeInfo typeInfo = get(BindingContext.EXPRESSION_TYPE_INFO, expression); return typeInfo != null ? typeInfo.getType() : null; } @Override - public void recordType(@NotNull KtExpression expression, @Nullable KtType type) { + public void recordType(@NotNull KtExpression expression, @Nullable KotlinType type) { JetTypeInfo typeInfo = get(BindingContext.EXPRESSION_TYPE_INFO, expression); typeInfo = typeInfo != null ? typeInfo.replaceType(type) : TypeInfoFactoryKt.createTypeInfo(type); record(BindingContext.EXPRESSION_TYPE_INFO, expression, typeInfo); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/BodyResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/BodyResolver.java index 562b55781a4..b0d8829e6a4 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/BodyResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/BodyResolver.java @@ -262,10 +262,10 @@ public class BodyResolver { : FunctionDescriptorUtil.getFunctionInnerScope(scopeForSupertypeResolution, primaryConstructor, trace); final ExpressionTypingServices typeInferrer = expressionTypingServices; // TODO : flow - final Map supertypes = Maps.newLinkedHashMap(); + final Map supertypes = Maps.newLinkedHashMap(); final ResolvedCall[] primaryConstructorDelegationCall = new ResolvedCall[1]; KtVisitorVoid visitor = new KtVisitorVoid() { - private void recordSupertype(KtTypeReference typeReference, KtType supertype) { + private void recordSupertype(KtTypeReference typeReference, KotlinType supertype) { if (supertype == null) return; supertypes.put(typeReference, supertype); } @@ -275,7 +275,7 @@ public class BodyResolver { if (descriptor.getKind() == ClassKind.INTERFACE) { trace.report(DELEGATION_IN_INTERFACE.on(specifier)); } - KtType supertype = trace.getBindingContext().get(BindingContext.TYPE, specifier.getTypeReference()); + KotlinType supertype = trace.getBindingContext().get(BindingContext.TYPE, specifier.getTypeReference()); recordSupertype(specifier.getTypeReference(), supertype); if (supertype != null) { DeclarationDescriptor declarationDescriptor = supertype.getConstructor().getDeclarationDescriptor(); @@ -289,7 +289,7 @@ public class BodyResolver { KtExpression delegateExpression = specifier.getDelegateExpression(); if (delegateExpression != null) { LexicalScope scope = scopeForConstructor == null ? scopeForMemberResolution : scopeForConstructor; - KtType expectedType = supertype != null ? supertype : NO_EXPECTED_TYPE; + KotlinType expectedType = supertype != null ? supertype : NO_EXPECTED_TYPE; typeInferrer.getType(scope, delegateExpression, expectedType, outerDataFlowInfo, trace); } if (primaryConstructor == null) { @@ -317,7 +317,7 @@ public class BodyResolver { trace, scopeForConstructor, CallMaker.makeCall(ReceiverValue.NO_RECEIVER, null, call), NO_EXPECTED_TYPE, outerDataFlowInfo, false); if (results.isSuccess()) { - KtType supertype = results.getResultingDescriptor().getReturnType(); + KotlinType supertype = results.getResultingDescriptor().getReturnType(); recordSupertype(typeReference, supertype); ClassDescriptor classDescriptor = TypeUtils.getClassDescriptor(supertype); if (classDescriptor != null) { @@ -342,7 +342,7 @@ public class BodyResolver { @Override public void visitDelegationToSuperClassSpecifier(@NotNull KtDelegatorToSuperClass specifier) { KtTypeReference typeReference = specifier.getTypeReference(); - KtType supertype = trace.getBindingContext().get(BindingContext.TYPE, typeReference); + KotlinType supertype = trace.getBindingContext().get(BindingContext.TYPE, typeReference); recordSupertype(typeReference, supertype); if (supertype == null) return; ClassDescriptor superClass = TypeUtils.getClassDescriptor(supertype); @@ -419,15 +419,15 @@ public class BodyResolver { private void checkSupertypeList( @NotNull ClassDescriptor supertypeOwner, - @NotNull Map supertypes, + @NotNull Map supertypes, @NotNull KtClassOrObject jetClass ) { Set allowedFinalSupertypes = getAllowedFinalSupertypes(supertypeOwner, jetClass); Set typeConstructors = Sets.newHashSet(); boolean classAppeared = false; - for (Map.Entry entry : supertypes.entrySet()) { + for (Map.Entry entry : supertypes.entrySet()) { KtTypeReference typeReference = entry.getKey(); - KtType supertype = entry.getValue(); + KotlinType supertype = entry.getValue(); KtTypeElement typeElement = typeReference.getTypeElement(); if (typeElement instanceof KtFunctionType) { @@ -709,7 +709,7 @@ public class BodyResolver { LexicalScope accessorScope = JetScopeUtils.makeScopeForPropertyAccessor( propertyDescriptor, parentScopeForAccessor, trace); - KtType delegateType = delegatedPropertyResolver.resolveDelegateExpression( + KotlinType delegateType = delegatedPropertyResolver.resolveDelegateExpression( delegateExpression, jetProperty, propertyDescriptor, propertyDeclarationInnerScope, accessorScope, trace, outerDataFlowInfo); @@ -734,7 +734,7 @@ public class BodyResolver { ) { LexicalScope propertyDeclarationInnerScope = JetScopeUtils.getPropertyDeclarationInnerScopeForInitializer( propertyDescriptor, scope, propertyDescriptor.getTypeParameters(), null, trace); - KtType expectedTypeForInitializer = property.getTypeReference() != null ? propertyDescriptor.getType() : NO_EXPECTED_TYPE; + KotlinType expectedTypeForInitializer = property.getTypeReference() != null ? propertyDescriptor.getType() : NO_EXPECTED_TYPE; if (propertyDescriptor.getCompileTimeInitializer() == null) { expressionTypingServices.getType(propertyDeclarationInnerScope, initializer, expectedTypeForInitializer, outerDataFlowInfo, trace); @@ -850,7 +850,7 @@ public class BodyResolver { valueParameterResolver.resolveValueParameters(valueParameters, valueParameterDescriptors, scope, outerDataFlowInfo, trace); } - private static void computeDeferredType(KtType type) { + private static void computeDeferredType(KotlinType type) { // handle type inference loop: function or property body contains a reference to itself // fun f() = { f() } // val x = x diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/CompileTimeConstantUtils.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/CompileTimeConstantUtils.java index c15033a25d6..25b7bbccdc5 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/CompileTimeConstantUtils.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/CompileTimeConstantUtils.java @@ -35,7 +35,7 @@ import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant; import org.jetbrains.kotlin.resolve.constants.ConstantValue; import org.jetbrains.kotlin.resolve.constants.TypedCompileTimeConstant; import org.jetbrains.kotlin.resolve.constants.evaluate.ConstantExpressionEvaluator; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.TypeProjection; import org.jetbrains.kotlin.types.TypeUtils; @@ -60,7 +60,7 @@ public class CompileTimeConstantUtils { for (KtParameter parameter : parameters) { VariableDescriptor parameterDescriptor = trace.getBindingContext().get(VALUE_PARAMETER, parameter); if (parameterDescriptor == null) continue; - KtType parameterType = parameterDescriptor.getType(); + KotlinType parameterType = parameterDescriptor.getType(); KtTypeReference typeReference = parameter.getTypeReference(); if (typeReference != null) { if (parameterType.isMarkedNullable()) { @@ -73,7 +73,7 @@ public class CompileTimeConstantUtils { } } - private static boolean isAcceptableTypeForAnnotationParameter(@NotNull KtType parameterType) { + private static boolean isAcceptableTypeForAnnotationParameter(@NotNull KotlinType parameterType) { ClassDescriptor typeDescriptor = TypeUtils.getClassDescriptor(parameterType); if (typeDescriptor == null) { return false; @@ -91,7 +91,7 @@ public class CompileTimeConstantUtils { if (KotlinBuiltIns.isArray(parameterType)) { List arguments = parameterType.getArguments(); if (arguments.size() == 1) { - KtType arrayType = arguments.get(0).getType(); + KotlinType arrayType = arguments.get(0).getType(); if (arrayType.isMarkedNullable()) { return false; } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/CompositeBindingContext.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/CompositeBindingContext.kt index 4bad29233af..26baca776ae 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/CompositeBindingContext.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/CompositeBindingContext.kt @@ -24,12 +24,12 @@ import com.intellij.psi.PsiElement import com.intellij.openapi.util.ModificationTracker import org.jetbrains.kotlin.psi.KtExpression import org.jetbrains.kotlin.resolve.diagnostics.Diagnostics -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType public class CompositeBindingContext private constructor( private val delegates: List ) : BindingContext { - override fun getType(expression: KtExpression): KtType? { + override fun getType(expression: KtExpression): KotlinType? { return delegates.asSequence().map { it.getType(expression) }.firstOrNull { it != null } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/ControlFlowAnalyzer.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/ControlFlowAnalyzer.java index 3fcb7edfcbf..492b5ae9a33 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/ControlFlowAnalyzer.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/ControlFlowAnalyzer.java @@ -24,7 +24,7 @@ import org.jetbrains.kotlin.descriptors.PropertyAccessorDescriptor; import org.jetbrains.kotlin.descriptors.PropertyDescriptor; import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor; import org.jetbrains.kotlin.psi.*; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import java.util.Map; @@ -52,7 +52,7 @@ public class ControlFlowAnalyzer { for (Map.Entry entry : c.getFunctions().entrySet()) { KtNamedFunction function = entry.getKey(); SimpleFunctionDescriptor functionDescriptor = entry.getValue(); - KtType expectedReturnType = !function.hasBlockBody() && !function.hasDeclaredReturnType() + KotlinType expectedReturnType = !function.hasBlockBody() && !function.hasDeclaredReturnType() ? NO_EXPECTED_TYPE : functionDescriptor.getReturnType(); checkFunction(c, function, expectedReturnType); @@ -87,12 +87,12 @@ public class ControlFlowAnalyzer { ? propertyDescriptor.getGetter() : propertyDescriptor.getSetter(); assert accessorDescriptor != null : "no property accessor descriptor " + accessor.getText(); - KtType returnType = accessorDescriptor.getReturnType(); + KotlinType returnType = accessorDescriptor.getReturnType(); checkFunction(c, accessor, returnType); } } - private void checkFunction(@NotNull BodiesResolveContext c, @NotNull KtDeclarationWithBody function, @Nullable KtType expectedReturnType) { + private void checkFunction(@NotNull BodiesResolveContext c, @NotNull KtDeclarationWithBody function, @Nullable KotlinType expectedReturnType) { if (!function.hasBody()) return; JetFlowInformationProvider flowInformationProvider = new JetFlowInformationProvider(function, trace); if (c.getTopDownAnalysisMode().isLocalDeclarations()) { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.java index ad9d0f249cc..1073bf92da2 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.java @@ -168,7 +168,7 @@ public class DeclarationsChecker { private void checkBoundsForTypeInClassHeader(@Nullable KtTypeReference typeReference) { if (typeReference != null) { - KtType type = trace.getBindingContext().get(TYPE, typeReference); + KotlinType type = trace.getBindingContext().get(TYPE, typeReference); if (type != null) { DescriptorResolver.checkBounds(typeReference, type, trace); } @@ -177,7 +177,7 @@ public class DeclarationsChecker { private void checkFinalUpperBounds(@Nullable KtTypeReference typeReference) { if (typeReference != null) { - KtType type = trace.getBindingContext().get(TYPE, typeReference); + KotlinType type = trace.getBindingContext().get(TYPE, typeReference); if (type != null) { DescriptorResolver.checkUpperBoundType(typeReference, type, trace); } @@ -213,7 +213,7 @@ public class DeclarationsChecker { TypeParameterDescriptor typeParameterDescriptor = (TypeParameterDescriptor) declarationDescriptor; // Immediate arguments of supertypes cannot be projected - Set conflictingTypes = Sets.newLinkedHashSet(); + Set conflictingTypes = Sets.newLinkedHashSet(); for (TypeProjection projection : projections) { conflictingTypes.add(projection.getType()); } @@ -254,7 +254,7 @@ public class DeclarationsChecker { int i = 0; for (TypeParameterDescriptor typeParameterDescriptor : classDescriptor.getTypeConstructor().getParameters()) { if (i >= typeParameterList.size()) return; - for (KtType upperBound : typeParameterDescriptor.getUpperBounds()) { + for (KotlinType upperBound : typeParameterDescriptor.getUpperBounds()) { EffectiveVisibility upperBoundVisibility = EffectiveVisibility.Companion.forType(upperBound); if (!upperBoundVisibility.sameOrMorePermissive(classVisibility)) { KtTypeParameter typeParameter = typeParameterList.get(i); @@ -271,7 +271,7 @@ public class DeclarationsChecker { boolean isInterface = classDescriptor.getKind() == ClassKind.INTERFACE; List delegationList = klass.getDelegationSpecifiers(); int i = -1; - for (KtType superType : classDescriptor.getTypeConstructor().getSupertypes()) { + for (KotlinType superType : classDescriptor.getTypeConstructor().getSupertypes()) { i++; if (i >= delegationList.size()) return; ClassDescriptor superDescriptor = TypeUtils.getClassDescriptor(superType); @@ -294,10 +294,10 @@ public class DeclarationsChecker { } } - private static void removeDuplicateTypes(Set conflictingTypes) { - for (Iterator iterator = conflictingTypes.iterator(); iterator.hasNext(); ) { - KtType type = iterator.next(); - for (KtType otherType : conflictingTypes) { + private static void removeDuplicateTypes(Set conflictingTypes) { + for (Iterator iterator = conflictingTypes.iterator(); iterator.hasNext(); ) { + KotlinType type = iterator.next(); + for (KotlinType otherType : conflictingTypes) { boolean subtypeOf = KotlinTypeChecker.DEFAULT.equalTypes(type, otherType); if (type != otherType && subtypeOf) { iterator.remove(); @@ -524,9 +524,9 @@ public class DeclarationsChecker { ReceiverParameterDescriptor receiverParameter = descriptor.getExtensionReceiverParameter(); if (receiverParameter == null) return false; - return TypeUtils.containsSpecialType(receiverParameter.getType(), new Function1() { + return TypeUtils.containsSpecialType(receiverParameter.getType(), new Function1() { @Override - public Boolean invoke(KtType type) { + public Boolean invoke(KotlinType type) { return parameter.equals(type.getConstructor().getDeclarationDescriptor()); } }); @@ -545,7 +545,7 @@ public class DeclarationsChecker { boolean returnTypeIsNullable = true; boolean returnTypeIsPrimitive = true; - KtType returnType = propertyDescriptor.getReturnType(); + KotlinType returnType = propertyDescriptor.getReturnType(); if (returnType != null) { returnTypeIsNullable = TypeUtils.isNullableType(returnType); returnTypeIsPrimitive = KotlinBuiltIns.isPrimitiveType(returnType); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DelegatedPropertyResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DelegatedPropertyResolver.java index f27483c5a7c..b48260e3795 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DelegatedPropertyResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DelegatedPropertyResolver.java @@ -37,7 +37,7 @@ import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver; import org.jetbrains.kotlin.resolve.validation.OperatorValidator; import org.jetbrains.kotlin.resolve.validation.SymbolUsageValidator; import org.jetbrains.kotlin.types.DeferredType; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.TypeUtils; import org.jetbrains.kotlin.types.checker.KotlinTypeChecker; import org.jetbrains.kotlin.types.expressions.ExpressionTypingContext; @@ -83,10 +83,10 @@ public class DelegatedPropertyResolver { } @Nullable - public KtType getDelegatedPropertyGetMethodReturnType( + public KotlinType getDelegatedPropertyGetMethodReturnType( @NotNull PropertyDescriptor propertyDescriptor, @NotNull KtExpression delegateExpression, - @NotNull KtType delegateType, + @NotNull KotlinType delegateType, @NotNull BindingTrace trace, @NotNull LexicalScope scope ) { @@ -99,13 +99,13 @@ public class DelegatedPropertyResolver { public void resolveDelegatedPropertyGetMethod( @NotNull PropertyDescriptor propertyDescriptor, @NotNull KtExpression delegateExpression, - @NotNull KtType delegateType, + @NotNull KotlinType delegateType, @NotNull BindingTrace trace, @NotNull LexicalScope scope ) { - KtType returnType = getDelegatedPropertyGetMethodReturnType( + KotlinType returnType = getDelegatedPropertyGetMethodReturnType( propertyDescriptor, delegateExpression, delegateType, trace, scope); - KtType propertyType = propertyDescriptor.getType(); + KotlinType propertyType = propertyDescriptor.getType(); /* Do not check return type of get() method of delegate for properties with DeferredType because property type is taken from it */ if (!(propertyType instanceof DeferredType) && returnType != null && !KotlinTypeChecker.DEFAULT.isSubtypeOf(returnType, propertyType)) { @@ -119,7 +119,7 @@ public class DelegatedPropertyResolver { public void resolveDelegatedPropertySetMethod( @NotNull PropertyDescriptor propertyDescriptor, @NotNull KtExpression delegateExpression, - @NotNull KtType delegateType, + @NotNull KotlinType delegateType, @NotNull BindingTrace trace, @NotNull LexicalScope scope ) { @@ -134,7 +134,7 @@ public class DelegatedPropertyResolver { public void resolveDelegatedPropertyPDMethod( @NotNull PropertyDescriptor propertyDescriptor, @NotNull KtExpression delegateExpression, - @NotNull KtType delegateType, + @NotNull KotlinType delegateType, @NotNull BindingTrace trace, @NotNull LexicalScope scope ) { @@ -172,7 +172,7 @@ public class DelegatedPropertyResolver { private void resolveDelegatedPropertyConventionMethod( @NotNull PropertyDescriptor propertyDescriptor, @NotNull KtExpression delegateExpression, - @NotNull KtType delegateType, + @NotNull KotlinType delegateType, @NotNull BindingTrace trace, @NotNull LexicalScope scope, boolean isGet @@ -231,7 +231,7 @@ public class DelegatedPropertyResolver { public OverloadResolutionResults getDelegatedPropertyConventionMethod( @NotNull PropertyDescriptor propertyDescriptor, @NotNull KtExpression delegateExpression, - @NotNull KtType delegateType, + @NotNull KotlinType delegateType, @NotNull BindingTrace trace, @NotNull LexicalScope scope, boolean isGet, @@ -240,7 +240,7 @@ public class DelegatedPropertyResolver { PropertyAccessorDescriptor accessor = isGet ? propertyDescriptor.getGetter() : propertyDescriptor.getSetter(); assert accessor != null : "Delegated property should have getter/setter " + propertyDescriptor + " " + delegateExpression.getText(); - KtType expectedType = isComplete && isGet && !(propertyDescriptor.getType() instanceof DeferredType) + KotlinType expectedType = isComplete && isGet && !(propertyDescriptor.getType() instanceof DeferredType) ? propertyDescriptor.getType() : TypeUtils.NO_EXPECTED_TYPE; ExpressionTypingContext context = ExpressionTypingContext.newContext( @@ -305,7 +305,7 @@ public class DelegatedPropertyResolver { assert calleeExpression != null : "CalleeExpression should exists for fake call of convention method"; StringBuilder builder = new StringBuilder(calleeExpression.getText()); builder.append("("); - List argumentTypes = Lists.newArrayList(); + List argumentTypes = Lists.newArrayList(); for (ValueArgument argument : call.getValueArguments()) { argumentTypes.add(context.getType(argument.getArgumentExpression())); @@ -316,7 +316,7 @@ public class DelegatedPropertyResolver { } @Nullable - public KtType resolveDelegateExpression( + public KotlinType resolveDelegateExpression( @NotNull KtExpression delegateExpression, @NotNull KtProperty jetProperty, @NotNull PropertyDescriptor propertyDescriptor, @@ -332,8 +332,8 @@ public class DelegatedPropertyResolver { if (calleeExpression != null) { traceToResolveDelegatedProperty.record(CONSTRAINT_SYSTEM_COMPLETER, calleeExpression, completer); } - KtType delegateType = expressionTypingServices.safeGetType(propertyDeclarationInnerScope, delegateExpression, NO_EXPECTED_TYPE, - dataFlowInfo, traceToResolveDelegatedProperty); + KotlinType delegateType = expressionTypingServices.safeGetType(propertyDeclarationInnerScope, delegateExpression, NO_EXPECTED_TYPE, + dataFlowInfo, traceToResolveDelegatedProperty); traceToResolveDelegatedProperty.commit(new TraceEntryFilter() { @Override public boolean accept(@Nullable WritableSlice slice, Object key) { @@ -351,13 +351,13 @@ public class DelegatedPropertyResolver { @NotNull final LexicalScope accessorScope, @NotNull final BindingTrace trace ) { - final KtType expectedType = property.getTypeReference() != null ? propertyDescriptor.getType() : NO_EXPECTED_TYPE; + final KotlinType expectedType = property.getTypeReference() != null ? propertyDescriptor.getType() : NO_EXPECTED_TYPE; return new ConstraintSystemCompleter() { @Override public void completeConstraintSystem( @NotNull ConstraintSystem constraintSystem, @NotNull ResolvedCall resolvedCall ) { - KtType returnType = resolvedCall.getCandidateDescriptor().getReturnType(); + KotlinType returnType = resolvedCall.getCandidateDescriptor().getReturnType(); if (returnType == null) return; TemporaryBindingTrace traceToResolveConventionMethods = @@ -370,7 +370,7 @@ public class DelegatedPropertyResolver { if (conventionMethodFound(getMethodResults)) { FunctionDescriptor descriptor = getMethodResults.getResultingDescriptor(); - KtType returnTypeOfGetMethod = descriptor.getReturnType(); + KotlinType returnTypeOfGetMethod = descriptor.getReturnType(); if (returnTypeOfGetMethod != null) { constraintSystem.addSupertypeConstraint(expectedType, returnTypeOfGetMethod, FROM_COMPLETER.position()); } @@ -413,7 +413,7 @@ public class DelegatedPropertyResolver { private void addConstraintForThisValue(ConstraintSystem constraintSystem, FunctionDescriptor resultingDescriptor) { ReceiverParameterDescriptor extensionReceiver = propertyDescriptor.getExtensionReceiverParameter(); ReceiverParameterDescriptor dispatchReceiver = propertyDescriptor.getDispatchReceiverParameter(); - KtType typeOfThis = + KotlinType typeOfThis = extensionReceiver != null ? extensionReceiver.getType() : dispatchReceiver != null ? dispatchReceiver.getType() : builtIns.getNullableNothingType(); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DelegatingBindingTrace.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DelegatingBindingTrace.java index 5f8ce203b10..7861467d5dc 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DelegatingBindingTrace.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DelegatingBindingTrace.java @@ -26,7 +26,7 @@ import org.jetbrains.kotlin.diagnostics.Diagnostic; import org.jetbrains.kotlin.psi.KtExpression; import org.jetbrains.kotlin.resolve.diagnostics.Diagnostics; import org.jetbrains.kotlin.resolve.diagnostics.MutableDiagnosticsWithSuppression; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.expressions.JetTypeInfo; import org.jetbrains.kotlin.types.expressions.typeInfoFactory.TypeInfoFactoryKt; import org.jetbrains.kotlin.util.slicedMap.*; @@ -58,7 +58,7 @@ public class DelegatingBindingTrace implements BindingTrace { @Nullable @Override - public KtType getType(@NotNull KtExpression expression) { + public KotlinType getType(@NotNull KtExpression expression) { return DelegatingBindingTrace.this.getType(expression); } @@ -139,13 +139,13 @@ public class DelegatingBindingTrace implements BindingTrace { @Nullable @Override - public KtType getType(@NotNull KtExpression expression) { + public KotlinType getType(@NotNull KtExpression expression) { JetTypeInfo typeInfo = get(BindingContext.EXPRESSION_TYPE_INFO, expression); return typeInfo != null ? typeInfo.getType() : null; } @Override - public void recordType(@NotNull KtExpression expression, @Nullable KtType type) { + public void recordType(@NotNull KtExpression expression, @Nullable KotlinType type) { JetTypeInfo typeInfo = get(BindingContext.EXPRESSION_TYPE_INFO, expression); if (typeInfo == null) { typeInfo = TypeInfoFactoryKt.createTypeInfo(type); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DelegationResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DelegationResolver.java index 7862dd69e87..a307ceb4259 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DelegationResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DelegationResolver.java @@ -25,7 +25,7 @@ import org.jetbrains.kotlin.psi.KtClassOrObject; import org.jetbrains.kotlin.psi.KtDelegationSpecifier; import org.jetbrains.kotlin.psi.KtDelegatorByExpressionSpecifier; import org.jetbrains.kotlin.psi.KtTypeReference; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.TypeUtils; import java.util.ArrayList; @@ -88,7 +88,7 @@ public final class DelegationResolver { if (typeReference == null) { continue; } - KtType delegatedTraitType = typeResolver.resolve(typeReference); + KotlinType delegatedTraitType = typeResolver.resolve(typeReference); if (delegatedTraitType == null || delegatedTraitType.isError()) { continue; } @@ -101,7 +101,7 @@ public final class DelegationResolver { @NotNull private Collection generateDelegatesForTrait( @NotNull Collection existingDelegates, - @NotNull KtType delegatedTraitType + @NotNull KotlinType delegatedTraitType ) { Collection result = new HashSet(); Collection candidates = generateDelegationCandidates(delegatedTraitType); @@ -120,7 +120,7 @@ public final class DelegationResolver { } @NotNull - private Collection generateDelegationCandidates(@NotNull KtType delegatedTraitType) { + private Collection generateDelegationCandidates(@NotNull KotlinType delegatedTraitType) { Collection descriptorsToDelegate = overridableMembersNotFromSuperClassOfTrait(delegatedTraitType); Collection result = new ArrayList(descriptorsToDelegate.size()); for (T memberDescriptor : descriptorsToDelegate) { @@ -156,7 +156,7 @@ public final class DelegationResolver { } @NotNull - private Collection overridableMembersNotFromSuperClassOfTrait(@NotNull KtType trait) { + private Collection overridableMembersNotFromSuperClassOfTrait(@NotNull KotlinType trait) { final Collection membersToSkip = getMembersFromClassSupertypeOfTrait(trait); return Collections2.filter( memberExtractor.getMembersByType(trait), @@ -182,9 +182,9 @@ public final class DelegationResolver { } @NotNull - private Collection getMembersFromClassSupertypeOfTrait(@NotNull KtType traitType) { - KtType classSupertype = null; - for (KtType supertype : TypeUtils.getAllSupertypes(traitType)) { + private Collection getMembersFromClassSupertypeOfTrait(@NotNull KotlinType traitType) { + KotlinType classSupertype = null; + for (KotlinType supertype : TypeUtils.getAllSupertypes(traitType)) { if (isNotTrait(supertype.getConstructor().getDeclarationDescriptor())) { classSupertype = supertype; break; @@ -203,11 +203,11 @@ public final class DelegationResolver { public interface MemberExtractor { @NotNull - Collection getMembersByType(@NotNull KtType type); + Collection getMembersByType(@NotNull KotlinType type); } public interface TypeResolver { @Nullable - KtType resolve(@NotNull KtTypeReference reference); + KotlinType resolve(@NotNull KtTypeReference reference); } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DescriptorResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DescriptorResolver.java index c79902ffcbf..3e8525a4331 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DescriptorResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DescriptorResolver.java @@ -96,20 +96,20 @@ public class DescriptorResolver { this.constantExpressionEvaluator = constantExpressionEvaluator; } - public List resolveSupertypes( + public List resolveSupertypes( @NotNull LexicalScope scope, @NotNull ClassDescriptor classDescriptor, @NotNull KtClassOrObject jetClass, BindingTrace trace ) { - List supertypes = Lists.newArrayList(); + List supertypes = Lists.newArrayList(); List delegationSpecifiers = jetClass.getDelegationSpecifiers(); - Collection declaredSupertypes = resolveDelegationSpecifiers( + Collection declaredSupertypes = resolveDelegationSpecifiers( scope, delegationSpecifiers, typeResolver, trace, false); - for (KtType declaredSupertype : declaredSupertypes) { + for (KotlinType declaredSupertype : declaredSupertypes) { addValidSupertype(supertypes, declaredSupertype); } @@ -118,21 +118,21 @@ public class DescriptorResolver { } if (supertypes.isEmpty()) { - KtType defaultSupertype = getDefaultSupertype(jetClass, trace, classDescriptor.getKind() == ClassKind.ANNOTATION_CLASS); + KotlinType defaultSupertype = getDefaultSupertype(jetClass, trace, classDescriptor.getKind() == ClassKind.ANNOTATION_CLASS); addValidSupertype(supertypes, defaultSupertype); } return supertypes; } - private static void addValidSupertype(List supertypes, KtType declaredSupertype) { + private static void addValidSupertype(List supertypes, KotlinType declaredSupertype) { if (!declaredSupertype.isError()) { supertypes.add(declaredSupertype); } } - private boolean containsClass(Collection result) { - for (KtType type : result) { + private boolean containsClass(Collection result) { + for (KotlinType type : result) { ClassifierDescriptor descriptor = type.getConstructor().getDeclarationDescriptor(); if (descriptor instanceof ClassDescriptor && ((ClassDescriptor) descriptor).getKind() != ClassKind.INTERFACE) { return true; @@ -141,7 +141,7 @@ public class DescriptorResolver { return false; } - private KtType getDefaultSupertype(KtClassOrObject jetClass, BindingTrace trace, boolean isAnnotation) { + private KotlinType getDefaultSupertype(KtClassOrObject jetClass, BindingTrace trace, boolean isAnnotation) { // TODO : beautify if (jetClass instanceof KtEnumEntry) { KtClassOrObject parent = KtStubbedPsiUtil.getContainingDeclaration(jetClass, KtClassOrObject.class); @@ -160,7 +160,7 @@ public class DescriptorResolver { return builtIns.getAnyType(); } - public Collection resolveDelegationSpecifiers( + public Collection resolveDelegationSpecifiers( LexicalScope extensibleScope, List delegationSpecifiers, @NotNull TypeResolver resolver, @@ -170,11 +170,11 @@ public class DescriptorResolver { if (delegationSpecifiers.isEmpty()) { return Collections.emptyList(); } - Collection result = Lists.newArrayList(); + Collection result = Lists.newArrayList(); for (KtDelegationSpecifier delegationSpecifier : delegationSpecifiers) { KtTypeReference typeReference = delegationSpecifier.getTypeReference(); if (typeReference != null) { - KtType supertype = resolver.resolveType(extensibleScope, typeReference, trace, checkBounds); + KotlinType supertype = resolver.resolveType(extensibleScope, typeReference, trace, checkBounds); if (DynamicTypesKt.isDynamic(supertype)) { trace.report(DYNAMIC_SUPERTYPE.on(typeReference)); } @@ -225,7 +225,7 @@ public class DescriptorResolver { @NotNull BindingTrace trace ) { Name functionName = DataClassUtilsKt.createComponentName(parameterIndex); - KtType returnType = property.getType(); + KotlinType returnType = property.getType(); SimpleFunctionDescriptorImpl functionDescriptor = SimpleFunctionDescriptorImpl.create( classDescriptor, @@ -257,7 +257,7 @@ public class DescriptorResolver { @NotNull ClassDescriptor classDescriptor, @NotNull BindingTrace trace ) { - KtType returnType = classDescriptor.getDefaultType(); + KotlinType returnType = classDescriptor.getDefaultType(); SimpleFunctionDescriptorImpl functionDescriptor = SimpleFunctionDescriptorImpl.create( classDescriptor, @@ -333,10 +333,10 @@ public class DescriptorResolver { @NotNull public ValueParameterDescriptorImpl resolveValueParameterDescriptor( - LexicalScope scope, FunctionDescriptor owner, KtParameter valueParameter, int index, KtType type, BindingTrace trace + LexicalScope scope, FunctionDescriptor owner, KtParameter valueParameter, int index, KotlinType type, BindingTrace trace ) { - KtType varargElementType = null; - KtType variableType = type; + KotlinType varargElementType = null; + KotlinType variableType = type; if (valueParameter.hasModifier(VARARG_KEYWORD)) { varargElementType = type; variableType = getVarargParameterType(type); @@ -378,8 +378,8 @@ public class DescriptorResolver { } @NotNull - private KtType getVarargParameterType(@NotNull KtType elementType) { - KtType primitiveArrayType = builtIns.getPrimitiveArrayJetTypeByPrimitiveJetType(elementType); + private KotlinType getVarargParameterType(@NotNull KotlinType elementType) { + KotlinType primitiveArrayType = builtIns.getPrimitiveArrayJetTypeByPrimitiveJetType(elementType); if (primitiveArrayType != null) { return primitiveArrayType; } @@ -449,21 +449,21 @@ public class DescriptorResolver { static final class UpperBoundCheckerTask { KtTypeReference upperBound; - KtType upperBoundType; + KotlinType upperBoundType; - private UpperBoundCheckerTask(KtTypeReference upperBound, KtType upperBoundType) { + private UpperBoundCheckerTask(KtTypeReference upperBound, KotlinType upperBoundType) { this.upperBound = upperBound; this.upperBoundType = upperBoundType; } } - public KtType resolveTypeParameterExtendsBound( + public KotlinType resolveTypeParameterExtendsBound( @NotNull TypeParameterDescriptor typeParameterDescriptor, @NotNull KtTypeReference extendsBound, LexicalScope scope, BindingTrace trace ) { - KtType type = typeResolver.resolveType(scope, extendsBound, trace, false); + KotlinType type = typeResolver.resolveType(scope, extendsBound, trace, false); if (type.getConstructor().equals(typeParameterDescriptor.getTypeConstructor())) { trace.report(Errors.CYCLIC_GENERIC_UPPER_BOUND.on(extendsBound)); type = ErrorUtils.createErrorType("Cyclic upper bound: " + type); @@ -490,7 +490,7 @@ public class DescriptorResolver { KtTypeReference extendsBound = jetTypeParameter.getExtendsBound(); if (extendsBound != null) { - KtType type = resolveTypeParameterExtendsBound(typeParameterDescriptor, extendsBound, scope, trace); + KotlinType type = resolveTypeParameterExtendsBound(typeParameterDescriptor, extendsBound, scope, trace); typeParameterDescriptor.addUpperBound(type); deferredUpperBoundCheckerTasks.add(new UpperBoundCheckerTask(extendsBound, type)); } @@ -503,7 +503,7 @@ public class DescriptorResolver { Name referencedName = subjectTypeParameterName.getReferencedNameAsName(); TypeParameterDescriptorImpl typeParameterDescriptor = parameterByName.get(referencedName); KtTypeReference boundTypeReference = constraint.getBoundTypeReference(); - KtType bound = null; + KotlinType bound = null; if (boundTypeReference != null) { bound = typeResolver.resolveType(scope, boundTypeReference, trace, false); deferredUpperBoundCheckerTasks.add(new UpperBoundCheckerTask(boundTypeReference, bound)); @@ -577,7 +577,7 @@ public class DescriptorResolver { public static void checkUpperBoundType( KtTypeReference upperBound, - @NotNull KtType upperBoundType, + @NotNull KotlinType upperBoundType, BindingTrace trace ) { if (!TypeUtils.canHaveSubtypes(KotlinTypeChecker.DEFAULT, upperBoundType)) { @@ -598,13 +598,13 @@ public class DescriptorResolver { @NotNull KtParameter parameter, BindingTrace trace ) { - KtType type = resolveParameterType(scope, parameter, trace); + KotlinType type = resolveParameterType(scope, parameter, trace); return resolveLocalVariableDescriptor(parameter, type, trace, scope); } - private KtType resolveParameterType(LexicalScope scope, KtParameter parameter, BindingTrace trace) { + private KotlinType resolveParameterType(LexicalScope scope, KtParameter parameter, BindingTrace trace) { KtTypeReference typeReference = parameter.getTypeReference(); - KtType type; + KotlinType type; if (typeReference != null) { type = typeResolver.resolveType(scope, typeReference, trace, true); } @@ -620,7 +620,7 @@ public class DescriptorResolver { public VariableDescriptor resolveLocalVariableDescriptor( @NotNull KtParameter parameter, - @NotNull KtType type, + @NotNull KotlinType type, BindingTrace trace, @NotNull LexicalScope scope ) { @@ -647,7 +647,7 @@ public class DescriptorResolver { ) { DeclarationDescriptor containingDeclaration = scope.getOwnerDescriptor(); VariableDescriptor result; - KtType type; + KotlinType type; // SCRIPT: Create property descriptors if (KtPsiUtil.isScriptDeclaration(variable)) { PropertyDescriptorImpl propertyDescriptor = PropertyDescriptorImpl.create( @@ -666,7 +666,7 @@ public class DescriptorResolver { type = getVariableType(propertyDescriptor, scope, variable, dataFlowInfo, false, trace); ReceiverParameterDescriptor receiverParameter = ((ScriptDescriptor) containingDeclaration).getThisAsReceiverParameter(); - propertyDescriptor.setType(type, Collections.emptyList(), receiverParameter, (KtType) null); + propertyDescriptor.setType(type, Collections.emptyList(), receiverParameter, (KotlinType) null); initializeWithDefaultGetterSetter(propertyDescriptor); trace.record(BindingContext.VARIABLE, variable, propertyDescriptor); result = propertyDescriptor; @@ -702,7 +702,7 @@ public class DescriptorResolver { public LocalVariableDescriptor resolveLocalVariableDescriptorWithType( @NotNull LexicalScope scope, @NotNull KtVariableDeclaration variable, - @Nullable KtType type, + @Nullable KotlinType type, @NotNull BindingTrace trace ) { LocalVariableDescriptor variableDescriptor = new LocalVariableDescriptor( @@ -765,7 +765,7 @@ public class DescriptorResolver { List typeParameterDescriptors; LexicalScope scopeWithTypeParameters; - KtType receiverType = null; + KotlinType receiverType = null; { List typeParameters = property.getTypeParameters(); @@ -798,7 +798,7 @@ public class DescriptorResolver { LexicalScope propertyScope = JetScopeUtils.getPropertyDeclarationInnerScope(propertyDescriptor, scope, typeParameterDescriptors, implicitInitializerReceiver, trace); - KtType type = getVariableType(propertyDescriptor, propertyScope, property, dataFlowInfo, true, trace); + KotlinType type = getVariableType(propertyDescriptor, propertyScope, property, dataFlowInfo, true, trace); propertyDescriptor.setType(type, typeParameterDescriptors, getDispatchReceiverParameterIfNeeded(containingDeclaration), receiverDescriptor); @@ -831,7 +831,7 @@ public class DescriptorResolver { } @NotNull - private KtType getVariableType( + private KotlinType getVariableType( @NotNull final VariableDescriptorWithInitializerImpl variableDescriptor, @NotNull final LexicalScope scope, @NotNull final KtVariableDeclaration variable, @@ -850,9 +850,9 @@ public class DescriptorResolver { return DeferredType.createRecursionIntolerant( storageManager, trace, - new Function0() { + new Function0() { @Override - public KtType invoke() { + public KotlinType invoke() { return resolveDelegatedPropertyType(property, (PropertyDescriptor) variableDescriptor, scope, property.getDelegateExpression(), dataFlowInfo, trace); } @@ -869,11 +869,12 @@ public class DescriptorResolver { return DeferredType.createRecursionIntolerant( storageManager, trace, - new Function0() { + new Function0() { @Override - public KtType invoke() { + public KotlinType invoke() { PreliminaryDeclarationVisitor.Companion.createForDeclaration(variable, trace); - KtType initializerType = resolveInitializerType(scope, variable.getInitializer(), dataFlowInfo, trace); + KotlinType + initializerType = resolveInitializerType(scope, variable.getInitializer(), dataFlowInfo, trace); setConstantForVariableIfNeeded(variableDescriptor, scope, variable, dataFlowInfo, initializerType, trace); return transformAnonymousTypeIfNeeded(variableDescriptor, variable, initializerType, trace); } @@ -881,14 +882,14 @@ public class DescriptorResolver { ); } else { - KtType initializerType = resolveInitializerType(scope, variable.getInitializer(), dataFlowInfo, trace); + KotlinType initializerType = resolveInitializerType(scope, variable.getInitializer(), dataFlowInfo, trace); setConstantForVariableIfNeeded(variableDescriptor, scope, variable, dataFlowInfo, initializerType, trace); return initializerType; } } } else { - KtType type = typeResolver.resolveType(scope, propertyTypeRef, trace, true); + KotlinType type = typeResolver.resolveType(scope, propertyTypeRef, trace, true); setConstantForVariableIfNeeded(variableDescriptor, scope, variable, dataFlowInfo, type, trace); return type; } @@ -899,7 +900,7 @@ public class DescriptorResolver { @NotNull final LexicalScope scope, @NotNull final KtVariableDeclaration variable, @NotNull final DataFlowInfo dataFlowInfo, - @NotNull final KtType variableType, + @NotNull final KotlinType variableType, @NotNull final BindingTrace trace ) { if (!shouldRecordInitializerForProperty(variableDescriptor, variableType)) return; @@ -912,7 +913,7 @@ public class DescriptorResolver { @Override public ConstantValue invoke() { KtExpression initializer = variable.getInitializer(); - KtType initializerType = expressionTypingServices.safeGetType(scope, initializer, variableType, dataFlowInfo, trace); + KotlinType initializerType = expressionTypingServices.safeGetType(scope, initializer, variableType, dataFlowInfo, trace); CompileTimeConstant constant = constantExpressionEvaluator.evaluateExpression(initializer, trace, initializerType); if (constant == null) return null; @@ -928,7 +929,7 @@ public class DescriptorResolver { } @NotNull - private KtType resolveDelegatedPropertyType( + private KotlinType resolveDelegatedPropertyType( @NotNull KtProperty property, @NotNull PropertyDescriptor propertyDescriptor, @NotNull LexicalScope scope, @@ -938,11 +939,11 @@ public class DescriptorResolver { ) { LexicalScope accessorScope = JetScopeUtils.makeScopeForPropertyAccessor(propertyDescriptor, scope, trace); - KtType type = delegatedPropertyResolver.resolveDelegateExpression( + KotlinType type = delegatedPropertyResolver.resolveDelegateExpression( delegateExpression, property, propertyDescriptor, scope, accessorScope, trace, dataFlowInfo); if (type != null) { - KtType getterReturnType = delegatedPropertyResolver + KotlinType getterReturnType = delegatedPropertyResolver .getDelegatedPropertyGetMethodReturnType(propertyDescriptor, delegateExpression, type, trace, accessorScope); if (getterReturnType != null) { return getterReturnType; @@ -952,10 +953,10 @@ public class DescriptorResolver { } @Nullable - /*package*/ static KtType transformAnonymousTypeIfNeeded( + /*package*/ static KotlinType transformAnonymousTypeIfNeeded( @NotNull DeclarationDescriptorWithVisibility descriptor, @NotNull KtNamedDeclaration declaration, - @NotNull KtType type, + @NotNull KotlinType type, @NotNull BindingTrace trace ) { ClassifierDescriptor classifier = type.getConstructor().getDeclarationDescriptor(); @@ -977,7 +978,7 @@ public class DescriptorResolver { } @NotNull - private KtType resolveInitializerType( + private KotlinType resolveInitializerType( @NotNull LexicalScope scope, @NotNull KtExpression initializer, @NotNull DataFlowInfo dataFlowInfo, @@ -1015,14 +1016,14 @@ public class DescriptorResolver { trace.report(SETTER_PARAMETER_WITH_DEFAULT_VALUE.on(parameter.getDefaultValue())); } - KtType type; + KotlinType type; KtTypeReference typeReference = parameter.getTypeReference(); if (typeReference == null) { type = propertyDescriptor.getType(); // TODO : this maybe unknown at this point } else { type = typeResolver.resolveType(scope, typeReference, trace, true); - KtType inType = propertyDescriptor.getType(); + KotlinType inType = propertyDescriptor.getType(); if (inType != null) { if (!TypeUtils.equalTypes(type, inType)) { trace.report(WRONG_SETTER_PARAMETER_TYPE.on(typeReference, inType, type)); @@ -1073,8 +1074,8 @@ public class DescriptorResolver { annotationSplitter.getAnnotationsForTarget(PROPERTY_GETTER), annotationResolver.resolveAnnotationsWithoutArguments(scope, getter.getModifierList(), trace))); - KtType outType = propertyDescriptor.getType(); - KtType returnType = outType; + KotlinType outType = propertyDescriptor.getType(); + KotlinType returnType = outType; KtTypeReference returnTypeReference = getter.getReturnTypeReference(); if (returnTypeReference != null) { returnType = typeResolver.resolveType(scope, returnTypeReference, trace, true); @@ -1108,7 +1109,7 @@ public class DescriptorResolver { @NotNull LexicalScope scope, @NotNull KtParameter parameter, final BindingTrace trace ) { - KtType type = resolveParameterType(scope, parameter, trace); + KotlinType type = resolveParameterType(scope, parameter, trace); Name name = parameter.getNameAsSafeName(); boolean isMutable = parameter.isMutable(); KtModifierList modifierList = parameter.getModifierList(); @@ -1165,7 +1166,7 @@ public class DescriptorResolver { return propertyDescriptor; } - public static void checkBounds(@NotNull KtTypeReference typeReference, @NotNull KtType type, @NotNull BindingTrace trace) { + public static void checkBounds(@NotNull KtTypeReference typeReference, @NotNull KotlinType type, @NotNull BindingTrace trace) { if (type.isError()) return; KtTypeElement typeElement = typeReference.getTypeElement(); @@ -1197,7 +1198,7 @@ public class DescriptorResolver { if (jetTypeArgument == null) continue; - KtType typeArgument = arguments.get(i).getType(); + KotlinType typeArgument = arguments.get(i).getType(); checkBounds(jetTypeArgument, typeArgument, trace); TypeParameterDescriptor typeParameterDescriptor = parameters.get(i); @@ -1207,13 +1208,13 @@ public class DescriptorResolver { public static void checkBounds( @NotNull KtTypeReference jetTypeArgument, - @NotNull KtType typeArgument, + @NotNull KotlinType typeArgument, @NotNull TypeParameterDescriptor typeParameterDescriptor, @NotNull TypeSubstitutor substitutor, @NotNull BindingTrace trace ) { - for (KtType bound : typeParameterDescriptor.getUpperBounds()) { - KtType substitutedBound = substitutor.safeSubstitute(bound, Variance.INVARIANT); + for (KotlinType bound : typeParameterDescriptor.getUpperBounds()) { + KotlinType substitutedBound = substitutor.safeSubstitute(bound, Variance.INVARIANT); if (!KotlinTypeChecker.DEFAULT.isSubtypeOf(typeArgument, substitutedBound)) { trace.report(UPPER_BOUND_VIOLATED.on(jetTypeArgument, substitutedBound, typeArgument)); } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/FunctionDescriptorResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/FunctionDescriptorResolver.kt index 52a533b91c7..ff829b5820c 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/FunctionDescriptorResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/FunctionDescriptorResolver.kt @@ -47,7 +47,7 @@ import org.jetbrains.kotlin.resolve.source.toSourceElement import org.jetbrains.kotlin.storage.StorageManager import org.jetbrains.kotlin.types.DeferredType import org.jetbrains.kotlin.types.ErrorUtils -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeUtils import org.jetbrains.kotlin.types.checker.KotlinTypeChecker import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices @@ -84,7 +84,7 @@ class FunctionDescriptorResolver( function: KtNamedFunction, trace: BindingTrace, dataFlowInfo: DataFlowInfo, - expectedFunctionType: KtType + expectedFunctionType: KotlinType ): SimpleFunctionDescriptor = resolveFunctionDescriptor( ::FunctionExpressionDescriptor, containingDescriptor, scope, function, trace, dataFlowInfo, expectedFunctionType) @@ -95,7 +95,7 @@ class FunctionDescriptorResolver( function: KtNamedFunction, trace: BindingTrace, dataFlowInfo: DataFlowInfo, - expectedFunctionType: KtType + expectedFunctionType: KotlinType ): SimpleFunctionDescriptor { val functionDescriptor = functionConstructor( containingDescriptor, @@ -143,7 +143,7 @@ class FunctionDescriptorResolver( function: KtFunction, functionDescriptor: SimpleFunctionDescriptorImpl, trace: BindingTrace, - expectedFunctionType: KtType + expectedFunctionType: KotlinType ) { val innerScope = LexicalWritableScope(scope, functionDescriptor, true, null, TraceBasedRedeclarationHandler(trace), "Function descriptor header scope") @@ -194,7 +194,7 @@ class FunctionDescriptorResolver( functionDescriptor: SimpleFunctionDescriptorImpl, innerScope: LexicalWritableScope, trace: BindingTrace, - expectedFunctionType: KtType + expectedFunctionType: KotlinType ): List { val expectedValueParameters = expectedFunctionType.getValueParameters(functionDescriptor) if (expectedValueParameters != null) { @@ -225,11 +225,11 @@ class FunctionDescriptorResolver( ) } - private fun KtType.functionTypeExpected() = !TypeUtils.noExpectedType(this) && KotlinBuiltIns.isFunctionOrExtensionFunctionType(this) - private fun KtType.getReceiverType(): KtType? = + private fun KotlinType.functionTypeExpected() = !TypeUtils.noExpectedType(this) && KotlinBuiltIns.isFunctionOrExtensionFunctionType(this) + private fun KotlinType.getReceiverType(): KotlinType? = if (functionTypeExpected()) KotlinBuiltIns.getReceiverType(this) else null - private fun KtType.getValueParameters(owner: FunctionDescriptor): List? = + private fun KotlinType.getValueParameters(owner: FunctionDescriptor): List? = if (functionTypeExpected()) KotlinBuiltIns.getValueParameters(owner, this) else null public fun resolvePrimaryConstructorDescriptor( @@ -322,7 +322,7 @@ class FunctionDescriptorResolver( val typeReference = valueParameter.getTypeReference() val expectedType = expectedValueParameters?.let { if (i < it.size()) it[i].getType() else null } - val type: KtType + val type: KotlinType if (typeReference != null) { type = typeResolver.resolveType(parameterScope, typeReference, trace, true) if (expectedType != null && !TypeUtils.noExpectedType(expectedType)) { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/FunctionDescriptorUtil.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/FunctionDescriptorUtil.java index 94bc443aa0d..d5a60953d99 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/FunctionDescriptorUtil.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/FunctionDescriptorUtil.java @@ -38,7 +38,7 @@ public class FunctionDescriptorUtil { private static final TypeSubstitutor MAKE_TYPE_PARAMETERS_FRESH = TypeSubstitutor.create(new TypeSubstitution() { @Override - public TypeProjection get(@NotNull KtType key) { + public TypeProjection get(@NotNull KotlinType key) { return null; } @@ -53,7 +53,7 @@ public class FunctionDescriptorUtil { public static TypeSubstitution createSubstitution( @NotNull FunctionDescriptor functionDescriptor, - @NotNull List typeArguments + @NotNull List typeArguments ) { if (functionDescriptor.getTypeParameters().isEmpty()) return TypeSubstitution.getEMPTY(); @@ -90,7 +90,7 @@ public class FunctionDescriptorUtil { public static void initializeFromFunctionType( @NotNull FunctionDescriptorImpl functionDescriptor, - @NotNull KtType functionType, + @NotNull KotlinType functionType, @Nullable ReceiverParameterDescriptor dispatchReceiverParameter, @NotNull Modality modality, @NotNull Visibility visibility @@ -129,7 +129,7 @@ public class FunctionDescriptorUtil { List parameters = new ArrayList(newParameters.size()); int idx = 0; for (ValueParameterDescriptor parameter : newParameters) { - KtType returnType = parameter.getReturnType(); + KotlinType returnType = parameter.getReturnType(); assert returnType != null; parameters.add( diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/ObservableBindingTrace.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/ObservableBindingTrace.java index b5ccfa109fe..0c0d2b19a4b 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/ObservableBindingTrace.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/ObservableBindingTrace.java @@ -21,7 +21,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.diagnostics.Diagnostic; import org.jetbrains.kotlin.psi.KtExpression; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.util.slicedMap.ReadOnlySlice; import org.jetbrains.kotlin.util.slicedMap.WritableSlice; @@ -78,12 +78,12 @@ public class ObservableBindingTrace implements BindingTrace { @Nullable @Override - public KtType getType(@NotNull KtExpression expression) { + public KotlinType getType(@NotNull KtExpression expression) { return originalTrace.getType(expression); } @Override - public void recordType(@NotNull KtExpression expression, @Nullable KtType type) { + public void recordType(@NotNull KtExpression expression, @Nullable KotlinType type) { originalTrace.recordType(expression, type); } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/OverloadUtil.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/OverloadUtil.java index ec7661c8348..f995fb4f386 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/OverloadUtil.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/OverloadUtil.java @@ -21,7 +21,7 @@ import org.jetbrains.kotlin.descriptors.CallableDescriptor; import org.jetbrains.kotlin.descriptors.ConstructorDescriptor; import org.jetbrains.kotlin.descriptors.PropertyDescriptor; import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.TypeCapabilitiesKt; import org.jetbrains.kotlin.types.checker.KotlinTypeChecker; @@ -65,12 +65,12 @@ public class OverloadUtil { return receiverAndParameterResult; } - List superValueParameters = OverridingUtil.compiledValueParameters(superDescriptor); - List subValueParameters = OverridingUtil.compiledValueParameters(subDescriptor); + List superValueParameters = OverridingUtil.compiledValueParameters(superDescriptor); + List subValueParameters = OverridingUtil.compiledValueParameters(subDescriptor); for (int i = 0; i < superValueParameters.size(); ++i) { - KtType superValueParameterType = OverridingUtil.getUpperBound(superValueParameters.get(i)); - KtType subValueParameterType = OverridingUtil.getUpperBound(subValueParameters.get(i)); + KotlinType superValueParameterType = OverridingUtil.getUpperBound(superValueParameters.get(i)); + KotlinType subValueParameterType = OverridingUtil.getUpperBound(subValueParameters.get(i)); if (!KotlinTypeChecker.DEFAULT.equalTypes(superValueParameterType, subValueParameterType) || TypeCapabilitiesKt.oneMoreSpecificThanAnother(subValueParameterType, superValueParameterType)) { return OverridingUtil.OverrideCompatibilityInfo diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/OverrideResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/OverrideResolver.java index f8bc205c459..4723b34612e 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/OverrideResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/OverrideResolver.java @@ -235,13 +235,13 @@ public class OverrideResolver { private static List getCallableMembersFromSupertypes(ClassDescriptor classDescriptor) { Set r = Sets.newLinkedHashSet(); - for (KtType supertype : classDescriptor.getTypeConstructor().getSupertypes()) { + for (KotlinType supertype : classDescriptor.getTypeConstructor().getSupertypes()) { r.addAll(getCallableMembersFromType(supertype)); } return new ArrayList(r); } - private static List getCallableMembersFromType(KtType type) { + private static List getCallableMembersFromType(KotlinType type) { List r = Lists.newArrayList(); for (DeclarationDescriptor decl : type.getMemberScope().getAllDescriptors()) { if (decl instanceof PropertyDescriptor || decl instanceof SimpleFunctionDescriptor) { @@ -687,13 +687,13 @@ public class OverrideResolver { TypeSubstitutor typeSubstitutor = prepareTypeSubstitutor(superDescriptor, subDescriptor); if (typeSubstitutor == null) return false; - KtType superReturnType = superDescriptor.getReturnType(); + KotlinType superReturnType = superDescriptor.getReturnType(); assert superReturnType != null; - KtType subReturnType = subDescriptor.getReturnType(); + KotlinType subReturnType = subDescriptor.getReturnType(); assert subReturnType != null; - KtType substitutedSuperReturnType = typeSubstitutor.substitute(superReturnType, Variance.OUT_VARIANCE); + KotlinType substitutedSuperReturnType = typeSubstitutor.substitute(superReturnType, Variance.OUT_VARIANCE); assert substitutedSuperReturnType != null; return KotlinTypeChecker.DEFAULT.isSubtypeOf(subReturnType, substitutedSuperReturnType); @@ -725,7 +725,7 @@ public class OverrideResolver { if (!superDescriptor.isVar()) return true; - KtType substitutedSuperReturnType = typeSubstitutor.substitute(superDescriptor.getType(), Variance.OUT_VARIANCE); + KotlinType substitutedSuperReturnType = typeSubstitutor.substitute(superDescriptor.getType(), Variance.OUT_VARIANCE); assert substitutedSuperReturnType != null; return KotlinTypeChecker.DEFAULT.equalTypes(subDescriptor.getType(), substitutedSuperReturnType); } @@ -792,7 +792,7 @@ public class OverrideResolver { @NotNull CallableMemberDescriptor declared, @NotNull ClassDescriptor declaringClass ) { - for (KtType supertype : declaringClass.getTypeConstructor().getSupertypes()) { + for (KotlinType supertype : declaringClass.getTypeConstructor().getSupertypes()) { Set all = Sets.newLinkedHashSet(); all.addAll(supertype.getMemberScope().getFunctions(declared.getName(), NoLookupLocation.UNSORTED)); //noinspection unchecked diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/PossiblyBareType.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/PossiblyBareType.java index f34b2b91f72..3cee33c3b44 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/PossiblyBareType.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/PossiblyBareType.java @@ -48,15 +48,15 @@ public class PossiblyBareType { } @NotNull - public static PossiblyBareType type(@NotNull KtType actualType) { + public static PossiblyBareType type(@NotNull KotlinType actualType) { return new PossiblyBareType(actualType, null, false); } - private final KtType actualType; + private final KotlinType actualType; private final TypeConstructor bareTypeConstructor; private final boolean nullable; - private PossiblyBareType(@Nullable KtType actualType, @Nullable TypeConstructor bareTypeConstructor, boolean nullable) { + private PossiblyBareType(@Nullable KotlinType actualType, @Nullable TypeConstructor bareTypeConstructor, boolean nullable) { this.actualType = actualType; this.bareTypeConstructor = bareTypeConstructor; this.nullable = nullable; @@ -67,7 +67,7 @@ public class PossiblyBareType { } @NotNull - public KtType getActualType() { + public KotlinType getActualType() { //noinspection ConstantConditions return actualType; } @@ -95,18 +95,18 @@ public class PossiblyBareType { } @NotNull - public TypeReconstructionResult reconstruct(@NotNull KtType subjectType) { + public TypeReconstructionResult reconstruct(@NotNull KotlinType subjectType) { if (!isBare()) return new TypeReconstructionResult(getActualType(), true); TypeReconstructionResult reconstructionResult = CastDiagnosticsUtil.findStaticallyKnownSubtype( TypeUtils.makeNotNullable(subjectType), getBareTypeConstructor() ); - KtType type = reconstructionResult.getResultingType(); + KotlinType type = reconstructionResult.getResultingType(); // No need to make an absent type nullable if (type == null) return reconstructionResult; - KtType resultingType = TypeUtils.makeNullableAsSpecified(type, isBareTypeNullable()); + KotlinType resultingType = TypeUtils.makeNullableAsSpecified(type, isBareTypeNullable()); return new TypeReconstructionResult(resultingType, reconstructionResult.isAllArgumentsInferred()); } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/ScriptBodyResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/ScriptBodyResolver.java index 2d4cb7f15e5..1bb4145582c 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/ScriptBodyResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/ScriptBodyResolver.java @@ -22,7 +22,7 @@ import org.jetbrains.kotlin.psi.KtScript; import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo; import org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil; import org.jetbrains.kotlin.types.ErrorUtils; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.expressions.CoercionStrategy; import org.jetbrains.kotlin.types.expressions.ExpressionTypingContext; import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices; @@ -52,7 +52,7 @@ public class ScriptBodyResolver { } @NotNull - public KtType resolveScriptReturnType( + public KotlinType resolveScriptReturnType( @NotNull KtScript script, @NotNull ScriptDescriptor scriptDescriptor, @NotNull BindingTrace trace @@ -65,7 +65,7 @@ public class ScriptBodyResolver { NO_EXPECTED_TYPE ); PreliminaryDeclarationVisitor.Companion.createForDeclaration(script, trace); - KtType returnType = expressionTypingServices.getBlockReturnedType(script.getBlockExpression(), CoercionStrategy.NO_COERCION, context).getType(); + KotlinType returnType = expressionTypingServices.getBlockReturnedType(script.getBlockExpression(), CoercionStrategy.NO_COERCION, context).getType(); if (returnType == null) { returnType = ErrorUtils.createErrorType("getBlockReturnedType returned null"); } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeBinding.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeBinding.kt index c3e2a420d94..cd023f0e570 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeBinding.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeBinding.kt @@ -16,7 +16,7 @@ package org.jetbrains.kotlin.resolve.typeBinding -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor import com.intellij.psi.PsiElement import org.jetbrains.kotlin.psi.KtTypeElement @@ -30,7 +30,7 @@ import org.jetbrains.kotlin.types.TypeProjectionImpl interface TypeBinding { val psiElement: P - val jetType: KtType + val jetType: KotlinType fun getArgumentBindings(): List?> } @@ -70,7 +70,7 @@ private class TypeArgumentBindingImpl( private class ExplicitTypeBinding( private val trace: BindingContext, override val psiElement: KtTypeElement, - override val jetType: KtType + override val jetType: KotlinType ) : TypeBinding { override fun getArgumentBindings(): List?> { @@ -111,7 +111,7 @@ private class ExplicitTypeBinding( private class NoTypeElementBinding( private val trace: BindingContext, override val psiElement: P, - override val jetType: KtType + override val jetType: KotlinType ): TypeBinding

{ override fun getArgumentBindings(): List?> { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt index c5c268f3a51..8346df66c23 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt @@ -62,12 +62,12 @@ public class TypeResolver( } } - public fun resolveType(scope: LexicalScope, typeReference: KtTypeReference, trace: BindingTrace, checkBounds: Boolean): KtType { + public fun resolveType(scope: LexicalScope, typeReference: KtTypeReference, trace: BindingTrace, checkBounds: Boolean): KotlinType { // bare types are not allowed return resolveType(TypeResolutionContext(scope, trace, checkBounds, false), typeReference) } - private fun resolveType(c: TypeResolutionContext, typeReference: KtTypeReference): KtType { + private fun resolveType(c: TypeResolutionContext, typeReference: KtTypeReference): KotlinType { assert(!c.allowBareTypes) { "Use resolvePossiblyBareType() when bare types are allowed" } return resolvePossiblyBareType(c, typeReference).getActualType() } @@ -136,7 +136,7 @@ public class TypeResolver( * * todo: find another way after release */ - private fun forceResolveTypeContents(type: KtType) { + private fun forceResolveTypeContents(type: KotlinType) { type.annotations // force read type annotations if (type.isFlexible()) { forceResolveTypeContents(type.flexibility().lowerBound) @@ -180,7 +180,7 @@ public class TypeResolver( result = if (scopeForTypeParameter is ErrorUtils.ErrorScope) type(ErrorUtils.createErrorType("?")) else - type(KtTypeImpl.create( + type(KotlinTypeImpl.create( annotations, classifierDescriptor.getTypeConstructor(), TypeUtils.hasNullableLowerBound(classifierDescriptor), @@ -234,7 +234,7 @@ public class TypeResolver( ) return } - val resultingType = KtTypeImpl.create(annotations, classifierDescriptor, false, arguments) + val resultingType = KotlinTypeImpl.create(annotations, classifierDescriptor, false, arguments) result = type(resultingType) if (c.checkBounds) { val substitutor = TypeSubstitutor.create(resultingType) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/VarianceChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/VarianceChecker.kt index 57e158c3c63..7005adfaa44 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/VarianceChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/VarianceChecker.kt @@ -32,7 +32,7 @@ import org.jetbrains.kotlin.resolve.typeBinding.createTypeBindingForReturnType import org.jetbrains.kotlin.psi.KtCallableDeclaration import org.jetbrains.kotlin.descriptors.CallableDescriptor import org.jetbrains.kotlin.resolve.TopDownAnalysisContext -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.psi.KtClass import org.jetbrains.kotlin.psi.KtTypeReference import org.jetbrains.kotlin.types.Variance.* @@ -74,7 +74,7 @@ class VarianceChecker(private val trace: BindingTrace) { } class VarianceConflictDiagnosticData( - val containingType: KtType, + val containingType: KotlinType, val typeParameter: TypeParameterDescriptor, val occurrencePosition: Variance ) @@ -158,7 +158,7 @@ class VarianceChecker(private val trace: BindingTrace) { private fun TypeBinding.checkTypePosition(position: Variance, diagnosticSink: DiagnosticSink) = checkTypePosition(jetType, position, diagnosticSink) - private fun TypeBinding.checkTypePosition(containingType: KtType, position: Variance, diagnosticSink: DiagnosticSink): Boolean { + private fun TypeBinding.checkTypePosition(containingType: KotlinType, position: Variance, diagnosticSink: DiagnosticSink): Boolean { val classifierDescriptor = jetType.getConstructor().getDeclarationDescriptor() if (classifierDescriptor is TypeParameterDescriptor) { val declarationVariance = classifierDescriptor.getVariance() diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/callableReferences/CallableReferencesResolutionUtils.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/callableReferences/CallableReferencesResolutionUtils.kt index 13943fe6010..d9bd7db9f79 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/callableReferences/CallableReferencesResolutionUtils.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/callableReferences/CallableReferencesResolutionUtils.kt @@ -46,7 +46,7 @@ import org.jetbrains.kotlin.resolve.scopes.receivers.TransientReceiver import org.jetbrains.kotlin.resolve.scopes.utils.memberScopeAsFileScope import org.jetbrains.kotlin.resolve.source.toSourceElement import org.jetbrains.kotlin.types.FunctionPlaceholders -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeUtils import org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils import org.jetbrains.kotlin.utils.ThrowingList @@ -55,7 +55,7 @@ public fun resolveCallableReferenceReceiverType( callableReferenceExpression: KtCallableReferenceExpression, context: ResolutionContext<*>, typeResolver: TypeResolver -): KtType? = +): KotlinType? = callableReferenceExpression.typeReference?.let { typeResolver.resolveType(context.scope, it, context.trace, false) } @@ -93,7 +93,7 @@ private fun OverloadResolutionResults<*>.isSomething(): Boolean = !isNothing() public fun resolvePossiblyAmbiguousCallableReference( callableReferenceExpression: KtCallableReferenceExpression, - lhsType: KtType?, + lhsType: KotlinType?, context: ResolutionContext<*>, resolutionMode: ResolveArgumentsMode, callResolver: CallResolver @@ -142,7 +142,7 @@ public fun resolvePossiblyAmbiguousCallableReference( public fun resolveCallableReferenceTarget( callableReferenceExpression: KtCallableReferenceExpression, - lhsType: KtType?, + lhsType: KotlinType?, context: ResolutionContext<*>, resolvedToSomething: BooleanArray, callResolver: CallResolver @@ -164,9 +164,9 @@ public fun resolveCallableReferenceTarget( private fun createReflectionTypeForFunction( descriptor: FunctionDescriptor, - receiverType: KtType?, + receiverType: KotlinType?, reflectionTypes: ReflectionTypes -): KtType? { +): KotlinType? { val returnType = descriptor.getReturnType() ?: return null val valueParametersTypes = ExpressionTypingUtils.getValueParametersTypes(descriptor.getValueParameters()) return reflectionTypes.getKFunctionType(Annotations.EMPTY, receiverType, valueParametersTypes, returnType) @@ -174,13 +174,13 @@ private fun createReflectionTypeForFunction( private fun createReflectionTypeForProperty( descriptor: PropertyDescriptor, - receiverType: KtType?, + receiverType: KotlinType?, reflectionTypes: ReflectionTypes -): KtType { +): KotlinType { return reflectionTypes.getKPropertyType(Annotations.EMPTY, receiverType, descriptor.getType(), descriptor.isVar()) } -private fun bindFunctionReference(expression: KtCallableReferenceExpression, referenceType: KtType, context: ResolutionContext<*>) { +private fun bindFunctionReference(expression: KtCallableReferenceExpression, referenceType: KotlinType, context: ResolutionContext<*>) { val functionDescriptor = AnonymousFunctionDescriptor( context.scope.ownerDescriptor, Annotations.EMPTY, @@ -192,7 +192,7 @@ private fun bindFunctionReference(expression: KtCallableReferenceExpression, ref context.trace.record(BindingContext.FUNCTION, expression, functionDescriptor) } -private fun bindPropertyReference(expression: KtCallableReferenceExpression, referenceType: KtType, context: ResolutionContext<*>) { +private fun bindPropertyReference(expression: KtCallableReferenceExpression, referenceType: KotlinType, context: ResolutionContext<*>) { val localVariable = LocalVariableDescriptor(context.scope.ownerDescriptor, Annotations.EMPTY, Name.special(""), referenceType, /* mutable = */ false, expression.toSourceElement()) @@ -201,11 +201,11 @@ private fun bindPropertyReference(expression: KtCallableReferenceExpression, ref private fun createReflectionTypeForCallableDescriptor( descriptor: CallableDescriptor, - lhsType: KtType?, + lhsType: KotlinType?, reflectionTypes: ReflectionTypes, trace: BindingTrace?, reportOn: KtExpression? -): KtType? { +): KotlinType? { val extensionReceiver = descriptor.extensionReceiverParameter val dispatchReceiver = descriptor.dispatchReceiverParameter?.let { dispatchReceiver -> // See CallableDescriptor#getOwnerForEffectiveDispatchReceiverParameter @@ -245,16 +245,16 @@ private fun createReflectionTypeForCallableDescriptor( public fun getReflectionTypeForCandidateDescriptor( descriptor: CallableDescriptor, reflectionTypes: ReflectionTypes -): KtType? = +): KotlinType? = createReflectionTypeForCallableDescriptor(descriptor, null, reflectionTypes, null, null) public fun createReflectionTypeForResolvedCallableReference( reference: KtCallableReferenceExpression, - lhsType: KtType?, + lhsType: KotlinType?, descriptor: CallableDescriptor, context: ResolutionContext<*>, reflectionTypes: ReflectionTypes -): KtType? { +): KotlinType? { val type = createReflectionTypeForCallableDescriptor( descriptor, lhsType, reflectionTypes, context.trace, reference.getCallableReference() ) ?: return null @@ -271,14 +271,14 @@ public fun createReflectionTypeForResolvedCallableReference( public fun getResolvedCallableReferenceShapeType( reference: KtCallableReferenceExpression, - lhsType: KtType?, + lhsType: KotlinType?, overloadResolutionResults: OverloadResolutionResults?, context: ResolutionContext<*>, expectedTypeUnknown: Boolean, reflectionTypes: ReflectionTypes, builtIns: KotlinBuiltIns, functionPlaceholders: FunctionPlaceholders -): KtType? = +): KotlinType? = when { overloadResolutionResults == null -> null diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/ArgumentTypeResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/ArgumentTypeResolver.java index a25288a5978..656e138e65b 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/ArgumentTypeResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/ArgumentTypeResolver.java @@ -47,7 +47,7 @@ import org.jetbrains.kotlin.resolve.scopes.receivers.QualifierReceiver; import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue; import org.jetbrains.kotlin.types.FunctionPlaceholders; import org.jetbrains.kotlin.types.FunctionPlaceholdersKt; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.TypeUtils; import org.jetbrains.kotlin.types.checker.KotlinTypeChecker; import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices; @@ -94,11 +94,11 @@ public class ArgumentTypeResolver { } public static boolean isSubtypeOfForArgumentType( - @NotNull KtType actualType, - @NotNull KtType expectedType + @NotNull KotlinType actualType, + @NotNull KotlinType expectedType ) { if (FunctionPlaceholdersKt.isFunctionPlaceholder(actualType)) { - KtType functionType = ConstraintSystemImplKt.createTypeForFunctionPlaceholder(actualType, expectedType); + KotlinType functionType = ConstraintSystemImplKt.createTypeForFunctionPlaceholder(actualType, expectedType); return KotlinTypeChecker.DEFAULT.isSubtypeOf(functionType, expectedType); } return KotlinTypeChecker.DEFAULT.isSubtypeOf(actualType, expectedType); @@ -231,19 +231,19 @@ public class ArgumentTypeResolver { @NotNull ResolveArgumentsMode resolveArgumentsMode ) { if (resolveArgumentsMode == SHAPE_FUNCTION_ARGUMENTS) { - KtType type = getShapeTypeOfCallableReference(callableReferenceExpression, context, true); + KotlinType type = getShapeTypeOfCallableReference(callableReferenceExpression, context, true); return TypeInfoFactoryKt.createTypeInfo(type); } return expressionTypingServices.getTypeInfo(expression, context.replaceContextDependency(INDEPENDENT)); } @Nullable - public KtType getShapeTypeOfCallableReference( + public KotlinType getShapeTypeOfCallableReference( @NotNull KtCallableReferenceExpression callableReferenceExpression, @NotNull CallResolutionContext context, boolean expectedTypeIsUnknown ) { - KtType receiverType = + KotlinType receiverType = CallableReferencesResolutionUtilsKt.resolveCallableReferenceReceiverType(callableReferenceExpression, context, typeResolver); OverloadResolutionResults overloadResolutionResults = CallableReferencesResolutionUtilsKt.resolvePossiblyAmbiguousCallableReference( @@ -262,14 +262,14 @@ public class ArgumentTypeResolver { @NotNull ResolveArgumentsMode resolveArgumentsMode ) { if (resolveArgumentsMode == SHAPE_FUNCTION_ARGUMENTS) { - KtType type = getShapeTypeOfFunctionLiteral(functionLiteral, context.scope, context.trace, true); + KotlinType type = getShapeTypeOfFunctionLiteral(functionLiteral, context.scope, context.trace, true); return TypeInfoFactoryKt.createTypeInfo(type, context); } return expressionTypingServices.getTypeInfo(expression, context.replaceContextDependency(INDEPENDENT)); } @Nullable - public KtType getShapeTypeOfFunctionLiteral( + public KotlinType getShapeTypeOfFunctionLiteral( @NotNull KtFunction function, @NotNull LexicalScope scope, @NotNull BindingTrace trace, @@ -279,19 +279,19 @@ public class ArgumentTypeResolver { if (function.getValueParameterList() == null && isFunctionLiteral) { return expectedTypeIsUnknown ? functionPlaceholders - .createFunctionPlaceholderType(Collections.emptyList(), /* hasDeclaredArguments = */ false) - : builtIns.getFunctionType(Annotations.Companion.getEMPTY(), null, Collections.emptyList(), DONT_CARE); + .createFunctionPlaceholderType(Collections.emptyList(), /* hasDeclaredArguments = */ false) + : builtIns.getFunctionType(Annotations.Companion.getEMPTY(), null, Collections.emptyList(), DONT_CARE); } List valueParameters = function.getValueParameters(); TemporaryBindingTrace temporaryTrace = TemporaryBindingTrace.create( trace, "trace to resolve function literal parameter types"); - List parameterTypes = Lists.newArrayList(); + List parameterTypes = Lists.newArrayList(); for (KtParameter parameter : valueParameters) { parameterTypes.add(resolveTypeRefWithDefault(parameter.getTypeReference(), scope, temporaryTrace, DONT_CARE)); } - KtType returnType = resolveTypeRefWithDefault(function.getTypeReference(), scope, temporaryTrace, DONT_CARE); + KotlinType returnType = resolveTypeRefWithDefault(function.getTypeReference(), scope, temporaryTrace, DONT_CARE); assert returnType != null; - KtType receiverType = resolveTypeRefWithDefault(function.getReceiverTypeReference(), scope, temporaryTrace, null); + KotlinType receiverType = resolveTypeRefWithDefault(function.getReceiverTypeReference(), scope, temporaryTrace, null); return expectedTypeIsUnknown && isFunctionLiteral ? functionPlaceholders.createFunctionPlaceholderType(parameterTypes, /* hasDeclaredArguments = */ true) @@ -299,11 +299,11 @@ public class ArgumentTypeResolver { } @Nullable - public KtType resolveTypeRefWithDefault( + public KotlinType resolveTypeRefWithDefault( @Nullable KtTypeReference returnTypeRef, @NotNull LexicalScope scope, @NotNull BindingTrace trace, - @Nullable KtType defaultValue + @Nullable KotlinType defaultValue ) { if (returnTypeRef != null) { return typeResolver.resolveType(scope, returnTypeRef, trace, true); @@ -347,15 +347,15 @@ public class ArgumentTypeResolver { } @Nullable - public KtType updateResultArgumentTypeIfNotDenotable( + public KotlinType updateResultArgumentTypeIfNotDenotable( @NotNull ResolutionContext context, @NotNull KtExpression expression ) { - KtType type = context.trace.getType(expression); + KotlinType type = context.trace.getType(expression); if (type != null && !type.getConstructor().isDenotable()) { if (type.getConstructor() instanceof IntegerValueTypeConstructor) { IntegerValueTypeConstructor constructor = (IntegerValueTypeConstructor) type.getConstructor(); - KtType primitiveType = TypeUtils.getPrimitiveNumberType(constructor, context.expectedType); + KotlinType primitiveType = TypeUtils.getPrimitiveNumberType(constructor, context.expectedType); constantExpressionEvaluator.updateNumberType(primitiveType, expression, context.statementFilter, context.trace); return primitiveType; } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallCompleter.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallCompleter.kt index daa23d184ed..269a29646bf 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallCompleter.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallCompleter.kt @@ -42,7 +42,7 @@ import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo import org.jetbrains.kotlin.resolve.calls.tasks.TracingStrategy import org.jetbrains.kotlin.resolve.validation.SymbolUsageValidator import org.jetbrains.kotlin.types.ErrorUtils -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeUtils import org.jetbrains.kotlin.types.expressions.DataFlowAnalyzer import java.util.* @@ -136,7 +136,7 @@ public class CallCompleter( } private fun MutableResolvedCall.completeConstraintSystem( - expectedType: KtType, + expectedType: KotlinType, trace: BindingTrace ) { fun updateSystemIfSuccessful(update: (ConstraintSystemImpl) -> Boolean) { @@ -240,7 +240,7 @@ public class CallCompleter( val deparenthesized = KtPsiUtil.getLastElementDeparenthesized(expression, context.statementFilter) ?: return val recordedType = expression.let { context.trace.getType(it) } - var updatedType: KtType? = recordedType + var updatedType: KotlinType? = recordedType val results = completeCallForArgument(deparenthesized, context) if (results != null && results.isSingleResult()) { @@ -288,11 +288,11 @@ public class CallCompleter( } private fun updateRecordedTypeForArgument( - updatedType: KtType?, - recordedType: KtType?, + updatedType: KotlinType?, + recordedType: KotlinType?, argumentExpression: KtExpression, trace: BindingTrace - ): KtType? { + ): KotlinType? { //workaround for KT-8218 if ((!ErrorUtils.containsErrorType(recordedType) && recordedType == updatedType) || updatedType == null) return updatedType diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallExpressionResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallExpressionResolver.java index 0c9787d86da..5282af54009 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallExpressionResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallExpressionResolver.java @@ -43,7 +43,7 @@ import org.jetbrains.kotlin.resolve.constants.evaluate.ConstantExpressionEvaluat import org.jetbrains.kotlin.resolve.scopes.receivers.*; import org.jetbrains.kotlin.resolve.validation.SymbolUsageValidator; import org.jetbrains.kotlin.types.ErrorUtils; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.TypeUtils; import org.jetbrains.kotlin.types.expressions.DataFlowAnalyzer; import org.jetbrains.kotlin.types.expressions.ExpressionTypingContext; @@ -103,7 +103,7 @@ public class CallExpressionResolver { } @Nullable - private KtType getVariableType( + private KotlinType getVariableType( @NotNull KtSimpleNameExpression nameExpression, @NotNull ReceiverValue receiver, @Nullable ASTNode callOperationNode, @NotNull ExpressionTypingContext context, @NotNull boolean[] result ) { @@ -149,7 +149,7 @@ public class CallExpressionResolver { TemporaryTraceAndCache temporaryForVariable = TemporaryTraceAndCache.create( context, "trace to resolve as variable", nameExpression); - KtType type = + KotlinType type = getVariableType(nameExpression, receiver, callOperationNode, context.replaceTraceAndCache(temporaryForVariable), result); // TODO: for a safe call, it's necessary to set receiver != null here, as inside ArgumentTypeResolver.analyzeArgumentsAndRecordTypes // Unfortunately it provokes problems with x?.y!!.foo() with the following x!!.bar(): @@ -236,7 +236,7 @@ public class CallExpressionResolver { } } - KtType type = functionDescriptor.getReturnType(); + KotlinType type = functionDescriptor.getReturnType(); // Extracting jump out possible and jump point flow info from arguments, if any List arguments = callExpression.getValueArguments(); DataFlowInfo resultFlowInfo = resolvedCall.getDataFlowInfoForArguments().getResultInfo(); @@ -257,8 +257,8 @@ public class CallExpressionResolver { if (calleeExpression instanceof KtSimpleNameExpression && callExpression.getTypeArgumentList() == null) { TemporaryTraceAndCache temporaryForVariable = TemporaryTraceAndCache.create( context, "trace to resolve as variable with 'invoke' call", callExpression); - KtType type = getVariableType((KtSimpleNameExpression) calleeExpression, receiver, callOperationNode, - context.replaceTraceAndCache(temporaryForVariable), result); + KotlinType type = getVariableType((KtSimpleNameExpression) calleeExpression, receiver, callOperationNode, + context.replaceTraceAndCache(temporaryForVariable), result); Qualifier qualifier = temporaryForVariable.trace.get(BindingContext.QUALIFIER, calleeExpression); if (result[0] && (qualifier == null || qualifier.getPackageView() == null)) { temporaryForVariable.commit(); @@ -350,7 +350,7 @@ public class CallExpressionResolver { replaceInsideCallChain(true); // Enter call chain // Visit receiver (x in x.y or x?.z) here. Recursion is possible. JetTypeInfo receiverTypeInfo = expressionTypingServices.getTypeInfo(receiverExpression, contextForReceiver); - KtType receiverType = receiverTypeInfo.getType(); + KotlinType receiverType = receiverTypeInfo.getType(); QualifierReceiver qualifierReceiver = (QualifierReceiver) context.trace.get(BindingContext.QUALIFIER, receiverExpression); if (receiverType == null) receiverType = ErrorUtils.createErrorType("Type for " + expression.getText()); @@ -363,7 +363,7 @@ public class CallExpressionResolver { // Visit selector (y in x.y) here. Recursion is also possible. JetTypeInfo selectorReturnTypeInfo = getSelectorReturnTypeInfo( receiver, expression.getOperationTokenNode(), selectorExpression, context); - KtType selectorReturnType = selectorReturnTypeInfo.getType(); + KotlinType selectorReturnType = selectorReturnTypeInfo.getType(); resolveDeferredReceiverInQualifiedExpression(qualifierReceiver, expression, context); checkNestedClassAccess(expression, context); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolver.java index 2161ecd824a..2c56064381a 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolver.java @@ -51,7 +51,7 @@ import org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil; import org.jetbrains.kotlin.resolve.scopes.LexicalScope; import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver; import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.TypeSubstitutor; import org.jetbrains.kotlin.types.expressions.ExpressionTypingContext; import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices; @@ -264,7 +264,7 @@ public class CallResolver { @NotNull BindingTrace trace, @NotNull LexicalScope scope, @NotNull Call call, - @NotNull KtType expectedType, + @NotNull KotlinType expectedType, @NotNull DataFlowInfo dataFlowInfo, boolean isAnnotationContext ) { @@ -311,16 +311,16 @@ public class CallResolver { } // Here we handle the case where the callee expression must be something of type function, e.g. (foo.bar())(1, 2) - KtType expectedType = NO_EXPECTED_TYPE; + KotlinType expectedType = NO_EXPECTED_TYPE; if (calleeExpression instanceof KtFunctionLiteralExpression) { int parameterNumber = ((KtFunctionLiteralExpression) calleeExpression).getValueParameters().size(); - List parameterTypes = new ArrayList(parameterNumber); + List parameterTypes = new ArrayList(parameterNumber); for (int i = 0; i < parameterNumber; i++) { parameterTypes.add(NO_EXPECTED_TYPE); } expectedType = builtIns.getFunctionType(Annotations.Companion.getEMPTY(), null, parameterTypes, context.expectedType); } - KtType calleeType = expressionTypingServices.safeGetType( + KotlinType calleeType = expressionTypingServices.safeGetType( context.scope, calleeExpression, expectedType, context.dataFlowInfo, context.trace); ExpressionReceiver expressionReceiver = new ExpressionReceiver(calleeExpression, calleeType); @@ -343,7 +343,7 @@ public class CallResolver { if (functionReference == null || typeReference == null) { return checkArgumentTypesAndFail(context); // No type there } - KtType constructedType = typeResolver.resolveType(context.scope, typeReference, context.trace, true); + KotlinType constructedType = typeResolver.resolveType(context.scope, typeReference, context.trace, true); if (constructedType.isError()) { return checkArgumentTypesAndFail(context); } @@ -436,9 +436,9 @@ public class CallResolver { ((ClassDescriptor) delegateClassDescriptor.getContainingDeclaration()). getThisAsReceiverParameter().getValue(); - KtType expectedType = isThisCall ? - calleeConstructor.getContainingDeclaration().getDefaultType() : - DescriptorUtils.getSuperClassType(currentClassDescriptor); + KotlinType expectedType = isThisCall ? + calleeConstructor.getContainingDeclaration().getDefaultType() : + DescriptorUtils.getSuperClassType(currentClassDescriptor); TypeSubstitutor knownTypeParametersSubstitutor = TypeSubstitutor.create(expectedType); for (CallableDescriptor descriptor : constructors) { @@ -565,7 +565,7 @@ public class CallResolver { context.trace.report(PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT.on(projection)); ModifierCheckerCore.INSTANCE.check(projection, context.trace, null); } - KtType type = argumentTypeResolver.resolveTypeRefWithDefault( + KotlinType type = argumentTypeResolver.resolveTypeRefWithDefault( projection.getTypeReference(), context.scope, context.trace, null); if (type != null) { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolverUtil.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolverUtil.kt index ed8abb2691e..30f81fa92ee 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolverUtil.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolverUtil.kt @@ -40,19 +40,19 @@ public enum class ResolveArgumentsMode { } -public fun hasUnknownFunctionParameter(type: KtType): Boolean { +public fun hasUnknownFunctionParameter(type: KotlinType): Boolean { assert(ReflectionTypes.isCallableType(type)) { "type $type is not a function or property" } return getParameterArgumentsOfCallableType(type).any { TypeUtils.containsSpecialType(it.getType(), DONT_CARE) || ErrorUtils.containsUninferredParameter(it.getType()) } } -public fun hasUnknownReturnType(type: KtType): Boolean { +public fun hasUnknownReturnType(type: KotlinType): Boolean { assert(ReflectionTypes.isCallableType(type)) { "type $type is not a function or property" } return ErrorUtils.containsErrorType(getReturnTypeForCallable(type)) } -public fun replaceReturnTypeByUnknown(type: KtType): KtType { +public fun replaceReturnTypeByUnknown(type: KotlinType): KotlinType { assert(ReflectionTypes.isCallableType(type)) { "type $type is not a function or property" } val newArguments = Lists.newArrayList() newArguments.addAll(getParameterArgumentsOfCallableType(type)) @@ -60,13 +60,13 @@ public fun replaceReturnTypeByUnknown(type: KtType): KtType { return replaceTypeArguments(type, newArguments) } -private fun replaceTypeArguments(type: KtType, newArguments: List) = - KtTypeImpl.create(type.getAnnotations(), type.getConstructor(), type.isMarkedNullable(), newArguments, type.getMemberScope()) +private fun replaceTypeArguments(type: KotlinType, newArguments: List) = + KotlinTypeImpl.create(type.getAnnotations(), type.getConstructor(), type.isMarkedNullable(), newArguments, type.getMemberScope()) -private fun getParameterArgumentsOfCallableType(type: KtType) = +private fun getParameterArgumentsOfCallableType(type: KotlinType) = type.getArguments().dropLast(1) -private fun getReturnTypeForCallable(type: KtType) = +private fun getReturnTypeForCallable(type: KotlinType) = type.getArguments().last().getType() private fun CallableDescriptor.hasReturnTypeDependentOnUninferredParams(constraintSystem: ConstraintSystem): Boolean { @@ -86,7 +86,7 @@ public fun CallableDescriptor.hasInferredReturnType(constraintSystem: Constraint return true } -public fun getErasedReceiverType(receiverParameterDescriptor: ReceiverParameterDescriptor, descriptor: CallableDescriptor): KtType { +public fun getErasedReceiverType(receiverParameterDescriptor: ReceiverParameterDescriptor, descriptor: CallableDescriptor): KotlinType { var receiverType = receiverParameterDescriptor.getType() for (typeParameter in descriptor.getTypeParameters()) { if (typeParameter.getTypeConstructor() == receiverType.getConstructor()) { @@ -97,7 +97,7 @@ public fun getErasedReceiverType(receiverParameterDescriptor: ReceiverParameterD for (typeProjection in receiverType.getArguments()) { fakeTypeArguments.add(TypeProjectionImpl(typeProjection.getProjectionKind(), DONT_CARE)) } - return KtTypeImpl.create(receiverType.getAnnotations(), receiverType.getConstructor(), receiverType.isMarkedNullable(), fakeTypeArguments, + return KotlinTypeImpl.create(receiverType.getAnnotations(), receiverType.getConstructor(), receiverType.isMarkedNullable(), fakeTypeArguments, ErrorUtils.createErrorScope("Error scope for erased receiver type", /*throwExceptions=*/true)) } @@ -146,7 +146,7 @@ public fun getSuperCallExpression(call: Call): KtSuperExpression? { return (call.getExplicitReceiver() as? ExpressionReceiver)?.getExpression() as? KtSuperExpression } -public fun getEffectiveExpectedType(parameterDescriptor: ValueParameterDescriptor, argument: ValueArgument): KtType { +public fun getEffectiveExpectedType(parameterDescriptor: ValueParameterDescriptor, argument: ValueArgument): KotlinType { if (argument.getSpreadElement() != null) { if (parameterDescriptor.getVarargElementType() == null) { // Spread argument passed to a non-vararg parameter, an error is already reported by ValueArgumentsToParametersMapper diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallTransformer.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallTransformer.java index 4c9e7d67576..f80edae4029 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallTransformer.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallTransformer.java @@ -45,7 +45,7 @@ import org.jetbrains.kotlin.resolve.calls.tasks.TracingStrategyForInvoke; import org.jetbrains.kotlin.resolve.calls.util.DelegatingCall; import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver; import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.util.OperatorNameConventions; import java.util.Collection; @@ -225,7 +225,7 @@ public class CallTransformer { } assert descriptor instanceof VariableDescriptor; - KtType returnType = descriptor.getReturnType(); + KotlinType returnType = descriptor.getReturnType(); if (returnType == null) { return Collections.emptyList(); } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CandidateResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CandidateResolver.kt index b584543d397..86324e9facd 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CandidateResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CandidateResolver.kt @@ -114,7 +114,7 @@ public class CandidateResolver( if (!jetTypeArguments.isEmpty()) { // Explicit type arguments passed - val typeArguments = ArrayList() + val typeArguments = ArrayList() for (projection in jetTypeArguments) { val type = projection.typeReference?.let { trace.bindingContext.get(BindingContext.TYPE, it) } ?: ErrorUtils.createErrorType("Star projection in a call") @@ -312,7 +312,7 @@ public class CandidateResolver( candidateCall: MutableResolvedCall, resolveFunctionArgumentBodies: ResolveArgumentsMode): ValueArgumentsCheckingResult { var resultStatus = SUCCESS - val argumentTypes = Lists.newArrayList() + val argumentTypes = Lists.newArrayList() val infoForArguments = candidateCall.getDataFlowInfoForArguments() for (entry in candidateCall.getValueArguments().entrySet()) { val parameterDescriptor = entry.getKey() @@ -331,7 +331,7 @@ public class CandidateResolver( infoForArguments.updateInfo(argument, typeInfoForCall.dataFlowInfo) var matchStatus = ArgumentMatchStatus.SUCCESS - var resultingType: KtType? = type + var resultingType: KotlinType? = type if (type == null || (type.isError() && !type.isFunctionPlaceholder)) { matchStatus = ArgumentMatchStatus.ARGUMENT_HAS_NO_TYPE } @@ -359,9 +359,9 @@ public class CandidateResolver( private fun smartCastValueArgumentTypeIfPossible( expression: KtExpression, - expectedType: KtType, - actualType: KtType, - context: ResolutionContext<*>): KtType? { + expectedType: KotlinType, + actualType: KotlinType, + context: ResolutionContext<*>): KotlinType? { val receiverToCast = ExpressionReceiver(KtPsiUtil.safeDeparenthesize(expression), actualType) val variants = smartCastManager.getSmartCastVariantsExcludingReceiver(context, receiverToCast) for (possibleType in variants) { @@ -482,11 +482,11 @@ public class CandidateResolver( return SUCCESS } - public inner class ValueArgumentsCheckingResult(public val status: ResolutionStatus, public val argumentTypes: List) + public inner class ValueArgumentsCheckingResult(public val status: ResolutionStatus, public val argumentTypes: List) private fun checkGenericBoundsInAFunctionCall( jetTypeArguments: List, - typeArguments: List, + typeArguments: List, functionDescriptor: CallableDescriptor, substitutor: TypeSubstitutor, trace: BindingTrace) { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/GenericCandidateResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/GenericCandidateResolver.kt index ac2ad623e95..02b2e0563b3 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/GenericCandidateResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/GenericCandidateResolver.kt @@ -94,7 +94,7 @@ class GenericCandidateResolver( val receiverArgument = candidateCall.getExtensionReceiver() val receiverParameter = candidate.getExtensionReceiverParameter() if (receiverArgument.exists() && receiverParameter != null) { - var receiverType: KtType? = if (context.candidateCall.isSafeCall()) + var receiverType: KotlinType? = if (context.candidateCall.isSafeCall()) TypeUtils.makeNotNullable(receiverArgument.getType()) else receiverArgument.getType() @@ -144,7 +144,7 @@ class GenericCandidateResolver( constraintPosition: ConstraintPosition, constraintSystem: ConstraintSystem, context: CallCandidateResolutionContext<*>, - effectiveExpectedType: KtType + effectiveExpectedType: KotlinType ): Boolean { val resolutionResults = getResolutionResultsCachedData(argumentExpression, context)?.resolutionResults if (resolutionResults == null || !resolutionResults.isSingleResult()) return false @@ -175,10 +175,10 @@ class GenericCandidateResolver( } private fun updateResultTypeForSmartCasts( - type: KtType?, + type: KotlinType?, argumentExpression: KtExpression?, context: ResolutionContext<*> - ): KtType? { + ): KotlinType? { val deparenthesizedArgument = KtPsiUtil.getLastElementDeparenthesized(argumentExpression, context.statementFilter) if (deparenthesizedArgument == null || type == null) return type @@ -287,8 +287,8 @@ class GenericCandidateResolver( callableReference: KtCallableReferenceExpression, constraintSystem: ConstraintSystem, context: CallCandidateResolutionContext, - effectiveExpectedType: KtType - ): KtType? { + effectiveExpectedType: KotlinType + ): KotlinType? { val substitutedType = constraintSystem.getCurrentSubstitutor().substitute(effectiveExpectedType, Variance.INVARIANT) if (substitutedType != null && !TypeUtils.isDontCarePlaceholder(substitutedType)) return substitutedType @@ -303,9 +303,9 @@ class GenericCandidateResolver( private fun getResolvedTypeForCallableReference( callableReference: KtCallableReferenceExpression, context: CallCandidateResolutionContext, - expectedType: KtType, + expectedType: KotlinType, valueArgument: ValueArgument - ): KtType? { + ): KotlinType? { val dataFlowInfoForArgument = context.candidateCall.getDataFlowInfoForArguments().getInfo(valueArgument) val expectedTypeWithoutReturnType = if (!hasUnknownReturnType(expectedType)) replaceReturnTypeByUnknown(expectedType) else expectedType val newContext = context diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/checkers/AdditionalTypeChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/checkers/AdditionalTypeChecker.kt index 9a4dd80170b..c70884bbaf3 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/checkers/AdditionalTypeChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/checkers/AdditionalTypeChecker.kt @@ -21,10 +21,10 @@ import org.jetbrains.kotlin.psi.KtExpression import org.jetbrains.kotlin.resolve.calls.context.CallResolutionContext import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType public interface AdditionalTypeChecker { - fun checkType(expression: KtExpression, expressionType: KtType, expressionTypeWithSmartCast: KtType, c: ResolutionContext<*>) + fun checkType(expression: KtExpression, expressionType: KotlinType, expressionTypeWithSmartCast: KotlinType, c: ResolutionContext<*>) fun checkReceiver( receiverParameter: ReceiverParameterDescriptor, receiverArgument: ReceiverValue, diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/checkers/ReifiedTypeParameterSubstitutionChecker.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/checkers/ReifiedTypeParameterSubstitutionChecker.java index 9478c71ce3b..6b1f846602a 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/checkers/ReifiedTypeParameterSubstitutionChecker.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/checkers/ReifiedTypeParameterSubstitutionChecker.java @@ -25,7 +25,7 @@ import org.jetbrains.kotlin.diagnostics.Errors; import org.jetbrains.kotlin.psi.KtExpression; import org.jetbrains.kotlin.resolve.calls.context.BasicCallResolutionContext; import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.typeUtil.TypeUtilsKt; import java.util.Map; @@ -35,10 +35,10 @@ public class ReifiedTypeParameterSubstitutionChecker implements CallChecker { public void check( @NotNull ResolvedCall resolvedCall, @NotNull BasicCallResolutionContext context ) { - Map typeArguments = resolvedCall.getTypeArguments(); - for (Map.Entry entry : typeArguments.entrySet()) { + Map typeArguments = resolvedCall.getTypeArguments(); + for (Map.Entry entry : typeArguments.entrySet()) { TypeParameterDescriptor parameter = entry.getKey(); - KtType argument = entry.getValue(); + KotlinType argument = entry.getValue(); ClassifierDescriptor argumentDeclarationDescription = argument.getConstructor().getDeclarationDescriptor(); if (parameter.isReified()) { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/context/BasicCallResolutionContext.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/context/BasicCallResolutionContext.java index 69c2261ff1a..f4b1578aadc 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/context/BasicCallResolutionContext.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/context/BasicCallResolutionContext.java @@ -26,14 +26,14 @@ import org.jetbrains.kotlin.resolve.calls.model.MutableDataFlowInfoForArguments; import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall; import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo; import org.jetbrains.kotlin.resolve.scopes.LexicalScope; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; public class BasicCallResolutionContext extends CallResolutionContext { private BasicCallResolutionContext( @NotNull BindingTrace trace, @NotNull LexicalScope scope, @NotNull Call call, - @NotNull KtType expectedType, + @NotNull KotlinType expectedType, @NotNull DataFlowInfo dataFlowInfo, @NotNull ContextDependency contextDependency, @NotNull CheckArgumentTypesMode checkArguments, @@ -54,7 +54,7 @@ public class BasicCallResolutionContext extends CallResolutionContext extends CallResolutionContext> { @NotNull @@ -47,7 +47,7 @@ public final class CallCandidateResolutionContext @NotNull BindingTrace trace, @NotNull LexicalScope scope, @NotNull Call call, - @NotNull KtType expectedType, + @NotNull KotlinType expectedType, @NotNull DataFlowInfo dataFlowInfo, @NotNull ContextDependency contextDependency, @NotNull CheckArgumentTypesMode checkArguments, @@ -99,7 +99,7 @@ public final class CallCandidateResolutionContext @NotNull BindingTrace trace, @NotNull LexicalScope scope, @NotNull DataFlowInfo dataFlowInfo, - @NotNull KtType expectedType, + @NotNull KotlinType expectedType, @NotNull ContextDependency contextDependency, @NotNull ResolutionResultsCache resolutionResultsCache, @NotNull StatementFilter statementFilter, diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/context/CallResolutionContext.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/context/CallResolutionContext.java index 71b33e253dd..2c781a14653 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/context/CallResolutionContext.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/context/CallResolutionContext.java @@ -26,7 +26,7 @@ import org.jetbrains.kotlin.resolve.calls.model.DataFlowInfoForArgumentsImpl; import org.jetbrains.kotlin.resolve.calls.model.MutableDataFlowInfoForArguments; import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo; import org.jetbrains.kotlin.resolve.scopes.LexicalScope; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; public abstract class CallResolutionContext> extends ResolutionContext { @NotNull @@ -40,7 +40,7 @@ public abstract class CallResolutionContext { } @NotNull - public SubtypingConstraint assertSubtyping(@NotNull KtType subtype, @NotNull KtType supertype) { + public SubtypingConstraint assertSubtyping(@NotNull KotlinType subtype, @NotNull KotlinType supertype) { return new SubtypingConstraint(this, subtype, supertype); } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintsUtil.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintsUtil.java index e28abefcd9d..5d47c8b30e4 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintsUtil.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintsUtil.java @@ -45,10 +45,10 @@ public class ConstraintsUtil { TypeParameterDescriptor firstConflictingParameter = getFirstConflictingParameter(constraintSystem); if (firstConflictingParameter == null) return Collections.emptyList(); - Collection conflictingTypes = constraintSystem.getTypeBounds(firstConflictingParameter).getValues(); + Collection conflictingTypes = constraintSystem.getTypeBounds(firstConflictingParameter).getValues(); List> substitutionContexts = Lists.newArrayList(); - for (KtType type : conflictingTypes) { + for (KotlinType type : conflictingTypes) { Map context = Maps.newLinkedHashMap(); context.put(firstConflictingParameter.getTypeConstructor(), new TypeProjectionImpl(type)); substitutionContexts.add(context); @@ -57,7 +57,7 @@ public class ConstraintsUtil { for (TypeParameterDescriptor typeParameter : constraintSystem.getTypeVariables()) { if (typeParameter == firstConflictingParameter) continue; - KtType safeType = getSafeValue(constraintSystem, typeParameter); + KotlinType safeType = getSafeValue(constraintSystem, typeParameter); for (Map context : substitutionContexts) { TypeProjection typeProjection = new TypeProjectionImpl(safeType); context.put(typeParameter.getTypeConstructor(), typeProjection); @@ -71,8 +71,8 @@ public class ConstraintsUtil { } @NotNull - public static KtType getSafeValue(@NotNull ConstraintSystem constraintSystem, @NotNull TypeParameterDescriptor typeParameter) { - KtType type = constraintSystem.getTypeBounds(typeParameter).getValue(); + public static KotlinType getSafeValue(@NotNull ConstraintSystem constraintSystem, @NotNull TypeParameterDescriptor typeParameter) { + KotlinType type = constraintSystem.getTypeBounds(typeParameter).getValue(); if (type != null) { return type; } @@ -85,13 +85,13 @@ public class ConstraintsUtil { @NotNull TypeParameterDescriptor typeParameter, boolean substituteOtherTypeParametersInBound ) { - KtType type = constraintSystem.getTypeBounds(typeParameter).getValue(); + KotlinType type = constraintSystem.getTypeBounds(typeParameter).getValue(); if (type == null) return true; - for (KtType upperBound : typeParameter.getUpperBounds()) { + for (KotlinType upperBound : typeParameter.getUpperBounds()) { if (!substituteOtherTypeParametersInBound && TypeUtils.dependsOnTypeParameters(upperBound, constraintSystem.getTypeVariables())) { continue; } - KtType substitutedUpperBound = constraintSystem.getResultingSubstitutor().substitute(upperBound, Variance.INVARIANT); + KotlinType substitutedUpperBound = constraintSystem.getResultingSubstitutor().substitute(upperBound, Variance.INVARIANT); assert substitutedUpperBound != null : "We wanted to substitute projections as a result for " + typeParameter; if (!KotlinTypeChecker.DEFAULT.isSubtypeOf(type, substitutedUpperBound)) { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/InferenceErrorData.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/InferenceErrorData.java index d2d0f3a7b79..a286100cb87 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/InferenceErrorData.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/InferenceErrorData.java @@ -19,7 +19,7 @@ package org.jetbrains.kotlin.resolve.calls.inference; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.descriptors.CallableDescriptor; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import java.util.List; @@ -29,16 +29,16 @@ public class InferenceErrorData { @NotNull public final ConstraintSystem constraintSystem; @Nullable - public final KtType receiverArgumentType; + public final KotlinType receiverArgumentType; @NotNull - public final KtType expectedType; + public final KotlinType expectedType; @NotNull - public final List valueArgumentsTypes; + public final List valueArgumentsTypes; private InferenceErrorData( @NotNull CallableDescriptor descriptor, @NotNull ConstraintSystem constraintSystem, - @NotNull List valueArgumentsTypes, @Nullable KtType receiverArgumentType, @NotNull KtType expectedType + @NotNull List valueArgumentsTypes, @Nullable KotlinType receiverArgumentType, @NotNull KotlinType expectedType ) { this.descriptor = descriptor; this.constraintSystem = constraintSystem; @@ -49,7 +49,7 @@ public class InferenceErrorData { @NotNull public static InferenceErrorData create(@NotNull CallableDescriptor descriptor, @NotNull ConstraintSystem constraintSystem, - @NotNull List valueArgumentsTypes, @Nullable KtType receiverArgumentType, @NotNull KtType expectedType) { + @NotNull List valueArgumentsTypes, @Nullable KotlinType receiverArgumentType, @NotNull KotlinType expectedType) { return new InferenceErrorData(descriptor, constraintSystem, valueArgumentsTypes, receiverArgumentType, expectedType); } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/SubtypingConstraint.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/SubtypingConstraint.java index 2a8591bbc8e..2bf85c92f54 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/SubtypingConstraint.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/SubtypingConstraint.java @@ -17,26 +17,26 @@ package org.jetbrains.kotlin.resolve.calls.inference; import org.jetbrains.annotations.NotNull; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; public class SubtypingConstraint { private final ConstraintType type; - private final KtType subtype; - private final KtType supertype; + private final KotlinType subtype; + private final KotlinType supertype; - public SubtypingConstraint(@NotNull ConstraintType type, @NotNull KtType subtype, @NotNull KtType supertype) { + public SubtypingConstraint(@NotNull ConstraintType type, @NotNull KotlinType subtype, @NotNull KotlinType supertype) { this.type = type; this.subtype = subtype; this.supertype = supertype; } @NotNull - public KtType getSubtype() { + public KotlinType getSubtype() { return subtype; } @NotNull - public KtType getSupertype() { + public KotlinType getSupertype() { return supertype; } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/model/DelegatingResolvedCall.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/model/DelegatingResolvedCall.java index 304aab9907d..20da37a93dd 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/model/DelegatingResolvedCall.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/model/DelegatingResolvedCall.java @@ -26,7 +26,7 @@ import org.jetbrains.kotlin.psi.ValueArgument; import org.jetbrains.kotlin.resolve.calls.results.ResolutionStatus; import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind; import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import java.util.List; import java.util.Map; @@ -100,7 +100,7 @@ public abstract class DelegatingResolvedCall imple @NotNull @Override - public Map getTypeArguments() { + public Map getTypeArguments() { return resolvedCall.getTypeArguments(); } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/model/ResolvedCall.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/model/ResolvedCall.java index 5f7e98eb4bc..2d745752e71 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/model/ResolvedCall.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/model/ResolvedCall.java @@ -26,7 +26,7 @@ import org.jetbrains.kotlin.psi.ValueArgument; import org.jetbrains.kotlin.resolve.calls.results.ResolutionStatus; import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind; import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import java.util.List; import java.util.Map; @@ -73,7 +73,7 @@ public interface ResolvedCall { /** What's substituted for type parameters */ @NotNull - Map getTypeArguments(); + Map getTypeArguments(); /** Data flow info for each argument and the result data flow info */ @NotNull diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/model/ResolvedCallImpl.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/model/ResolvedCallImpl.java index dea7e12ded9..3ae128530b7 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/model/ResolvedCallImpl.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/model/ResolvedCallImpl.java @@ -35,7 +35,7 @@ import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind; import org.jetbrains.kotlin.resolve.calls.tasks.ResolutionCandidate; import org.jetbrains.kotlin.resolve.calls.tasks.TracingStrategy; import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.TypeProjection; import org.jetbrains.kotlin.types.TypeSubstitutor; @@ -81,7 +81,7 @@ public class ResolvedCallImpl implements MutableRe private final ExplicitReceiverKind explicitReceiverKind; private final TypeSubstitutor knownTypeParametersSubstitutor; - private final Map typeArguments = Maps.newLinkedHashMap(); + private final Map typeArguments = Maps.newLinkedHashMap(); private final Map valueArguments = Maps.newLinkedHashMap(); private final MutableDataFlowInfoForArguments dataFlowInfoForArguments; private final Map argumentToParameterMap = Maps.newHashMap(); @@ -287,7 +287,7 @@ public class ResolvedCallImpl implements MutableRe @NotNull @Override - public Map getTypeArguments() { + public Map getTypeArguments() { return typeArguments; } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/results/OverloadResolutionResultsUtil.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/results/OverloadResolutionResultsUtil.java index b8156a52f5f..79d8f74f1e3 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/results/OverloadResolutionResultsUtil.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/results/OverloadResolutionResultsUtil.java @@ -23,7 +23,7 @@ import org.jetbrains.kotlin.descriptors.CallableDescriptor; import org.jetbrains.kotlin.resolve.calls.context.ContextDependency; import org.jetbrains.kotlin.resolve.calls.model.MutableResolvedCall; import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import java.util.Collection; @@ -37,7 +37,7 @@ public class OverloadResolutionResultsUtil { } @Nullable - public static KtType getResultingType( + public static KotlinType getResultingType( @NotNull OverloadResolutionResults results, @NotNull ContextDependency contextDependency ) { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/results/OverloadingConflictResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/results/OverloadingConflictResolver.java index 1ea81e096ae..0914706b350 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/results/OverloadingConflictResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/results/OverloadingConflictResolver.java @@ -164,8 +164,8 @@ public class OverloadingConflictResolver { ValueParameterDescriptor fParam = fParams.get(i); ValueParameterDescriptor gParam = gParams.get(i); - KtType fParamType = fParam.getType(); - KtType gParamType = gParam.getType(); + KotlinType fParamType = fParam.getType(); + KotlinType gParamType = gParam.getType(); if (!typeMoreSpecific(fParamType, gParamType)) { return false; @@ -180,8 +180,8 @@ public class OverloadingConflictResolver { ValueParameterDescriptor fParam = fParams.get(i); ValueParameterDescriptor gParam = gParams.get(i); - KtType fParamType = fParam.getType(); - KtType gParamType = gParam.getType(); + KotlinType fParamType = fParam.getType(); + KotlinType gParamType = gParam.getType(); if (!typeMoreSpecific(fParamType, gParamType)) { return false; @@ -195,7 +195,7 @@ public class OverloadingConflictResolver { // here we check that typeOf(a) < elementTypeOf(vf) and elementTypeOf(vg) < elementTypeOf(vf) if (fSize < gSize) { ValueParameterDescriptor fParam = fParams.get(fSize - 1); - KtType fParamType = fParam.getVarargElementType(); + KotlinType fParamType = fParam.getVarargElementType(); assert fParamType != null : "fIsVararg guarantees this"; for (int i = fSize - 1; i < gSize; i++) { ValueParameterDescriptor gParam = gParams.get(i); @@ -206,7 +206,7 @@ public class OverloadingConflictResolver { } else { ValueParameterDescriptor gParam = gParams.get(gSize - 1); - KtType gParamType = gParam.getVarargElementType(); + KotlinType gParamType = gParam.getVarargElementType(); assert gParamType != null : "gIsVararg guarantees this"; for (int i = gSize - 1; i < fSize; i++) { ValueParameterDescriptor fParam = fParams.get(i); @@ -221,8 +221,8 @@ public class OverloadingConflictResolver { } @NotNull - private static KtType getVarargElementTypeOrType(@NotNull ValueParameterDescriptor parameterDescriptor) { - KtType varargElementType = parameterDescriptor.getVarargElementType(); + private static KotlinType getVarargElementTypeOrType(@NotNull ValueParameterDescriptor parameterDescriptor) { + KotlinType varargElementType = parameterDescriptor.getVarargElementType(); if (varargElementType != null) { return varargElementType; } @@ -238,7 +238,7 @@ public class OverloadingConflictResolver { return !f.getOriginal().getTypeParameters().isEmpty(); } - private boolean typeMoreSpecific(@NotNull KtType specific, @NotNull KtType general) { + private boolean typeMoreSpecific(@NotNull KotlinType specific, @NotNull KotlinType general) { boolean isSubtype = KotlinTypeChecker.DEFAULT.isSubtypeOf(specific, general) || numericTypeMoreSpecific(specific, general); @@ -253,13 +253,13 @@ public class OverloadingConflictResolver { return true; } - private boolean numericTypeMoreSpecific(@NotNull KtType specific, @NotNull KtType general) { - KtType _double = builtIns.getDoubleType(); - KtType _float = builtIns.getFloatType(); - KtType _long = builtIns.getLongType(); - KtType _int = builtIns.getIntType(); - KtType _byte = builtIns.getByteType(); - KtType _short = builtIns.getShortType(); + private boolean numericTypeMoreSpecific(@NotNull KotlinType specific, @NotNull KotlinType general) { + KotlinType _double = builtIns.getDoubleType(); + KotlinType _float = builtIns.getFloatType(); + KotlinType _long = builtIns.getLongType(); + KotlinType _int = builtIns.getIntType(); + KotlinType _byte = builtIns.getByteType(); + KotlinType _short = builtIns.getShortType(); if (TypeUtils.equalTypes(specific, _double) && TypeUtils.equalTypes(general, _float)) return true; if (TypeUtils.equalTypes(specific, _int)) { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/smartcasts/DataFlowInfo.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/smartcasts/DataFlowInfo.java index e01bd5aa59a..2fe2c8b4d37 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/smartcasts/DataFlowInfo.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/smartcasts/DataFlowInfo.java @@ -19,7 +19,7 @@ package org.jetbrains.kotlin.resolve.calls.smartcasts; import com.google.common.collect.ImmutableMap; import com.google.common.collect.SetMultimap; import org.jetbrains.annotations.NotNull; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import java.util.Map; import java.util.Set; @@ -35,7 +35,7 @@ public interface DataFlowInfo { Map getCompleteNullabilityInfo(); @NotNull - SetMultimap getCompleteTypeInfo(); + SetMultimap getCompleteTypeInfo(); @NotNull Nullability getNullability(@NotNull DataFlowValue key); @@ -45,7 +45,7 @@ public interface DataFlowInfo { * are NOT included. So it's quite possible to get an empty set here. */ @NotNull - Set getPossibleTypes(@NotNull DataFlowValue key); + Set getPossibleTypes(@NotNull DataFlowValue key); /** * Call this function to clear all data flow information about @@ -73,7 +73,7 @@ public interface DataFlowInfo { DataFlowInfo disequate(@NotNull DataFlowValue a, @NotNull DataFlowValue b); @NotNull - DataFlowInfo establishSubtyping(@NotNull DataFlowValue value, @NotNull KtType type); + DataFlowInfo establishSubtyping(@NotNull DataFlowValue value, @NotNull KotlinType type); /** * Call this function to add data flow information from other to this and return sum as the result diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/smartcasts/DataFlowValue.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/smartcasts/DataFlowValue.kt index c6890b53056..357f4b20a48 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/smartcasts/DataFlowValue.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/smartcasts/DataFlowValue.kt @@ -18,13 +18,13 @@ package org.jetbrains.kotlin.resolve.calls.smartcasts import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.types.ErrorUtils -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType /** * This class describes an arbitrary object which has some value in data flow analysis. * In general case it's some r-value. */ -class DataFlowValue(val id: Any?, val type: KtType, val kind: DataFlowValue.Kind, val immanentNullability: Nullability) { +class DataFlowValue(val id: Any?, val type: KotlinType, val kind: DataFlowValue.Kind, val immanentNullability: Nullability) { enum class Kind(private val str: String) { // Smart casts are completely safe diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/smartcasts/DataFlowValueFactory.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/smartcasts/DataFlowValueFactory.java index cf2c4c62c41..567b817691b 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/smartcasts/DataFlowValueFactory.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/smartcasts/DataFlowValueFactory.java @@ -36,7 +36,7 @@ import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall; import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt; import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValue.Kind; import org.jetbrains.kotlin.resolve.scopes.receivers.*; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.TypeUtils; import org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils; import org.jetbrains.kotlin.types.expressions.PreliminaryDeclarationVisitor; @@ -59,7 +59,7 @@ public class DataFlowValueFactory { @NotNull public static DataFlowValue createDataFlowValue( @NotNull KtExpression expression, - @NotNull KtType type, + @NotNull KotlinType type, @NotNull ResolutionContext resolutionContext ) { return createDataFlowValue(expression, type, resolutionContext.trace.getBindingContext(), @@ -69,7 +69,7 @@ public class DataFlowValueFactory { @NotNull public static DataFlowValue createDataFlowValue( @NotNull KtExpression expression, - @NotNull KtType type, + @NotNull KotlinType type, @NotNull BindingContext bindingContext, @NotNull DeclarationDescriptor containingDeclarationOrModule ) { @@ -105,7 +105,7 @@ public class DataFlowValueFactory { @NotNull public static DataFlowValue createDataFlowValue(@NotNull ThisReceiver receiver) { - KtType type = receiver.getType(); + KotlinType type = receiver.getType(); return new DataFlowValue(receiver, type, STABLE_VALUE, getImmanentNullability(type)); } @@ -126,7 +126,7 @@ public class DataFlowValueFactory { ) { if (receiverValue instanceof TransientReceiver || receiverValue instanceof ScriptReceiver) { // SCRIPT: smartcasts data flow - KtType type = receiverValue.getType(); + KotlinType type = receiverValue.getType(); return new DataFlowValue(receiverValue, type, STABLE_VALUE, getImmanentNullability(type)); } else if (receiverValue instanceof ClassReceiver || receiverValue instanceof ExtensionReceiver) { @@ -153,7 +153,7 @@ public class DataFlowValueFactory { @NotNull BindingContext bindingContext, @Nullable ModuleDescriptor usageContainingModule ) { - KtType type = variableDescriptor.getType(); + KotlinType type = variableDescriptor.getType(); return new DataFlowValue(variableDescriptor, type, variableKind(variableDescriptor, usageContainingModule, bindingContext, property), @@ -161,7 +161,7 @@ public class DataFlowValueFactory { } @NotNull - private static Nullability getImmanentNullability(@NotNull KtType type) { + private static Nullability getImmanentNullability(@NotNull KotlinType type) { return TypeUtils.isNullableType(type) ? Nullability.UNKNOWN : Nullability.NOT_NULL; } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/smartcasts/DelegatingDataFlowInfo.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/smartcasts/DelegatingDataFlowInfo.java index 8474870ddef..5d2cdd594db 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/smartcasts/DelegatingDataFlowInfo.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/smartcasts/DelegatingDataFlowInfo.java @@ -19,7 +19,7 @@ package org.jetbrains.kotlin.resolve.calls.smartcasts; import com.google.common.collect.*; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.TypeUtils; import java.util.HashSet; @@ -31,7 +31,7 @@ import static org.jetbrains.kotlin.resolve.calls.smartcasts.Nullability.NOT_NULL /* package */ class DelegatingDataFlowInfo implements DataFlowInfo { private static final ImmutableMap EMPTY_NULLABILITY_INFO = ImmutableMap.of(); - private static final SetMultimap EMPTY_TYPE_INFO = newTypeInfo(); + private static final SetMultimap EMPTY_TYPE_INFO = newTypeInfo(); @Nullable private final DataFlowInfo parent; @@ -41,7 +41,7 @@ import static org.jetbrains.kotlin.resolve.calls.smartcasts.Nullability.NOT_NULL // Also immutable @NotNull - private final SetMultimap typeInfo; + private final SetMultimap typeInfo; /** * Value for which type info was cleared or reassigned at this point @@ -53,7 +53,7 @@ import static org.jetbrains.kotlin.resolve.calls.smartcasts.Nullability.NOT_NULL /* package */ DelegatingDataFlowInfo( @Nullable DataFlowInfo parent, @NotNull ImmutableMap nullabilityInfo, - @NotNull SetMultimap typeInfo + @NotNull SetMultimap typeInfo ) { this(parent, nullabilityInfo, typeInfo, null); } @@ -61,7 +61,7 @@ import static org.jetbrains.kotlin.resolve.calls.smartcasts.Nullability.NOT_NULL /* package */ DelegatingDataFlowInfo( @Nullable DataFlowInfo parent, @NotNull ImmutableMap nullabilityInfo, - @NotNull SetMultimap typeInfo, + @NotNull SetMultimap typeInfo, @Nullable DataFlowValue valueWithGivenTypeInfo ) { this.parent = parent; @@ -90,8 +90,8 @@ import static org.jetbrains.kotlin.resolve.calls.smartcasts.Nullability.NOT_NULL @Override @NotNull - public SetMultimap getCompleteTypeInfo() { - SetMultimap result = newTypeInfo(); + public SetMultimap getCompleteTypeInfo() { + SetMultimap result = newTypeInfo(); Set withGivenTypeInfo = new HashSet(); DelegatingDataFlowInfo info = this; while (info != null) { @@ -130,18 +130,18 @@ import static org.jetbrains.kotlin.resolve.calls.smartcasts.Nullability.NOT_NULL @Override @NotNull - public Set getPossibleTypes(@NotNull DataFlowValue key) { - KtType originalType = key.getType(); - Set types = collectTypesFromMeAndParents(key); + public Set getPossibleTypes(@NotNull DataFlowValue key) { + KotlinType originalType = key.getType(); + Set types = collectTypesFromMeAndParents(key); if (getNullability(key).canBeNull()) { return types; } - Set enrichedTypes = Sets.newHashSetWithExpectedSize(types.size() + 1); + Set enrichedTypes = Sets.newHashSetWithExpectedSize(types.size() + 1); if (originalType.isMarkedNullable()) { enrichedTypes.add(TypeUtils.makeNotNullable(originalType)); } - for (KtType type : types) { + for (KotlinType type : types) { enrichedTypes.add(TypeUtils.makeNotNullable(type)); } @@ -174,8 +174,8 @@ import static org.jetbrains.kotlin.resolve.calls.smartcasts.Nullability.NOT_NULL Nullability nullabilityOfB = getNullability(b); putNullability(nullability, a, nullabilityOfB); - SetMultimap newTypeInfo = newTypeInfo(); - Set typesForB = collectTypesFromMeAndParents(b); + SetMultimap newTypeInfo = newTypeInfo(); + Set typesForB = collectTypesFromMeAndParents(b); // Own type of B must be recorded separately, e.g. for a constant // But if its type is the same as A or it's null, there is no reason to do it // because usually null type or own type are not saved in this set @@ -203,7 +203,7 @@ import static org.jetbrains.kotlin.resolve.calls.smartcasts.Nullability.NOT_NULL changed |= putNullability(builder, a, nullabilityOfA.refine(nullabilityOfB)); changed |= putNullability(builder, b, nullabilityOfB.refine(nullabilityOfA)); - SetMultimap newTypeInfo = newTypeInfo(); + SetMultimap newTypeInfo = newTypeInfo(); newTypeInfo.putAll(a, collectTypesFromMeAndParents(b)); newTypeInfo.putAll(b, collectTypesFromMeAndParents(a)); changed |= !newTypeInfo.isEmpty(); @@ -218,8 +218,8 @@ import static org.jetbrains.kotlin.resolve.calls.smartcasts.Nullability.NOT_NULL } @NotNull - private Set collectTypesFromMeAndParents(@NotNull DataFlowValue value) { - Set types = new LinkedHashSet(); + private Set collectTypesFromMeAndParents(@NotNull DataFlowValue value) { + Set types = new LinkedHashSet(); DataFlowInfo current = this; while (current != null) { @@ -257,12 +257,12 @@ import static org.jetbrains.kotlin.resolve.calls.smartcasts.Nullability.NOT_NULL @Override @NotNull - public DataFlowInfo establishSubtyping(@NotNull DataFlowValue value, @NotNull KtType type) { + public DataFlowInfo establishSubtyping(@NotNull DataFlowValue value, @NotNull KotlinType type) { if (value.getType().equals(type)) return this; if (getPossibleTypes(value).contains(type)) return this; ImmutableMap newNullabilityInfo = type.isMarkedNullable() ? EMPTY_NULLABILITY_INFO : ImmutableMap.of(value, NOT_NULL); - SetMultimap newTypeInfo = ImmutableSetMultimap.of(value, type); + SetMultimap newTypeInfo = ImmutableSetMultimap.of(value, type); return new DelegatingDataFlowInfo(this, newNullabilityInfo, newTypeInfo); } @@ -287,8 +287,8 @@ import static org.jetbrains.kotlin.resolve.calls.smartcasts.Nullability.NOT_NULL } } - SetMultimap myTypeInfo = getCompleteTypeInfo(); - SetMultimap otherTypeInfo = other.getCompleteTypeInfo(); + SetMultimap myTypeInfo = getCompleteTypeInfo(); + SetMultimap otherTypeInfo = other.getCompleteTypeInfo(); if (nullabilityMapBuilder.isEmpty() && containsAll(myTypeInfo, otherTypeInfo)) { return this; } @@ -296,7 +296,7 @@ import static org.jetbrains.kotlin.resolve.calls.smartcasts.Nullability.NOT_NULL return new DelegatingDataFlowInfo(this, ImmutableMap.copyOf(nullabilityMapBuilder), otherTypeInfo); } - private static boolean containsAll(SetMultimap first, SetMultimap second) { + private static boolean containsAll(SetMultimap first, SetMultimap second) { return first.entries().containsAll(second.entries()); } @@ -318,13 +318,13 @@ import static org.jetbrains.kotlin.resolve.calls.smartcasts.Nullability.NOT_NULL nullabilityMapBuilder.put(key, thisFlags.or(otherFlags)); } - SetMultimap myTypeInfo = getCompleteTypeInfo(); - SetMultimap otherTypeInfo = other.getCompleteTypeInfo(); - SetMultimap newTypeInfo = newTypeInfo(); + SetMultimap myTypeInfo = getCompleteTypeInfo(); + SetMultimap otherTypeInfo = other.getCompleteTypeInfo(); + SetMultimap newTypeInfo = newTypeInfo(); for (DataFlowValue key : Sets.intersection(myTypeInfo.keySet(), otherTypeInfo.keySet())) { - Set thisTypes = myTypeInfo.get(key); - Set otherTypes = otherTypeInfo.get(key); + Set thisTypes = myTypeInfo.get(key); + Set otherTypes = otherTypeInfo.get(key); newTypeInfo.putAll(key, Sets.intersection(thisTypes, otherTypes)); } @@ -336,7 +336,7 @@ import static org.jetbrains.kotlin.resolve.calls.smartcasts.Nullability.NOT_NULL } @NotNull - /* package */ static SetMultimap newTypeInfo() { + /* package */ static SetMultimap newTypeInfo() { return LinkedHashMultimap.create(); } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/smartcasts/SmartCastManager.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/smartcasts/SmartCastManager.java index d78f2fee9fc..4e6e7ce29c2 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/smartcasts/SmartCastManager.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/smartcasts/SmartCastManager.java @@ -29,7 +29,7 @@ import org.jetbrains.kotlin.resolve.BindingTrace; import org.jetbrains.kotlin.resolve.calls.ArgumentTypeResolver; import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext; import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.TypeIntersector; import org.jetbrains.kotlin.types.TypeUtils; import org.jetbrains.kotlin.types.checker.KotlinTypeChecker; @@ -44,7 +44,7 @@ import static org.jetbrains.kotlin.resolve.BindingContext.SMARTCAST; public class SmartCastManager { @NotNull - public List getSmartCastVariants( + public List getSmartCastVariants( @NotNull ReceiverValue receiverToCast, @NotNull ResolutionContext context ) { @@ -52,33 +52,33 @@ public class SmartCastManager { } @NotNull - public List getSmartCastVariants( + public List getSmartCastVariants( @NotNull ReceiverValue receiverToCast, @NotNull BindingContext bindingContext, @NotNull DeclarationDescriptor containingDeclarationOrModule, @NotNull DataFlowInfo dataFlowInfo ) { - List variants = Lists.newArrayList(); + List variants = Lists.newArrayList(); variants.add(receiverToCast.getType()); variants.addAll(getSmartCastVariantsExcludingReceiver(bindingContext, containingDeclarationOrModule, dataFlowInfo, receiverToCast)); return variants; } @NotNull - public List getSmartCastVariantsWithLessSpecificExcluded( + public List getSmartCastVariantsWithLessSpecificExcluded( @NotNull ReceiverValue receiverToCast, @NotNull BindingContext bindingContext, @NotNull DeclarationDescriptor containingDeclarationOrModule, @NotNull DataFlowInfo dataFlowInfo ) { - final List variants = getSmartCastVariants(receiverToCast, bindingContext, - containingDeclarationOrModule, dataFlowInfo); - return CollectionsKt.filter(variants, new Function1() { + final List variants = getSmartCastVariants(receiverToCast, bindingContext, + containingDeclarationOrModule, dataFlowInfo); + return CollectionsKt.filter(variants, new Function1() { @Override - public Boolean invoke(final KtType type) { - return !CollectionsKt.any(variants, new Function1() { + public Boolean invoke(final KotlinType type) { + return !CollectionsKt.any(variants, new Function1() { @Override - public Boolean invoke(KtType another) { + public Boolean invoke(KotlinType another) { return another != type && KotlinTypeChecker.DEFAULT.isSubtypeOf(another, type); } }); @@ -90,7 +90,7 @@ public class SmartCastManager { * @return variants @param receiverToCast may be cast to according to context dataFlowInfo, receiverToCast itself is NOT included */ @NotNull - public Collection getSmartCastVariantsExcludingReceiver( + public Collection getSmartCastVariantsExcludingReceiver( @NotNull ResolutionContext context, @NotNull ReceiverValue receiverToCast ) { @@ -104,7 +104,7 @@ public class SmartCastManager { * @return variants @param receiverToCast may be cast to according to @param dataFlowInfo, @param receiverToCast itself is NOT included */ @NotNull - public Collection getSmartCastVariantsExcludingReceiver( + public Collection getSmartCastVariantsExcludingReceiver( @NotNull BindingContext bindingContext, @NotNull DeclarationDescriptor containingDeclarationOrModule, @NotNull DataFlowInfo dataFlowInfo, @@ -119,27 +119,27 @@ public class SmartCastManager { public boolean isSubTypeBySmartCastIgnoringNullability( @NotNull ReceiverValue receiverArgument, - @NotNull KtType receiverParameterType, + @NotNull KotlinType receiverParameterType, @NotNull ResolutionContext context ) { - List smartCastTypes = getSmartCastVariants(receiverArgument, context); + List smartCastTypes = getSmartCastVariants(receiverArgument, context); return getSmartCastSubType(TypeUtils.makeNullable(receiverParameterType), smartCastTypes) != null; } @Nullable - private KtType getSmartCastSubType( - @NotNull KtType receiverParameterType, - @NotNull Collection smartCastTypes + private KotlinType getSmartCastSubType( + @NotNull KotlinType receiverParameterType, + @NotNull Collection smartCastTypes ) { - Set subTypes = Sets.newHashSet(); - for (KtType smartCastType : smartCastTypes) { + Set subTypes = Sets.newHashSet(); + for (KotlinType smartCastType : smartCastTypes) { if (ArgumentTypeResolver.isSubtypeOfForArgumentType(smartCastType, receiverParameterType)) { subTypes.add(smartCastType); } } if (subTypes.isEmpty()) return null; - KtType intersection = TypeIntersector.intersectTypes(KotlinTypeChecker.DEFAULT, subTypes); + KotlinType intersection = TypeIntersector.intersectTypes(KotlinTypeChecker.DEFAULT, subTypes); if (intersection == null || !intersection.getConstructor().isDenotable()) { return receiverParameterType; } @@ -148,7 +148,7 @@ public class SmartCastManager { private static void recordCastOrError( @NotNull KtExpression expression, - @NotNull KtType type, + @NotNull KotlinType type, @NotNull BindingTrace trace, boolean canBeCast, boolean recordExpressionType @@ -169,12 +169,12 @@ public class SmartCastManager { @Nullable public SmartCastResult checkAndRecordPossibleCast( @NotNull DataFlowValue dataFlowValue, - @NotNull KtType expectedType, + @NotNull KotlinType expectedType, @Nullable KtExpression expression, @NotNull ResolutionContext c, boolean recordExpressionType ) { - for (KtType possibleType : c.dataFlowInfo.getPossibleTypes(dataFlowValue)) { + for (KotlinType possibleType : c.dataFlowInfo.getPossibleTypes(dataFlowValue)) { if (ArgumentTypeResolver.isSubtypeOfForArgumentType(possibleType, expectedType)) { if (expression != null) { recordCastOrError(expression, possibleType, c.trace, dataFlowValue.isPredictable(), recordExpressionType); @@ -198,7 +198,7 @@ public class SmartCastManager { // E.g. in case x!! when x has type of T where T is type parameter with nullable upper bounds // x!! is immanently not null (see DataFlowValueFactory.createDataFlowValue for expression) boolean immanentlyNotNull = !dataFlowValue.getImmanentNullability().canBeNull(); - KtType nullableExpectedType = TypeUtils.makeNullable(expectedType); + KotlinType nullableExpectedType = TypeUtils.makeNullable(expectedType); if (ArgumentTypeResolver.isSubtypeOfForArgumentType(dataFlowValue.getType(), nullableExpectedType)) { if (!immanentlyNotNull) { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/smartcasts/SmartCastResult.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/smartcasts/SmartCastResult.kt index 643e31f48ed..e0856a5113d 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/smartcasts/SmartCastResult.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/smartcasts/SmartCastResult.kt @@ -16,6 +16,6 @@ package org.jetbrains.kotlin.resolve.calls.smartcasts -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType -public class SmartCastResult(public val resultType: KtType, public val isCorrect: Boolean) +public class SmartCastResult(public val resultType: KotlinType, public val isCorrect: Boolean) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/AbstractTracingStrategy.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/AbstractTracingStrategy.java index fb68ba5754f..d5bc07f1828 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/AbstractTracingStrategy.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/AbstractTracingStrategy.java @@ -37,7 +37,7 @@ import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall; import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt; import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver; import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.Variance; import org.jetbrains.kotlin.types.expressions.OperatorConventions; @@ -158,7 +158,7 @@ public abstract class AbstractTracingStrategy implements TracingStrategy { } @Override - public void unsafeCall(@NotNull BindingTrace trace, @NotNull KtType type, boolean isCallForImplicitInvoke) { + public void unsafeCall(@NotNull BindingTrace trace, @NotNull KotlinType type, boolean isCallForImplicitInvoke) { ASTNode callOperationNode = call.getCallOperationNode(); if (callOperationNode != null && !isCallForImplicitInvoke) { trace.report(UNSAFE_CALL.on(callOperationNode.getPsi(), type)); @@ -186,7 +186,7 @@ public abstract class AbstractTracingStrategy implements TracingStrategy { } @Override - public void unnecessarySafeCall(@NotNull BindingTrace trace, @NotNull KtType type) { + public void unnecessarySafeCall(@NotNull BindingTrace trace, @NotNull KotlinType type) { ASTNode callOperationNode = call.getCallOperationNode(); assert callOperationNode != null; ReceiverValue explicitReceiver = call.getExplicitReceiver(); @@ -215,12 +215,12 @@ public abstract class AbstractTracingStrategy implements TracingStrategy { return; } if (status.hasOnlyErrorsDerivedFrom(EXPECTED_TYPE_POSITION)) { - KtType declaredReturnType = data.descriptor.getReturnType(); + KotlinType declaredReturnType = data.descriptor.getReturnType(); if (declaredReturnType == null) return; ConstraintSystem systemWithoutExpectedTypeConstraint = ((ConstraintSystemImpl) constraintSystem).filterConstraintsOut(EXPECTED_TYPE_POSITION); - KtType substitutedReturnType = systemWithoutExpectedTypeConstraint.getResultingSubstitutor().substitute( + KotlinType substitutedReturnType = systemWithoutExpectedTypeConstraint.getResultingSubstitutor().substitute( declaredReturnType, Variance.OUT_VARIANCE); assert substitutedReturnType != null; //todo diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/CallableDescriptorCollectors.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/CallableDescriptorCollectors.kt index 9b37f43ce56..7a3c0ddc268 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/CallableDescriptorCollectors.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/CallableDescriptorCollectors.kt @@ -32,7 +32,7 @@ import org.jetbrains.kotlin.resolve.scopes.LexicalScope import org.jetbrains.kotlin.resolve.scopes.utils.collectAllFromMeAndParent import org.jetbrains.kotlin.resolve.scopes.utils.getLocalVariable import org.jetbrains.kotlin.types.ErrorUtils -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.util.OperatorNameConventions import org.jetbrains.kotlin.utils.singletonOrEmptyList @@ -45,11 +45,11 @@ public interface CallableDescriptorCollector { // todo this is hack for static members priority public fun getStaticInheritanceByName(lexicalScope: LexicalScope, name: Name, location: LookupLocation): Collection - public fun getMembersByName(receiver: KtType, name: Name, location: LookupLocation): Collection + public fun getMembersByName(receiver: KotlinType, name: Name, location: LookupLocation): Collection - public fun getStaticMembersByName(receiver: KtType, name: Name, location: LookupLocation): Collection + public fun getStaticMembersByName(receiver: KotlinType, name: Name, location: LookupLocation): Collection - public fun getExtensionsByName(scope: KtScope, name: Name, receiverTypes: Collection, location: LookupLocation): Collection + public fun getExtensionsByName(scope: KtScope, name: Name, receiverTypes: Collection, location: LookupLocation): Collection } private fun CallableDescriptorCollector.withDefaultFilter() = filtered { !LibrarySourceHacks.shouldSkip(it) } @@ -107,7 +107,7 @@ private object FunctionCollector : CallableDescriptorCollector { + override fun getMembersByName(receiver: KotlinType, name: Name, location: LookupLocation): Collection { val receiverScope = receiver.memberScope val members = receiverScope.getFunctions(name, location) val constructors = getConstructors(receiverScope, name, location, { !isStaticNestedClass(it) }) @@ -125,11 +125,11 @@ private object FunctionCollector : CallableDescriptorCollector { + override fun getStaticMembersByName(receiver: KotlinType, name: Name, location: LookupLocation): Collection { return getConstructors(receiver.memberScope, name, location, { isStaticNestedClass(it) }) } - override fun getExtensionsByName(scope: KtScope, name: Name, receiverTypes: Collection, location: LookupLocation): Collection { + override fun getExtensionsByName(scope: KtScope, name: Name, receiverTypes: Collection, location: LookupLocation): Collection { val functions = scope.getFunctions(name, location) val (extensions, nonExtensions) = functions.partition { it.extensionReceiverParameter != null } val syntheticExtensions = scope.getSyntheticExtensionFunctions(receiverTypes, name, location) @@ -199,18 +199,18 @@ private object VariableCollector : CallableDescriptorCollector { + override fun getMembersByName(receiver: KotlinType, name: Name, location: LookupLocation): Collection { val memberScope = receiver.memberScope val properties = memberScope.getProperties(name, location) val fakeDescriptor = getFakeDescriptorForObject(memberScope, name, location) return if (fakeDescriptor != null) properties + fakeDescriptor else properties } - override fun getStaticMembersByName(receiver: KtType, name: Name, location: LookupLocation): Collection { + override fun getStaticMembersByName(receiver: KotlinType, name: Name, location: LookupLocation): Collection { return listOf() } - override fun getExtensionsByName(scope: KtScope, name: Name, receiverTypes: Collection, location: LookupLocation): Collection { + override fun getExtensionsByName(scope: KtScope, name: Name, receiverTypes: Collection, location: LookupLocation): Collection { // property may have an extension function type, we check the applicability later to avoid an early computing of deferred types return scope.getLocalVariable(name).singletonOrEmptyList() + scope.getProperties(name, location) + @@ -236,15 +236,15 @@ private object PropertyCollector : CallableDescriptorCollector { + override fun getMembersByName(receiver: KotlinType, name: Name, location: LookupLocation): Collection { return filterProperties(VARIABLES_COLLECTOR.getMembersByName(receiver, name, location)) } - override fun getStaticMembersByName(receiver: KtType, name: Name, location: LookupLocation): Collection { + override fun getStaticMembersByName(receiver: KotlinType, name: Name, location: LookupLocation): Collection { return filterProperties(VARIABLES_COLLECTOR.getStaticMembersByName(receiver, name, location)) } - override fun getExtensionsByName(scope: KtScope, name: Name, receiverTypes: Collection, location: LookupLocation): Collection { + override fun getExtensionsByName(scope: KtScope, name: Name, receiverTypes: Collection, location: LookupLocation): Collection { return filterProperties(VARIABLES_COLLECTOR.getExtensionsByName(scope, name, receiverTypes, location)) } @@ -266,15 +266,15 @@ private fun CallableDescriptorCollector.filtered(fil return delegate.getNonExtensionsByName(scope, name, location).filter(filter) } - override fun getMembersByName(receiver: KtType, name: Name, location: LookupLocation): Collection { + override fun getMembersByName(receiver: KotlinType, name: Name, location: LookupLocation): Collection { return delegate.getMembersByName(receiver, name, location).filter(filter) } - override fun getStaticMembersByName(receiver: KtType, name: Name, location: LookupLocation): Collection { + override fun getStaticMembersByName(receiver: KotlinType, name: Name, location: LookupLocation): Collection { return delegate.getStaticMembersByName(receiver, name, location).filter(filter) } - override fun getExtensionsByName(scope: KtScope, name: Name, receiverTypes: Collection, location: LookupLocation): Collection { + override fun getExtensionsByName(scope: KtScope, name: Name, receiverTypes: Collection, location: LookupLocation): Collection { return delegate.getExtensionsByName(scope, name, receiverTypes, location).filter(filter) } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/ResolutionTask.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/ResolutionTask.java index 9ecedb0f030..3032584518d 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/ResolutionTask.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/ResolutionTask.java @@ -30,7 +30,7 @@ import org.jetbrains.kotlin.resolve.calls.model.MutableDataFlowInfoForArguments; import org.jetbrains.kotlin.resolve.calls.model.MutableResolvedCall; import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo; import org.jetbrains.kotlin.resolve.scopes.LexicalScope; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import java.util.Collection; @@ -48,7 +48,7 @@ public class ResolutionTask extends C @NotNull BindingTrace trace, @NotNull LexicalScope scope, @NotNull Call call, - @NotNull KtType expectedType, + @NotNull KotlinType expectedType, @NotNull DataFlowInfo dataFlowInfo, @NotNull ContextDependency contextDependency, @NotNull CheckArgumentTypesMode checkArguments, @@ -101,7 +101,7 @@ public class ResolutionTask extends C @NotNull BindingTrace trace, @NotNull LexicalScope scope, @NotNull DataFlowInfo dataFlowInfo, - @NotNull KtType expectedType, + @NotNull KotlinType expectedType, @NotNull ContextDependency contextDependency, @NotNull ResolutionResultsCache resolutionResultsCache, @NotNull StatementFilter statementFilter, diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/TaskPrioritizer.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/TaskPrioritizer.kt index 0c850f81430..a58a2a3d959 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/TaskPrioritizer.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/TaskPrioritizer.kt @@ -50,7 +50,7 @@ import org.jetbrains.kotlin.resolve.scopes.utils.memberScopeAsFileScope import org.jetbrains.kotlin.resolve.validation.InfixValidator import org.jetbrains.kotlin.storage.StorageManager import org.jetbrains.kotlin.types.ErrorUtils -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.checker.KotlinTypeChecker import org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils import org.jetbrains.kotlin.types.isDynamic @@ -144,7 +144,7 @@ public class TaskPrioritizer( val value: ReceiverValue, private val context: ResolutionContext<*> ) { - val types: Collection by lazy { smartCastManager.getSmartCastVariants(value, context) } + val types: Collection by lazy { smartCastManager.getSmartCastVariants(value, context) } } private fun addCandidatesForExplicitReceiver( diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/TracingStrategy.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/TracingStrategy.java index 61f5d9f1b53..26d553416db 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/TracingStrategy.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/TracingStrategy.java @@ -23,7 +23,7 @@ import org.jetbrains.kotlin.resolve.BindingTrace; import org.jetbrains.kotlin.resolve.calls.inference.InferenceErrorData; import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall; import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import java.util.Collection; @@ -89,10 +89,10 @@ public interface TracingStrategy { ) {} @Override - public void unsafeCall(@NotNull BindingTrace trace, @NotNull KtType type, boolean isCallForImplicitInvoke) {} + public void unsafeCall(@NotNull BindingTrace trace, @NotNull KotlinType type, boolean isCallForImplicitInvoke) {} @Override - public void unnecessarySafeCall(@NotNull BindingTrace trace, @NotNull KtType type) {} + public void unnecessarySafeCall(@NotNull BindingTrace trace, @NotNull KotlinType type) {} @Override public void invisibleMember(@NotNull BindingTrace trace, @NotNull DeclarationDescriptorWithVisibility descriptor) {} @@ -145,9 +145,9 @@ public interface TracingStrategy { @NotNull ExplicitReceiverKind explicitReceiverKind ); - void unsafeCall(@NotNull BindingTrace trace, @NotNull KtType type, boolean isCallForImplicitInvoke); + void unsafeCall(@NotNull BindingTrace trace, @NotNull KotlinType type, boolean isCallForImplicitInvoke); - void unnecessarySafeCall(@NotNull BindingTrace trace, @NotNull KtType type); + void unnecessarySafeCall(@NotNull BindingTrace trace, @NotNull KotlinType type); void invisibleMember(@NotNull BindingTrace trace, @NotNull DeclarationDescriptorWithVisibility descriptor); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/TracingStrategyForImplicitConstructorDelegationCall.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/TracingStrategyForImplicitConstructorDelegationCall.kt index 8dd49b1d097..c8549d44d16 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/TracingStrategyForImplicitConstructorDelegationCall.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/TracingStrategyForImplicitConstructorDelegationCall.kt @@ -32,7 +32,7 @@ import org.jetbrains.kotlin.resolve.calls.inference.InferenceErrorData import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue import org.jetbrains.kotlin.types.ErrorUtils -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType public class TracingStrategyForImplicitConstructorDelegationCall( @@ -109,11 +109,11 @@ public class TracingStrategyForImplicitConstructorDelegationCall( unexpectedError("nestedClassAccessViaInstanceReference") } - override fun unsafeCall(trace: BindingTrace, type: KtType, isCallForImplicitInvoke: Boolean) { + override fun unsafeCall(trace: BindingTrace, type: KotlinType, isCallForImplicitInvoke: Boolean) { unexpectedError("unsafeCall") } - override fun unnecessarySafeCall(trace: BindingTrace, type: KtType) { + override fun unnecessarySafeCall(trace: BindingTrace, type: KotlinType) { unexpectedError("unnecessarySafeCall") } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/TracingStrategyForInvoke.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/TracingStrategyForInvoke.java index a4f551c5572..9892821f1b7 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/TracingStrategyForInvoke.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/TracingStrategyForInvoke.java @@ -27,7 +27,7 @@ import org.jetbrains.kotlin.psi.KtSimpleNameExpression; import org.jetbrains.kotlin.resolve.BindingContext; import org.jetbrains.kotlin.resolve.BindingTrace; import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import java.util.Collection; @@ -37,12 +37,12 @@ import static org.jetbrains.kotlin.resolve.BindingContext.CALL; import static org.jetbrains.kotlin.resolve.BindingContext.RESOLVED_CALL; public class TracingStrategyForInvoke extends AbstractTracingStrategy { - private final KtType calleeType; + private final KotlinType calleeType; public TracingStrategyForInvoke( @NotNull KtExpression reference, @NotNull Call call, - @NotNull KtType calleeType + @NotNull KotlinType calleeType ) { super(reference, call); this.calleeType = calleeType; diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/dynamicCalls.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/dynamicCalls.kt index 89896e0b331..182af07daa7 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/dynamicCalls.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/dynamicCalls.kt @@ -31,7 +31,7 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns import org.jetbrains.kotlin.resolve.scopes.KtScope import org.jetbrains.kotlin.resolve.scopes.KtScopeImpl import org.jetbrains.kotlin.resolve.scopes.receivers.TransientReceiver -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.Variance import org.jetbrains.kotlin.types.createDynamicType import org.jetbrains.kotlin.types.expressions.OperatorConventions @@ -103,7 +103,7 @@ class DynamicCallableDescriptors(private val builtIns: KotlinBuiltIns) { dynamicType, createTypeParameters(propertyDescriptor, call), createDynamicDispatchReceiverParameter(propertyDescriptor), - null as KtType? + null as KotlinType? ) val getter = DescriptorFactory.createDefaultGetter(propertyDescriptor, Annotations.EMPTY) @@ -155,7 +155,7 @@ class DynamicCallableDescriptors(private val builtIns: KotlinBuiltIns) { private fun createValueParameters(owner: FunctionDescriptor, call: Call): List { val parameters = ArrayList() - fun addParameter(arg : ValueArgument, outType: KtType, varargElementType: KtType?) { + fun addParameter(arg : ValueArgument, outType: KotlinType, varargElementType: KotlinType?) { val index = parameters.size() parameters.add(ValueParameterDescriptorImpl( @@ -173,7 +173,7 @@ class DynamicCallableDescriptors(private val builtIns: KotlinBuiltIns) { )) } - fun getFunctionType(funLiteralExpr: KtFunctionLiteralExpression): KtType { + fun getFunctionType(funLiteralExpr: KtFunctionLiteralExpression): KotlinType { val funLiteral = funLiteralExpr.getFunctionLiteral() val receiverType = funLiteral.getReceiverTypeReference()?.let { dynamicType } @@ -183,8 +183,8 @@ class DynamicCallableDescriptors(private val builtIns: KotlinBuiltIns) { } for (arg in call.getValueArguments()) { - val outType: KtType - val varargElementType: KtType? + val outType: KotlinType + val varargElementType: KotlinType? var hasSpreadOperator = false val argExpression = KtPsiUtil.deparenthesize(arg.getArgumentExpression()) @@ -229,7 +229,7 @@ public fun DeclarationDescriptor.isDynamic(): Boolean { } class CollectorForDynamicReceivers(val delegate: CallableDescriptorCollector) : CallableDescriptorCollector by delegate { - override fun getExtensionsByName(scope: KtScope, name: Name, receiverTypes: Collection, location: LookupLocation): Collection { + override fun getExtensionsByName(scope: KtScope, name: Name, receiverTypes: Collection, location: LookupLocation): Collection { return delegate.getExtensionsByName(scope, name, receiverTypes, location).filter { it.getExtensionReceiverParameter()?.getType()?.isDynamic() ?: false } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/util/FakeCallableDescriptorForObject.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/util/FakeCallableDescriptorForObject.kt index ed9e65aff88..12bfa9be8ba 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/util/FakeCallableDescriptorForObject.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/util/FakeCallableDescriptorForObject.kt @@ -20,7 +20,7 @@ import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.resolve.descriptorUtil.classObjectType import org.jetbrains.kotlin.resolve.descriptorUtil.getClassObjectReferenceTarget import org.jetbrains.kotlin.resolve.descriptorUtil.hasClassObjectType -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import java.util.Collections public class FakeCallableDescriptorForObject( @@ -44,7 +44,7 @@ public class FakeCallableDescriptorForObject( override fun getValueParameters(): List = Collections.emptyList() - override fun getReturnType(): KtType? = getType() + override fun getReturnType(): KotlinType? = getType() override fun hasSynthesizedParameterNames() = false @@ -52,7 +52,7 @@ public class FakeCallableDescriptorForObject( override fun getOverriddenDescriptors(): Set = Collections.emptySet() - override fun getType(): KtType = classDescriptor.classObjectType!! + override fun getType(): KotlinType = classDescriptor.classObjectType!! override fun isVar() = false diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstantChecker.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstantChecker.java index 28bad745d90..d242d3a30b0 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstantChecker.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstantChecker.java @@ -27,7 +27,7 @@ import org.jetbrains.kotlin.diagnostics.DiagnosticFactory; import org.jetbrains.kotlin.psi.KtConstantExpression; import org.jetbrains.kotlin.psi.KtElement; import org.jetbrains.kotlin.resolve.BindingTrace; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.TypeUtils; import org.jetbrains.kotlin.types.checker.KotlinTypeChecker; @@ -57,7 +57,7 @@ public class CompileTimeConstantChecker { public boolean checkConstantExpressionType( @Nullable ConstantValue compileTimeConstant, @NotNull KtConstantExpression expression, - @NotNull KtType expectedType + @NotNull KotlinType expectedType ) { IElementType elementType = expression.getNode().getElementType(); @@ -81,7 +81,7 @@ public class CompileTimeConstantChecker { private boolean checkIntegerValue( @Nullable ConstantValue value, - @NotNull KtType expectedType, + @NotNull KotlinType expectedType, @NotNull KtConstantExpression expression ) { if (value == null) { @@ -93,7 +93,7 @@ public class CompileTimeConstantChecker { } if (!noExpectedTypeOrError(expectedType)) { - KtType valueType = value.getType(); + KotlinType valueType = value.getType(); if (!KotlinTypeChecker.DEFAULT.isSubtypeOf(valueType, expectedType)) { return reportError(CONSTANT_EXPECTED_TYPE_MISMATCH.on(expression, "integer", expectedType)); } @@ -103,14 +103,14 @@ public class CompileTimeConstantChecker { private boolean checkFloatValue( @Nullable ConstantValue value, - @NotNull KtType expectedType, + @NotNull KotlinType expectedType, @NotNull KtConstantExpression expression ) { if (value == null) { return reportError(FLOAT_LITERAL_OUT_OF_RANGE.on(expression)); } if (!noExpectedTypeOrError(expectedType)) { - KtType valueType = value.getType(); + KotlinType valueType = value.getType(); if (!KotlinTypeChecker.DEFAULT.isSubtypeOf(valueType, expectedType)) { return reportError(CONSTANT_EXPECTED_TYPE_MISMATCH.on(expression, "floating-point", expectedType)); } @@ -119,7 +119,7 @@ public class CompileTimeConstantChecker { } private boolean checkBooleanValue( - @NotNull KtType expectedType, + @NotNull KotlinType expectedType, @NotNull KtConstantExpression expression ) { if (!noExpectedTypeOrError(expectedType) @@ -129,7 +129,7 @@ public class CompileTimeConstantChecker { return false; } - private boolean checkCharValue(ConstantValue constant, KtType expectedType, KtConstantExpression expression) { + private boolean checkCharValue(ConstantValue constant, KotlinType expectedType, KtConstantExpression expression) { if (!noExpectedTypeOrError(expectedType) && !KotlinTypeChecker.DEFAULT.isSubtypeOf(builtIns.getCharType(), expectedType)) { return reportError(CONSTANT_EXPECTED_TYPE_MISMATCH.on(expression, "character", expectedType)); @@ -146,7 +146,7 @@ public class CompileTimeConstantChecker { return false; } - private boolean checkNullValue(@NotNull KtType expectedType, @NotNull KtConstantExpression expression) { + private boolean checkNullValue(@NotNull KotlinType expectedType, @NotNull KtConstantExpression expression) { if (!noExpectedTypeOrError(expectedType) && !TypeUtils.acceptsNullable(expectedType)) { return reportError(NULL_FOR_NONNULL_TYPE.on(expression, expectedType)); } @@ -269,7 +269,7 @@ public class CompileTimeConstantChecker { return null; } - public static boolean noExpectedTypeOrError(KtType expectedType) { + public static boolean noExpectedTypeOrError(KotlinType expectedType) { return TypeUtils.noExpectedType(expectedType) || expectedType.isError(); } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt index 0f4bd35306b..3e9366c17ef 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt @@ -31,7 +31,7 @@ import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall import org.jetbrains.kotlin.resolve.calls.model.ResolvedValueArgument import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind import org.jetbrains.kotlin.resolve.constants.* -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeUtils import org.jetbrains.kotlin.types.checker.KotlinTypeChecker import org.jetbrains.kotlin.types.expressions.OperatorConventions @@ -45,7 +45,7 @@ public class ConstantExpressionEvaluator( internal val constantValueFactory = ConstantValueFactory(builtIns) public fun updateNumberType( - numberType: KtType, + numberType: KotlinType, expression: KtExpression?, statementFilter: StatementFilter, trace: BindingTrace @@ -102,7 +102,7 @@ public class ConstantExpressionEvaluator( private fun checkCompileTimeConstant( argumentExpression: KtExpression, - expectedType: KtType, + expectedType: KotlinType, trace: BindingTrace ) { val expressionType = trace.getType(argumentExpression) @@ -145,7 +145,7 @@ public class ConstantExpressionEvaluator( private fun getArgumentExpressionsForArrayCall( expression: KtCallExpression, trace: BindingTrace - ): Pair, KtType?>? { + ): Pair, KotlinType?>? { val resolvedCall = expression.getResolvedCall(trace.getBindingContext()) if (resolvedCall == null || !CompileTimeConstantUtils.isArrayMethodCall(resolvedCall)) { return null @@ -163,7 +163,7 @@ public class ConstantExpressionEvaluator( } } - return Pair, KtType>(result, elementType) + return Pair, KotlinType>(result, elementType) } private fun hasSpread(argument: ResolvedValueArgument): Boolean { @@ -173,7 +173,7 @@ public class ConstantExpressionEvaluator( private fun resolveAnnotationValueArguments( resolvedValueArgument: ResolvedValueArgument, - expectedType: KtType, + expectedType: KotlinType, trace: BindingTrace): List> { val constants = ArrayList>() for (argument in resolvedValueArgument.getArguments()) { @@ -194,7 +194,7 @@ public class ConstantExpressionEvaluator( public fun evaluateExpression( expression: KtExpression, trace: BindingTrace, - expectedType: KtType? = TypeUtils.NO_EXPECTED_TYPE + expectedType: KotlinType? = TypeUtils.NO_EXPECTED_TYPE ): CompileTimeConstant<*>? { val visitor = ConstantExpressionEvaluatorVisitor(this, trace) val constant = visitor.evaluate(expression, expectedType) ?: return null @@ -204,7 +204,7 @@ public class ConstantExpressionEvaluator( public fun evaluateToConstantValue( expression: KtExpression, trace: BindingTrace, - expectedType: KtType + expectedType: KotlinType ): ConstantValue<*>? { return evaluateExpression(expression, trace, expectedType)?.toConstantValue(expectedType) } @@ -227,11 +227,11 @@ public class ConstantExpressionEvaluator( private class ConstantExpressionEvaluatorVisitor( private val constantExpressionEvaluator: ConstantExpressionEvaluator, private val trace: BindingTrace -) : KtVisitor?, KtType>() { +) : KtVisitor?, KotlinType>() { private val factory = constantExpressionEvaluator.constantValueFactory - fun evaluate(expression: KtExpression, expectedType: KtType?): CompileTimeConstant<*>? { + fun evaluate(expression: KtExpression, expectedType: KotlinType?): CompileTimeConstant<*>? { val recordedCompileTimeConstant = ConstantExpressionEvaluator.getPossiblyErrorConstant(expression, trace.getBindingContext()) if (recordedCompileTimeConstant != null) { return recordedCompileTimeConstant @@ -272,7 +272,7 @@ private class ConstantExpressionEvaluatorVisitor( override fun visitEscapeStringTemplateEntry(entry: KtEscapeStringTemplateEntry, data: Nothing?) = factory.createStringValue(entry.getUnescapedValue()).wrap() } - override fun visitConstantExpression(expression: KtConstantExpression, expectedType: KtType?): CompileTimeConstant<*>? { + override fun visitConstantExpression(expression: KtConstantExpression, expectedType: KotlinType?): CompileTimeConstant<*>? { val text = expression.getText() ?: return null val nodeElementType = expression.getNode().getElementType() @@ -290,7 +290,7 @@ private class ConstantExpressionEvaluatorVisitor( return createConstant(result, expectedType, CompileTimeConstant.Parameters(true, !isLongWithSuffix(), false, usesNonConstValAsConstant = false)) } - override fun visitParenthesizedExpression(expression: KtParenthesizedExpression, expectedType: KtType?): CompileTimeConstant<*>? { + override fun visitParenthesizedExpression(expression: KtParenthesizedExpression, expectedType: KotlinType?): CompileTimeConstant<*>? { val deparenthesizedExpression = KtPsiUtil.deparenthesize(expression) if (deparenthesizedExpression != null && deparenthesizedExpression != expression) { return evaluate(deparenthesizedExpression, expectedType) @@ -298,7 +298,7 @@ private class ConstantExpressionEvaluatorVisitor( return null } - override fun visitLabeledExpression(expression: KtLabeledExpression, expectedType: KtType?): CompileTimeConstant<*>? { + override fun visitLabeledExpression(expression: KtLabeledExpression, expectedType: KotlinType?): CompileTimeConstant<*>? { val baseExpression = expression.getBaseExpression() if (baseExpression != null) { return evaluate(baseExpression, expectedType) @@ -306,7 +306,7 @@ private class ConstantExpressionEvaluatorVisitor( return null } - override fun visitStringTemplateExpression(expression: KtStringTemplateExpression, expectedType: KtType?): CompileTimeConstant<*>? { + override fun visitStringTemplateExpression(expression: KtStringTemplateExpression, expectedType: KotlinType?): CompileTimeConstant<*>? { val sb = StringBuilder() var interupted = false var canBeUsedInAnnotation = true @@ -339,10 +339,10 @@ private class ConstantExpressionEvaluatorVisitor( else null } - override fun visitBinaryWithTypeRHSExpression(expression: KtBinaryExpressionWithTypeRHS, expectedType: KtType?): CompileTimeConstant<*>? = + override fun visitBinaryWithTypeRHSExpression(expression: KtBinaryExpressionWithTypeRHS, expectedType: KotlinType?): CompileTimeConstant<*>? = evaluate(expression.getLeft(), expectedType) - override fun visitBinaryExpression(expression: KtBinaryExpression, expectedType: KtType?): CompileTimeConstant<*>? { + override fun visitBinaryExpression(expression: KtBinaryExpression, expectedType: KotlinType?): CompileTimeConstant<*>? { val leftExpression = expression.getLeft() ?: return null val operationToken = expression.getOperationToken() @@ -379,7 +379,7 @@ private class ConstantExpressionEvaluatorVisitor( } } - private fun evaluateCall(callExpression: KtExpression, receiverExpression: KtExpression, expectedType: KtType?): CompileTimeConstant<*>? { + private fun evaluateCall(callExpression: KtExpression, receiverExpression: KtExpression, expectedType: KotlinType?): CompileTimeConstant<*>? { val resolvedCall = callExpression.getResolvedCall(trace.getBindingContext()) if (resolvedCall == null) return null @@ -501,14 +501,14 @@ private class ConstantExpressionEvaluatorVisitor( return false } - override fun visitUnaryExpression(expression: KtUnaryExpression, expectedType: KtType?): CompileTimeConstant<*>? { + override fun visitUnaryExpression(expression: KtUnaryExpression, expectedType: KotlinType?): CompileTimeConstant<*>? { val leftExpression = expression.getBaseExpression() if (leftExpression == null) return null return evaluateCall(expression.getOperationReference(), leftExpression, expectedType) } - override fun visitSimpleNameExpression(expression: KtSimpleNameExpression, expectedType: KtType?): CompileTimeConstant<*>? { + override fun visitSimpleNameExpression(expression: KtSimpleNameExpression, expectedType: KotlinType?): CompileTimeConstant<*>? { val enumDescriptor = trace.getBindingContext().get(BindingContext.REFERENCE_TARGET, expression); if (enumDescriptor != null && DescriptorUtils.isEnumEntry(enumDescriptor)) { return factory.createEnumValue(enumDescriptor as ClassDescriptor).wrap() @@ -547,7 +547,7 @@ private class ConstantExpressionEvaluatorVisitor( return false } - override fun visitQualifiedExpression(expression: KtQualifiedExpression, expectedType: KtType?): CompileTimeConstant<*>? { + override fun visitQualifiedExpression(expression: KtQualifiedExpression, expectedType: KotlinType?): CompileTimeConstant<*>? { val selectorExpression = expression.getSelectorExpression() // 1.toInt(); 1.plus(1); if (selectorExpression is KtCallExpression) { @@ -578,7 +578,7 @@ private class ConstantExpressionEvaluatorVisitor( return null } - override fun visitCallExpression(expression: KtCallExpression, expectedType: KtType?): CompileTimeConstant<*>? { + override fun visitCallExpression(expression: KtCallExpression, expectedType: KotlinType?): CompileTimeConstant<*>? { val call = expression.getResolvedCall(trace.getBindingContext()) if (call == null) return null @@ -613,13 +613,13 @@ private class ConstantExpressionEvaluatorVisitor( return null } - override fun visitClassLiteralExpression(expression: KtClassLiteralExpression, expectedType: KtType?): CompileTimeConstant<*>? { + override fun visitClassLiteralExpression(expression: KtClassLiteralExpression, expectedType: KotlinType?): CompileTimeConstant<*>? { val jetType = trace.getType(expression)!! if (jetType.isError()) return null return KClassValue(jetType).wrap() } - private fun resolveArguments(valueArguments: List, expectedType: KtType): List> { + private fun resolveArguments(valueArguments: List, expectedType: KotlinType): List> { val constants = arrayListOf>() for (argument in valueArguments) { val argumentExpression = argument.getArgumentExpression() @@ -633,7 +633,7 @@ private class ConstantExpressionEvaluatorVisitor( return constants } - override fun visitJetElement(element: KtElement, expectedType: KtType?): CompileTimeConstant<*>? { + override fun visitJetElement(element: KtElement, expectedType: KotlinType?): CompileTimeConstant<*>? { return null } @@ -662,7 +662,7 @@ private class ConstantExpressionEvaluatorVisitor( } - private fun getCompileTimeType(c: KtType): CompileTimeType? { + private fun getCompileTimeType(c: KotlinType): CompileTimeType? { val builtIns = constantExpressionEvaluator.builtIns return when (TypeUtils.makeNotNullable(c)) { builtIns.intType -> INT @@ -679,7 +679,7 @@ private class ConstantExpressionEvaluatorVisitor( } } - private fun createOperationArgument(expression: KtExpression, expressionType: KtType, compileTimeType: CompileTimeType<*>): OperationArgument? { + private fun createOperationArgument(expression: KtExpression, expressionType: KotlinType, compileTimeType: CompileTimeType<*>): OperationArgument? { val compileTimeConstant = constantExpressionEvaluator.evaluateExpression(expression, trace, expressionType) ?: return null val evaluationResult = compileTimeConstant.getValue(expressionType) ?: return null return OperationArgument(evaluationResult, compileTimeType, expression) @@ -687,7 +687,7 @@ private class ConstantExpressionEvaluatorVisitor( private fun createConstant( value: Any?, - expectedType: KtType?, + expectedType: KotlinType?, parameters: CompileTimeConstant.Parameters ): CompileTimeConstant<*>? { return if (parameters.isPure) { @@ -701,7 +701,7 @@ private class ConstantExpressionEvaluatorVisitor( private fun createCompileTimeConstant( value: Any?, parameters: CompileTimeConstant.Parameters, - expectedType: KtType + expectedType: KotlinType ): CompileTimeConstant<*>? { return when (value) { is Byte, is Short, is Int, is Long -> createIntegerCompileTimeConstant((value as Number).toLong(), parameters, expectedType) @@ -712,7 +712,7 @@ private class ConstantExpressionEvaluatorVisitor( private fun createIntegerCompileTimeConstant( value: Long, parameters: CompileTimeConstant.Parameters, - expectedType: KtType + expectedType: KotlinType ): CompileTimeConstant<*>? { if (TypeUtils.noExpectedType(expectedType) || expectedType.isError()) { return IntegerValueTypeConstant(value, constantExpressionEvaluator.builtIns, parameters) @@ -833,7 +833,7 @@ private fun createCompileTimeConstantForCompareTo(result: Any?, operationReferen fun isIntegerType(value: Any?) = value is Byte || value is Short || value is Int || value is Long -private fun getReceiverExpressionType(resolvedCall: ResolvedCall<*>): KtType? { +private fun getReceiverExpressionType(resolvedCall: ResolvedCall<*>): KotlinType? { return when (resolvedCall.getExplicitReceiverKind()) { ExplicitReceiverKind.DISPATCH_RECEIVER -> resolvedCall.getDispatchReceiver().getType() ExplicitReceiverKind.EXTENSION_RECEIVER -> resolvedCall.getExtensionReceiver().getType() diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/ForceResolveUtil.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/ForceResolveUtil.java index 7fba79bc9e5..554e2fa271e 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/ForceResolveUtil.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/ForceResolveUtil.java @@ -47,8 +47,8 @@ public class ForceResolveUtil { } } - public static void forceResolveAllContents(@NotNull Collection types) { - for (KtType type : types) { + public static void forceResolveAllContents(@NotNull Collection types) { + for (KotlinType type : types) { forceResolveAllContents(type); } } @@ -87,7 +87,7 @@ public class ForceResolveUtil { } @Nullable - public static KtType forceResolveAllContents(@Nullable KtType type) { + public static KotlinType forceResolveAllContents(@Nullable KotlinType type) { if (type == null) return null; forceResolveAllContents(type.getAnnotations()); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/LazyImportScope.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/LazyImportScope.kt index 19fa8a42c46..8aa3d5670bd 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/LazyImportScope.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/LazyImportScope.kt @@ -33,7 +33,7 @@ import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter import org.jetbrains.kotlin.resolve.scopes.KtScope import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue import org.jetbrains.kotlin.storage.StorageManager -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.util.collectionUtils.concat import org.jetbrains.kotlin.utils.Printer import java.util.* @@ -202,17 +202,17 @@ class LazyImportScope( return importResolver.collectFromImports(name) { scope, name -> scope.getFunctions(name, location) } } - override fun getSyntheticExtensionProperties(receiverTypes: Collection, name: Name, location: LookupLocation): Collection { + override fun getSyntheticExtensionProperties(receiverTypes: Collection, name: Name, location: LookupLocation): Collection { if (filteringKind == FilteringKind.INVISIBLE_CLASSES) return listOf() return importResolver.collectFromImports(name) { scope, name -> scope.getSyntheticExtensionProperties(receiverTypes, name, location) } } - override fun getSyntheticExtensionFunctions(receiverTypes: Collection, name: Name, location: LookupLocation): Collection { + override fun getSyntheticExtensionFunctions(receiverTypes: Collection, name: Name, location: LookupLocation): Collection { if (filteringKind == FilteringKind.INVISIBLE_CLASSES) return listOf() return importResolver.collectFromImports(name) { scope, name -> scope.getSyntheticExtensionFunctions(receiverTypes, name, location) } } - override fun getSyntheticExtensionProperties(receiverTypes: Collection): Collection { + override fun getSyntheticExtensionProperties(receiverTypes: Collection): Collection { // we do not perform any filtering by visibility here because all descriptors from both visible/invisible filter scopes are to be added anyway if (filteringKind == FilteringKind.INVISIBLE_CLASSES) return listOf() @@ -223,7 +223,7 @@ class LazyImportScope( } } - override fun getSyntheticExtensionFunctions(receiverTypes: Collection): Collection { + override fun getSyntheticExtensionFunctions(receiverTypes: Collection): Collection { // we do not perform any filtering by visibility here because all descriptors from both visible/invisible filter scopes are to be added anyway if (filteringKind == FilteringKind.INVISIBLE_CLASSES) return listOf() diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassDescriptor.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassDescriptor.java index cda0ff41515..d8a930e6bcc 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassDescriptor.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassDescriptor.java @@ -55,7 +55,7 @@ import org.jetbrains.kotlin.storage.NotNullLazyValue; import org.jetbrains.kotlin.storage.NullableLazyValue; import org.jetbrains.kotlin.storage.StorageManager; import org.jetbrains.kotlin.types.AbstractClassTypeConstructor; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.TypeConstructor; import org.jetbrains.kotlin.types.TypeUtils; @@ -68,9 +68,9 @@ import static org.jetbrains.kotlin.resolve.BindingContext.TYPE; import static org.jetbrains.kotlin.resolve.ModifiersChecker.*; public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDescriptorWithResolutionScopes, LazyEntity { - private static final Predicate VALID_SUPERTYPE = new Predicate() { + private static final Predicate VALID_SUPERTYPE = new Predicate() { @Override - public boolean apply(KtType type) { + public boolean apply(KotlinType type) { assert !type.isError() : "Error types must be filtered out in DescriptorResolver"; return TypeUtils.getClassDescriptor(type) != null; } @@ -488,21 +488,21 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes private static class Supertypes { @Mutable - public final Collection trueSupertypes; + public final Collection trueSupertypes; @Mutable - public final Collection cyclicSupertypes; + public final Collection cyclicSupertypes; - private Supertypes(@Mutable @NotNull Collection trueSupertypes) { - this(trueSupertypes, new ArrayList(0)); + private Supertypes(@Mutable @NotNull Collection trueSupertypes) { + this(trueSupertypes, new ArrayList(0)); } - private Supertypes(@Mutable @NotNull Collection trueSupertypes, @Mutable @NotNull Collection cyclicSupertypes) { + private Supertypes(@Mutable @NotNull Collection trueSupertypes, @Mutable @NotNull Collection cyclicSupertypes) { this.trueSupertypes = trueSupertypes; this.cyclicSupertypes = cyclicSupertypes; } @NotNull - public Collection getAllSupertypes() { + public Collection getAllSupertypes() { return CollectionsKt.plus(trueSupertypes, cyclicSupertypes); } } @@ -513,7 +513,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes @Override public Supertypes invoke() { if (KotlinBuiltIns.isSpecialClassWithNoSupertypes(LazyClassDescriptor.this)) { - return new Supertypes(Collections.emptyList()); + return new Supertypes(Collections.emptyList()); } KtClassOrObject classOrObject = declarationProvider.getOwnerInfo().getCorrespondingClassOrObject(); @@ -521,7 +521,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes return new Supertypes(Collections.singleton(c.getModuleDescriptor().getBuiltIns().getAnyType())); } - List allSupertypes = c.getDescriptorResolver() + List allSupertypes = c.getDescriptorResolver() .resolveSupertypes(getScopeForClassHeaderResolution(), LazyClassDescriptor.this, classOrObject, c.getTrace()); @@ -531,7 +531,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes new Function1() { @Override public Supertypes invoke(Boolean firstTime) { - return new Supertypes(Collections.emptyList()); + return new Supertypes(Collections.emptyList()); } }, new Function1() { @@ -581,13 +581,13 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes @NotNull @Override - public Collection getSupertypes() { + public Collection getSupertypes() { return supertypes.invoke().trueSupertypes; } private void findAndDisconnectLoopsInTypeHierarchy(Supertypes supertypes) { - for (Iterator iterator = supertypes.trueSupertypes.iterator(); iterator.hasNext(); ) { - KtType supertype = iterator.next(); + for (Iterator iterator = supertypes.trueSupertypes.iterator(); iterator.hasNext(); ) { + KotlinType supertype = iterator.next(); if (isReachable(supertype.getConstructor(), this, new HashSet())) { iterator.remove(); supertypes.cyclicSupertypes.add(supertype); @@ -614,7 +614,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes for (KtDelegationSpecifier delegationSpecifier : classOrObject.getDelegationSpecifiers()) { KtTypeReference typeReference = delegationSpecifier.getTypeReference(); if (typeReference == null) continue; - KtType supertype = trace.get(TYPE, typeReference); + KotlinType supertype = trace.get(TYPE, typeReference); if (supertype != null && supertype.getConstructor() == superclass.getTypeConstructor()) { elementToMark = typeReference; } @@ -634,7 +634,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes private boolean isReachable(TypeConstructor from, TypeConstructor to, Set visited) { if (!visited.add(from)) return false; - for (KtType supertype : getNeighbors(from)) { + for (KotlinType supertype : getNeighbors(from)) { TypeConstructor supertypeConstructor = supertype.getConstructor(); if (supertypeConstructor == to) { return true; @@ -646,9 +646,9 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes return false; } - private Collection getNeighbors(TypeConstructor from) { + private Collection getNeighbors(TypeConstructor from) { // Supertypes + type for container - Collection neighbours = new ArrayList( + Collection neighbours = new ArrayList( from instanceof LazyClassTypeConstructor ? ((LazyClassTypeConstructor) from).supertypes.invoke().getAllSupertypes() : from.getSupertypes() diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassMemberScope.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassMemberScope.kt index 61d8a5140da..a104e41242e 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassMemberScope.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassMemberScope.kt @@ -40,7 +40,7 @@ import org.jetbrains.kotlin.resolve.varianceChecker.VarianceChecker import org.jetbrains.kotlin.storage.NotNullLazyValue import org.jetbrains.kotlin.storage.NullableLazyValue import org.jetbrains.kotlin.types.DeferredType -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import java.util.* public open class LazyClassMemberScope( @@ -85,7 +85,7 @@ public open class LazyClassMemberScope( } private interface MemberExtractor { - public fun extract(extractFrom: KtType, name: Name): Collection + public fun extract(extractFrom: KotlinType, name: Name): Collection } private val primaryConstructor: NullableLazyValue @@ -315,13 +315,13 @@ public open class LazyClassMemberScope( companion object { private val EXTRACT_FUNCTIONS: MemberExtractor = object : MemberExtractor { - override fun extract(extractFrom: KtType, name: Name): Collection { + override fun extract(extractFrom: KotlinType, name: Name): Collection { return extractFrom.memberScope.getFunctions(name, NoLookupLocation.FOR_ALREADY_TRACKED) } } private val EXTRACT_PROPERTIES: MemberExtractor = object : MemberExtractor { - override fun extract(extractFrom: KtType, name: Name): Collection { + override fun extract(extractFrom: KotlinType, name: Name): Collection { @Suppress("UNCHECKED_CAST") return extractFrom.memberScope.getProperties(name, NoLookupLocation.FOR_ALREADY_TRACKED) as Collection } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyTypeParameterDescriptor.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyTypeParameterDescriptor.java index 460cc6bf0b1..2100dca52a2 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyTypeParameterDescriptor.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyTypeParameterDescriptor.java @@ -26,7 +26,7 @@ import org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil; import org.jetbrains.kotlin.resolve.lazy.LazyClassContext; import org.jetbrains.kotlin.resolve.lazy.LazyEntity; import org.jetbrains.kotlin.resolve.source.KotlinSourceElementKt; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import java.util.Set; @@ -57,14 +57,14 @@ public class LazyTypeParameterDescriptor extends AbstractLazyTypeParameterDescri @NotNull @Override - protected Set resolveUpperBounds() { - Set upperBounds = Sets.newLinkedHashSet(); + protected Set resolveUpperBounds() { + Set upperBounds = Sets.newLinkedHashSet(); KtTypeParameter jetTypeParameter = this.jetTypeParameter; KtTypeReference extendsBound = jetTypeParameter.getExtendsBound(); if (extendsBound != null) { - KtType boundType = c.getDescriptorResolver().resolveTypeParameterExtendsBound( + KotlinType boundType = c.getDescriptorResolver().resolveTypeParameterExtendsBound( this, extendsBound, getContainingDeclaration().getScopeForClassHeaderResolution(), c.getTrace()); upperBounds.add(boundType); } @@ -78,7 +78,7 @@ public class LazyTypeParameterDescriptor extends AbstractLazyTypeParameterDescri return upperBounds; } - private void resolveUpperBoundsFromWhereClause(Set upperBounds) { + private void resolveUpperBoundsFromWhereClause(Set upperBounds) { KtClassOrObject classOrObject = KtStubbedPsiUtil.getPsiOrStubParent(jetTypeParameter, KtClassOrObject.class, true); if (classOrObject instanceof KtClass) { KtClass ktClass = (KtClass) classOrObject; @@ -90,7 +90,7 @@ public class LazyTypeParameterDescriptor extends AbstractLazyTypeParameterDescri KtTypeReference boundTypeReference = jetTypeConstraint.getBoundTypeReference(); if (boundTypeReference != null) { - KtType boundType = resolveBoundType(boundTypeReference); + KotlinType boundType = resolveBoundType(boundTypeReference); upperBounds.add(boundType); } } @@ -100,7 +100,7 @@ public class LazyTypeParameterDescriptor extends AbstractLazyTypeParameterDescri } - private KtType resolveBoundType(@NotNull KtTypeReference boundTypeReference) { + private KotlinType resolveBoundType(@NotNull KtTypeReference boundTypeReference) { return c.getTypeResolver() .resolveType(getContainingDeclaration().getScopeForClassHeaderResolution(), boundTypeReference, c.getTrace(), false); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/receivers/ExpressionReceiver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/receivers/ExpressionReceiver.java index dd2e04c5c1f..f618556ceaa 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/receivers/ExpressionReceiver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/receivers/ExpressionReceiver.java @@ -18,13 +18,13 @@ package org.jetbrains.kotlin.resolve.scopes.receivers; import org.jetbrains.annotations.NotNull; import org.jetbrains.kotlin.psi.KtExpression; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; public class ExpressionReceiver extends AbstractReceiverValue implements ReceiverValue { private final KtExpression expression; - public ExpressionReceiver(@NotNull KtExpression expression, @NotNull KtType type) { + public ExpressionReceiver(@NotNull KtExpression expression, @NotNull KotlinType type) { super(type); this.expression = expression; } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/receivers/Qualifier.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/receivers/Qualifier.kt index ec7dac60d45..d7fbc15dedf 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/receivers/Qualifier.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/receivers/Qualifier.kt @@ -38,7 +38,7 @@ import org.jetbrains.kotlin.resolve.scopes.FilteringScope import org.jetbrains.kotlin.resolve.scopes.KtScope import org.jetbrains.kotlin.resolve.scopes.utils.asJetScope import org.jetbrains.kotlin.resolve.validation.SymbolUsageValidator -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.expressions.ExpressionTypingContext import org.jetbrains.kotlin.utils.addIfNotNull import java.util.* @@ -102,7 +102,7 @@ class QualifierReceiver ( return ChainedScope(descriptor, "Static scope for " + name + " as package or class or object", *scopes.toTypedArray()) } - override fun getType(): KtType = throw IllegalStateException("No type corresponds to QualifierReceiver '$this'") + override fun getType(): KotlinType = throw IllegalStateException("No type corresponds to QualifierReceiver '$this'") override fun exists() = true @@ -136,7 +136,7 @@ fun createQualifier( fun QualifierReceiver.resolveAsStandaloneExpression( context: ExpressionTypingContext, symbolUsageValidator: SymbolUsageValidator -): KtType? { +): KotlinType? { resolveAndRecordReferenceTarget(context, symbolUsageValidator, selector = null) if (classifier is TypeParameterDescriptor) { context.trace.report(TYPE_PARAMETER_IS_NOT_AN_EXPRESSION.on(referenceExpression, classifier)) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/receivers/ScriptReceiver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/receivers/ScriptReceiver.java index 1225149a436..7560e9b8d45 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/receivers/ScriptReceiver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/receivers/ScriptReceiver.java @@ -19,7 +19,7 @@ package org.jetbrains.kotlin.resolve.scopes.receivers; import org.jetbrains.annotations.NotNull; import org.jetbrains.kotlin.descriptors.ScriptDescriptor; import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; // SCRIPT: script receiver public class ScriptReceiver implements ThisReceiver { @@ -40,7 +40,7 @@ public class ScriptReceiver implements ThisReceiver { @NotNull @Override - public KtType getType() { + public KotlinType getType() { // not sure return DescriptorUtilsKt.getBuiltIns(scriptDescriptor).getAnyType(); } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/utils/ScopeUtils.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/utils/ScopeUtils.kt index acc9006bf03..b17976b2061 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/utils/ScopeUtils.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/utils/ScopeUtils.kt @@ -23,7 +23,7 @@ import org.jetbrains.kotlin.incremental.components.NoLookupLocation import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.resolve.lazy.LazyFileScope import org.jetbrains.kotlin.resolve.scopes.* -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.util.collectionUtils.concat import org.jetbrains.kotlin.utils.Printer @@ -155,16 +155,16 @@ private class LexicalToJetScopeAdapter(lexicalScope: LexicalScope): KtScope { it.getDeclaredFunctions(name, location) } - override fun getSyntheticExtensionProperties(receiverTypes: Collection, name: Name, location: LookupLocation) + override fun getSyntheticExtensionProperties(receiverTypes: Collection, name: Name, location: LookupLocation) = lexicalScope.getFileScope().getSyntheticExtensionProperties(receiverTypes, name, location) - override fun getSyntheticExtensionFunctions(receiverTypes: Collection, name: Name, location: LookupLocation) + override fun getSyntheticExtensionFunctions(receiverTypes: Collection, name: Name, location: LookupLocation) = lexicalScope.getFileScope().getSyntheticExtensionFunctions(receiverTypes, name, location) - override fun getSyntheticExtensionProperties(receiverTypes: Collection) + override fun getSyntheticExtensionProperties(receiverTypes: Collection) = lexicalScope.getFileScope().getSyntheticExtensionProperties(receiverTypes) - override fun getSyntheticExtensionFunctions(receiverTypes: Collection) + override fun getSyntheticExtensionFunctions(receiverTypes: Collection) = lexicalScope.getFileScope().getSyntheticExtensionFunctions(receiverTypes) override fun getContainingDeclaration() = lexicalScope.ownerDescriptor @@ -200,16 +200,16 @@ private class LexicalToJetScopeAdapter(lexicalScope: LexicalScope): KtScope { private class MemberScopeToFileScopeAdapter(val memberScope: KtScope) : FileScope { override fun getPackage(name: Name): PackageViewDescriptor? = memberScope.getPackage(name) - override fun getSyntheticExtensionProperties(receiverTypes: Collection, name: Name, location: LookupLocation) + override fun getSyntheticExtensionProperties(receiverTypes: Collection, name: Name, location: LookupLocation) = memberScope.getSyntheticExtensionProperties(receiverTypes, name, location) - override fun getSyntheticExtensionFunctions(receiverTypes: Collection, name: Name, location: LookupLocation) + override fun getSyntheticExtensionFunctions(receiverTypes: Collection, name: Name, location: LookupLocation) = memberScope.getSyntheticExtensionFunctions(receiverTypes, name, location) - override fun getSyntheticExtensionProperties(receiverTypes: Collection) + override fun getSyntheticExtensionProperties(receiverTypes: Collection) = memberScope.getSyntheticExtensionProperties(receiverTypes) - override fun getSyntheticExtensionFunctions(receiverTypes: Collection) + override fun getSyntheticExtensionFunctions(receiverTypes: Collection) = memberScope.getSyntheticExtensionFunctions(receiverTypes) override fun getDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/storage/LockBasedLazyResolveStorageManager.kt b/compiler/frontend/src/org/jetbrains/kotlin/storage/LockBasedLazyResolveStorageManager.kt index 42739c86138..43bff4d0023 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/storage/LockBasedLazyResolveStorageManager.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/storage/LockBasedLazyResolveStorageManager.kt @@ -26,7 +26,7 @@ import org.jetbrains.kotlin.resolve.TraceEntryFilter import org.jetbrains.kotlin.resolve.diagnostics.Diagnostics import com.intellij.util.containers.ContainerUtil import org.jetbrains.kotlin.psi.KtExpression -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType public class LockBasedLazyResolveStorageManager(private val storageManager: StorageManager): StorageManager by storageManager, LazyResolveStorageManager { override fun createSoftlyRetainedMemoizedFunction(compute: Function1) = @@ -39,7 +39,7 @@ public class LockBasedLazyResolveStorageManager(private val storageManager: Stor LockProtectedTrace(storageManager, originalTrace) private class LockProtectedContext(private val storageManager: StorageManager, private val context: BindingContext) : BindingContext { - override fun getType(expression: KtExpression): KtType? = storageManager.compute { context.getType(expression) } + override fun getType(expression: KtExpression): KotlinType? = storageManager.compute { context.getType(expression) } override fun getDiagnostics(): Diagnostics = storageManager.compute { context.getDiagnostics() } @@ -56,11 +56,11 @@ public class LockBasedLazyResolveStorageManager(private val storageManager: Stor } private class LockProtectedTrace(private val storageManager: StorageManager, private val trace: BindingTrace) : BindingTrace { - override fun recordType(expression: KtExpression, type: KtType?) { + override fun recordType(expression: KtExpression, type: KotlinType?) { storageManager.compute { trace.recordType(expression, type) } } - override fun getType(expression: KtExpression): KtType? = storageManager.compute { trace.getType(expression) } + override fun getType(expression: KtExpression): KotlinType? = storageManager.compute { trace.getType(expression) } private val context: BindingContext = LockProtectedContext(storageManager, trace.getBindingContext()) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/BoundsSubstitutor.java b/compiler/frontend/src/org/jetbrains/kotlin/types/BoundsSubstitutor.java index a7127c475cb..fbf047e1ffa 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/BoundsSubstitutor.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/BoundsSubstitutor.java @@ -30,9 +30,9 @@ import java.util.List; import java.util.Map; public class BoundsSubstitutor { - private static final Function PROJECTIONS_TO_TYPES = new Function() { + private static final Function PROJECTIONS_TO_TYPES = new Function() { @Override - public KtType apply(TypeProjection projection) { + public KotlinType apply(TypeProjection projection) { return projection.getType(); } }; @@ -60,8 +60,8 @@ public class BoundsSubstitutor { // todo assert: no loops for (TypeParameterDescriptor descriptor : topologicallySortTypeParameters(typeParameters)) { - KtType upperBoundsAsType = descriptor.getUpperBoundsAsType(); - KtType substitutedUpperBoundsAsType = substitutor.substitute(upperBoundsAsType, Variance.INVARIANT); + KotlinType upperBoundsAsType = descriptor.getUpperBoundsAsType(); + KotlinType substitutedUpperBoundsAsType = substitutor.substitute(upperBoundsAsType, Variance.INVARIANT); mutableSubstitution.put(descriptor.getTypeConstructor(), new TypeProjectionImpl(substitutedUpperBoundsAsType)); } @@ -96,16 +96,16 @@ public class BoundsSubstitutor { ) { return DFS.dfs( current.getUpperBounds(), - new DFS.Neighbors() { + new DFS.Neighbors() { @NotNull @Override - public Iterable getNeighbors(KtType current) { + public Iterable getNeighbors(KotlinType current) { return Collections2.transform(current.getArguments(), PROJECTIONS_TO_TYPES); } }, - new DFS.NodeHandlerWithListResult() { + new DFS.NodeHandlerWithListResult() { @Override - public boolean beforeChildren(KtType current) { + public boolean beforeChildren(KotlinType current) { ClassifierDescriptor declarationDescriptor = current.getConstructor().getDeclarationDescriptor(); // typeParameters in a list, but it contains very few elements, so it's fine to call contains() on it //noinspection SuspiciousMethodCalls diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/CastDiagnosticsUtil.java b/compiler/frontend/src/org/jetbrains/kotlin/types/CastDiagnosticsUtil.java index 8d1f05560ce..03b7d74e78a 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/CastDiagnosticsUtil.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/CastDiagnosticsUtil.java @@ -39,8 +39,8 @@ public class CastDiagnosticsUtil { // As this method produces a warning, it must be _complete_ (not sound), i.e. every time it says "cast impossible", // it must be really impossible public static boolean isCastPossible( - @NotNull KtType lhsType, - @NotNull KtType rhsType, + @NotNull KotlinType lhsType, + @NotNull KotlinType rhsType, @NotNull PlatformToKotlinClassMap platformToKotlinClassMap ) { if (KotlinBuiltIns.isNullableNothing(lhsType) && !TypeUtils.isNullableType(rhsType)) return false; @@ -62,12 +62,12 @@ public class CastDiagnosticsUtil { * Due to limitations in PlatformToKotlinClassMap, we only consider mapping of platform classes to Kotlin classed * (i.e. java.lang.String -> kotlin.String) and ignore mappings that go the other way. */ - private static boolean isRelated(@NotNull KtType a, @NotNull KtType b, @NotNull PlatformToKotlinClassMap platformToKotlinClassMap) { - List aTypes = mapToPlatformIndependentTypes(TypeUtils.makeNotNullable(a), platformToKotlinClassMap); - List bTypes = mapToPlatformIndependentTypes(TypeUtils.makeNotNullable(b), platformToKotlinClassMap); + private static boolean isRelated(@NotNull KotlinType a, @NotNull KotlinType b, @NotNull PlatformToKotlinClassMap platformToKotlinClassMap) { + List aTypes = mapToPlatformIndependentTypes(TypeUtils.makeNotNullable(a), platformToKotlinClassMap); + List bTypes = mapToPlatformIndependentTypes(TypeUtils.makeNotNullable(b), platformToKotlinClassMap); - for (KtType aType : aTypes) { - for (KtType bType : bTypes) { + for (KotlinType aType : aTypes) { + for (KotlinType bType : bTypes) { if (KotlinTypeChecker.DEFAULT.isSubtypeOf(aType, bType)) return true; if (KotlinTypeChecker.DEFAULT.isSubtypeOf(bType, aType)) return true; } @@ -76,8 +76,8 @@ public class CastDiagnosticsUtil { return false; } - private static List mapToPlatformIndependentTypes( - @NotNull KtType type, + private static List mapToPlatformIndependentTypes( + @NotNull KotlinType type, @NotNull PlatformToKotlinClassMap platformToKotlinClassMap ) { ClassifierDescriptor descriptor = type.getConstructor().getDeclarationDescriptor(); @@ -87,21 +87,21 @@ public class CastDiagnosticsUtil { Collection kotlinClasses = platformToKotlinClassMap.mapPlatformClass(originalClass); if (kotlinClasses.isEmpty()) return Collections.singletonList(type); - List result = Lists.newArrayListWithCapacity(2); + List result = Lists.newArrayListWithCapacity(2); result.add(type); for (ClassDescriptor classDescriptor : kotlinClasses) { - KtType kotlinType = TypeUtils.substituteProjectionsForParameters(classDescriptor, type.getArguments()); + KotlinType kotlinType = TypeUtils.substituteProjectionsForParameters(classDescriptor, type.getArguments()); result.add(kotlinType); } return result; } - private static boolean isFinal(@NotNull KtType type) { + private static boolean isFinal(@NotNull KotlinType type) { return !TypeUtils.canHaveSubtypes(KotlinTypeChecker.DEFAULT, type); } - private static boolean isTrait(@NotNull KtType type) { + private static boolean isTrait(@NotNull KotlinType type) { ClassifierDescriptor descriptor = type.getConstructor().getDeclarationDescriptor(); return descriptor instanceof ClassDescriptor && ((ClassDescriptor) descriptor).getKind() == ClassKind.INTERFACE; } @@ -110,7 +110,7 @@ public class CastDiagnosticsUtil { * Check if cast from supertype to subtype is erased. * It is an error in "is" statement and warning in "as". */ - public static boolean isCastErased(@NotNull KtType supertype, @NotNull KtType subtype, @NotNull KotlinTypeChecker typeChecker) { + public static boolean isCastErased(@NotNull KotlinType supertype, @NotNull KotlinType subtype, @NotNull KotlinTypeChecker typeChecker) { // cast between T and T? is always OK if (supertype.isMarkedNullable() || subtype.isMarkedNullable()) { return isCastErased(TypeUtils.makeNotNullable(supertype), TypeUtils.makeNotNullable(subtype), typeChecker); @@ -126,7 +126,7 @@ public class CastDiagnosticsUtil { // NOTE: this does not account for 'as Array>' if (allParametersReified(subtype)) return false; - KtType staticallyKnownSubtype = findStaticallyKnownSubtype(supertype, subtype.getConstructor()).getResultingType(); + KotlinType staticallyKnownSubtype = findStaticallyKnownSubtype(supertype, subtype.getConstructor()).getResultingType(); // If the substitution failed, it means that the result is an impossible type, e.g. something like Out // In this case, we can't guarantee anything, so the cast is considered to be erased @@ -153,18 +153,18 @@ public class CastDiagnosticsUtil { * subtype = List<...> * result = List<*>, some arguments were not inferred, replaced with '*' */ - public static TypeReconstructionResult findStaticallyKnownSubtype(@NotNull KtType supertype, @NotNull TypeConstructor subtypeConstructor) { + public static TypeReconstructionResult findStaticallyKnownSubtype(@NotNull KotlinType supertype, @NotNull TypeConstructor subtypeConstructor) { assert !supertype.isMarkedNullable() : "This method only makes sense for non-nullable types"; // Assume we are casting an expression of type Collection to List // First, let's make List, where T is a type variable ClassifierDescriptor descriptor = subtypeConstructor.getDeclarationDescriptor(); assert descriptor != null : "Can't create default type for " + subtypeConstructor; - KtType subtypeWithVariables = descriptor.getDefaultType(); + KotlinType subtypeWithVariables = descriptor.getDefaultType(); // Now, let's find a supertype of List that is a Collection of something, // in this case it will be Collection - KtType supertypeWithVariables = TypeCheckingProcedure.findCorrespondingSupertype(subtypeWithVariables, supertype); + KotlinType supertypeWithVariables = TypeCheckingProcedure.findCorrespondingSupertype(subtypeWithVariables, supertype); final List variables = subtypeWithVariables.getConstructor().getParameters(); @@ -204,12 +204,12 @@ public class CastDiagnosticsUtil { // At this point we have values for all type parameters of List // Let's make a type by substituting them: List -> List - KtType substituted = TypeSubstitutor.create(substitution).substitute(subtypeWithVariables, Variance.INVARIANT); + KotlinType substituted = TypeSubstitutor.create(substitution).substitute(subtypeWithVariables, Variance.INVARIANT); return new TypeReconstructionResult(substituted, allArgumentsInferred); } - private static boolean allParametersReified(KtType subtype) { + private static boolean allParametersReified(KotlinType subtype) { for (TypeParameterDescriptor parameterDescriptor : subtype.getConstructor().getParameters()) { if (!parameterDescriptor.isReified()) return false; } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/DeferredType.java b/compiler/frontend/src/org/jetbrains/kotlin/types/DeferredType.java index df7d958d228..3c4e802c60f 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/DeferredType.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/DeferredType.java @@ -36,9 +36,9 @@ public class DeferredType extends DelegatingType implements LazyType { } }; - private static final Function1 RECURSION_PREVENTER = new Function1() { + private static final Function1 RECURSION_PREVENTER = new Function1() { @Override - public KtType invoke(Boolean firstTime) { + public KotlinType invoke(Boolean firstTime) { if (firstTime) throw new ReenteringLazyValueComputationException(); return ErrorUtils.createErrorType("Recursive dependency"); } @@ -48,7 +48,7 @@ public class DeferredType extends DelegatingType implements LazyType { public static DeferredType create( @NotNull StorageManager storageManager, @NotNull BindingTrace trace, - @NotNull Function0 compute + @NotNull Function0 compute ) { DeferredType deferredType = new DeferredType(storageManager.createLazyValue(compute)); trace.record(DEFERRED_TYPE, new Box(deferredType)); @@ -59,7 +59,7 @@ public class DeferredType extends DelegatingType implements LazyType { public static DeferredType createRecursionIntolerant( @NotNull StorageManager storageManager, @NotNull BindingTrace trace, - @NotNull Function0 compute + @NotNull Function0 compute ) { //noinspection unchecked DeferredType deferredType = new DeferredType(storageManager.createLazyValueWithPostCompute( @@ -71,9 +71,9 @@ public class DeferredType extends DelegatingType implements LazyType { return deferredType; } - private final NotNullLazyValue lazyValue; + private final NotNullLazyValue lazyValue; - private DeferredType(@NotNull NotNullLazyValue lazyValue) { + private DeferredType(@NotNull NotNullLazyValue lazyValue) { this.lazyValue = lazyValue; } @@ -82,7 +82,7 @@ public class DeferredType extends DelegatingType implements LazyType { } @Override - public KtType getDelegate() { + public KotlinType getDelegate() { return lazyValue.invoke(); } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/SubstitutionUtils.java b/compiler/frontend/src/org/jetbrains/kotlin/types/SubstitutionUtils.java index 1cda6693af2..63b704f9f64 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/SubstitutionUtils.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/SubstitutionUtils.java @@ -35,7 +35,7 @@ public class SubstitutionUtils { * Builds a context with all the supertypes' parameters substituted */ @NotNull - public static TypeSubstitutor buildDeepSubstitutor(@NotNull KtType type) { + public static TypeSubstitutor buildDeepSubstitutor(@NotNull KotlinType type) { Map substitution = Maps.newHashMap(); TypeSubstitutor typeSubstitutor = TypeSubstitutor.create(substitution); // we use the mutability of the map here @@ -57,7 +57,7 @@ public class SubstitutionUtils { F declared in MyFooCollection -> out CharSequence */ @NotNull - public static Multimap buildDeepSubstitutionMultimap(@NotNull KtType type) { + public static Multimap buildDeepSubstitutionMultimap(@NotNull KotlinType type) { Multimap fullSubstitution = LinkedHashMultimap.create(); Map substitution = Maps.newHashMap(); TypeSubstitutor typeSubstitutor = TypeSubstitutor.create(substitution); @@ -68,7 +68,7 @@ public class SubstitutionUtils { // we use the mutability of the substitution map here private static void fillInDeepSubstitutor( - @NotNull KtType context, + @NotNull KotlinType context, @NotNull TypeSubstitutor substitutor, @NotNull Map substitution, @Nullable Multimap fullSubstitution @@ -92,7 +92,7 @@ public class SubstitutionUtils { } } if (KotlinBuiltIns.isNothingOrNullableNothing(context)) return; - for (KtType supertype : context.getConstructor().getSupertypes()) { + for (KotlinType supertype : context.getConstructor().getSupertypes()) { fillInDeepSubstitutor(supertype, substitutor, substitution, fullSubstitution); } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/TypeReconstructionResult.java b/compiler/frontend/src/org/jetbrains/kotlin/types/TypeReconstructionResult.java index 45137973fd4..5203bf3eba0 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/TypeReconstructionResult.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/TypeReconstructionResult.java @@ -19,16 +19,16 @@ package org.jetbrains.kotlin.types; import org.jetbrains.annotations.Nullable; public class TypeReconstructionResult { - private final KtType resultingType; + private final KotlinType resultingType; private final boolean allArgumentsInferred; - public TypeReconstructionResult(@Nullable KtType resultingType, boolean allArgumentsInferred) { + public TypeReconstructionResult(@Nullable KotlinType resultingType, boolean allArgumentsInferred) { this.resultingType = resultingType; this.allArgumentsInferred = allArgumentsInferred; } @Nullable - public KtType getResultingType() { + public KotlinType getResultingType() { return resultingType; } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/TypeUnifier.java b/compiler/frontend/src/org/jetbrains/kotlin/types/TypeUnifier.java index 61025fed5e5..fc391605659 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/TypeUnifier.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/TypeUnifier.java @@ -63,8 +63,8 @@ public class TypeUnifier { Predicate isVariable, UnificationResultImpl result ) { - KtType known = knownProjection.getType(); - KtType withVariables = projectWithVariables.getType(); + KotlinType known = knownProjection.getType(); + KotlinType withVariables = projectWithVariables.getType(); // in Foo ~ in X => Foo ~ X Variance knownProjectionKind = knownProjection.getProjectionKind(); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java index dde1fb84831..2a318589dac 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java @@ -139,7 +139,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { } @NotNull - public KtType getDefaultType(IElementType constantType) { + public KotlinType getDefaultType(IElementType constantType) { KotlinBuiltIns builtIns = components.builtIns; if (constantType == KtNodeTypes.INTEGER_CONSTANT) { return builtIns.getIntType(); @@ -179,8 +179,8 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { JetTypeInfo typeInfo = facade.getTypeInfo(left, contextWithNoExpectedType); - KtType subjectType = typeInfo.getType(); - KtType targetType = reconstructBareType(right, possiblyBareTarget, subjectType, context.trace, components.builtIns); + KotlinType subjectType = typeInfo.getType(); + KotlinType targetType = reconstructBareType(right, possiblyBareTarget, subjectType, context.trace, components.builtIns); if (subjectType != null) { checkBinaryWithTypeRHS(expression, contextWithNoExpectedType, targetType, subjectType); @@ -191,15 +191,15 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { } } - KtType result = operationType == AS_SAFE ? TypeUtils.makeNullable(targetType) : targetType; + KotlinType result = operationType == AS_SAFE ? TypeUtils.makeNullable(targetType) : targetType; return components.dataFlowAnalyzer.checkType(typeInfo.replaceType(result), expression, context); } private void checkBinaryWithTypeRHS( @NotNull KtBinaryExpressionWithTypeRHS expression, @NotNull ExpressionTypingContext context, - @NotNull KtType targetType, - @Nullable KtType actualType + @NotNull KotlinType targetType, + @Nullable KotlinType actualType ) { if (actualType == null) return; KtSimpleNameExpression operationSign = expression.getOperationReference(); @@ -213,8 +213,8 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { private void checkForCastImpossibilityOrRedundancy( KtBinaryExpressionWithTypeRHS expression, - KtType actualType, - KtType targetType, + KotlinType actualType, + KotlinType targetType, ExpressionTypingContext context ) { if (actualType == null || noExpectedType(targetType) || targetType.isError()) return; @@ -236,11 +236,11 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { context.trace.report(USELESS_CAST.on(expression)); return; } - Collection possibleTypes = components.dataFlowAnalyzer.getAllPossibleTypes( + Collection possibleTypes = components.dataFlowAnalyzer.getAllPossibleTypes( expression.getLeft(), context.dataFlowInfo, actualType, context); boolean checkExactType = checkExactTypeForUselessCast(expression); - for (KtType possibleType : possibleTypes) { + for (KotlinType possibleType : possibleTypes) { boolean castIsUseless = checkExactType ? possibleType.equals(targetType) : typeChecker.isSubtypeOf(possibleType, targetType); @@ -275,7 +275,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { @Override public JetTypeInfo visitThisExpression(@NotNull KtThisExpression expression, ExpressionTypingContext context) { - KtType result = null; + KotlinType result = null; LabelResolver.LabeledReceiverResolutionResult resolutionResult = resolveToReceiver(expression, context, false); switch (resolutionResult.getCode()) { @@ -310,7 +310,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { context.trace.report(SUPER_NOT_AVAILABLE.on(expression)); return errorInSuper(expression, context); case SUCCESS: - KtType result = checkPossiblyQualifiedSuper(expression, context, resolutionResult.getReceiverParameterDescriptor()); + KotlinType result = checkPossiblyQualifiedSuper(expression, context, resolutionResult.getReceiverParameterDescriptor()); if (result != null) { context.trace.recordType(expression.getInstanceReference(), result); } @@ -327,14 +327,14 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { return TypeInfoFactoryKt.noTypeInfo(context); } - private KtType checkPossiblyQualifiedSuper( + private KotlinType checkPossiblyQualifiedSuper( KtSuperExpression expression, ExpressionTypingContext context, ReceiverParameterDescriptor thisReceiver ) { - KtType result = null; - KtType thisType = thisReceiver.getType(); - Collection supertypes = thisType.getConstructor().getSupertypes(); + KotlinType result = null; + KotlinType thisType = thisReceiver.getType(); + Collection supertypes = thisType.getConstructor().getSupertypes(); TypeSubstitutor substitutor = TypeSubstitutor.create(thisType); KtTypeReference superTypeQualifier = expression.getSuperTypeQualifier(); @@ -342,7 +342,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { KtTypeElement typeElement = superTypeQualifier.getTypeElement(); DeclarationDescriptor classifierCandidate = null; - KtType supertype = null; + KotlinType supertype = null; PsiElement redundantTypeArguments = null; if (typeElement instanceof KtUserType) { KtUserType userType = (KtUserType) typeElement; @@ -367,7 +367,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { else if (classifierCandidate instanceof ClassDescriptor) { ClassDescriptor superclass = (ClassDescriptor) classifierCandidate; - for (KtType declaredSupertype : supertypes) { + for (KotlinType declaredSupertype : supertypes) { if (declaredSupertype.getConstructor().equals(superclass.getTypeConstructor())) { result = substitutor.safeSubstitute(declaredSupertype, Variance.INVARIANT); break; @@ -386,11 +386,11 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { } else { if (UnqualifiedSuperKt.isPossiblyAmbiguousUnqualifiedSuper(expression, supertypes)) { - Collection supertypesResolvedFromContext = + Collection supertypesResolvedFromContext = UnqualifiedSuperKt.resolveUnqualifiedSuperFromExpressionContext( expression, supertypes, components.builtIns.getAnyType()); if (supertypesResolvedFromContext.size() == 1) { - KtType singleResolvedType = supertypesResolvedFromContext.iterator().next(); + KotlinType singleResolvedType = supertypesResolvedFromContext.iterator().next(); result = substitutor.substitute(singleResolvedType, Variance.INVARIANT); } else if (supertypesResolvedFromContext.isEmpty()) { @@ -404,7 +404,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { } else { // supertypes may be empty when all the supertypes are error types (are not resolved, for example) - KtType type = supertypes.isEmpty() + KotlinType type = supertypes.isEmpty() ? components.builtIns.getAnyType() : supertypes.iterator().next(); result = substitutor.substitute(type, Variance.INVARIANT); @@ -506,7 +506,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { @Override public JetTypeInfo visitClassLiteralExpression(@NotNull KtClassLiteralExpression expression, ExpressionTypingContext c) { - KtType type = resolveClassLiteral(expression, c); + KotlinType type = resolveClassLiteral(expression, c); if (type != null && !type.isError()) { return components.dataFlowAnalyzer.createCheckedTypeInfo( components.reflectionTypes.getKClassType(Annotations.Companion.getEMPTY(), type), c, expression @@ -517,7 +517,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { } @Nullable - private KtType resolveClassLiteral(@NotNull KtClassLiteralExpression expression, ExpressionTypingContext c) { + private KotlinType resolveClassLiteral(@NotNull KtClassLiteralExpression expression, ExpressionTypingContext c) { KtTypeReference typeReference = expression.getTypeReference(); if (typeReference == null) { @@ -531,7 +531,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { PossiblyBareType possiblyBareType = components.typeResolver.resolvePossiblyBareType(context, typeReference); - KtType type = null; + KotlinType type = null; if (possiblyBareType.isBare()) { if (!possiblyBareType.isNullable()) { ClassifierDescriptor descriptor = possiblyBareType.getBareTypeConstructor().getDeclarationDescriptor(); @@ -546,7 +546,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { } } else { - KtType actualType = possiblyBareType.getActualType(); + KotlinType actualType = possiblyBareType.getActualType(); if (actualType.isError()) return null; if (isAllowedInClassLiteral(actualType)) { type = actualType; @@ -562,7 +562,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { } @NotNull - private static KtType substituteWithStarProjections(@NotNull ClassDescriptor descriptor) { + private static KotlinType substituteWithStarProjections(@NotNull ClassDescriptor descriptor) { TypeConstructor typeConstructor = descriptor.getTypeConstructor(); List arguments = CollectionsKt.map(typeConstructor.getParameters(), new Function1() { @@ -572,14 +572,14 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { } }); - return KtTypeImpl.create(Annotations.Companion.getEMPTY(), descriptor, false, arguments); + return KotlinTypeImpl.create(Annotations.Companion.getEMPTY(), descriptor, false, arguments); } - private static boolean isAllowedInClassLiteral(@NotNull KtType type) { + private static boolean isAllowedInClassLiteral(@NotNull KotlinType type) { return isClassAvailableAtRuntime(type, false); } - private static boolean isClassAvailableAtRuntime(@NotNull KtType type, boolean canBeNullable) { + private static boolean isClassAvailableAtRuntime(@NotNull KotlinType type, boolean canBeNullable) { if (type.isMarkedNullable() && !canBeNullable) return false; TypeConstructor typeConstructor = type.getConstructor(); @@ -614,7 +614,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { public JetTypeInfo visitCallableReferenceExpression(@NotNull KtCallableReferenceExpression expression, ExpressionTypingContext c) { KtTypeReference typeReference = expression.getTypeReference(); - KtType receiverType = + KotlinType receiverType = typeReference == null ? null : components.typeResolver.resolveType(c.scope, typeReference, c.trace, false); @@ -622,17 +622,17 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { KtSimpleNameExpression callableReference = expression.getCallableReference(); if (callableReference.getReferencedName().isEmpty()) { c.trace.report(UNRESOLVED_REFERENCE.on(callableReference, callableReference)); - KtType errorType = ErrorUtils.createErrorType("Empty callable reference"); + KotlinType errorType = ErrorUtils.createErrorType("Empty callable reference"); return components.dataFlowAnalyzer.createCheckedTypeInfo(errorType, c, expression); } - KtType result = getCallableReferenceType(expression, receiverType, c); + KotlinType result = getCallableReferenceType(expression, receiverType, c); return components.dataFlowAnalyzer.createCheckedTypeInfo(result, c, expression); } @Override public JetTypeInfo visitObjectLiteralExpression(@NotNull final KtObjectLiteralExpression expression, final ExpressionTypingContext context) { - final KtType[] result = new KtType[1]; + final KotlinType[] result = new KotlinType[1]; TemporaryBindingTrace temporaryTrace = TemporaryBindingTrace.create(context.trace, "trace to resolve object literal expression", expression); ObservableBindingTrace.RecordHandler handler = new ObservableBindingTrace.RecordHandler() { @@ -640,11 +640,11 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { @Override public void handleRecord(WritableSlice slice, PsiElement declaration, final ClassDescriptor descriptor) { if (slice == CLASS && declaration == expression.getObjectDeclaration()) { - KtType defaultType = DeferredType.createRecursionIntolerant(components.globalContext.getStorageManager(), - context.trace, - new Function0() { + KotlinType defaultType = DeferredType.createRecursionIntolerant(components.globalContext.getStorageManager(), + context.trace, + new Function0() { @Override - public KtType invoke() { + public KotlinType invoke() { return descriptor.getDefaultType(); } }); @@ -681,9 +681,9 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { } @Nullable - private KtType getCallableReferenceType( + private KotlinType getCallableReferenceType( @NotNull KtCallableReferenceExpression expression, - @Nullable KtType lhsType, + @Nullable KotlinType lhsType, @NotNull ExpressionTypingContext context ) { KtSimpleNameExpression reference = expression.getCallableReference(); @@ -742,7 +742,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { // Type check the base expression JetTypeInfo typeInfo = facade.safeGetTypeInfo(baseExpression, context); - KtType type = ExpressionTypingUtils.safeGetType(typeInfo); + KotlinType type = ExpressionTypingUtils.safeGetType(typeInfo); ExpressionReceiver receiver = new ExpressionReceiver(baseExpression, type); Call call = CallMaker.makeCall(receiver, expression); @@ -773,8 +773,8 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { } // Computing the return type - KtType returnType = resolutionResults.getResultingDescriptor().getReturnType(); - KtType result; + KotlinType returnType = resolutionResults.getResultingDescriptor().getReturnType(); + KotlinType result; if (operationType == KtTokens.PLUSPLUS || operationType == KtTokens.MINUSMINUS) { assert returnType != null : "returnType is null for " + resolutionResults.getResultingDescriptor(); if (KotlinBuiltIns.isUnit(returnType)) { @@ -782,7 +782,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { context.trace.report(INC_DEC_SHOULD_NOT_RETURN_UNIT.on(operationSign)); } else { - KtType receiverType = receiver.getType(); + KotlinType receiverType = receiver.getType(); if (!KotlinTypeChecker.DEFAULT.isSubtypeOf(returnType, receiverType)) { context.trace.report(RESULT_TYPE_MISMATCH.on(operationSign, name.asString(), receiverType, returnType)); } @@ -838,7 +838,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { return baseTypeInfo; } assert baseTypeInfo != null : "Base expression was not processed: " + expression; - KtType baseType = baseTypeInfo.getType(); + KotlinType baseType = baseTypeInfo.getType(); if (baseType == null) { return baseTypeInfo; } @@ -850,7 +850,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { DataFlowValue value = createDataFlowValue(baseExpression, baseType, context); baseTypeInfo = baseTypeInfo.replaceDataFlowInfo(dataFlowInfo.disequate(value, DataFlowValue.nullValue(components.builtIns))); } - KtType resultingType = TypeUtils.makeNotNullable(baseType); + KotlinType resultingType = TypeUtils.makeNotNullable(baseType); if (context.contextDependency == DEPENDENT) { return baseTypeInfo.replaceType(resultingType); } @@ -884,12 +884,12 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { } private static boolean isKnownToBeNotNull(KtExpression expression, ExpressionTypingContext context) { - KtType type = context.trace.getType(expression); + KotlinType type = context.trace.getType(expression); assert type != null : "This method is only supposed to be called when the type is not null"; return isKnownToBeNotNull(expression, type, context); } - private static boolean isKnownToBeNotNull(KtExpression expression, KtType jetType, ExpressionTypingContext context) { + private static boolean isKnownToBeNotNull(KtExpression expression, KotlinType jetType, ExpressionTypingContext context) { DataFlowValue dataFlowValue = createDataFlowValue(expression, jetType, context); return !context.dataFlowInfo.getNullability(dataFlowValue).canBeNull(); } @@ -1051,7 +1051,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { traceInterpretingRightAsNullableAny.recordType(right, components.builtIns.getNullableAnyType()); // Nothing? has no members, and `equals()` would be unresolved on it - KtType leftType = leftTypeInfo.getType(); + KotlinType leftType = leftTypeInfo.getType(); if (leftType != null && KotlinBuiltIns.isNothingOrNullableNothing(leftType)) { traceInterpretingRightAsNullableAny.recordType(left, components.builtIns.getNullableAnyType()); } @@ -1109,8 +1109,8 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { @NotNull KtSimpleNameExpression operationSign ) { JetTypeInfo typeInfo = getTypeInfoForBinaryCall(OperatorNameConventions.COMPARE_TO, context, expression); - KtType compareToReturnType = typeInfo.getType(); - KtType type = null; + KotlinType compareToReturnType = typeInfo.getType(); + KotlinType type = null; if (compareToReturnType != null && !compareToReturnType.isError()) { if (KotlinTypeChecker.DEFAULT.equalTypes(components.builtIns.getIntType(), compareToReturnType)) { type = components.builtIns.getBooleanType(); @@ -1129,7 +1129,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { @Nullable KtExpression right, @NotNull ExpressionTypingContext context ) { - KtType booleanType = components.builtIns.getBooleanType(); + KotlinType booleanType = components.builtIns.getBooleanType(); JetTypeInfo leftTypeInfo = getTypeInfoOrNullType(left, context.replaceExpectedType(booleanType), facade); DataFlowInfo dataFlowInfo = leftTypeInfo.getDataFlowInfo(); @@ -1170,7 +1170,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { if (leftTypeInfo == null) return TypeInfoFactoryKt.noTypeInfo(context); } assert leftTypeInfo != null : "Left expression was not processed: " + expression; - KtType leftType = leftTypeInfo.getType(); + KotlinType leftType = leftTypeInfo.getType(); if (leftType != null && isKnownToBeNotNull(left, leftType, context)) { context.trace.report(USELESS_ELVIS.on(expression, leftType)); } @@ -1181,7 +1181,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { } assert rightTypeInfo != null : "Right expression was not processed: " + expression; boolean loopBreakContinuePossible = leftTypeInfo.getJumpOutPossible() || rightTypeInfo.getJumpOutPossible(); - KtType rightType = rightTypeInfo.getType(); + KotlinType rightType = rightTypeInfo.getType(); // Only left argument DFA is taken into account here: we cannot be sure that right argument is executed DataFlowInfo dataFlowInfo = resolvedCall.getDataFlowInfoForArguments().getInfo(call.getValueArguments().get(1)); @@ -1194,7 +1194,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { dataFlowInfo = dataFlowInfo.disequate(leftValue, DataFlowValue.nullValue(components.builtIns)); } } - KtType type = resolvedCall.getResultingDescriptor().getReturnType(); + KotlinType type = resolvedCall.getResultingDescriptor().getReturnType(); if (type == null || rightType == null) return TypeInfoFactoryKt.noTypeInfo(dataFlowInfo); // Sometimes return type for special call for elvis operator might be nullable, @@ -1239,7 +1239,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { CallMaker.makeCall(callElement, receiver, null, operationSign, Collections.singletonList(leftArgument)), operationSign, OperatorNameConventions.CONTAINS); - KtType containsType = OverloadResolutionResultsUtil.getResultingType(resolutionResult, context.contextDependency); + KotlinType containsType = OverloadResolutionResultsUtil.getResultingType(resolutionResult, context.contextDependency); ensureBooleanResult(operationSign, OperatorNameConventions.CONTAINS, containsType, context); if (left != null) { @@ -1256,11 +1256,11 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { } - private boolean ensureBooleanResult(KtExpression operationSign, Name name, KtType resultType, ExpressionTypingContext context) { + private boolean ensureBooleanResult(KtExpression operationSign, Name name, KotlinType resultType, ExpressionTypingContext context) { return ensureBooleanResultWithCustomSubject(operationSign, resultType, "'" + name + "'", context); } - private boolean ensureBooleanResultWithCustomSubject(KtExpression operationSign, KtType resultType, String subjectName, ExpressionTypingContext context) { + private boolean ensureBooleanResultWithCustomSubject(KtExpression operationSign, KotlinType resultType, String subjectName, ExpressionTypingContext context) { if (resultType != null) { // TODO : Relax? if (!components.builtIns.isBooleanOrSubtype(resultType)) { @@ -1278,9 +1278,9 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { KtExpression right = expression.getRight(); // TODO : duplicated effort for == and != - KtType leftType = facade.getTypeInfo(left, context).getType(); + KotlinType leftType = facade.getTypeInfo(left, context).getType(); if (leftType != null && right != null) { - KtType rightType = facade.getTypeInfo(right, context).getType(); + KotlinType rightType = facade.getTypeInfo(right, context).getType(); if (rightType != null) { if (TypeIntersector.isIntersectionEmpty(leftType, rightType)) { @@ -1288,9 +1288,9 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { } SenselessComparisonChecker.checkSenselessComparisonWithNull( expression, left, right, context, - new Function1() { + new Function1() { @Override - public KtType invoke(KtExpression expression) { + public KotlinType invoke(KtExpression expression) { return facade.getTypeInfo(expression, context).getType(); } }, @@ -1475,7 +1475,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { JetTypeInfo arrayTypeInfo = facade.safeGetTypeInfo(arrayExpression, oldContext.replaceExpectedType(NO_EXPECTED_TYPE) .replaceContextDependency(INDEPENDENT)); - KtType arrayType = ExpressionTypingUtils.safeGetType(arrayTypeInfo); + KotlinType arrayType = ExpressionTypingUtils.safeGetType(arrayTypeInfo); ExpressionTypingContext context = oldContext.replaceDataFlowInfo(arrayTypeInfo.getDataFlowInfo()); ExpressionReceiver receiver = new ExpressionReceiver(arrayExpression, arrayType); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ControlStructureTypingUtils.java b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ControlStructureTypingUtils.java index 555babeb892..b39193445fb 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ControlStructureTypingUtils.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ControlStructureTypingUtils.java @@ -48,7 +48,7 @@ import org.jetbrains.kotlin.resolve.calls.tasks.ResolutionCandidate; import org.jetbrains.kotlin.resolve.calls.tasks.TracingStrategy; import org.jetbrains.kotlin.resolve.calls.util.CallMaker; import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.TypeUtils; import org.jetbrains.kotlin.types.Variance; @@ -110,12 +110,12 @@ public class ControlStructureTypingUtils { function, Annotations.Companion.getEMPTY(), false, Variance.INVARIANT, Name.identifier(""), 0); - KtType type = typeParameter.getDefaultType(); - KtType nullableType = TypeUtils.makeNullable(type); + KotlinType type = typeParameter.getDefaultType(); + KotlinType nullableType = TypeUtils.makeNullable(type); List valueParameters = new ArrayList(argumentNames.size()); for (int i = 0; i < argumentNames.size(); i++) { - KtType argumentType = isArgumentNullable.get(i) ? nullableType : type; + KotlinType argumentType = isArgumentNullable.get(i) ? nullableType : type; ValueParameterDescriptorImpl valueParameter = new ValueParameterDescriptorImpl( function, null, i, Annotations.Companion.getEMPTY(), Name.identifier(argumentNames.get(i)), argumentType, @@ -266,9 +266,9 @@ public class ControlStructureTypingUtils { ) { class CheckTypeContext { public BindingTrace trace; - public KtType expectedType; + public KotlinType expectedType; - CheckTypeContext(@NotNull BindingTrace trace, @NotNull KtType expectedType) { + CheckTypeContext(@NotNull BindingTrace trace, @NotNull KotlinType expectedType) { this.trace = trace; this.expectedType = expectedType; } @@ -511,14 +511,14 @@ public class ControlStructureTypingUtils { @Override public void unsafeCall( - @NotNull BindingTrace trace, @NotNull KtType type, boolean isCallForImplicitInvoke + @NotNull BindingTrace trace, @NotNull KotlinType type, boolean isCallForImplicitInvoke ) { logError(); } @Override public void unnecessarySafeCall( - @NotNull BindingTrace trace, @NotNull KtType type + @NotNull BindingTrace trace, @NotNull KotlinType type ) { logError(); } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ControlStructureTypingVisitor.java b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ControlStructureTypingVisitor.java index a3494e7fc27..a7c89413b17 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ControlStructureTypingVisitor.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ControlStructureTypingVisitor.java @@ -39,7 +39,7 @@ import org.jetbrains.kotlin.resolve.scopes.receivers.TransientReceiver; import org.jetbrains.kotlin.resolve.scopes.utils.ScopeUtilsKt; import org.jetbrains.kotlin.types.CommonSupertypes; import org.jetbrains.kotlin.types.ErrorUtils; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.TypeUtils; import org.jetbrains.kotlin.types.checker.KotlinTypeChecker; import org.jetbrains.kotlin.types.expressions.typeInfoFactory.TypeInfoFactoryKt; @@ -69,7 +69,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor { if (condition != null) { JetTypeInfo typeInfo = facade.getTypeInfo(condition, context.replaceScope(scope) .replaceExpectedType(components.builtIns.getBooleanType()).replaceContextDependency(INDEPENDENT)); - KtType conditionType = typeInfo.getType(); + KotlinType conditionType = typeInfo.getType(); if (conditionType != null && !components.builtIns.isBooleanOrSubtype(conditionType)) { context.trace.report(TYPE_MISMATCH_IN_CONDITION.on(condition, conditionType)); @@ -139,8 +139,8 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor { assert elseTypeInfo != null : "'Else' branch of if expression was not processed: " + ifExpression; boolean loopBreakContinuePossible = thenTypeInfo.getJumpOutPossible() || elseTypeInfo.getJumpOutPossible(); - KtType thenType = thenTypeInfo.getType(); - KtType elseType = elseTypeInfo.getType(); + KotlinType thenType = thenTypeInfo.getType(); + KotlinType elseType = elseTypeInfo.getType(); DataFlowInfo thenDataFlowInfo = thenTypeInfo.getDataFlowInfo(); DataFlowInfo elseDataFlowInfo = elseTypeInfo.getDataFlowInfo(); @@ -161,7 +161,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor { resultDataFlowInfo = thenDataFlowInfo.or(elseDataFlowInfo); } - KtType resultType = resolvedCall.getResultingDescriptor().getReturnType(); + KotlinType resultType = resolvedCall.getResultingDescriptor().getReturnType(); // If break or continue was possible, take condition check info as the jump info return TypeInfoFactoryKt .createTypeInfo(components.dataFlowAnalyzer.checkImplicitCast(resultType, ifExpression, contextWithExpectedType, isStatement), @@ -182,7 +182,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor { .replaceContextDependency(INDEPENDENT); JetTypeInfo typeInfo = components.expressionTypingServices.getBlockReturnedTypeWithWritableScope( presentScope, Collections.singletonList(presentBranch), CoercionStrategy.NO_COERCION, newContext); - KtType type = typeInfo.getType(); + KotlinType type = typeInfo.getType(); DataFlowInfo dataFlowInfo; if (type != null && KotlinBuiltIns.isNothing(type)) { dataFlowInfo = otherInfo; @@ -373,7 +373,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor { context = context.replaceDataFlowInfo(loopVisitor.clearDataFlowInfoForAssignedLocalVariables(context.dataFlowInfo)); KtExpression loopRange = expression.getLoopRange(); - KtType expectedParameterType = null; + KotlinType expectedParameterType = null; JetTypeInfo loopRangeInfo; if (loopRange != null) { ExpressionReceiver loopRangeReceiver = getExpressionReceiver(facade, loopRange, context.replaceScope(context.scope)); @@ -399,7 +399,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor { else { KtMultiDeclaration multiParameter = expression.getMultiParameter(); if (multiParameter != null && loopRange != null) { - KtType elementType = expectedParameterType == null ? ErrorUtils.createErrorType("Loop range has no type") : expectedParameterType; + KotlinType elementType = expectedParameterType == null ? ErrorUtils.createErrorType("Loop range has no type") : expectedParameterType; TransientReceiver iteratorNextAsReceiver = new TransientReceiver(elementType); components.annotationResolver.resolveAnnotationsWithArguments(loopScope, multiParameter.getModifierList(), context.trace); components.multiDeclarationResolver.defineLocalVariablesFromMultiDeclaration( @@ -427,7 +427,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor { private VariableDescriptor createLoopParameterDescriptor( KtParameter loopParameter, - KtType expectedParameterType, + KotlinType expectedParameterType, ExpressionTypingContext context ) { components.modifiersChecker.withTrace(context.trace).checkParameterHasNoValOrVar(loopParameter, VAL_OR_VAR_ON_LOOP_PARAMETER); @@ -437,7 +437,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor { if (typeReference != null) { variableDescriptor = components.descriptorResolver. resolveLocalVariableDescriptor(context.scope, loopParameter, context.trace); - KtType actualParameterType = variableDescriptor.getType(); + KotlinType actualParameterType = variableDescriptor.getType(); if (expectedParameterType != null && !KotlinTypeChecker.DEFAULT.isSubtypeOf(expectedParameterType, actualParameterType)) { context.trace.report(TYPE_MISMATCH_IN_FOR_LOOP.on(typeReference, expectedParameterType, actualParameterType)); @@ -469,7 +469,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor { KtExpression tryBlock = expression.getTryBlock(); List catchClauses = expression.getCatchClauses(); KtFinallySection finallyBlock = expression.getFinallyBlock(); - List types = new ArrayList(); + List types = new ArrayList(); for (KtCatchClause catchClause : catchClauses) { KtParameter catchParameter = catchClause.getCatchParameter(); KtExpression catchBody = catchClause.getCatchBody(); @@ -481,12 +481,12 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor { VariableDescriptor variableDescriptor = components.descriptorResolver.resolveLocalVariableDescriptor( context.scope, catchParameter, context.trace); - KtType throwableType = components.builtIns.getThrowable().getDefaultType(); + KotlinType throwableType = components.builtIns.getThrowable().getDefaultType(); components.dataFlowAnalyzer.checkType(variableDescriptor.getType(), catchParameter, context.replaceExpectedType(throwableType)); if (catchBody != null) { LexicalWritableScope catchScope = newWritableScopeImpl(context, "Catch scope"); catchScope.addVariableDescriptor(variableDescriptor); - KtType type = facade.getTypeInfo(catchBody, context.replaceScope(catchScope)).getType(); + KotlinType type = facade.getTypeInfo(catchBody, context.replaceScope(catchScope)).getType(); if (type != null) { types.add(type); } @@ -500,7 +500,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor { context.replaceExpectedType(NO_EXPECTED_TYPE)); } - KtType type = facade.getTypeInfo(tryBlock, context).getType(); + KotlinType type = facade.getTypeInfo(tryBlock, context).getType(); if (type != null) { types.add(type); } @@ -516,7 +516,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor { public JetTypeInfo visitThrowExpression(@NotNull KtThrowExpression expression, ExpressionTypingContext context) { KtExpression thrownExpression = expression.getThrownExpression(); if (thrownExpression != null) { - KtType throwableType = components.builtIns.getThrowable().getDefaultType(); + KotlinType throwableType = components.builtIns.getThrowable().getDefaultType(); facade.getTypeInfo(thrownExpression, context .replaceExpectedType(throwableType).replaceScope(context.scope).replaceContextDependency(INDEPENDENT)); } @@ -529,8 +529,8 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor { KtExpression returnedExpression = expression.getReturnedExpression(); - KtType expectedType = NO_EXPECTED_TYPE; - KtType resultType = components.builtIns.getNothingType(); + KotlinType expectedType = NO_EXPECTED_TYPE; + KotlinType resultType = components.builtIns.getNothingType(); KtDeclaration parentDeclaration = PsiTreeUtil.getParentOfType(expression, KtDeclaration.class); if (parentDeclaration instanceof KtParameter) { @@ -616,12 +616,12 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor { } @NotNull - private static KtType getFunctionExpectedReturnType( + private static KotlinType getFunctionExpectedReturnType( @NotNull FunctionDescriptor descriptor, @NotNull KtElement function, @NotNull ExpressionTypingContext context ) { - KtType expectedType; + KotlinType expectedType; if (function instanceof KtSecondaryConstructor) { expectedType = DescriptorUtilsKt.getBuiltIns(descriptor).getUnitType(); } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/DataFlowAnalyzer.java b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/DataFlowAnalyzer.java index 0e8a78c72d9..8596e125d42 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/DataFlowAnalyzer.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/DataFlowAnalyzer.java @@ -32,7 +32,7 @@ import org.jetbrains.kotlin.resolve.calls.smartcasts.*; import org.jetbrains.kotlin.resolve.constants.*; import org.jetbrains.kotlin.resolve.constants.evaluate.ConstantExpressionEvaluator; import org.jetbrains.kotlin.types.DynamicTypesKt; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.TypeUtils; import org.jetbrains.kotlin.types.checker.KotlinTypeChecker; import org.jetbrains.kotlin.types.expressions.typeInfoFactory.TypeInfoFactoryKt; @@ -102,9 +102,9 @@ public class DataFlowAnalyzer { KtExpression right = expression.getRight(); if (right == null) return; - KtType lhsType = context.trace.getBindingContext().getType(left); + KotlinType lhsType = context.trace.getBindingContext().getType(left); if (lhsType == null) return; - KtType rhsType = context.trace.getBindingContext().getType(right); + KotlinType rhsType = context.trace.getBindingContext().getType(right); if (rhsType == null) return; DataFlowValue leftValue = DataFlowValueFactory.createDataFlowValue(left, lhsType, context); @@ -155,7 +155,7 @@ public class DataFlowAnalyzer { } @Nullable - public KtType checkType(@Nullable KtType expressionType, @NotNull KtExpression expression, @NotNull ResolutionContext context) { + public KotlinType checkType(@Nullable KotlinType expressionType, @NotNull KtExpression expression, @NotNull ResolutionContext context) { return checkType(expressionType, expression, context, null); } @@ -165,8 +165,8 @@ public class DataFlowAnalyzer { } @NotNull - private KtType checkTypeInternal( - @NotNull KtType expressionType, + private KotlinType checkTypeInternal( + @NotNull KotlinType expressionType, @NotNull KtExpression expression, @NotNull ResolutionContext c, @NotNull Ref hasError @@ -189,7 +189,7 @@ public class DataFlowAnalyzer { return expressionType; } - KtType possibleType = checkPossibleCast(expressionType, expression, c); + KotlinType possibleType = checkPossibleCast(expressionType, expression, c); if (possibleType != null) return possibleType; c.trace.report(TYPE_MISMATCH.on(expression, c.expectedType, expressionType)); @@ -198,8 +198,8 @@ public class DataFlowAnalyzer { } @Nullable - public KtType checkType( - @Nullable KtType expressionType, + public KotlinType checkType( + @Nullable KotlinType expressionType, @NotNull KtExpression expressionToCheck, @NotNull ResolutionContext c, @Nullable Ref hasError @@ -216,7 +216,7 @@ public class DataFlowAnalyzer { if (expressionType == null) return null; - KtType result = checkTypeInternal(expressionType, expression, c, hasError); + KotlinType result = checkTypeInternal(expressionType, expression, c, hasError); if (Boolean.FALSE.equals(hasError.get())) { for (AdditionalTypeChecker checker : additionalTypeCheckers) { checker.checkType(expression, expressionType, result, c); @@ -227,8 +227,8 @@ public class DataFlowAnalyzer { } @Nullable - public KtType checkPossibleCast( - @NotNull KtType expressionType, + public KotlinType checkPossibleCast( + @NotNull KotlinType expressionType, @NotNull KtExpression expression, @NotNull ResolutionContext c ) { @@ -238,15 +238,15 @@ public class DataFlowAnalyzer { return result != null ? result.getResultType() : null; } - public void recordExpectedType(@NotNull BindingTrace trace, @NotNull KtExpression expression, @NotNull KtType expectedType) { + public void recordExpectedType(@NotNull BindingTrace trace, @NotNull KtExpression expression, @NotNull KotlinType expectedType) { if (expectedType != NO_EXPECTED_TYPE) { - KtType normalizeExpectedType = expectedType == UNIT_EXPECTED_TYPE ? builtIns.getUnitType() : expectedType; + KotlinType normalizeExpectedType = expectedType == UNIT_EXPECTED_TYPE ? builtIns.getUnitType() : expectedType; trace.record(BindingContext.EXPECTED_EXPRESSION_TYPE, expression, normalizeExpectedType); } } @Nullable - public KtType 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()) { context.trace.report(EXPECTED_TYPE_MISMATCH.on(expression, context.expectedType)); return null; @@ -255,7 +255,7 @@ public class DataFlowAnalyzer { } @Nullable - public KtType checkImplicitCast(@Nullable KtType expressionType, @NotNull KtExpression expression, @NotNull ResolutionContext context, boolean isStatement) { + public KotlinType checkImplicitCast(@Nullable KotlinType expressionType, @NotNull KtExpression expression, @NotNull ResolutionContext context, boolean isStatement) { boolean isIfExpression = expression instanceof KtIfExpression; if (expressionType != null && (context.expectedType == NO_EXPECTED_TYPE || isIfExpression) && context.contextDependency == INDEPENDENT && !isStatement @@ -289,14 +289,14 @@ public class DataFlowAnalyzer { } @NotNull - public Collection getAllPossibleTypes( + public Collection getAllPossibleTypes( @NotNull KtExpression expression, @NotNull DataFlowInfo dataFlowInfo, - @NotNull KtType type, + @NotNull KotlinType type, @NotNull ResolutionContext c ) { DataFlowValue dataFlowValue = DataFlowValueFactory.createDataFlowValue(expression, type, c); - Collection possibleTypes = Sets.newHashSet(type); + Collection possibleTypes = Sets.newHashSet(type); if (dataFlowValue.isPredictable()) { possibleTypes.addAll(dataFlowInfo.getPossibleTypes(dataFlowValue)); } @@ -305,7 +305,7 @@ public class DataFlowAnalyzer { @NotNull public JetTypeInfo createCheckedTypeInfo( - @Nullable KtType type, + @Nullable KotlinType type, @NotNull ResolutionContext context, @NotNull KtExpression expression ) { @@ -318,7 +318,7 @@ public class DataFlowAnalyzer { @NotNull KtExpression expression, @NotNull ExpressionTypingContext context ) { - KtType expressionType; + KotlinType expressionType; if (value instanceof IntegerValueTypeConstant) { IntegerValueTypeConstant integerValueTypeConstant = (IntegerValueTypeConstant) value; if (context.contextDependency == INDEPENDENT) { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingContext.java b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingContext.java index cbef23e4c25..e9917e9645b 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingContext.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingContext.java @@ -26,7 +26,7 @@ import org.jetbrains.kotlin.resolve.calls.context.ResolutionResultsCache; import org.jetbrains.kotlin.resolve.calls.context.ResolutionResultsCacheImpl; import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo; import org.jetbrains.kotlin.resolve.scopes.LexicalScope; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; public class ExpressionTypingContext extends ResolutionContext { @@ -35,7 +35,7 @@ public class ExpressionTypingContext extends ResolutionContext getValueParametersTypes(@NotNull List valueParameters) { - List parameterTypes = new ArrayList(valueParameters.size()); + public static List getValueParametersTypes(@NotNull List valueParameters) { + List parameterTypes = new ArrayList(valueParameters.size()); for (ValueParameterDescriptor parameter : valueParameters) { parameterTypes.add(parameter.getType()); } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingVisitorDispatcher.java b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingVisitorDispatcher.java index abefb39806f..0ab892ef3b5 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingVisitorDispatcher.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingVisitorDispatcher.java @@ -31,7 +31,7 @@ import org.jetbrains.kotlin.resolve.bindingContextUtil.BindingContextUtilsKt; import org.jetbrains.kotlin.resolve.scopes.LexicalWritableScope; import org.jetbrains.kotlin.types.DeferredType; import org.jetbrains.kotlin.types.ErrorUtils; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.expressions.typeInfoFactory.TypeInfoFactoryKt; import org.jetbrains.kotlin.util.PerformanceCounter; import org.jetbrains.kotlin.util.ReenteringLazyValueComputationException; @@ -171,7 +171,7 @@ public abstract class ExpressionTypingVisitorDispatcher extends KtVisitor binaryOperationDescriptors; - KtType binaryOperationType; + KotlinType binaryOperationType; TemporaryTraceAndCache temporaryForBinaryOperation = TemporaryTraceAndCache.create( context, "trace to check binary operation like '+' for", expression); TemporaryBindingTrace ignoreReportsTrace = TemporaryBindingTrace.create(context.trace, "Trace for checking assignability"); @@ -289,7 +289,7 @@ public class ExpressionTypingVisitorForStatements extends ExpressionTypingVisito binaryOperationType = null; } - KtType type = assignmentOperationType != null ? assignmentOperationType : binaryOperationType; + KotlinType type = assignmentOperationType != null ? assignmentOperationType : binaryOperationType; JetTypeInfo rightInfo = leftInfo; if (assignmentOperationDescriptors.isSuccess() && binaryOperationDescriptors.isSuccess()) { // Both 'plus()' and 'plusAssign()' available => ambiguity @@ -347,13 +347,13 @@ public class ExpressionTypingVisitorForStatements extends ExpressionTypingVisito return typeInfo.replaceType(checkAssignmentType(typeInfo.getType(), expression, contextWithExpectedType)); } JetTypeInfo leftInfo = ExpressionTypingUtils.getTypeInfoOrNullType(left, context, facade); - KtType leftType = leftInfo.getType(); + KotlinType leftType = leftInfo.getType(); DataFlowInfo dataFlowInfo = leftInfo.getDataFlowInfo(); JetTypeInfo resultInfo; if (right != null) { resultInfo = facade.getTypeInfo(right, context.replaceDataFlowInfo(dataFlowInfo).replaceExpectedType(leftType)); dataFlowInfo = resultInfo.getDataFlowInfo(); - KtType rightType = resultInfo.getType(); + KotlinType rightType = resultInfo.getType(); if (left != null && leftType != null && rightType != null) { DataFlowValue leftValue = DataFlowValueFactory.createDataFlowValue(left, leftType, context); DataFlowValue rightValue = DataFlowValueFactory.createDataFlowValue(right, rightType, context); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/FakeCallResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/FakeCallResolver.kt index df1c9270cbd..593ac65533c 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/FakeCallResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/FakeCallResolver.kt @@ -28,7 +28,7 @@ import org.jetbrains.kotlin.resolve.calls.CallResolver import org.jetbrains.kotlin.resolve.calls.results.OverloadResolutionResults import org.jetbrains.kotlin.resolve.calls.util.CallMaker import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.utils.doNothing import java.util.* @@ -41,7 +41,7 @@ public class FakeCallResolver( receiver: ReceiverValue, name: Name, callElement: KtExpression?, - vararg argumentTypes: KtType + vararg argumentTypes: KotlinType ): OverloadResolutionResults { val traceWithFakeArgumentInfo = TemporaryBindingTrace.create(context.trace, "trace to store fake argument for", name) val fakeArguments = ArrayList() diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ForLoopConventionsChecker.java b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ForLoopConventionsChecker.java index 4f87b6b4326..107ccd86eb2 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ForLoopConventionsChecker.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ForLoopConventionsChecker.java @@ -35,7 +35,7 @@ import org.jetbrains.kotlin.resolve.validation.OperatorValidator; import org.jetbrains.kotlin.resolve.validation.SymbolUsageValidator; import org.jetbrains.kotlin.types.DynamicTypesKt; import org.jetbrains.kotlin.types.ErrorUtils; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.util.slicedMap.WritableSlice; import java.util.Collections; @@ -60,7 +60,7 @@ public class ForLoopConventionsChecker { } @Nullable - public KtType checkIterableConvention(@NotNull ExpressionReceiver loopRange, ExpressionTypingContext context) { + public KotlinType checkIterableConvention(@NotNull ExpressionReceiver loopRange, ExpressionTypingContext context) { KtExpression loopRangeExpression = loopRange.getExpression(); // Make a fake call loopRange.iterator(), and try to resolve it @@ -79,10 +79,10 @@ public class ForLoopConventionsChecker { symbolUsageValidator.validateCall(iteratorResolvedCall, iteratorFunction, context.trace, loopRangeExpression); - KtType iteratorType = iteratorFunction.getReturnType(); - KtType hasNextType = checkConventionForIterator(context, loopRangeExpression, iteratorType, "hasNext", - HAS_NEXT_FUNCTION_AMBIGUITY, HAS_NEXT_MISSING, HAS_NEXT_FUNCTION_NONE_APPLICABLE, - LOOP_RANGE_HAS_NEXT_RESOLVED_CALL); + KotlinType iteratorType = iteratorFunction.getReturnType(); + KotlinType hasNextType = checkConventionForIterator(context, loopRangeExpression, iteratorType, "hasNext", + HAS_NEXT_FUNCTION_AMBIGUITY, HAS_NEXT_MISSING, HAS_NEXT_FUNCTION_NONE_APPLICABLE, + LOOP_RANGE_HAS_NEXT_RESOLVED_CALL); if (hasNextType != null && !builtIns.isBooleanOrSubtype(hasNextType)) { context.trace.report(HAS_NEXT_FUNCTION_TYPE_MISMATCH.on(loopRangeExpression, hasNextType)); } @@ -112,14 +112,14 @@ public class ForLoopConventionsChecker { } @Nullable - private KtType checkConventionForIterator( + private KotlinType checkConventionForIterator( @NotNull ExpressionTypingContext context, @NotNull KtExpression loopRangeExpression, - @NotNull KtType iteratorType, + @NotNull KotlinType iteratorType, @NotNull String name, - @NotNull DiagnosticFactory1 ambiguity, - @NotNull DiagnosticFactory1 missing, - @NotNull DiagnosticFactory1 noneApplicable, + @NotNull DiagnosticFactory1 ambiguity, + @NotNull DiagnosticFactory1 missing, + @NotNull DiagnosticFactory1 noneApplicable, @NotNull WritableSlice> resolvedCallKey ) { OverloadResolutionResults nextResolutionResults = fakeCallResolver.resolveFakeCall( diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/FunctionsTypingVisitor.kt b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/FunctionsTypingVisitor.kt index ba84ae96daf..d9d471e1c41 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/FunctionsTypingVisitor.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/FunctionsTypingVisitor.kt @@ -34,7 +34,7 @@ import org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil import org.jetbrains.kotlin.resolve.scopes.LexicalWritableScope import org.jetbrains.kotlin.resolve.source.toSourceElement import org.jetbrains.kotlin.types.CommonSupertypes -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeUtils import org.jetbrains.kotlin.types.TypeUtils.* import org.jetbrains.kotlin.types.expressions.CoercionStrategy.COERCION_TO_UNIT @@ -114,7 +114,7 @@ public class FunctionsTypingVisitor(facade: ExpressionTypingInternals) : Express } } - private fun createFunctionType(functionDescriptor: SimpleFunctionDescriptor): KtType? { + private fun createFunctionType(functionDescriptor: SimpleFunctionDescriptor): KotlinType? { val receiverType = functionDescriptor.getExtensionReceiverParameter()?.getType() val returnType = functionDescriptor.getReturnType() @@ -177,7 +177,7 @@ public class FunctionsTypingVisitor(facade: ExpressionTypingInternals) : Express context: ExpressionTypingContext, functionDescriptor: SimpleFunctionDescriptorImpl, functionTypeExpected: Boolean - ): KtType { + ): KotlinType { val expectedReturnType = if (functionTypeExpected) KotlinBuiltIns.getReturnTypeFromFunctionType(context.expectedType) else null val returnType = computeUnsafeReturnType(expression, context, functionDescriptor, expectedReturnType); @@ -193,8 +193,8 @@ public class FunctionsTypingVisitor(facade: ExpressionTypingInternals) : Express expression: KtFunctionLiteralExpression, context: ExpressionTypingContext, functionDescriptor: SimpleFunctionDescriptorImpl, - expectedReturnType: KtType? - ): KtType? { + expectedReturnType: KotlinType? + ): KotlinType? { val functionLiteral = expression.getFunctionLiteral() val expectedType = expectedReturnType ?: NO_EXPECTED_TYPE @@ -212,9 +212,9 @@ public class FunctionsTypingVisitor(facade: ExpressionTypingInternals) : Express private fun computeReturnTypeBasedOnReturnExpressions( functionLiteral: KtFunctionLiteral, context: ExpressionTypingContext, - typeOfBodyExpression: KtType? - ): KtType? { - val returnedExpressionTypes = Lists.newArrayList() + typeOfBodyExpression: KotlinType? + ): KotlinType? { + val returnedExpressionTypes = Lists.newArrayList() var hasEmptyReturn = false val returnExpressions = collectReturns(functionLiteral, context.trace) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/JetTypeInfo.kt b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/JetTypeInfo.kt index db89f14fd11..7ea8cfdcbd8 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/JetTypeInfo.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/JetTypeInfo.kt @@ -17,7 +17,7 @@ package org.jetbrains.kotlin.types.expressions import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType /** * Stores simultaneously type of current expression together with data flow info @@ -31,7 +31,7 @@ import org.jetbrains.kotlin.types.KtType * Both break and continue are counted as possible jump outside of a loop, but return is not. */ /*package*/ open class JetTypeInfo( - val type: KtType?, + val type: KotlinType?, val dataFlowInfo: DataFlowInfo, val jumpOutPossible: Boolean = false, val jumpFlowInfo: DataFlowInfo = dataFlowInfo @@ -40,7 +40,7 @@ import org.jetbrains.kotlin.types.KtType fun clearType() = replaceType(null) // NB: do not compare type with this.type because this comparison is complex and unstabld - fun replaceType(type: KtType?) = JetTypeInfo(type, dataFlowInfo, jumpOutPossible, jumpFlowInfo) + fun replaceType(type: KotlinType?) = JetTypeInfo(type, dataFlowInfo, jumpOutPossible, jumpFlowInfo) fun replaceJumpOutPossible(jumpOutPossible: Boolean) = if (jumpOutPossible == this.jumpOutPossible) this else JetTypeInfo(type, dataFlowInfo, jumpOutPossible, jumpFlowInfo) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/MultiDeclarationResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/MultiDeclarationResolver.kt index f7b4878f389..85fa193915d 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/MultiDeclarationResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/MultiDeclarationResolver.kt @@ -29,7 +29,7 @@ import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue import org.jetbrains.kotlin.resolve.scopes.utils.getLocalVariable import org.jetbrains.kotlin.resolve.validation.SymbolUsageValidator import org.jetbrains.kotlin.types.ErrorUtils -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeUtils import org.jetbrains.kotlin.types.checker.KotlinTypeChecker @@ -52,7 +52,7 @@ public class MultiDeclarationResolver( val expectedType = getExpectedTypeForComponent(context, entry) val results = fakeCallResolver.resolveFakeCall(context.replaceExpectedType(expectedType), receiver, componentName, entry) - var componentType: KtType? = null + var componentType: KotlinType? = null if (results.isSuccess()) { context.trace.record(BindingContext.COMPONENT_RESOLVED_CALL, entry, results.getResultingCall()) @@ -82,7 +82,7 @@ public class MultiDeclarationResolver( } } - private fun getExpectedTypeForComponent(context: ExpressionTypingContext, entry: KtMultiDeclarationEntry): KtType { + private fun getExpectedTypeForComponent(context: ExpressionTypingContext, entry: KtMultiDeclarationEntry): KotlinType { val entryTypeRef = entry.getTypeReference() ?: return TypeUtils.NO_EXPECTED_TYPE return typeResolver.resolveType(context.scope, entryTypeRef, context.trace, true) } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/PatternMatchingTypingVisitor.java b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/PatternMatchingTypingVisitor.java index 846078647e3..55c5d8e2e15 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/PatternMatchingTypingVisitor.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/PatternMatchingTypingVisitor.java @@ -59,7 +59,7 @@ public class PatternMatchingTypingVisitor extends ExpressionTypingVisitor { .replaceContextDependency(INDEPENDENT); KtExpression leftHandSide = expression.getLeftHandSide(); JetTypeInfo typeInfo = facade.safeGetTypeInfo(leftHandSide, context.replaceScope(context.scope)); - KtType knownType = typeInfo.getType(); + KotlinType knownType = typeInfo.getType(); if (expression.getTypeReference() != null) { DataFlowValue dataFlowValue = DataFlowValueFactory.createDataFlowValue(leftHandSide, knownType, context); DataFlowInfo conditionInfo = checkTypeForIs(context, knownType, expression.getTypeReference(), dataFlowValue).thenInfo; @@ -81,7 +81,7 @@ public class PatternMatchingTypingVisitor extends ExpressionTypingVisitor { // TODO :change scope according to the bound value in the when header KtExpression subjectExpression = expression.getSubjectExpression(); - KtType subjectType; + KotlinType subjectType; boolean loopBreakContinuePossible = false; if (subjectExpression == null) { subjectType = ErrorUtils.createErrorType("Unknown type"); @@ -103,7 +103,7 @@ public class PatternMatchingTypingVisitor extends ExpressionTypingVisitor { // TODO : exhaustive patterns - Set expressionTypes = Sets.newHashSet(); + Set expressionTypes = Sets.newHashSet(); DataFlowInfo commonDataFlowInfo = null; DataFlowInfo elseDataFlowInfo = context.dataFlowInfo; for (KtWhenEntry whenEntry : expression.getEntries()) { @@ -120,7 +120,7 @@ public class PatternMatchingTypingVisitor extends ExpressionTypingVisitor { JetTypeInfo typeInfo = components.expressionTypingServices.getBlockReturnedTypeWithWritableScope( scopeToExtend, Collections.singletonList(bodyExpression), coercionStrategy, newContext); loopBreakContinuePossible |= typeInfo.getJumpOutPossible(); - KtType type = typeInfo.getType(); + KotlinType type = typeInfo.getType(); if (type != null) { expressionTypes.add(type); } @@ -157,7 +157,7 @@ public class PatternMatchingTypingVisitor extends ExpressionTypingVisitor { @NotNull KtWhenEntry whenEntry, @NotNull ExpressionTypingContext context, @Nullable KtExpression subjectExpression, - @NotNull KtType subjectType, + @NotNull KotlinType subjectType, @NotNull DataFlowValue subjectDataFlowValue ) { if (whenEntry.isElse()) { @@ -182,7 +182,7 @@ public class PatternMatchingTypingVisitor extends ExpressionTypingVisitor { private DataFlowInfos checkWhenCondition( @Nullable final KtExpression subjectExpression, - final KtType subjectType, + final KotlinType subjectType, KtWhenCondition condition, final ExpressionTypingContext context, final DataFlowValue subjectDataFlowValue @@ -204,7 +204,7 @@ public class PatternMatchingTypingVisitor extends ExpressionTypingVisitor { argumentForSubject, rangeExpression, context); DataFlowInfo dataFlowInfo = typeInfo.getDataFlowInfo(); newDataFlowInfo.set(new DataFlowInfos(dataFlowInfo, dataFlowInfo)); - KtType type = typeInfo.getType(); + KotlinType type = typeInfo.getType(); if (type == null || !isBoolean(type)) { context.trace.report(TYPE_MISMATCH_IN_RANGE.on(condition)); } @@ -260,7 +260,7 @@ public class PatternMatchingTypingVisitor extends ExpressionTypingVisitor { private DataFlowInfos checkTypeForExpressionCondition( ExpressionTypingContext context, KtExpression expression, - KtType subjectType, + KotlinType subjectType, boolean conditionExpected, DataFlowValue subjectDataFlowValue ) { @@ -268,13 +268,13 @@ public class PatternMatchingTypingVisitor extends ExpressionTypingVisitor { return noChange(context); } JetTypeInfo typeInfo = facade.getTypeInfo(expression, context); - KtType type = typeInfo.getType(); + KotlinType type = typeInfo.getType(); if (type == null) { return noChange(context); } context = context.replaceDataFlowInfo(typeInfo.getDataFlowInfo()); if (conditionExpected) { - KtType booleanType = components.builtIns.getBooleanType(); + KotlinType booleanType = components.builtIns.getBooleanType(); if (!KotlinTypeChecker.DEFAULT.equalTypes(booleanType, type)) { context.trace.report(TYPE_MISMATCH_IN_CONDITION.on(expression, type)); } @@ -298,7 +298,7 @@ public class PatternMatchingTypingVisitor extends ExpressionTypingVisitor { private DataFlowInfos checkTypeForIs( ExpressionTypingContext context, - KtType subjectType, + KotlinType subjectType, KtTypeReference typeReferenceAfterIs, DataFlowValue subjectDataFlowValue ) { @@ -307,7 +307,7 @@ public class PatternMatchingTypingVisitor extends ExpressionTypingVisitor { } TypeResolutionContext typeResolutionContext = new TypeResolutionContext(context.scope, context.trace, true, /*allowBareTypes=*/ true); PossiblyBareType possiblyBareTarget = components.typeResolver.resolvePossiblyBareType(typeResolutionContext, typeReferenceAfterIs); - KtType targetType = TypeReconstructionUtil.reconstructBareType(typeReferenceAfterIs, possiblyBareTarget, subjectType, context.trace, components.builtIns); + KotlinType targetType = TypeReconstructionUtil.reconstructBareType(typeReferenceAfterIs, possiblyBareTarget, subjectType, context.trace, components.builtIns); if (DynamicTypesKt.isDynamic(targetType)) { context.trace.report(DYNAMIC_NOT_ALLOWED.on(typeReferenceAfterIs)); @@ -339,8 +339,8 @@ public class PatternMatchingTypingVisitor extends ExpressionTypingVisitor { */ private void checkTypeCompatibility( @NotNull ExpressionTypingContext context, - @Nullable KtType type, - @NotNull KtType subjectType, + @Nullable KotlinType type, + @NotNull KotlinType subjectType, @NotNull KtElement reportErrorOn ) { // TODO : Take smart casts into account? diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/SenselessComparisonChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/SenselessComparisonChecker.kt index 11392a3df75..3e782865f2a 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/SenselessComparisonChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/SenselessComparisonChecker.kt @@ -18,7 +18,7 @@ package org.jetbrains.kotlin.types.expressions import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory -import org.jetbrains.kotlin.types.KtType +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 @@ -32,7 +32,7 @@ object SenselessComparisonChecker { left: KtExpression, right: KtExpression, context: ResolutionContext<*>, - getType: (KtExpression) -> KtType?, + getType: (KtExpression) -> KotlinType?, getNullability: (DataFlowValue) -> Nullability ) { val expr = diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/TypeInfoFactory.kt b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/TypeInfoFactory.kt index ecec1bb1ed5..e8db85a54ed 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/TypeInfoFactory.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/TypeInfoFactory.kt @@ -19,7 +19,7 @@ package org.jetbrains.kotlin.types.expressions.typeInfoFactory import org.jetbrains.kotlin.psi.KtExpression import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.expressions.DataFlowAnalyzer import org.jetbrains.kotlin.types.expressions.JetTypeInfo @@ -27,14 +27,14 @@ import org.jetbrains.kotlin.types.expressions.JetTypeInfo * Functions in this file are intended to create type info instances in different circumstances */ -public fun createTypeInfo(type: KtType?, dataFlowInfo: DataFlowInfo): JetTypeInfo = JetTypeInfo(type, dataFlowInfo) +public fun createTypeInfo(type: KotlinType?, dataFlowInfo: DataFlowInfo): JetTypeInfo = JetTypeInfo(type, dataFlowInfo) -public fun createTypeInfo(type: KtType?, dataFlowInfo: DataFlowInfo, jumpPossible: Boolean, jumpFlowInfo: DataFlowInfo): JetTypeInfo = +public fun createTypeInfo(type: KotlinType?, dataFlowInfo: DataFlowInfo, jumpPossible: Boolean, jumpFlowInfo: DataFlowInfo): JetTypeInfo = JetTypeInfo(type, dataFlowInfo, jumpPossible, jumpFlowInfo) -public fun createTypeInfo(type: KtType?): JetTypeInfo = createTypeInfo(type, DataFlowInfo.EMPTY) +public fun createTypeInfo(type: KotlinType?): JetTypeInfo = createTypeInfo(type, DataFlowInfo.EMPTY) -public fun createTypeInfo(type: KtType?, context: ResolutionContext<*>): JetTypeInfo = createTypeInfo(type, context.dataFlowInfo) +public fun createTypeInfo(type: KotlinType?, context: ResolutionContext<*>): JetTypeInfo = createTypeInfo(type, context.dataFlowInfo) public fun noTypeInfo(dataFlowInfo: DataFlowInfo): JetTypeInfo = createTypeInfo(null, dataFlowInfo) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/TypeReconstructionUtil.java b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/TypeReconstructionUtil.java index d3727596eeb..0ecce6ff460 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/TypeReconstructionUtil.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/TypeReconstructionUtil.java @@ -25,7 +25,7 @@ import org.jetbrains.kotlin.resolve.BindingContext; import org.jetbrains.kotlin.resolve.BindingTrace; import org.jetbrains.kotlin.resolve.PossiblyBareType; import org.jetbrains.kotlin.types.ErrorUtils; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.TypeConstructor; import org.jetbrains.kotlin.types.TypeReconstructionResult; @@ -33,10 +33,10 @@ import static org.jetbrains.kotlin.diagnostics.Errors.NO_TYPE_ARGUMENTS_ON_RHS; public class TypeReconstructionUtil { @NotNull - public static KtType reconstructBareType( + public static KotlinType reconstructBareType( @NotNull KtTypeReference right, @NotNull PossiblyBareType possiblyBareTarget, - @Nullable KtType subjectType, + @Nullable KotlinType subjectType, @NotNull BindingTrace trace, @NotNull KotlinBuiltIns builtIns ) { @@ -52,7 +52,7 @@ public class TypeReconstructionUtil { allStarProjectionsString(typeConstructor))); } - KtType targetType = reconstructionResult.getResultingType(); + KotlinType targetType = reconstructionResult.getResultingType(); if (targetType != null) { if (possiblyBareTarget.isBare()) { trace.record(BindingContext.TYPE, right, targetType); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/unqualifiedSuper/unqualifiedSuper.kt b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/unqualifiedSuper/unqualifiedSuper.kt index 9fdc9f4b3c7..a06af73da4f 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/unqualifiedSuper/unqualifiedSuper.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/unqualifiedSuper/unqualifiedSuper.kt @@ -29,16 +29,16 @@ import org.jetbrains.kotlin.psi.KtCallExpression import org.jetbrains.kotlin.psi.KtDotQualifiedExpression import org.jetbrains.kotlin.psi.KtSimpleNameExpression import org.jetbrains.kotlin.psi.KtSuperExpression -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeUtils import org.jetbrains.kotlin.utils.addToStdlib.singletonList public fun resolveUnqualifiedSuperFromExpressionContext( superExpression: KtSuperExpression, - supertypes: Collection, - anyType: KtType -): Collection { + supertypes: Collection, + anyType: KotlinType +): Collection { val parentElement = superExpression.parent if (parentElement is KtDotQualifiedExpression) { @@ -74,7 +74,7 @@ private val ARITY_OF_METHODS_OF_ANY = hashMapOf("hashCode" to 0, "equals" to 1, private fun isCallingMethodOfAny(callExpression: KtCallExpression, calleeName: Name): Boolean = ARITY_OF_METHODS_OF_ANY.getOrElse(calleeName.asString(), { -1 }) == callExpression.valueArguments.size() -public fun isPossiblyAmbiguousUnqualifiedSuper(superExpression: KtSuperExpression, supertypes: Collection): Boolean = +public fun isPossiblyAmbiguousUnqualifiedSuper(superExpression: KtSuperExpression, supertypes: Collection): Boolean = supertypes.size() > 1 || (supertypes.size() == 1 && supertypes.single().isInterface() && isCallingMethodOfAnyWithSuper(superExpression)) @@ -94,10 +94,10 @@ private fun isCallingMethodOfAnyWithSuper(superExpression: KtSuperExpression): B return false } -private fun KtType.isInterface(): Boolean = +private fun KotlinType.isInterface(): Boolean = TypeUtils.getClassDescriptor(this)?.kind == ClassKind.INTERFACE -private fun resolveSupertypesForMethodOfAny(supertypes: Collection, calleeName: Name, location: LookupLocation, anyType: KtType): Collection { +private fun resolveSupertypesForMethodOfAny(supertypes: Collection, calleeName: Name, location: LookupLocation, anyType: KotlinType): Collection { val typesWithConcreteOverride = resolveSupertypesByMembers(supertypes, false) { getFunctionMembers(it, calleeName, location) } return if (typesWithConcreteOverride.isNotEmpty()) typesWithConcreteOverride @@ -105,19 +105,19 @@ private fun resolveSupertypesForMethodOfAny(supertypes: Collection, call anyType.singletonList() } -private fun resolveSupertypesByCalleeName(supertypes: Collection, calleeName: Name, location: LookupLocation): Collection = +private fun resolveSupertypesByCalleeName(supertypes: Collection, calleeName: Name, location: LookupLocation): Collection = resolveSupertypesByMembers(supertypes, true) { getFunctionMembers(it, calleeName, location) + getPropertyMembers(it, calleeName, location) } -private fun resolveSupertypesByPropertyName(supertypes: Collection, propertyName: Name, location: LookupLocation): Collection = +private fun resolveSupertypesByPropertyName(supertypes: Collection, propertyName: Name, location: LookupLocation): Collection = resolveSupertypesByMembers(supertypes, true) { getPropertyMembers(it, propertyName, location) } private inline fun resolveSupertypesByMembers( - supertypes: Collection, + supertypes: Collection, allowArbitraryMembers: Boolean, - getMembers: (KtType) -> Collection -): Collection { - val typesWithConcreteMembers = SmartList() - val typesWithArbitraryMembers = SmartList() + getMembers: (KotlinType) -> Collection +): Collection { + val typesWithConcreteMembers = SmartList() + val typesWithArbitraryMembers = SmartList() for (supertype in supertypes) { val members = getMembers(supertype) @@ -131,16 +131,16 @@ private inline fun resolveSupertypesByMembers( return if (typesWithConcreteMembers.isNotEmpty()) typesWithConcreteMembers else if (allowArbitraryMembers) typesWithArbitraryMembers - else emptyList() + else emptyList() } -private fun getFunctionMembers(type: KtType, name: Name, location: LookupLocation): Collection = +private fun getFunctionMembers(type: KotlinType, name: Name, location: LookupLocation): Collection = type.memberScope.getFunctions(name, location) -private fun getPropertyMembers(type: KtType, name: Name, location: LookupLocation): Collection = +private fun getPropertyMembers(type: KotlinType, name: Name, location: LookupLocation): Collection = type.memberScope.getProperties(name, location).filterIsInstanceTo(SmartList()) -private fun isConcreteMember(supertype: KtType, memberDescriptor: MemberDescriptor): Boolean { +private fun isConcreteMember(supertype: KotlinType, memberDescriptor: MemberDescriptor): Boolean { // "Concrete member" is a function or a property that is not abstract, // and is not an implicit fake override for a method of Any on an interface. diff --git a/compiler/light-classes/src/org/jetbrains/kotlin/asJava/KotlinLightClassForAnonymousDeclaration.java b/compiler/light-classes/src/org/jetbrains/kotlin/asJava/KotlinLightClassForAnonymousDeclaration.java index 5561df751a4..55df4405ad4 100644 --- a/compiler/light-classes/src/org/jetbrains/kotlin/asJava/KotlinLightClassForAnonymousDeclaration.java +++ b/compiler/light-classes/src/org/jetbrains/kotlin/asJava/KotlinLightClassForAnonymousDeclaration.java @@ -28,7 +28,7 @@ import org.jetbrains.kotlin.descriptors.DeclarationDescriptor; import org.jetbrains.kotlin.name.FqName; import org.jetbrains.kotlin.psi.KtClassOrObject; import org.jetbrains.kotlin.resolve.DescriptorUtils; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import java.util.Collection; @@ -52,11 +52,11 @@ class KotlinLightClassForAnonymousDeclaration extends KotlinLightClassForExplici ClassDescriptor descriptor = getDescriptor(); if (descriptor == null) return CommonClassNames.JAVA_LANG_OBJECT; - Collection superTypes = descriptor.getTypeConstructor().getSupertypes(); + Collection superTypes = descriptor.getTypeConstructor().getSupertypes(); if (superTypes.isEmpty()) return CommonClassNames.JAVA_LANG_OBJECT; - KtType superType = superTypes.iterator().next(); + KotlinType superType = superTypes.iterator().next(); DeclarationDescriptor superClassDescriptor = superType.getConstructor().getDeclarationDescriptor(); if (superClassDescriptor == null) { diff --git a/compiler/serialization/src/org/jetbrains/kotlin/serialization/DescriptorSerializer.java b/compiler/serialization/src/org/jetbrains/kotlin/serialization/DescriptorSerializer.java index 01ad515263f..f1988fe8bc5 100644 --- a/compiler/serialization/src/org/jetbrains/kotlin/serialization/DescriptorSerializer.java +++ b/compiler/serialization/src/org/jetbrains/kotlin/serialization/DescriptorSerializer.java @@ -139,7 +139,7 @@ public class DescriptorSerializer { if (!KotlinBuiltIns.isSpecialClassWithNoSupertypes(classDescriptor)) { // Special classes (Any, Nothing) have no supertypes - for (KtType supertype : classDescriptor.getTypeConstructor().getSupertypes()) { + for (KotlinType supertype : classDescriptor.getTypeConstructor().getSupertypes()) { if (useTypeTable()) { builder.addSupertypeId(typeId(supertype)); } @@ -382,7 +382,7 @@ public class DescriptorSerializer { builder.setType(type(descriptor.getType())); } - KtType varargElementType = descriptor.getVarargElementType(); + KotlinType varargElementType = descriptor.getVarargElementType(); if (varargElementType != null) { if (useTypeTable()) { builder.setVarargElementTypeId(typeId(varargElementType)); @@ -414,10 +414,10 @@ public class DescriptorSerializer { } extension.serializeTypeParameter(typeParameter, builder); - Set upperBounds = typeParameter.getUpperBounds(); + Set upperBounds = typeParameter.getUpperBounds(); if (upperBounds.size() == 1 && KotlinBuiltIns.isDefaultBound(CollectionsKt.single(upperBounds))) return builder; - for (KtType upperBound : upperBounds) { + for (KotlinType upperBound : upperBounds) { if (useTypeTable()) { builder.addUpperBoundId(typeId(upperBound)); } @@ -441,12 +441,12 @@ public class DescriptorSerializer { throw new IllegalStateException("Unknown variance: " + variance); } - private int typeId(@NotNull KtType type) { + private int typeId(@NotNull KotlinType type) { return typeTable.get(type(type)); } @NotNull - private ProtoBuf.Type.Builder type(@NotNull KtType type) { + private ProtoBuf.Type.Builder type(@NotNull KotlinType type) { assert !type.isError() : "Can't serialize error types: " + type; // TODO if (FlexibleTypesKt.isFlexible(type)) { diff --git a/compiler/serialization/src/org/jetbrains/kotlin/serialization/SerializerExtension.java b/compiler/serialization/src/org/jetbrains/kotlin/serialization/SerializerExtension.java index 5b6a7bcb15d..29f4743e46e 100644 --- a/compiler/serialization/src/org/jetbrains/kotlin/serialization/SerializerExtension.java +++ b/compiler/serialization/src/org/jetbrains/kotlin/serialization/SerializerExtension.java @@ -18,7 +18,7 @@ package org.jetbrains.kotlin.serialization; import org.jetbrains.annotations.NotNull; import org.jetbrains.kotlin.descriptors.*; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import java.util.Collection; @@ -48,7 +48,7 @@ public abstract class SerializerExtension { public void serializeValueParameter(@NotNull ValueParameterDescriptor descriptor, @NotNull ProtoBuf.ValueParameter.Builder proto) { } - public void serializeType(@NotNull KtType type, @NotNull ProtoBuf.Type.Builder proto) { + public void serializeType(@NotNull KotlinType type, @NotNull ProtoBuf.Type.Builder proto) { } public void serializeTypeParameter(@NotNull TypeParameterDescriptor typeParameter, @NotNull ProtoBuf.TypeParameter.Builder proto) { diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/LazyOperationsLog.kt b/compiler/tests/org/jetbrains/kotlin/checkers/LazyOperationsLog.kt index 6b22b5275bb..37234e71e6b 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/LazyOperationsLog.kt +++ b/compiler/tests/org/jetbrains/kotlin/checkers/LazyOperationsLog.kt @@ -32,8 +32,8 @@ import org.jetbrains.kotlin.resolve.scopes.KtScope import org.jetbrains.kotlin.serialization.ProtoBuf import org.jetbrains.kotlin.serialization.deserialization.DeserializationContext import org.jetbrains.kotlin.serialization.deserialization.TypeDeserializer -import org.jetbrains.kotlin.types.KtType -import org.jetbrains.kotlin.types.KtTypeImpl +import org.jetbrains.kotlin.types.KotlinType +import org.jetbrains.kotlin.types.KotlinTypeImpl import org.jetbrains.kotlin.utils.Printer import java.lang.reflect.Constructor import java.lang.reflect.GenericDeclaration @@ -159,7 +159,7 @@ class LazyOperationsLog( val text = when { typeProto.hasClassName() -> context.nameResolver.getClassId(typeProto.className).asSingleFqName().asString() typeProto.hasTypeParameter() -> { - val classifier = (o as KtType).constructor.declarationDescriptor!! + val classifier = (o as KotlinType).constructor.declarationDescriptor!! "" + classifier.name + " in " + DescriptorUtils.getFqName(classifier.containingDeclaration) } else -> "???" @@ -183,7 +183,7 @@ class LazyOperationsLog( sb.append(" }") } } - o is KtTypeImpl -> { + o is KotlinTypeImpl -> { StringBuilder { append(o.getConstructor()) if (!o.getArguments().isEmpty()) { diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/CodegenTestFiles.java b/compiler/tests/org/jetbrains/kotlin/codegen/CodegenTestFiles.java index 40100051ec6..6ec066b0c76 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/CodegenTestFiles.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/CodegenTestFiles.java @@ -31,7 +31,7 @@ import org.jetbrains.kotlin.resolve.AnalyzerScriptParameter; import org.jetbrains.kotlin.resolve.AnalyzingUtils; import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform; import org.jetbrains.kotlin.test.JetTestUtils; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.Variance; import java.io.IOException; @@ -131,7 +131,7 @@ public class CodegenTestFiles { String valueString = scriptParametersMatcher.group(3); Object value; - KtType jetType; + KotlinType jetType; KotlinBuiltIns builtIns = JvmPlatform.INSTANCE$.getBuiltIns(); if (type.equals("kotlin.String")) { value = valueString; diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/TestlibTest.java b/compiler/tests/org/jetbrains/kotlin/codegen/TestlibTest.java index 9cd781f1184..9ca76cbe745 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/TestlibTest.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/TestlibTest.java @@ -42,7 +42,7 @@ import org.jetbrains.kotlin.resolve.BindingContextUtils; import org.jetbrains.kotlin.test.ConfigurationKind; import org.jetbrains.kotlin.test.JetTestUtils; import org.jetbrains.kotlin.test.TestJdkKind; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import java.io.File; import java.lang.reflect.Modifier; @@ -121,7 +121,7 @@ public class TestlibTest extends UsefulTestCase { BindingContext.DECLARATION_TO_DESCRIPTOR, declaration); - for (KtType superType : getAllSupertypes(descriptor.getDefaultType())) { + for (KotlinType superType : getAllSupertypes(descriptor.getDefaultType())) { if (!"junit/framework/Test".equals(typeMapper.mapType(superType).getInternalName())) continue; String name = typeMapper.mapClass(descriptor).getInternalName(); diff --git a/compiler/tests/org/jetbrains/kotlin/resolve/ExpectedResolveData.java b/compiler/tests/org/jetbrains/kotlin/resolve/ExpectedResolveData.java index 72d8cb34111..88cb0b71adb 100644 --- a/compiler/tests/org/jetbrains/kotlin/resolve/ExpectedResolveData.java +++ b/compiler/tests/org/jetbrains/kotlin/resolve/ExpectedResolveData.java @@ -38,7 +38,7 @@ import org.jetbrains.kotlin.renderer.DescriptorRenderer; import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform; import org.jetbrains.kotlin.resolve.lazy.JvmResolveUtil; import org.jetbrains.kotlin.types.ErrorUtils; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.TypeConstructor; import java.util.List; @@ -244,7 +244,7 @@ public abstract class ExpectedResolveData { continue; } - KtType actualType = bindingContext.get(BindingContext.TYPE, typeReference); + KotlinType actualType = bindingContext.get(BindingContext.TYPE, typeReference); assertNotNull("Type " + name + " not resolved for reference " + name, actualType); ClassifierDescriptor expectedClass = builtIns.getBuiltInClassByName(Name.identifier(name.substring(STANDARD_PREFIX.length()))); assertNotNull("Expected class not found: " + name); @@ -299,7 +299,7 @@ public abstract class ExpectedResolveData { PsiElement element = position.getElement(); KtExpression expression = getAncestorOfType(KtExpression.class, element); - KtType expressionType = bindingContext.getType(expression); + KotlinType expressionType = bindingContext.getType(expression); TypeConstructor expectedTypeConstructor; if (typeName.startsWith(STANDARD_PREFIX)) { String name = typeName.substring(STANDARD_PREFIX.length()); diff --git a/compiler/tests/org/jetbrains/kotlin/resolve/JetExpectedResolveDataUtil.java b/compiler/tests/org/jetbrains/kotlin/resolve/JetExpectedResolveDataUtil.java index 1b23ce3cf9e..3267671dcc5 100644 --- a/compiler/tests/org/jetbrains/kotlin/resolve/JetExpectedResolveDataUtil.java +++ b/compiler/tests/org/jetbrains/kotlin/resolve/JetExpectedResolveDataUtil.java @@ -37,7 +37,7 @@ import org.jetbrains.kotlin.resolve.scopes.utils.ScopeUtilsKt; import org.jetbrains.kotlin.test.JetTestUtils; import org.jetbrains.kotlin.tests.di.ContainerForTests; import org.jetbrains.kotlin.tests.di.InjectionKt; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.TypeUtils; import org.jetbrains.kotlin.types.expressions.ExpressionTypingContext; @@ -129,7 +129,7 @@ public class JetExpectedResolveDataUtil { ClassDescriptor classDescriptor, String name, Project project, - KtType... parameterTypes + KotlinType... parameterTypes ) { ModuleDescriptorImpl emptyModule = JetTestUtils.createEmptyModule(); ContainerForTests container = InjectionKt.createContainerForTests(project, emptyModule); diff --git a/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/AbstractConstraintSystemTest.kt b/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/AbstractConstraintSystemTest.kt index 8ce82aa77d7..7b6b840c237 100644 --- a/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/AbstractConstraintSystemTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/AbstractConstraintSystemTest.kt @@ -30,7 +30,7 @@ import org.jetbrains.kotlin.test.JetLiteFixture import org.jetbrains.kotlin.test.JetTestUtils import org.jetbrains.kotlin.tests.di.createContainerForTests import org.jetbrains.kotlin.types.ErrorUtils -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.Variance import java.io.File import java.util.ArrayList @@ -86,7 +86,7 @@ abstract public class AbstractConstraintSystemTest() : JetLiteFixture() { constraintSystem.registerTypeVariables(typeParameterDescriptors, { Variance.INVARIANT }) val constraints = parseConstraints(constraintsFileText) - fun KtType.assertNotError(): KtType { + fun KotlinType.assertNotError(): KotlinType { assert(!ErrorUtils.containsErrorType(this)) { "Type $this is resolved to or contains error type" } return this } diff --git a/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/ConstraintSystemTestData.kt b/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/ConstraintSystemTestData.kt index b3ffefd2b63..ca0e0c624f0 100644 --- a/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/ConstraintSystemTestData.kt +++ b/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/ConstraintSystemTestData.kt @@ -30,8 +30,8 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns import org.jetbrains.kotlin.resolve.scopes.KtScope import org.jetbrains.kotlin.resolve.scopes.LexicalScope import org.jetbrains.kotlin.test.JetTestUtils -import org.jetbrains.kotlin.types.KtType -import org.jetbrains.kotlin.types.KtTypeImpl +import org.jetbrains.kotlin.types.KotlinType +import org.jetbrains.kotlin.types.KotlinTypeImpl import java.util.regex.Pattern public class ConstraintSystemTestData( @@ -60,11 +60,11 @@ public class ConstraintSystemTestData( throw AssertionError("Unsupported type parameter name: $name. You may add it to constraintSystem/declarations.kt") } - fun getType(name: String): KtType { + fun getType(name: String): KotlinType { val matcher = INTEGER_VALUE_TYPE_PATTERN.matcher(name) if (matcher.find()) { val number = matcher.group(1)!! - return KtTypeImpl.create( + return KotlinTypeImpl.create( Annotations.EMPTY, IntegerValueTypeConstructor(number.toLong(), functionFoo.builtIns), false, listOf(), KtScope.Empty ) diff --git a/compiler/tests/org/jetbrains/kotlin/test/JetTestUtils.java b/compiler/tests/org/jetbrains/kotlin/test/JetTestUtils.java index 8b41cc34f06..fa5c0b7e014 100644 --- a/compiler/tests/org/jetbrains/kotlin/test/JetTestUtils.java +++ b/compiler/tests/org/jetbrains/kotlin/test/JetTestUtils.java @@ -74,7 +74,7 @@ import org.jetbrains.kotlin.resolve.lazy.JvmResolveUtil; import org.jetbrains.kotlin.resolve.lazy.LazyResolveTestUtil; import org.jetbrains.kotlin.storage.LockBasedStorageManager; import org.jetbrains.kotlin.test.util.JetTestUtilsKt; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.expressions.JetTypeInfo; import org.jetbrains.kotlin.util.slicedMap.ReadOnlySlice; import org.jetbrains.kotlin.util.slicedMap.SlicedMap; @@ -148,7 +148,7 @@ public class JetTestUtils { @Nullable @Override - public KtType getType(@NotNull KtExpression expression) { + public KotlinType getType(@NotNull KtExpression expression) { return DUMMY_TRACE.getType(expression); } @@ -183,13 +183,13 @@ public class JetTestUtils { @Nullable @Override - public KtType getType(@NotNull KtExpression expression) { + public KotlinType getType(@NotNull KtExpression expression) { JetTypeInfo typeInfo = get(BindingContext.EXPRESSION_TYPE_INFO, expression); return typeInfo != null ? typeInfo.getType() : null; } @Override - public void recordType(@NotNull KtExpression expression, @Nullable KtType type) { + public void recordType(@NotNull KtExpression expression, @Nullable KotlinType type) { } @Override @@ -231,7 +231,7 @@ public class JetTestUtils { @Nullable @Override - public KtType getType(@NotNull KtExpression expression) { + public KotlinType getType(@NotNull KtExpression expression) { return DUMMY_EXCEPTION_ON_ERROR_TRACE.getType(expression); } @@ -264,12 +264,12 @@ public class JetTestUtils { @Nullable @Override - public KtType getType(@NotNull KtExpression expression) { + public KotlinType getType(@NotNull KtExpression expression) { return null; } @Override - public void recordType(@NotNull KtExpression expression, @Nullable KtType type) { + public void recordType(@NotNull KtExpression expression, @Nullable KotlinType type) { } @Override diff --git a/compiler/tests/org/jetbrains/kotlin/test/util/DescriptorValidator.java b/compiler/tests/org/jetbrains/kotlin/test/util/DescriptorValidator.java index fedb60fc0a5..cf75f4a080e 100644 --- a/compiler/tests/org/jetbrains/kotlin/test/util/DescriptorValidator.java +++ b/compiler/tests/org/jetbrains/kotlin/test/util/DescriptorValidator.java @@ -25,7 +25,7 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns; import org.jetbrains.kotlin.descriptors.*; import org.jetbrains.kotlin.incremental.components.NoLookupLocation; import org.jetbrains.kotlin.resolve.scopes.KtScope; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.junit.Assert; import java.io.PrintStream; @@ -93,7 +93,7 @@ public class DescriptorValidator { private void validateType( @NotNull DeclarationDescriptor descriptor, - @Nullable KtType type, + @Nullable KotlinType type, @NotNull DiagnosticCollector collector ) { if (type == null) { @@ -134,9 +134,9 @@ public class DescriptorValidator { private void validateTypes( DeclarationDescriptor descriptor, DiagnosticCollector collector, - Collection types + Collection types ) { - for (KtType type : types) { + for (KotlinType type : types) { validateType(descriptor, type, collector); } } @@ -163,8 +163,8 @@ public class DescriptorValidator { DeclarationDescriptor descriptor, DiagnosticCollector collector, String name, - KtType expected, - KtType actual + KotlinType expected, + KotlinType actual ) { if (expected.isError() && actual.isError()) { assertEquals(descriptor, collector, name, expected.toString(), actual.toString()); @@ -235,7 +235,7 @@ public class DescriptorValidator { ) { validateTypeParameters(collector, descriptor.getTypeConstructor().getParameters()); - Collection supertypes = descriptor.getTypeConstructor().getSupertypes(); + Collection supertypes = descriptor.getTypeConstructor().getSupertypes(); if (supertypes.isEmpty() && descriptor.getKind() != ClassKind.INTERFACE && !KotlinBuiltIns.isSpecialClassWithNoSupertypes(descriptor)) { report(collector, descriptor, "No supertypes for non-trait"); diff --git a/compiler/tests/org/jetbrains/kotlin/types/AbstractJetTypeBindingTest.kt b/compiler/tests/org/jetbrains/kotlin/types/AbstractJetTypeBindingTest.kt index fb3e1eec756..f96b95fabe0 100644 --- a/compiler/tests/org/jetbrains/kotlin/types/AbstractJetTypeBindingTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/types/AbstractJetTypeBindingTest.kt @@ -65,7 +65,7 @@ abstract class AbstractJetTypeBindingTest : JetLiteFixture() { } private class MyPrinter(out: StringBuilder) : Printer(out) { - private fun KtType.render() = DescriptorRenderer.SHORT_NAMES_IN_TYPES.renderType(this) + private fun KotlinType.render() = DescriptorRenderer.SHORT_NAMES_IN_TYPES.renderType(this) private fun TypeParameterDescriptor?.render() = if (this == null) "null" else DescriptorRenderer.SHORT_NAMES_IN_TYPES.render(this) fun print(argument: TypeArgumentBinding<*>?): MyPrinter { diff --git a/compiler/tests/org/jetbrains/kotlin/types/JetTypeCheckerTest.java b/compiler/tests/org/jetbrains/kotlin/types/JetTypeCheckerTest.java index ef16ff1faab..a47d79c7162 100644 --- a/compiler/tests/org/jetbrains/kotlin/types/JetTypeCheckerTest.java +++ b/compiler/tests/org/jetbrains/kotlin/types/JetTypeCheckerTest.java @@ -498,10 +498,10 @@ public class JetTypeCheckerTest extends JetLiteFixture { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void assertSupertypes(String typeStr, String... supertypeStrs) { - Set allSupertypes = TypeUtils.getAllSupertypes(makeType(scopeWithImports, typeStr)); - Set expected = Sets.newHashSet(); + Set allSupertypes = TypeUtils.getAllSupertypes(makeType(scopeWithImports, typeStr)); + Set expected = Sets.newHashSet(); for (String supertypeStr : supertypeStrs) { - KtType supertype = makeType(scopeWithImports, supertypeStr); + KotlinType supertype = makeType(scopeWithImports, supertypeStr); expected.add(supertype); } assertEquals(expected, allSupertypes); @@ -516,27 +516,27 @@ public class JetTypeCheckerTest extends JetLiteFixture { } private void assertIntersection(String expected, String... types) { - Set typesToIntersect = new LinkedHashSet(); + Set typesToIntersect = new LinkedHashSet(); for (String type : types) { typesToIntersect.add(makeType(type)); } - KtType result = TypeIntersector.intersectTypes(KotlinTypeChecker.DEFAULT, typesToIntersect); + KotlinType result = TypeIntersector.intersectTypes(KotlinTypeChecker.DEFAULT, typesToIntersect); // assertNotNull("Intersection is null for " + typesToIntersect, result); assertEquals(makeType(expected), result); } private void assertCommonSupertype(String expected, String... types) { - Collection subtypes = new ArrayList(); + Collection subtypes = new ArrayList(); for (String type : types) { subtypes.add(makeType(type)); } - KtType result = CommonSupertypes.commonSupertype(subtypes); + KotlinType result = CommonSupertypes.commonSupertype(subtypes); assertTrue(result + " != " + expected, result.equals(makeType(expected))); } private void assertSubtypingRelation(String subtype, String supertype, boolean expected) { - KtType typeNode1 = makeType(subtype); - KtType typeNode2 = makeType(supertype); + KotlinType typeNode1 = makeType(subtype); + KotlinType typeNode2 = makeType(supertype); boolean result = KotlinTypeChecker.DEFAULT.isSubtypeOf( typeNode1, typeNode2); @@ -544,22 +544,22 @@ public class JetTypeCheckerTest extends JetLiteFixture { assertTrue(typeNode1 + " is " + modifier + "a subtype of " + typeNode2, result == expected); } - private void assertType(String expression, KtType expectedType) { + private void assertType(String expression, KotlinType expectedType) { Project project = getProject(); KtExpression ktExpression = KtPsiFactoryKt.KtPsiFactory(project).createExpression(expression); - KtType type = expressionTypingServices.getType(ScopeUtilsKt.asLexicalScope(scopeWithImports), ktExpression, TypeUtils.NO_EXPECTED_TYPE, DataFlowInfo.EMPTY, JetTestUtils.DUMMY_TRACE); + KotlinType type = expressionTypingServices.getType(ScopeUtilsKt.asLexicalScope(scopeWithImports), ktExpression, TypeUtils.NO_EXPECTED_TYPE, DataFlowInfo.EMPTY, JetTestUtils.DUMMY_TRACE); assertTrue(type + " != " + expectedType, type.equals(expectedType)); } private void assertErrorType(String expression) { Project project = getProject(); KtExpression ktExpression = KtPsiFactoryKt.KtPsiFactory(project).createExpression(expression); - KtType type = expressionTypingServices.safeGetType(ScopeUtilsKt.asLexicalScope(scopeWithImports), ktExpression, TypeUtils.NO_EXPECTED_TYPE, DataFlowInfo.EMPTY, JetTestUtils.DUMMY_TRACE); + KotlinType type = expressionTypingServices.safeGetType(ScopeUtilsKt.asLexicalScope(scopeWithImports), ktExpression, TypeUtils.NO_EXPECTED_TYPE, DataFlowInfo.EMPTY, JetTestUtils.DUMMY_TRACE); assertTrue("Error type expected but " + type + " returned", type.isError()); } private void assertType(String contextType, final String expression, String expectedType) { - final KtType thisType = makeType(contextType); + final KotlinType thisType = makeType(contextType); KtScope scope = new AbstractScopeAdapter() { @NotNull @Override @@ -586,9 +586,9 @@ public class JetTypeCheckerTest extends JetLiteFixture { private void assertType(KtScope scope, String expression, String expectedTypeStr) { Project project = getProject(); KtExpression ktExpression = KtPsiFactoryKt.KtPsiFactory(project).createExpression(expression); - KtType type = expressionTypingServices.getType( + KotlinType type = expressionTypingServices.getType( ScopeUtilsKt.asLexicalScope(addImports(scope)), ktExpression, TypeUtils.NO_EXPECTED_TYPE, DataFlowInfo.EMPTY, new BindingTraceContext()); - KtType expectedType = expectedTypeStr == null ? null : makeType(expectedTypeStr); + KotlinType expectedType = expectedTypeStr == null ? null : makeType(expectedTypeStr); assertEquals(expectedType, type); } @@ -630,11 +630,11 @@ public class JetTypeCheckerTest extends JetLiteFixture { return new ChainedScope(scope.getContainingDeclaration(), "JetTypeCheckerTest.addImports scope with imports", scopeChain.toArray(new KtScope[scopeChain.size()])); } - private KtType makeType(String typeStr) { + private KotlinType makeType(String typeStr) { return makeType(scopeWithImports, typeStr); } - private KtType makeType(KtScope scope, String typeStr) { + private KotlinType makeType(KtScope scope, String typeStr) { return typeResolver.resolveType(ScopeUtilsKt.asLexicalScope(scope), KtPsiFactoryKt.KtPsiFactory(getProject()).createType(typeStr), JetTestUtils.DUMMY_TRACE, true); } } diff --git a/compiler/tests/org/jetbrains/kotlin/types/TypeSubstitutorTest.java b/compiler/tests/org/jetbrains/kotlin/types/TypeSubstitutorTest.java index b7fc4532175..ccb6198cdce 100644 --- a/compiler/tests/org/jetbrains/kotlin/types/TypeSubstitutorTest.java +++ b/compiler/tests/org/jetbrains/kotlin/types/TypeSubstitutorTest.java @@ -102,12 +102,12 @@ public class TypeSubstitutorTest extends KotlinTestWithEnvironment { } private void doTest(@Nullable String expectedTypeStr, String initialTypeStr, Pair... substitutionStrs) { - KtType initialType = resolveType(initialTypeStr); + KotlinType initialType = resolveType(initialTypeStr); Map map = stringsToSubstitutionMap(substitutionStrs); TypeSubstitutor substitutor = TypeSubstitutor.create(map); - KtType result = substitutor.substitute(initialType, Variance.INVARIANT); + KotlinType result = substitutor.substitute(initialType, Variance.INVARIANT); if (expectedTypeStr == null) { assertNull(result); @@ -129,7 +129,7 @@ public class TypeSubstitutorTest extends KotlinTestWithEnvironment { assertTrue(typeParameterName + " is not a type parameter: " + classifier, classifier instanceof TypeParameterDescriptor); String typeStr = "C<" + replacementProjectionString + ">"; - KtType typeWithArgument = resolveType(typeStr); + KotlinType typeWithArgument = resolveType(typeStr); assert !typeWithArgument.getArguments().isEmpty() : "No arguments: " + typeWithArgument + " from " + typeStr; map.put(classifier.getTypeConstructor(), typeWithArgument.getArguments().get(0)); @@ -137,11 +137,11 @@ public class TypeSubstitutorTest extends KotlinTestWithEnvironment { return map; } - private KtType resolveType(String typeStr) { + private KotlinType resolveType(String typeStr) { KtTypeReference jetTypeReference = KtPsiFactoryKt.KtPsiFactory(getProject()).createType(typeStr); AnalyzingUtils.checkForSyntacticErrors(jetTypeReference); BindingTrace trace = new BindingTraceContext(); - KtType type = container.getTypeResolver().resolveType(ScopeUtilsKt.asLexicalScope(scope), jetTypeReference, trace, true); + KotlinType type = container.getTypeResolver().resolveType(ScopeUtilsKt.asLexicalScope(scope), jetTypeReference, trace, true); if (!trace.getBindingContext().getDiagnostics().isEmpty()) { fail("Errors:\n" + StringUtil.join( trace.getBindingContext().getDiagnostics(), diff --git a/compiler/tests/org/jetbrains/kotlin/types/TypeUnifierTest.java b/compiler/tests/org/jetbrains/kotlin/types/TypeUnifierTest.java index b8682c1535f..b9374098556 100644 --- a/compiler/tests/org/jetbrains/kotlin/types/TypeUnifierTest.java +++ b/compiler/tests/org/jetbrains/kotlin/types/TypeUnifierTest.java @@ -213,7 +213,7 @@ public class TypeUnifierTest extends JetLiteFixture { KtTypeReference typeReference = projection.getTypeReference(); assert typeReference != null; - KtType type = typeResolver.resolveType(ScopeUtilsKt.asLexicalScope(withX), typeReference, JetTestUtils.DUMMY_TRACE, true); + KotlinType type = typeResolver.resolveType(ScopeUtilsKt.asLexicalScope(withX), typeReference, JetTestUtils.DUMMY_TRACE, true); return new TypeProjectionImpl(getProjectionKind(typeStr, projection), type); } diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/components/ExternalSignatureResolver.java b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/components/ExternalSignatureResolver.java index 60e9972313a..fda413f1171 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/components/ExternalSignatureResolver.java +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/components/ExternalSignatureResolver.java @@ -22,7 +22,7 @@ import org.jetbrains.kotlin.descriptors.*; import org.jetbrains.kotlin.load.java.structure.JavaField; import org.jetbrains.kotlin.load.java.structure.JavaMember; import org.jetbrains.kotlin.load.java.structure.JavaMethod; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import java.util.Collections; import java.util.List; @@ -34,8 +34,8 @@ public interface ExternalSignatureResolver { public PropagatedMethodSignature resolvePropagatedSignature( @NotNull JavaMethod method, @NotNull ClassDescriptor owner, - @NotNull KtType returnType, - @Nullable KtType receiverType, + @NotNull KotlinType returnType, + @Nullable KotlinType receiverType, @NotNull List valueParameters, @NotNull List typeParameters ) { @@ -50,8 +50,8 @@ public interface ExternalSignatureResolver { public AlternativeMethodSignature resolveAlternativeMethodSignature( @NotNull JavaMember methodOrConstructor, boolean hasSuperMethods, - @Nullable KtType returnType, - @Nullable KtType receiverType, + @Nullable KotlinType returnType, + @Nullable KotlinType receiverType, @NotNull List valueParameters, @NotNull List typeParameters, boolean hasStableParameterNames @@ -64,7 +64,7 @@ public interface ExternalSignatureResolver { @NotNull @Override public AlternativeFieldSignature resolveAlternativeFieldSignature( - @NotNull JavaField field, @NotNull KtType returnType, boolean isVar + @NotNull JavaField field, @NotNull KotlinType returnType, boolean isVar ) { return new AlternativeFieldSignature(returnType, null); } @@ -89,15 +89,15 @@ public interface ExternalSignatureResolver { } class AlternativeMethodSignature extends MemberSignature { - private final KtType returnType; - private final KtType receiverType; + private final KotlinType returnType; + private final KotlinType receiverType; private final List valueParameters; private final List typeParameters; private final boolean hasStableParameterNames; public AlternativeMethodSignature( - @Nullable KtType returnType, - @Nullable KtType receiverType, + @Nullable KotlinType returnType, + @Nullable KotlinType receiverType, @NotNull List valueParameters, @NotNull List typeParameters, @NotNull List signatureErrors, @@ -112,12 +112,12 @@ public interface ExternalSignatureResolver { } @Nullable - public KtType getReturnType() { + public KotlinType getReturnType() { return returnType; } @Nullable - public KtType getReceiverType() { + public KotlinType getReceiverType() { return receiverType; } @@ -137,15 +137,15 @@ public interface ExternalSignatureResolver { } class AlternativeFieldSignature extends MemberSignature { - private final KtType returnType; + private final KotlinType returnType; - public AlternativeFieldSignature(@NotNull KtType returnType, @Nullable String signatureError) { + public AlternativeFieldSignature(@NotNull KotlinType returnType, @Nullable String signatureError) { super(signatureError == null ? Collections.emptyList() : Collections.singletonList(signatureError)); this.returnType = returnType; } @NotNull - public KtType getReturnType() { + public KotlinType getReturnType() { return returnType; } } @@ -154,8 +154,8 @@ public interface ExternalSignatureResolver { private final List superMethods; public PropagatedMethodSignature( - @Nullable KtType returnType, - @Nullable KtType receiverType, + @Nullable KotlinType returnType, + @Nullable KotlinType receiverType, @NotNull List valueParameters, @NotNull List typeParameters, @NotNull List signatureErrors, @@ -176,8 +176,8 @@ public interface ExternalSignatureResolver { PropagatedMethodSignature resolvePropagatedSignature( @NotNull JavaMethod method, @NotNull ClassDescriptor owner, - @NotNull KtType returnType, - @Nullable KtType receiverType, + @NotNull KotlinType returnType, + @Nullable KotlinType receiverType, @NotNull List valueParameters, @NotNull List typeParameters ); @@ -186,8 +186,8 @@ public interface ExternalSignatureResolver { AlternativeMethodSignature resolveAlternativeMethodSignature( @NotNull JavaMember methodOrConstructor, boolean hasSuperMethods, - @Nullable KtType returnType, - @Nullable KtType receiverType, + @Nullable KotlinType returnType, + @Nullable KotlinType receiverType, @NotNull List valueParameters, @NotNull List typeParameters, boolean hasStableParameterNames @@ -196,7 +196,7 @@ public interface ExternalSignatureResolver { @NotNull AlternativeFieldSignature resolveAlternativeFieldSignature( @NotNull JavaField field, - @NotNull KtType returnType, + @NotNull KotlinType returnType, boolean isVar ); diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/components/SamConversionResolver.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/components/SamConversionResolver.kt index b17b1a52550..7af0554688f 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/components/SamConversionResolver.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/components/SamConversionResolver.kt @@ -22,7 +22,7 @@ import org.jetbrains.kotlin.load.java.descriptors.SamConstructorDescriptor import org.jetbrains.kotlin.load.java.structure.JavaMethod import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.resolve.scopes.KtScope -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType public interface SamConversionResolver { public companion object EMPTY : SamConversionResolver { @@ -30,7 +30,7 @@ public interface SamConversionResolver { override fun resolveSamConstructor(name: Name, scope: KtScope) = null override fun resolveFunctionTypeIfSamInterface( classDescriptor: JavaClassDescriptor, resolveMethod: (JavaMethod) -> FunctionDescriptor - ): KtType? = null + ): KotlinType? = null } public fun resolveSamConstructor(name: Name, scope: KtScope): SamConstructorDescriptor? @@ -40,5 +40,5 @@ public interface SamConversionResolver { public fun resolveFunctionTypeIfSamInterface( classDescriptor: JavaClassDescriptor, resolveMethod: (JavaMethod) -> FunctionDescriptor - ): KtType? + ): KotlinType? } diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaCallableMemberDescriptor.java b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaCallableMemberDescriptor.java index 78c5a899d3c..b432a322ff2 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaCallableMemberDescriptor.java +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaCallableMemberDescriptor.java @@ -19,15 +19,15 @@ package org.jetbrains.kotlin.load.java.descriptors; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import java.util.List; public interface JavaCallableMemberDescriptor extends CallableMemberDescriptor { @NotNull JavaCallableMemberDescriptor enhance( - @Nullable KtType enhancedReceiverType, - @NotNull List enhancedValueParametersTypes, - @NotNull KtType enhancedReturnType + @Nullable KotlinType enhancedReceiverType, + @NotNull List enhancedValueParametersTypes, + @NotNull KotlinType enhancedReturnType ); } diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaClassDescriptor.java b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaClassDescriptor.java index 5b184f2790d..d3f9c94ddce 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaClassDescriptor.java +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaClassDescriptor.java @@ -18,9 +18,9 @@ package org.jetbrains.kotlin.load.java.descriptors; import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.descriptors.ClassDescriptor; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; public interface JavaClassDescriptor extends ClassDescriptor { @Nullable - KtType getFunctionTypeForSamInterface(); + KotlinType getFunctionTypeForSamInterface(); } diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaConstructorDescriptor.java b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaConstructorDescriptor.java index 4670d4533b2..63fdbb95b07 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaConstructorDescriptor.java +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaConstructorDescriptor.java @@ -21,7 +21,7 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.descriptors.*; import org.jetbrains.kotlin.descriptors.annotations.Annotations; import org.jetbrains.kotlin.descriptors.impl.ConstructorDescriptorImpl; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import java.util.List; @@ -96,9 +96,9 @@ public class JavaConstructorDescriptor extends ConstructorDescriptorImpl impleme @Override @NotNull public JavaConstructorDescriptor enhance( - @Nullable KtType enhancedReceiverType, - @NotNull List enhancedValueParametersTypes, - @NotNull KtType enhancedReturnType + @Nullable KotlinType enhancedReceiverType, + @NotNull List enhancedValueParametersTypes, + @NotNull KotlinType enhancedReturnType ) { JavaConstructorDescriptor enhanced = createSubstitutedCopy(getContainingDeclaration(), getOriginal(), getKind()); // We do not use doSubstitute here as in JavaMethodDescriptor.enhance because type parameters of constructor belongs to class diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaMethodDescriptor.java b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaMethodDescriptor.java index 2470ad67c22..79acb46315f 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaMethodDescriptor.java +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaMethodDescriptor.java @@ -22,7 +22,7 @@ import org.jetbrains.kotlin.descriptors.*; import org.jetbrains.kotlin.descriptors.annotations.Annotations; import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl; import org.jetbrains.kotlin.name.Name; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.TypeSubstitutor; import org.jetbrains.kotlin.util.OperatorChecks; @@ -77,11 +77,11 @@ public class JavaMethodDescriptor extends SimpleFunctionDescriptorImpl implement @NotNull @Override public SimpleFunctionDescriptorImpl initialize( - @Nullable KtType receiverParameterType, + @Nullable KotlinType receiverParameterType, @Nullable ReceiverParameterDescriptor dispatchReceiverParameter, @NotNull List typeParameters, @NotNull List unsubstitutedValueParameters, - @Nullable KtType unsubstitutedReturnType, + @Nullable KotlinType unsubstitutedReturnType, @Nullable Modality modality, @NotNull Visibility visibility ) { @@ -130,9 +130,9 @@ public class JavaMethodDescriptor extends SimpleFunctionDescriptorImpl implement @Override @NotNull public JavaMethodDescriptor enhance( - @Nullable KtType enhancedReceiverType, - @NotNull List enhancedValueParametersTypes, - @NotNull KtType enhancedReturnType + @Nullable KotlinType enhancedReceiverType, + @NotNull List enhancedValueParametersTypes, + @NotNull KotlinType enhancedReturnType ) { List enhancedValueParameters = UtilKt.copyValueParameters(enhancedValueParametersTypes, getValueParameters(), this); diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaPropertyDescriptor.java b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaPropertyDescriptor.java index a47a4bf42b6..03ad508e0db 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaPropertyDescriptor.java +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaPropertyDescriptor.java @@ -24,7 +24,7 @@ import org.jetbrains.kotlin.descriptors.impl.PropertyDescriptorImpl; import org.jetbrains.kotlin.descriptors.impl.PropertyGetterDescriptorImpl; import org.jetbrains.kotlin.descriptors.impl.PropertySetterDescriptorImpl; import org.jetbrains.kotlin.name.Name; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import java.util.List; @@ -55,9 +55,9 @@ public class JavaPropertyDescriptor extends PropertyDescriptorImpl implements Ja @NotNull @Override public JavaCallableMemberDescriptor enhance( - @Nullable KtType enhancedReceiverType, - @NotNull List enhancedValueParametersTypes, - @NotNull KtType enhancedReturnType + @Nullable KotlinType enhancedReceiverType, + @NotNull List enhancedValueParametersTypes, + @NotNull KotlinType enhancedReturnType ) { JavaPropertyDescriptor enhanced = new JavaPropertyDescriptor( getContainingDeclaration(), diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/util.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/util.kt index a213d2bea94..864d55285a6 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/util.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/util.kt @@ -29,10 +29,10 @@ import org.jetbrains.kotlin.serialization.ProtoBuf import org.jetbrains.kotlin.serialization.deserialization.NameResolver import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedCallableMemberDescriptor import org.jetbrains.kotlin.serialization.jvm.JvmProtoBuf -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType fun copyValueParameters( - newValueParametersTypes: Collection, + newValueParametersTypes: Collection, oldValueParameters: Collection, newOwner: CallableDescriptor ): List { diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaAnnotationDescriptor.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaAnnotationDescriptor.kt index ccc856d119a..b63dd6267d3 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaAnnotationDescriptor.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaAnnotationDescriptor.kt @@ -65,7 +65,7 @@ class LazyJavaAnnotationDescriptor( private val factory = ConstantValueFactory(c.module.builtIns) - override fun getType(): KtType = type() + override fun getType(): KotlinType = type() private val allValueArguments = c.storageManager.createLazyValue { computeValueArguments() diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassDescriptor.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassDescriptor.kt index ffb22516462..63a066ccacd 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassDescriptor.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassDescriptor.kt @@ -102,7 +102,7 @@ class LazyJavaClassDescriptor( } } - override fun getFunctionTypeForSamInterface(): KtType? = functionTypeForSamInterface() + override fun getFunctionTypeForSamInterface(): KotlinType? = functionTypeForSamInterface() override fun isCompanionObject() = false @@ -120,12 +120,12 @@ class LazyJavaClassDescriptor( override fun getParameters(): List = parameters() - private val supertypes = c.storageManager.createLazyValue> { + private val supertypes = c.storageManager.createLazyValue> { val javaTypes = jClass.getSupertypes() - val result = ArrayList(javaTypes.size()) + val result = ArrayList(javaTypes.size()) val incomplete = ArrayList(0) - val purelyImplementedSupertype: KtType? = getPurelyImplementedSupertype() + val purelyImplementedSupertype: KotlinType? = getPurelyImplementedSupertype() for (javaType in javaTypes) { val jetType = c.typeResolver.transformJavaType(javaType, TypeUsage.SUPERTYPE.toAttributes()) @@ -154,7 +154,7 @@ class LazyJavaClassDescriptor( if (result.isNotEmpty()) result.toReadOnlyList() else listOf(c.module.builtIns.getAnyType()) } - private fun getPurelyImplementedSupertype(): KtType? { + private fun getPurelyImplementedSupertype(): KotlinType? { val purelyImplementedFqName = getPurelyImplementsFqNameFromAnnotation() ?: FakePureImplementationsProvider.getPurelyImplementedInterface(fqName) ?: return null @@ -169,7 +169,7 @@ class LazyJavaClassDescriptor( parameter -> TypeProjectionImpl(Variance.INVARIANT, parameter.getDefaultType()) } - return KtTypeImpl.create( + return KotlinTypeImpl.create( Annotations.EMPTY, classDescriptor, /* nullable =*/ false, parametersAsTypeProjections ) @@ -186,7 +186,7 @@ class LazyJavaClassDescriptor( return FqName(fqNameString) } - override fun getSupertypes(): Collection = supertypes() + override fun getSupertypes(): Collection = supertypes() override fun getAnnotations() = Annotations.EMPTY diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassMemberScope.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassMemberScope.kt index 0edc6566d61..ef381a13f4c 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassMemberScope.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassMemberScope.kt @@ -52,7 +52,7 @@ import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.OverridingUtil import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter import org.jetbrains.kotlin.serialization.deserialization.ErrorReporter -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeUtils import org.jetbrains.kotlin.types.checker.KotlinTypeChecker import org.jetbrains.kotlin.utils.* @@ -263,7 +263,7 @@ public class LazyJavaClassMemberScope( } private fun createPropertyDescriptorWithDefaultGetter( - method: JavaMethod, givenType: KtType? = null, modality: Modality + method: JavaMethod, givenType: KotlinType? = null, modality: Modality ): JavaPropertyDescriptor { val annotations = c.resolveAnnotations(method) @@ -277,7 +277,7 @@ public class LazyJavaClassMemberScope( propertyDescriptor.initialize(getter, null) val returnType = givenType ?: computeMethodReturnType(method, annotations, c.child(propertyDescriptor, method)) - propertyDescriptor.setType(returnType, listOf(), getDispatchReceiverParameter(), null as KtType?) + propertyDescriptor.setType(returnType, listOf(), getDispatchReceiverParameter(), null as KotlinType?) getter.initialize(returnType) return propertyDescriptor @@ -302,7 +302,7 @@ public class LazyJavaClassMemberScope( /* isStaticFinal = */ false ) - propertyDescriptor.setType(getterMethod.returnType!!, listOf(), getDispatchReceiverParameter(), null as KtType?) + propertyDescriptor.setType(getterMethod.returnType!!, listOf(), getDispatchReceiverParameter(), null as KotlinType?) val getter = DescriptorFactory.createGetter( propertyDescriptor, getterMethod.annotations, /* isDefault = */false, @@ -326,7 +326,7 @@ public class LazyJavaClassMemberScope( } override fun resolveMethodSignature( - method: JavaMethod, methodTypeParameters: List, returnType: KtType, + method: JavaMethod, methodTypeParameters: List, returnType: KotlinType, valueParameters: LazyJavaScope.ResolvedValueParameters ): LazyJavaScope.MethodSignatureData { val propagated = c.components.externalSignatureResolver.resolvePropagatedSignature( @@ -410,7 +410,7 @@ public class LazyJavaClassMemberScope( } && returnType.isSubtypeOf(builtinWithErasedParameters.returnType) } - private fun KtType?.isSubtypeOf(other: KtType?): Boolean { + private fun KotlinType?.isSubtypeOf(other: KotlinType?): Boolean { return KotlinTypeChecker.DEFAULT.isSubtypeOf(this ?: return false, other ?: return false) } @@ -510,8 +510,8 @@ public class LazyJavaClassMemberScope( constructor: ConstructorDescriptor, index: Int, method: JavaMethod, - returnType: KtType, - varargElementType: KtType? + returnType: KotlinType, + varargElementType: KotlinType? ) { add(ValueParameterDescriptorImpl( constructor, diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaScope.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaScope.kt index 9da1ea2ef42..3e697105ee2 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaScope.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaScope.kt @@ -43,7 +43,7 @@ import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter import org.jetbrains.kotlin.resolve.scopes.KtScope import org.jetbrains.kotlin.resolve.scopes.KtScopeImpl import org.jetbrains.kotlin.storage.NotNullLazyValue -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeUtils import org.jetbrains.kotlin.utils.Printer import org.jetbrains.kotlin.utils.addIfNotNull @@ -106,7 +106,7 @@ public abstract class LazyJavaScope( protected abstract fun resolveMethodSignature( method: JavaMethod, methodTypeParameters: List, - returnType: KtType, + returnType: KotlinType, valueParameters: ResolvedValueParameters): MethodSignatureData open fun resolveMethodToFunctionDescriptor(method: JavaMethod): JavaMethodDescriptor { @@ -147,7 +147,7 @@ public abstract class LazyJavaScope( return functionDescriptorImpl } - protected fun computeMethodReturnType(method: JavaMethod, annotations: Annotations, c: LazyJavaResolverContext): KtType { + protected fun computeMethodReturnType(method: JavaMethod, annotations: Annotations, c: LazyJavaResolverContext): KotlinType { val annotationMethod = method.getContainingClass().isAnnotationType() val returnTypeAttrs = LazyJavaTypeAttributes( TypeUsage.MEMBER_SIGNATURE_COVARIANT, annotations, @@ -255,7 +255,7 @@ public abstract class LazyJavaScope( c.components.externalSignatureResolver.reportSignatureErrors(propertyDescriptor, signatureErrors) } - propertyDescriptor.setType(effectiveSignature.getReturnType(), listOf(), getDispatchReceiverParameter(), null as KtType?) + propertyDescriptor.setType(effectiveSignature.getReturnType(), listOf(), getDispatchReceiverParameter(), null as KotlinType?) if (DescriptorUtils.shouldRecordInitializerForProperty(propertyDescriptor, propertyDescriptor.getType())) { propertyDescriptor.setCompileTimeInitializer( @@ -282,7 +282,7 @@ public abstract class LazyJavaScope( private val JavaField.isFinalStatic: Boolean get() = isFinal && isStatic - private fun getPropertyType(field: JavaField, annotations: Annotations): KtType { + private fun getPropertyType(field: JavaField, annotations: Annotations): KotlinType { // Fields do not have their own generic parameters val finalStatic = field.isFinalStatic // simple static constants should not have flexible types: diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaStaticClassScope.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaStaticClassScope.kt index a58cbaa8c1e..30920126b86 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaStaticClassScope.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaStaticClassScope.kt @@ -33,7 +33,7 @@ import org.jetbrains.kotlin.resolve.DescriptorFactory.createEnumValuesMethod import org.jetbrains.kotlin.resolve.DescriptorFactory.createEnumValuesProperty import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.utils.addIfNotNull public class LazyJavaStaticClassScope( @@ -117,7 +117,7 @@ public class LazyJavaStaticClassScope( private fun getStaticPropertiesFromJavaSupertypes(name: Name, descriptor: ClassDescriptor): Set { - fun getStaticProperties(supertype: KtType): Iterable { + fun getStaticProperties(supertype: KotlinType): Iterable { val superTypeDescriptor = supertype.constructor.declarationDescriptor as? ClassDescriptor ?: return emptyList() val staticScope = superTypeDescriptor.staticScope diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaStaticScope.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaStaticScope.kt index 046994b490d..d9522fafdfb 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaStaticScope.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaStaticScope.kt @@ -24,7 +24,7 @@ import org.jetbrains.kotlin.load.java.lazy.LazyJavaResolverContext import org.jetbrains.kotlin.load.java.structure.JavaMethod import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType public abstract class LazyJavaStaticScope( c: LazyJavaResolverContext, @@ -40,7 +40,7 @@ public abstract class LazyJavaStaticScope( override fun getImplicitReceiversHierarchy(): List = listOf() override fun resolveMethodSignature( - method: JavaMethod, methodTypeParameters: List, returnType: KtType, + method: JavaMethod, methodTypeParameters: List, returnType: KotlinType, valueParameters: LazyJavaScope.ResolvedValueParameters ): LazyJavaScope.MethodSignatureData { val effectiveSignature = c.components.externalSignatureResolver.resolveAlternativeMethodSignature( diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaTypeParameterDescriptor.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaTypeParameterDescriptor.kt index afd198e7a5a..07ea6058c25 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaTypeParameterDescriptor.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaTypeParameterDescriptor.kt @@ -19,7 +19,7 @@ package org.jetbrains.kotlin.load.java.lazy.descriptors import org.jetbrains.kotlin.descriptors.impl.AbstractLazyTypeParameterDescriptor import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.types.Variance -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.load.java.structure.JavaTypeParameter import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor @@ -45,7 +45,7 @@ class LazyJavaTypeParameterDescriptor( SourceElement.NO_SOURCE ) { - override fun resolveUpperBounds(): Set { + override fun resolveUpperBounds(): Set { val bounds = javaTypeParameter.getUpperBounds() if (bounds.isEmpty()) { return setOf(LazyJavaTypeResolver.FlexibleJavaClassifierTypeCapabilities.create( diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/types/LazyJavaTypeResolver.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/types/LazyJavaTypeResolver.kt index 810837cd575..e4ba5c36074 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/types/LazyJavaTypeResolver.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/types/LazyJavaTypeResolver.kt @@ -52,7 +52,7 @@ class LazyJavaTypeResolver( private val typeParameterResolver: TypeParameterResolver ) { - public fun transformJavaType(javaType: JavaType, attr: JavaTypeAttributes): KtType { + public fun transformJavaType(javaType: JavaType, attr: JavaTypeAttributes): KotlinType { return when (javaType) { is JavaPrimitiveType -> { val primitiveType = javaType.getType() @@ -71,7 +71,7 @@ class LazyJavaTypeResolver( } } - public fun transformArrayType(arrayType: JavaArrayType, attr: JavaTypeAttributes, isVararg: Boolean = false): KtType { + public fun transformArrayType(arrayType: JavaArrayType, attr: JavaTypeAttributes, isVararg: Boolean = false): KotlinType { return run { val javaComponentType = arrayType.getComponentType() val primitiveType = (javaComponentType as? JavaPrimitiveType)?.getType() @@ -169,10 +169,10 @@ class LazyJavaTypeResolver( // We do not memoize the results of this method, because it would consume much memory, and the real gain is little: // the case this method accounts for is very rare, not point in optimizing it - private fun getConstructorTypeParameterSubstitute(): KtType { + private fun getConstructorTypeParameterSubstitute(): KotlinType { // If a Java-constructor declares its own type parameters, we have no way of directly expressing them in Kotlin, // so we replace them by intersections of their upper bounds - val supertypesJet = HashSet() + val supertypesJet = HashSet() for (supertype in (classifier() as JavaTypeParameter).getUpperBounds()) { supertypesJet.add(transformJavaType(supertype, UPPER_BOUND.toAttributes())) } @@ -290,11 +290,11 @@ class LazyJavaTypeResolver( public object FlexibleJavaClassifierTypeCapabilities : FlexibleTypeCapabilities { @JvmStatic - fun create(lowerBound: KtType, upperBound: KtType) = DelegatingFlexibleType.create(lowerBound, upperBound, this) + fun create(lowerBound: KotlinType, upperBound: KotlinType) = DelegatingFlexibleType.create(lowerBound, upperBound, this) override val id: String get() = "kotlin.jvm.PlatformType" - override fun getCapability(capabilityClass: Class, jetType: KtType, flexibility: Flexibility): T? { + override fun getCapability(capabilityClass: Class, jetType: KotlinType, flexibility: Flexibility): T? { @Suppress("UNCHECKED_CAST") return when (capabilityClass) { javaClass(), javaClass() -> Impl(flexibility) as T @@ -305,8 +305,8 @@ class LazyJavaTypeResolver( private class Impl(val flexibility: Flexibility) : CustomTypeVariable, Specificity { - private val lowerBound: KtType get() = flexibility.lowerBound - private val upperBound: KtType get() = flexibility.upperBound + private val lowerBound: KotlinType get() = flexibility.lowerBound + private val upperBound: KotlinType get() = flexibility.upperBound override val isTypeVariable: Boolean = lowerBound.getConstructor() == upperBound.getConstructor() && lowerBound.getConstructor().getDeclarationDescriptor() is TypeParameterDescriptor @@ -314,12 +314,12 @@ class LazyJavaTypeResolver( override val typeParameterDescriptor: TypeParameterDescriptor? = if (isTypeVariable) lowerBound.getConstructor().getDeclarationDescriptor() as TypeParameterDescriptor else null - override fun substitutionResult(replacement: KtType): KtType { + override fun substitutionResult(replacement: KotlinType): KotlinType { return if (replacement.isFlexible()) replacement else create(replacement, TypeUtils.makeNullable(replacement)) } - override fun getSpecificityRelationTo(otherType: KtType): Specificity.Relation { + override fun getSpecificityRelationTo(otherType: KotlinType): Specificity.Relation { // For primitive types we have to take care of the case when there are two overloaded methods like // foo(int) and foo(Integer) // if we do not discriminate one of them, any call to foo(kotlin.Int) will result in overload resolution ambiguity @@ -425,8 +425,8 @@ internal fun TypeParameterDescriptor.getErasedUpperBound( // E.g. `class A` // To prevent recursive calls return defaultValue() instead potentiallyRecursiveTypeParameter: TypeParameterDescriptor? = null, - defaultValue: (() -> KtType) = { ErrorUtils.createErrorType("Can't compute erased upper bound of type parameter `$this`") } -): KtType { + defaultValue: (() -> KotlinType) = { ErrorUtils.createErrorType("Can't compute erased upper bound of type parameter `$this`") } +): KotlinType { if (this === potentiallyRecursiveTypeParameter) return defaultValue() val firstUpperBound = upperBounds.first() @@ -450,7 +450,7 @@ internal fun TypeParameterDescriptor.getErasedUpperBound( return defaultValue() } -private fun KtType.replaceArgumentsWithStarProjections(): KtType { +private fun KotlinType.replaceArgumentsWithStarProjections(): KotlinType { if (constructor.parameters.isEmpty() || constructor.declarationDescriptor == null) return this // We could just create JetTypeImpl with current type constructor and star projections, @@ -459,7 +459,7 @@ private fun KtType.replaceArgumentsWithStarProjections(): KtType { } private object ConstantStarSubstitution : TypeSubstitution() { - override fun get(key: KtType): TypeProjection? { + override fun get(key: KotlinType): TypeProjection? { // Let substitutor deal with flexibility if (key.isFlexible()) return null diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/types/RawType.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/types/RawType.kt index d91b8322e5b..37cd3365255 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/types/RawType.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/types/RawType.kt @@ -32,14 +32,14 @@ public object RawTypeCapabilities : TypeCapabilities { } private object RawFlexibleRendering : CustomFlexibleRendering { - private fun DescriptorRenderer.renderArguments(jetType: KtType) = jetType.arguments.map { renderTypeProjection(it) } + private fun DescriptorRenderer.renderArguments(jetType: KotlinType) = jetType.arguments.map { renderTypeProjection(it) } private fun String.replaceArgs(newArgs: String): String { if (!contains('<')) return this return "${substringBefore('<')}<$newArgs>${substringAfterLast('>')}" } - override fun renderInflexible(type: KtType, renderer: DescriptorRenderer): String? { + override fun renderInflexible(type: KotlinType, renderer: DescriptorRenderer): String? { if (type.arguments.isNotEmpty()) return null return StringBuilder { @@ -81,12 +81,12 @@ public object RawTypeCapabilities : TypeCapabilities { } internal object RawSubstitution : TypeSubstitution() { - override fun get(key: KtType) = TypeProjectionImpl(eraseType(key)) + override fun get(key: KotlinType) = TypeProjectionImpl(eraseType(key)) private val lowerTypeAttr = TypeUsage.MEMBER_SIGNATURE_INVARIANT.toAttributes().toFlexible(JavaTypeFlexibility.FLEXIBLE_LOWER_BOUND) private val upperTypeAttr = TypeUsage.MEMBER_SIGNATURE_INVARIANT.toAttributes().toFlexible(JavaTypeFlexibility.FLEXIBLE_UPPER_BOUND) - public fun eraseType(type: KtType): KtType { + public fun eraseType(type: KotlinType): KotlinType { val declaration = type.constructor.declarationDescriptor return when (declaration) { is TypeParameterDescriptor -> eraseType(declaration.getErasedUpperBound()) @@ -102,20 +102,20 @@ internal object RawSubstitution : TypeSubstitution() { } } - private fun eraseInflexibleBasedOnClassDescriptor(type: KtType, declaration: ClassDescriptor, attr: JavaTypeAttributes): KtType { + private fun eraseInflexibleBasedOnClassDescriptor(type: KotlinType, declaration: ClassDescriptor, attr: JavaTypeAttributes): KotlinType { if (KotlinBuiltIns.isArray(type)) { val componentTypeProjection = type.arguments[0] val arguments = listOf( TypeProjectionImpl(componentTypeProjection.projectionKind, eraseType(componentTypeProjection.type)) ) - return KtTypeImpl.create( + return KotlinTypeImpl.create( type.annotations, type.constructor, type.isMarkedNullable, arguments, (type.constructor.declarationDescriptor as ClassDescriptor).getMemberScope(arguments) ) } val constructor = type.constructor - return KtTypeImpl.create( + return KotlinTypeImpl.create( type.annotations, constructor, type.isMarkedNullable, type.constructor.parameters.map { parameter -> @@ -130,7 +130,7 @@ internal object RawSubstitution : TypeSubstitution() { fun computeProjection( parameter: TypeParameterDescriptor, attr: JavaTypeAttributes, - erasedUpperBound: KtType = parameter.getErasedUpperBound() + erasedUpperBound: KotlinType = parameter.getErasedUpperBound() ) = when (attr.flexibility) { // Raw(List) => (List..List<*>) // Raw(Enum) => (Enum>..Enum>) diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/signatureEnhancement.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/signatureEnhancement.kt index 0967064620e..4a2f0092f34 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/signatureEnhancement.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/signatureEnhancement.kt @@ -18,7 +18,7 @@ package org.jetbrains.kotlin.load.java.typeEnhacement import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor import org.jetbrains.kotlin.load.java.descriptors.JavaCallableMemberDescriptor -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType public fun enhanceSignatures(platformSignatures: Collection): Collection { return platformSignatures.map { @@ -51,17 +51,17 @@ public fun D.enhanceSignature(): D { } private class SignatureParts( - val fromOverride: KtType, - val fromOverridden: Collection, + val fromOverride: KotlinType, + val fromOverridden: Collection, val isCovariant: Boolean ) { - fun enhance(): KtType { + fun enhance(): KotlinType { val qualifiers = fromOverride.computeIndexedQualifiersForOverride(this.fromOverridden, isCovariant) return fromOverride.enhance(qualifiers) } } -private fun D.parts(isCovariant: Boolean, collector: (D) -> KtType): SignatureParts { +private fun D.parts(isCovariant: Boolean, collector: (D) -> KotlinType): SignatureParts { return SignatureParts( collector(this), this.getOverriddenDescriptors().map { diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/typeEnhancement.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/typeEnhancement.kt index 4f6fec3ccb1..48926026eb4 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/typeEnhancement.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/typeEnhancement.kt @@ -37,7 +37,7 @@ import org.jetbrains.kotlin.utils.toReadOnlyList // Example: for `A>`, indices go as follows: `0 - A<...>, 1 - B, 2 - C, 3 - D, 4 - E`, // which corresponds to the left-to-right breadth-first walk of the tree representation of the type. // For flexible types, both bounds are indexed in the same way: `(A..C)` gives `0 - (A..C), 1 - B and D`. -fun KtType.enhance(qualifiers: (Int) -> JavaTypeQualifiers) = this.enhancePossiblyFlexible(qualifiers, 0).type +fun KotlinType.enhance(qualifiers: (Int) -> JavaTypeQualifiers) = this.enhancePossiblyFlexible(qualifiers, 0).type private enum class TypeComponentPosition { @@ -46,9 +46,9 @@ private enum class TypeComponentPosition { INFLEXIBLE } -private data class Result(val type: KtType, val subtreeSize: Int) +private data class Result(val type: KotlinType, val subtreeSize: Int) -private fun KtType.enhancePossiblyFlexible(qualifiers: (Int) -> JavaTypeQualifiers, index: Int): Result { +private fun KotlinType.enhancePossiblyFlexible(qualifiers: (Int) -> JavaTypeQualifiers, index: Int): Result { if (this.isError()) return Result(this, 1) return if (this.isFlexible()) { with(this.flexibility()) { @@ -67,7 +67,7 @@ private fun KtType.enhancePossiblyFlexible(qualifiers: (Int) -> JavaTypeQualifie else this.enhanceInflexible(qualifiers, index, TypeComponentPosition.INFLEXIBLE) } -private fun KtType.enhanceInflexible(qualifiers: (Int) -> JavaTypeQualifiers, index: Int, position: TypeComponentPosition): Result { +private fun KotlinType.enhanceInflexible(qualifiers: (Int) -> JavaTypeQualifiers, index: Int, position: TypeComponentPosition): Result { val shouldEnhance = position.shouldEnhance() if (!shouldEnhance && getArguments().isEmpty()) return Result(this, 1) @@ -104,7 +104,7 @@ private fun KtType.enhanceInflexible(qualifiers: (Int) -> JavaTypeQualifiers, in typeConstructor.parameters, enhancedArguments ) - val enhancedType = KtTypeImpl.create( + val enhancedType = KotlinTypeImpl.create( newAnnotations, typeConstructor, enhancedNullability, @@ -153,7 +153,7 @@ private fun ClassifierDescriptor.enhanceMutability(qualifiers: JavaTypeQualifier return this.noChange() } -private fun KtType.getEnhancedNullability(qualifiers: JavaTypeQualifiers, position: TypeComponentPosition): EnhancementResult { +private fun KotlinType.getEnhancedNullability(qualifiers: JavaTypeQualifiers, position: TypeComponentPosition): EnhancementResult { if (!position.shouldEnhance()) return this.isMarkedNullable().noChange() return when (qualifiers.nullability) { diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/typeQualifiers.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/typeQualifiers.kt index 1cda769252f..00df6d37d43 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/typeQualifiers.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/typeQualifiers.kt @@ -24,7 +24,7 @@ import org.jetbrains.kotlin.load.java.typeEnhacement.NullabilityQualifier.NOT_NU import org.jetbrains.kotlin.load.java.typeEnhacement.NullabilityQualifier.NULLABLE import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.platform.JavaToKotlinClassMap -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.checker.KotlinTypeChecker import org.jetbrains.kotlin.types.flexibility import org.jetbrains.kotlin.types.isFlexible @@ -65,7 +65,7 @@ class JavaTypeQualifiers( } } -private fun KtType.extractQualifiers(): JavaTypeQualifiers { +private fun KotlinType.extractQualifiers(): JavaTypeQualifiers { val (lower, upper) = if (this.isFlexible()) flexibility().let { Pair(it.lowerBound, it.upperBound) } @@ -88,11 +88,11 @@ private fun Annotations.extractQualifiers(): JavaTypeQualifiers { ) } -fun KtType.computeIndexedQualifiersForOverride(fromSupertypes: Collection, isCovariant: Boolean): (Int) -> JavaTypeQualifiers { - fun KtType.toIndexed(): List { - val list = ArrayList(1) +fun KotlinType.computeIndexedQualifiersForOverride(fromSupertypes: Collection, isCovariant: Boolean): (Int) -> JavaTypeQualifiers { + fun KotlinType.toIndexed(): List { + val list = ArrayList(1) - fun add(type: KtType) { + fun add(type: KotlinType) { list.add(type) for (arg in type.getArguments()) { if (arg.isStarProjection()) { @@ -134,7 +134,7 @@ fun KtType.computeIndexedQualifiersForOverride(fromSupertypes: Collection computedResult.getOrElse(index) { JavaTypeQualifiers.NONE } } } -private fun KtType.computeQualifiersForOverride(fromSupertypes: Collection, isCovariant: Boolean): JavaTypeQualifiers { +private fun KotlinType.computeQualifiersForOverride(fromSupertypes: Collection, isCovariant: Boolean): JavaTypeQualifiers { val nullabilityFromSupertypes = fromSupertypes.map { it.extractQualifiers().nullability }.filterNotNull().toSet() val mutabilityFromSupertypes = fromSupertypes.map { it.extractQualifiers().mutability }.filterNotNull().toSet() val own = getAnnotations().extractQualifiers() diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/AbstractBinaryClassAnnotationAndConstantLoader.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/AbstractBinaryClassAnnotationAndConstantLoader.kt index 57960dd1991..43ab355a02c 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/AbstractBinaryClassAnnotationAndConstantLoader.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/AbstractBinaryClassAnnotationAndConstantLoader.kt @@ -30,7 +30,7 @@ import org.jetbrains.kotlin.serialization.jvm.JvmProtoBuf.propertyImplClassName import org.jetbrains.kotlin.serialization.jvm.JvmProtoBuf.propertySignature import org.jetbrains.kotlin.serialization.jvm.JvmProtoBufUtil import org.jetbrains.kotlin.storage.StorageManager -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import java.util.* public abstract class AbstractBinaryClassAnnotationAndConstantLoader( @@ -170,7 +170,7 @@ public abstract class AbstractBinaryClassAnnotationAndConstantLoader { + override fun forClass(classDescriptor: DeserializedClassDescriptor): Collection { if (isSerializableInJava(classDescriptor.fqNameSafe)) { return listOf(mockSerializableType) } diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/platform/JavaToKotlinClassMap.java b/core/descriptor.loader.java/src/org/jetbrains/kotlin/platform/JavaToKotlinClassMap.java index 7fbc13b6830..e3a31332966 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/platform/JavaToKotlinClassMap.java +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/platform/JavaToKotlinClassMap.java @@ -28,7 +28,7 @@ import org.jetbrains.kotlin.name.FqNameUnsafe; import org.jetbrains.kotlin.name.Name; import org.jetbrains.kotlin.resolve.DescriptorUtils; import org.jetbrains.kotlin.resolve.jvm.JvmPrimitiveType; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.TypeUtils; import java.lang.annotation.Annotation; @@ -184,7 +184,7 @@ public class JavaToKotlinClassMap implements PlatformToKotlinClassMap { return mutableToReadOnly.containsKey(mutable); } - public boolean isMutable(@NotNull KtType type) { + public boolean isMutable(@NotNull KotlinType type) { ClassDescriptor classDescriptor = TypeUtils.getClassDescriptor(type); return classDescriptor != null && isMutable(classDescriptor); } @@ -193,7 +193,7 @@ public class JavaToKotlinClassMap implements PlatformToKotlinClassMap { return readOnlyToMutable.containsKey(readOnly); } - public boolean isReadOnly(@NotNull KtType type) { + public boolean isReadOnly(@NotNull KotlinType type) { ClassDescriptor classDescriptor = TypeUtils.getClassDescriptor(type); return classDescriptor != null && isReadOnly(classDescriptor); } diff --git a/core/descriptors/src/org/jetbrains/kotlin/builtins/BuiltInsAnnotationAndConstantLoader.kt b/core/descriptors/src/org/jetbrains/kotlin/builtins/BuiltInsAnnotationAndConstantLoader.kt index 9f30d7a149d..65206142699 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/builtins/BuiltInsAnnotationAndConstantLoader.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/builtins/BuiltInsAnnotationAndConstantLoader.kt @@ -24,7 +24,7 @@ import org.jetbrains.kotlin.resolve.constants.ConstantValue import org.jetbrains.kotlin.serialization.ProtoBuf import org.jetbrains.kotlin.serialization.builtins.BuiltInsProtoBuf import org.jetbrains.kotlin.serialization.deserialization.* -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType class BuiltInsAnnotationAndConstantLoader( module: ModuleDescriptor @@ -81,7 +81,7 @@ class BuiltInsAnnotationAndConstantLoader( override fun loadPropertyConstant( container: ProtoContainer, proto: ProtoBuf.Property, - expectedType: KtType + expectedType: KotlinType ): ConstantValue<*>? { if (!proto.hasExtension(BuiltInsProtoBuf.compileTimeValue)) return null val value = proto.getExtension(BuiltInsProtoBuf.compileTimeValue) diff --git a/core/descriptors/src/org/jetbrains/kotlin/builtins/KotlinBuiltIns.java b/core/descriptors/src/org/jetbrains/kotlin/builtins/KotlinBuiltIns.java index 11a66cd038a..43be21b0062 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/builtins/KotlinBuiltIns.java +++ b/core/descriptors/src/org/jetbrains/kotlin/builtins/KotlinBuiltIns.java @@ -61,9 +61,9 @@ public abstract class KotlinBuiltIns { private final BuiltinsPackageFragment builtinsPackageFragment; private final BuiltinsPackageFragment annotationPackageFragment; - private final Map primitiveTypeToArrayJetType; - private final Map primitiveJetTypeToJetArrayType; - private final Map jetArrayTypeToPrimitiveJetType; + private final Map primitiveTypeToArrayJetType; + private final Map primitiveJetTypeToJetArrayType; + private final Map jetArrayTypeToPrimitiveJetType; public static final FqNames FQ_NAMES = new FqNames(); @@ -91,9 +91,9 @@ public abstract class KotlinBuiltIns { builtinsPackageFragment = (BuiltinsPackageFragment) single(packageFragmentProvider.getPackageFragments(BUILT_INS_PACKAGE_FQ_NAME)); annotationPackageFragment = (BuiltinsPackageFragment) single(packageFragmentProvider.getPackageFragments(ANNOTATION_PACKAGE_FQ_NAME)); - primitiveTypeToArrayJetType = new EnumMap(PrimitiveType.class); - primitiveJetTypeToJetArrayType = new HashMap(); - jetArrayTypeToPrimitiveJetType = new HashMap(); + primitiveTypeToArrayJetType = new EnumMap(PrimitiveType.class); + primitiveJetTypeToJetArrayType = new HashMap(); + jetArrayTypeToPrimitiveJetType = new HashMap(); for (PrimitiveType primitive : PrimitiveType.values()) { makePrimitive(primitive); } @@ -105,8 +105,8 @@ public abstract class KotlinBuiltIns { } private void makePrimitive(@NotNull PrimitiveType primitiveType) { - KtType type = getBuiltInTypeByClassName(primitiveType.getTypeName().asString()); - KtType arrayType = getBuiltInTypeByClassName(primitiveType.getArrayTypeName().asString()); + KotlinType type = getBuiltInTypeByClassName(primitiveType.getTypeName().asString()); + KotlinType arrayType = getBuiltInTypeByClassName(primitiveType.getArrayTypeName().asString()); primitiveTypeToArrayJetType.put(primitiveType, arrayType); primitiveJetTypeToJetArrayType.put(type, arrayType); @@ -540,100 +540,100 @@ public abstract class KotlinBuiltIns { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @NotNull - private KtType getBuiltInTypeByClassName(@NotNull String classSimpleName) { + private KotlinType getBuiltInTypeByClassName(@NotNull String classSimpleName) { return getBuiltInClassByName(classSimpleName).getDefaultType(); } // Special @NotNull - public KtType getNothingType() { + public KotlinType getNothingType() { return getNothing().getDefaultType(); } @NotNull - public KtType getNullableNothingType() { + public KotlinType getNullableNothingType() { return TypeUtils.makeNullable(getNothingType()); } @NotNull - public KtType getAnyType() { + public KotlinType getAnyType() { return getAny().getDefaultType(); } @NotNull - public KtType getNullableAnyType() { + public KotlinType getNullableAnyType() { return TypeUtils.makeNullable(getAnyType()); } // Primitive @NotNull - public KtType getPrimitiveJetType(@NotNull PrimitiveType type) { + public KotlinType getPrimitiveJetType(@NotNull PrimitiveType type) { return getPrimitiveClassDescriptor(type).getDefaultType(); } @NotNull - public KtType getByteType() { + public KotlinType getByteType() { return getPrimitiveJetType(BYTE); } @NotNull - public KtType getShortType() { + public KotlinType getShortType() { return getPrimitiveJetType(SHORT); } @NotNull - public KtType getIntType() { + public KotlinType getIntType() { return getPrimitiveJetType(INT); } @NotNull - public KtType getLongType() { + public KotlinType getLongType() { return getPrimitiveJetType(LONG); } @NotNull - public KtType getFloatType() { + public KotlinType getFloatType() { return getPrimitiveJetType(FLOAT); } @NotNull - public KtType getDoubleType() { + public KotlinType getDoubleType() { return getPrimitiveJetType(DOUBLE); } @NotNull - public KtType getCharType() { + public KotlinType getCharType() { return getPrimitiveJetType(CHAR); } @NotNull - public KtType getBooleanType() { + public KotlinType getBooleanType() { return getPrimitiveJetType(BOOLEAN); } // Recognized @NotNull - public KtType getUnitType() { + public KotlinType getUnitType() { return getUnit().getDefaultType(); } @NotNull - public KtType getStringType() { + public KotlinType getStringType() { return getString().getDefaultType(); } @NotNull - public KtType getArrayElementType(@NotNull KtType arrayType) { + public KotlinType getArrayElementType(@NotNull KotlinType arrayType) { if (isArray(arrayType)) { if (arrayType.getArguments().size() != 1) { throw new IllegalStateException(); } return arrayType.getArguments().get(0).getType(); } - KtType primitiveType = jetArrayTypeToPrimitiveJetType.get(TypeUtils.makeNotNullable(arrayType)); + KotlinType primitiveType = jetArrayTypeToPrimitiveJetType.get(TypeUtils.makeNotNullable(arrayType)); if (primitiveType == null) { throw new IllegalStateException("not array: " + arrayType); } @@ -641,7 +641,7 @@ public abstract class KotlinBuiltIns { } @NotNull - public KtType getPrimitiveArrayJetType(@NotNull PrimitiveType primitiveType) { + public KotlinType getPrimitiveArrayJetType(@NotNull PrimitiveType primitiveType) { return primitiveTypeToArrayJetType.get(primitiveType); } @@ -649,7 +649,7 @@ public abstract class KotlinBuiltIns { * @return {@code null} if not primitive */ @Nullable - public KtType getPrimitiveArrayJetTypeByPrimitiveJetType(@NotNull KtType jetType) { + public KotlinType getPrimitiveArrayJetTypeByPrimitiveJetType(@NotNull KotlinType jetType) { return primitiveJetTypeToJetArrayType.get(jetType); } @@ -668,9 +668,9 @@ public abstract class KotlinBuiltIns { } @NotNull - public KtType getArrayType(@NotNull Variance projectionType, @NotNull KtType argument) { + public KotlinType getArrayType(@NotNull Variance projectionType, @NotNull KotlinType argument) { List types = Collections.singletonList(new TypeProjectionImpl(projectionType, argument)); - return KtTypeImpl.create( + return KotlinTypeImpl.create( Annotations.Companion.getEMPTY(), getArray(), false, @@ -679,10 +679,10 @@ public abstract class KotlinBuiltIns { } @NotNull - public KtType getEnumType(@NotNull KtType argument) { + public KotlinType getEnumType(@NotNull KotlinType argument) { Variance projectionType = Variance.INVARIANT; List types = Collections.singletonList(new TypeProjectionImpl(projectionType, argument)); - return KtTypeImpl.create( + return KotlinTypeImpl.create( Annotations.Companion.getEMPTY(), getEnum(), false, @@ -691,7 +691,7 @@ public abstract class KotlinBuiltIns { } @NotNull - public KtType getAnnotationType() { + public KotlinType getAnnotationType() { return getAnnotation().getDefaultType(); } @@ -701,16 +701,16 @@ public abstract class KotlinBuiltIns { Collections.>emptyMap(), SourceElement.NO_SOURCE); } - private static boolean isTypeAnnotatedWithExtension(@NotNull KtType type) { + private static boolean isTypeAnnotatedWithExtension(@NotNull KotlinType type) { return type.getAnnotations().findAnnotation(FQ_NAMES.extension) != null; } @NotNull - public KtType getFunctionType( + public KotlinType getFunctionType( @NotNull Annotations annotations, - @Nullable KtType receiverType, - @NotNull List parameterTypes, - @NotNull KtType returnType + @Nullable KotlinType receiverType, + @NotNull List parameterTypes, + @NotNull KotlinType returnType ) { List arguments = getFunctionTypeArgumentProjections(receiverType, parameterTypes, returnType); int size = parameterTypes.size(); @@ -718,7 +718,7 @@ public abstract class KotlinBuiltIns { Annotations typeAnnotations = receiverType == null ? annotations : addExtensionAnnotation(annotations); - return KtTypeImpl.create(typeAnnotations, classDescriptor, false, arguments); + return KotlinTypeImpl.create(typeAnnotations, classDescriptor, false, arguments); } @NotNull @@ -731,22 +731,22 @@ public abstract class KotlinBuiltIns { @NotNull public static List getFunctionTypeArgumentProjections( - @Nullable KtType receiverType, - @NotNull List parameterTypes, - @NotNull KtType returnType + @Nullable KotlinType receiverType, + @NotNull List parameterTypes, + @NotNull KotlinType returnType ) { List arguments = new ArrayList(parameterTypes.size() + (receiverType != null ? 1 : 0) + 1); if (receiverType != null) { arguments.add(defaultProjection(receiverType)); } - for (KtType parameterType : parameterTypes) { + for (KotlinType parameterType : parameterTypes) { arguments.add(defaultProjection(parameterType)); } arguments.add(defaultProjection(returnType)); return arguments; } - private static TypeProjection defaultProjection(KtType returnType) { + private static TypeProjection defaultProjection(KotlinType returnType) { return new TypeProjectionImpl(Variance.INVARIANT, returnType); } @@ -756,16 +756,16 @@ public abstract class KotlinBuiltIns { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - public static boolean isArray(@NotNull KtType type) { + public static boolean isArray(@NotNull KotlinType type) { return isConstructedFromGivenClass(type, FQ_NAMES.array); } - public static boolean isPrimitiveArray(@NotNull KtType type) { + public static boolean isPrimitiveArray(@NotNull KotlinType type) { ClassifierDescriptor descriptor = type.getConstructor().getDeclarationDescriptor(); return descriptor != null && getPrimitiveTypeByArrayClassFqName(getFqName(descriptor)) != null; } - public static boolean isPrimitiveType(@NotNull KtType type) { + public static boolean isPrimitiveType(@NotNull KotlinType type) { ClassifierDescriptor descriptor = type.getConstructor().getDeclarationDescriptor(); return !type.isMarkedNullable() && descriptor instanceof ClassDescriptor && isPrimitiveClass((ClassDescriptor) descriptor); } @@ -776,40 +776,40 @@ public abstract class KotlinBuiltIns { // Functions - public static boolean isFunctionOrExtensionFunctionType(@NotNull KtType type) { + public static boolean isFunctionOrExtensionFunctionType(@NotNull KotlinType type) { return isFunctionType(type) || isExtensionFunctionType(type); } - public static boolean isFunctionType(@NotNull KtType type) { + public static boolean isFunctionType(@NotNull KotlinType type) { if (isExactFunctionType(type)) return true; - for (KtType superType : type.getConstructor().getSupertypes()) { + for (KotlinType superType : type.getConstructor().getSupertypes()) { if (isFunctionType(superType)) return true; } return false; } - public static boolean isExtensionFunctionType(@NotNull KtType type) { + public static boolean isExtensionFunctionType(@NotNull KotlinType type) { if (isExactExtensionFunctionType(type)) return true; - for (KtType superType : type.getConstructor().getSupertypes()) { + for (KotlinType superType : type.getConstructor().getSupertypes()) { if (isExtensionFunctionType(superType)) return true; } return false; } - public static boolean isExactFunctionOrExtensionFunctionType(@NotNull KtType type) { + public static boolean isExactFunctionOrExtensionFunctionType(@NotNull KotlinType type) { ClassifierDescriptor descriptor = type.getConstructor().getDeclarationDescriptor(); return descriptor != null && isNumberedFunctionClassFqName(getFqName(descriptor)); } - public static boolean isExactFunctionType(@NotNull KtType type) { + public static boolean isExactFunctionType(@NotNull KotlinType type) { return isExactFunctionOrExtensionFunctionType(type) && !isTypeAnnotatedWithExtension(type); } - public static boolean isExactExtensionFunctionType(@NotNull KtType type) { + public static boolean isExactExtensionFunctionType(@NotNull KotlinType type) { return isExactFunctionOrExtensionFunctionType(type) && isTypeAnnotatedWithExtension(type); } @@ -828,7 +828,7 @@ public abstract class KotlinBuiltIns { } @Nullable - public static KtType getReceiverType(@NotNull KtType type) { + public static KotlinType getReceiverType(@NotNull KotlinType type) { assert isFunctionOrExtensionFunctionType(type) : type; if (isExtensionFunctionType(type)) { // TODO: this is incorrect when a class extends from an extension function and swaps type arguments @@ -838,7 +838,7 @@ public abstract class KotlinBuiltIns { } @NotNull - public static List getValueParameters(@NotNull FunctionDescriptor functionDescriptor, @NotNull KtType type) { + public static List getValueParameters(@NotNull FunctionDescriptor functionDescriptor, @NotNull KotlinType type) { assert isFunctionOrExtensionFunctionType(type); List parameterTypes = getParameterTypeProjectionsFromFunctionType(type); List valueParameters = new ArrayList(parameterTypes.size()); @@ -858,14 +858,14 @@ public abstract class KotlinBuiltIns { } @NotNull - public static KtType getReturnTypeFromFunctionType(@NotNull KtType type) { + public static KotlinType getReturnTypeFromFunctionType(@NotNull KotlinType type) { assert isFunctionOrExtensionFunctionType(type); List arguments = type.getArguments(); return arguments.get(arguments.size() - 1).getType(); } @NotNull - public static List getParameterTypeProjectionsFromFunctionType(@NotNull KtType type) { + public static List getParameterTypeProjectionsFromFunctionType(@NotNull KotlinType type) { assert isFunctionOrExtensionFunctionType(type); List arguments = type.getArguments(); int first = isExtensionFunctionType(type) ? 1 : 0; @@ -879,14 +879,14 @@ public abstract class KotlinBuiltIns { // Recognized & special - private static boolean isConstructedFromGivenClass(@NotNull KtType type, @NotNull FqNameUnsafe fqName) { + private static boolean isConstructedFromGivenClass(@NotNull KotlinType type, @NotNull FqNameUnsafe fqName) { ClassifierDescriptor descriptor = type.getConstructor().getDeclarationDescriptor(); return descriptor != null && /* quick check to avoid creation of full FqName instance */ descriptor.getName().equals(fqName.shortName()) && fqName.equals(getFqName(descriptor)); } - private static boolean isNotNullConstructedFromGivenClass(@NotNull KtType type, @NotNull FqNameUnsafe fqName) { + private static boolean isNotNullConstructedFromGivenClass(@NotNull KotlinType type, @NotNull FqNameUnsafe fqName) { return !type.isMarkedNullable() && isConstructedFromGivenClass(type, fqName); } @@ -899,16 +899,16 @@ public abstract class KotlinBuiltIns { return isAny(getFqName(descriptor)); } - public static boolean isAny(@NotNull KtType type) { + public static boolean isAny(@NotNull KotlinType type) { return isConstructedFromGivenClassAndNotNullable(type, FQ_NAMES.any); } - public static boolean isBoolean(@NotNull KtType type) { + public static boolean isBoolean(@NotNull KotlinType type) { return isConstructedFromGivenClassAndNotNullable(type, FQ_NAMES._boolean); } - public static boolean isBooleanOrNullableBoolean(@NotNull KtType type) { + public static boolean isBooleanOrNullableBoolean(@NotNull KotlinType type) { return isConstructedFromGivenClass(type, FQ_NAMES._boolean); } @@ -916,35 +916,35 @@ public abstract class KotlinBuiltIns { return FQ_NAMES._boolean.equals(getFqName(classDescriptor)); } - public static boolean isChar(@NotNull KtType type) { + public static boolean isChar(@NotNull KotlinType type) { return isConstructedFromGivenClassAndNotNullable(type, FQ_NAMES._char); } - public static boolean isInt(@NotNull KtType type) { + public static boolean isInt(@NotNull KotlinType type) { return isConstructedFromGivenClassAndNotNullable(type, FQ_NAMES._int); } - public static boolean isByte(@NotNull KtType type) { + public static boolean isByte(@NotNull KotlinType type) { return isConstructedFromGivenClassAndNotNullable(type, FQ_NAMES._byte); } - public static boolean isLong(@NotNull KtType type) { + public static boolean isLong(@NotNull KotlinType type) { return isConstructedFromGivenClassAndNotNullable(type, FQ_NAMES._long); } - public static boolean isShort(@NotNull KtType type) { + public static boolean isShort(@NotNull KotlinType type) { return isConstructedFromGivenClassAndNotNullable(type, FQ_NAMES._short); } - public static boolean isFloat(@NotNull KtType type) { + public static boolean isFloat(@NotNull KotlinType type) { return isConstructedFromGivenClassAndNotNullable(type, FQ_NAMES._float); } - public static boolean isDouble(@NotNull KtType type) { + public static boolean isDouble(@NotNull KotlinType type) { return isConstructedFromGivenClassAndNotNullable(type, FQ_NAMES._double); } - private static boolean isConstructedFromGivenClassAndNotNullable(@NotNull KtType type, @NotNull FqNameUnsafe fqName) { + private static boolean isConstructedFromGivenClassAndNotNullable(@NotNull KotlinType type, @NotNull FqNameUnsafe fqName) { return isConstructedFromGivenClass(type, fqName) && !type.isMarkedNullable(); } @@ -952,57 +952,57 @@ public abstract class KotlinBuiltIns { return FQ_NAMES.any.equals(fqName); } - public static boolean isNothing(@NotNull KtType type) { + public static boolean isNothing(@NotNull KotlinType type) { return isNothingOrNullableNothing(type) && !type.isMarkedNullable(); } - public static boolean isNullableNothing(@NotNull KtType type) { + public static boolean isNullableNothing(@NotNull KotlinType type) { return isNothingOrNullableNothing(type) && type.isMarkedNullable(); } - public static boolean isNothingOrNullableNothing(@NotNull KtType type) { + public static boolean isNothingOrNullableNothing(@NotNull KotlinType type) { return isConstructedFromGivenClass(type, FQ_NAMES.nothing); } - public static boolean isAnyOrNullableAny(@NotNull KtType type) { + public static boolean isAnyOrNullableAny(@NotNull KotlinType type) { return isConstructedFromGivenClass(type, FQ_NAMES.any); } - public static boolean isNullableAny(@NotNull KtType type) { + public static boolean isNullableAny(@NotNull KotlinType type) { return isAnyOrNullableAny(type) && type.isMarkedNullable(); } - public static boolean isDefaultBound(@NotNull KtType type) { + public static boolean isDefaultBound(@NotNull KotlinType type) { return isNullableAny(type); } - public static boolean isUnit(@NotNull KtType type) { + public static boolean isUnit(@NotNull KotlinType type) { return isNotNullConstructedFromGivenClass(type, FQ_NAMES.unit); } - public boolean isBooleanOrSubtype(@NotNull KtType type) { + public boolean isBooleanOrSubtype(@NotNull KotlinType type) { return KotlinTypeChecker.DEFAULT.isSubtypeOf(type, getBooleanType()); } - public static boolean isString(@Nullable KtType type) { + public static boolean isString(@Nullable KotlinType type) { return type != null && isNotNullConstructedFromGivenClass(type, FQ_NAMES.string); } - public static boolean isCollectionOrNullableCollection(@NotNull KtType type) { + public static boolean isCollectionOrNullableCollection(@NotNull KotlinType type) { return isConstructedFromGivenClass(type, FQ_NAMES._collection); } - public static boolean isListOrNullableList(@NotNull KtType type) { + public static boolean isListOrNullableList(@NotNull KotlinType type) { return isConstructedFromGivenClass(type, FQ_NAMES._list); } - public static boolean isSetOrNullableSet(@NotNull KtType type) { + public static boolean isSetOrNullableSet(@NotNull KotlinType type) { return isConstructedFromGivenClass(type, FQ_NAMES._set); } - public static boolean isIterableOrNullableIterable(@NotNull KtType type) { + public static boolean isIterableOrNullableIterable(@NotNull KotlinType type) { return isConstructedFromGivenClass(type, FQ_NAMES._iterable); } @@ -1054,7 +1054,7 @@ public abstract class KotlinBuiltIns { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @NotNull - public KtType getDefaultBound() { + public KotlinType getDefaultBound() { return getNullableAnyType(); } diff --git a/core/descriptors/src/org/jetbrains/kotlin/builtins/ReflectionTypes.kt b/core/descriptors/src/org/jetbrains/kotlin/builtins/ReflectionTypes.kt index 8d479148dac..e0810ec7402 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/builtins/ReflectionTypes.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/builtins/ReflectionTypes.kt @@ -57,22 +57,22 @@ public class ReflectionTypes(private val module: ModuleDescriptor) { public val kMutableProperty0: ClassDescriptor by ClassLookup public val kMutableProperty1: ClassDescriptor by ClassLookup - public fun getKClassType(annotations: Annotations, type: KtType): KtType { + public fun getKClassType(annotations: Annotations, type: KotlinType): KotlinType { val descriptor = kClass if (ErrorUtils.isError(descriptor)) { return descriptor.defaultType } val arguments = listOf(TypeProjectionImpl(Variance.INVARIANT, type)) - return KtTypeImpl.create(annotations, descriptor, false, arguments) + return KotlinTypeImpl.create(annotations, descriptor, false, arguments) } public fun getKFunctionType( annotations: Annotations, - receiverType: KtType?, - parameterTypes: List, - returnType: KtType - ): KtType { + receiverType: KotlinType?, + parameterTypes: List, + returnType: KotlinType + ): KotlinType { val arguments = KotlinBuiltIns.getFunctionTypeArgumentProjections(receiverType, parameterTypes, returnType) val classDescriptor = getKFunction(arguments.size() - 1 /* return type */) @@ -81,10 +81,10 @@ public class ReflectionTypes(private val module: ModuleDescriptor) { return classDescriptor.defaultType } - return KtTypeImpl.create(annotations, classDescriptor, false, arguments) + return KotlinTypeImpl.create(annotations, classDescriptor, false, arguments) } - public fun getKPropertyType(annotations: Annotations, receiverType: KtType?, returnType: KtType, mutable: Boolean): KtType { + public fun getKPropertyType(annotations: Annotations, receiverType: KotlinType?, returnType: KotlinType, mutable: Boolean): KotlinType { val classDescriptor = when { receiverType != null -> when { @@ -106,7 +106,7 @@ public class ReflectionTypes(private val module: ModuleDescriptor) { arguments.add(TypeProjectionImpl(receiverType)) } arguments.add(TypeProjectionImpl(returnType)) - return KtTypeImpl.create(annotations, classDescriptor, false, arguments) + return KotlinTypeImpl.create(annotations, classDescriptor, false, arguments) } companion object { @@ -115,21 +115,21 @@ public class ReflectionTypes(private val module: ModuleDescriptor) { return containingPackage != null && containingPackage.fqName == KOTLIN_REFLECT_FQ_NAME } - public fun isCallableType(type: KtType): Boolean = + public fun isCallableType(type: KotlinType): Boolean = KotlinBuiltIns.isFunctionOrExtensionFunctionType(type) || isKCallableType(type) - private fun isKCallableType(type: KtType): Boolean = + private fun isKCallableType(type: KotlinType): Boolean = isExactKCallableType(type) || type.constructor.supertypes.any { isKCallableType(it) } - private fun isExactKCallableType(type: KtType): Boolean { + private fun isExactKCallableType(type: KotlinType): Boolean { val descriptor = type.constructor.declarationDescriptor return descriptor is ClassDescriptor && DescriptorUtils.getFqName(descriptor) == KotlinBuiltIns.FQ_NAMES.kCallable } - public fun createKPropertyStarType(module: ModuleDescriptor): KtType? { + public fun createKPropertyStarType(module: ModuleDescriptor): KotlinType? { val kPropertyClass = module.findClassAcrossModuleDependencies(KotlinBuiltIns.FQ_NAMES.kProperty) ?: return null - return KtTypeImpl.create( + return KotlinTypeImpl.create( Annotations.EMPTY, kPropertyClass, false, listOf(StarProjectionImpl(kPropertyClass.typeConstructor.parameters.single())) ) diff --git a/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/FunctionClassDescriptor.kt b/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/FunctionClassDescriptor.kt index 204733b577e..db5cbdd29cd 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/FunctionClassDescriptor.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/FunctionClassDescriptor.kt @@ -108,7 +108,7 @@ public class FunctionClassDescriptor( } private val supertypes = storageManager.createLazyValue { - val result = ArrayList(2) + val result = ArrayList(2) fun add(packageFragment: PackageFragmentDescriptor, name: Name) { val descriptor = packageFragment.getMemberScope().getClassifier(name, NoLookupLocation.FROM_BUILTINS) as? ClassDescriptor @@ -121,7 +121,7 @@ public class FunctionClassDescriptor( TypeProjectionImpl(it.getDefaultType()) } - result.add(KtTypeImpl.create(Annotations.EMPTY, descriptor, false, arguments)) + result.add(KotlinTypeImpl.create(Annotations.EMPTY, descriptor, false, arguments)) } // Add unnumbered base class, e.g. Function for Function{n}, KFunction for KFunction{n} @@ -140,7 +140,7 @@ public class FunctionClassDescriptor( override fun getParameters() = parameters - override fun getSupertypes(): Collection = supertypes() + override fun getSupertypes(): Collection = supertypes() override fun getDeclarationDescriptor() = this@FunctionClassDescriptor override fun isDenotable() = true diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/CallableDescriptor.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/CallableDescriptor.java index 3eb526d3e9f..74ee3ea9e02 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/CallableDescriptor.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/CallableDescriptor.java @@ -18,7 +18,7 @@ package org.jetbrains.kotlin.descriptors; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.TypeSubstitutor; import java.util.Collection; @@ -38,7 +38,7 @@ public interface CallableDescriptor extends DeclarationDescriptorWithVisibility, * Method may return null for not yet fully initialized object or if error occurred. */ @Nullable - KtType getReturnType(); + KotlinType getReturnType(); @NotNull @Override diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/ClassDescriptor.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/ClassDescriptor.java index 3a2198b18c6..77f3949af7d 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/ClassDescriptor.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/ClassDescriptor.java @@ -20,7 +20,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.ReadOnly; import org.jetbrains.kotlin.resolve.scopes.KtScope; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.TypeProjection; import org.jetbrains.kotlin.types.TypeSubstitution; import org.jetbrains.kotlin.types.TypeSubstitutor; @@ -57,7 +57,7 @@ public interface ClassDescriptor extends ClassifierDescriptor, MemberDescriptor, */ @NotNull @Override - KtType getDefaultType(); + KotlinType getDefaultType(); @NotNull @Override diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/ClassifierDescriptor.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/ClassifierDescriptor.java index b32a5604f21..088dc00609a 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/ClassifierDescriptor.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/ClassifierDescriptor.java @@ -17,7 +17,7 @@ package org.jetbrains.kotlin.descriptors; import org.jetbrains.annotations.NotNull; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.TypeConstructor; public interface ClassifierDescriptor extends DeclarationDescriptorNonRoot { @@ -25,5 +25,5 @@ public interface ClassifierDescriptor extends DeclarationDescriptorNonRoot { TypeConstructor getTypeConstructor(); @NotNull - KtType getDefaultType(); + KotlinType getDefaultType(); } diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/ConstUtil.kt b/core/descriptors/src/org/jetbrains/kotlin/descriptors/ConstUtil.kt index 0badeaad74d..1f1b8ab1db1 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/ConstUtil.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/ConstUtil.kt @@ -19,11 +19,11 @@ package org.jetbrains.kotlin.descriptors import org.jetbrains.kotlin.builtins.KotlinBuiltIns -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType object ConstUtil { @JvmStatic - public fun canBeUsedForConstVal(type: KtType) = type.canBeUsedForConstVal() + public fun canBeUsedForConstVal(type: KotlinType) = type.canBeUsedForConstVal() } -public fun KtType.canBeUsedForConstVal() = KotlinBuiltIns.isPrimitiveType(this) || KotlinBuiltIns.isString(this) +public fun KotlinType.canBeUsedForConstVal() = KotlinBuiltIns.isPrimitiveType(this) || KotlinBuiltIns.isString(this) diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/ConstructorDescriptor.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/ConstructorDescriptor.java index 5bf438978d5..2fed0c495d6 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/ConstructorDescriptor.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/ConstructorDescriptor.java @@ -18,7 +18,7 @@ package org.jetbrains.kotlin.descriptors; import org.jetbrains.annotations.NotNull; import org.jetbrains.kotlin.name.Name; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import java.util.List; @@ -29,7 +29,7 @@ public interface ConstructorDescriptor extends FunctionDescriptor { @NotNull @Override - KtType getReturnType(); + KotlinType getReturnType(); @NotNull @Override diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/EffectiveVisibility.kt b/core/descriptors/src/org/jetbrains/kotlin/descriptors/EffectiveVisibility.kt index ecb0c5a200a..03018a18d75 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/EffectiveVisibility.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/EffectiveVisibility.kt @@ -17,7 +17,7 @@ package org.jetbrains.kotlin.descriptors import org.jetbrains.kotlin.resolve.DescriptorUtils -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeConstructor sealed class EffectiveVisibility(val name: String) { @@ -231,9 +231,9 @@ sealed class EffectiveVisibility(val name: String) { lowerBound(visibility.forVisibility(this), this?.forClass(classes + this@forClass) ?: Public) } - fun KtType.forType() = forType(emptySet()) + fun KotlinType.forType() = forType(emptySet()) - private fun KtType.forType(types: Set): EffectiveVisibility = + private fun KotlinType.forType(types: Set): EffectiveVisibility = if (this in types) Public else lowerBound(constructor.forTypeConstructor(), arguments.map { it.type.forType(types + this) } ) diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/ParameterDescriptor.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/ParameterDescriptor.java index cf21a80b157..147b0911cb3 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/ParameterDescriptor.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/ParameterDescriptor.java @@ -17,11 +17,11 @@ package org.jetbrains.kotlin.descriptors; import org.jetbrains.annotations.NotNull; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; public interface ParameterDescriptor extends CallableDescriptor { @NotNull - KtType getType(); + KotlinType getType(); @Override @NotNull diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/TypeParameterDescriptor.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/TypeParameterDescriptor.java index fd14091ddfd..aaaaff820c4 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/TypeParameterDescriptor.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/TypeParameterDescriptor.java @@ -17,7 +17,7 @@ package org.jetbrains.kotlin.descriptors; import org.jetbrains.annotations.NotNull; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.TypeConstructor; import org.jetbrains.kotlin.types.TypeSubstitutor; import org.jetbrains.kotlin.types.Variance; @@ -31,13 +31,13 @@ public interface TypeParameterDescriptor extends ClassifierDescriptor { Variance getVariance(); @NotNull - Set getUpperBounds(); + Set getUpperBounds(); @NotNull - KtType getUpperBoundsAsType(); + KotlinType getUpperBoundsAsType(); @NotNull - Set getLowerBounds(); + Set getLowerBounds(); @NotNull @Override diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/ValueParameterDescriptor.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/ValueParameterDescriptor.java index 0783ebfdae0..e326d6086a8 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/ValueParameterDescriptor.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/ValueParameterDescriptor.java @@ -19,7 +19,7 @@ package org.jetbrains.kotlin.descriptors; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.name.Name; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import java.util.Collection; @@ -42,7 +42,7 @@ public interface ValueParameterDescriptor extends VariableDescriptor, ParameterD boolean declaresDefaultValue(); @Nullable - KtType getVarargElementType(); + KotlinType getVarargElementType(); @NotNull @Override diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/VariableDescriptor.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/VariableDescriptor.java index 43917585040..dfe92c19331 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/VariableDescriptor.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/VariableDescriptor.java @@ -19,12 +19,12 @@ package org.jetbrains.kotlin.descriptors; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.resolve.constants.ConstantValue; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.TypeSubstitutor; public interface VariableDescriptor extends CallableDescriptor { @NotNull - KtType getType(); + KotlinType getType(); @Override @NotNull diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/AnnotationDescriptor.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/AnnotationDescriptor.java index 531f0429028..1c5d996d564 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/AnnotationDescriptor.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/AnnotationDescriptor.java @@ -21,13 +21,13 @@ import org.jetbrains.annotations.ReadOnly; import org.jetbrains.kotlin.descriptors.SourceElement; import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor; import org.jetbrains.kotlin.resolve.constants.ConstantValue; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import java.util.Map; public interface AnnotationDescriptor { @NotNull - KtType getType(); + KotlinType getType(); @NotNull @ReadOnly diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/AnnotationDescriptorImpl.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/AnnotationDescriptorImpl.java index 581f52c7e78..5be2b809d25 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/AnnotationDescriptorImpl.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/AnnotationDescriptorImpl.java @@ -21,18 +21,18 @@ import org.jetbrains.kotlin.descriptors.SourceElement; import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor; import org.jetbrains.kotlin.renderer.DescriptorRenderer; import org.jetbrains.kotlin.resolve.constants.ConstantValue; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import java.util.Collections; import java.util.Map; public class AnnotationDescriptorImpl implements AnnotationDescriptor { - private final KtType annotationType; + private final KotlinType annotationType; private final Map> valueArguments; private final SourceElement source; public AnnotationDescriptorImpl( - @NotNull KtType annotationType, + @NotNull KotlinType annotationType, @NotNull Map> valueArguments, @NotNull SourceElement source ) { @@ -43,7 +43,7 @@ public class AnnotationDescriptorImpl implements AnnotationDescriptor { @Override @NotNull - public KtType getType() { + public KotlinType getType() { return annotationType; } diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/AbstractClassDescriptor.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/AbstractClassDescriptor.java index 2b02370a44e..aa1b7e6df22 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/AbstractClassDescriptor.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/AbstractClassDescriptor.java @@ -31,15 +31,15 @@ import java.util.List; public abstract class AbstractClassDescriptor implements ClassDescriptor { private final Name name; - protected final NotNullLazyValue defaultType; + protected final NotNullLazyValue defaultType; private final NotNullLazyValue unsubstitutedInnerClassesScope; private final NotNullLazyValue thisAsReceiverParameter; public AbstractClassDescriptor(@NotNull StorageManager storageManager, @NotNull Name name) { this.name = name; - this.defaultType = storageManager.createLazyValue(new Function0() { + this.defaultType = storageManager.createLazyValue(new Function0() { @Override - public KtType invoke() { + public KotlinType invoke() { return TypeUtils.makeUnsubstitutedType(AbstractClassDescriptor.this, getUnsubstitutedMemberScope()); } }); @@ -113,7 +113,7 @@ public abstract class AbstractClassDescriptor implements ClassDescriptor { @NotNull @Override - public KtType getDefaultType() { + public KotlinType getDefaultType() { return defaultType.invoke(); } diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/AbstractLazyTypeParameterDescriptor.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/AbstractLazyTypeParameterDescriptor.java index a9ccfa353e0..fd78fec339a 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/AbstractLazyTypeParameterDescriptor.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/AbstractLazyTypeParameterDescriptor.java @@ -26,7 +26,7 @@ import org.jetbrains.kotlin.descriptors.annotations.Annotations; import org.jetbrains.kotlin.name.Name; import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt; import org.jetbrains.kotlin.storage.StorageManager; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.TypeConstructor; import org.jetbrains.kotlin.types.Variance; @@ -53,7 +53,7 @@ public abstract class AbstractLazyTypeParameterDescriptor extends AbstractTypePa return new TypeConstructor() { @NotNull @Override - public Collection getSupertypes() { + public Collection getSupertypes() { return AbstractLazyTypeParameterDescriptor.this.getUpperBounds(); } diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/AbstractReceiverParameterDescriptor.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/AbstractReceiverParameterDescriptor.java index e5938e57958..6e21f769200 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/AbstractReceiverParameterDescriptor.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/AbstractReceiverParameterDescriptor.java @@ -22,7 +22,7 @@ import org.jetbrains.kotlin.descriptors.*; import org.jetbrains.kotlin.descriptors.annotations.Annotations; import org.jetbrains.kotlin.name.Name; import org.jetbrains.kotlin.resolve.scopes.receivers.TransientReceiver; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.TypeSubstitutor; import org.jetbrains.kotlin.types.Variance; @@ -41,7 +41,7 @@ public abstract class AbstractReceiverParameterDescriptor extends DeclarationDes @Override public ReceiverParameterDescriptor substitute(@NotNull TypeSubstitutor substitutor) { if (substitutor.isEmpty()) return this; - KtType substitutedType = substitutor.substitute(getType(), Variance.INVARIANT); + KotlinType substitutedType = substitutor.substitute(getType(), Variance.INVARIANT); if (substitutedType == null) return null; return new ReceiverParameterDescriptorImpl(getContainingDeclaration(), new TransientReceiver(substitutedType)); @@ -72,13 +72,13 @@ public abstract class AbstractReceiverParameterDescriptor extends DeclarationDes @Nullable @Override - public KtType getReturnType() { + public KotlinType getReturnType() { return getType(); } @NotNull @Override - public KtType getType() { + public KotlinType getType() { return getValue().getType(); } diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/AbstractTypeParameterDescriptor.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/AbstractTypeParameterDescriptor.java index 25ad9a1cac8..5346236a760 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/AbstractTypeParameterDescriptor.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/AbstractTypeParameterDescriptor.java @@ -43,9 +43,9 @@ public abstract class AbstractTypeParameterDescriptor extends DeclarationDescrip private final int index; private final NotNullLazyValue typeConstructor; - private final NotNullLazyValue defaultType; - private final NotNullLazyValue> upperBounds; - private final NotNullLazyValue upperBoundsAsType; + private final NotNullLazyValue defaultType; + private final NotNullLazyValue> upperBounds; + private final NotNullLazyValue upperBoundsAsType; protected AbstractTypeParameterDescriptor( @NotNull final StorageManager storageManager, @@ -68,11 +68,11 @@ public abstract class AbstractTypeParameterDescriptor extends DeclarationDescrip return createTypeConstructor(); } }); - this.defaultType = storageManager.createLazyValue(new Function0() { + this.defaultType = storageManager.createLazyValue(new Function0() { @Override - public KtType invoke() { - return KtTypeImpl.create(Annotations.Companion.getEMPTY(), getTypeConstructor(), false, Collections.emptyList(), - new LazyScopeAdapter(storageManager.createLazyValue( + public KotlinType invoke() { + return KotlinTypeImpl.create(Annotations.Companion.getEMPTY(), getTypeConstructor(), false, Collections.emptyList(), + new LazyScopeAdapter(storageManager.createLazyValue( new Function0() { @Override public KtScope invoke() { @@ -82,15 +82,15 @@ public abstract class AbstractTypeParameterDescriptor extends DeclarationDescrip ))); } }); - this.upperBounds = storageManager.createRecursionTolerantLazyValue(new Function0>() { + this.upperBounds = storageManager.createRecursionTolerantLazyValue(new Function0>() { @Override - public Set invoke() { + public Set invoke() { return resolveUpperBounds(); } }, Collections.singleton(ErrorUtils.createErrorType("Recursion while calculating upper bounds"))); - this.upperBoundsAsType = storageManager.createLazyValue(new Function0() { + this.upperBoundsAsType = storageManager.createLazyValue(new Function0() { @Override - public KtType invoke() { + public KotlinType invoke() { return computeUpperBoundsAsType(); } }); @@ -98,7 +98,7 @@ public abstract class AbstractTypeParameterDescriptor extends DeclarationDescrip @NotNull @ReadOnly - protected abstract Set resolveUpperBounds(); + protected abstract Set resolveUpperBounds(); @NotNull protected abstract TypeConstructor createTypeConstructor(); @@ -121,21 +121,21 @@ public abstract class AbstractTypeParameterDescriptor extends DeclarationDescrip @NotNull @Override - public Set getUpperBounds() { + public Set getUpperBounds() { return upperBounds.invoke(); } @NotNull @Override - public KtType getUpperBoundsAsType() { + public KotlinType getUpperBoundsAsType() { return upperBoundsAsType.invoke(); } @NotNull - private KtType computeUpperBoundsAsType() { - Set upperBounds = getUpperBounds(); + private KotlinType computeUpperBoundsAsType() { + Set upperBounds = getUpperBounds(); assert !upperBounds.isEmpty() : "Upper bound list is empty in " + getName(); - KtType upperBoundsAsType = TypeIntersector.intersectTypes(KotlinTypeChecker.DEFAULT, upperBounds); + KotlinType upperBoundsAsType = TypeIntersector.intersectTypes(KotlinTypeChecker.DEFAULT, upperBounds); return upperBoundsAsType != null ? upperBoundsAsType : getBuiltIns(this).getNothingType(); } @@ -147,13 +147,13 @@ public abstract class AbstractTypeParameterDescriptor extends DeclarationDescrip @NotNull @Override - public KtType getDefaultType() { + public KotlinType getDefaultType() { return defaultType.invoke(); } @NotNull @Override - public Set getLowerBounds() { + public Set getLowerBounds() { return Collections.singleton(getBuiltIns(this).getNothingType()); } diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/ClassDescriptorImpl.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/ClassDescriptorImpl.java index 62dd2012038..30b66b2b88a 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/ClassDescriptorImpl.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/ClassDescriptorImpl.java @@ -24,7 +24,7 @@ import org.jetbrains.kotlin.name.Name; import org.jetbrains.kotlin.resolve.scopes.KtScope; import org.jetbrains.kotlin.resolve.scopes.StaticScopeForKotlinClass; import org.jetbrains.kotlin.storage.LockBasedStorageManager; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.TypeConstructor; import org.jetbrains.kotlin.types.TypeConstructorImpl; @@ -45,7 +45,7 @@ public class ClassDescriptorImpl extends ClassDescriptorBase { @NotNull DeclarationDescriptor containingDeclaration, @NotNull Name name, @NotNull Modality modality, - @NotNull Collection supertypes, + @NotNull Collection supertypes, @NotNull SourceElement source ) { super(LockBasedStorageManager.NO_LOCKS, containingDeclaration, name, source); diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/EnumEntrySyntheticClassDescriptor.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/EnumEntrySyntheticClassDescriptor.java index 47d0e8cbfd0..b2eb7715cc1 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/EnumEntrySyntheticClassDescriptor.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/EnumEntrySyntheticClassDescriptor.java @@ -34,7 +34,7 @@ import org.jetbrains.kotlin.resolve.scopes.StaticScopeForKotlinClass; import org.jetbrains.kotlin.storage.MemoizedFunctionToNotNull; import org.jetbrains.kotlin.storage.NotNullLazyValue; import org.jetbrains.kotlin.storage.StorageManager; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.TypeConstructor; import org.jetbrains.kotlin.types.TypeConstructorImpl; import org.jetbrains.kotlin.utils.Printer; @@ -63,7 +63,7 @@ public class EnumEntrySyntheticClassDescriptor extends ClassDescriptorBase { @NotNull NotNullLazyValue> enumMemberNames, @NotNull SourceElement source ) { - KtType enumType = enumClass.getDefaultType(); + KotlinType enumType = enumClass.getDefaultType(); return new EnumEntrySyntheticClassDescriptor(storageManager, enumClass, enumType, name, enumMemberNames, source); } @@ -71,7 +71,7 @@ public class EnumEntrySyntheticClassDescriptor extends ClassDescriptorBase { private EnumEntrySyntheticClassDescriptor( @NotNull StorageManager storageManager, @NotNull ClassDescriptor containingClass, - @NotNull KtType supertype, + @NotNull KotlinType supertype, @NotNull Name name, @NotNull NotNullLazyValue> enumMemberNames, @NotNull SourceElement source @@ -225,7 +225,7 @@ public class EnumEntrySyntheticClassDescriptor extends ClassDescriptorBase { @NotNull private KtScope getSupertypeScope() { - Collection supertype = getTypeConstructor().getSupertypes(); + Collection supertype = getTypeConstructor().getSupertypes(); assert supertype.size() == 1 : "Enum entry and its companion object both should have exactly one supertype: " + supertype; return supertype.iterator().next().getMemberScope(); } diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/FunctionDescriptorImpl.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/FunctionDescriptorImpl.java index a2dbf88ae2d..ae4819d35af 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/FunctionDescriptorImpl.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/FunctionDescriptorImpl.java @@ -23,7 +23,7 @@ import org.jetbrains.kotlin.descriptors.annotations.Annotations; import org.jetbrains.kotlin.name.Name; import org.jetbrains.kotlin.resolve.DescriptorFactory; import org.jetbrains.kotlin.types.DescriptorSubstitutor; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.TypeSubstitutor; import org.jetbrains.kotlin.types.Variance; import org.jetbrains.kotlin.utils.CollectionsKt; @@ -37,7 +37,7 @@ import java.util.Set; public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRootImpl implements FunctionDescriptor { private List typeParameters; private List unsubstitutedValueParameters; - private KtType unsubstitutedReturnType; + private KotlinType unsubstitutedReturnType; private ReceiverParameterDescriptor extensionReceiverParameter; private ReceiverParameterDescriptor dispatchReceiverParameter; private Modality modality; @@ -66,11 +66,11 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo @NotNull public FunctionDescriptorImpl initialize( - @Nullable KtType receiverParameterType, + @Nullable KotlinType receiverParameterType, @Nullable ReceiverParameterDescriptor dispatchReceiverParameter, @NotNull List typeParameters, @NotNull List unsubstitutedValueParameters, - @Nullable KtType unsubstitutedReturnType, + @Nullable KotlinType unsubstitutedReturnType, @Nullable Modality modality, @NotNull Visibility visibility ) { @@ -125,7 +125,7 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo this.isTailrec = isTailrec; } - public void setReturnType(@NotNull KtType unsubstitutedReturnType) { + public void setReturnType(@NotNull KotlinType unsubstitutedReturnType) { if (this.unsubstitutedReturnType != null) { // TODO: uncomment and fix tests //throw new IllegalStateException("returnType already set"); @@ -228,7 +228,7 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo } @Override - public KtType getReturnType() { + public KotlinType getReturnType() { return unsubstitutedReturnType; } @@ -275,7 +275,7 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo } @Nullable - protected KtType getExtensionReceiverParameterType() { + protected KotlinType getExtensionReceiverParameterType() { if (extensionReceiverParameter == null) return null; return extensionReceiverParameter.getType(); } @@ -295,8 +295,8 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo boolean copyOverrides, @NotNull Kind kind, @NotNull List newValueParameterDescriptors, - @Nullable KtType newExtensionReceiverParameterType, - @NotNull KtType newReturnType + @Nullable KotlinType newExtensionReceiverParameterType, + @NotNull KotlinType newReturnType ) { FunctionDescriptorImpl substitutedDescriptor = createSubstitutedCopy(newOwner, original, kind); @@ -306,7 +306,7 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo originalTypeParameters, originalSubstitutor.getSubstitution(), substitutedDescriptor, substitutedTypeParameters ); - KtType substitutedReceiverParameterType = null; + KotlinType substitutedReceiverParameterType = null; if (newExtensionReceiverParameterType != null) { substitutedReceiverParameterType = substitutor.substitute(newExtensionReceiverParameterType, Variance.IN_VARIANCE); if (substitutedReceiverParameterType == null) { @@ -339,7 +339,7 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo return null; } - KtType substitutedReturnType = substitutor.substitute(newReturnType, Variance.OUT_VARIANCE); + KotlinType substitutedReturnType = substitutor.substitute(newReturnType, Variance.OUT_VARIANCE); if (substitutedReturnType == null) { return null; } @@ -389,9 +389,9 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo List result = new ArrayList(unsubstitutedValueParameters.size()); for (ValueParameterDescriptor unsubstitutedValueParameter : unsubstitutedValueParameters) { // TODO : Lazy? - KtType substitutedType = substitutor.substitute(unsubstitutedValueParameter.getType(), Variance.IN_VARIANCE); - KtType varargElementType = unsubstitutedValueParameter.getVarargElementType(); - KtType substituteVarargElementType = + KotlinType substitutedType = substitutor.substitute(unsubstitutedValueParameter.getType(), Variance.IN_VARIANCE); + KotlinType varargElementType = unsubstitutedValueParameter.getVarargElementType(); + KotlinType substituteVarargElementType = varargElementType == null ? null : substitutor.substitute(varargElementType, Variance.IN_VARIANCE); if (substitutedType == null) return null; result.add( diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/LazySubstitutingClassDescriptor.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/LazySubstitutingClassDescriptor.java index b271fd743b7..6144f8374dc 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/LazySubstitutingClassDescriptor.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/LazySubstitutingClassDescriptor.java @@ -68,9 +68,9 @@ public class LazySubstitutingClassDescriptor implements ClassDescriptor { if (typeConstructor == null) { TypeSubstitutor substitutor = getSubstitutor(); - Collection originalSupertypes = originalTypeConstructor.getSupertypes(); - Collection supertypes = new ArrayList(originalSupertypes.size()); - for (KtType supertype : originalSupertypes) { + Collection originalSupertypes = originalTypeConstructor.getSupertypes(); + Collection supertypes = new ArrayList(originalSupertypes.size()); + for (KotlinType supertype : originalSupertypes) { supertypes.add(substitutor.substitute(supertype, Variance.INVARIANT)); } @@ -125,9 +125,9 @@ public class LazySubstitutingClassDescriptor implements ClassDescriptor { @NotNull @Override - public KtType getDefaultType() { + public KotlinType getDefaultType() { List typeProjections = TypeUtils.getDefaultTypeProjections(getTypeConstructor().getParameters()); - return KtTypeImpl.create( + return KotlinTypeImpl.create( getAnnotations(), this, false, diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/PropertyDescriptorImpl.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/PropertyDescriptorImpl.java index 375f0fc9d58..ab49ecbcbe5 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/PropertyDescriptorImpl.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/PropertyDescriptorImpl.java @@ -24,7 +24,7 @@ import org.jetbrains.kotlin.descriptors.annotations.Annotations; import org.jetbrains.kotlin.name.Name; import org.jetbrains.kotlin.resolve.DescriptorFactory; import org.jetbrains.kotlin.types.DescriptorSubstitutor; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.TypeSubstitutor; import org.jetbrains.kotlin.types.Variance; import org.jetbrains.kotlin.utils.SmartSet; @@ -89,17 +89,17 @@ public class PropertyDescriptorImpl extends VariableDescriptorWithInitializerImp } public void setType( - @NotNull KtType outType, + @NotNull KotlinType outType, @ReadOnly @NotNull List typeParameters, @Nullable ReceiverParameterDescriptor dispatchReceiverParameter, - @Nullable KtType receiverType + @Nullable KotlinType receiverType ) { ReceiverParameterDescriptor extensionReceiverParameter = DescriptorFactory.createExtensionReceiverParameterForCallable(this, receiverType); setType(outType, typeParameters, dispatchReceiverParameter, extensionReceiverParameter); } public void setType( - @NotNull KtType outType, + @NotNull KotlinType outType, @ReadOnly @NotNull List typeParameters, @Nullable ReceiverParameterDescriptor dispatchReceiverParameter, @Nullable ReceiverParameterDescriptor extensionReceiverParameter @@ -145,7 +145,7 @@ public class PropertyDescriptorImpl extends VariableDescriptorWithInitializerImp @NotNull @Override - public KtType getReturnType() { + public KotlinType getReturnType() { return getType(); } @@ -227,8 +227,8 @@ public class PropertyDescriptorImpl extends VariableDescriptorWithInitializerImp originalTypeParameters, originalSubstitutor.getSubstitution(), substitutedDescriptor, substitutedTypeParameters ); - KtType originalOutType = getType(); - KtType outType = substitutor.substitute(originalOutType, Variance.OUT_VARIANCE); + KotlinType originalOutType = getType(); + KotlinType outType = substitutor.substitute(originalOutType, Variance.OUT_VARIANCE); if (outType == null) { return null; // TODO : tell the user that the property was projected out } @@ -244,7 +244,7 @@ public class PropertyDescriptorImpl extends VariableDescriptorWithInitializerImp substitutedDispatchReceiver = null; } - KtType substitutedReceiverType; + KotlinType substitutedReceiverType; if (extensionReceiverParameter != null) { substitutedReceiverType = substitutor.substitute(extensionReceiverParameter.getType(), Variance.IN_VARIANCE); if (substitutedReceiverType == null) return null; @@ -260,7 +260,7 @@ public class PropertyDescriptorImpl extends VariableDescriptorWithInitializerImp getter.hasBody(), getter.isDefault(), getter.isExternal(), kind, original == null ? null : original.getGetter(), SourceElement.NO_SOURCE ); if (newGetter != null) { - KtType returnType = getter.getReturnType(); + KotlinType returnType = getter.getReturnType(); newGetter.initialize(returnType != null ? substitutor.substitute(returnType, Variance.OUT_VARIANCE) : null); } PropertySetterDescriptorImpl newSetter = setter == null ? null : new PropertySetterDescriptorImpl( diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/PropertyGetterDescriptorImpl.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/PropertyGetterDescriptorImpl.java index 59216d6b506..bb7bf7d5064 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/PropertyGetterDescriptorImpl.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/PropertyGetterDescriptorImpl.java @@ -21,14 +21,14 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.descriptors.*; import org.jetbrains.kotlin.descriptors.annotations.Annotations; import org.jetbrains.kotlin.name.Name; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import java.util.Collection; import java.util.Collections; import java.util.List; public class PropertyGetterDescriptorImpl extends PropertyAccessorDescriptorImpl implements PropertyGetterDescriptor { - private KtType returnType; + private KotlinType returnType; @NotNull private final PropertyGetterDescriptor original; @@ -51,7 +51,7 @@ public class PropertyGetterDescriptorImpl extends PropertyAccessorDescriptorImpl this.original = original != null ? original : this; } - public void initialize(KtType returnType) { + public void initialize(KotlinType returnType) { this.returnType = returnType == null ? getCorrespondingProperty().getType() : returnType; } @@ -69,7 +69,7 @@ public class PropertyGetterDescriptorImpl extends PropertyAccessorDescriptorImpl } @Override - public KtType getReturnType() { + public KotlinType getReturnType() { return returnType; } diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/PropertySetterDescriptorImpl.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/PropertySetterDescriptorImpl.java index 82dfc2bc9e8..c1d71488bcb 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/PropertySetterDescriptorImpl.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/PropertySetterDescriptorImpl.java @@ -21,7 +21,7 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.descriptors.*; import org.jetbrains.kotlin.descriptors.annotations.Annotations; import org.jetbrains.kotlin.name.Name; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import java.util.Collection; import java.util.Collections; @@ -64,7 +64,7 @@ public class PropertySetterDescriptorImpl extends PropertyAccessorDescriptorImpl public static ValueParameterDescriptorImpl createSetterParameter( @NotNull PropertySetterDescriptor setterDescriptor, - @NotNull KtType type + @NotNull KotlinType type ) { return new ValueParameterDescriptorImpl( setterDescriptor, null, 0, Annotations.Companion.getEMPTY(), Name.special(""), type, @@ -93,7 +93,7 @@ public class PropertySetterDescriptorImpl extends PropertyAccessorDescriptorImpl @NotNull @Override - public KtType getReturnType() { + public KotlinType getReturnType() { return getBuiltIns(this).getUnitType(); } diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/ScriptCodeDescriptor.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/ScriptCodeDescriptor.java index a0a3452c9b0..45eb4a0ab40 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/ScriptCodeDescriptor.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/ScriptCodeDescriptor.java @@ -21,7 +21,7 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.descriptors.*; import org.jetbrains.kotlin.descriptors.annotations.Annotations; import org.jetbrains.kotlin.name.Name; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import java.util.Collections; import java.util.List; @@ -35,7 +35,7 @@ public class ScriptCodeDescriptor extends FunctionDescriptorImpl { public void initialize( @NotNull ReceiverParameterDescriptor dispatchReceiverParameter, @NotNull List valueParameters, - @NotNull KtType returnType) { + @NotNull KotlinType returnType) { super.initialize(null, dispatchReceiverParameter, Collections.emptyList(), valueParameters, returnType, Modality.FINAL, Visibilities.INTERNAL); } diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/SimpleFunctionDescriptorImpl.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/SimpleFunctionDescriptorImpl.java index 1f36e973fc0..1f64434f911 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/SimpleFunctionDescriptorImpl.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/SimpleFunctionDescriptorImpl.java @@ -21,7 +21,7 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.descriptors.*; import org.jetbrains.kotlin.descriptors.annotations.Annotations; import org.jetbrains.kotlin.name.Name; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.TypeSubstitutor; import java.util.List; @@ -52,11 +52,11 @@ public class SimpleFunctionDescriptorImpl extends FunctionDescriptorImpl impleme @NotNull @Override public SimpleFunctionDescriptorImpl initialize( - @Nullable KtType receiverParameterType, + @Nullable KotlinType receiverParameterType, @Nullable ReceiverParameterDescriptor dispatchReceiverParameter, @NotNull List typeParameters, @NotNull List unsubstitutedValueParameters, - @Nullable KtType unsubstitutedReturnType, + @Nullable KotlinType unsubstitutedReturnType, @Nullable Modality modality, @NotNull Visibility visibility ) { diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/TypeParameterDescriptorImpl.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/TypeParameterDescriptorImpl.java index af310a90ce3..5cc2badc3f7 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/TypeParameterDescriptorImpl.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/TypeParameterDescriptorImpl.java @@ -24,7 +24,7 @@ import org.jetbrains.kotlin.descriptors.annotations.Annotations; import org.jetbrains.kotlin.name.Name; import org.jetbrains.kotlin.resolve.DescriptorUtils; import org.jetbrains.kotlin.storage.LockBasedStorageManager; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.TypeConstructor; import org.jetbrains.kotlin.types.TypeConstructorImpl; import org.jetbrains.kotlin.types.Variance; @@ -63,7 +63,7 @@ public class TypeParameterDescriptorImpl extends AbstractTypeParameterDescriptor return new TypeParameterDescriptorImpl(containingDeclaration, annotations, reified, variance, name, index, source); } - private final Set upperBounds = SmartSet.create(); + private final Set upperBounds = SmartSet.create(); private boolean initialized = false; private TypeParameterDescriptorImpl( @@ -113,12 +113,12 @@ public class TypeParameterDescriptorImpl extends AbstractTypeParameterDescriptor initialized = true; } - public void addUpperBound(@NotNull KtType bound) { + public void addUpperBound(@NotNull KotlinType bound) { checkUninitialized(); doAddUpperBound(bound); } - private void doAddUpperBound(KtType bound) { + private void doAddUpperBound(KotlinType bound) { upperBounds.add(bound); // TODO : Duplicates? } @@ -132,7 +132,7 @@ public class TypeParameterDescriptorImpl extends AbstractTypeParameterDescriptor @NotNull @Override - protected Set resolveUpperBounds() { + protected Set resolveUpperBounds() { checkInitialized(); return upperBounds; } diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/ValueParameterDescriptorImpl.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/ValueParameterDescriptorImpl.java index 92c9d585a41..0e7fe7ee85e 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/ValueParameterDescriptorImpl.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/ValueParameterDescriptorImpl.java @@ -24,7 +24,7 @@ import org.jetbrains.kotlin.descriptors.*; import org.jetbrains.kotlin.descriptors.annotations.Annotations; import org.jetbrains.kotlin.name.Name; import org.jetbrains.kotlin.resolve.constants.ConstantValue; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.TypeSubstitutor; import java.util.Collection; @@ -33,7 +33,7 @@ public class ValueParameterDescriptorImpl extends VariableDescriptorImpl impleme private final boolean declaresDefaultValue; private final boolean isCrossinline; private final boolean isNoinline; - private final KtType varargElementType; + private final KotlinType varargElementType; private final int index; private final ValueParameterDescriptor original; @@ -43,11 +43,11 @@ public class ValueParameterDescriptorImpl extends VariableDescriptorImpl impleme int index, @NotNull Annotations annotations, @NotNull Name name, - @NotNull KtType outType, + @NotNull KotlinType outType, boolean declaresDefaultValue, boolean isCrossinline, boolean isNoinline, - @Nullable KtType varargElementType, + @Nullable KotlinType varargElementType, @NotNull SourceElement source ) { super(containingDeclaration, annotations, name, outType, source); @@ -87,7 +87,7 @@ public class ValueParameterDescriptorImpl extends VariableDescriptorImpl impleme @Nullable @Override - public KtType getVarargElementType() { + public KotlinType getVarargElementType() { return varargElementType; } diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/VariableDescriptorImpl.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/VariableDescriptorImpl.java index 5963ade905d..cce427321af 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/VariableDescriptorImpl.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/VariableDescriptorImpl.java @@ -21,20 +21,20 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.descriptors.*; import org.jetbrains.kotlin.descriptors.annotations.Annotations; import org.jetbrains.kotlin.name.Name; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import java.util.Collection; import java.util.Collections; import java.util.List; public abstract class VariableDescriptorImpl extends DeclarationDescriptorNonRootImpl implements VariableDescriptor { - protected KtType outType; + protected KotlinType outType; public VariableDescriptorImpl( @NotNull DeclarationDescriptor containingDeclaration, @NotNull Annotations annotations, @NotNull Name name, - @Nullable KtType outType, + @Nullable KotlinType outType, @NotNull SourceElement source ) { super(containingDeclaration, annotations, name, source); @@ -44,11 +44,11 @@ public abstract class VariableDescriptorImpl extends DeclarationDescriptorNonRoo @NotNull @Override - public KtType getType() { + public KotlinType getType() { return outType; } - public void setOutType(KtType outType) { + public void setOutType(KotlinType outType) { assert this.outType == null; this.outType = outType; } @@ -99,7 +99,7 @@ public abstract class VariableDescriptorImpl extends DeclarationDescriptorNonRoo @NotNull @Override - public KtType getReturnType() { + public KotlinType getReturnType() { return getType(); } diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/VariableDescriptorWithInitializerImpl.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/VariableDescriptorWithInitializerImpl.java index 2fc71c19c7e..41eab86f85f 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/VariableDescriptorWithInitializerImpl.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/VariableDescriptorWithInitializerImpl.java @@ -24,7 +24,7 @@ import org.jetbrains.kotlin.descriptors.annotations.Annotations; import org.jetbrains.kotlin.name.Name; import org.jetbrains.kotlin.resolve.constants.ConstantValue; import org.jetbrains.kotlin.storage.NullableLazyValue; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.LazyType; public abstract class VariableDescriptorWithInitializerImpl extends VariableDescriptorImpl { @@ -36,7 +36,7 @@ public abstract class VariableDescriptorWithInitializerImpl extends VariableDesc @NotNull DeclarationDescriptor containingDeclaration, @NotNull Annotations annotations, @NotNull Name name, - @Nullable KtType outType, + @Nullable KotlinType outType, boolean isVar, @NotNull SourceElement source ) { diff --git a/core/descriptors/src/org/jetbrains/kotlin/renderer/CustomRendering.kt b/core/descriptors/src/org/jetbrains/kotlin/renderer/CustomRendering.kt index 013e07aa2e2..035004ec483 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/renderer/CustomRendering.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/renderer/CustomRendering.kt @@ -17,10 +17,10 @@ package org.jetbrains.kotlin.renderer import org.jetbrains.kotlin.types.Flexibility -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeCapability public interface CustomFlexibleRendering : TypeCapability { - public fun renderInflexible(type: KtType, renderer: DescriptorRenderer): String? + public fun renderInflexible(type: KotlinType, renderer: DescriptorRenderer): String? public fun renderBounds(flexibility: Flexibility, renderer: DescriptorRenderer): Pair? } diff --git a/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRenderer.kt b/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRenderer.kt index 1be5fcead6a..61cabf2ad33 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRenderer.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRenderer.kt @@ -22,7 +22,7 @@ import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.FqNameBase import org.jetbrains.kotlin.name.Name -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeConstructor import org.jetbrains.kotlin.types.TypeProjection @@ -34,7 +34,7 @@ public abstract class DescriptorRenderer : Renderer { return DescriptorRendererImpl(options) } - public abstract fun renderType(type: KtType): String + public abstract fun renderType(type: KotlinType): String public abstract fun renderTypeArguments(typeArguments: List): String @@ -184,7 +184,7 @@ public interface DescriptorRendererOptions { public var receiverAfterName: Boolean public var renderCompanionObjectName: Boolean public var withoutSuperTypes: Boolean - public var typeNormalizer: (KtType) -> KtType + public var typeNormalizer: (KotlinType) -> KotlinType public var renderDefaultValues: Boolean public var flexibleTypesForCode: Boolean public var secondaryConstructorsAsPrimary: Boolean diff --git a/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt index b63460dcca5..99de0e9379e 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt @@ -146,11 +146,11 @@ internal class DescriptorRendererImpl( } /* TYPES RENDERING */ - override fun renderType(type: KtType): String { + override fun renderType(type: KotlinType): String { return renderNormalizedType(typeNormalizer(type)) } - private fun renderNormalizedType(type: KtType): String { + private fun renderNormalizedType(type: KotlinType): String { if (type is LazyType && debugMode) { return type.toString() } @@ -172,13 +172,13 @@ internal class DescriptorRendererImpl( return renderInflexibleType(type) } - private fun renderFlexibleTypeWithBothBounds(lower: KtType, upper: KtType): String { + private fun renderFlexibleTypeWithBothBounds(lower: KotlinType, upper: KotlinType): String { return renderFlexibleTypeWithBothBounds(renderNormalizedType(lower), renderNormalizedType(upper)) } private fun renderFlexibleTypeWithBothBounds(lower: String, upper: String) = "($lower..$upper)" - private fun renderInflexibleType(type: KtType): String { + private fun renderInflexibleType(type: KotlinType): String { assert(!type.isFlexible()) { "Flexible types not allowed here: " + renderNormalizedType(type) } val customResult = type.getCapability()?.renderInflexible(type, this) @@ -202,12 +202,12 @@ internal class DescriptorRendererImpl( return renderDefaultType(type) } - private fun shouldRenderAsPrettyFunctionType(type: KtType): Boolean { + private fun shouldRenderAsPrettyFunctionType(type: KotlinType): Boolean { return prettyFunctionTypes && KotlinBuiltIns.isExactFunctionOrExtensionFunctionType(type) && type.getArguments().none { it.isStarProjection() } } - private fun renderFlexibleType(type: KtType): String { + private fun renderFlexibleType(type: KotlinType): String { val lower = type.flexibility().lowerBound val upper = type.flexibility().upperBound @@ -246,7 +246,7 @@ internal class DescriptorRendererImpl( }.toString() } - private fun renderDefaultType(type: KtType): String { + private fun renderDefaultType(type: KotlinType): String { val sb = StringBuilder() renderAnnotations(type, sb, /* needBrackets = */ true) @@ -290,7 +290,7 @@ internal class DescriptorRendererImpl( }.joinTo(builder, ", ") } - private fun renderFunctionType(type: KtType): String { + private fun renderFunctionType(type: KotlinType): String { return StringBuilder { val isNullable = type.isMarkedNullable() if (isNullable) append("(") @@ -338,7 +338,7 @@ internal class DescriptorRendererImpl( private fun renderAnnotations(annotated: Annotated, builder: StringBuilder, needBrackets: Boolean = false) { if (DescriptorRendererModifier.ANNOTATIONS !in modifiers) return - val excluded = if (annotated is KtType) excludedTypeAnnotationClasses else excludedAnnotationClasses + val excluded = if (annotated is KotlinType) excludedTypeAnnotationClasses else excludedAnnotationClasses val annotationsBuilder = StringBuilder { // Sort is needed just to fix some order when annotations resolved from modifiers diff --git a/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererOptionsImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererOptionsImpl.kt index a5370f57d25..0d4235cfcc9 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererOptionsImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererOptionsImpl.kt @@ -17,7 +17,7 @@ package org.jetbrains.kotlin.renderer import org.jetbrains.kotlin.name.FqName -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import java.lang.reflect.Modifier import kotlin.properties.Delegates import kotlin.properties.ObservableProperty @@ -92,7 +92,7 @@ internal class DescriptorRendererOptionsImpl : DescriptorRendererOptions { override var includePropertyConstant by property(false) override var withoutTypeParameters by property(false) override var withoutSuperTypes by property(false) - override var typeNormalizer by property<(KtType) -> KtType>({ it }) + override var typeNormalizer by property<(KotlinType) -> KotlinType>({ it }) override var renderDefaultValues by property(true) override var flexibleTypesForCode by property(false) override var secondaryConstructorsAsPrimary by property(true) diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorFactory.java b/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorFactory.java index f9e0f049372..641cf40edfc 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorFactory.java +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorFactory.java @@ -25,7 +25,7 @@ import org.jetbrains.kotlin.descriptors.annotations.AnnotationsImpl; import org.jetbrains.kotlin.descriptors.impl.*; import org.jetbrains.kotlin.name.Name; import org.jetbrains.kotlin.resolve.scopes.receivers.ExtensionReceiver; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.Variance; import java.util.Collections; @@ -141,13 +141,13 @@ public class DescriptorFactory { /* lateInit = */ false, /* isConst = */ false ); - KtType type = getBuiltIns(enumClass).getArrayType(Variance.INVARIANT, enumClass.getDefaultType()); + KotlinType type = getBuiltIns(enumClass).getArrayType(Variance.INVARIANT, enumClass.getDefaultType()); PropertyGetterDescriptorImpl getter = createDefaultGetter(values, Annotations.Companion.getEMPTY()); values.initialize(getter, null); getter.initialize(type); - values.setType(type, Collections.emptyList(), null, (KtType) null); + values.setType(type, Collections.emptyList(), null, (KotlinType) null); return values; } @@ -173,7 +173,7 @@ public class DescriptorFactory { @Nullable public static ReceiverParameterDescriptor createExtensionReceiverParameterForCallable( @NotNull CallableDescriptor owner, - @Nullable KtType receiverParameterType + @Nullable KotlinType receiverParameterType ) { return receiverParameterType == null ? null diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorUtils.java b/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorUtils.java index ea0d77b633d..3ae4b3cff4f 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorUtils.java +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorUtils.java @@ -38,7 +38,7 @@ import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter; import org.jetbrains.kotlin.resolve.scopes.FilteringScope; import org.jetbrains.kotlin.resolve.scopes.KtScope; import org.jetbrains.kotlin.types.ErrorUtils; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.LazyType; import org.jetbrains.kotlin.types.TypeConstructor; import org.jetbrains.kotlin.types.checker.KotlinTypeChecker; @@ -244,7 +244,7 @@ public class DescriptorUtils { } public static boolean isDirectSubclass(@NotNull ClassDescriptor subClass, @NotNull ClassDescriptor superClass) { - for (KtType superType : subClass.getTypeConstructor().getSupertypes()) { + for (KotlinType superType : subClass.getTypeConstructor().getSupertypes()) { if (isSameClass(superType, superClass.getOriginal())) { return true; } @@ -256,7 +256,7 @@ public class DescriptorUtils { return isSubtypeOfClass(subClass.getDefaultType(), superClass.getOriginal()); } - private static boolean isSameClass(@NotNull KtType type, @NotNull DeclarationDescriptor other) { + private static boolean isSameClass(@NotNull KotlinType type, @NotNull DeclarationDescriptor other) { DeclarationDescriptor descriptor = type.getConstructor().getDeclarationDescriptor(); if (descriptor != null) { DeclarationDescriptor originalDescriptor = descriptor.getOriginal(); @@ -270,9 +270,9 @@ public class DescriptorUtils { return false; } - private static boolean isSubtypeOfClass(@NotNull KtType type, @NotNull DeclarationDescriptor superClass) { + private static boolean isSubtypeOfClass(@NotNull KotlinType type, @NotNull DeclarationDescriptor superClass) { if (isSameClass(type, superClass)) return true; - for (KtType superType : type.getConstructor().getSupertypes()) { + for (KotlinType superType : type.getConstructor().getSupertypes()) { if (isSubtypeOfClass(superType, superClass)) { return true; } @@ -349,9 +349,9 @@ public class DescriptorUtils { @NotNull public static List getSuperclassDescriptors(@NotNull ClassDescriptor classDescriptor) { - Collection superclassTypes = classDescriptor.getTypeConstructor().getSupertypes(); + Collection superclassTypes = classDescriptor.getTypeConstructor().getSupertypes(); List superClassDescriptors = new ArrayList(); - for (KtType type : superclassTypes) { + for (KotlinType type : superclassTypes) { ClassDescriptor result = getClassDescriptorForType(type); if (!isAny(result)) { superClassDescriptors.add(result); @@ -361,9 +361,9 @@ public class DescriptorUtils { } @NotNull - public static KtType getSuperClassType(@NotNull ClassDescriptor classDescriptor) { - Collection superclassTypes = classDescriptor.getTypeConstructor().getSupertypes(); - for (KtType type : superclassTypes) { + public static KotlinType getSuperClassType(@NotNull ClassDescriptor classDescriptor) { + Collection superclassTypes = classDescriptor.getTypeConstructor().getSupertypes(); + for (KotlinType type : superclassTypes) { ClassDescriptor superClassDescriptor = getClassDescriptorForType(type); if (superClassDescriptor.getKind() != ClassKind.INTERFACE) { return type; @@ -374,8 +374,8 @@ public class DescriptorUtils { @Nullable public static ClassDescriptor getSuperClassDescriptor(@NotNull ClassDescriptor classDescriptor) { - Collection superclassTypes = classDescriptor.getTypeConstructor().getSupertypes(); - for (KtType type : superclassTypes) { + Collection superclassTypes = classDescriptor.getTypeConstructor().getSupertypes(); + for (KotlinType type : superclassTypes) { ClassDescriptor superClassDescriptor = getClassDescriptorForType(type); if (superClassDescriptor.getKind() != ClassKind.INTERFACE) { return superClassDescriptor; @@ -385,7 +385,7 @@ public class DescriptorUtils { } @NotNull - public static ClassDescriptor getClassDescriptorForType(@NotNull KtType type) { + public static ClassDescriptor getClassDescriptorForType(@NotNull KotlinType type) { return getClassDescriptorForTypeConstructor(type.getConstructor()); } @@ -422,7 +422,7 @@ public class DescriptorUtils { } @Nullable - public static KtType getReceiverParameterType(@Nullable ReceiverParameterDescriptor receiverParameterDescriptor) { + public static KotlinType getReceiverParameterType(@Nullable ReceiverParameterDescriptor receiverParameterDescriptor) { return receiverParameterDescriptor == null ? null : receiverParameterDescriptor.getType(); } @@ -474,7 +474,7 @@ public class DescriptorUtils { return descriptor; } - public static boolean shouldRecordInitializerForProperty(@NotNull VariableDescriptor variable, @NotNull KtType type) { + public static boolean shouldRecordInitializerForProperty(@NotNull VariableDescriptor variable, @NotNull KotlinType type) { if (variable.isVar() || type.isError()) return false; if (type instanceof LazyType || type.isMarkedNullable()) return true; diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorUtils.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorUtils.kt index cc972d9197c..f5e1ed3c0c7 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorUtils.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorUtils.kt @@ -29,7 +29,7 @@ import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.FqNameUnsafe import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.constants.EnumValue -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.utils.DFS public fun ClassDescriptor.getClassObjectReferenceTarget(): ClassDescriptor = getCompanionObjectDescriptor() ?: this @@ -74,7 +74,7 @@ public val ClassDescriptor.classId: ClassId public val ClassDescriptor.hasClassObjectType: Boolean get() = classObjectType != null /** If a literal of this class can be used as a value, returns the type of this value */ -public val ClassDescriptor.classObjectType: KtType? +public val ClassDescriptor.classObjectType: KotlinType? get() { val correspondingDescriptor = when (this.getKind()) { OBJECT -> this diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/OverridingUtil.java b/core/descriptors/src/org/jetbrains/kotlin/resolve/OverridingUtil.java index aab13518a0e..c366cc99ddc 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/OverridingUtil.java +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/OverridingUtil.java @@ -27,7 +27,7 @@ import org.jetbrains.kotlin.descriptors.impl.PropertyAccessorDescriptorImpl; import org.jetbrains.kotlin.descriptors.impl.PropertyDescriptorImpl; import org.jetbrains.kotlin.name.Name; import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.TypeConstructor; import org.jetbrains.kotlin.types.checker.KotlinTypeChecker; import org.jetbrains.kotlin.utils.DFS; @@ -98,16 +98,16 @@ public class OverridingUtil { return receiverAndParameterResult; } - List superValueParameters = compiledValueParameters(superDescriptor); - List subValueParameters = compiledValueParameters(subDescriptor); + List superValueParameters = compiledValueParameters(superDescriptor); + List subValueParameters = compiledValueParameters(subDescriptor); List superTypeParameters = superDescriptor.getTypeParameters(); List subTypeParameters = subDescriptor.getTypeParameters(); if (superTypeParameters.size() != subTypeParameters.size()) { for (int i = 0; i < superValueParameters.size(); ++i) { - KtType superValueParameterType = getUpperBound(superValueParameters.get(i)); - KtType subValueParameterType = getUpperBound(subValueParameters.get(i)); + KotlinType superValueParameterType = getUpperBound(superValueParameters.get(i)); + KotlinType subValueParameterType = getUpperBound(subValueParameters.get(i)); // TODO: compare erasure if (!KotlinTypeChecker.DEFAULT.equalTypes(superValueParameterType, subValueParameterType)) { return OverrideCompatibilityInfo.typeParameterNumberMismatch(); @@ -147,8 +147,8 @@ public class OverridingUtil { } for (int i = 0, unsubstitutedValueParametersSize = superValueParameters.size(); i < unsubstitutedValueParametersSize; i++) { - KtType superValueParameter = superValueParameters.get(i); - KtType subValueParameter = subValueParameters.get(i); + KotlinType superValueParameter = superValueParameters.get(i); + KotlinType subValueParameter = subValueParameters.get(i); if (!areTypesEquivalent(superValueParameter, subValueParameter, localEqualityAxioms)) { return OverrideCompatibilityInfo.valueParameterTypeMismatch(superValueParameter, subValueParameter, INCOMPATIBLE); @@ -156,8 +156,8 @@ public class OverridingUtil { } if (checkReturnType) { - KtType superReturnType = superDescriptor.getReturnType(); - KtType subReturnType = subDescriptor.getReturnType(); + KotlinType superReturnType = superDescriptor.getReturnType(); + KotlinType subReturnType = subDescriptor.getReturnType(); if (superReturnType != null && subReturnType != null) { boolean bothErrors = subReturnType.isError() && superReturnType.isError(); @@ -194,8 +194,8 @@ public class OverridingUtil { } private static boolean areTypesEquivalent( - @NotNull KtType typeInSuper, - @NotNull KtType typeInSub, + @NotNull KotlinType typeInSuper, + @NotNull KotlinType typeInSub, @NotNull KotlinTypeChecker.TypeConstructorEquality axioms ) { boolean bothErrors = typeInSuper.isError() && typeInSub.isError(); @@ -205,9 +205,9 @@ public class OverridingUtil { return true; } - static List compiledValueParameters(CallableDescriptor callableDescriptor) { + static List compiledValueParameters(CallableDescriptor callableDescriptor) { ReceiverParameterDescriptor receiverParameter = callableDescriptor.getExtensionReceiverParameter(); - ArrayList parameters = new ArrayList(); + ArrayList parameters = new ArrayList(); if (receiverParameter != null) { parameters.add(receiverParameter.getType()); } @@ -217,7 +217,7 @@ public class OverridingUtil { return parameters; } - static KtType getUpperBound(KtType type) { + static KotlinType getUpperBound(KotlinType type) { if (type.getConstructor().getDeclarationDescriptor() instanceof ClassDescriptor) { return type; } @@ -297,9 +297,9 @@ public class OverridingUtil { if (a instanceof SimpleFunctionDescriptor) { assert b instanceof SimpleFunctionDescriptor : "b is " + b.getClass(); - KtType aReturnType = a.getReturnType(); + KotlinType aReturnType = a.getReturnType(); assert aReturnType != null; - KtType bReturnType = b.getReturnType(); + KotlinType bReturnType = b.getReturnType(); assert bReturnType != null; return KotlinTypeChecker.DEFAULT.isSubtypeOf(aReturnType, bReturnType); @@ -569,7 +569,7 @@ public class OverridingUtil { } @NotNull - public static OverrideCompatibilityInfo valueParameterTypeMismatch(KtType superValueParameter, KtType subValueParameter, Result result) { + public static OverrideCompatibilityInfo valueParameterTypeMismatch(KotlinType superValueParameter, KotlinType subValueParameter, Result result) { return new OverrideCompatibilityInfo(result, "valueParameterTypeMismatch"); // TODO } @@ -579,7 +579,7 @@ public class OverridingUtil { } @NotNull - public static OverrideCompatibilityInfo returnTypeMismatch(KtType substitutedSuperReturnType, KtType unsubstitutedSubReturnType) { + public static OverrideCompatibilityInfo returnTypeMismatch(KotlinType substitutedSuperReturnType, KotlinType unsubstitutedSubReturnType) { return new OverrideCompatibilityInfo(Result.CONFLICT, "returnTypeMismatch: " + unsubstitutedSubReturnType + " >< " + substitutedSuperReturnType); // TODO } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/annotationsForResolve.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/annotationsForResolve.kt index 09b469e2449..c4ba2bc8f38 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/annotationsForResolve.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/annotationsForResolve.kt @@ -20,14 +20,14 @@ import org.jetbrains.kotlin.descriptors.CallableDescriptor import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor import org.jetbrains.kotlin.descriptors.annotations.Annotations import org.jetbrains.kotlin.name.FqName -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType private val NO_INFER_ANNOTATION_FQ_NAME = FqName("kotlin.internal.NoInfer") private val EXACT_ANNOTATION_FQ_NAME = FqName("kotlin.internal.Exact") -public fun KtType.hasNoInferAnnotation(): Boolean = annotations.hasAnnotation(NO_INFER_ANNOTATION_FQ_NAME) +public fun KotlinType.hasNoInferAnnotation(): Boolean = annotations.hasAnnotation(NO_INFER_ANNOTATION_FQ_NAME) -public fun KtType.hasExactAnnotation(): Boolean = annotations.hasAnnotation(EXACT_ANNOTATION_FQ_NAME) +public fun KotlinType.hasExactAnnotation(): Boolean = annotations.hasAnnotation(EXACT_ANNOTATION_FQ_NAME) public fun Annotations.hasInternalAnnotationForResolve(): Boolean = hasAnnotation(NO_INFER_ANNOTATION_FQ_NAME) || hasAnnotation(EXACT_ANNOTATION_FQ_NAME) diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/CapturedTypeConstructor.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/CapturedTypeConstructor.kt index c8e0d8fc1d7..26bef2ba240 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/CapturedTypeConstructor.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/CapturedTypeConstructor.kt @@ -35,7 +35,7 @@ public class CapturedTypeConstructor( override fun getParameters(): List = listOf() - override fun getSupertypes(): Collection { + override fun getSupertypes(): Collection { val superType = if (typeProjection.getProjectionKind() == Variance.OUT_VARIANCE) typeProjection.getType() else @@ -63,10 +63,10 @@ public class CapturedType( private val delegateType = run { val scope = ErrorUtils.createErrorScope( "No member resolution should be done on captured type, it used only during constraint system resolution", true) - KtTypeImpl.create(Annotations.EMPTY, CapturedTypeConstructor(typeProjection), false, listOf(), scope) + KotlinTypeImpl.create(Annotations.EMPTY, CapturedTypeConstructor(typeProjection), false, listOf(), scope) } - override fun getDelegate(): KtType = delegateType + override fun getDelegate(): KotlinType = delegateType override fun getCapability(capabilityClass: Class): T? { @Suppress("UNCHECKED_CAST") @@ -74,20 +74,20 @@ public class CapturedType( else super.getCapability(capabilityClass) } - override val subTypeRepresentative: KtType + override val subTypeRepresentative: KotlinType get() = representative(OUT_VARIANCE, builtIns.nullableAnyType) - override val superTypeRepresentative: KtType + override val superTypeRepresentative: KotlinType get() = representative(IN_VARIANCE, builtIns.nothingType) - private fun representative(variance: Variance, default: KtType) = + private fun representative(variance: Variance, default: KotlinType) = if (typeProjection.getProjectionKind() == variance) typeProjection.getType() else default - override fun sameTypeConstructor(type: KtType) = delegateType.getConstructor() === type.getConstructor() + override fun sameTypeConstructor(type: KotlinType) = delegateType.getConstructor() === type.getConstructor() override fun toString() = "Captured($typeProjection)" } -public fun createCapturedType(typeProjection: TypeProjection): KtType = CapturedType(typeProjection) +public fun createCapturedType(typeProjection: TypeProjection): KotlinType = CapturedType(typeProjection) -public fun KtType.isCaptured(): Boolean = getConstructor() is CapturedTypeConstructor +public fun KotlinType.isCaptured(): Boolean = getConstructor() is CapturedTypeConstructor diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystem.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystem.kt index dea4ec15291..c75e2b98f78 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystem.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystem.kt @@ -18,7 +18,7 @@ package org.jetbrains.kotlin.resolve.calls.inference import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPosition -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeSubstitutor import org.jetbrains.kotlin.types.Variance @@ -47,7 +47,7 @@ public interface ConstraintSystem { * For example, for {@code "fun id(t: T) {}"} to infer T in invocation "id(1)" * should be generated a constraint "Int is a subtype of T" where T is a subject type, and Int is a constraining type. */ - public fun addSubtypeConstraint(constrainingType: KtType?, subjectType: KtType, constraintPosition: ConstraintPosition) + public fun addSubtypeConstraint(constrainingType: KotlinType?, subjectType: KotlinType, constraintPosition: ConstraintPosition) /** * Adds a constraint that the constraining type is a supertype of the subject type.

@@ -56,7 +56,7 @@ public interface ConstraintSystem { * For example, for {@code "fun create() : T"} to infer T in invocation "val i: Int = create()" * should be generated a constraint "Int is a supertype of T" where T is a subject type, and Int is a constraining type. */ - public fun addSupertypeConstraint(constrainingType: KtType?, subjectType: KtType, constraintPosition: ConstraintPosition) + public fun addSupertypeConstraint(constrainingType: KotlinType?, subjectType: KotlinType, constraintPosition: ConstraintPosition) public fun getStatus(): ConstraintSystemStatus diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt index c3863626641..d00a7b1a90d 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt @@ -45,7 +45,7 @@ import java.util.* public class ConstraintSystemImpl : ConstraintSystem { - data class Constraint(val kind: ConstraintKind, val subtype: KtType, val superType: KtType, val position: ConstraintPosition) + data class Constraint(val kind: ConstraintKind, val subtype: KotlinType, val superType: KotlinType, val position: ConstraintPosition) public enum class ConstraintKind { SUB_TYPE, @@ -60,7 +60,7 @@ public class ConstraintSystemImpl : ConstraintSystem { get() = if (externalTypeParameters.isEmpty()) allTypeParameterBounds else allTypeParameterBounds.filter { !externalTypeParameters.contains(it.key) } - private val cachedTypeForVariable = HashMap() + private val cachedTypeForVariable = HashMap() private val usedInBounds = HashMap>() @@ -165,16 +165,16 @@ public class ConstraintSystemImpl : ConstraintSystem { } } - val TypeParameterDescriptor.correspondingType: KtType + val TypeParameterDescriptor.correspondingType: KotlinType get() = cachedTypeForVariable.getOrPut(this) { - KtTypeImpl.create(Annotations.EMPTY, this.getTypeConstructor(), false, listOf(), KtScope.Empty) + KotlinTypeImpl.create(Annotations.EMPTY, this.getTypeConstructor(), false, listOf(), KtScope.Empty) } - fun KtType.isProper() = !TypeUtils.containsSpecialType(this) { + fun KotlinType.isProper() = !TypeUtils.containsSpecialType(this) { type -> type.getConstructor().getDeclarationDescriptor() in getAllTypeVariables() } - fun KtType.getNestedTypeVariables(original: Boolean = true): List { + fun KotlinType.getNestedTypeVariables(original: Boolean = true): List { return getNestedArguments().map { typeProjection -> typeProjection.getType().getConstructor().getDeclarationDescriptor() as? TypeParameterDescriptor }.filterNotNull().filter { if (original) it in originalToVariables.keySet() else it in getAllTypeVariables() } @@ -206,22 +206,22 @@ public class ConstraintSystemImpl : ConstraintSystem { return newSystem } - override fun addSupertypeConstraint(constrainingType: KtType?, subjectType: KtType, constraintPosition: ConstraintPosition) { + override fun addSupertypeConstraint(constrainingType: KotlinType?, subjectType: KotlinType, constraintPosition: ConstraintPosition) { if (constrainingType != null && TypeUtils.noExpectedType(constrainingType)) return val newSubjectType = originalToVariablesSubstitutor.substitute(subjectType, Variance.INVARIANT) addConstraint(SUB_TYPE, newSubjectType, constrainingType, ConstraintContext(constraintPosition, initial = true)) } - override fun addSubtypeConstraint(constrainingType: KtType?, subjectType: KtType, constraintPosition: ConstraintPosition) { + override fun addSubtypeConstraint(constrainingType: KotlinType?, subjectType: KotlinType, constraintPosition: ConstraintPosition) { val newSubjectType = originalToVariablesSubstitutor.substitute(subjectType, Variance.INVARIANT) addConstraint(SUB_TYPE, constrainingType, newSubjectType, ConstraintContext(constraintPosition, initial = true)) } fun addConstraint( constraintKind: ConstraintKind, - subType: KtType?, - superType: KtType?, + subType: KotlinType?, + superType: KotlinType?, constraintContext: ConstraintContext ) { val constraintPosition = constraintContext.position @@ -231,7 +231,7 @@ public class ConstraintSystemImpl : ConstraintSystem { val typeCheckingProcedure = TypeCheckingProcedure(object : TypeCheckingProcedureCallbacks { private var depth = 0 - override fun assertEqualTypes(a: KtType, b: KtType, typeCheckingProcedure: TypeCheckingProcedure): Boolean { + override fun assertEqualTypes(a: KotlinType, b: KotlinType, typeCheckingProcedure: TypeCheckingProcedure): Boolean { depth++ doAddConstraint(EQUAL, a, b, newConstraintContext, typeCheckingProcedure) depth-- @@ -243,14 +243,14 @@ public class ConstraintSystemImpl : ConstraintSystem { return a == b } - override fun assertSubtype(subtype: KtType, supertype: KtType, typeCheckingProcedure: TypeCheckingProcedure): Boolean { + override fun assertSubtype(subtype: KotlinType, supertype: KotlinType, typeCheckingProcedure: TypeCheckingProcedure): Boolean { depth++ doAddConstraint(SUB_TYPE, subtype, supertype, newConstraintContext, typeCheckingProcedure) depth-- return true } - override fun capture(typeVariable: KtType, typeProjection: TypeProjection): Boolean { + override fun capture(typeVariable: KotlinType, typeProjection: TypeProjection): Boolean { if (isMyTypeVariable(typeProjection.getType())) return false val myTypeVariable = getMyTypeVariable(typeVariable) @@ -264,7 +264,7 @@ public class ConstraintSystemImpl : ConstraintSystem { return false } - override fun noCorrespondingSupertype(subtype: KtType, supertype: KtType): Boolean { + override fun noCorrespondingSupertype(subtype: KotlinType, supertype: KotlinType): Boolean { errors.add(newTypeInferenceOrParameterConstraintError(constraintPosition)) return true } @@ -272,7 +272,7 @@ public class ConstraintSystemImpl : ConstraintSystem { doAddConstraint(constraintKind, subType, superType, constraintContext, typeCheckingProcedure) } - private fun isErrorOrSpecialType(type: KtType?, constraintPosition: ConstraintPosition): Boolean { + private fun isErrorOrSpecialType(type: KotlinType?, constraintPosition: ConstraintPosition): Boolean { if (TypeUtils.isDontCarePlaceholder(type) || ErrorUtils.isUninferredParameter(type)) { return true } @@ -286,8 +286,8 @@ public class ConstraintSystemImpl : ConstraintSystem { private fun doAddConstraint( constraintKind: ConstraintKind, - subType: KtType?, - superType: KtType?, + subType: KotlinType?, + superType: KotlinType?, constraintContext: ConstraintContext, typeCheckingProcedure: TypeCheckingProcedure ) { @@ -317,7 +317,7 @@ public class ConstraintSystemImpl : ConstraintSystem { subType } - fun simplifyConstraint(subType: KtType, superType: KtType) { + fun simplifyConstraint(subType: KotlinType, superType: KotlinType) { if (isMyTypeVariable(subType)) { generateTypeParameterBound(subType, superType, constraintKind.toBound(), constraintContext) return @@ -348,7 +348,7 @@ public class ConstraintSystemImpl : ConstraintSystem { fun addBound( typeVariable: TypeParameterDescriptor, - constrainingType: KtType, + constrainingType: KotlinType, kind: TypeBounds.BoundKind, constraintContext: ConstraintContext ) { @@ -370,8 +370,8 @@ public class ConstraintSystemImpl : ConstraintSystem { } private fun generateTypeParameterBound( - parameterType: KtType, - constrainingType: KtType, + parameterType: KotlinType, + constrainingType: KotlinType, boundKind: TypeBounds.BoundKind, constraintContext: ConstraintContext ) { @@ -414,7 +414,7 @@ public class ConstraintSystemImpl : ConstraintSystem { } private fun generateTypeParameterCaptureConstraint( - parameterType: KtType, + parameterType: KotlinType, constrainingTypeProjection: TypeProjection, constraintContext: ConstraintContext ) { @@ -452,9 +452,9 @@ public class ConstraintSystemImpl : ConstraintSystem { fun isMyTypeVariable(typeVariable: TypeParameterDescriptor) = allTypeParameterBounds.contains(typeVariable) - fun isMyTypeVariable(type: KtType): Boolean = getMyTypeVariable(type) != null + fun isMyTypeVariable(type: KotlinType): Boolean = getMyTypeVariable(type) != null - fun getMyTypeVariable(type: KtType): TypeParameterDescriptor? { + fun getMyTypeVariable(type: KotlinType): TypeParameterDescriptor? { val typeParameterDescriptor = type.getConstructor().getDeclarationDescriptor() as? TypeParameterDescriptor return if (typeParameterDescriptor != null && isMyTypeVariable(typeParameterDescriptor)) typeParameterDescriptor else null } @@ -471,12 +471,12 @@ public class ConstraintSystemImpl : ConstraintSystem { private fun getSubstitutor(substituteOriginal: Boolean, getDefaultValue: (TypeParameterDescriptor) -> TypeProjection) = replaceUninferredBy(getDefaultValue, substituteOriginal).setApproximateCapturedTypes() - private fun storeInitialConstraint(constraintKind: ConstraintKind, subType: KtType, superType: KtType, position: ConstraintPosition) { + private fun storeInitialConstraint(constraintKind: ConstraintKind, subType: KotlinType, superType: KotlinType, position: ConstraintPosition) { initialConstraints.add(Constraint(constraintKind, subType, superType, position)) } private fun satisfyInitialConstraints(): Boolean { - fun KtType.substitute(): KtType? { + fun KotlinType.substitute(): KotlinType? { val substitutor = getSubstitutor(substituteOriginal = false) { TypeProjectionImpl(ErrorUtils.createUninferredParameterType(it)) } return substitutor.substitute(this, Variance.INVARIANT) ?: return null } @@ -518,9 +518,9 @@ public class ConstraintSystemImpl : ConstraintSystem { } fun createTypeForFunctionPlaceholder( - functionPlaceholder: KtType, - expectedType: KtType -): KtType { + functionPlaceholder: KotlinType, + expectedType: KotlinType +): KotlinType { if (!functionPlaceholder.isFunctionPlaceholder) return functionPlaceholder val functionPlaceholderTypeConstructor = functionPlaceholder.getConstructor() as FunctionPlaceholderTypeConstructor @@ -531,7 +531,7 @@ fun createTypeForFunctionPlaceholder( // the first parameter is receiver (if present), the last one is return type, // the remaining are function arguments val functionArgumentsSize = if (isExtension) typeParamSize - 2 else typeParamSize - 1 - val result = arrayListOf() + val result = arrayListOf() (1..functionArgumentsSize).forEach { result.add(DONT_CARE) } result } @@ -575,7 +575,7 @@ public fun createTypeSubstitutor(conversion: (TypeParameterDescriptor) -> TypePa if (descriptor !is TypeParameterDescriptor) return null val typeParameterDescriptor = conversion(descriptor) ?: return null - val type = KtTypeImpl.create(Annotations.EMPTY, typeParameterDescriptor.getTypeConstructor(), false, listOf(), KtScope.Empty) + val type = KotlinTypeImpl.create(Annotations.EMPTY, typeParameterDescriptor.getTypeConstructor(), false, listOf(), KtScope.Empty) return TypeProjectionImpl(type) } }) diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBounds.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBounds.kt index cb7b1bbcd00..5e4a6603935 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBounds.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBounds.kt @@ -22,7 +22,7 @@ import org.jetbrains.kotlin.resolve.calls.inference.TypeBounds.BoundKind.EXACT_B import org.jetbrains.kotlin.resolve.calls.inference.TypeBounds.BoundKind.LOWER_BOUND import org.jetbrains.kotlin.resolve.calls.inference.TypeBounds.BoundKind.UPPER_BOUND import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPosition -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.Variance public interface TypeBounds { @@ -32,10 +32,10 @@ public interface TypeBounds { public val bounds: Collection - public val value: KtType? + public val value: KotlinType? get() = if (values.size() == 1) values.first() else null - public val values: Collection + public val values: Collection public enum class BoundKind { LOWER_BOUND, @@ -45,7 +45,7 @@ public interface TypeBounds { public class Bound( public val typeVariable: TypeParameterDescriptor, - public val constrainingType: KtType, + public val constrainingType: KotlinType, public val kind: BoundKind, public val position: ConstraintPosition, public val isProper: Boolean, diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBoundsImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBoundsImpl.kt index f92f9075f7b..54462dfa208 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBoundsImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBoundsImpl.kt @@ -34,7 +34,7 @@ public class TypeBoundsImpl( ) : TypeBounds { override val bounds = ArrayList() - private var resultValues: Collection? = null + private var resultValues: Collection? = null var isFixed: Boolean = false private set @@ -51,12 +51,12 @@ public class TypeBoundsImpl( bounds.add(bound) } - private fun filterBounds(bounds: Collection, kind: BoundKind): Set { + private fun filterBounds(bounds: Collection, kind: BoundKind): Set { return filterBounds(bounds, kind, null) } - private fun filterBounds(bounds: Collection, kind: BoundKind, errorValues: MutableCollection?): Set { - val result = LinkedHashSet() + private fun filterBounds(bounds: Collection, kind: BoundKind, errorValues: MutableCollection?): Set { + val result = LinkedHashSet() for (bound in bounds) { if (bound.kind == kind) { if (!ErrorUtils.containsErrorType(bound.constrainingType)) { @@ -76,7 +76,7 @@ public class TypeBoundsImpl( return result } - override val values: Collection + override val values: Collection get() { if (resultValues == null) { resultValues = computeValues() @@ -84,8 +84,8 @@ public class TypeBoundsImpl( return resultValues!! } - private fun computeValues(): Collection { - val values = LinkedHashSet() + private fun computeValues(): Collection { + val values = LinkedHashSet() val bounds = bounds.filter { it.isProper } if (bounds.isEmpty()) { @@ -146,7 +146,7 @@ public class TypeBoundsImpl( return values } - private fun tryPossibleAnswer(bounds: Collection, possibleAnswer: KtType?): Boolean { + private fun tryPossibleAnswer(bounds: Collection, possibleAnswer: KotlinType?): Boolean { if (possibleAnswer == null) return false // a captured type might be an answer if (!possibleAnswer.getConstructor().isDenotable() && !possibleAnswer.isCaptured()) return false diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/constraintIncorporation.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/constraintIncorporation.kt index 418dac7c815..33584768f70 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/constraintIncorporation.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/constraintIncorporation.kt @@ -96,7 +96,7 @@ private fun ConstraintSystemImpl.generateNewBound(bound: Bound, substitution: Bo val position = CompoundConstraintPosition(bound.position, substitution.position) - fun addNewBound(newConstrainingType: KtType, newBoundKind: BoundKind) { + fun addNewBound(newConstrainingType: KotlinType, newBoundKind: BoundKind) { // We don't generate new recursive constraints val nestedTypeVariables = newConstrainingType.getNestedTypeVariables(original = false) if (nestedTypeVariables.contains(bound.typeVariable)) return @@ -117,7 +117,7 @@ private fun ConstraintSystemImpl.generateNewBound(bound: Bound, substitution: Bo // todo // if we allow non-trivial type projections, we bump into errors like // "Empty intersection for types [MutableCollection, MutableCollection, MutableCollection]" - fun KtType.containsConstrainingTypeWithoutProjection() = this.getNestedArguments().any { + fun KotlinType.containsConstrainingTypeWithoutProjection() = this.getNestedArguments().any { it.getType().getConstructor() == substitution.constrainingType.getConstructor() && it.getProjectionKind() == Variance.INVARIANT } if (approximationBounds.upper.containsConstrainingTypeWithoutProjection() && bound.kind != LOWER_BOUND) { diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstant.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstant.kt index 605d641aaa7..ce572aa6c46 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstant.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstant.kt @@ -26,9 +26,9 @@ public interface CompileTimeConstant { public val parameters: CompileTimeConstant.Parameters - public fun toConstantValue(expectedType: KtType): ConstantValue + public fun toConstantValue(expectedType: KotlinType): ConstantValue - public fun getValue(expectedType: KtType): T = toConstantValue(expectedType).value + public fun getValue(expectedType: KotlinType): T = toConstantValue(expectedType).value public val canBeUsedInAnnotations: Boolean get() = parameters.canBeUsedInAnnotation @@ -53,9 +53,9 @@ public class TypedCompileTimeConstant( override val isError: Boolean get() = constantValue is ErrorValue - public val type: KtType = constantValue.type + public val type: KotlinType = constantValue.type - override fun toConstantValue(expectedType: KtType): ConstantValue = constantValue + override fun toConstantValue(expectedType: KotlinType): ConstantValue = constantValue } public class IntegerValueTypeConstant( @@ -65,7 +65,7 @@ public class IntegerValueTypeConstant( ) : CompileTimeConstant { private val typeConstructor = IntegerValueTypeConstructor(value.toLong(), builtIns) - override fun toConstantValue(expectedType: KtType): ConstantValue { + override fun toConstantValue(expectedType: KotlinType): ConstantValue { val factory = ConstantValueFactory(builtIns) val type = getType(expectedType) return when { @@ -84,12 +84,12 @@ public class IntegerValueTypeConstant( } } - val unknownIntegerType = KtTypeImpl.create( + val unknownIntegerType = KotlinTypeImpl.create( Annotations.EMPTY, typeConstructor, false, emptyList(), ErrorUtils.createErrorScope("Scope for number value type (" + typeConstructor.toString() + ")", true) ) - public fun getType(expectedType: KtType): KtType = TypeUtils.getPrimitiveNumberType(typeConstructor, expectedType) + public fun getType(expectedType: KotlinType): KotlinType = TypeUtils.getPrimitiveNumberType(typeConstructor, expectedType) override fun toString() = typeConstructor.toString() } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ConstantValueFactory.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ConstantValueFactory.kt index be7cb53e689..6d84c9f7d09 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ConstantValueFactory.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ConstantValueFactory.kt @@ -19,7 +19,7 @@ package org.jetbrains.kotlin.resolve.constants import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeUtils public class ConstantValueFactory( @@ -51,12 +51,12 @@ public class ConstantValueFactory( fun createArrayValue( value: List>, - type: KtType + type: KotlinType ) = ArrayValue(value, type, builtins) fun createAnnotationValue(value: AnnotationDescriptor) = AnnotationValue(value) - fun createKClassValue(type: KtType) = KClassValue(type) + fun createKClassValue(type: KotlinType) = KClassValue(type) fun createConstantValue( value: Any? @@ -79,7 +79,7 @@ public class ConstantValueFactory( public fun createIntegerConstantValue( value: Long, - expectedType: KtType + expectedType: KotlinType ): ConstantValue<*>? { val notNullExpected = TypeUtils.makeNotNullable(expectedType) return when { diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueTypeConstructor.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueTypeConstructor.kt index 1454ce8ef49..c40de35874d 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueTypeConstructor.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueTypeConstructor.kt @@ -19,7 +19,7 @@ package org.jetbrains.kotlin.resolve.constants import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor import org.jetbrains.kotlin.descriptors.annotations.Annotations -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeConstructor import java.util.* @@ -27,7 +27,7 @@ public class IntegerValueTypeConstructor( private val value: Long, private val builtIns: KotlinBuiltIns ) : TypeConstructor { - private val supertypes = ArrayList(4) + private val supertypes = ArrayList(4) init { // order of types matters @@ -39,13 +39,13 @@ public class IntegerValueTypeConstructor( supertypes.add(builtIns.getLongType()) } - private fun checkBoundsAndAddSuperType(value: Long, minValue: Long, maxValue: Long, kotlinType: KtType) { + private fun checkBoundsAndAddSuperType(value: Long, minValue: Long, maxValue: Long, kotlinType: KotlinType) { if (value >= minValue && value <= maxValue) { supertypes.add(kotlinType) } } - override fun getSupertypes(): Collection = supertypes + override fun getSupertypes(): Collection = supertypes override fun getParameters(): List = emptyList() diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/constantValues.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/constantValues.kt index cac4640e388..77db4d6a806 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/constantValues.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/constantValues.kt @@ -22,11 +22,11 @@ import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor import org.jetbrains.kotlin.resolve.descriptorUtil.classObjectType import org.jetbrains.kotlin.types.ErrorUtils -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.utils.sure public abstract class ConstantValue(public open val value: T) { - public abstract val type: KtType + public abstract val type: KotlinType public abstract fun accept(visitor: AnnotationArgumentVisitor, data: D): R @@ -37,7 +37,7 @@ public abstract class IntegerValueConstant protected constructor(value: T) : public class AnnotationValue(value: AnnotationDescriptor) : ConstantValue(value) { - override val type: KtType + override val type: KotlinType get() = value.getType() override fun accept(visitor: AnnotationArgumentVisitor, data: D) = visitor.visitAnnotationValue(this, data) @@ -46,7 +46,7 @@ public class AnnotationValue(value: AnnotationDescriptor) : ConstantValue>, - override val type: KtType, + override val type: KotlinType, private val builtIns: KotlinBuiltIns ) : ConstantValue>>(value) { @@ -56,7 +56,7 @@ public class ArrayValue( override fun accept(visitor: AnnotationArgumentVisitor, data: D) = visitor.visitArrayValue(this, data) - public val elementType: KtType + public val elementType: KotlinType get() = builtIns.getArrayElementType(type) override fun equals(other: Any?): Boolean { @@ -140,7 +140,7 @@ public class EnumValue( value: ClassDescriptor ) : ConstantValue(value) { - override val type: KtType + override val type: KotlinType get() = value.classObjectType.sure { "Enum entry must have a class object type: " + value } override fun accept(visitor: AnnotationArgumentVisitor, data: D) = visitor.visitEnumValue(this, data) @@ -211,9 +211,9 @@ public class IntValue( override fun hashCode() = value } -public class KClassValue(override val type: KtType) : - ConstantValue(type) { - override val value: KtType +public class KClassValue(override val type: KotlinType) : + ConstantValue(type) { + override val value: KotlinType get() = type.getArguments().single().getType() override fun accept(visitor: AnnotationArgumentVisitor, data: D) = visitor.visitKClassValue(this, data) diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/AbstractScopeAdapter.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/AbstractScopeAdapter.kt index 180a7dc98ec..19ca372ab8a 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/AbstractScopeAdapter.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/AbstractScopeAdapter.kt @@ -19,7 +19,7 @@ package org.jetbrains.kotlin.resolve.scopes import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.incremental.components.LookupLocation import org.jetbrains.kotlin.name.Name -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.utils.Printer /** @@ -54,19 +54,19 @@ public abstract class AbstractScopeAdapter : KtScope { return workerScope.getProperties(name, location) } - override fun getSyntheticExtensionProperties(receiverTypes: Collection, name: Name, location: LookupLocation): Collection { + override fun getSyntheticExtensionProperties(receiverTypes: Collection, name: Name, location: LookupLocation): Collection { return workerScope.getSyntheticExtensionProperties(receiverTypes, name, location) } - override fun getSyntheticExtensionFunctions(receiverTypes: Collection, name: Name, location: LookupLocation): Collection { + override fun getSyntheticExtensionFunctions(receiverTypes: Collection, name: Name, location: LookupLocation): Collection { return workerScope.getSyntheticExtensionFunctions(receiverTypes, name, location) } - override fun getSyntheticExtensionProperties(receiverTypes: Collection): Collection { + override fun getSyntheticExtensionProperties(receiverTypes: Collection): Collection { return workerScope.getSyntheticExtensionProperties(receiverTypes) } - override fun getSyntheticExtensionFunctions(receiverTypes: Collection): Collection { + override fun getSyntheticExtensionFunctions(receiverTypes: Collection): Collection { return workerScope.getSyntheticExtensionFunctions(receiverTypes) } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/ChainedScope.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/ChainedScope.kt index 8ff84d62d7d..050756d1691 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/ChainedScope.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/ChainedScope.kt @@ -19,7 +19,7 @@ package org.jetbrains.kotlin.resolve.scopes import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.incremental.components.LookupLocation import org.jetbrains.kotlin.name.Name -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.util.collectionUtils.getFirstMatch import org.jetbrains.kotlin.util.collectionUtils.getFromAllScopes import org.jetbrains.kotlin.utils.Printer @@ -48,16 +48,16 @@ public open class ChainedScope( override fun getFunctions(name: Name, location: LookupLocation): Collection = getFromAllScopes(scopeChain) { it.getFunctions(name, location) } - override fun getSyntheticExtensionProperties(receiverTypes: Collection, name: Name, location: LookupLocation): Collection + override fun getSyntheticExtensionProperties(receiverTypes: Collection, name: Name, location: LookupLocation): Collection = getFromAllScopes(scopeChain) { it.getSyntheticExtensionProperties(receiverTypes, name, location) } - override fun getSyntheticExtensionFunctions(receiverTypes: Collection, name: Name, location: LookupLocation): Collection + override fun getSyntheticExtensionFunctions(receiverTypes: Collection, name: Name, location: LookupLocation): Collection = getFromAllScopes(scopeChain) { it.getSyntheticExtensionFunctions(receiverTypes, name, location) } - override fun getSyntheticExtensionProperties(receiverTypes: Collection): Collection + override fun getSyntheticExtensionProperties(receiverTypes: Collection): Collection = getFromAllScopes(scopeChain) { it.getSyntheticExtensionProperties(receiverTypes) } - override fun getSyntheticExtensionFunctions(receiverTypes: Collection): Collection + override fun getSyntheticExtensionFunctions(receiverTypes: Collection): Collection = getFromAllScopes(scopeChain) { it.getSyntheticExtensionFunctions(receiverTypes) } override fun getImplicitReceiversHierarchy(): List { diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/FilteringScope.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/FilteringScope.kt index 36140675d05..a210b6e0504 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/FilteringScope.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/FilteringScope.kt @@ -21,7 +21,7 @@ import org.jetbrains.kotlin.descriptors.FunctionDescriptor import org.jetbrains.kotlin.descriptors.PropertyDescriptor import org.jetbrains.kotlin.incremental.components.LookupLocation import org.jetbrains.kotlin.name.Name -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.utils.Printer public class FilteringScope(private val workerScope: KtScope, private val predicate: (DeclarationDescriptor) -> Boolean) : KtScope { @@ -39,16 +39,16 @@ public class FilteringScope(private val workerScope: KtScope, private val predic override fun getProperties(name: Name, location: LookupLocation) = workerScope.getProperties(name, location).filter(predicate) - override fun getSyntheticExtensionProperties(receiverTypes: Collection, name: Name, location: LookupLocation): Collection + override fun getSyntheticExtensionProperties(receiverTypes: Collection, name: Name, location: LookupLocation): Collection = workerScope.getSyntheticExtensionProperties(receiverTypes, name, location).filter(predicate) - override fun getSyntheticExtensionFunctions(receiverTypes: Collection, name: Name, location: LookupLocation): Collection + override fun getSyntheticExtensionFunctions(receiverTypes: Collection, name: Name, location: LookupLocation): Collection = workerScope.getSyntheticExtensionFunctions(receiverTypes, name, location).filter(predicate) - override fun getSyntheticExtensionProperties(receiverTypes: Collection): Collection + override fun getSyntheticExtensionProperties(receiverTypes: Collection): Collection = workerScope.getSyntheticExtensionProperties(receiverTypes).filter(predicate) - override fun getSyntheticExtensionFunctions(receiverTypes: Collection): Collection + override fun getSyntheticExtensionFunctions(receiverTypes: Collection): Collection = workerScope.getSyntheticExtensionFunctions(receiverTypes).filter(predicate) override fun getLocalVariable(name: Name) = filterDescriptor(workerScope.getLocalVariable(name)) diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/KtScope.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/KtScope.kt index 619f4253024..8af5aa8d50c 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/KtScope.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/KtScope.kt @@ -20,7 +20,7 @@ import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.incremental.components.LookupLocation import org.jetbrains.kotlin.incremental.components.NoLookupLocation import org.jetbrains.kotlin.name.Name -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.utils.Printer import org.jetbrains.kotlin.utils.toReadOnlyList import java.lang.reflect.Modifier @@ -37,11 +37,11 @@ public interface KtScope { public fun getFunctions(name: Name, location: LookupLocation): Collection - public fun getSyntheticExtensionProperties(receiverTypes: Collection, name: Name, location: LookupLocation): Collection - public fun getSyntheticExtensionFunctions(receiverTypes: Collection, name: Name, location: LookupLocation): Collection + public fun getSyntheticExtensionProperties(receiverTypes: Collection, name: Name, location: LookupLocation): Collection + public fun getSyntheticExtensionFunctions(receiverTypes: Collection, name: Name, location: LookupLocation): Collection - public fun getSyntheticExtensionProperties(receiverTypes: Collection): Collection - public fun getSyntheticExtensionFunctions(receiverTypes: Collection): Collection + public fun getSyntheticExtensionProperties(receiverTypes: Collection): Collection + public fun getSyntheticExtensionFunctions(receiverTypes: Collection): Collection public fun getContainingDeclaration(): DeclarationDescriptor diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/KtScopeImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/KtScopeImpl.kt index f30247eaa4d..c31f4105b33 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/KtScopeImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/KtScopeImpl.kt @@ -19,7 +19,7 @@ package org.jetbrains.kotlin.resolve.scopes import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.incremental.components.LookupLocation import org.jetbrains.kotlin.name.Name -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.utils.Printer public abstract class KtScopeImpl : KtScope { @@ -33,11 +33,11 @@ public abstract class KtScopeImpl : KtScope { override fun getFunctions(name: Name, location: LookupLocation): Collection = emptyList() - override fun getSyntheticExtensionProperties(receiverTypes: Collection, name: Name, location: LookupLocation): Collection = emptyList() - override fun getSyntheticExtensionFunctions(receiverTypes: Collection, name: Name, location: LookupLocation): Collection = emptyList() + override fun getSyntheticExtensionProperties(receiverTypes: Collection, name: Name, location: LookupLocation): Collection = emptyList() + override fun getSyntheticExtensionFunctions(receiverTypes: Collection, name: Name, location: LookupLocation): Collection = emptyList() - override fun getSyntheticExtensionProperties(receiverTypes: Collection): Collection = emptyList() - override fun getSyntheticExtensionFunctions(receiverTypes: Collection): Collection = emptyList() + override fun getSyntheticExtensionProperties(receiverTypes: Collection): Collection = emptyList() + override fun getSyntheticExtensionFunctions(receiverTypes: Collection): Collection = emptyList() override fun getDeclarationsByLabel(labelName: Name): Collection = emptyList() diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/Scopes.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/Scopes.kt index ef14db14c3e..44cf060ea07 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/Scopes.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/Scopes.kt @@ -20,7 +20,7 @@ import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.incremental.components.LookupLocation import org.jetbrains.kotlin.incremental.components.NoLookupLocation import org.jetbrains.kotlin.name.Name -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.utils.Printer // see ScopeUtils.kt in the frontend module @@ -58,11 +58,11 @@ public interface FileScope: LexicalScope { fun getPackage(name: Name): PackageViewDescriptor? - public fun getSyntheticExtensionProperties(receiverTypes: Collection, name: Name, location: LookupLocation): Collection - public fun getSyntheticExtensionFunctions(receiverTypes: Collection, name: Name, location: LookupLocation): Collection + public fun getSyntheticExtensionProperties(receiverTypes: Collection, name: Name, location: LookupLocation): Collection + public fun getSyntheticExtensionFunctions(receiverTypes: Collection, name: Name, location: LookupLocation): Collection - public fun getSyntheticExtensionProperties(receiverTypes: Collection): Collection - public fun getSyntheticExtensionFunctions(receiverTypes: Collection): Collection + public fun getSyntheticExtensionProperties(receiverTypes: Collection): Collection + public fun getSyntheticExtensionFunctions(receiverTypes: Collection): Collection public fun getDescriptors( kindFilter: DescriptorKindFilter = DescriptorKindFilter.ALL, diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/SubstitutingScope.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/SubstitutingScope.kt index 26c8958c1f1..2f2c146d4ea 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/SubstitutingScope.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/SubstitutingScope.kt @@ -22,7 +22,7 @@ import org.jetbrains.kotlin.descriptors.PropertyDescriptor import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor import org.jetbrains.kotlin.incremental.components.LookupLocation import org.jetbrains.kotlin.name.Name -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeSubstitutor import org.jetbrains.kotlin.utils.Printer import org.jetbrains.kotlin.utils.newHashSetWithExpectedSize @@ -71,16 +71,16 @@ public class SubstitutingScope(private val workerScope: KtScope, private val sub override fun getFunctions(name: Name, location: LookupLocation) = substitute(workerScope.getFunctions(name, location)) - override fun getSyntheticExtensionProperties(receiverTypes: Collection, name: Name, location: LookupLocation): Collection + override fun getSyntheticExtensionProperties(receiverTypes: Collection, name: Name, location: LookupLocation): Collection = substitute(workerScope.getSyntheticExtensionProperties(receiverTypes, name, location)) - override fun getSyntheticExtensionFunctions(receiverTypes: Collection, name: Name, location: LookupLocation): Collection + override fun getSyntheticExtensionFunctions(receiverTypes: Collection, name: Name, location: LookupLocation): Collection = substitute(workerScope.getSyntheticExtensionFunctions(receiverTypes, name, location)) - override fun getSyntheticExtensionProperties(receiverTypes: Collection): Collection + override fun getSyntheticExtensionProperties(receiverTypes: Collection): Collection = substitute(workerScope.getSyntheticExtensionProperties(receiverTypes)) - override fun getSyntheticExtensionFunctions(receiverTypes: Collection): Collection + override fun getSyntheticExtensionFunctions(receiverTypes: Collection): Collection = substitute(workerScope.getSyntheticExtensionFunctions(receiverTypes)) override fun getPackage(name: Name) = workerScope.getPackage(name) diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/receivers/AbstractReceiverValue.java b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/receivers/AbstractReceiverValue.java index 0dca93ba7c7..b22b645a340 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/receivers/AbstractReceiverValue.java +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/receivers/AbstractReceiverValue.java @@ -17,18 +17,18 @@ package org.jetbrains.kotlin.resolve.scopes.receivers; import org.jetbrains.annotations.NotNull; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; public abstract class AbstractReceiverValue implements ReceiverValue { - protected final KtType receiverType; + protected final KotlinType receiverType; - public AbstractReceiverValue(@NotNull KtType receiverType) { + public AbstractReceiverValue(@NotNull KotlinType receiverType) { this.receiverType = receiverType; } @Override @NotNull - public KtType getType() { + public KotlinType getType() { return receiverType; } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/receivers/ClassReceiver.java b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/receivers/ClassReceiver.java index 6004aba686b..c4506bb5a04 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/receivers/ClassReceiver.java +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/receivers/ClassReceiver.java @@ -18,7 +18,7 @@ package org.jetbrains.kotlin.resolve.scopes.receivers; import org.jetbrains.annotations.NotNull; import org.jetbrains.kotlin.descriptors.ClassDescriptor; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; public class ClassReceiver implements ThisReceiver { @@ -35,7 +35,7 @@ public class ClassReceiver implements ThisReceiver { @NotNull @Override - public KtType getType() { + public KotlinType getType() { return classDescriptor.getDefaultType(); } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/receivers/ExtensionReceiver.java b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/receivers/ExtensionReceiver.java index c91268d5a86..ad9290e4de9 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/receivers/ExtensionReceiver.java +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/receivers/ExtensionReceiver.java @@ -18,13 +18,13 @@ package org.jetbrains.kotlin.resolve.scopes.receivers; import org.jetbrains.annotations.NotNull; import org.jetbrains.kotlin.descriptors.CallableDescriptor; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; public class ExtensionReceiver extends AbstractReceiverValue implements ThisReceiver { private final CallableDescriptor descriptor; - public ExtensionReceiver(@NotNull CallableDescriptor callableDescriptor, @NotNull KtType receiverType) { + public ExtensionReceiver(@NotNull CallableDescriptor callableDescriptor, @NotNull KotlinType receiverType) { super(receiverType); this.descriptor = callableDescriptor; } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/receivers/ReceiverValue.java b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/receivers/ReceiverValue.java index cbfcbfb8729..b054522f598 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/receivers/ReceiverValue.java +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/receivers/ReceiverValue.java @@ -17,13 +17,13 @@ package org.jetbrains.kotlin.resolve.scopes.receivers; import org.jetbrains.annotations.NotNull; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; public interface ReceiverValue { ReceiverValue NO_RECEIVER = new ReceiverValue() { @NotNull @Override - public KtType getType() { + public KotlinType getType() { throw new UnsupportedOperationException("NO_RECEIVER.getType()"); } @@ -41,7 +41,7 @@ public interface ReceiverValue { ReceiverValue IRRELEVANT_RECEIVER = new ReceiverValue() { @NotNull @Override - public KtType getType() { + public KotlinType getType() { throw new UnsupportedOperationException("IRRELEVANT_RECEIVER.getType()"); } @@ -57,7 +57,7 @@ public interface ReceiverValue { }; @NotNull - KtType getType(); + KotlinType getType(); boolean exists(); } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/receivers/TransientReceiver.java b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/receivers/TransientReceiver.java index 0130db4d4a1..61004aef192 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/receivers/TransientReceiver.java +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/receivers/TransientReceiver.java @@ -17,14 +17,14 @@ package org.jetbrains.kotlin.resolve.scopes.receivers; import org.jetbrains.annotations.NotNull; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; /** * This represents the receiver of hasNext and next() in for-loops * Cannot be an expression receiver because there is no expression for the iterator() call */ public class TransientReceiver extends AbstractReceiverValue { - public TransientReceiver(@NotNull KtType type) { + public TransientReceiver(@NotNull KotlinType type) { super(type); } diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/AbstractKtType.java b/core/descriptors/src/org/jetbrains/kotlin/types/AbstractKotlinType.java similarity index 94% rename from core/descriptors/src/org/jetbrains/kotlin/types/AbstractKtType.java rename to core/descriptors/src/org/jetbrains/kotlin/types/AbstractKotlinType.java index f632a34e90e..542db19ca2e 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/AbstractKtType.java +++ b/core/descriptors/src/org/jetbrains/kotlin/types/AbstractKotlinType.java @@ -25,7 +25,7 @@ import org.jetbrains.kotlin.types.checker.KotlinTypeChecker; import java.util.Iterator; import java.util.List; -public abstract class AbstractKtType implements KtType { +public abstract class AbstractKotlinType implements KotlinType { @Nullable @Override public T getCapability(@NotNull Class capabilityClass) { @@ -49,9 +49,9 @@ public abstract class AbstractKtType implements KtType { @Override public final boolean equals(Object obj) { if (this == obj) return true; - if (!(obj instanceof KtType)) return false; + if (!(obj instanceof KotlinType)) return false; - KtType type = (KtType) obj; + KotlinType type = (KotlinType) obj; return isMarkedNullable() == type.isMarkedNullable() && KotlinTypeChecker.FLEXIBLE_UNEQUAL_TO_INFLEXIBLE.equalTypes(this, type); } diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/AbstractLazyType.kt b/core/descriptors/src/org/jetbrains/kotlin/types/AbstractLazyType.kt index 0973fbe5944..163d2ad36fa 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/AbstractLazyType.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/AbstractLazyType.kt @@ -22,7 +22,7 @@ import org.jetbrains.kotlin.storage.StorageManager import org.jetbrains.kotlin.resolve.scopes.KtScope import org.jetbrains.kotlin.descriptors.annotations.Annotations -public abstract class AbstractLazyType(storageManager: StorageManager) : AbstractKtType(), LazyType { +public abstract class AbstractLazyType(storageManager: StorageManager) : AbstractKotlinType(), LazyType { private val typeConstructor = storageManager.createLazyValue { computeTypeConstructor() } override fun getConstructor(): TypeConstructor = typeConstructor() @@ -63,6 +63,6 @@ public abstract class AbstractLazyType(storageManager: StorageManager) : Abstrac if (!arguments.isComputed()) { return "" + getConstructor() + "" } - return super.toString() + return super.toString() } } diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/CapturedTypeApproximation.kt b/core/descriptors/src/org/jetbrains/kotlin/types/CapturedTypeApproximation.kt index 90aea4b20ac..322a780fe3f 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/CapturedTypeApproximation.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/CapturedTypeApproximation.kt @@ -33,8 +33,8 @@ public data class ApproximationBounds( private class TypeArgument( val typeParameter: TypeParameterDescriptor, - val inProjection: KtType, - val outProjection: KtType + val inProjection: KotlinType, + val outProjection: KotlinType ) { val isConsistent: Boolean get() = KotlinTypeChecker.DEFAULT.isSubtypeOf(inProjection, outProjection) @@ -85,12 +85,12 @@ private fun substituteCapturedTypes(typeProjection: TypeProjection): TypeProject return typeSubstitutor.substituteWithoutApproximation(typeProjection) } -public fun approximateCapturedTypes(type: KtType): ApproximationBounds { +public fun approximateCapturedTypes(type: KotlinType): ApproximationBounds { val typeConstructor = type.getConstructor() if (type.isCaptured()) { val typeProjection = (typeConstructor as CapturedTypeConstructor).typeProjection // todo: preserve flexibility as well - fun KtType.makeNullableIfNeeded() = TypeUtils.makeNullableIfNeeded(this, type.isMarkedNullable()) + fun KotlinType.makeNullableIfNeeded() = TypeUtils.makeNullableIfNeeded(this, type.isMarkedNullable()) val bound = typeProjection.getType().makeNullableIfNeeded() return when (typeProjection.getProjectionKind()) { @@ -115,9 +115,9 @@ public fun approximateCapturedTypes(type: KtType): ApproximationBounds { type.replaceTypeArguments(upperBoundArguments)) } -private fun KtType.replaceTypeArguments(newTypeArguments: List): KtType { +private fun KotlinType.replaceTypeArguments(newTypeArguments: List): KotlinType { assert(getArguments().size() == newTypeArguments.size()) { "Incorrect type arguments $newTypeArguments" } - return KtTypeImpl.create( + return KotlinTypeImpl.create( getAnnotations(), getConstructor(), isMarkedNullable(), newTypeArguments.map { it.toTypeProjection() }, getMemberScope() ) } diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/CommonSupertypes.java b/core/descriptors/src/org/jetbrains/kotlin/types/CommonSupertypes.java index 0d46162ce3a..459c2aa947d 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/CommonSupertypes.java +++ b/core/descriptors/src/org/jetbrains/kotlin/types/CommonSupertypes.java @@ -38,10 +38,10 @@ import static org.jetbrains.kotlin.types.Variance.OUT_VARIANCE; public class CommonSupertypes { @Nullable - public static KtType commonSupertypeForNonDenotableTypes(@NotNull Collection types) { + public static KotlinType commonSupertypeForNonDenotableTypes(@NotNull Collection types) { if (types.isEmpty()) return null; if (types.size() == 1) { - KtType type = types.iterator().next(); + KotlinType type = types.iterator().next(); if (type.getConstructor() instanceof IntersectionTypeConstructor) { return commonSupertypeForNonDenotableTypes(type.getConstructor().getSupertypes()); } @@ -50,15 +50,15 @@ public class CommonSupertypes { } @NotNull - public static KtType commonSupertype(@NotNull Collection types) { + public static KotlinType commonSupertype(@NotNull Collection types) { // Recursion should not be significantly deeper than the deepest type in question // It can be slightly deeper, though: e.g. when initial types are simple, but their supertypes are complex return findCommonSupertype(types, 0, maxDepth(types) + 3); } - private static int maxDepth(@NotNull Collection types) { + private static int maxDepth(@NotNull Collection types) { int max = 0; - for (KtType type : types) { + for (KotlinType type : types) { int depth = depth(type); if (max < depth) { max = depth; @@ -67,10 +67,10 @@ public class CommonSupertypes { return max; } - private static int depth(@NotNull final KtType type) { - return 1 + maxDepth(CollectionsKt.map(type.getArguments(), new Function1() { + private static int depth(@NotNull final KotlinType type) { + return 1 + maxDepth(CollectionsKt.map(type.getArguments(), new Function1() { @Override - public KtType invoke(TypeProjection projection) { + public KotlinType invoke(TypeProjection projection) { if (projection.isStarProjection()) { // any type is good enough for depth here return type.getConstructor().getBuiltIns().getAnyType(); @@ -81,13 +81,13 @@ public class CommonSupertypes { } @NotNull - private static KtType findCommonSupertype(@NotNull Collection types, int recursionDepth, int maxDepth) { + private static KotlinType findCommonSupertype(@NotNull Collection types, int recursionDepth, int maxDepth) { assert recursionDepth <= maxDepth : "Recursion depth exceeded: " + recursionDepth + " > " + maxDepth + " for types " + types; boolean hasFlexible = false; - List upper = new ArrayList(types.size()); - List lower = new ArrayList(types.size()); + List upper = new ArrayList(types.size()); + List lower = new ArrayList(types.size()); Set capabilities = new LinkedHashSet(); - for (KtType type : types) { + for (KotlinType type : types) { if (FlexibleTypesKt.isFlexible(type)) { hasFlexible = true; Flexibility flexibility = FlexibleTypesKt.flexibility(type); @@ -110,18 +110,18 @@ public class CommonSupertypes { } @NotNull - private static KtType commonSuperTypeForInflexible(@NotNull Collection types, int recursionDepth, int maxDepth) { + private static KotlinType commonSuperTypeForInflexible(@NotNull Collection types, int recursionDepth, int maxDepth) { assert !types.isEmpty(); - Collection typeSet = new HashSet(types); + Collection typeSet = new HashSet(types); - KtType bestFit = FlexibleTypesKt.singleBestRepresentative(typeSet); + KotlinType bestFit = FlexibleTypesKt.singleBestRepresentative(typeSet); if (bestFit != null) return bestFit; // If any of the types is nullable, the result must be nullable // This also removed Nothing and Nothing? because they are subtypes of everything else boolean nullable = false; - for (Iterator iterator = typeSet.iterator(); iterator.hasNext();) { - KtType type = iterator.next(); + for (Iterator iterator = typeSet.iterator(); iterator.hasNext();) { + KotlinType type = iterator.next(); assert type != null; assert !FlexibleTypesKt.isFlexible(type) : "Flexible type " + type + " passed to commonSuperTypeForInflexible"; if (KotlinBuiltIns.isNothingOrNullableNothing(type)) { @@ -145,10 +145,10 @@ public class CommonSupertypes { } // constructor of the supertype -> all of its instantiations occurring as supertypes - Map> commonSupertypes = computeCommonRawSupertypes(typeSet); + Map> commonSupertypes = computeCommonRawSupertypes(typeSet); while (commonSupertypes.size() > 1) { - Set merge = new HashSet(); - for (Set supertypes : commonSupertypes.values()) { + Set merge = new HashSet(); + for (Set supertypes : commonSupertypes.values()) { merge.addAll(supertypes); } commonSupertypes = computeCommonRawSupertypes(merge); @@ -156,24 +156,24 @@ public class CommonSupertypes { assert !commonSupertypes.isEmpty() : commonSupertypes + " <- " + types; // constructor of the supertype -> all of its instantiations occurring as supertypes - Map.Entry> entry = commonSupertypes.entrySet().iterator().next(); + Map.Entry> entry = commonSupertypes.entrySet().iterator().next(); // Reconstructing type arguments if possible - KtType result = computeSupertypeProjections(entry.getKey(), entry.getValue(), recursionDepth, maxDepth); + KotlinType result = computeSupertypeProjections(entry.getKey(), entry.getValue(), recursionDepth, maxDepth); return TypeUtils.makeNullableIfNeeded(result, nullable); } // Raw supertypes are superclasses w/o type arguments // @return TypeConstructor -> all instantiations of this constructor occurring as supertypes @NotNull - private static Map> computeCommonRawSupertypes(@NotNull Collection types) { + private static Map> computeCommonRawSupertypes(@NotNull Collection types) { assert !types.isEmpty(); - Map> constructorToAllInstances = new HashMap>(); + Map> constructorToAllInstances = new HashMap>(); Set commonSuperclasses = null; List order = null; - for (KtType type : types) { + for (KotlinType type : types) { Set visited = new HashSet(); order = topologicallySortSuperclassesAndRecordAllInstances(type, constructorToAllInstances, visited); @@ -187,7 +187,7 @@ public class CommonSupertypes { assert order != null; Set notSource = new HashSet(); - Map> result = new HashMap>(); + Map> result = new HashMap>(); for (TypeConstructor superConstructor : order) { if (!commonSuperclasses.contains(superConstructor)) { continue; @@ -205,7 +205,7 @@ public class CommonSupertypes { // constructor - type constructor of a supertype to be instantiated // types - instantiations of constructor occurring as supertypes of classes we are trying to intersect @NotNull - private static KtType computeSupertypeProjections(@NotNull TypeConstructor constructor, @NotNull Set types, int recursionDepth, int maxDepth) { + private static KotlinType computeSupertypeProjections(@NotNull TypeConstructor constructor, @NotNull Set types, int recursionDepth, int maxDepth) { // we assume that all the given types are applications of the same type constructor assert !types.isEmpty(); @@ -218,14 +218,14 @@ public class CommonSupertypes { List newProjections = new ArrayList(parameters.size()); for (TypeParameterDescriptor parameterDescriptor : parameters) { Set typeProjections = new HashSet(); - for (KtType type : types) { + for (KotlinType type : types) { typeProjections.add(type.getArguments().get(parameterDescriptor.getIndex())); } newProjections.add(computeSupertypeProjection(parameterDescriptor, typeProjections, recursionDepth, maxDepth)); } boolean nullable = false; - for (KtType type : types) { + for (KotlinType type : types) { nullable |= type.isMarkedNullable(); } @@ -240,7 +240,7 @@ public class CommonSupertypes { else { newScope = ErrorUtils.createErrorScope("A scope for common supertype which is not a normal classifier", true); } - return KtTypeImpl.create(Annotations.Companion.getEMPTY(), constructor, nullable, newProjections, newScope); + return KotlinTypeImpl.create(Annotations.Companion.getEMPTY(), constructor, nullable, newProjections, newScope); } @NotNull @@ -260,8 +260,8 @@ public class CommonSupertypes { return new TypeProjectionImpl(OUT_VARIANCE, DescriptorUtilsKt.getBuiltIns(parameterDescriptor).getNullableAnyType()); } - Set ins = new HashSet(); - Set outs = new HashSet(); + Set ins = new HashSet(); + Set outs = new HashSet(); Variance variance = parameterDescriptor.getVariance(); switch (variance) { @@ -300,8 +300,8 @@ public class CommonSupertypes { if (outs != null) { assert !outs.isEmpty() : "Out projections is empty for parameter " + parameterDescriptor + ", type projections " + typeProjections; Variance projectionKind = variance == OUT_VARIANCE ? Variance.INVARIANT : OUT_VARIANCE; - KtType superType = findCommonSupertype(outs, recursionDepth + 1, maxDepth); - for (KtType upperBound: parameterDescriptor.getUpperBounds()) { + KotlinType superType = findCommonSupertype(outs, recursionDepth + 1, maxDepth); + for (KotlinType upperBound: parameterDescriptor.getUpperBounds()) { if (!TypeUtilsKt.isSubtypeOf(superType, upperBound)) { return new StarProjectionImpl(parameterDescriptor); } @@ -310,7 +310,7 @@ public class CommonSupertypes { } if (ins != null) { assert !ins.isEmpty() : "In projections is empty for parameter " + parameterDescriptor + ", type projections " + typeProjections; - KtType intersection = TypeIntersector.intersectTypes(KotlinTypeChecker.DEFAULT, ins); + KotlinType intersection = TypeIntersector.intersectTypes(KotlinTypeChecker.DEFAULT, ins); if (intersection == null) { return new TypeProjectionImpl(OUT_VARIANCE, findCommonSupertype(parameterDescriptor.getUpperBounds(), recursionDepth + 1, maxDepth)); } @@ -325,7 +325,7 @@ public class CommonSupertypes { private static void markAll(@NotNull TypeConstructor typeConstructor, @NotNull Set markerSet) { markerSet.add(typeConstructor); - for (KtType type : typeConstructor.getSupertypes()) { + for (KotlinType type : typeConstructor.getSupertypes()) { markAll(type.getConstructor(), markerSet); } } diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/DelegatingType.java b/core/descriptors/src/org/jetbrains/kotlin/types/DelegatingType.java index d87a68c5e01..2b21af4c3b7 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/DelegatingType.java +++ b/core/descriptors/src/org/jetbrains/kotlin/types/DelegatingType.java @@ -24,8 +24,8 @@ import org.jetbrains.kotlin.types.checker.KotlinTypeChecker; import java.util.List; -public abstract class DelegatingType implements KtType { - protected abstract KtType getDelegate(); +public abstract class DelegatingType implements KotlinType { + protected abstract KotlinType getDelegate(); @NotNull @Override @@ -87,9 +87,9 @@ public abstract class DelegatingType implements KtType { @Override public boolean equals(Object obj) { if (this == obj) return true; - if (!(obj instanceof KtType)) return false; + if (!(obj instanceof KotlinType)) return false; - KtType type = (KtType) obj; + KotlinType type = (KotlinType) obj; return KotlinTypeChecker.FLEXIBLE_UNEQUAL_TO_INFLEXIBLE.equalTypes(this, type); } diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/DescriptorSubstitutor.java b/core/descriptors/src/org/jetbrains/kotlin/types/DescriptorSubstitutor.java index 23075e72844..2a9b2a47a76 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/DescriptorSubstitutor.java +++ b/core/descriptors/src/org/jetbrains/kotlin/types/DescriptorSubstitutor.java @@ -67,7 +67,7 @@ public class DescriptorSubstitutor { for (TypeParameterDescriptor descriptor : typeParameters) { TypeParameterDescriptorImpl substituted = substitutedMap.get(descriptor); - for (KtType upperBound : descriptor.getUpperBounds()) { + for (KotlinType upperBound : descriptor.getUpperBounds()) { substituted.getUpperBounds().add(substitutor.substitute(upperBound, Variance.INVARIANT)); } } diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/DisjointKeysUnionTypeSubstitution.kt b/core/descriptors/src/org/jetbrains/kotlin/types/DisjointKeysUnionTypeSubstitution.kt index 2fba5aad778..cae2f445a01 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/DisjointKeysUnionTypeSubstitution.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/DisjointKeysUnionTypeSubstitution.kt @@ -32,7 +32,7 @@ public class DisjointKeysUnionTypeSubstitution private constructor( } } - override fun get(key: KtType) = first[key] ?: second[key] + override fun get(key: KotlinType) = first[key] ?: second[key] override fun isEmpty() = false diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/ErrorUtils.java b/core/descriptors/src/org/jetbrains/kotlin/types/ErrorUtils.java index 1daac1f756a..87326719c46 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/ErrorUtils.java +++ b/core/descriptors/src/org/jetbrains/kotlin/types/ErrorUtils.java @@ -145,7 +145,7 @@ public class ErrorUtils { } } for (TypeParameterDescriptor parameter : function.getTypeParameters()) { - for (KtType upperBound : parameter.getUpperBounds()) { + for (KotlinType upperBound : parameter.getUpperBounds()) { if (containsErrorType(upperBound)) { return true; } @@ -185,7 +185,7 @@ public class ErrorUtils { @NotNull @Override public Collection getSyntheticExtensionProperties( - @NotNull Collection receiverTypes, @NotNull Name name, + @NotNull Collection receiverTypes, @NotNull Name name, @NotNull LookupLocation location ) { return ERROR_PROPERTY_GROUP; @@ -194,7 +194,7 @@ public class ErrorUtils { @NotNull @Override public Collection getSyntheticExtensionFunctions( - @NotNull Collection receiverTypes, @NotNull Name name, + @NotNull Collection receiverTypes, @NotNull Name name, @NotNull LookupLocation location ) { return Collections.singleton(createErrorFunction(this)); @@ -202,14 +202,14 @@ public class ErrorUtils { @NotNull @Override - public Collection getSyntheticExtensionProperties(@NotNull Collection receiverTypes) { + public Collection getSyntheticExtensionProperties(@NotNull Collection receiverTypes) { return ERROR_PROPERTY_GROUP; } @NotNull @Override public Collection getSyntheticExtensionFunctions( - @NotNull Collection receiverTypes + @NotNull Collection receiverTypes ) { return Collections.singleton(createErrorFunction(this)); } @@ -319,7 +319,7 @@ public class ErrorUtils { @NotNull @Override public Collection getSyntheticExtensionProperties( - @NotNull Collection receiverTypes, @NotNull Name name, + @NotNull Collection receiverTypes, @NotNull Name name, @NotNull LookupLocation location ) { throw new IllegalStateException(); @@ -328,7 +328,7 @@ public class ErrorUtils { @NotNull @Override public Collection getSyntheticExtensionFunctions( - @NotNull Collection receiverTypes, @NotNull Name name, + @NotNull Collection receiverTypes, @NotNull Name name, @NotNull LookupLocation location ) { throw new IllegalStateException(); @@ -336,14 +336,14 @@ public class ErrorUtils { @NotNull @Override - public Collection getSyntheticExtensionProperties(@NotNull Collection receiverTypes) { + public Collection getSyntheticExtensionProperties(@NotNull Collection receiverTypes) { throw new IllegalStateException(); } @NotNull @Override public Collection getSyntheticExtensionFunctions( - @NotNull Collection receiverTypes + @NotNull Collection receiverTypes ) { throw new IllegalStateException(); } @@ -402,7 +402,7 @@ public class ErrorUtils { private static class ErrorClassDescriptor extends ClassDescriptorImpl { public ErrorClassDescriptor(@Nullable String name) { super(getErrorModule(), Name.special(name == null ? "" : ""), - Modality.OPEN, Collections.emptyList(), SourceElement.NO_SOURCE); + Modality.OPEN, Collections.emptyList(), SourceElement.NO_SOURCE); ConstructorDescriptorImpl errorConstructor = ConstructorDescriptorImpl.create(this, Annotations.Companion.getEMPTY(), true, SourceElement.NO_SOURCE); errorConstructor.initialize(Collections.emptyList(), Collections.emptyList(), @@ -460,7 +460,7 @@ public class ErrorUtils { return new ErrorScope(debugMessage); } - private static final KtType ERROR_PROPERTY_TYPE = createErrorType(""); + private static final KotlinType ERROR_PROPERTY_TYPE = createErrorType(""); private static final PropertyDescriptor ERROR_PROPERTY = createErrorProperty(); private static final Set ERROR_VARIABLE_GROUP = Collections.singleton(ERROR_PROPERTY); @@ -483,7 +483,7 @@ public class ErrorUtils { descriptor.setType(ERROR_PROPERTY_TYPE, Collections.emptyList(), null, - (KtType) null + (KotlinType) null ); return descriptor; @@ -505,22 +505,22 @@ public class ErrorUtils { } @NotNull - public static KtType createErrorType(@NotNull String debugMessage) { + public static KotlinType createErrorType(@NotNull String debugMessage) { return createErrorTypeWithArguments(debugMessage, Collections.emptyList()); } @NotNull - public static KtType createErrorTypeWithCustomDebugName(@NotNull String debugName) { + public static KotlinType createErrorTypeWithCustomDebugName(@NotNull String debugName) { return createErrorTypeWithCustomConstructor(debugName, createErrorTypeConstructorWithCustomDebugName(debugName)); } @NotNull - public static KtType createErrorTypeWithCustomConstructor(@NotNull String debugName, @NotNull TypeConstructor typeConstructor) { + public static KotlinType createErrorTypeWithCustomConstructor(@NotNull String debugName, @NotNull TypeConstructor typeConstructor) { return new ErrorTypeImpl(typeConstructor, createErrorScope(debugName)); } @NotNull - public static KtType createErrorTypeWithArguments(@NotNull String debugMessage, @NotNull List arguments) { + public static KotlinType createErrorTypeWithArguments(@NotNull String debugMessage, @NotNull List arguments) { return new ErrorTypeImpl(createErrorTypeConstructor(debugMessage), createErrorScope(debugMessage), arguments); } @@ -547,7 +547,7 @@ public class ErrorUtils { @NotNull @Override - public Collection getSupertypes() { + public Collection getSupertypes() { return emptyList(); } @@ -586,7 +586,7 @@ public class ErrorUtils { }; } - public static boolean containsErrorType(@Nullable KtType type) { + public static boolean containsErrorType(@Nullable KotlinType type) { if (type == null) return false; if (type.isError()) return true; for (TypeProjection projection : type.getArguments()) { @@ -615,7 +615,7 @@ public class ErrorUtils { ); } - private static class ErrorTypeImpl implements KtType { + private static class ErrorTypeImpl implements KotlinType { private final TypeConstructor constructor; private final KtScope memberScope; private final List arguments; @@ -697,21 +697,21 @@ public class ErrorUtils { return ERROR_MODULE; } - public static boolean isUninferredParameter(@Nullable KtType type) { + public static boolean isUninferredParameter(@Nullable KotlinType type) { return type != null && type.getConstructor() instanceof UninferredParameterTypeConstructor; } - public static boolean containsUninferredParameter(@Nullable KtType type) { - return TypeUtils.containsSpecialType(type, new Function1() { + public static boolean containsUninferredParameter(@Nullable KotlinType type) { + return TypeUtils.containsSpecialType(type, new Function1() { @Override - public Boolean invoke(KtType argumentType) { + public Boolean invoke(KotlinType argumentType) { return isUninferredParameter(argumentType); } }); } @NotNull - public static KtType createUninferredParameterType(@NotNull TypeParameterDescriptor typeParameterDescriptor) { + public static KotlinType createUninferredParameterType(@NotNull TypeParameterDescriptor typeParameterDescriptor) { return createErrorTypeWithCustomConstructor("Scope for error type for not inferred parameter: " + typeParameterDescriptor.getName(), new UninferredParameterTypeConstructor(typeParameterDescriptor)); } @@ -738,7 +738,7 @@ public class ErrorUtils { @NotNull @Override - public Collection getSupertypes() { + public Collection getSupertypes() { return errorTypeConstructor.getSupertypes(); } diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/FunctionPlaceholders.kt b/core/descriptors/src/org/jetbrains/kotlin/types/FunctionPlaceholders.kt index d471ba57ce4..3f38231ae08 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/FunctionPlaceholders.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/FunctionPlaceholders.kt @@ -23,9 +23,9 @@ import org.jetbrains.kotlin.descriptors.annotations.Annotations class FunctionPlaceholders(private val builtIns: KotlinBuiltIns) { fun createFunctionPlaceholderType( - argumentTypes: List, + argumentTypes: List, hasDeclaredArguments: Boolean - ): KtType { + ): KotlinType { return ErrorUtils.createErrorTypeWithCustomConstructor( "function placeholder type", FunctionPlaceholderTypeConstructor(argumentTypes, hasDeclaredArguments, builtIns) @@ -33,13 +33,13 @@ class FunctionPlaceholders(private val builtIns: KotlinBuiltIns) { } } -val KtType?.isFunctionPlaceholder: Boolean +val KotlinType?.isFunctionPlaceholder: Boolean get() { return this != null && constructor is FunctionPlaceholderTypeConstructor } class FunctionPlaceholderTypeConstructor( - val argumentTypes: List, + val argumentTypes: List, val hasDeclaredArguments: Boolean, private val kotlinBuiltIns: KotlinBuiltIns ) : TypeConstructor { @@ -49,7 +49,7 @@ class FunctionPlaceholderTypeConstructor( return errorTypeConstructor.parameters } - override fun getSupertypes(): Collection { + override fun getSupertypes(): Collection { return errorTypeConstructor.supertypes } diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/IntersectionTypeConstructor.java b/core/descriptors/src/org/jetbrains/kotlin/types/IntersectionTypeConstructor.java index e5a49b54dd5..b45e4b5f337 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/IntersectionTypeConstructor.java +++ b/core/descriptors/src/org/jetbrains/kotlin/types/IntersectionTypeConstructor.java @@ -26,14 +26,14 @@ import org.jetbrains.kotlin.descriptors.annotations.Annotations; import java.util.*; public class IntersectionTypeConstructor extends AnnotatedImpl implements TypeConstructor { - private final Set intersectedTypes; + private final Set intersectedTypes; private final int hashCode; - public IntersectionTypeConstructor(Annotations annotations, Collection typesToIntersect) { + public IntersectionTypeConstructor(Annotations annotations, Collection typesToIntersect) { super(annotations); assert !typesToIntersect.isEmpty() : "Attempt to create an empty intersection"; - this.intersectedTypes = new LinkedHashSet(typesToIntersect); + this.intersectedTypes = new LinkedHashSet(typesToIntersect); this.hashCode = intersectedTypes.hashCode(); } @@ -45,7 +45,7 @@ public class IntersectionTypeConstructor extends AnnotatedImpl implements TypeCo @NotNull @Override - public Collection getSupertypes() { + public Collection getSupertypes() { return intersectedTypes; } @@ -75,10 +75,10 @@ public class IntersectionTypeConstructor extends AnnotatedImpl implements TypeCo return makeDebugNameForIntersectionType(intersectedTypes); } - private static String makeDebugNameForIntersectionType(Iterable resultingTypes) { + private static String makeDebugNameForIntersectionType(Iterable resultingTypes) { StringBuilder debugName = new StringBuilder("{"); - for (Iterator iterator = resultingTypes.iterator(); iterator.hasNext(); ) { - KtType type = iterator.next(); + for (Iterator iterator = resultingTypes.iterator(); iterator.hasNext(); ) { + KotlinType type = iterator.next(); debugName.append(type.toString()); if (iterator.hasNext()) { diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/KtType.java b/core/descriptors/src/org/jetbrains/kotlin/types/KotlinType.java similarity index 92% rename from core/descriptors/src/org/jetbrains/kotlin/types/KtType.java rename to core/descriptors/src/org/jetbrains/kotlin/types/KotlinType.java index 8d363665e6e..fed8f75fe63 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/KtType.java +++ b/core/descriptors/src/org/jetbrains/kotlin/types/KotlinType.java @@ -26,9 +26,9 @@ import org.jetbrains.kotlin.types.checker.KotlinTypeChecker; import java.util.List; /** - * @see KotlinTypeChecker#isSubtypeOf(KtType, KtType) + * @see KotlinTypeChecker#isSubtypeOf(KotlinType, KotlinType) */ -public interface KtType extends Annotated { +public interface KotlinType extends Annotated { @NotNull TypeConstructor getConstructor(); diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/KtTypeImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/types/KotlinTypeImpl.kt similarity index 85% rename from core/descriptors/src/org/jetbrains/kotlin/types/KtTypeImpl.kt rename to core/descriptors/src/org/jetbrains/kotlin/types/KotlinTypeImpl.kt index 45341556a8c..620dfc3f1fb 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/KtTypeImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/KotlinTypeImpl.kt @@ -20,7 +20,7 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.annotations.Annotations import org.jetbrains.kotlin.resolve.scopes.KtScope -public open class KtTypeImpl +public open class KotlinTypeImpl private constructor( private val annotations: Annotations, private val constructor: TypeConstructor, @@ -28,7 +28,7 @@ private constructor( private val arguments: List, private val substitution: TypeSubstitution?, private val memberScope: KtScope -) : AbstractKtType() { +) : AbstractKotlinType() { companion object { @JvmStatic @@ -36,9 +36,9 @@ private constructor( constructor: TypeConstructor, nullable: Boolean, arguments: List, - memberScope: KtScope): KtTypeImpl + memberScope: KtScope): KotlinTypeImpl - = KtTypeImpl(annotations, constructor, nullable, arguments, null, memberScope) + = KotlinTypeImpl(annotations, constructor, nullable, arguments, null, memberScope) @JvmStatic public fun create(annotations: Annotations, @@ -48,20 +48,20 @@ private constructor( substitution: TypeSubstitution, memberScope: KtScope, capabilities: TypeCapabilities - ): KtTypeImpl { + ): KotlinTypeImpl { if (capabilities !== TypeCapabilities.NONE) { return WithCapabilities(annotations, constructor, nullable, arguments, substitution, memberScope, capabilities) } - return KtTypeImpl(annotations, constructor, nullable, arguments, substitution, memberScope) + return KotlinTypeImpl(annotations, constructor, nullable, arguments, substitution, memberScope) } @JvmStatic public fun create(annotations: Annotations, descriptor: ClassDescriptor, nullable: Boolean, - arguments: List): KtTypeImpl + arguments: List): KotlinTypeImpl - = KtTypeImpl( + = KotlinTypeImpl( annotations, descriptor.typeConstructor, nullable, arguments, null, descriptor.getMemberScope(arguments) ) } @@ -74,7 +74,7 @@ private constructor( substitution: TypeSubstitution?, memberScope: KtScope, private val typeCapabilities: TypeCapabilities - ) : KtTypeImpl(annotations, constructor, nullable, arguments, substitution, memberScope) { + ) : KotlinTypeImpl(annotations, constructor, nullable, arguments, substitution, memberScope) { override fun getCapabilities(): TypeCapabilities = typeCapabilities } diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/LazyType.java b/core/descriptors/src/org/jetbrains/kotlin/types/LazyType.java index da055a0b632..c02915cc75b 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/LazyType.java +++ b/core/descriptors/src/org/jetbrains/kotlin/types/LazyType.java @@ -16,5 +16,5 @@ package org.jetbrains.kotlin.types; -public interface LazyType extends KtType { +public interface LazyType extends KotlinType { } diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/StarProjectionImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/types/StarProjectionImpl.kt index c8314062c79..d10509738c9 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/StarProjectionImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/StarProjectionImpl.kt @@ -27,14 +27,14 @@ class StarProjectionImpl( override fun getProjectionKind() = Variance.OUT_VARIANCE // No synchronization here: there's no problem in accidentally computing this twice - private val _type: KtType by lazy(LazyThreadSafetyMode.NONE) { + private val _type: KotlinType by lazy(LazyThreadSafetyMode.NONE) { typeParameter.starProjectionType() } override fun getType() = _type } -public fun TypeParameterDescriptor.starProjectionType(): KtType { +public fun TypeParameterDescriptor.starProjectionType(): KotlinType { val classDescriptor = this.getContainingDeclaration() as ClassDescriptor val typeParameters = classDescriptor.getTypeConstructor().getParameters().map { it.getTypeConstructor() } return TypeSubstitutor.create( @@ -49,7 +49,7 @@ public fun TypeParameterDescriptor.starProjectionType(): KtType { } class TypeBasedStarProjectionImpl( - private val _type: KtType + private val _type: KotlinType ) : TypeProjectionBase() { override fun isStarProjection() = true diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/TypeCapabilities.kt b/core/descriptors/src/org/jetbrains/kotlin/types/TypeCapabilities.kt index c4653f2f8d3..9cfc1715ca1 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/TypeCapabilities.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/TypeCapabilities.kt @@ -28,7 +28,7 @@ public interface TypeCapabilities { fun getCapability(capabilityClass: Class): T? } -public inline fun KtType.getCapability(): T? = getCapability(javaClass()) +public inline fun KotlinType.getCapability(): T? = getCapability(javaClass()) public interface Specificity : TypeCapability { @@ -38,16 +38,16 @@ public interface Specificity : TypeCapability { DONT_KNOW } - public fun getSpecificityRelationTo(otherType: KtType): Relation + public fun getSpecificityRelationTo(otherType: KotlinType): Relation } -fun KtType.getSpecificityRelationTo(otherType: KtType) = +fun KotlinType.getSpecificityRelationTo(otherType: KotlinType) = this.getCapability(javaClass())?.getSpecificityRelationTo(otherType) ?: Specificity.Relation.DONT_KNOW -fun oneMoreSpecificThanAnother(a: KtType, b: KtType) = +fun oneMoreSpecificThanAnother(a: KotlinType, b: KotlinType) = a.getSpecificityRelationTo(b) != Specificity.Relation.DONT_KNOW || b.getSpecificityRelationTo(a) != Specificity.Relation.DONT_KNOW -// To facilitate laziness, any KtType implementation may inherit from this trait, +// To facilitate laziness, any KotlinType implementation may inherit from this trait, // even if it turns out that the type an instance represents is not actually a type variable // (i.e. it is not derived from a type parameter), see isTypeVariable public interface CustomTypeVariable : TypeCapability { @@ -57,29 +57,29 @@ public interface CustomTypeVariable : TypeCapability { public val typeParameterDescriptor: TypeParameterDescriptor? // Throws an exception when isTypeVariable == false - public fun substitutionResult(replacement: KtType): KtType + public fun substitutionResult(replacement: KotlinType): KotlinType } -public fun KtType.isCustomTypeVariable(): Boolean = this.getCapability(javaClass())?.isTypeVariable ?: false -public fun KtType.getCustomTypeVariable(): CustomTypeVariable? = +public fun KotlinType.isCustomTypeVariable(): Boolean = this.getCapability(javaClass())?.isTypeVariable ?: false +public fun KotlinType.getCustomTypeVariable(): CustomTypeVariable? = this.getCapability(javaClass())?.let { if (it.isTypeVariable) it else null } public interface SubtypingRepresentatives : TypeCapability { - public val subTypeRepresentative: KtType - public val superTypeRepresentative: KtType + public val subTypeRepresentative: KotlinType + public val superTypeRepresentative: KotlinType - public fun sameTypeConstructor(type: KtType): Boolean + public fun sameTypeConstructor(type: KotlinType): Boolean } -public fun KtType.getSubtypeRepresentative(): KtType = +public fun KotlinType.getSubtypeRepresentative(): KotlinType = this.getCapability(javaClass())?.subTypeRepresentative ?: this -public fun KtType.getSupertypeRepresentative(): KtType = +public fun KotlinType.getSupertypeRepresentative(): KotlinType = this.getCapability(javaClass())?.superTypeRepresentative ?: this -public fun sameTypeConstructors(first: KtType, second: KtType): Boolean { +public fun sameTypeConstructors(first: KotlinType, second: KotlinType): Boolean { val typeRangeCapability = javaClass() return first.getCapability(typeRangeCapability)?.sameTypeConstructor(second) ?: false || second.getCapability(typeRangeCapability)?.sameTypeConstructor(first) ?: false diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/TypeConstructor.java b/core/descriptors/src/org/jetbrains/kotlin/types/TypeConstructor.java index 2709312505f..38bd4c130f8 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/TypeConstructor.java +++ b/core/descriptors/src/org/jetbrains/kotlin/types/TypeConstructor.java @@ -34,7 +34,7 @@ public interface TypeConstructor extends Annotated { @NotNull @ReadOnly - Collection getSupertypes(); + Collection getSupertypes(); /** * Cannot have subtypes. diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/TypeConstructorImpl.java b/core/descriptors/src/org/jetbrains/kotlin/types/TypeConstructorImpl.java index b6160b19c0d..9a67b92a232 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/TypeConstructorImpl.java +++ b/core/descriptors/src/org/jetbrains/kotlin/types/TypeConstructorImpl.java @@ -40,7 +40,7 @@ public abstract class TypeConstructorImpl extends AnnotatedImpl implements TypeC boolean isFinal, @NotNull String debugName, @NotNull List parameters, - @NotNull Collection supertypes + @NotNull Collection supertypes ) { return new TypeConstructorImpl(classDescriptor, annotations, isFinal, debugName, parameters, supertypes) { @Override @@ -63,7 +63,7 @@ public abstract class TypeConstructorImpl extends AnnotatedImpl implements TypeC boolean isFinal, @NotNull String debugName, @NotNull List parameters, - @NotNull Collection supertypes + @NotNull Collection supertypes ) { return new TypeConstructorImpl(typeParameterDescriptor, annotations, isFinal, debugName, parameters, supertypes) { @Override @@ -79,7 +79,7 @@ public abstract class TypeConstructorImpl extends AnnotatedImpl implements TypeC } private final List parameters; - private final Collection supertypes; + private final Collection supertypes; private final String debugName; private final boolean isFinal; @@ -91,7 +91,7 @@ public abstract class TypeConstructorImpl extends AnnotatedImpl implements TypeC boolean isFinal, @NotNull String debugName, @NotNull List parameters, - @NotNull Collection supertypes) { + @NotNull Collection supertypes) { super(annotations); this.classifierDescriptor = classifierDescriptor; this.isFinal = isFinal; @@ -108,7 +108,7 @@ public abstract class TypeConstructorImpl extends AnnotatedImpl implements TypeC @Override @NotNull - public Collection getSupertypes() { + public Collection getSupertypes() { return supertypes; } diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/TypeIntersector.java b/core/descriptors/src/org/jetbrains/kotlin/types/TypeIntersector.java index 350c33b6f3f..03a04a702e5 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/TypeIntersector.java +++ b/core/descriptors/src/org/jetbrains/kotlin/types/TypeIntersector.java @@ -37,14 +37,14 @@ import static org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.Co public class TypeIntersector { - public static boolean isIntersectionEmpty(@NotNull KtType typeA, @NotNull KtType typeB) { - return intersectTypes(KotlinTypeChecker.DEFAULT, new LinkedHashSet(Arrays.asList(typeA, typeB))) == null; + public static boolean isIntersectionEmpty(@NotNull KotlinType typeA, @NotNull KotlinType typeB) { + return intersectTypes(KotlinTypeChecker.DEFAULT, new LinkedHashSet(Arrays.asList(typeA, typeB))) == null; } @Nullable - public static KtType intersectTypes( + public static KotlinType intersectTypes( @NotNull KotlinTypeChecker typeChecker, - @NotNull Set types + @NotNull Set types ) { assert (!types.isEmpty()) : "Attempting to intersect empty set of types, this case should be dealt with on the call site."; @@ -54,10 +54,10 @@ public class TypeIntersector { // Intersection of T1..Tn is an intersection of their non-null versions, // made nullable is they all were nullable - KtType nothingOrNullableNothing = null; + KotlinType nothingOrNullableNothing = null; boolean allNullable = true; - List nullabilityStripped = new ArrayList(types.size()); - for (KtType type : types) { + List nullabilityStripped = new ArrayList(types.size()); + for (KotlinType type : types) { if (type.isError()) continue; if (KotlinBuiltIns.isNothingOrNullableNothing(type)) { @@ -77,11 +77,11 @@ public class TypeIntersector { } // Now we remove types that have subtypes in the list - List resultingTypes = new ArrayList(); + List resultingTypes = new ArrayList(); outer: - for (KtType type : nullabilityStripped) { + for (KotlinType type : nullabilityStripped) { if (!TypeUtils.canHaveSubtypes(typeChecker, type)) { - for (KtType other : nullabilityStripped) { + for (KotlinType other : nullabilityStripped) { // It makes sense to check for subtyping (other <: type), despite that // type is not supposed to be open, for there're enums if (!TypeUnifier.mayBeEqual(type, other) && !typeChecker.isSubtypeOf(type, other) && !typeChecker.isSubtypeOf(other, type)) { @@ -91,7 +91,7 @@ public class TypeIntersector { return TypeUtils.makeNullableAsSpecified(type, allNullable); } else { - for (KtType other : nullabilityStripped) { + for (KotlinType other : nullabilityStripped) { if (!type.equals(other) && typeChecker.isSubtypeOf(other, type)) { continue outer; } @@ -100,7 +100,7 @@ public class TypeIntersector { } // Don't add type if it is already present, to avoid trivial type intersections in result - for (KtType other : resultingTypes) { + for (KotlinType other : resultingTypes) { if (typeChecker.equalTypes(other, type)) { continue outer; } @@ -114,7 +114,7 @@ public class TypeIntersector { // in that case, we can safely select the best representative out of that set and return it // TODO: maybe return the most specific among the types that are subtypes to all others in the `nullabilityStripped`? // TODO: e.g. among {Int, Int?, Int!}, return `Int` (now it returns `Int!`). - KtType bestRepresentative = FlexibleTypesKt.singleBestRepresentative(nullabilityStripped); + KotlinType bestRepresentative = FlexibleTypesKt.singleBestRepresentative(nullabilityStripped); if (bestRepresentative == null) { throw new AssertionError("Empty intersection for types " + types); } @@ -129,12 +129,12 @@ public class TypeIntersector { KtScope[] scopes = new KtScope[resultingTypes.size()]; int i = 0; - for (KtType type : resultingTypes) { + for (KotlinType type : resultingTypes) { scopes[i] = type.getMemberScope(); i++; } - return KtTypeImpl.create( + return KotlinTypeImpl.create( Annotations.Companion.getEMPTY(), constructor, allNullable, @@ -167,11 +167,11 @@ public class TypeIntersector { } } - public static boolean mayBeEqual(@NotNull KtType type, @NotNull KtType other) { + public static boolean mayBeEqual(@NotNull KotlinType type, @NotNull KotlinType other) { return unify(type, other); } - private static boolean unify(KtType withParameters, KtType expected) { + private static boolean unify(KotlinType withParameters, KotlinType expected) { // T -> how T is used final Map parameters = new HashMap(); Function1 processor = new Function1() { @@ -195,7 +195,7 @@ public class TypeIntersector { return constraintSystem.getStatus().isSuccessful(); } - private static void processAllTypeParameters(KtType type, Variance howThisTypeIsUsed, Function1 result) { + private static void processAllTypeParameters(KotlinType type, Variance howThisTypeIsUsed, Function1 result) { ClassifierDescriptor descriptor = type.getConstructor().getDeclarationDescriptor(); if (descriptor instanceof TypeParameterDescriptor) { result.invoke(new TypeParameterUsage((TypeParameterDescriptor) descriptor, howThisTypeIsUsed)); diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/TypeProjection.java b/core/descriptors/src/org/jetbrains/kotlin/types/TypeProjection.java index 37d823bacf5..346026017f8 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/TypeProjection.java +++ b/core/descriptors/src/org/jetbrains/kotlin/types/TypeProjection.java @@ -23,7 +23,7 @@ public interface TypeProjection { Variance getProjectionKind(); @NotNull - KtType getType(); + KotlinType getType(); boolean isStarProjection(); } diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/TypeProjectionImpl.java b/core/descriptors/src/org/jetbrains/kotlin/types/TypeProjectionImpl.java index 410498f87a3..920bbe4194c 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/TypeProjectionImpl.java +++ b/core/descriptors/src/org/jetbrains/kotlin/types/TypeProjectionImpl.java @@ -20,14 +20,14 @@ import org.jetbrains.annotations.NotNull; public class TypeProjectionImpl extends TypeProjectionBase { private final Variance projection; - private final KtType type; + private final KotlinType type; - public TypeProjectionImpl(@NotNull Variance projection, @NotNull KtType type) { + public TypeProjectionImpl(@NotNull Variance projection, @NotNull KotlinType type) { this.projection = projection; this.type = type; } - public TypeProjectionImpl(@NotNull KtType type) { + public TypeProjectionImpl(@NotNull KotlinType type) { this(Variance.INVARIANT, type); } @@ -39,7 +39,7 @@ public class TypeProjectionImpl extends TypeProjectionBase { @Override @NotNull - public KtType getType() { + public KotlinType getType() { return type; } diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/TypeSubstitution.kt b/core/descriptors/src/org/jetbrains/kotlin/types/TypeSubstitution.kt index a5def888ad0..e00a1e008d4 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/TypeSubstitution.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/TypeSubstitution.kt @@ -23,13 +23,13 @@ public abstract class TypeSubstitution { companion object { @JvmStatic public val EMPTY: TypeSubstitution = object : TypeSubstitution() { - override fun get(key: KtType) = null + override fun get(key: KotlinType) = null override fun isEmpty() = true override fun toString() = "Empty TypeSubstitution" } } - public abstract fun get(key: KtType): TypeProjection? + public abstract fun get(key: KotlinType): TypeProjection? public open fun isEmpty(): Boolean = false @@ -41,7 +41,7 @@ public abstract class TypeSubstitution { } public abstract class TypeConstructorSubstitution : TypeSubstitution() { - override fun get(key: KtType) = get(key.constructor) + override fun get(key: KotlinType) = get(key.constructor) public abstract fun get(key: TypeConstructor): TypeProjection? @@ -82,7 +82,7 @@ public class IndexedParametersSubstitution( override fun isEmpty(): Boolean = arguments.isEmpty() - override fun get(key: KtType): TypeProjection? { + override fun get(key: KotlinType): TypeProjection? { val parameter = key.constructor.declarationDescriptor as? TypeParameterDescriptor ?: return null val index = parameter.index @@ -94,7 +94,7 @@ public class IndexedParametersSubstitution( } } -public fun KtType.computeNewSubstitution( +public fun KotlinType.computeNewSubstitution( newParameters: List, newArguments: List ): TypeSubstitution { @@ -118,7 +118,7 @@ private class CompositeTypeSubstitution( private val second: TypeSubstitution ) : TypeSubstitution() { - override fun get(key: KtType): TypeProjection? { + override fun get(key: KotlinType): TypeProjection? { val firstResult = first[key] ?: return second[key] return second.buildSubstitutor().substitute(firstResult) } @@ -131,7 +131,7 @@ private class CompositeTypeSubstitution( } public open class DelegatedTypeSubstitution(val substitution: TypeSubstitution): TypeSubstitution() { - override fun get(key: KtType) = substitution.get(key) + override fun get(key: KotlinType) = substitution.get(key) override fun isEmpty() = substitution.isEmpty() diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/TypeSubstitutor.java b/core/descriptors/src/org/jetbrains/kotlin/types/TypeSubstitutor.java index f6f600adb63..8b335b32d51 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/TypeSubstitutor.java +++ b/core/descriptors/src/org/jetbrains/kotlin/types/TypeSubstitutor.java @@ -63,7 +63,7 @@ public class TypeSubstitutor { } @NotNull - public static TypeSubstitutor create(@NotNull KtType context) { + public static TypeSubstitutor create(@NotNull KotlinType context) { return create(new IndexedParametersSubstitution(context.getConstructor(), context.getArguments())); } @@ -85,7 +85,7 @@ public class TypeSubstitutor { } @NotNull - public KtType safeSubstitute(@NotNull KtType type, @NotNull Variance howThisTypeIsUsed) { + public KotlinType safeSubstitute(@NotNull KotlinType type, @NotNull Variance howThisTypeIsUsed) { if (isEmpty()) { return type; } @@ -98,7 +98,7 @@ public class TypeSubstitutor { } @Nullable - public KtType substitute(@NotNull KtType type, @NotNull Variance howThisTypeIsUsed) { + public KotlinType substitute(@NotNull KotlinType type, @NotNull Variance howThisTypeIsUsed) { TypeProjection projection = substitute(new TypeProjectionImpl(howThisTypeIsUsed, type)); return projection == null ? null : projection.getType(); } @@ -132,7 +132,7 @@ public class TypeSubstitutor { if (originalProjection.isStarProjection()) return originalProjection; // The type is within the substitution range, i.e. T or T? - KtType type = originalProjection.getType(); + KotlinType type = originalProjection.getType(); TypeProjection replacement = substitution.get(type); Variance originalProjectionKind = originalProjection.getProjectionKind(); if (replacement == null && FlexibleTypesKt.isFlexible(type) && !TypeCapabilitiesKt.isCustomTypeVariable(type)) { @@ -147,7 +147,7 @@ public class TypeSubstitutor { originalProjectionKind == Variance.INVARIANT || originalProjectionKind == substitutedProjectionKind : "Unexpected substituted projection kind: " + substitutedProjectionKind + "; original: " + originalProjectionKind; - KtType substitutedFlexibleType = DelegatingFlexibleType.create( + KotlinType substitutedFlexibleType = DelegatingFlexibleType.create( substitutedLower.getType(), substitutedUpper.getType(), flexibility.getExtraCapabilities()); return new TypeProjectionImpl(substitutedProjectionKind, substitutedFlexibleType); } @@ -171,7 +171,7 @@ public class TypeSubstitutor { return new TypeProjectionImpl(Variance.OUT_VARIANCE, type.getConstructor().getBuiltIns().getNullableAnyType()); } } - KtType substitutedType; + KotlinType substitutedType; CustomTypeVariable typeVariable = TypeCapabilitiesKt.getCustomTypeVariable(type); if (replacement.isStarProjection()) { return replacement; @@ -217,7 +217,7 @@ public class TypeSubstitutor { TypeProjection originalProjection, int recursionDepth ) throws SubstitutionException { - final KtType type = originalProjection.getType(); + final KotlinType type = originalProjection.getType(); Variance projectionKind = originalProjection.getProjectionKind(); if (type.getConstructor().getDeclarationDescriptor() instanceof TypeParameterDescriptor) { // substitution can't change type parameter @@ -236,17 +236,17 @@ public class TypeSubstitutor { @Nullable @Override - public TypeProjection get(@NotNull KtType key) { + public TypeProjection get(@NotNull KotlinType key) { return containedOrCapturedTypeParameters.contains(key.getConstructor()) ? substitution.get(key) : null; } }; - KtType substitutedType = KtTypeImpl.create(type.getAnnotations(), // Old annotations. This is questionable - type.getConstructor(), // The same constructor - type.isMarkedNullable(), // Same nullability - substitutedArguments, - substitutionFilteringTypeParameters, - new SubstitutingScope(type.getMemberScope(), create(substitutionFilteringTypeParameters)), - type.getCapabilities()); + KotlinType substitutedType = KotlinTypeImpl.create(type.getAnnotations(), // Old annotations. This is questionable + type.getConstructor(), // The same constructor + type.isMarkedNullable(), // Same nullability + substitutedArguments, + substitutionFilteringTypeParameters, + new SubstitutingScope(type.getMemberScope(), create(substitutionFilteringTypeParameters)), + type.getCapabilities()); return new TypeProjectionImpl(projectionKind, substitutedType); } diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.java b/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.java index 816d405ea6b..7779d51eb34 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.java +++ b/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.java @@ -33,12 +33,12 @@ import org.jetbrains.kotlin.utils.DFS; import java.util.*; public class TypeUtils { - public static final KtType DONT_CARE = ErrorUtils.createErrorTypeWithCustomDebugName("DONT_CARE"); - public static final KtType PLACEHOLDER_FUNCTION_TYPE = ErrorUtils.createErrorTypeWithCustomDebugName("PLACEHOLDER_FUNCTION_TYPE"); + public static final KotlinType DONT_CARE = ErrorUtils.createErrorTypeWithCustomDebugName("DONT_CARE"); + public static final KotlinType PLACEHOLDER_FUNCTION_TYPE = ErrorUtils.createErrorTypeWithCustomDebugName("PLACEHOLDER_FUNCTION_TYPE"); - public static final KtType CANT_INFER_FUNCTION_PARAM_TYPE = ErrorUtils.createErrorType("Cannot be inferred"); + public static final KotlinType CANT_INFER_FUNCTION_PARAM_TYPE = ErrorUtils.createErrorType("Cannot be inferred"); - public static class SpecialType implements KtType { + public static class SpecialType implements KotlinType { private final String name; public SpecialType(String name) { @@ -104,30 +104,30 @@ public class TypeUtils { } @NotNull - public static final KtType NO_EXPECTED_TYPE = new SpecialType("NO_EXPECTED_TYPE"); + public static final KotlinType NO_EXPECTED_TYPE = new SpecialType("NO_EXPECTED_TYPE"); - public static final KtType UNIT_EXPECTED_TYPE = new SpecialType("UNIT_EXPECTED_TYPE"); + public static final KotlinType UNIT_EXPECTED_TYPE = new SpecialType("UNIT_EXPECTED_TYPE"); - public static boolean noExpectedType(@NotNull KtType type) { + public static boolean noExpectedType(@NotNull KotlinType type) { return type == NO_EXPECTED_TYPE || type == UNIT_EXPECTED_TYPE; } - public static boolean isDontCarePlaceholder(@Nullable KtType type) { + public static boolean isDontCarePlaceholder(@Nullable KotlinType type) { return type != null && type.getConstructor() == DONT_CARE.getConstructor(); } @NotNull - public static KtType makeNullable(@NotNull KtType type) { + public static KotlinType makeNullable(@NotNull KotlinType type) { return makeNullableAsSpecified(type, true); } @NotNull - public static KtType makeNotNullable(@NotNull KtType type) { + public static KotlinType makeNotNullable(@NotNull KotlinType type) { return makeNullableAsSpecified(type, false); } @NotNull - public static KtType makeNullableAsSpecified(@NotNull KtType type, boolean nullable) { + public static KotlinType makeNullableAsSpecified(@NotNull KotlinType type, boolean nullable) { NullAwareness nullAwareness = type.getCapability(NullAwareness.class); if (nullAwareness != null) { return nullAwareness.makeNullableAsSpecified(nullable); @@ -151,14 +151,14 @@ public class TypeUtils { } @NotNull - public static KtType makeNullableIfNeeded(@NotNull KtType type, boolean nullable) { + public static KotlinType makeNullableIfNeeded(@NotNull KotlinType type, boolean nullable) { if (nullable) { return makeNullable(type); } return type; } - public static boolean canHaveSubtypes(KotlinTypeChecker typeChecker, @NotNull KtType type) { + public static boolean canHaveSubtypes(KotlinTypeChecker typeChecker, @NotNull KotlinType type) { if (type.isMarkedNullable()) { return true; } @@ -172,7 +172,7 @@ public class TypeUtils { TypeParameterDescriptor parameterDescriptor = parameters.get(i); TypeProjection typeProjection = arguments.get(i); Variance projectionKind = typeProjection.getProjectionKind(); - KtType argument = typeProjection.getType(); + KotlinType argument = typeProjection.getType(); switch (parameterDescriptor.getVariance()) { case INVARIANT: @@ -223,8 +223,8 @@ public class TypeUtils { return false; } - private static boolean lowerThanBound(KotlinTypeChecker typeChecker, KtType argument, TypeParameterDescriptor parameterDescriptor) { - for (KtType bound : parameterDescriptor.getUpperBounds()) { + private static boolean lowerThanBound(KotlinTypeChecker typeChecker, KotlinType argument, TypeParameterDescriptor parameterDescriptor) { + for (KotlinType bound : parameterDescriptor.getUpperBounds()) { if (typeChecker.isSubtypeOf(argument, bound)) { if (!argument.getConstructor().equals(bound.getConstructor())) { return true; @@ -235,13 +235,13 @@ public class TypeUtils { } @NotNull - public static KtType makeUnsubstitutedType(ClassDescriptor classDescriptor, KtScope unsubstitutedMemberScope) { + public static KotlinType makeUnsubstitutedType(ClassDescriptor classDescriptor, KtScope unsubstitutedMemberScope) { if (ErrorUtils.isError(classDescriptor)) { return ErrorUtils.createErrorType("Unsubstituted type for " + classDescriptor); } TypeConstructor typeConstructor = classDescriptor.getTypeConstructor(); List arguments = getDefaultTypeProjections(typeConstructor.getParameters()); - return KtTypeImpl.create( + return KotlinTypeImpl.create( Annotations.Companion.getEMPTY(), typeConstructor, false, @@ -260,13 +260,13 @@ public class TypeUtils { } @NotNull - public static List getImmediateSupertypes(@NotNull KtType type) { + public static List getImmediateSupertypes(@NotNull KotlinType type) { boolean isNullable = type.isMarkedNullable(); TypeSubstitutor substitutor = TypeSubstitutor.create(type); - Collection originalSupertypes = type.getConstructor().getSupertypes(); - List result = new ArrayList(originalSupertypes.size()); - for (KtType supertype : originalSupertypes) { - KtType substitutedType = substitutor.substitute(supertype, Variance.INVARIANT); + Collection originalSupertypes = type.getConstructor().getSupertypes(); + List result = new ArrayList(originalSupertypes.size()); + for (KotlinType supertype : originalSupertypes) { + KotlinType substitutedType = substitutor.substitute(supertype, Variance.INVARIANT); if (substitutedType != null) { result.add(makeNullableIfNeeded(substitutedType, isNullable)); } @@ -274,26 +274,26 @@ public class TypeUtils { return result; } - private static void collectAllSupertypes(@NotNull KtType type, @NotNull Set result) { - List immediateSupertypes = getImmediateSupertypes(type); + private static void collectAllSupertypes(@NotNull KotlinType type, @NotNull Set result) { + List immediateSupertypes = getImmediateSupertypes(type); result.addAll(immediateSupertypes); - for (KtType supertype : immediateSupertypes) { + for (KotlinType supertype : immediateSupertypes) { collectAllSupertypes(supertype, result); } } @NotNull - public static Set getAllSupertypes(@NotNull KtType type) { + public static Set getAllSupertypes(@NotNull KotlinType type) { // 15 is obtained by experimentation: JDK classes like ArrayList tend to have so many supertypes, // the average number is lower - Set result = new LinkedHashSet(15); + Set result = new LinkedHashSet(15); collectAllSupertypes(type, result); return result; } public static boolean hasNullableLowerBound(@NotNull TypeParameterDescriptor typeParameterDescriptor) { - for (KtType bound : typeParameterDescriptor.getLowerBounds()) { + for (KotlinType bound : typeParameterDescriptor.getLowerBounds()) { if (bound.isMarkedNullable()) { return true; } @@ -306,7 +306,7 @@ public class TypeUtils { * Semantics should be the same as `!isSubtype(T, Any)` * @return true if a value of this type can be null */ - public static boolean isNullableType(@NotNull KtType type) { + public static boolean isNullableType(@NotNull KotlinType type) { if (type.isMarkedNullable()) { return true; } @@ -324,7 +324,7 @@ public class TypeUtils { * Semantics should be the same as `isSubtype(Nothing?, T)` * @return true if `null` can be assigned to storage of this type */ - public static boolean acceptsNullable(@NotNull KtType type) { + public static boolean acceptsNullable(@NotNull KotlinType type) { if (type.isMarkedNullable()) { return true; } @@ -337,13 +337,13 @@ public class TypeUtils { return false; } - public static boolean hasNullableSuperType(@NotNull KtType type) { + public static boolean hasNullableSuperType(@NotNull KotlinType type) { if (type.getConstructor().getDeclarationDescriptor() instanceof ClassDescriptor) { // A class/trait cannot have a nullable supertype return false; } - for (KtType supertype : getImmediateSupertypes(type)) { + for (KotlinType supertype : getImmediateSupertypes(type)) { if (supertype.isMarkedNullable()) return true; if (hasNullableSuperType(supertype)) return true; } @@ -352,7 +352,7 @@ public class TypeUtils { } @Nullable - public static ClassDescriptor getClassDescriptor(@NotNull KtType type) { + public static ClassDescriptor getClassDescriptor(@NotNull KotlinType type) { DeclarationDescriptor declarationDescriptor = type.getConstructor().getDeclarationDescriptor(); if (declarationDescriptor instanceof ClassDescriptor) { return (ClassDescriptor) declarationDescriptor; @@ -361,10 +361,10 @@ public class TypeUtils { } @NotNull - public static KtType substituteParameters(@NotNull ClassDescriptor clazz, @NotNull List typeArguments) { - List projections = CollectionsKt.map(typeArguments, new Function1() { + public static KotlinType substituteParameters(@NotNull ClassDescriptor clazz, @NotNull List typeArguments) { + List projections = CollectionsKt.map(typeArguments, new Function1() { @Override - public TypeProjection invoke(KtType type) { + public TypeProjection invoke(KotlinType type) { return new TypeProjectionImpl(type); } }); @@ -373,7 +373,7 @@ public class TypeUtils { } @NotNull - public static KtType substituteProjectionsForParameters(@NotNull ClassDescriptor clazz, @NotNull List projections) { + public static KotlinType substituteProjectionsForParameters(@NotNull ClassDescriptor clazz, @NotNull List projections) { List clazzTypeParameters = clazz.getTypeConstructor().getParameters(); if (clazzTypeParameters.size() != projections.size()) { throw new IllegalArgumentException("type parameter counts do not match: " + clazz + ", " + projections); @@ -390,11 +390,11 @@ public class TypeUtils { return TypeSubstitutor.create(substitutions).substitute(clazz.getDefaultType(), Variance.INVARIANT); } - public static boolean equalTypes(@NotNull KtType a, @NotNull KtType b) { + public static boolean equalTypes(@NotNull KotlinType a, @NotNull KotlinType b) { return KotlinTypeChecker.DEFAULT.isSubtypeOf(a, b) && KotlinTypeChecker.DEFAULT.isSubtypeOf(b, a); } - public static boolean dependsOnTypeParameters(@NotNull KtType type, @NotNull Collection typeParameters) { + public static boolean dependsOnTypeParameters(@NotNull KotlinType type, @NotNull Collection typeParameters) { return dependsOnTypeConstructors(type, CollectionsKt.map( typeParameters, new Function1() { @@ -406,7 +406,7 @@ public class TypeUtils { )); } - public static boolean dependsOnTypeConstructors(@NotNull KtType type, @NotNull Collection typeParameterConstructors) { + public static boolean dependsOnTypeConstructors(@NotNull KotlinType type, @NotNull Collection typeParameterConstructors) { if (typeParameterConstructors.contains(type.getConstructor())) return true; for (TypeProjection typeProjection : type.getArguments()) { if (!typeProjection.isStarProjection() && dependsOnTypeConstructors(typeProjection.getType(), typeParameterConstructors)) { @@ -416,18 +416,18 @@ public class TypeUtils { return false; } - public static boolean containsSpecialType(@Nullable KtType type, @NotNull final KtType specialType) { - return containsSpecialType(type, new Function1() { + public static boolean containsSpecialType(@Nullable KotlinType type, @NotNull final KotlinType specialType) { + return containsSpecialType(type, new Function1() { @Override - public Boolean invoke(KtType type) { + public Boolean invoke(KotlinType type) { return specialType.equals(type); } }); } public static boolean containsSpecialType( - @Nullable KtType type, - @NotNull Function1 isSpecialType + @Nullable KotlinType type, + @NotNull Function1 isSpecialType ) { if (type == null) return false; if (isSpecialType.invoke(type)) return true; @@ -448,10 +448,10 @@ public class TypeUtils { } @Nullable - public static KtType commonSupertypeForNumberTypes(@NotNull Collection numberLowerBounds) { + public static KotlinType commonSupertypeForNumberTypes(@NotNull Collection numberLowerBounds) { if (numberLowerBounds.isEmpty()) return null; - Set intersectionOfSupertypes = getIntersectionOfSupertypes(numberLowerBounds); - KtType primitiveNumberType = getDefaultPrimitiveNumberType(intersectionOfSupertypes); + Set intersectionOfSupertypes = getIntersectionOfSupertypes(numberLowerBounds); + KotlinType primitiveNumberType = getDefaultPrimitiveNumberType(intersectionOfSupertypes); if (primitiveNumberType != null) { return primitiveNumberType; } @@ -459,10 +459,10 @@ public class TypeUtils { } @NotNull - private static Set getIntersectionOfSupertypes(@NotNull Collection types) { - Set upperBounds = new HashSet(); - for (KtType type : types) { - Collection supertypes = type.getConstructor().getSupertypes(); + private static Set getIntersectionOfSupertypes(@NotNull Collection types) { + Set upperBounds = new HashSet(); + for (KotlinType type : types) { + Collection supertypes = type.getConstructor().getSupertypes(); if (upperBounds.isEmpty()) { upperBounds.addAll(supertypes); } @@ -474,29 +474,29 @@ public class TypeUtils { } @NotNull - public static KtType getDefaultPrimitiveNumberType(@NotNull IntegerValueTypeConstructor numberValueTypeConstructor) { - KtType type = getDefaultPrimitiveNumberType(numberValueTypeConstructor.getSupertypes()); + public static KotlinType getDefaultPrimitiveNumberType(@NotNull IntegerValueTypeConstructor numberValueTypeConstructor) { + KotlinType type = getDefaultPrimitiveNumberType(numberValueTypeConstructor.getSupertypes()); assert type != null : "Strange number value type constructor: " + numberValueTypeConstructor + ". " + "Super types doesn't contain double, int or long: " + numberValueTypeConstructor.getSupertypes(); return type; } @Nullable - private static KtType getDefaultPrimitiveNumberType(@NotNull Collection supertypes) { + private static KotlinType getDefaultPrimitiveNumberType(@NotNull Collection supertypes) { if (supertypes.isEmpty()) { return null; } KotlinBuiltIns builtIns = supertypes.iterator().next().getConstructor().getBuiltIns(); - KtType doubleType = builtIns.getDoubleType(); + KotlinType doubleType = builtIns.getDoubleType(); if (supertypes.contains(doubleType)) { return doubleType; } - KtType intType = builtIns.getIntType(); + KotlinType intType = builtIns.getIntType(); if (supertypes.contains(intType)) { return intType; } - KtType longType = builtIns.getLongType(); + KotlinType longType = builtIns.getLongType(); if (supertypes.contains(longType)) { return longType; } @@ -504,14 +504,14 @@ public class TypeUtils { } @NotNull - public static KtType getPrimitiveNumberType( + public static KotlinType getPrimitiveNumberType( @NotNull IntegerValueTypeConstructor numberValueTypeConstructor, - @NotNull KtType expectedType + @NotNull KotlinType expectedType ) { if (noExpectedType(expectedType) || expectedType.isError()) { return getDefaultPrimitiveNumberType(numberValueTypeConstructor); } - for (KtType primitiveNumberType : numberValueTypeConstructor.getSupertypes()) { + for (KotlinType primitiveNumberType : numberValueTypeConstructor.getSupertypes()) { if (KotlinTypeChecker.DEFAULT.isSubtypeOf(primitiveNumberType, expectedType)) { return primitiveNumberType; } @@ -520,20 +520,20 @@ public class TypeUtils { } public static List topologicallySortSuperclassesAndRecordAllInstances( - @NotNull KtType type, - @NotNull final Map> constructorToAllInstances, + @NotNull KotlinType type, + @NotNull final Map> constructorToAllInstances, @NotNull final Set visited ) { return DFS.dfs( Collections.singletonList(type), - new DFS.Neighbors() { + new DFS.Neighbors() { @NotNull @Override - public Iterable getNeighbors(KtType current) { + public Iterable getNeighbors(KotlinType current) { TypeSubstitutor substitutor = TypeSubstitutor.create(current); - Collection supertypes = current.getConstructor().getSupertypes(); - List result = new ArrayList(supertypes.size()); - for (KtType supertype : supertypes) { + Collection supertypes = current.getConstructor().getSupertypes(); + List result = new ArrayList(supertypes.size()); + for (KotlinType supertype : supertypes) { if (visited.contains(supertype.getConstructor())) { continue; } @@ -542,20 +542,20 @@ public class TypeUtils { return result; } }, - new DFS.Visited() { + new DFS.Visited() { @Override - public boolean checkAndMarkVisited(KtType current) { + public boolean checkAndMarkVisited(KotlinType current) { return visited.add(current.getConstructor()); } }, - new DFS.NodeHandlerWithListResult() { + new DFS.NodeHandlerWithListResult() { @Override - public boolean beforeChildren(KtType current) { + public boolean beforeChildren(KotlinType current) { TypeConstructor constructor = current.getConstructor(); - Set instances = constructorToAllInstances.get(constructor); + Set instances = constructorToAllInstances.get(constructor); if (instances == null) { - instances = new HashSet(); + instances = new HashSet(); constructorToAllInstances.put(constructor, instances); } instances.add(current); @@ -564,14 +564,14 @@ public class TypeUtils { } @Override - public void afterChildren(KtType current) { + public void afterChildren(KotlinType current) { result.addFirst(current.getConstructor()); } } ); } - public static TypeSubstitutor makeConstantSubstitutor(Collection typeParameterDescriptors, KtType type) { + public static TypeSubstitutor makeConstantSubstitutor(Collection typeParameterDescriptors, KotlinType type) { final Set constructors = org.jetbrains.kotlin.utils.CollectionsKt .newHashSetWithExpectedSize(typeParameterDescriptors.size()); for (TypeParameterDescriptor typeParameterDescriptor : typeParameterDescriptors) { @@ -595,27 +595,27 @@ public class TypeUtils { }); } - public static boolean isTypeParameter(@NotNull KtType type) { + public static boolean isTypeParameter(@NotNull KotlinType type) { return getTypeParameterDescriptorOrNull(type) != null; } - public static boolean isNonReifiedTypeParemeter(@NotNull KtType type) { + public static boolean isNonReifiedTypeParemeter(@NotNull KotlinType type) { TypeParameterDescriptor typeParameterDescriptor = getTypeParameterDescriptorOrNull(type); return typeParameterDescriptor != null && !typeParameterDescriptor.isReified(); } @Nullable - public static TypeParameterDescriptor getTypeParameterDescriptorOrNull(@NotNull KtType type) { + public static TypeParameterDescriptor getTypeParameterDescriptorOrNull(@NotNull KotlinType type) { if (type.getConstructor().getDeclarationDescriptor() instanceof TypeParameterDescriptor) { return (TypeParameterDescriptor) type.getConstructor().getDeclarationDescriptor(); } return null; } - private static abstract class AbstractTypeWithKnownNullability extends AbstractKtType { - private final KtType delegate; + private static abstract class AbstractTypeWithKnownNullability extends AbstractKotlinType { + private final KotlinType delegate; - private AbstractTypeWithKnownNullability(@NotNull KtType delegate) { + private AbstractTypeWithKnownNullability(@NotNull KotlinType delegate) { this.delegate = delegate; } @@ -672,7 +672,7 @@ public class TypeUtils { private static class NullableType extends AbstractTypeWithKnownNullability { - private NullableType(@NotNull KtType delegate) { + private NullableType(@NotNull KotlinType delegate) { super(delegate); } @@ -684,7 +684,7 @@ public class TypeUtils { private static class NotNullType extends AbstractTypeWithKnownNullability { - private NotNullType(@NotNull KtType delegate) { + private NotNullType(@NotNull KotlinType delegate) { super(delegate); } diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.kt b/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.kt index 205503effac..26dd0ee9bd8 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.kt @@ -35,7 +35,7 @@ public enum class TypeNullability { FLEXIBLE } -public fun KtType.nullability(): TypeNullability { +public fun KotlinType.nullability(): TypeNullability { return when { isNullabilityFlexible() -> TypeNullability.FLEXIBLE TypeUtils.isNullableType(this) -> TypeNullability.NULLABLE @@ -43,22 +43,22 @@ public fun KtType.nullability(): TypeNullability { } } -val KtType.builtIns: KotlinBuiltIns +val KotlinType.builtIns: KotlinBuiltIns get() = constructor.builtIns -fun KtType.makeNullable() = TypeUtils.makeNullable(this) -fun KtType.makeNotNullable() = TypeUtils.makeNotNullable(this) +fun KotlinType.makeNullable() = TypeUtils.makeNullable(this) +fun KotlinType.makeNotNullable() = TypeUtils.makeNotNullable(this) -fun KtType.immediateSupertypes(): Collection = TypeUtils.getImmediateSupertypes(this) -fun KtType.supertypes(): Collection = TypeUtils.getAllSupertypes(this) +fun KotlinType.immediateSupertypes(): Collection = TypeUtils.getImmediateSupertypes(this) +fun KotlinType.supertypes(): Collection = TypeUtils.getAllSupertypes(this) -fun KtType.isNothing(): Boolean = KotlinBuiltIns.isNothing(this) -fun KtType.isUnit(): Boolean = KotlinBuiltIns.isUnit(this) -fun KtType.isAnyOrNullableAny(): Boolean = KotlinBuiltIns.isAnyOrNullableAny(this) -fun KtType.isBoolean(): Boolean = KotlinBuiltIns.isBoolean(this) -fun KtType.isBooleanOrNullableBoolean(): Boolean = KotlinBuiltIns.isBooleanOrNullableBoolean(this) +fun KotlinType.isNothing(): Boolean = KotlinBuiltIns.isNothing(this) +fun KotlinType.isUnit(): Boolean = KotlinBuiltIns.isUnit(this) +fun KotlinType.isAnyOrNullableAny(): Boolean = KotlinBuiltIns.isAnyOrNullableAny(this) +fun KotlinType.isBoolean(): Boolean = KotlinBuiltIns.isBoolean(this) +fun KotlinType.isBooleanOrNullableBoolean(): Boolean = KotlinBuiltIns.isBooleanOrNullableBoolean(this) -private fun KtType.getContainedTypeParameters(): Collection { +private fun KotlinType.getContainedTypeParameters(): Collection { val declarationDescriptor = getConstructor().getDeclarationDescriptor() if (declarationDescriptor is TypeParameterDescriptor) return listOf(declarationDescriptor) @@ -85,24 +85,24 @@ fun DeclarationDescriptor.getCapturedTypeParameters(): Collection { +public fun KotlinType.getContainedAndCapturedTypeParameterConstructors(): Collection { // todo type arguments (instead of type parameters) of the type of outer class must be considered; KT-6325 val capturedTypeParameters = getConstructor().getDeclarationDescriptor()?.getCapturedTypeParameters() ?: emptyList() val typeParameters = getContainedTypeParameters() + capturedTypeParameters return typeParameters.map { it.getTypeConstructor() }.toReadOnlyList() } -public fun KtType.isSubtypeOf(superType: KtType): Boolean = KotlinTypeChecker.DEFAULT.isSubtypeOf(this, superType) +public fun KotlinType.isSubtypeOf(superType: KotlinType): Boolean = KotlinTypeChecker.DEFAULT.isSubtypeOf(this, superType) -public fun KtType.cannotBeReified(): Boolean = KotlinBuiltIns.isNothingOrNullableNothing(this) || this.isDynamic() +public fun KotlinType.cannotBeReified(): Boolean = KotlinBuiltIns.isNothingOrNullableNothing(this) || this.isDynamic() -fun TypeProjection.substitute(doSubstitute: (KtType) -> KtType): TypeProjection { +fun TypeProjection.substitute(doSubstitute: (KotlinType) -> KotlinType): TypeProjection { return if (isStarProjection()) this else TypeProjectionImpl(getProjectionKind(), doSubstitute(getType())) } -fun KtType.replaceAnnotations(newAnnotations: Annotations): KtType { +fun KotlinType.replaceAnnotations(newAnnotations: Annotations): KotlinType { if (newAnnotations.isEmpty()) return this return object : DelegatingType() { override fun getDelegate() = this@replaceAnnotations @@ -111,13 +111,13 @@ fun KtType.replaceAnnotations(newAnnotations: Annotations): KtType { } } -public fun KotlinTypeChecker.equalTypesOrNulls(type1: KtType?, type2: KtType?): Boolean { +public fun KotlinTypeChecker.equalTypesOrNulls(type1: KotlinType?, type2: KotlinType?): Boolean { if (type1 === type2) return true if (type1 == null || type2 == null) return false return equalTypes(type1, type2) } -fun KtType.getNestedArguments(): List { +fun KotlinType.getNestedArguments(): List { val result = ArrayList() val stack = ArrayDeque() @@ -134,11 +134,11 @@ fun KtType.getNestedArguments(): List { return result } -fun KtType.containsError() = ErrorUtils.containsErrorType(this) +fun KotlinType.containsError() = ErrorUtils.containsErrorType(this) -public fun List.defaultProjections(): List = map { TypeProjectionImpl(it) } +public fun List.defaultProjections(): List = map { TypeProjectionImpl(it) } -public fun KtType.isDefaultBound(): Boolean = KotlinBuiltIns.isDefaultBound(getSupertypeRepresentative()) +public fun KotlinType.isDefaultBound(): Boolean = KotlinBuiltIns.isDefaultBound(getSupertypeRepresentative()) -public fun createProjection(type: KtType, projectionKind: Variance, typeParameterDescriptor: TypeParameterDescriptor?): TypeProjection = +public fun createProjection(type: KotlinType, projectionKind: Variance, typeParameterDescriptor: TypeParameterDescriptor?): TypeProjection = TypeProjectionImpl(if (typeParameterDescriptor?.variance == projectionKind) Variance.INVARIANT else projectionKind, type) diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/checker/KotlinTypeChecker.java b/core/descriptors/src/org/jetbrains/kotlin/types/checker/KotlinTypeChecker.java index f6fb258cb47..c6139d20cb9 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/checker/KotlinTypeChecker.java +++ b/core/descriptors/src/org/jetbrains/kotlin/types/checker/KotlinTypeChecker.java @@ -17,7 +17,7 @@ package org.jetbrains.kotlin.types.checker; import org.jetbrains.annotations.NotNull; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.TypeConstructor; public class KotlinTypeChecker { @@ -30,14 +30,14 @@ public class KotlinTypeChecker { public static final KotlinTypeChecker ERROR_TYPES_ARE_EQUAL_TO_ANYTHING = new KotlinTypeChecker(new TypeCheckingProcedure(new TypeCheckerProcedureCallbacksImpl() { @Override - public boolean assertEqualTypes(@NotNull KtType a, @NotNull KtType b, @NotNull TypeCheckingProcedure typeCheckingProcedure) { + public boolean assertEqualTypes(@NotNull KotlinType a, @NotNull KotlinType b, @NotNull TypeCheckingProcedure typeCheckingProcedure) { return a.isError() || b.isError() || super.assertEqualTypes(a, b, typeCheckingProcedure); } })); public static final KotlinTypeChecker FLEXIBLE_UNEQUAL_TO_INFLEXIBLE = new KotlinTypeChecker(new TypeCheckingProcedure(new TypeCheckerProcedureCallbacksImpl()) { @Override - protected boolean heterogeneousEquivalence(KtType inflexibleType, KtType flexibleType) { + protected boolean heterogeneousEquivalence(KotlinType inflexibleType, KotlinType flexibleType) { return false; } }); @@ -58,11 +58,11 @@ public class KotlinTypeChecker { this.procedure = procedure; } - public boolean isSubtypeOf(@NotNull KtType subtype, @NotNull KtType supertype) { + public boolean isSubtypeOf(@NotNull KotlinType subtype, @NotNull KotlinType supertype) { return procedure.isSubtypeOf(subtype, supertype); } - public boolean equalTypes(@NotNull KtType a, @NotNull KtType b) { + public boolean equalTypes(@NotNull KotlinType a, @NotNull KotlinType b) { return procedure.equalTypes(a, b); } } diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/checker/TypeCheckerProcedureCallbacksImpl.java b/core/descriptors/src/org/jetbrains/kotlin/types/checker/TypeCheckerProcedureCallbacksImpl.java index 6d3f1720477..51f7b63f929 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/checker/TypeCheckerProcedureCallbacksImpl.java +++ b/core/descriptors/src/org/jetbrains/kotlin/types/checker/TypeCheckerProcedureCallbacksImpl.java @@ -17,13 +17,13 @@ package org.jetbrains.kotlin.types.checker; import org.jetbrains.annotations.NotNull; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.TypeConstructor; import org.jetbrains.kotlin.types.TypeProjection; class TypeCheckerProcedureCallbacksImpl implements TypeCheckingProcedureCallbacks { @Override - public boolean assertEqualTypes(@NotNull KtType a, @NotNull KtType b, @NotNull TypeCheckingProcedure typeCheckingProcedure) { + public boolean assertEqualTypes(@NotNull KotlinType a, @NotNull KotlinType b, @NotNull TypeCheckingProcedure typeCheckingProcedure) { return typeCheckingProcedure.equalTypes(a, b); } @@ -33,17 +33,17 @@ class TypeCheckerProcedureCallbacksImpl implements TypeCheckingProcedureCallback } @Override - public boolean assertSubtype(@NotNull KtType subtype, @NotNull KtType supertype, @NotNull TypeCheckingProcedure typeCheckingProcedure) { + public boolean assertSubtype(@NotNull KotlinType subtype, @NotNull KotlinType supertype, @NotNull TypeCheckingProcedure typeCheckingProcedure) { return typeCheckingProcedure.isSubtypeOf(subtype, supertype); } @Override - public boolean capture(@NotNull KtType type, @NotNull TypeProjection typeProjection) { + public boolean capture(@NotNull KotlinType type, @NotNull TypeProjection typeProjection) { return false; } @Override - public boolean noCorrespondingSupertype(@NotNull KtType subtype, @NotNull KtType supertype) { + public boolean noCorrespondingSupertype(@NotNull KotlinType subtype, @NotNull KotlinType supertype) { return false; // type checking fails } } diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/checker/TypeCheckingProcedure.java b/core/descriptors/src/org/jetbrains/kotlin/types/checker/TypeCheckingProcedure.java index 197bda5426b..37986e075c0 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/checker/TypeCheckingProcedure.java +++ b/core/descriptors/src/org/jetbrains/kotlin/types/checker/TypeCheckingProcedure.java @@ -32,23 +32,23 @@ public class TypeCheckingProcedure { // This method returns the supertype of the first parameter that has the same constructor // as the second parameter, applying the substitution of type arguments to it @Nullable - public static KtType findCorrespondingSupertype(@NotNull KtType subtype, @NotNull KtType supertype) { + public static KotlinType findCorrespondingSupertype(@NotNull KotlinType subtype, @NotNull KotlinType supertype) { return findCorrespondingSupertype(subtype, supertype, new TypeCheckerProcedureCallbacksImpl()); } // This method returns the supertype of the first parameter that has the same constructor // as the second parameter, applying the substitution of type arguments to it @Nullable - public static KtType findCorrespondingSupertype(@NotNull KtType subtype, @NotNull KtType supertype, @NotNull TypeCheckingProcedureCallbacks typeCheckingProcedureCallbacks) { + public static KotlinType findCorrespondingSupertype(@NotNull KotlinType subtype, @NotNull KotlinType supertype, @NotNull TypeCheckingProcedureCallbacks typeCheckingProcedureCallbacks) { return UtilsKt.findCorrespondingSupertype(subtype, supertype, typeCheckingProcedureCallbacks); } - public static KtType getOutType(TypeParameterDescriptor parameter, TypeProjection argument) { + public static KotlinType getOutType(TypeParameterDescriptor parameter, TypeProjection argument) { boolean isOutProjected = argument.getProjectionKind() == IN_VARIANCE || parameter.getVariance() == IN_VARIANCE; return isOutProjected ? parameter.getUpperBoundsAsType() : argument.getType(); } - public static KtType getInType(@NotNull TypeParameterDescriptor parameter, @NotNull TypeProjection argument) { + public static KotlinType getInType(@NotNull TypeParameterDescriptor parameter, @NotNull TypeProjection argument) { boolean isOutProjected = argument.getProjectionKind() == OUT_VARIANCE || parameter.getVariance() == OUT_VARIANCE; return isOutProjected ? DescriptorUtilsKt.getBuiltIns(parameter).getNothingType() : argument.getType(); } @@ -59,7 +59,7 @@ public class TypeCheckingProcedure { this.constraints = constraints; } - public boolean equalTypes(@NotNull KtType type1, @NotNull KtType type2) { + public boolean equalTypes(@NotNull KotlinType type1, @NotNull KotlinType type2) { if (type1 == type2) return true; if (FlexibleTypesKt.isFlexible(type1)) { if (FlexibleTypesKt.isFlexible(type2)) { @@ -116,7 +116,7 @@ public class TypeCheckingProcedure { return true; } - protected boolean heterogeneousEquivalence(KtType inflexibleType, KtType flexibleType) { + protected boolean heterogeneousEquivalence(KotlinType inflexibleType, KotlinType flexibleType) { // This is to account for the case when we have Collection vs (Mutable)Collection! or K(java.util.Collection) assert !FlexibleTypesKt.isFlexible(inflexibleType) : "Only inflexible types are allowed here: " + inflexibleType; return isSubtypeOf(FlexibleTypesKt.flexibility(flexibleType).getLowerBound(), inflexibleType) @@ -178,12 +178,12 @@ public class TypeCheckingProcedure { return EnrichedProjectionKind.fromVariance(b); } - public boolean isSubtypeOf(@NotNull KtType subtype, @NotNull KtType supertype) { + public boolean isSubtypeOf(@NotNull KotlinType subtype, @NotNull KotlinType supertype) { if (TypeCapabilitiesKt.sameTypeConstructors(subtype, supertype)) { return !subtype.isMarkedNullable() || supertype.isMarkedNullable(); } - KtType subtypeRepresentative = TypeCapabilitiesKt.getSubtypeRepresentative(subtype); - KtType supertypeRepresentative = TypeCapabilitiesKt.getSupertypeRepresentative(supertype); + KotlinType subtypeRepresentative = TypeCapabilitiesKt.getSubtypeRepresentative(subtype); + KotlinType supertypeRepresentative = TypeCapabilitiesKt.getSupertypeRepresentative(supertype); if (subtypeRepresentative != subtype || supertypeRepresentative != supertype) { // recursive invocation for possible chain of representatives return isSubtypeOf(subtypeRepresentative, supertypeRepresentative); @@ -191,7 +191,7 @@ public class TypeCheckingProcedure { return isSubtypeOfForRepresentatives(subtype, supertype); } - private boolean isSubtypeOfForRepresentatives(KtType subtype, KtType supertype) { + private boolean isSubtypeOfForRepresentatives(KotlinType subtype, KotlinType supertype) { if (subtype.isError() || supertype.isError()) { return true; } @@ -204,7 +204,7 @@ public class TypeCheckingProcedure { return true; } - @Nullable KtType closestSupertype = findCorrespondingSupertype(subtype, supertype, constraints); + @Nullable KotlinType closestSupertype = findCorrespondingSupertype(subtype, supertype, constraints); if (closestSupertype == null) { return constraints.noCorrespondingSupertype(subtype, supertype); // if this returns true, there still isn't any supertype to continue with } @@ -216,7 +216,7 @@ public class TypeCheckingProcedure { return checkSubtypeForTheSameConstructor(closestSupertype, supertype); } - private boolean checkSubtypeForTheSameConstructor(@NotNull KtType subtype, @NotNull KtType supertype) { + private boolean checkSubtypeForTheSameConstructor(@NotNull KotlinType subtype, @NotNull KotlinType supertype) { TypeConstructor constructor = subtype.getConstructor(); assert constraints.assertEqualTypeConstructors(constructor, supertype.getConstructor()) : constructor + " is not " + supertype.getConstructor(); @@ -231,12 +231,12 @@ public class TypeCheckingProcedure { TypeProjection superArgument = superArguments.get(i); if (superArgument.isStarProjection()) continue; - KtType superIn = getInType(parameter, superArgument); - KtType superOut = getOutType(parameter, superArgument); + KotlinType superIn = getInType(parameter, superArgument); + KotlinType superOut = getOutType(parameter, superArgument); TypeProjection subArgument = subArguments.get(i); - KtType subIn = getInType(parameter, subArgument); - KtType subOut = getOutType(parameter, subArgument); + KotlinType subIn = getInType(parameter, subArgument); + KotlinType subOut = getOutType(parameter, subArgument); if (capture(subArgument, superArgument, parameter)) continue; diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/checker/TypeCheckingProcedureCallbacks.java b/core/descriptors/src/org/jetbrains/kotlin/types/checker/TypeCheckingProcedureCallbacks.java index e0375932e22..dd8cabaa6dc 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/checker/TypeCheckingProcedureCallbacks.java +++ b/core/descriptors/src/org/jetbrains/kotlin/types/checker/TypeCheckingProcedureCallbacks.java @@ -17,7 +17,7 @@ package org.jetbrains.kotlin.types.checker; import org.jetbrains.annotations.NotNull; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.TypeConstructor; import org.jetbrains.kotlin.types.TypeProjection; @@ -25,13 +25,13 @@ import org.jetbrains.kotlin.types.TypeProjection; * Methods of this class return true to continue type checking and false to fail */ public interface TypeCheckingProcedureCallbacks { - boolean assertEqualTypes(@NotNull KtType a, @NotNull KtType b, @NotNull TypeCheckingProcedure typeCheckingProcedure); + boolean assertEqualTypes(@NotNull KotlinType a, @NotNull KotlinType b, @NotNull TypeCheckingProcedure typeCheckingProcedure); boolean assertEqualTypeConstructors(@NotNull TypeConstructor a, @NotNull TypeConstructor b); - boolean assertSubtype(@NotNull KtType subtype, @NotNull KtType supertype, @NotNull TypeCheckingProcedure typeCheckingProcedure); + boolean assertSubtype(@NotNull KotlinType subtype, @NotNull KotlinType supertype, @NotNull TypeCheckingProcedure typeCheckingProcedure); - boolean capture(@NotNull KtType type, @NotNull TypeProjection typeProjection); + boolean capture(@NotNull KotlinType type, @NotNull TypeProjection typeProjection); - boolean noCorrespondingSupertype(@NotNull KtType subtype, @NotNull KtType supertype); + boolean noCorrespondingSupertype(@NotNull KotlinType subtype, @NotNull KotlinType supertype); } diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/checker/utils.kt b/core/descriptors/src/org/jetbrains/kotlin/types/checker/utils.kt index 3ed9027cc70..a1259696fc2 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/checker/utils.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/checker/utils.kt @@ -16,19 +16,19 @@ package org.jetbrains.kotlin.types.checker -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeSubstitutor import org.jetbrains.kotlin.types.TypeUtils import org.jetbrains.kotlin.types.Variance import org.jetbrains.kotlin.types.checker.TypeCheckingProcedureCallbacks import java.util.* -private class SubtypePathNode(val type: KtType, val previous: SubtypePathNode?) +private class SubtypePathNode(val type: KotlinType, val previous: SubtypePathNode?) public fun findCorrespondingSupertype( - subtype: KtType, supertype: KtType, + subtype: KotlinType, supertype: KotlinType, typeCheckingProcedureCallbacks: TypeCheckingProcedureCallbacks -): KtType? { +): KotlinType? { val queue = ArrayDeque() queue.add(SubtypePathNode(subtype, null)) diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/dynamicTypes.kt b/core/descriptors/src/org/jetbrains/kotlin/types/dynamicTypes.kt index 803296f91a1..aad5fe00767 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/dynamicTypes.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/dynamicTypes.kt @@ -31,7 +31,7 @@ class DynamicTypesAllowed: DynamicTypesSettings() { interface Dynamicity : TypeCapability -fun KtType.isDynamic(): Boolean = this.getCapability(javaClass()) != null +fun KotlinType.isDynamic(): Boolean = this.getCapability(javaClass()) != null fun createDynamicType(builtIns: KotlinBuiltIns) = object : DelegatingFlexibleType( builtIns.nothingType, @@ -42,7 +42,7 @@ fun createDynamicType(builtIns: KotlinBuiltIns) = object : DelegatingFlexibleTyp public object DynamicTypeCapabilities : FlexibleTypeCapabilities { override val id: String get() = "kotlin.DynamicType" - override fun getCapability(capabilityClass: Class, jetType: KtType, flexibility: Flexibility): T? { + override fun getCapability(capabilityClass: Class, jetType: KotlinType, flexibility: Flexibility): T? { @Suppress("UNCHECKED_CAST") return if (capabilityClass in Impl.capabilityClasses) Impl(flexibility) as T else null } @@ -57,13 +57,13 @@ public object DynamicTypeCapabilities : FlexibleTypeCapabilities { ) } - override val delegateType: KtType = flexibility.upperBound + override val delegateType: KotlinType = flexibility.upperBound - override fun getSpecificityRelationTo(otherType: KtType): Specificity.Relation { + override fun getSpecificityRelationTo(otherType: KotlinType): Specificity.Relation { return if (!otherType.isDynamic()) Specificity.Relation.LESS_SPECIFIC else Specificity.Relation.DONT_KNOW } - override fun makeNullableAsSpecified(nullable: Boolean): KtType { + override fun makeNullableAsSpecified(nullable: Boolean): KotlinType { // Nullability has no effect on dynamics return createDynamicType(delegateType.builtIns) } diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/flexibleTypes.kt b/core/descriptors/src/org/jetbrains/kotlin/types/flexibleTypes.kt index 1f5033ad549..5edb6f69227 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/flexibleTypes.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/flexibleTypes.kt @@ -22,11 +22,11 @@ import org.jetbrains.kotlin.renderer.DescriptorRenderer import org.jetbrains.kotlin.types.checker.KotlinTypeChecker public interface FlexibleTypeCapabilities { - fun getCapability(capabilityClass: Class, jetType: KtType, flexibility: Flexibility): T? + fun getCapability(capabilityClass: Class, jetType: KotlinType, flexibility: Flexibility): T? val id: String object NONE : FlexibleTypeCapabilities { - override fun getCapability(capabilityClass: Class, jetType: KtType, flexibility: Flexibility): T? = null + override fun getCapability(capabilityClass: Class, jetType: KotlinType, flexibility: Flexibility): T? = null override val id: String get() = "NONE" } } @@ -41,37 +41,37 @@ public interface Flexibility : TypeCapability, SubtypingRepresentatives { } // lowerBound is a subtype of upperBound - public val lowerBound: KtType - public val upperBound: KtType + public val lowerBound: KotlinType + public val upperBound: KotlinType public val extraCapabilities: FlexibleTypeCapabilities - override val subTypeRepresentative: KtType + override val subTypeRepresentative: KotlinType get() = lowerBound - override val superTypeRepresentative: KtType + override val superTypeRepresentative: KotlinType get() = upperBound - override fun sameTypeConstructor(type: KtType) = false + override fun sameTypeConstructor(type: KotlinType) = false } -public fun KtType.isFlexible(): Boolean = this.getCapability(javaClass()) != null -public fun KtType.flexibility(): Flexibility = this.getCapability(javaClass())!! +public fun KotlinType.isFlexible(): Boolean = this.getCapability(javaClass()) != null +public fun KotlinType.flexibility(): Flexibility = this.getCapability(javaClass())!! -public fun KtType.isNullabilityFlexible(): Boolean { +public fun KotlinType.isNullabilityFlexible(): Boolean { val flexibility = this.getCapability(javaClass()) ?: return false return TypeUtils.isNullableType(flexibility.lowerBound) != TypeUtils.isNullableType(flexibility.upperBound) } -// This function is intended primarily for sets: since KtType.equals() represents _syntactical_ equality of types, +// This function is intended primarily for sets: since KotlinType.equals() represents _syntactical_ equality of types, // whereas KotlinTypeChecker.DEFAULT.equalsTypes() represents semantic equality // A set of types (e.g. exact bounds etc) may contain, for example, X, X? and X! -// These are not equal syntactically (by KtType.equals()), but X! is _compatible_ with others as exact bounds, +// These are not equal syntactically (by KotlinType.equals()), but X! is _compatible_ with others as exact bounds, // moreover, X! is a better fit. // // So, we are looking for a type among this set such that it is equal to all others semantically // (by KotlinTypeChecker.DEFAULT.equalsTypes()), and fits at least as well as they do. -fun Collection.singleBestRepresentative(): KtType? { +fun Collection.singleBestRepresentative(): KotlinType? { if (this.size() == 1) return this.first() return this.firstOrNull { @@ -97,21 +97,21 @@ fun Collection.singleBestRepresentative(): TypeProjection? { return TypeProjectionImpl(projectionKinds.single(), bestType) } -public fun KtType.lowerIfFlexible(): KtType = if (this.isFlexible()) this.flexibility().lowerBound else this -public fun KtType.upperIfFlexible(): KtType = if (this.isFlexible()) this.flexibility().upperBound else this +public fun KotlinType.lowerIfFlexible(): KotlinType = if (this.isFlexible()) this.flexibility().lowerBound else this +public fun KotlinType.upperIfFlexible(): KotlinType = if (this.isFlexible()) this.flexibility().upperBound else this public interface NullAwareness : TypeCapability { - public fun makeNullableAsSpecified(nullable: Boolean): KtType + public fun makeNullableAsSpecified(nullable: Boolean): KotlinType public fun computeIsNullable(): Boolean } interface FlexibleTypeDelegation : TypeCapability { - public val delegateType: KtType + public val delegateType: KotlinType } public open class DelegatingFlexibleType protected constructor( - override val lowerBound: KtType, - override val upperBound: KtType, + override val lowerBound: KotlinType, + override val upperBound: KotlinType, override val extraCapabilities: FlexibleTypeCapabilities ) : DelegatingType(), NullAwareness, Flexibility, FlexibleTypeDelegation { companion object { @@ -123,7 +123,7 @@ public open class DelegatingFlexibleType protected constructor( ) @JvmStatic - fun create(lowerBound: KtType, upperBound: KtType, extraCapabilities: FlexibleTypeCapabilities): KtType { + fun create(lowerBound: KotlinType, upperBound: KotlinType, extraCapabilities: FlexibleTypeCapabilities): KotlinType { if (lowerBound == upperBound) return lowerBound return DelegatingFlexibleType(lowerBound, upperBound, extraCapabilities) } @@ -150,7 +150,7 @@ public open class DelegatingFlexibleType protected constructor( return super.getCapability(capabilityClass) } - override fun makeNullableAsSpecified(nullable: Boolean): KtType { + override fun makeNullableAsSpecified(nullable: Boolean): KotlinType { return create( TypeUtils.makeNullableAsSpecified(lowerBound, nullable), TypeUtils.makeNullableAsSpecified(upperBound, nullable), @@ -161,7 +161,7 @@ public open class DelegatingFlexibleType protected constructor( override fun isMarkedNullable(): Boolean = getCapability(javaClass())!!.computeIsNullable() - override val delegateType: KtType = lowerBound + override val delegateType: KotlinType = lowerBound override fun getDelegate() = getCapability(javaClass())!!.delegateType diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/AdditionalSupertypes.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/AdditionalSupertypes.kt index 3547274f5e7..c311c8c96cf 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/AdditionalSupertypes.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/AdditionalSupertypes.kt @@ -17,12 +17,12 @@ package org.jetbrains.kotlin.serialization.deserialization import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedClassDescriptor -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType interface AdditionalSupertypes { - fun forClass(classDescriptor: DeserializedClassDescriptor): Collection + fun forClass(classDescriptor: DeserializedClassDescriptor): Collection object None : AdditionalSupertypes { - override fun forClass(classDescriptor: DeserializedClassDescriptor): Collection = emptyList() + override fun forClass(classDescriptor: DeserializedClassDescriptor): Collection = emptyList() } } \ No newline at end of file diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/AnnotationAndConstantLoader.java b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/AnnotationAndConstantLoader.java index 3b3bcdccf1a..91945666a3d 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/AnnotationAndConstantLoader.java +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/AnnotationAndConstantLoader.java @@ -20,7 +20,7 @@ import com.google.protobuf.MessageLite; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.serialization.ProtoBuf; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import java.util.List; @@ -72,6 +72,6 @@ public interface AnnotationAndConstantLoader { C loadPropertyConstant( @NotNull ProtoContainer container, @NotNull ProtoBuf.Property proto, - @NotNull KtType expectedType + @NotNull KotlinType expectedType ); } diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/AnnotationDeserializer.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/AnnotationDeserializer.kt index 97a59249bce..e16a31ca2f1 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/AnnotationDeserializer.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/AnnotationDeserializer.kt @@ -30,7 +30,7 @@ import org.jetbrains.kotlin.serialization.ProtoBuf.Annotation.Argument import org.jetbrains.kotlin.serialization.ProtoBuf.Annotation.Argument.Value import org.jetbrains.kotlin.serialization.ProtoBuf.Annotation.Argument.Value.Type import org.jetbrains.kotlin.types.ErrorUtils -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.Variance import org.jetbrains.kotlin.types.typeUtil.isSubtypeOf @@ -65,7 +65,7 @@ public class AnnotationDeserializer(private val module: ModuleDescriptor) { } public fun resolveValue( - expectedType: KtType, + expectedType: KotlinType, value: Value, nameResolver: NameResolver ): ConstantValue<*> { @@ -141,7 +141,7 @@ public class AnnotationDeserializer(private val module: ModuleDescriptor) { return factory.createErrorValue("Unresolved enum entry: $enumClassId.$enumEntryName") } - private fun resolveArrayElementType(value: Value, nameResolver: NameResolver): KtType = + private fun resolveArrayElementType(value: Value, nameResolver: NameResolver): KotlinType = with(builtIns) { when (value.getType()) { Type.BYTE -> getByteType() diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/TypeDeserializer.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/TypeDeserializer.kt index 2e15c340289..46c9dd44a85 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/TypeDeserializer.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/TypeDeserializer.kt @@ -53,7 +53,7 @@ public class TypeDeserializer( get() = typeParameterDescriptors().values().toReadOnlyList() // TODO: don't load identical types from TypeTable more than once - fun type(proto: ProtoBuf.Type, additionalAnnotations: Annotations = Annotations.EMPTY): KtType { + fun type(proto: ProtoBuf.Type, additionalAnnotations: Annotations = Annotations.EMPTY): KotlinType { if (proto.hasFlexibleTypeCapabilitiesId()) { val id = c.nameResolver.getString(proto.flexibleTypeCapabilitiesId) val capabilities = c.components.flexibleTypeCapabilitiesDeserializer.capabilitiesById(id) ?: diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedClassDescriptor.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedClassDescriptor.kt index 4207308105a..cff573a1d85 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedClassDescriptor.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedClassDescriptor.kt @@ -32,7 +32,7 @@ import org.jetbrains.kotlin.serialization.Flags import org.jetbrains.kotlin.serialization.ProtoBuf import org.jetbrains.kotlin.serialization.deserialization.* import org.jetbrains.kotlin.types.AbstractClassTypeConstructor -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.upperIfFlexible import org.jetbrains.kotlin.utils.addIfNotNull import org.jetbrains.kotlin.utils.singletonOrEmptyList @@ -134,8 +134,8 @@ public class DeserializedClassDescriptor( override fun getCompanionObjectDescriptor(): ClassDescriptor? = companionObjectDescriptor() - private fun computeSupertypes(): Collection { - val result = ArrayList(classProto.supertypeCount) + private fun computeSupertypes(): Collection { + val result = ArrayList(classProto.supertypeCount) val unresolved = ArrayList(0) for (supertypeProto in classProto.supertypes(c.typeTable)) { diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedTypeParameterDescriptor.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedTypeParameterDescriptor.kt index 07b006f22bd..940302c4e08 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedTypeParameterDescriptor.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedTypeParameterDescriptor.kt @@ -23,7 +23,7 @@ import org.jetbrains.kotlin.descriptors.impl.AbstractLazyTypeParameterDescriptor import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns import org.jetbrains.kotlin.serialization.ProtoBuf import org.jetbrains.kotlin.serialization.deserialization.* -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import java.util.* class DeserializedTypeParameterDescriptor( @@ -39,12 +39,12 @@ class DeserializedTypeParameterDescriptor( override fun getAnnotations(): Annotations = annotations - override fun resolveUpperBounds(): Set { + override fun resolveUpperBounds(): Set { val upperBounds = proto.upperBounds(typeTable) if (upperBounds.isEmpty()) { return setOf(this.builtIns.getDefaultBound()) } - val result = LinkedHashSet(upperBounds.size()) + val result = LinkedHashSet(upperBounds.size()) for (upperBound in upperBounds) { result.add(typeDeserializer.type(upperBound, Annotations.EMPTY)) } diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KTypeImpl.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KTypeImpl.kt index eded4c383bb..960e756d34a 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KTypeImpl.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KTypeImpl.kt @@ -16,12 +16,12 @@ package kotlin.reflect.jvm.internal -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import java.lang.reflect.Type import kotlin.reflect.KType internal class KTypeImpl( - val type: KtType, + val type: KotlinType, computeJavaType: () -> Type ) : KType { internal val javaType: Type by ReflectProperties.lazySoft(computeJavaType) diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/ReflectionObjectRenderer.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/ReflectionObjectRenderer.kt index b52e0ee9767..a993f9d8c69 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/ReflectionObjectRenderer.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/ReflectionObjectRenderer.kt @@ -21,7 +21,7 @@ import org.jetbrains.kotlin.descriptors.FunctionDescriptor import org.jetbrains.kotlin.descriptors.PropertyDescriptor import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor import org.jetbrains.kotlin.renderer.DescriptorRenderer -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import kotlin.reflect.KParameter internal object ReflectionObjectRenderer { @@ -94,7 +94,7 @@ internal object ReflectionObjectRenderer { }.toString() } - fun renderType(type: KtType): String { + fun renderType(type: KotlinType): String { return renderer.renderType(type) } } diff --git a/generators/src/org/jetbrains/kotlin/generators/evaluate/GenerateOperationsMap.kt b/generators/src/org/jetbrains/kotlin/generators/evaluate/GenerateOperationsMap.kt index 5a0698ced0c..a9089349342 100644 --- a/generators/src/org/jetbrains/kotlin/generators/evaluate/GenerateOperationsMap.kt +++ b/generators/src/org/jetbrains/kotlin/generators/evaluate/GenerateOperationsMap.kt @@ -23,7 +23,7 @@ import org.jetbrains.kotlin.descriptors.FunctionDescriptor import org.jetbrains.kotlin.generators.util.GeneratorsFileUtil import org.jetbrains.kotlin.resolve.TargetPlatform import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeUtils import org.jetbrains.kotlin.utils.Printer import java.io.File @@ -47,8 +47,8 @@ fun generate(): String { p.println("/** This file is generated by org.jetbrains.kotlin.generators.evaluate:generate(). DO NOT MODIFY MANUALLY */") p.println() - val unaryOperationsMap = arrayListOf, Boolean>>() - val binaryOperationsMap = arrayListOf>>() + val unaryOperationsMap = arrayListOf, Boolean>>() + val binaryOperationsMap = arrayListOf>>() val builtIns = TargetPlatform.Default.builtIns @Suppress("UNCHECKED_CAST") @@ -122,7 +122,7 @@ fun generate(): String { return sb.toString() } -fun renderCheckUnaryOperation(name: String, params: List): String { +fun renderCheckUnaryOperation(name: String, params: List): String { val isAllParamsIntegers = params.fold(true) { a, b -> a && b.isIntegerType() } if (!isAllParamsIntegers) { return "emptyUnaryFun" @@ -134,7 +134,7 @@ fun renderCheckUnaryOperation(name: String, params: List): String { } } -fun renderCheckBinaryOperation(name: String, params: List): String { +fun renderCheckBinaryOperation(name: String, params: List): String { val isAllParamsIntegers = params.fold(true) { a, b -> a && b.isIntegerType() } if (!isAllParamsIntegers) { return "emptyBinaryFun" @@ -153,7 +153,7 @@ fun renderCheckBinaryOperation(name: String, params: List): String { } } -private fun KtType.isIntegerType(): Boolean { +private fun KotlinType.isIntegerType(): Boolean { return KotlinBuiltIns.isInt(this) || KotlinBuiltIns.isShort(this) || KotlinBuiltIns.isByte(this) || @@ -161,7 +161,7 @@ private fun KtType.isIntegerType(): Boolean { } -private fun CallableDescriptor.getParametersTypes(): List { +private fun CallableDescriptor.getParametersTypes(): List { val list = arrayListOf((getContainingDeclaration() as ClassDescriptor).getDefaultType()) getValueParameters().map { it.getType() }.forEach { list.add(TypeUtils.makeNotNullable(it)) @@ -169,4 +169,4 @@ private fun CallableDescriptor.getParametersTypes(): List { return list } -private fun KtType.asString(): String = getConstructor().getDeclarationDescriptor()!!.getName().asString().toUpperCase() +private fun KotlinType.asString(): String = getConstructor().getDeclarationDescriptor()!!.getName().asString().toUpperCase() diff --git a/idea/ide-common/src/org/jetbrains/kotlin/idea/codeInsight/ReferenceVariantsHelper.kt b/idea/ide-common/src/org/jetbrains/kotlin/idea/codeInsight/ReferenceVariantsHelper.kt index 8acd07c6310..443df14fff5 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/idea/codeInsight/ReferenceVariantsHelper.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/idea/codeInsight/ReferenceVariantsHelper.kt @@ -40,7 +40,7 @@ import org.jetbrains.kotlin.resolve.scopes.getDescriptorsFiltered import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver import org.jetbrains.kotlin.resolve.scopes.utils.getDescriptorsFiltered import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeUtils import org.jetbrains.kotlin.types.checker.KotlinTypeChecker import org.jetbrains.kotlin.utils.addIfNotNull @@ -222,8 +222,8 @@ public class ReferenceVariantsHelper( } private fun MutableSet.processAll( - implicitReceiverTypes: Collection, - receiverTypes: Collection, + implicitReceiverTypes: Collection, + receiverTypes: Collection, resolutionScope: KtScope, callType: CallType<*>, kindFilter: DescriptorKindFilter, @@ -235,8 +235,8 @@ public class ReferenceVariantsHelper( } private fun MutableSet.addMemberExtensions( - dispatchReceiverTypes: Collection, - extensionReceiverTypes: Collection, + dispatchReceiverTypes: Collection, + extensionReceiverTypes: Collection, callType: CallType<*>, kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean @@ -250,7 +250,7 @@ public class ReferenceVariantsHelper( } private fun MutableSet.addNonExtensionMembers( - receiverTypes: Collection, + receiverTypes: Collection, kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean, constructorFilter: (ClassDescriptor) -> Boolean @@ -287,7 +287,7 @@ public class ReferenceVariantsHelper( private fun MutableSet.addScopeAndSyntheticExtensions( resolutionScope: KtScope, - receiverTypes: Collection, + receiverTypes: Collection, callType: CallType<*>, kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean @@ -320,7 +320,7 @@ public class ReferenceVariantsHelper( } } - private fun getQualifierRuntimeType(receiver: KtExpression): KtType? { + private fun getQualifierRuntimeType(receiver: KtExpression): KotlinType? { val type = context.getType(receiver) if (type != null && TypeUtils.canHaveSubtypes(KotlinTypeChecker.DEFAULT, type)) { val evaluator = receiver.getContainingFile().getCopyableUserData(KtCodeFragment.RUNTIME_TYPE_EVALUATOR) diff --git a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/CallType.kt b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/CallType.kt index 51bebc9d2eb..461ee392158 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/CallType.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/CallType.kt @@ -29,7 +29,7 @@ import org.jetbrains.kotlin.resolve.calls.smartcasts.SmartCastManager import org.jetbrains.kotlin.resolve.scopes.DescriptorKindExclude import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.utils.addToStdlib.singletonOrEmptyList public sealed class CallType(val descriptorKindFilter: DescriptorKindFilter) { @@ -185,7 +185,7 @@ public fun CallTypeAndReceiver<*, *>.receiverTypes( position: KtExpression, moduleDescriptor: ModuleDescriptor, predictableSmartCastsOnly: Boolean -): Collection? { +): Collection? { val receiverExpression: KtExpression? when (this) { is CallTypeAndReceiver.CALLABLE_REFERENCE -> { diff --git a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/FuzzyType.kt b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/FuzzyType.kt index 03044c917a0..44f52817fdd 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/FuzzyType.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/FuzzyType.kt @@ -23,7 +23,7 @@ import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemImpl import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind import org.jetbrains.kotlin.resolve.calls.inference.registerTypeVariables -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeSubstitutor import org.jetbrains.kotlin.types.Variance import org.jetbrains.kotlin.types.typeUtil.* @@ -51,7 +51,7 @@ fun FuzzyType.isAlmostEverything(): Boolean { } class FuzzyType( - val type: KtType, + val type: KotlinType, freeParameters: Collection ) { public val freeParameters: Set @@ -71,7 +71,7 @@ class FuzzyType( override fun hashCode() = type.hashCode() - private fun MutableSet.addUsedTypeParameters(type: KtType) { + private fun MutableSet.addUsedTypeParameters(type: KotlinType) { val typeParameter = type.getConstructor().getDeclarationDescriptor() as? TypeParameterDescriptor if (typeParameter != null && add(typeParameter)) { typeParameter.getLowerBounds().forEach { addUsedTypeParameters(it) } @@ -91,10 +91,10 @@ class FuzzyType( public fun checkIsSuperTypeOf(otherType: FuzzyType): TypeSubstitutor? = matchedSubstitutor(otherType, MatchKind.IS_SUPERTYPE) - public fun checkIsSubtypeOf(otherType: KtType): TypeSubstitutor? + public fun checkIsSubtypeOf(otherType: KotlinType): TypeSubstitutor? = checkIsSubtypeOf(FuzzyType(otherType, emptyList())) - public fun checkIsSuperTypeOf(otherType: KtType): TypeSubstitutor? + public fun checkIsSuperTypeOf(otherType: KotlinType): TypeSubstitutor? = checkIsSuperTypeOf(FuzzyType(otherType, emptyList())) private enum class MatchKind { @@ -106,7 +106,7 @@ class FuzzyType( if (type.isError()) return null if (otherType.type.isError()) return null - fun KtType.checkInheritance(otherType: KtType): Boolean { + fun KotlinType.checkInheritance(otherType: KotlinType): Boolean { return when (matchKind) { MatchKind.IS_SUBTYPE -> this.isSubtypeOf(otherType) MatchKind.IS_SUPERTYPE -> otherType.isSubtypeOf(this) diff --git a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/IdeDescriptorRenderers.kt b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/IdeDescriptorRenderers.kt index 69d6051dd93..8edea32ff72 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/IdeDescriptorRenderers.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/IdeDescriptorRenderers.kt @@ -20,16 +20,16 @@ import org.jetbrains.kotlin.renderer.DescriptorRenderer import org.jetbrains.kotlin.renderer.DescriptorRendererModifier import org.jetbrains.kotlin.renderer.NameShortness import org.jetbrains.kotlin.renderer.OverrideRenderingPolicy -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.isDynamic import org.jetbrains.kotlin.types.typeUtil.builtIns public object IdeDescriptorRenderers { - public val APPROXIMATE_FLEXIBLE_TYPES: (KtType) -> KtType = { approximateFlexibleTypes(it, true) } + public val APPROXIMATE_FLEXIBLE_TYPES: (KotlinType) -> KotlinType = { approximateFlexibleTypes(it, true) } - public val APPROXIMATE_FLEXIBLE_TYPES_IN_ARGUMENTS: (KtType) -> KtType = { approximateFlexibleTypes(it, false) } + public val APPROXIMATE_FLEXIBLE_TYPES_IN_ARGUMENTS: (KotlinType) -> KotlinType = { approximateFlexibleTypes(it, false) } - private fun unwrapAnonymousType(type: KtType): KtType { + private fun unwrapAnonymousType(type: KotlinType): KotlinType { if (type.isDynamic()) return type val classifier = type.constructor.declarationDescriptor diff --git a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/ImportsUtils.kt b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/ImportsUtils.kt index bd81e950d63..6cbdcf11c00 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/ImportsUtils.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/ImportsUtils.kt @@ -26,7 +26,7 @@ import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.bindingContextUtil.getReferenceTargets import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe import org.jetbrains.kotlin.resolve.descriptorUtil.getImportableDescriptor -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType public val DeclarationDescriptor.importableFqName: FqName? get() { @@ -51,7 +51,7 @@ public fun DeclarationDescriptor.canBeReferencedViaImport(): Boolean { } } -public fun KtType.canBeReferencedViaImport(): Boolean { +public fun KotlinType.canBeReferencedViaImport(): Boolean { val descriptor = getConstructor().getDeclarationDescriptor() return descriptor != null && descriptor.canBeReferencedViaImport() } diff --git a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/TypeUtils.kt b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/TypeUtils.kt index be21002210d..d41b277a4e9 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/TypeUtils.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/TypeUtils.kt @@ -34,7 +34,7 @@ import org.jetbrains.kotlin.resolve.scopes.utils.getClassifier import org.jetbrains.kotlin.types.* import org.jetbrains.kotlin.types.typeUtil.* -public fun approximateFlexibleTypes(jetType: KtType, outermost: Boolean = true): KtType { +public fun approximateFlexibleTypes(jetType: KotlinType, outermost: Boolean = true): KotlinType { if (jetType.isDynamic()) return jetType if (jetType.isFlexible()) { val flexible = jetType.flexibility() @@ -60,7 +60,7 @@ public fun approximateFlexibleTypes(jetType: KtType, outermost: Boolean = true): return approximation } - return KtTypeImpl.create( + return KotlinTypeImpl.create( jetType.getAnnotations(), jetType.getConstructor(), jetType.isMarkedNullable(), @@ -69,15 +69,15 @@ public fun approximateFlexibleTypes(jetType: KtType, outermost: Boolean = true): ) } -public fun KtType.isAnnotatedReadOnly(): Boolean = hasAnnotationMaybeExternal(JETBRAINS_READONLY_ANNOTATION) -public fun KtType.isAnnotatedNotNull(): Boolean = hasAnnotationMaybeExternal(JETBRAINS_NOT_NULL_ANNOTATION) -public fun KtType.isAnnotatedNullable(): Boolean = hasAnnotationMaybeExternal(JETBRAINS_NULLABLE_ANNOTATION) +public fun KotlinType.isAnnotatedReadOnly(): Boolean = hasAnnotationMaybeExternal(JETBRAINS_READONLY_ANNOTATION) +public fun KotlinType.isAnnotatedNotNull(): Boolean = hasAnnotationMaybeExternal(JETBRAINS_NOT_NULL_ANNOTATION) +public fun KotlinType.isAnnotatedNullable(): Boolean = hasAnnotationMaybeExternal(JETBRAINS_NULLABLE_ANNOTATION) -private fun KtType.hasAnnotationMaybeExternal(fqName: FqName) = with (getAnnotations()) { +private fun KotlinType.hasAnnotationMaybeExternal(fqName: FqName) = with (getAnnotations()) { findAnnotation(fqName) ?: findExternalAnnotation(fqName) } != null -fun KtType.isResolvableInScope(scope: LexicalScope?, checkTypeParameters: Boolean): Boolean { +fun KotlinType.isResolvableInScope(scope: LexicalScope?, checkTypeParameters: Boolean): Boolean { if (canBeReferencedViaImport()) return true val descriptor = getConstructor().getDeclarationDescriptor() @@ -87,13 +87,13 @@ fun KtType.isResolvableInScope(scope: LexicalScope?, checkTypeParameters: Boolea return scope != null && scope.getClassifier(descriptor.name, NoLookupLocation.FROM_IDE) == descriptor } -public fun KtType.approximateWithResolvableType(scope: LexicalScope?, checkTypeParameters: Boolean): KtType { +public fun KotlinType.approximateWithResolvableType(scope: LexicalScope?, checkTypeParameters: Boolean): KotlinType { if (isError() || isResolvableInScope(scope, checkTypeParameters)) return this return supertypes().firstOrNull { it.isResolvableInScope(scope, checkTypeParameters) } ?: builtIns.anyType } -public fun KtType.anonymousObjectSuperTypeOrNull(): KtType? { +public fun KotlinType.anonymousObjectSuperTypeOrNull(): KotlinType? { val classDescriptor = constructor.declarationDescriptor if (classDescriptor != null && DescriptorUtils.isAnonymousObject(classDescriptor)) { return immediateSupertypes().firstOrNull() ?: classDescriptor.builtIns.anyType diff --git a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/extensionsUtils.kt b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/extensionsUtils.kt index f46415a4208..f4229b7ee93 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/extensionsUtils.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/extensionsUtils.kt @@ -29,7 +29,7 @@ import org.jetbrains.kotlin.resolve.scopes.KtScope import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue import org.jetbrains.kotlin.resolve.scopes.receivers.ThisReceiver -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.typeUtil.TypeNullability import org.jetbrains.kotlin.types.typeUtil.makeNotNullable import org.jetbrains.kotlin.types.typeUtil.nullability @@ -73,7 +73,7 @@ public fun CallableDescriptor.substituteExtensionIfCallable( } public fun CallableDescriptor.substituteExtensionIfCallable( - receiverTypes: Collection, + receiverTypes: Collection, callType: CallType<*> ): Collection { if (!callType.descriptorKindFilter.accepts(this)) return listOf() diff --git a/idea/ide-common/src/org/jetbrains/kotlin/util/substitutionUtils.kt b/idea/ide-common/src/org/jetbrains/kotlin/util/substitutionUtils.kt index 9357251fc77..80ce4546b61 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/util/substitutionUtils.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/util/substitutionUtils.kt @@ -22,7 +22,7 @@ import org.jetbrains.kotlin.types.* import org.jetbrains.kotlin.types.checker.TypeCheckingProcedure import java.util.LinkedHashMap -public fun getTypeSubstitution(baseType: KtType, derivedType: KtType): LinkedHashMap? { +public fun getTypeSubstitution(baseType: KotlinType, derivedType: KotlinType): LinkedHashMap? { val substitutedType = TypeCheckingProcedure.findCorrespondingSupertype(derivedType, baseType) ?: return null val substitution = LinkedHashMap(substitutedType.getArguments().size()) @@ -55,6 +55,6 @@ public fun getCallableSubstitutor( return getCallableSubstitution(baseCallable, derivedCallable)?.let { TypeSubstitutor.create(it) } } -public fun getTypeSubstitutor(baseType: KtType, derivedType: KtType): TypeSubstitutor? { +public fun getTypeSubstitutor(baseType: KotlinType, derivedType: KotlinType): TypeSubstitutor? { return getTypeSubstitution(baseType, derivedType)?.let { TypeSubstitutor.create(it) } } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/JetDescriptorIconProvider.java b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/JetDescriptorIconProvider.java index badad4eac7a..3a622dd92e8 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/JetDescriptorIconProvider.java +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/JetDescriptorIconProvider.java @@ -84,7 +84,7 @@ public final class JetDescriptorIconProvider { if (descriptor instanceof FunctionDescriptor) { FunctionDescriptor functionDescriptor = (FunctionDescriptor) descriptor; if (functionDescriptor.getExtensionReceiverParameter() != null) { - return KtIcons.EXTENSION_FUNCTION; + return KotlinIcons.EXTENSION_FUNCTION; } if (descriptor.getContainingDeclaration() instanceof ClassDescriptor) { @@ -96,38 +96,38 @@ public final class JetDescriptorIconProvider { } } else { - return KtIcons.FUNCTION; + return KotlinIcons.FUNCTION; } } if (descriptor instanceof ClassDescriptor) { switch (((ClassDescriptor) descriptor).getKind()) { case INTERFACE: - return KtIcons.TRAIT; + return KotlinIcons.TRAIT; case ENUM_CLASS: - return KtIcons.ENUM; + return KotlinIcons.ENUM; case ENUM_ENTRY: - return KtIcons.ENUM; + return KotlinIcons.ENUM; case ANNOTATION_CLASS: return PlatformIcons.ANNOTATION_TYPE_ICON; case OBJECT: - return KtIcons.OBJECT; + return KotlinIcons.OBJECT; case CLASS: - return KtIcons.CLASS; + return KotlinIcons.CLASS; default: LOG.warn("No icon for descriptor: " + descriptor); return null; } } if (descriptor instanceof ValueParameterDescriptor) { - return KtIcons.PARAMETER; + return KotlinIcons.PARAMETER; } if (descriptor instanceof LocalVariableDescriptor) { - return ((VariableDescriptor) descriptor).isVar() ? KtIcons.VAR : KtIcons.VAL; + return ((VariableDescriptor) descriptor).isVar() ? KotlinIcons.VAR : KotlinIcons.VAL; } if (descriptor instanceof PropertyDescriptor) { - return ((VariableDescriptor) descriptor).isVar() ? KtIcons.FIELD_VAR : KtIcons.FIELD_VAL; + return ((VariableDescriptor) descriptor).isVar() ? KotlinIcons.FIELD_VAR : KotlinIcons.FIELD_VAL; } if (descriptor instanceof TypeParameterDescriptor) { diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/JetIconProvider.java b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/JetIconProvider.java index 8ca7782473c..55062291e70 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/JetIconProvider.java +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/JetIconProvider.java @@ -62,7 +62,7 @@ public class JetIconProvider extends IconProvider implements DumbAware { if (psiElement instanceof KtFile) { KtFile file = (KtFile) psiElement; KtClassOrObject mainClass = getMainClass(file); - return mainClass != null && file.getDeclarations().size() == 1 ? getIcon(mainClass, flags) : KtIcons.FILE; + return mainClass != null && file.getDeclarations().size() == 1 ? getIcon(mainClass, flags) : KotlinIcons.FILE; } Icon result = getBaseIcon(psiElement); @@ -102,7 +102,7 @@ public class JetIconProvider extends IconProvider implements DumbAware { } if (psiElement instanceof KotlinLightClassForFacade) { - return KtIcons.FILE; + return KotlinIcons.FILE; } if (psiElement instanceof KotlinLightClassForDecompiledDeclaration) { @@ -112,7 +112,7 @@ public class JetIconProvider extends IconProvider implements DumbAware { } else { //TODO (light classes for decompiled files): correct presentation - return KtIcons.CLASS; + return KotlinIcons.CLASS; } } @@ -122,7 +122,7 @@ public class JetIconProvider extends IconProvider implements DumbAware { if (psiElement instanceof KtNamedFunction) { if (((KtFunction) psiElement).getReceiverTypeReference() != null) { - return KtIcons.EXTENSION_FUNCTION; + return KotlinIcons.EXTENSION_FUNCTION; } if (PsiTreeUtil.getParentOfType(psiElement, KtNamedDeclaration.class) instanceof KtClass) { @@ -134,41 +134,41 @@ public class JetIconProvider extends IconProvider implements DumbAware { } } else { - return KtIcons.FUNCTION; + return KotlinIcons.FUNCTION; } } - if (psiElement instanceof KtFunctionLiteral) return KtIcons.LAMBDA; + if (psiElement instanceof KtFunctionLiteral) return KotlinIcons.LAMBDA; if (psiElement instanceof KtClass) { KtClass ktClass = (KtClass) psiElement; if (ktClass.isInterface()) { - return KtIcons.TRAIT; + return KotlinIcons.TRAIT; } - Icon icon = ktClass.isEnum() ? KtIcons.ENUM : KtIcons.CLASS; + Icon icon = ktClass.isEnum() ? KotlinIcons.ENUM : KotlinIcons.CLASS; if (ktClass instanceof KtEnumEntry) { KtEnumEntry enumEntry = (KtEnumEntry) ktClass; if (enumEntry.getPrimaryConstructorParameterList() == null) { - icon = KtIcons.ENUM; + icon = KotlinIcons.ENUM; } } return icon; } if (psiElement instanceof KtObjectDeclaration) { - return KtIcons.OBJECT; + return KotlinIcons.OBJECT; } if (psiElement instanceof KtParameter) { KtParameter parameter = (KtParameter) psiElement; if (KtPsiUtil.getClassIfParameterIsProperty(parameter) != null) { - return parameter.isMutable() ? KtIcons.FIELD_VAR : KtIcons.FIELD_VAL; + return parameter.isMutable() ? KotlinIcons.FIELD_VAR : KotlinIcons.FIELD_VAL; } - return KtIcons.PARAMETER; + return KotlinIcons.PARAMETER; } if (psiElement instanceof KtProperty) { KtProperty property = (KtProperty) psiElement; - return property.isVar() ? KtIcons.FIELD_VAR : KtIcons.FIELD_VAL; + return property.isVar() ? KotlinIcons.FIELD_VAR : KotlinIcons.FIELD_VAL; } return null; diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/KtIcons.java b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/KotlinIcons.java similarity index 98% rename from idea/idea-analysis/src/org/jetbrains/kotlin/idea/KtIcons.java rename to idea/idea-analysis/src/org/jetbrains/kotlin/idea/KotlinIcons.java index 6fc9253aa91..0cc19eb09e7 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/KtIcons.java +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/KotlinIcons.java @@ -21,7 +21,7 @@ import com.intellij.util.PlatformIcons; import javax.swing.*; -public interface KtIcons { +public interface KotlinIcons { Icon SMALL_LOGO = IconLoader.getIcon("/org/jetbrains/kotlin/idea/icons/kotlin.png"); Icon KOTLIN_LOGO_24 = IconLoader.getIcon("/org/jetbrains/kotlin/idea/icons/kotlin24.png"); diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/analysis/AnalyzerUtil.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/analysis/AnalyzerUtil.kt index 6728b3fdb9a..7a0517ab5f7 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/analysis/AnalyzerUtil.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/analysis/AnalyzerUtil.kt @@ -25,7 +25,7 @@ import org.jetbrains.kotlin.resolve.BindingTraceContext import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo import org.jetbrains.kotlin.resolve.scopes.KtScope import org.jetbrains.kotlin.resolve.scopes.utils.asLexicalScope -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeUtils import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices import org.jetbrains.kotlin.types.expressions.JetTypeInfo @@ -37,7 +37,7 @@ public fun KtExpression.computeTypeInfoInContext( contextExpression: KtExpression = this, trace: BindingTrace = BindingTraceContext(), dataFlowInfo: DataFlowInfo = DataFlowInfo.EMPTY, - expectedType: KtType = TypeUtils.NO_EXPECTED_TYPE, + expectedType: KotlinType = TypeUtils.NO_EXPECTED_TYPE, isStatement: Boolean = false ): JetTypeInfo { PreliminaryDeclarationVisitor.createForExpression(this, trace) @@ -51,7 +51,7 @@ public fun KtExpression.analyzeInContext( contextExpression: KtExpression = this, trace: BindingTrace = BindingTraceContext(), dataFlowInfo: DataFlowInfo = DataFlowInfo.EMPTY, - expectedType: KtType = TypeUtils.NO_EXPECTED_TYPE, + expectedType: KotlinType = TypeUtils.NO_EXPECTED_TYPE, isStatement: Boolean = false ): BindingContext { computeTypeInfoInContext(scope, contextExpression, trace, dataFlowInfo, expectedType, isStatement) @@ -64,7 +64,7 @@ public fun KtExpression.computeTypeInContext( contextExpression: KtExpression = this, trace: BindingTrace = BindingTraceContext(), dataFlowInfo: DataFlowInfo = DataFlowInfo.EMPTY, - expectedType: KtType = TypeUtils.NO_EXPECTED_TYPE -): KtType? { + expectedType: KotlinType = TypeUtils.NO_EXPECTED_TYPE +): KotlinType? { return computeTypeInfoInContext(scope, contextExpression, trace, dataFlowInfo, expectedType).type } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/AnnotationLoaderForKotlinJavaScriptStubBuilder.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/AnnotationLoaderForKotlinJavaScriptStubBuilder.kt index d241612bb66..66288ba8f6b 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/AnnotationLoaderForKotlinJavaScriptStubBuilder.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/AnnotationLoaderForKotlinJavaScriptStubBuilder.kt @@ -25,7 +25,7 @@ import org.jetbrains.kotlin.serialization.deserialization.AnnotationAndConstantL import org.jetbrains.kotlin.serialization.deserialization.NameResolver import org.jetbrains.kotlin.serialization.deserialization.ProtoContainer import org.jetbrains.kotlin.serialization.js.JsProtoBuf -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType public class AnnotationLoaderForKotlinJavaScriptStubBuilder() : AnnotationAndConstantLoader { @@ -79,6 +79,6 @@ public class AnnotationLoaderForKotlinJavaScriptStubBuilder() : AnnotationAndCon override fun loadPropertyConstant( container: ProtoContainer, proto: ProtoBuf.Property, - expectedType: KtType + expectedType: KotlinType ) {} } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/navigation/MemberMatching.java b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/navigation/MemberMatching.java index 9b75551cea8..a29b75c1323 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/navigation/MemberMatching.java +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/navigation/MemberMatching.java @@ -33,7 +33,7 @@ import org.jetbrains.kotlin.name.Name; import org.jetbrains.kotlin.psi.*; import org.jetbrains.kotlin.renderer.DescriptorRenderer; import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import java.util.List; import java.util.Set; @@ -173,7 +173,7 @@ public class MemberMatching { } String declarationTypeText = typeReference.getText(); - KtType typeToRender = varargInDeclaration ? descriptorParameter.getVarargElementType() : descriptorParameter.getType(); + KotlinType typeToRender = varargInDeclaration ? descriptorParameter.getVarargElementType() : descriptorParameter.getType(); assert typeToRender != null; String descriptorParameterText = DescriptorRenderer.FQ_NAMES_IN_TYPES.renderType(typeToRender); if (!declarationTypeText.equals(descriptorParameterText)) { @@ -221,9 +221,9 @@ public class MemberMatching { } Set descriptorUpperBounds = Sets.newHashSet(ContainerUtil.map( - descriptor.getUpperBounds(), new Function() { + descriptor.getUpperBounds(), new Function() { @Override - public String fun(KtType type) { + public String fun(KotlinType type) { return DescriptorRenderer.FQ_NAMES_IN_TYPES.renderType(type); } })); diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/FunctionsHighlightingVisitor.java b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/FunctionsHighlightingVisitor.java index 56ba4dbaea3..b9c93f34abf 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/FunctionsHighlightingVisitor.java +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/FunctionsHighlightingVisitor.java @@ -28,7 +28,7 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilKt; import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall; import org.jetbrains.kotlin.resolve.calls.model.VariableAsFunctionResolvedCall; import org.jetbrains.kotlin.resolve.calls.tasks.DynamicCallsKt; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.TypeUtils; public class FunctionsHighlightingVisitor extends AfterAnalysisHighlightingVisitor { @@ -103,13 +103,13 @@ public class FunctionsHighlightingVisitor extends AfterAnalysisHighlightingVisit return false; } - KtType defaultType = ((ClassDescriptor) parent).getDefaultType(); + KotlinType defaultType = ((ClassDescriptor) parent).getDefaultType(); if (KotlinBuiltIns.isFunctionOrExtensionFunctionType(defaultType)) { return true; } - for (KtType supertype : TypeUtils.getAllSupertypes(defaultType)) { + for (KotlinType supertype : TypeUtils.getAllSupertypes(defaultType)) { if (KotlinBuiltIns.isFunctionOrExtensionFunctionType(supertype)) { return true; } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/HtmlTabledDescriptorRenderer.java b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/HtmlTabledDescriptorRenderer.java index fcab2300152..1be6402d8c5 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/HtmlTabledDescriptorRenderer.java +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/HtmlTabledDescriptorRenderer.java @@ -29,7 +29,7 @@ import org.jetbrains.kotlin.diagnostics.rendering.TabledDescriptorRenderer.Table import org.jetbrains.kotlin.idea.highlighter.renderersUtil.RenderersUtilKt; import org.jetbrains.kotlin.renderer.*; import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPosition; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import java.util.Collections; import java.util.Iterator; @@ -43,7 +43,7 @@ public class HtmlTabledDescriptorRenderer extends TabledDescriptorRenderer { @NotNull @Override - public Renderer getTypeRenderer() { + public Renderer getTypeRenderer() { return IdeRenderers.HTML_RENDER_TYPE; } @@ -117,8 +117,8 @@ public class HtmlTabledDescriptorRenderer extends TabledDescriptorRenderer { } private void renderFunctionArguments( - @Nullable KtType receiverType, - @NotNull List argumentTypes, + @Nullable KotlinType receiverType, + @NotNull List argumentTypes, Predicate isErrorPosition, StringBuilder result ) { @@ -141,8 +141,8 @@ public class HtmlTabledDescriptorRenderer extends TabledDescriptorRenderer { td(result, RenderersUtilKt.renderStrong("(")); int i = 0; - for (Iterator iterator = argumentTypes.iterator(); iterator.hasNext(); ) { - KtType argumentType = iterator.next(); + for (Iterator iterator = argumentTypes.iterator(); iterator.hasNext(); ) { + KotlinType argumentType = iterator.next(); boolean error = false; if (isErrorPosition.apply(VALUE_PARAMETER_POSITION.position(i))) { error = true; diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/IdeRenderers.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/IdeRenderers.kt index 6c9fa4a12d6..bb29544e0f1 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/IdeRenderers.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/IdeRenderers.kt @@ -25,7 +25,7 @@ import org.jetbrains.kotlin.resolve.MemberComparator import org.jetbrains.kotlin.resolve.calls.inference.InferenceErrorData import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall import org.jetbrains.kotlin.resolve.jvm.diagnostics.ConflictingJvmDeclarationsData -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType public object IdeRenderers { public val HTML_AMBIGUOUS_CALLS: Renderer>> = Renderer { @@ -36,7 +36,7 @@ public object IdeRenderers { .joinToString("") { "

  • " + DescriptorRenderer.HTML.render(it) + "
  • " } } - public val HTML_RENDER_TYPE: Renderer = Renderer { + public val HTML_RENDER_TYPE: Renderer = Renderer { DescriptorRenderer.HTML.renderType(it) } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/VariablesHighlightingVisitor.java b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/VariablesHighlightingVisitor.java index 846f106336b..e0c43002cae 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/VariablesHighlightingVisitor.java +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/VariablesHighlightingVisitor.java @@ -27,7 +27,7 @@ import org.jetbrains.kotlin.psi.*; import org.jetbrains.kotlin.renderer.DescriptorRenderer; import org.jetbrains.kotlin.resolve.BindingContext; import org.jetbrains.kotlin.resolve.calls.tasks.DynamicCallsKt; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.expressions.CaptureKind; import static org.jetbrains.kotlin.resolve.BindingContext.*; @@ -69,7 +69,7 @@ class VariablesHighlightingVisitor extends AfterAnalysisHighlightingVisitor { @Override public void visitExpression(@NotNull KtExpression expression) { - KtType smartCast = bindingContext.get(SMARTCAST, expression); + KotlinType smartCast = bindingContext.get(SMARTCAST, expression); if (smartCast != null) { holder.createInfoAnnotation(expression, "Smart cast to " + DescriptorRenderer.FQ_NAMES_IN_TYPES.renderType(smartCast)).setTextAttributes( JetHighlightingColors.SMART_CAST_VALUE); diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionSession.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionSession.kt index 1afec0bbb62..b7d451ce043 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionSession.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionSession.kt @@ -45,7 +45,7 @@ import org.jetbrains.kotlin.psi.psiUtil.parentsWithSelf import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.typeUtil.makeNotNullable import org.jetbrains.kotlin.util.capitalizeDecapitalize.decapitalizeSmart import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstance @@ -313,7 +313,7 @@ abstract class CompletionSession(protected val configuration: CompletionSessionC ) } - private fun createLookupElementFactory(callType: CallType<*>?, receiverTypes: Collection?): LookupElementFactory { + private fun createLookupElementFactory(callType: CallType<*>?, receiverTypes: Collection?): LookupElementFactory { val contextVariablesProvider = { nameExpression?.let { referenceVariantsHelper.getReferenceVariants(it, DescriptorKindFilter.VARIABLES, { true }, CallTypeAndReceiver.DEFAULT) @@ -327,7 +327,7 @@ abstract class CompletionSession(protected val configuration: CompletionSessionC insertHandlerProvider, contextVariablesProvider) } - private fun detectCallTypeAndReceiverTypes(): Pair, Collection?> { + private fun detectCallTypeAndReceiverTypes(): Pair, Collection?> { if (nameExpression == null) { return CallTypeAndReceiver.UNKNOWN to null } diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionUtils.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionUtils.kt index 9e393b6518e..5883f2694bb 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionUtils.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionUtils.kt @@ -26,7 +26,7 @@ import com.intellij.psi.PsiDocumentManager import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.CallableDescriptor import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor -import org.jetbrains.kotlin.idea.KtIcons +import org.jetbrains.kotlin.idea.KotlinIcons import org.jetbrains.kotlin.idea.completion.handlers.CastReceiverInsertHandler import org.jetbrains.kotlin.idea.completion.handlers.WithTailInsertHandler import org.jetbrains.kotlin.idea.core.getResolutionScope @@ -43,7 +43,7 @@ import org.jetbrains.kotlin.renderer.render import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.inline.InlineUtil import org.jetbrains.kotlin.resolve.scopes.utils.asJetScope -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.typeUtil.TypeNullability import org.jetbrains.kotlin.types.typeUtil.nullability import java.util.* @@ -247,7 +247,7 @@ fun returnExpressionItems(bindingContext: BindingContext, position: KtElement): return result } -private fun KtDeclarationWithBody.returnType(bindingContext: BindingContext): KtType? { +private fun KtDeclarationWithBody.returnType(bindingContext: BindingContext): KotlinType? { val callable = bindingContext[BindingContext.DECLARATION_TO_DESCRIPTOR, this] as? CallableDescriptor ?: return null return callable.getReturnType() } @@ -310,12 +310,12 @@ fun breakOrContinueExpressionItems(position: KtElement, breakOrContinue: String) return result } -fun LookupElementFactory.createLookupElementForType(type: KtType): LookupElement? { +fun LookupElementFactory.createLookupElementForType(type: KotlinType): LookupElement? { if (type.isError()) return null if (KotlinBuiltIns.isExactFunctionOrExtensionFunctionType(type)) { val text = IdeDescriptorRenderers.SOURCE_CODE_SHORT_NAMES_IN_TYPES.renderType(type) - val baseLookupElement = LookupElementBuilder.create(text).withIcon(KtIcons.LAMBDA) + val baseLookupElement = LookupElementBuilder.create(text).withIcon(KotlinIcons.LAMBDA) return BaseTypeLookupElement(type, baseLookupElement) } else { @@ -339,7 +339,7 @@ fun LookupElementFactory.createLookupElementForType(type: KtType): LookupElement } } -private open class BaseTypeLookupElement(type: KtType, baseLookupElement: LookupElement) : LookupElementDecorator(baseLookupElement) { +private open class BaseTypeLookupElement(type: KotlinType, baseLookupElement: LookupElement) : LookupElementDecorator(baseLookupElement) { val fullText = IdeDescriptorRenderers.SOURCE_CODE.renderType(type) override fun equals(other: Any?) = other is BaseTypeLookupElement && fullText == other.fullText diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/ExpectedInfos.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/ExpectedInfos.kt index cb2418dd79d..b7bea025912 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/ExpectedInfos.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/ExpectedInfos.kt @@ -38,7 +38,7 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.getCall import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall import org.jetbrains.kotlin.resolve.calls.util.DelegatingCall import org.jetbrains.kotlin.resolve.descriptorUtil.hasDefaultValue -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeSubstitutor import org.jetbrains.kotlin.types.TypeUtils import org.jetbrains.kotlin.types.typeUtil.containsError @@ -97,15 +97,15 @@ class ExpectedInfo( constructor(fuzzyType: FuzzyType, expectedName: String?, tail: Tail?, itemOptions: ItemOptions = ItemOptions.DEFAULT, additionalData: ExpectedInfo.AdditionalData? = null) : this(ByExpectedTypeFilter(fuzzyType), expectedName, tail, itemOptions, additionalData) - constructor(type: KtType, expectedName: String?, tail: Tail?, itemOptions: ItemOptions = ItemOptions.DEFAULT, additionalData: ExpectedInfo.AdditionalData? = null) + constructor(type: KotlinType, expectedName: String?, tail: Tail?, itemOptions: ItemOptions = ItemOptions.DEFAULT, additionalData: ExpectedInfo.AdditionalData? = null) : this(FuzzyType(type, emptyList()), expectedName, tail, itemOptions, additionalData) fun matchingSubstitutor(descriptorType: FuzzyType): TypeSubstitutor? = filter.matchingSubstitutor(descriptorType) - fun matchingSubstitutor(descriptorType: KtType): TypeSubstitutor? = matchingSubstitutor(FuzzyType(descriptorType, emptyList())) + fun matchingSubstitutor(descriptorType: KotlinType): TypeSubstitutor? = matchingSubstitutor(FuzzyType(descriptorType, emptyList())) companion object { - fun createForArgument(type: KtType, expectedName: String?, tail: Tail?, argumentData: ArgumentPositionData, itemOptions: ItemOptions = ItemOptions.DEFAULT): ExpectedInfo { + fun createForArgument(type: KotlinType, expectedName: String?, tail: Tail?, argumentData: ArgumentPositionData, itemOptions: ItemOptions = ItemOptions.DEFAULT): ExpectedInfo { return ExpectedInfo(FuzzyType(type, argumentData.function.typeParameters), expectedName, tail, itemOptions, argumentData) } @@ -113,7 +113,7 @@ class ExpectedInfo( return ExpectedInfo(ByTypeFilter.None, null, null/*TODO?*/, ItemOptions.DEFAULT, argumentData) } - fun createForReturnValue(type: KtType?, callable: CallableDescriptor): ExpectedInfo { + fun createForReturnValue(type: KotlinType?, callable: CallableDescriptor): ExpectedInfo { val filter = if (type != null) ByExpectedTypeFilter(FuzzyType(type, emptyList())) else ByTypeFilter.All return ExpectedInfo(filter, callable.name.asString(), null, additionalData = ReturnValueAdditionalData(callable)) } @@ -223,7 +223,7 @@ class ExpectedInfos( return results } - private fun calculateForArgument(call: Call, callExpectedType: KtType, argument: ValueArgument): Collection { + private fun calculateForArgument(call: Call, callExpectedType: KotlinType, argument: ValueArgument): Collection { val argumentIndex = call.getValueArguments().indexOf(argument) assert(argumentIndex >= 0) { "Could not find argument '$argument(${argument.asElement().text})' among arguments of call: $call" diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/HeuristicSignatures.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/HeuristicSignatures.kt index 6605c5e8273..b70c789c8fa 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/HeuristicSignatures.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/HeuristicSignatures.kt @@ -31,7 +31,7 @@ import org.jetbrains.kotlin.resolve.TypeResolver import org.jetbrains.kotlin.resolve.scopes.LexicalScopeImpl import org.jetbrains.kotlin.resolve.scopes.utils.memberScopeAsFileScope import org.jetbrains.kotlin.types.IndexedParametersSubstitution -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.SubstitutionUtils import org.jetbrains.kotlin.types.Variance import java.util.* @@ -41,13 +41,13 @@ public class HeuristicSignatures( private val project: Project, private val typeResolver: TypeResolver ) { - public fun correctedParameterType(function: FunctionDescriptor, parameter: ValueParameterDescriptor): KtType? { + public fun correctedParameterType(function: FunctionDescriptor, parameter: ValueParameterDescriptor): KotlinType? { val parameterIndex = function.getValueParameters().indexOf(parameter) assert(parameterIndex >= 0) return correctedParameterType(function, parameterIndex) } - private fun correctedParameterType(function: FunctionDescriptor, parameterIndex: Int): KtType? { + private fun correctedParameterType(function: FunctionDescriptor, parameterIndex: Int): KotlinType? { val ownerType = function.getDispatchReceiverParameter()?.getType() ?: return null val superFunctions = function.getOverriddenDescriptors() @@ -74,7 +74,7 @@ public class HeuristicSignatures( } } - private fun typeFromText(text: String, typeParameters: Collection): KtType { + private fun typeFromText(text: String, typeParameters: Collection): KotlinType { val typeRef = KtPsiFactory(project).createType(text) val rootPackagesScope = SubpackagesScope(moduleDescriptor, FqName.ROOT).memberScopeAsFileScope() val scope = LexicalScopeImpl(rootPackagesScope, moduleDescriptor, false, null, "Root packages + type parameters") { diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/InsertHandlerProvider.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/InsertHandlerProvider.kt index 79f7cb6846b..4739c6bdac8 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/InsertHandlerProvider.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/InsertHandlerProvider.kt @@ -23,7 +23,7 @@ import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.idea.completion.handlers.* import org.jetbrains.kotlin.idea.util.CallType import org.jetbrains.kotlin.idea.util.fuzzyReturnType -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import java.util.* class InsertHandlerProvider( @@ -85,7 +85,7 @@ class InsertHandlerProvider( val potentiallyInferred = HashSet() - fun addPotentiallyInferred(type: KtType) { + fun addPotentiallyInferred(type: KotlinType) { val descriptor = type.constructor.declarationDescriptor as? TypeParameterDescriptor if (descriptor != null && descriptor in typeParameters) { potentiallyInferred.add(descriptor) diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KeywordValues.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KeywordValues.kt index bb38e3623dc..61a4aa06e5e 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KeywordValues.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KeywordValues.kt @@ -31,7 +31,7 @@ import org.jetbrains.kotlin.idea.util.CallTypeAndReceiver import org.jetbrains.kotlin.idea.util.FuzzyType import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.resolve.BindingContext -import org.jetbrains.kotlin.types.KtTypeImpl +import org.jetbrains.kotlin.types.KotlinTypeImpl import org.jetbrains.kotlin.types.TypeProjectionImpl import org.jetbrains.kotlin.types.TypeSubstitutor import org.jetbrains.kotlin.types.typeUtil.isBooleanOrNullableBoolean @@ -92,7 +92,7 @@ object KeywordValues { val qualifierType = bindingContext[BindingContext.TYPE, callTypeAndReceiver.receiver] if (qualifierType != null) { val kClassDescriptor = resolutionFacade.getFrontendService(ReflectionTypes::class.java).kClass - val classLiteralType = KtTypeImpl.create(Annotations.EMPTY, kClassDescriptor, false, listOf(TypeProjectionImpl(qualifierType))) + val classLiteralType = KotlinTypeImpl.create(Annotations.EMPTY, kClassDescriptor, false, listOf(TypeProjectionImpl(qualifierType))) val kClassTypes = listOf(FuzzyType(classLiteralType, emptyList())) val kClassMatcher = { info: ExpectedInfo -> kClassTypes.matchExpectedInfo(info) } consumer.consume("class", kClassMatcher, SmartCompletionItemPriority.CLASS_LITERAL) { @@ -104,7 +104,7 @@ object KeywordValues { .singleOrNull() as? ClassDescriptor if (javaLangClassDescriptor != null) { - val javaLangClassType = KtTypeImpl.create(Annotations.EMPTY, javaLangClassDescriptor, false, listOf(TypeProjectionImpl(qualifierType))) + val javaLangClassType = KotlinTypeImpl.create(Annotations.EMPTY, javaLangClassDescriptor, false, listOf(TypeProjectionImpl(qualifierType))) val javaClassTypes = listOf(FuzzyType(javaLangClassType, emptyList())) val javaClassMatcher = { info: ExpectedInfo -> javaClassTypes.matchExpectedInfo(info) } consumer.consume("class", javaClassMatcher, SmartCompletionItemPriority.CLASS_LITERAL) { diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementFactory.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementFactory.kt index 48df7bff9a1..2d047c5c714 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementFactory.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementFactory.kt @@ -38,13 +38,13 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.hasDefaultValue import org.jetbrains.kotlin.resolve.descriptorUtil.isExtension import org.jetbrains.kotlin.synthetic.SamAdapterExtensionFunctionDescriptor import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeUtils import org.jetbrains.kotlin.types.typeUtil.isSubtypeOf class LookupElementFactory( private val resolutionFacade: ResolutionFacade, - private val receiverTypes: Collection?, + private val receiverTypes: Collection?, private val callType: CallType<*>?, private val isInStringTemplateAfterDollar: Boolean, public val insertHandlerProvider: InsertHandlerProvider, @@ -104,7 +104,7 @@ class LookupElementFactory( } } - private fun createFunctionCallElementWithLambda(descriptor: FunctionDescriptor, parameterType: KtType, explicitLambdaParameters: Boolean, useReceiverTypes: Boolean): LookupElement { + private fun createFunctionCallElementWithLambda(descriptor: FunctionDescriptor, parameterType: KotlinType, explicitLambdaParameters: Boolean, useReceiverTypes: Boolean): LookupElement { var lookupElement = createLookupElement(descriptor, useReceiverTypes) val inputTypeArguments = (insertHandlerProvider.insertHandler(descriptor) as KotlinFunctionInsertHandler.Normal).inputTypeArguments val lambdaInfo = GenerateLambdaInfo(parameterType, explicitLambdaParameters) diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/NamedArgumentCompletion.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/NamedArgumentCompletion.kt index 10acea2c70c..1fc934194ac 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/NamedArgumentCompletion.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/NamedArgumentCompletion.kt @@ -20,7 +20,7 @@ import com.intellij.codeInsight.completion.InsertHandler import com.intellij.codeInsight.completion.InsertionContext import com.intellij.codeInsight.lookup.LookupElement import com.intellij.codeInsight.lookup.LookupElementBuilder -import org.jetbrains.kotlin.idea.KtIcons +import org.jetbrains.kotlin.idea.KotlinIcons import org.jetbrains.kotlin.idea.completion.handlers.WithTailInsertHandler import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.psi.KtCallElement @@ -29,7 +29,7 @@ import org.jetbrains.kotlin.psi.KtValueArgument import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType import org.jetbrains.kotlin.renderer.DescriptorRenderer import org.jetbrains.kotlin.renderer.render -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import java.util.* object NamedArgumentCompletion { @@ -45,7 +45,7 @@ object NamedArgumentCompletion { } public fun complete(collector: LookupElementsCollector, expectedInfos: Collection) { - val nameToParameterType = HashMap>() + val nameToParameterType = HashMap>() for (expectedInfo in expectedInfos) { val argumentData = expectedInfo.additionalData as? ArgumentPositionData.Positional ?: continue for (parameter in argumentData.namedArgumentCandidates) { @@ -59,7 +59,7 @@ object NamedArgumentCompletion { val lookupElement = LookupElementBuilder.create(nameString) .withPresentableText("$nameString =") .withTailText(" $typeText") - .withIcon(KtIcons.PARAMETER) + .withIcon(KotlinIcons.PARAMETER) .withInsertHandler(NamedArgumentInsertHandler(name)) .assignPriority(ItemPriority.NAMED_PARAMETER) collector.addElement(lookupElement) diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/ParameterNameAndTypeCompletion.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/ParameterNameAndTypeCompletion.kt index 05d3a62cc10..079fbd11fd2 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/ParameterNameAndTypeCompletion.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/ParameterNameAndTypeCompletion.kt @@ -43,7 +43,7 @@ import org.jetbrains.kotlin.psi.psiUtil.forEachDescendantOfType import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter import org.jetbrains.kotlin.resolve.scopes.utils.getDescriptorsFiltered -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import java.util.* class ParameterNameAndTypeCompletion( @@ -152,7 +152,7 @@ class ParameterNameAndTypeCompletion( } } - private fun KtType.isVisible(visibilityFilter: (DeclarationDescriptor) -> Boolean): Boolean { + private fun KotlinType.isVisible(visibilityFilter: (DeclarationDescriptor) -> Boolean): Boolean { if (isError()) return false val classifier = getConstructor().getDeclarationDescriptor() ?: return false return visibilityFilter(classifier) && getArguments().all { it.isStarProjection || it.getType().isVisible(visibilityFilter) } @@ -175,7 +175,7 @@ class ParameterNameAndTypeCompletion( = lookupElementFactory.createLookupElementForJavaClass(psiClass, qualifyNestedClasses = true) } - private class ArbitraryType(private val type: KtType) : Type(IdeDescriptorRenderers.SOURCE_CODE.renderType(type)) { + private class ArbitraryType(private val type: KotlinType) : Type(IdeDescriptorRenderers.SOURCE_CODE.renderType(type)) { override fun createTypeLookupElement(lookupElementFactory: LookupElementFactory) = lookupElementFactory.createLookupElementForType(type) } diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/SmartCastCalculator.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/SmartCastCalculator.kt index 641b5871dfc..36dc5f41ca7 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/SmartCastCalculator.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/SmartCastCalculator.kt @@ -33,7 +33,7 @@ import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory import org.jetbrains.kotlin.resolve.calls.smartcasts.Nullability import org.jetbrains.kotlin.resolve.scopes.KtScope import org.jetbrains.kotlin.resolve.scopes.receivers.ThisReceiver -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.typeUtil.isSubtypeOf import org.jetbrains.kotlin.types.typeUtil.makeNotNullable import java.util.HashMap @@ -49,18 +49,18 @@ class SmartCastCalculator( private val entityToSmartCastInfo: Map = processDataFlowInfo(bindingContext.getDataFlowInfo(expression), bindingContext[BindingContext.RESOLUTION_SCOPE, expression], receiver) - fun types(descriptor: VariableDescriptor): Collection { + fun types(descriptor: VariableDescriptor): Collection { val type = descriptor.returnType ?: return emptyList() return entityType(descriptor, type) } - fun types(thisReceiverParameter: ReceiverParameterDescriptor): Collection { + fun types(thisReceiverParameter: ReceiverParameterDescriptor): Collection { val type = thisReceiverParameter.type val thisReceiver = thisReceiverParameter.value as? ThisReceiver ?: return listOf(type) return entityType(thisReceiver, type) } - private fun entityType(entity: Any, ownType: KtType): Collection { + private fun entityType(entity: Any, ownType: KotlinType): Collection { val smartCastInfo = entityToSmartCastInfo[entity] ?: return listOf(ownType) var types = smartCastInfo.types + ownType @@ -72,7 +72,7 @@ class SmartCastCalculator( return types } - private data class SmartCastInfo(var types: Collection, var notNull: Boolean) { + private data class SmartCastInfo(var types: Collection, var notNull: Boolean) { constructor() : this(emptyList(), false) } diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/GenerateLambda.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/GenerateLambda.kt index f99caa25890..90dec7dcb35 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/GenerateLambda.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/GenerateLambda.kt @@ -35,9 +35,9 @@ import org.jetbrains.kotlin.idea.util.application.executeWriteCommand import org.jetbrains.kotlin.psi.KtExpression import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType -fun insertLambdaTemplate(context: InsertionContext, placeholderRange: TextRange, lambdaType: KtType) { +fun insertLambdaTemplate(context: InsertionContext, placeholderRange: TextRange, lambdaType: KotlinType) { val explicitParameterTypes = needExplicitParameterTypes(context, placeholderRange, lambdaType) // we start template later to not interfere with insertion of tail type @@ -64,14 +64,14 @@ fun insertLambdaTemplate(context: InsertionContext, placeholderRange: TextRange, } } -fun lambdaPresentation(lambdaType: KtType?): String { +fun lambdaPresentation(lambdaType: KotlinType?): String { if (lambdaType == null) return "{...}" val parameterTypes = functionParameterTypes(lambdaType) val parametersPresentation = parameterTypes.map { IdeDescriptorRenderers.SOURCE_CODE_SHORT_NAMES_IN_TYPES.renderType(it) }.joinToString(", ") return "{ $parametersPresentation -> ... }" } -private fun needExplicitParameterTypes(context: InsertionContext, placeholderRange: TextRange, lambdaType: KtType): Boolean { +private fun needExplicitParameterTypes(context: InsertionContext, placeholderRange: TextRange, lambdaType: KotlinType): Boolean { PsiDocumentManager.getInstance(context.getProject()).commitAllDocuments() val file = context.getFile() as KtFile val expression = PsiTreeUtil.findElementOfClassAtRange(file, placeholderRange.getStartOffset(), placeholderRange.getEndOffset(), javaClass()) @@ -92,7 +92,7 @@ private fun needExplicitParameterTypes(context: InsertionContext, placeholderRan return functionTypes.filter { KotlinBuiltIns.getParameterTypeProjectionsFromFunctionType(it).size() == lambdaParameterCount }.size() > 1 } -private fun buildTemplate(lambdaType: KtType, explicitParameterTypes: Boolean, project: Project): Template { +private fun buildTemplate(lambdaType: KotlinType, explicitParameterTypes: Boolean, project: Project): Template { val parameterTypes = functionParameterTypes(lambdaType) val manager = TemplateManager.getInstance(project) @@ -128,5 +128,5 @@ private class ParameterNameExpression(val nameSuggestions: Array) : Expr = Array(nameSuggestions.size(), { LookupElementBuilder.create(nameSuggestions[it]) }) } -fun functionParameterTypes(functionType: KtType): List +fun functionParameterTypes(functionType: KotlinType): List = KotlinBuiltIns.getParameterTypeProjectionsFromFunctionType(functionType).map { it.getType() } diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/KotlinFunctionInsertHandler.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/KotlinFunctionInsertHandler.kt index 46860a79a8e..0cb59675443 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/KotlinFunctionInsertHandler.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/KotlinFunctionInsertHandler.kt @@ -29,9 +29,9 @@ import org.jetbrains.kotlin.idea.core.formatter.JetCodeStyleSettings import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.psi.KtTypeArgumentList import org.jetbrains.kotlin.psi.psiUtil.endOffset -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType -class GenerateLambdaInfo(val lambdaType: KtType, val explicitParameters: Boolean) +class GenerateLambdaInfo(val lambdaType: KotlinType, val explicitParameters: Boolean) sealed class KotlinFunctionInsertHandler : KotlinCallableInsertHandler() { diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/ClassLiteralItems.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/ClassLiteralItems.kt index 9474d0937e0..8c92c4a9728 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/ClassLiteralItems.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/ClassLiteralItems.kt @@ -28,7 +28,7 @@ import org.jetbrains.kotlin.idea.completion.createLookupElementForType import org.jetbrains.kotlin.idea.completion.fuzzyType import org.jetbrains.kotlin.idea.imports.importableFqName import org.jetbrains.kotlin.idea.quickfix.moveCaret -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.Variance import java.util.* @@ -39,7 +39,7 @@ object ClassLiteralItems { lookupElementFactory: LookupElementFactory, isJvmModule: Boolean ) { - val typeAndSuffixToExpectedInfos = LinkedHashMap, MutableList>() + val typeAndSuffixToExpectedInfos = LinkedHashMap, MutableList>() for (expectedInfo in expectedInfos) { val fuzzyType = expectedInfo.fuzzyType ?: continue diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/SmartCompletion.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/SmartCompletion.kt index 0dfdadd5ea7..506ada5515c 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/SmartCompletion.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/SmartCompletion.kt @@ -34,7 +34,7 @@ import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.DescriptorUtils -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeUtils import org.jetbrains.kotlin.types.typeUtil.makeNotNullable import org.jetbrains.kotlin.utils.addIfNotNull @@ -374,7 +374,7 @@ class SmartCompletion( if (elementType != KtTokens.AS_KEYWORD && elementType != KtTokens.AS_SAFE) return null val expectedInfos = calcExpectedInfos(binaryExpression) - val expectedInfosGrouped: Map> = expectedInfos.groupBy { it.fuzzyType?.type?.makeNotNullable() } + val expectedInfosGrouped: Map> = expectedInfos.groupBy { it.fuzzyType?.type?.makeNotNullable() } val items = ArrayList() for ((type, infos) in expectedInfosGrouped) { diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/TypeInstantiationItems.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/TypeInstantiationItems.kt index 51d8e987da6..10a6626d7c3 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/TypeInstantiationItems.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/TypeInstantiationItems.kt @@ -266,7 +266,7 @@ class TypeInstantiationItems( return InstantiationLookupElement(lookupElement).addTail(tail) } - private fun KtType.areTypeParametersUsedInside(freeParameters: Collection): Boolean { + private fun KotlinType.areTypeParametersUsedInside(freeParameters: Collection): Boolean { return FuzzyType(this, freeParameters).freeParameters.isNotEmpty() } @@ -296,7 +296,7 @@ class TypeInstantiationItems( private val tail: Tail?) : InheritanceItemsSearcher { private val baseHasTypeArgs = classDescriptor.typeConstructor.parameters.isNotEmpty() - private val expectedType = KtTypeImpl.create(Annotations.EMPTY, classDescriptor, false, typeArgs) + private val expectedType = KotlinTypeImpl.create(Annotations.EMPTY, classDescriptor, false, typeArgs) private val expectedFuzzyType = FuzzyType(expectedType, freeParameters) override fun search(nameFilter: (String) -> Boolean, consumer: (LookupElement) -> Unit) { diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/TypesWithContainsDetector.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/TypesWithContainsDetector.kt index f3a097fd68a..d8501677e42 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/TypesWithContainsDetector.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/TypesWithContainsDetector.kt @@ -26,14 +26,14 @@ import org.jetbrains.kotlin.idea.util.nullability import org.jetbrains.kotlin.incremental.components.NoLookupLocation import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.resolve.scopes.KtScope -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeUtils import org.jetbrains.kotlin.types.typeUtil.TypeNullability import java.util.* class TypesWithContainsDetector( private val scope: KtScope, - private val argumentType: KtType, + private val argumentType: KotlinType, private val resolutionFacade: ResolutionFacade ) { private val cache = HashMap() @@ -41,7 +41,7 @@ class TypesWithContainsDetector( private val booleanType = resolutionFacade.moduleDescriptor.builtIns.booleanType private val heuristicSignatures = resolutionFacade.ideService() - private val typesWithExtensionContains: Collection = scope.getFunctions(containsName, NoLookupLocation.FROM_IDE) + private val typesWithExtensionContains: Collection = scope.getFunctions(containsName, NoLookupLocation.FROM_IDE) .filter { it.getExtensionReceiverParameter() != null && isGoodContainsFunction(it, listOf()) } .map { it.getExtensionReceiverParameter()!!.getType() } diff --git a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/IterableTypesDetection.kt b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/IterableTypesDetection.kt index 21724fe3989..94daf647cdd 100644 --- a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/IterableTypesDetection.kt +++ b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/IterableTypesDetection.kt @@ -27,7 +27,7 @@ import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo import org.jetbrains.kotlin.resolve.scopes.KtScope import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver import org.jetbrains.kotlin.resolve.scopes.utils.asLexicalScope -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeUtils import org.jetbrains.kotlin.types.expressions.ExpressionTypingContext import org.jetbrains.kotlin.types.expressions.ForLoopConventionsChecker @@ -48,24 +48,24 @@ public class IterableTypesDetection( private inner class Detector(private val scope: KtScope): IterableTypesDetector { private val cache = HashMap() - private val typesWithExtensionIterator: Collection = scope.getFunctions(iteratorName, NoLookupLocation.FROM_IDE) + private val typesWithExtensionIterator: Collection = scope.getFunctions(iteratorName, NoLookupLocation.FROM_IDE) .map { it.getExtensionReceiverParameter() } .filterNotNull() .map { it.getType() } - override fun isIterable(type: FuzzyType, loopVarType: KtType?): Boolean { + override fun isIterable(type: FuzzyType, loopVarType: KotlinType?): Boolean { val elementType = elementType(type) ?: return false return loopVarType == null || elementType.checkIsSubtypeOf(loopVarType) != null } - override fun isIterable(type: KtType, loopVarType: KtType?): Boolean + override fun isIterable(type: KotlinType, loopVarType: KotlinType?): Boolean = isIterable(FuzzyType(type, emptyList()), loopVarType) private fun elementType(type: FuzzyType): FuzzyType? { return cache.getOrPut(type, { elementTypeNoCache(type) }) } - override fun elementType(type: KtType): FuzzyType? + override fun elementType(type: KotlinType): FuzzyType? = elementType(FuzzyType(type, emptyList())) private fun elementTypeNoCache(type: FuzzyType): FuzzyType? { @@ -87,9 +87,9 @@ public class IterableTypesDetection( } public interface IterableTypesDetector { - public fun isIterable(type: KtType, loopVarType: KtType? = null): Boolean + public fun isIterable(type: KotlinType, loopVarType: KotlinType? = null): Boolean - public fun isIterable(type: FuzzyType, loopVarType: KtType? = null): Boolean + public fun isIterable(type: FuzzyType, loopVarType: KotlinType? = null): Boolean - public fun elementType(type: KtType): FuzzyType? + public fun elementType(type: KotlinType): FuzzyType? } \ No newline at end of file diff --git a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/KotlinIndicesHelper.kt b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/KotlinIndicesHelper.kt index 1001b99c746..6c6479c0677 100644 --- a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/KotlinIndicesHelper.kt +++ b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/KotlinIndicesHelper.kt @@ -37,7 +37,7 @@ import org.jetbrains.kotlin.psi.KtNamedDeclaration import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.isAnnotatedAsHidden import org.jetbrains.kotlin.resolve.lazy.ResolveSessionUtils -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.utils.addIfNotNull import org.jetbrains.kotlin.utils.addToStdlib.singletonOrEmptyList import java.util.* @@ -114,7 +114,7 @@ public class KotlinIndicesHelper( return findSuitableExtensions(declarations, receiverTypes, callTypeAndReceiver.callType) } - private fun MutableCollection.addTypeNames(type: KtType) { + private fun MutableCollection.addTypeNames(type: KotlinType) { val constructor = type.getConstructor() addIfNotNull(constructor.getDeclarationDescriptor()?.getName()?.asString()) constructor.getSupertypes().forEach { addTypeNames(it) } @@ -125,7 +125,7 @@ public class KotlinIndicesHelper( */ private fun findSuitableExtensions( declarations: Sequence, - receiverTypes: Collection, + receiverTypes: Collection, callType: CallType<*> ): Collection { val result = LinkedHashSet() diff --git a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/KotlinNameSuggester.kt b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/KotlinNameSuggester.kt index 2bc3874a075..da6055efd3e 100644 --- a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/KotlinNameSuggester.kt +++ b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/KotlinNameSuggester.kt @@ -23,7 +23,7 @@ import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.types.ErrorUtils -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeUtils import org.jetbrains.kotlin.types.checker.KotlinTypeChecker import org.jetbrains.kotlin.types.typeUtil.builtIns @@ -50,7 +50,7 @@ public object KotlinNameSuggester { return result } - public fun suggestNamesByType(type: KtType, validator: (String) -> Boolean, defaultName: String? = null): List { + public fun suggestNamesByType(type: KotlinType, validator: (String) -> Boolean, defaultName: String? = null): List { val result = ArrayList() result.addNamesByType(type, validator) @@ -74,7 +74,7 @@ public object KotlinNameSuggester { return result } - public fun suggestIterationVariableNames(collection: KtExpression, elementType: KtType, validator: (String) -> Boolean, defaultName: String?): Collection { + public fun suggestIterationVariableNames(collection: KtExpression, elementType: KotlinType, validator: (String) -> Boolean, defaultName: String?): Collection { val result = LinkedHashSet() suggestNamesByExpressionOnly(collection, { true }) @@ -133,7 +133,7 @@ public object KotlinNameSuggester { } } - private fun MutableCollection.addNamesByType(type: KtType, validator: (String) -> Boolean) { + private fun MutableCollection.addNamesByType(type: KotlinType, validator: (String) -> Boolean) { var type = TypeUtils.makeNotNullable(type) // wipe out '?' val builtIns = type.builtIns val typeChecker = KotlinTypeChecker.DEFAULT diff --git a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/Utils.kt b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/Utils.kt index 547065e34c1..337821184d0 100644 --- a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/Utils.kt +++ b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/Utils.kt @@ -45,7 +45,7 @@ import org.jetbrains.kotlin.resolve.scopes.KtScope import org.jetbrains.kotlin.resolve.scopes.LexicalScope import org.jetbrains.kotlin.resolve.scopes.receivers.ThisReceiver import org.jetbrains.kotlin.resolve.scopes.utils.asJetScope -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeUtils import org.jetbrains.kotlin.types.checker.KotlinTypeChecker import org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils @@ -130,7 +130,7 @@ public fun KtImportDirective.targetDescriptors(): Collection> { @@ -169,7 +169,7 @@ public fun Call.resolveCandidates( return candidates } -private fun expectedType(call: Call, bindingContext: BindingContext): KtType { +private fun expectedType(call: Call, bindingContext: BindingContext): KotlinType { return (call.callElement as? KtExpression)?.let { bindingContext[BindingContext.EXPECTED_EXPRESSION_TYPE, it.getQualifiedExpressionForSelectorOrThis()] } ?: TypeUtils.NO_EXPECTED_TYPE diff --git a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/quickfix/QuickFixUtil.java b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/quickfix/QuickFixUtil.java index a67cd138f10..7de65d0533d 100644 --- a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/quickfix/QuickFixUtil.java +++ b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/quickfix/QuickFixUtil.java @@ -37,7 +37,7 @@ import org.jetbrains.kotlin.resolve.DescriptorUtils; import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilKt; import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall; import org.jetbrains.kotlin.types.DeferredType; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.checker.KotlinTypeChecker; public class QuickFixUtil { @@ -58,12 +58,12 @@ public class QuickFixUtil { } @Nullable - public static KtType getDeclarationReturnType(KtNamedDeclaration declaration) { + public static KotlinType getDeclarationReturnType(KtNamedDeclaration declaration) { PsiFile file = declaration.getContainingFile(); if (!(file instanceof KtFile)) return null; DeclarationDescriptor descriptor = ResolutionUtils.resolveToDescriptor(declaration); if (!(descriptor instanceof CallableDescriptor)) return null; - KtType type = ((CallableDescriptor) descriptor).getReturnType(); + KotlinType type = ((CallableDescriptor) descriptor).getReturnType(); if (type instanceof DeferredType) { type = ((DeferredType) type).getDelegate(); } @@ -71,10 +71,10 @@ public class QuickFixUtil { } @Nullable - public static KtType findLowerBoundOfOverriddenCallablesReturnTypes(@NotNull CallableDescriptor descriptor) { - KtType matchingReturnType = null; + public static KotlinType findLowerBoundOfOverriddenCallablesReturnTypes(@NotNull CallableDescriptor descriptor) { + KotlinType matchingReturnType = null; for (CallableDescriptor overriddenDescriptor : ((CallableDescriptor) descriptor).getOverriddenDescriptors()) { - KtType overriddenReturnType = overriddenDescriptor.getReturnType(); + KotlinType overriddenReturnType = overriddenDescriptor.getReturnType(); if (overriddenReturnType == null) { return null; } @@ -155,7 +155,7 @@ public class QuickFixUtil { } } - public static String renderTypeWithFqNameOnClash(KtType type, String nameToCheckAgainst) { + public static String renderTypeWithFqNameOnClash(KotlinType type, String nameToCheckAgainst) { FqName typeFqName = DescriptorUtils.getFqNameSafe(DescriptorUtils.getClassDescriptorForType(type)); FqName fqNameToCheckAgainst = new FqName(nameToCheckAgainst); DescriptorRenderer renderer = typeFqName.shortName().equals(fqNameToCheckAgainst.shortName()) diff --git a/idea/idea-repl/src/org/jetbrains/kotlin/console/gutter/ReplIcons.kt b/idea/idea-repl/src/org/jetbrains/kotlin/console/gutter/ReplIcons.kt index dd1a6436868..dc61a5715da 100644 --- a/idea/idea-repl/src/org/jetbrains/kotlin/console/gutter/ReplIcons.kt +++ b/idea/idea-repl/src/org/jetbrains/kotlin/console/gutter/ReplIcons.kt @@ -17,7 +17,7 @@ package org.jetbrains.kotlin.console.gutter import com.intellij.icons.AllIcons -import org.jetbrains.kotlin.idea.KtIcons +import org.jetbrains.kotlin.idea.KotlinIcons import javax.swing.Icon public data class IconWithTooltip(val icon: Icon, val tooltip: String?) @@ -25,7 +25,7 @@ public data class IconWithTooltip(val icon: Icon, val tooltip: String?) public object ReplIcons { public val BUILD_WARNING_INDICATOR: IconWithTooltip = IconWithTooltip(AllIcons.Ide.Warning_notifications, null) public val HISTORY_INDICATOR: IconWithTooltip = IconWithTooltip(AllIcons.General.MessageHistory, "History of executed commands") - public val EDITOR_INDICATOR: IconWithTooltip = IconWithTooltip(KtIcons.LAUNCH, "Write your commands here") + public val EDITOR_INDICATOR: IconWithTooltip = IconWithTooltip(KotlinIcons.LAUNCH, "Write your commands here") public val EDITOR_READLINE_INDICATOR: IconWithTooltip = IconWithTooltip(AllIcons.General.Balloon, "Waiting for input...") public val COMMAND_MARKER: IconWithTooltip = IconWithTooltip(AllIcons.General.Run, "Executed command") public val READLINE_MARKER: IconWithTooltip = IconWithTooltip(AllIcons.Icons.Ide.SpeedSearchPrompt, "Input line") diff --git a/idea/src/org/jetbrains/kotlin/idea/actions/NewKotlinFileAction.java b/idea/src/org/jetbrains/kotlin/idea/actions/NewKotlinFileAction.java index 866ecab3c7c..db71f8d773d 100644 --- a/idea/src/org/jetbrains/kotlin/idea/actions/NewKotlinFileAction.java +++ b/idea/src/org/jetbrains/kotlin/idea/actions/NewKotlinFileAction.java @@ -32,7 +32,7 @@ import com.intellij.psi.PsiDirectory; import com.intellij.psi.PsiFile; import org.jetbrains.kotlin.idea.JetBundle; import org.jetbrains.kotlin.idea.KotlinFileType; -import org.jetbrains.kotlin.idea.KtIcons; +import org.jetbrains.kotlin.idea.KotlinIcons; import org.jetbrains.kotlin.idea.configuration.ConfigureKotlinInProjectUtils; import java.util.Map; @@ -57,10 +57,10 @@ public class NewKotlinFileAction extends CreateFileFromTemplateAction implements builder .setTitle("New Kotlin File/Class") .addKind("File", KotlinFileType.INSTANCE.getIcon(), "Kotlin File") - .addKind("Class", KtIcons.CLASS, "Kotlin Class") - .addKind("Interface", KtIcons.TRAIT, "Kotlin Interface") - .addKind("Enum class", KtIcons.ENUM, "Kotlin Enum") - .addKind("Object", KtIcons.OBJECT, "Kotlin Object"); + .addKind("Class", KotlinIcons.CLASS, "Kotlin Class") + .addKind("Interface", KotlinIcons.TRAIT, "Kotlin Interface") + .addKind("Enum class", KotlinIcons.ENUM, "Kotlin Enum") + .addKind("Object", KotlinIcons.OBJECT, "Kotlin Object"); } @Override diff --git a/idea/src/org/jetbrains/kotlin/idea/actions/ShowExpressionTypeAction.kt b/idea/src/org/jetbrains/kotlin/idea/actions/ShowExpressionTypeAction.kt index 2929a4a5725..3f79a07ef07 100644 --- a/idea/src/org/jetbrains/kotlin/idea/actions/ShowExpressionTypeAction.kt +++ b/idea/src/org/jetbrains/kotlin/idea/actions/ShowExpressionTypeAction.kt @@ -35,7 +35,7 @@ import org.jetbrains.kotlin.psi.psiUtil.parents import org.jetbrains.kotlin.psi.psiUtil.startOffset import org.jetbrains.kotlin.renderer.DescriptorRenderer import org.jetbrains.kotlin.resolve.BindingContext -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType @Deprecated("Remove once we no longer support IDEA 14.1") public class ShowExpressionTypeAction : AnAction() { @@ -80,9 +80,9 @@ public class ShowExpressionTypeAction : AnAction() { } companion object { - fun renderTypeHint(type: KtType) = "" + DescriptorRenderer.HTML.renderType(type) + "" + fun renderTypeHint(type: KotlinType) = "" + DescriptorRenderer.HTML.renderType(type) + "" - fun typeByExpression(expression: KtExpression): KtType? { + fun typeByExpression(expression: KtExpression): KotlinType? { val bindingContext = expression.analyze() if (expression is KtCallableDeclaration) { diff --git a/idea/src/org/jetbrains/kotlin/idea/actions/ShowKotlinBytecodeAction.kt b/idea/src/org/jetbrains/kotlin/idea/actions/ShowKotlinBytecodeAction.kt index c4ba1aca4e8..99b5c81bcaf 100644 --- a/idea/src/org/jetbrains/kotlin/idea/actions/ShowKotlinBytecodeAction.kt +++ b/idea/src/org/jetbrains/kotlin/idea/actions/ShowKotlinBytecodeAction.kt @@ -23,7 +23,7 @@ import com.intellij.openapi.wm.ToolWindowAnchor import com.intellij.openapi.wm.ToolWindowManager import com.intellij.ui.content.ContentFactory import org.jetbrains.kotlin.idea.KotlinFileType -import org.jetbrains.kotlin.idea.KtIcons +import org.jetbrains.kotlin.idea.KotlinIcons import org.jetbrains.kotlin.idea.internal.KotlinBytecodeToolWindow public class ShowKotlinBytecodeAction(): AnAction() { @@ -36,7 +36,7 @@ public class ShowKotlinBytecodeAction(): AnAction() { var toolWindow = toolWindowManager.getToolWindow(TOOLWINDOW_ID) if (toolWindow == null) { toolWindow = toolWindowManager.registerToolWindow("Kotlin Bytecode", true, ToolWindowAnchor.RIGHT) - toolWindow.setIcon(KtIcons.SMALL_LOGO_13) + toolWindow.setIcon(KotlinIcons.SMALL_LOGO_13) val contentManager = toolWindow.getContentManager() val contentFactory = ContentFactory.SERVICE.getInstance() diff --git a/idea/src/org/jetbrains/kotlin/idea/actions/generate/KotlinGenerateSecondaryConstructorAction.kt b/idea/src/org/jetbrains/kotlin/idea/actions/generate/KotlinGenerateSecondaryConstructorAction.kt index 38041385e33..705265b186a 100644 --- a/idea/src/org/jetbrains/kotlin/idea/actions/generate/KotlinGenerateSecondaryConstructorAction.kt +++ b/idea/src/org/jetbrains/kotlin/idea/actions/generate/KotlinGenerateSecondaryConstructorAction.kt @@ -42,7 +42,7 @@ import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns import org.jetbrains.kotlin.resolve.descriptorUtil.getSuperClassNotAny import org.jetbrains.kotlin.resolve.source.getPsi -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeSubstitutor import org.jetbrains.kotlin.types.Variance import org.jetbrains.kotlin.types.checker.KotlinTypeChecker @@ -140,7 +140,7 @@ class KotlinGenerateSecondaryConstructorAction : KotlinGenerateMemberActionBase< propertiesToInitialize: List, superConstructor: ConstructorDescriptor? ): KtSecondaryConstructor? { - fun equalTypes(types1: Collection, types2: Collection): Boolean { + fun equalTypes(types1: Collection, types2: Collection): Boolean { return types1.size == types2.size && (types1.zip(types2)).all { KotlinTypeChecker.DEFAULT.equalTypes(it.first, it.second) } } diff --git a/idea/src/org/jetbrains/kotlin/idea/actions/internal/CheckPartialBodyResolveAction.kt b/idea/src/org/jetbrains/kotlin/idea/actions/internal/CheckPartialBodyResolveAction.kt index 1e21b6be761..49a024baa52 100644 --- a/idea/src/org/jetbrains/kotlin/idea/actions/internal/CheckPartialBodyResolveAction.kt +++ b/idea/src/org/jetbrains/kotlin/idea/actions/internal/CheckPartialBodyResolveAction.kt @@ -43,7 +43,7 @@ import org.jetbrains.kotlin.psi.psiUtil.siblings import org.jetbrains.kotlin.renderer.DescriptorRenderer import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull import java.util.ArrayList import javax.swing.SwingUtilities @@ -147,7 +147,7 @@ public class CheckPartialBodyResolveAction : AnAction() { } private fun DeclarationDescriptor.presentation() = DescriptorRenderer.FQ_NAMES_IN_TYPES.render(this) - private fun KtType.presentation() = DescriptorRenderer.FQ_NAMES_IN_TYPES.renderType(this) + private fun KotlinType.presentation() = DescriptorRenderer.FQ_NAMES_IN_TYPES.renderType(this) override fun update(e: AnActionEvent) { if (!KotlinInternalMode.enabled) { diff --git a/idea/src/org/jetbrains/kotlin/idea/actions/internal/FindImplicitNothingAction.kt b/idea/src/org/jetbrains/kotlin/idea/actions/internal/FindImplicitNothingAction.kt index b4f8e1c28ea..c8774855297 100644 --- a/idea/src/org/jetbrains/kotlin/idea/actions/internal/FindImplicitNothingAction.kt +++ b/idea/src/org/jetbrains/kotlin/idea/actions/internal/FindImplicitNothingAction.kt @@ -33,7 +33,7 @@ import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.CallableDescriptor -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.resolve.calls.callUtil.getCalleeExpressionIfAny import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils import com.intellij.usages.UsageViewManager @@ -125,7 +125,7 @@ public class FindImplicitNothingAction : AnAction() { } } - private fun KtType.isNothingOrNothingFunctionType(): Boolean { + private fun KotlinType.isNothingOrNothingFunctionType(): Boolean { return when { KotlinBuiltIns.isNothing(this) -> true diff --git a/idea/src/org/jetbrains/kotlin/idea/codeInsight/CodeInsightUtils.java b/idea/src/org/jetbrains/kotlin/idea/codeInsight/CodeInsightUtils.java index 50e08f0fede..8458b5fb3cd 100644 --- a/idea/src/org/jetbrains/kotlin/idea/codeInsight/CodeInsightUtils.java +++ b/idea/src/org/jetbrains/kotlin/idea/codeInsight/CodeInsightUtils.java @@ -35,7 +35,7 @@ import org.jetbrains.kotlin.lexer.KtTokens; import org.jetbrains.kotlin.psi.*; import org.jetbrains.kotlin.resolve.BindingContext; import org.jetbrains.kotlin.resolve.scopes.receivers.Qualifier; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import java.util.ArrayList; import java.util.Collections; @@ -223,7 +223,7 @@ public class CodeInsightUtils { } @Nullable - public static String defaultInitializer(KtType type) { + public static String defaultInitializer(KotlinType type) { if (type.isMarkedNullable()) { return "null"; } diff --git a/idea/src/org/jetbrains/kotlin/idea/codeInsight/GotoSuperActionHandler.java b/idea/src/org/jetbrains/kotlin/idea/codeInsight/GotoSuperActionHandler.java index 0580a98fd90..b2e9a3cafed 100644 --- a/idea/src/org/jetbrains/kotlin/idea/codeInsight/GotoSuperActionHandler.java +++ b/idea/src/org/jetbrains/kotlin/idea/codeInsight/GotoSuperActionHandler.java @@ -39,7 +39,7 @@ import org.jetbrains.kotlin.idea.caches.resolve.ResolutionUtils; import org.jetbrains.kotlin.psi.*; import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils; import org.jetbrains.kotlin.resolve.OverrideResolver; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import java.util.Collection; import java.util.List; @@ -103,10 +103,10 @@ public class GotoSuperActionHandler implements CodeInsightActionHandler { private static List findSuperDeclarations(DeclarationDescriptor descriptor) { Collection superDescriptors; if (descriptor instanceof ClassDescriptor) { - Collection supertypes = ((ClassDescriptor) descriptor).getTypeConstructor().getSupertypes(); - List superclasses = ContainerUtil.mapNotNull(supertypes, new Function() { + Collection supertypes = ((ClassDescriptor) descriptor).getTypeConstructor().getSupertypes(); + List superclasses = ContainerUtil.mapNotNull(supertypes, new Function() { @Override - public ClassDescriptor fun(KtType type) { + public ClassDescriptor fun(KotlinType type) { ClassifierDescriptor descriptor = type.getConstructor().getDeclarationDescriptor(); if (descriptor instanceof ClassDescriptor) { return (ClassDescriptor) descriptor; diff --git a/idea/src/org/jetbrains/kotlin/idea/codeInsight/JetTypeDeclarationProvider.java b/idea/src/org/jetbrains/kotlin/idea/codeInsight/JetTypeDeclarationProvider.java index 4a6afa937fe..7af99fe7574 100644 --- a/idea/src/org/jetbrains/kotlin/idea/codeInsight/JetTypeDeclarationProvider.java +++ b/idea/src/org/jetbrains/kotlin/idea/codeInsight/JetTypeDeclarationProvider.java @@ -26,7 +26,7 @@ import org.jetbrains.kotlin.psi.KtElement; import org.jetbrains.kotlin.psi.KtFile; import org.jetbrains.kotlin.resolve.BindingContext; import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; public class JetTypeDeclarationProvider implements TypeDeclarationProvider { @Override @@ -35,7 +35,7 @@ public class JetTypeDeclarationProvider implements TypeDeclarationProvider { BindingContext bindingContext = ResolutionUtils.analyze((KtElement)symbol); DeclarationDescriptor descriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, symbol); if (descriptor instanceof CallableDescriptor) { - KtType type = ((CallableDescriptor) descriptor).getReturnType(); + KotlinType type = ((CallableDescriptor) descriptor).getReturnType(); if (type != null) { ClassifierDescriptor classifierDescriptor = type.getConstructor().getDeclarationDescriptor(); if (classifierDescriptor != null) { diff --git a/idea/src/org/jetbrains/kotlin/idea/codeInsight/surroundWith/MoveDeclarationsOutHelper.java b/idea/src/org/jetbrains/kotlin/idea/codeInsight/surroundWith/MoveDeclarationsOutHelper.java index 7dc0c943dc5..802b25819aa 100644 --- a/idea/src/org/jetbrains/kotlin/idea/codeInsight/surroundWith/MoveDeclarationsOutHelper.java +++ b/idea/src/org/jetbrains/kotlin/idea/codeInsight/surroundWith/MoveDeclarationsOutHelper.java @@ -33,7 +33,7 @@ import org.jetbrains.kotlin.idea.util.ShortenReferences; import org.jetbrains.kotlin.psi.*; import org.jetbrains.kotlin.resolve.BindingContext; import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import java.util.ArrayList; import java.util.List; @@ -106,7 +106,7 @@ public class MoveDeclarationsOutHelper { @NotNull private static KtProperty createVariableDeclaration(@NotNull KtProperty property, boolean generateDefaultInitializers) { - KtType propertyType = getPropertyType(property); + KotlinType propertyType = getPropertyType(property); String defaultInitializer = null; if (generateDefaultInitializers && property.isVar()) { defaultInitializer = CodeInsightUtils.defaultInitializer(propertyType); @@ -115,7 +115,7 @@ public class MoveDeclarationsOutHelper { } @NotNull - private static KtType getPropertyType(@NotNull KtProperty property) { + private static KotlinType getPropertyType(@NotNull KtProperty property) { BindingContext bindingContext = ResolutionUtils.analyze(property, BodyResolveMode.PARTIAL); VariableDescriptor propertyDescriptor = bindingContext.get(BindingContext.VARIABLE, property); @@ -124,7 +124,7 @@ public class MoveDeclarationsOutHelper { } @NotNull - private static KtProperty createProperty(@NotNull KtProperty property, @NotNull KtType propertyType, @Nullable String initializer) { + private static KtProperty createProperty(@NotNull KtProperty property, @NotNull KotlinType propertyType, @Nullable String initializer) { KtTypeReference typeRef = property.getTypeReference(); String typeString = null; if (typeRef != null) { diff --git a/idea/src/org/jetbrains/kotlin/idea/codeInsight/surroundWith/expression/KotlinExpressionSurrounder.java b/idea/src/org/jetbrains/kotlin/idea/codeInsight/surroundWith/expression/KotlinExpressionSurrounder.java index c4aa60af131..dd0eb5dd9ba 100644 --- a/idea/src/org/jetbrains/kotlin/idea/codeInsight/surroundWith/expression/KotlinExpressionSurrounder.java +++ b/idea/src/org/jetbrains/kotlin/idea/codeInsight/surroundWith/expression/KotlinExpressionSurrounder.java @@ -28,7 +28,7 @@ import org.jetbrains.kotlin.psi.KtCallExpression; import org.jetbrains.kotlin.psi.KtExpression; import org.jetbrains.kotlin.psi.KtQualifiedExpression; import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import static org.jetbrains.kotlin.builtins.KotlinBuiltIns.isUnit; @@ -44,7 +44,7 @@ public abstract class KotlinExpressionSurrounder implements Surrounder { if (expression instanceof KtCallExpression && expression.getParent() instanceof KtQualifiedExpression) { return false; } - KtType type = ResolutionUtils.analyze(expression, BodyResolveMode.PARTIAL).getType(expression); + KotlinType type = ResolutionUtils.analyze(expression, BodyResolveMode.PARTIAL).getType(expression); if (type == null || isUnit(type)) { return false; } diff --git a/idea/src/org/jetbrains/kotlin/idea/codeInsight/surroundWith/expression/KotlinNotSurrounder.java b/idea/src/org/jetbrains/kotlin/idea/codeInsight/surroundWith/expression/KotlinNotSurrounder.java index 3dbd3eaf184..f919e396684 100644 --- a/idea/src/org/jetbrains/kotlin/idea/codeInsight/surroundWith/expression/KotlinNotSurrounder.java +++ b/idea/src/org/jetbrains/kotlin/idea/codeInsight/surroundWith/expression/KotlinNotSurrounder.java @@ -30,7 +30,7 @@ import org.jetbrains.kotlin.psi.KtParenthesizedExpression; import org.jetbrains.kotlin.psi.KtPrefixExpression; import org.jetbrains.kotlin.psi.KtPsiFactoryKt; import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; public class KotlinNotSurrounder extends KotlinExpressionSurrounder { @Override @@ -40,7 +40,7 @@ public class KotlinNotSurrounder extends KotlinExpressionSurrounder { @Override public boolean isApplicable(@NotNull KtExpression expression) { - KtType type = ResolutionUtils.analyze(expression, BodyResolveMode.PARTIAL).getType(expression); + KotlinType type = ResolutionUtils.analyze(expression, BodyResolveMode.PARTIAL).getType(expression); return type != null && KotlinBuiltIns.isBoolean(type); } diff --git a/idea/src/org/jetbrains/kotlin/idea/codeInsight/surroundWith/expression/KotlinRuntimeTypeCastSurrounder.kt b/idea/src/org/jetbrains/kotlin/idea/codeInsight/surroundWith/expression/KotlinRuntimeTypeCastSurrounder.kt index d3801e49ff8..c3b8d10675a 100644 --- a/idea/src/org/jetbrains/kotlin/idea/codeInsight/surroundWith/expression/KotlinRuntimeTypeCastSurrounder.kt +++ b/idea/src/org/jetbrains/kotlin/idea/codeInsight/surroundWith/expression/KotlinRuntimeTypeCastSurrounder.kt @@ -36,7 +36,7 @@ import org.jetbrains.kotlin.idea.util.ShortenReferences import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeUtils import org.jetbrains.kotlin.types.checker.KotlinTypeChecker @@ -75,7 +75,7 @@ public class KotlinRuntimeTypeCastSurrounder: KotlinExpressionSurrounder() { indicator: ProgressIndicator ): KotlinRuntimeTypeEvaluator(myEditor, expression, context, indicator) { - override fun typeCalculationFinished(type: KtType?) { + override fun typeCalculationFinished(type: KotlinType?) { if (type == null) return hold() diff --git a/idea/src/org/jetbrains/kotlin/idea/codeInsight/surroundWith/expression/KotlinWhenSurrounder.java b/idea/src/org/jetbrains/kotlin/idea/codeInsight/surroundWith/expression/KotlinWhenSurrounder.java index ccc3ecdd774..2f0ab4c6466 100644 --- a/idea/src/org/jetbrains/kotlin/idea/codeInsight/surroundWith/expression/KotlinWhenSurrounder.java +++ b/idea/src/org/jetbrains/kotlin/idea/codeInsight/surroundWith/expression/KotlinWhenSurrounder.java @@ -29,7 +29,7 @@ import org.jetbrains.kotlin.idea.JetBundle; import org.jetbrains.kotlin.idea.caches.resolve.ResolutionUtils; import org.jetbrains.kotlin.psi.*; import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; public class KotlinWhenSurrounder extends KotlinExpressionSurrounder { @Override @@ -65,7 +65,7 @@ public class KotlinWhenSurrounder extends KotlinExpressionSurrounder { } private String getCodeTemplate(KtExpression expression) { - KtType type = ResolutionUtils.analyze(expression, BodyResolveMode.PARTIAL).getType(expression); + KotlinType type = ResolutionUtils.analyze(expression, BodyResolveMode.PARTIAL).getType(expression); if (type != null) { ClassifierDescriptor descriptor = type.getConstructor().getDeclarationDescriptor(); if (descriptor instanceof ClassDescriptor && ((ClassDescriptor) descriptor).getKind() == ClassKind.ENUM_CLASS) { diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinCodeFragmentFactory.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinCodeFragmentFactory.kt index 58365870c9a..8441f33e6d6 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinCodeFragmentFactory.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinCodeFragmentFactory.kt @@ -61,7 +61,7 @@ import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.inline.InlineUtil import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.typeUtil.makeNullable import org.jetbrains.kotlin.utils.addToStdlib.check import java.util.* @@ -106,9 +106,9 @@ class KotlinCodeFragmentFactory: CodeFragmentFactory() { else { val semaphore = Semaphore() semaphore.down() - val nameRef = AtomicReference() + val nameRef = AtomicReference() val worker = object : KotlinRuntimeTypeEvaluator(null, expression, debuggerContext, ProgressManager.getInstance().progressIndicator) { - override fun typeCalculationFinished(type: KtType?) { + override fun typeCalculationFinished(type: KotlinType?) { nameRef.set(type) semaphore.up() } diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluateExpressionCache.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluateExpressionCache.kt index cdc6de316ee..b8be4a18b5d 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluateExpressionCache.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluateExpressionCache.kt @@ -26,7 +26,7 @@ import com.intellij.debugger.engine.evaluation.EvaluationContextImpl import java.util.ArrayList import com.intellij.openapi.components.ServiceManager import com.intellij.util.containers.MultiMap -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.apache.log4j.Logger @@ -96,12 +96,12 @@ class KotlinEvaluateExpressionCache(val project: Project) { class ParametersDescriptor : Iterable { private val list = ArrayList() - fun add(name: String, jetType: KtType, value: Value? = null) { + fun add(name: String, jetType: KotlinType, value: Value? = null) { list.add(Parameter(name, jetType, value)) } override fun iterator() = list.iterator() } - data class Parameter(val callText: String, val type: KtType, val value: Value? = null) + data class Parameter(val callText: String, val type: KotlinType, val value: Value? = null) } diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinRuntimeTypeEvaluator.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinRuntimeTypeEvaluator.kt index a11aaa688f7..259afec3957 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinRuntimeTypeEvaluator.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinRuntimeTypeEvaluator.kt @@ -36,7 +36,7 @@ import com.sun.jdi.Value import org.jetbrains.eval4j.jdi.asValue import org.jetbrains.kotlin.psi.KtExpression import org.jetbrains.kotlin.psi.KtPsiFactory -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.org.objectweb.asm.Type as AsmType public abstract class KotlinRuntimeTypeEvaluator( @@ -44,10 +44,10 @@ public abstract class KotlinRuntimeTypeEvaluator( expression: KtExpression, context: DebuggerContextImpl, indicator: ProgressIndicator -) : EditorEvaluationCommand(editor, expression, context, indicator) { +) : EditorEvaluationCommand(editor, expression, context, indicator) { override fun threadAction() { - var type: KtType? = null + var type: KotlinType? = null try { type = evaluate() } @@ -60,9 +60,9 @@ public abstract class KotlinRuntimeTypeEvaluator( } } - protected abstract fun typeCalculationFinished(type: KtType?) + protected abstract fun typeCalculationFinished(type: KotlinType?) - override fun evaluate(evaluationContext: EvaluationContextImpl): KtType? { + override fun evaluate(evaluationContext: EvaluationContextImpl): KotlinType? { val project = evaluationContext.getProject() val evaluator = DebuggerInvocationUtil.commitAndRunReadAction(project, EvaluatingComputable { @@ -80,7 +80,7 @@ public abstract class KotlinRuntimeTypeEvaluator( } companion object { - private fun getCastableRuntimeType(project: Project, value: Value): KtType? { + private fun getCastableRuntimeType(project: Project, value: Value): KotlinType? { val myValue = value.asValue() var psiClass = myValue.asmType.getClassDescriptor(project) if (psiClass != null) { diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinLambdaSmartStepIntoTarget.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinLambdaSmartStepIntoTarget.kt index c8f22015c67..9ac0210d57c 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinLambdaSmartStepIntoTarget.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinLambdaSmartStepIntoTarget.kt @@ -22,7 +22,7 @@ import com.intellij.psi.PsiElement import com.intellij.psi.PsiMethod import com.intellij.util.Range import org.jetbrains.kotlin.descriptors.DeclarationDescriptor -import org.jetbrains.kotlin.idea.KtIcons +import org.jetbrains.kotlin.idea.KotlinIcons import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.psi.KtElement import org.jetbrains.kotlin.psi.KtFunctionLiteralExpression @@ -34,7 +34,7 @@ public class KotlinLambdaSmartStepTarget( highlightElement: KtFunctionLiteralExpression, lines: Range ): SmartStepTarget(label, highlightElement, true, lines) { - override fun getIcon() = KtIcons.LAMBDA + override fun getIcon() = KotlinIcons.LAMBDA fun getLambda() = getHighlightElement() as KtFunctionLiteralExpression diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinMethodSmartStepIntoTarget.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinMethodSmartStepIntoTarget.kt index 686c24af85a..c89be0b0ac8 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinMethodSmartStepIntoTarget.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinMethodSmartStepIntoTarget.kt @@ -4,7 +4,7 @@ import com.intellij.debugger.actions.SmartStepTarget import com.intellij.psi.PsiElement import com.intellij.util.Range import org.jetbrains.kotlin.descriptors.DeclarationDescriptor -import org.jetbrains.kotlin.idea.KtIcons +import org.jetbrains.kotlin.idea.KotlinIcons import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers import org.jetbrains.kotlin.psi.KtElement import org.jetbrains.kotlin.psi.KtNamedFunction @@ -19,8 +19,8 @@ public class KotlinMethodSmartStepTarget( ): SmartStepTarget(label, highlightElement, false, lines) { override fun getIcon(): Icon? { return when { - resolvedElement is KtNamedFunction && resolvedElement.getReceiverTypeReference() != null -> KtIcons.EXTENSION_FUNCTION - else -> KtIcons.FUNCTION + resolvedElement is KtNamedFunction && resolvedElement.getReceiverTypeReference() != null -> KotlinIcons.EXTENSION_FUNCTION + else -> KotlinIcons.FUNCTION } } diff --git a/idea/src/org/jetbrains/kotlin/idea/framework/JSFrameworkType.java b/idea/src/org/jetbrains/kotlin/idea/framework/JSFrameworkType.java index 5a6430e9f71..ea1ef8a97d7 100644 --- a/idea/src/org/jetbrains/kotlin/idea/framework/JSFrameworkType.java +++ b/idea/src/org/jetbrains/kotlin/idea/framework/JSFrameworkType.java @@ -19,7 +19,7 @@ package org.jetbrains.kotlin.idea.framework; import com.intellij.framework.FrameworkTypeEx; import com.intellij.framework.addSupport.FrameworkSupportInModuleProvider; import org.jetbrains.annotations.NotNull; -import org.jetbrains.kotlin.idea.KtIcons; +import org.jetbrains.kotlin.idea.KotlinIcons; import javax.swing.*; @@ -47,6 +47,6 @@ public class JSFrameworkType extends FrameworkTypeEx { @NotNull @Override public Icon getIcon() { - return KtIcons.SMALL_LOGO_13; + return KotlinIcons.SMALL_LOGO_13; } } diff --git a/idea/src/org/jetbrains/kotlin/idea/framework/JSLibraryStdPresentationProvider.java b/idea/src/org/jetbrains/kotlin/idea/framework/JSLibraryStdPresentationProvider.java index c9dd74580b3..b541bd2cbe6 100644 --- a/idea/src/org/jetbrains/kotlin/idea/framework/JSLibraryStdPresentationProvider.java +++ b/idea/src/org/jetbrains/kotlin/idea/framework/JSLibraryStdPresentationProvider.java @@ -23,7 +23,7 @@ import com.intellij.openapi.roots.libraries.LibraryPresentationProvider; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.jetbrains.kotlin.idea.KtIcons; +import org.jetbrains.kotlin.idea.KotlinIcons; import org.jetbrains.kotlin.utils.LibraryUtils; import org.jetbrains.kotlin.utils.PathUtil; @@ -43,7 +43,7 @@ public class JSLibraryStdPresentationProvider extends LibraryPresentationProvide @Nullable @Override public Icon getIcon() { - return KtIcons.SMALL_LOGO_13; + return KotlinIcons.SMALL_LOGO_13; } @Nullable diff --git a/idea/src/org/jetbrains/kotlin/idea/framework/JavaFrameworkType.java b/idea/src/org/jetbrains/kotlin/idea/framework/JavaFrameworkType.java index 005e95da5de..4bd88863cf2 100644 --- a/idea/src/org/jetbrains/kotlin/idea/framework/JavaFrameworkType.java +++ b/idea/src/org/jetbrains/kotlin/idea/framework/JavaFrameworkType.java @@ -19,7 +19,7 @@ package org.jetbrains.kotlin.idea.framework; import com.intellij.framework.FrameworkTypeEx; import com.intellij.framework.addSupport.FrameworkSupportInModuleProvider; import org.jetbrains.annotations.NotNull; -import org.jetbrains.kotlin.idea.KtIcons; +import org.jetbrains.kotlin.idea.KotlinIcons; import javax.swing.*; @@ -47,6 +47,6 @@ public class JavaFrameworkType extends FrameworkTypeEx { @NotNull @Override public Icon getIcon() { - return KtIcons.SMALL_LOGO_13; + return KotlinIcons.SMALL_LOGO_13; } } diff --git a/idea/src/org/jetbrains/kotlin/idea/framework/JavaRuntimePresentationProvider.java b/idea/src/org/jetbrains/kotlin/idea/framework/JavaRuntimePresentationProvider.java index df650451a2a..ab0dc0531b0 100644 --- a/idea/src/org/jetbrains/kotlin/idea/framework/JavaRuntimePresentationProvider.java +++ b/idea/src/org/jetbrains/kotlin/idea/framework/JavaRuntimePresentationProvider.java @@ -23,7 +23,7 @@ import com.intellij.openapi.roots.libraries.LibraryPresentationProvider; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.jetbrains.kotlin.idea.KtIcons; +import org.jetbrains.kotlin.idea.KotlinIcons; import org.jetbrains.kotlin.utils.LibraryUtils; import org.jetbrains.kotlin.utils.PathUtil; @@ -43,7 +43,7 @@ public class JavaRuntimePresentationProvider extends LibraryPresentationProvider @Nullable @Override public Icon getIcon() { - return KtIcons.SMALL_LOGO_13; + return KotlinIcons.SMALL_LOGO_13; } @Nullable diff --git a/idea/src/org/jetbrains/kotlin/idea/framework/KotlinModuleBuilder.kt b/idea/src/org/jetbrains/kotlin/idea/framework/KotlinModuleBuilder.kt index 01762714fa1..1e315cba396 100644 --- a/idea/src/org/jetbrains/kotlin/idea/framework/KotlinModuleBuilder.kt +++ b/idea/src/org/jetbrains/kotlin/idea/framework/KotlinModuleBuilder.kt @@ -21,7 +21,7 @@ import com.intellij.ide.util.projectWizard.ModuleWizardStep import com.intellij.ide.util.projectWizard.SettingsStep import com.intellij.ide.util.projectWizard.WizardContext import com.intellij.openapi.roots.ui.configuration.ModulesProvider -import org.jetbrains.kotlin.idea.KtIcons +import org.jetbrains.kotlin.idea.KotlinIcons import org.jetbrains.kotlin.resolve.TargetPlatform public class KotlinModuleBuilder( @@ -30,8 +30,8 @@ public class KotlinModuleBuilder( override fun getName() = builderName override fun getPresentableName() = builderName override fun getDescription() = builderDescription - override fun getBigIcon() = KtIcons.KOTLIN_LOGO_24 - override fun getNodeIcon() = KtIcons.SMALL_LOGO + override fun getBigIcon() = KotlinIcons.KOTLIN_LOGO_24 + override fun getNodeIcon() = KotlinIcons.SMALL_LOGO override fun getGroupName() = KotlinTemplatesFactory.KOTLIN_GROUP_NAME override fun createWizardSteps(wizardContext: WizardContext, modulesProvider: ModulesProvider) = ModuleWizardStep.EMPTY_ARRAY diff --git a/idea/src/org/jetbrains/kotlin/idea/framework/KotlinTemplatesFactory.kt b/idea/src/org/jetbrains/kotlin/idea/framework/KotlinTemplatesFactory.kt index af4bb82fa7e..0d84e349786 100644 --- a/idea/src/org/jetbrains/kotlin/idea/framework/KotlinTemplatesFactory.kt +++ b/idea/src/org/jetbrains/kotlin/idea/framework/KotlinTemplatesFactory.kt @@ -19,7 +19,7 @@ package org.jetbrains.kotlin.idea.framework import com.intellij.ide.util.projectWizard.WizardContext import com.intellij.platform.ProjectTemplatesFactory import com.intellij.platform.templates.BuilderBasedTemplate -import org.jetbrains.kotlin.idea.KtIcons +import org.jetbrains.kotlin.idea.KotlinIcons import org.jetbrains.kotlin.js.resolve.JsPlatform import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform @@ -29,7 +29,7 @@ public class KotlinTemplatesFactory : ProjectTemplatesFactory() { } override fun getGroups() = arrayOf(KOTLIN_GROUP_NAME) - override fun getGroupIcon(group: String) = KtIcons.SMALL_LOGO + override fun getGroupIcon(group: String) = KotlinIcons.SMALL_LOGO override fun createTemplates(group: String?, context: WizardContext?) = arrayOf( diff --git a/idea/src/org/jetbrains/kotlin/idea/hierarchy/KotlinTypeHierarchyProvider.java b/idea/src/org/jetbrains/kotlin/idea/hierarchy/KotlinTypeHierarchyProvider.java index 675a05af545..01b9c36a403 100644 --- a/idea/src/org/jetbrains/kotlin/idea/hierarchy/KotlinTypeHierarchyProvider.java +++ b/idea/src/org/jetbrains/kotlin/idea/hierarchy/KotlinTypeHierarchyProvider.java @@ -39,7 +39,7 @@ import org.jetbrains.kotlin.psi.KtClassOrObject; import org.jetbrains.kotlin.psi.KtNamedFunction; import org.jetbrains.kotlin.renderer.DescriptorRenderer; import org.jetbrains.kotlin.resolve.BindingContext; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import java.util.Collection; @@ -72,7 +72,7 @@ public class KotlinTypeHierarchyProvider extends JavaTypeHierarchyProvider { FunctionDescriptor functionDescriptor = ResolutionUtils.analyze(function) .get(BindingContext.FUNCTION, target); if (functionDescriptor != null) { - KtType type = functionDescriptor.getReturnType(); + KotlinType type = functionDescriptor.getReturnType(); if (type != null) { String returnTypeText = DescriptorRenderer.FQ_NAMES_IN_TYPES.renderType(type); if (returnTypeText.equals(functionName)) { diff --git a/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinColorSettingsPage.kt b/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinColorSettingsPage.kt index 70b4de5b192..f608da1d56c 100644 --- a/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinColorSettingsPage.kt +++ b/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinColorSettingsPage.kt @@ -23,7 +23,7 @@ import com.intellij.openapi.options.colors.AttributesDescriptor import com.intellij.openapi.options.colors.ColorDescriptor import com.intellij.openapi.options.colors.ColorSettingsPage import org.jetbrains.kotlin.idea.JetBundle -import org.jetbrains.kotlin.idea.KtIcons +import org.jetbrains.kotlin.idea.KotlinIcons import org.jetbrains.kotlin.idea.KotlinLanguage import javax.swing.* @@ -32,7 +32,7 @@ import java.lang.reflect.Modifier import java.util.HashMap public class KotlinColorSettingsPage : ColorSettingsPage { - override fun getIcon() = KtIcons.SMALL_LOGO + override fun getIcon() = KotlinIcons.SMALL_LOGO override fun getHighlighter(): SyntaxHighlighter = JetHighlighter() override fun getDemoText(): String { diff --git a/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinRunLineMarkerContributor.kt b/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinRunLineMarkerContributor.kt index e4345a3a7ae..0f210027f4e 100644 --- a/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinRunLineMarkerContributor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinRunLineMarkerContributor.kt @@ -20,7 +20,7 @@ import com.intellij.execution.lineMarker.ExecutorAction import com.intellij.execution.lineMarker.RunLineMarkerContributor import com.intellij.psi.PsiElement import org.jetbrains.kotlin.descriptors.FunctionDescriptor -import org.jetbrains.kotlin.idea.KtIcons +import org.jetbrains.kotlin.idea.KotlinIcons import org.jetbrains.kotlin.idea.MainFunctionDetector import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptor import org.jetbrains.kotlin.psi.KtNamedFunction @@ -38,7 +38,7 @@ public class KotlinRunLineMarkerContributor : RunLineMarkerContributor() { } if (detector.isMain(function)) { - return RunLineMarkerContributor.Info(KtIcons.LAUNCH, null, ExecutorAction.getActions(0)) + return RunLineMarkerContributor.Info(KotlinIcons.LAUNCH, null, ExecutorAction.getActions(0)) } return null diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertToBlockBodyIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertToBlockBodyIntention.kt index cdc0805a74a..7893787ce50 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertToBlockBodyIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertToBlockBodyIntention.kt @@ -24,7 +24,7 @@ import org.jetbrains.kotlin.descriptors.FunctionDescriptor import org.jetbrains.kotlin.idea.caches.resolve.analyze import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.resolve.BindingContext -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType public class ConvertToBlockBodyIntention : JetSelfTargetingIntention( javaClass(), "Convert to block body" @@ -84,7 +84,7 @@ public class ConvertToBlockBodyIntention : JetSelfTargetingIntention(javaClass(), "Iterate over collection"), HighPriorityAction { override fun isApplicableTo(element: KtExpression, caretOffset: Int): Boolean { @@ -44,7 +44,7 @@ public class IterateExpressionIntention : JetSelfTargetingIntention(javaClass(), "Replace by reconstructed type"), LowPriorityAction { override fun isApplicableTo(element: KtTypeReference): Boolean { @@ -57,7 +57,7 @@ public class ReconstructTypeInCastOrIsIntention : JetSelfTargetingOffsetIndepend ShortenReferences.DEFAULT.process(element.replaced(newType)) } - private fun getReconstructedType(typeRef: KtTypeReference): KtType? { + private fun getReconstructedType(typeRef: KtTypeReference): KotlinType? { return typeRef.analyze().get(BindingContext.TYPE, typeRef) } } diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveExplicitTypeArgumentsIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveExplicitTypeArgumentsIntention.kt index d6f789d8abd..0876e6177c1 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveExplicitTypeArgumentsIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveExplicitTypeArgumentsIntention.kt @@ -29,7 +29,7 @@ import org.jetbrains.kotlin.resolve.calls.CallResolver import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall import org.jetbrains.kotlin.resolve.calls.util.DelegatingCall import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeUtils import org.jetbrains.kotlin.types.checker.KotlinTypeChecker @@ -79,7 +79,7 @@ public class RemoveExplicitTypeArgumentsIntention : JetSelfTargetingOffsetIndepe val args = originalCall.getTypeArguments() val newArgs = resolutionResults.getResultingCall().getTypeArguments() - fun equalTypes(type1: KtType, type2: KtType): Boolean { + fun equalTypes(type1: KotlinType, type2: KotlinType): Boolean { return if (approximateFlexible) { KotlinTypeChecker.DEFAULT.equalTypes(type1, type2) } diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/SpecifyTypeExplicitlyIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/SpecifyTypeExplicitlyIntention.kt index 03cf2652fac..4e3c0943d69 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/SpecifyTypeExplicitlyIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/SpecifyTypeExplicitlyIntention.kt @@ -30,7 +30,7 @@ import org.jetbrains.kotlin.psi.psiUtil.getElementTextWithContext import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.types.ErrorUtils -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeUtils import java.util.* @@ -59,27 +59,27 @@ public class SpecifyTypeExplicitlyIntention : JetSelfTargetingIntention() else arrayListOf(exprType) + val types = if (isAnonymous) ArrayList() else arrayListOf(exprType) types.addAll(allSupertypes) - return object : ChooseValueExpression(types, types.first()) { - override fun getLookupString(element: KtType) = IdeDescriptorRenderers.SOURCE_CODE_SHORT_NAMES_IN_TYPES.renderType(element) - override fun getResult(element: KtType) = IdeDescriptorRenderers.SOURCE_CODE.renderType(element) + return object : ChooseValueExpression(types, types.first()) { + override fun getLookupString(element: KotlinType) = IdeDescriptorRenderers.SOURCE_CODE_SHORT_NAMES_IN_TYPES.renderType(element) + override fun getResult(element: KotlinType) = IdeDescriptorRenderers.SOURCE_CODE.renderType(element) } } - public fun addTypeAnnotation(editor: Editor?, declaration: KtCallableDeclaration, exprType: KtType) { + public fun addTypeAnnotation(editor: Editor?, declaration: KtCallableDeclaration, exprType: KotlinType) { if (editor != null) { addTypeAnnotationWithTemplate(editor, declaration, exprType) } @@ -99,7 +99,7 @@ public class SpecifyTypeExplicitlyIntention : JetSelfTargetingIntention() + private val typesToShorten = ArrayList() override fun getText(): String { val parameters = functionDescriptor.valueParameters diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/AddFunctionToSupertypeFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/AddFunctionToSupertypeFix.kt index f56916d140b..5cc442c687c 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/AddFunctionToSupertypeFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/AddFunctionToSupertypeFix.kt @@ -38,7 +38,7 @@ import org.jetbrains.kotlin.psi.KtClass import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.psi.KtNamedFunction import org.jetbrains.kotlin.psi.KtPsiFactory -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.checker.KotlinTypeChecker import org.jetbrains.kotlin.types.typeUtil.supertypes import java.util.* @@ -158,8 +158,8 @@ class AddFunctionToSupertypeFix private constructor( } private fun getSuperClasses(classDescriptor: ClassDescriptor): List { - val supertypes = classDescriptor.defaultType.supertypes().sortedWith(object : Comparator { - override fun compare(o1: KtType, o2: KtType): Int { + val supertypes = classDescriptor.defaultType.supertypes().sortedWith(object : Comparator { + override fun compare(o1: KotlinType, o2: KotlinType): Int { return when { o1 == o2 -> 0 KotlinTypeChecker.DEFAULT.isSubtypeOf(o1, o2) -> -1 diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/AddGenericUpperBoundFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/AddGenericUpperBoundFix.kt index 4fe14b5059b..5143fce27e4 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/AddGenericUpperBoundFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/AddGenericUpperBoundFix.kt @@ -33,13 +33,13 @@ import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemImpl import org.jetbrains.kotlin.resolve.calls.inference.ConstraintsUtil import org.jetbrains.kotlin.resolve.calls.inference.InferenceErrorData import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.Variance import org.jetbrains.kotlin.utils.singletonOrEmptyList public class AddGenericUpperBoundFix( typeParameter: KtTypeParameter, - upperBound: KtType + upperBound: KotlinType ) : KotlinQuickFixAction(typeParameter) { private val renderedUpperBound: String = IdeDescriptorRenderers.SOURCE_CODE.renderType(upperBound) @@ -100,7 +100,7 @@ public class AddGenericUpperBoundFix( }.filterNotNull() } - private fun createAction(argument: KtType, upperBound: KtType): IntentionAction? { + private fun createAction(argument: KotlinType, upperBound: KotlinType): IntentionAction? { if (!upperBound.constructor.isDenotable) return null val typeParameterDescriptor = (argument.constructor.declarationDescriptor as? TypeParameterDescriptor) ?: return null diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/AddNameToArgumentFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/AddNameToArgumentFix.kt index 991e6f69e75..05542d471aa 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/AddNameToArgumentFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/AddNameToArgumentFix.kt @@ -25,7 +25,7 @@ import com.intellij.openapi.ui.popup.PopupStep import com.intellij.openapi.ui.popup.util.BaseListPopupStep import com.intellij.psi.PsiFile import org.jetbrains.kotlin.diagnostics.Diagnostic -import org.jetbrains.kotlin.idea.KtIcons +import org.jetbrains.kotlin.idea.KotlinIcons import org.jetbrains.kotlin.idea.caches.resolve.analyze import org.jetbrains.kotlin.idea.util.application.executeWriteCommand import org.jetbrains.kotlin.name.Name @@ -109,7 +109,7 @@ public class AddNameToArgumentFix(argument: KtValueArgument) : KotlinQuickFixAct return PopupStep.FINAL_CHOICE } - override fun getIconFor(name: Name) = KtIcons.PARAMETER + override fun getIconFor(name: Name) = KotlinIcons.PARAMETER override fun getTextFor(name: Name) = createArgumentWithName(name).text } diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/CastExpressionFix.java b/idea/src/org/jetbrains/kotlin/idea/quickfix/CastExpressionFix.java index 8012a4a1e05..d89ed21d66c 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/CastExpressionFix.java +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/CastExpressionFix.java @@ -33,13 +33,13 @@ import org.jetbrains.kotlin.idea.util.ShortenReferences; import org.jetbrains.kotlin.psi.*; import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm; import org.jetbrains.kotlin.types.FlexibleTypesKt; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.checker.KotlinTypeChecker; public class CastExpressionFix extends KotlinQuickFixAction { - private final KtType type; + private final KotlinType type; - public CastExpressionFix(@NotNull KtExpression element, @NotNull KtType type) { + public CastExpressionFix(@NotNull KtExpression element, @NotNull KotlinType type) { super(element); this.type = type; } @@ -63,7 +63,7 @@ public class CastExpressionFix extends KotlinQuickFixAction { @Override public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) { if (!super.isAvailable(project, editor, file)) return false; - KtType expressionType = ResolutionUtils.analyze(getElement()).getType(getElement()); + KotlinType expressionType = ResolutionUtils.analyze(getElement()).getType(getElement()); return expressionType != null && ( KotlinTypeChecker.DEFAULT.isSubtypeOf(type, expressionType) // downcast @@ -104,7 +104,7 @@ public class CastExpressionFix extends KotlinQuickFixAction { @Nullable @Override public IntentionAction createAction(@NotNull Diagnostic diagnostic) { - DiagnosticWithParameters2 diagnosticWithParameters = + DiagnosticWithParameters2 diagnosticWithParameters = Errors.SMARTCAST_IMPOSSIBLE.cast(diagnostic); return new CastExpressionFix(diagnosticWithParameters.getPsiElement(), diagnosticWithParameters.getA()); } @@ -117,7 +117,7 @@ public class CastExpressionFix extends KotlinQuickFixAction { @Nullable @Override public IntentionAction createAction(@NotNull Diagnostic diagnostic) { - DiagnosticWithParameters2 diagnosticWithParameters = + DiagnosticWithParameters2 diagnosticWithParameters = ErrorsJvm.JAVA_TYPE_MISMATCH.cast(diagnostic); return new CastExpressionFix( diagnosticWithParameters.getPsiElement(), FlexibleTypesKt.flexibility(diagnosticWithParameters.getB()).getUpperBound() diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/ChangeAccessorTypeFix.java b/idea/src/org/jetbrains/kotlin/idea/quickfix/ChangeAccessorTypeFix.java index 52537fd8c48..bcae45da277 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/ChangeAccessorTypeFix.java +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/ChangeAccessorTypeFix.java @@ -28,10 +28,10 @@ import org.jetbrains.kotlin.idea.core.quickfix.QuickFixUtil; import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers; import org.jetbrains.kotlin.idea.util.ShortenReferences; import org.jetbrains.kotlin.psi.*; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; public class ChangeAccessorTypeFix extends KotlinQuickFixAction { - private KtType type; + private KotlinType type; public ChangeAccessorTypeFix(@NotNull KtPropertyAccessor element) { super(element); @@ -41,7 +41,7 @@ public class ChangeAccessorTypeFix extends KotlinQuickFixAction { - private final KtType type; + private final KotlinType type; private final KtTypeReference functionLiteralReturnTypeRef; private IntentionAction appropriateQuickFix = null; - public ChangeFunctionLiteralReturnTypeFix(@NotNull KtFunctionLiteralExpression functionLiteralExpression, @NotNull KtType type) { + public ChangeFunctionLiteralReturnTypeFix(@NotNull KtFunctionLiteralExpression functionLiteralExpression, @NotNull KotlinType type) { super(functionLiteralExpression); this.type = type; functionLiteralReturnTypeRef = functionLiteralExpression.getFunctionLiteral().getTypeReference(); AnalysisResult analysisResult = ResolutionUtils.analyzeFullyAndGetResult(functionLiteralExpression.getContainingJetFile()); BindingContext context = analysisResult.getBindingContext(); - KtType functionLiteralType = context.getType(functionLiteralExpression); + KotlinType functionLiteralType = context.getType(functionLiteralExpression); assert functionLiteralType != null : "Type of function literal not available in binding context"; KotlinBuiltIns builtIns = analysisResult.getModuleDescriptor().getBuiltIns(); ClassDescriptor functionClass = builtIns.getFunction(functionLiteralType.getArguments().size() - 1); - List functionClassTypeParameters = new LinkedList(); + List functionClassTypeParameters = new LinkedList(); for (TypeProjection typeProjection: functionLiteralType.getArguments()) { functionClassTypeParameters.add(typeProjection.getType()); } // Replacing return type: functionClassTypeParameters.remove(functionClassTypeParameters.size() - 1); functionClassTypeParameters.add(type); - KtType eventualFunctionLiteralType = TypeUtils.substituteParameters(functionClass, functionClassTypeParameters); + KotlinType eventualFunctionLiteralType = TypeUtils.substituteParameters(functionClass, functionClassTypeParameters); KtProperty correspondingProperty = PsiTreeUtil.getParentOfType(functionLiteralExpression, KtProperty.class); if (correspondingProperty != null && QuickFixUtil.canEvaluateTo(correspondingProperty.getInitializer(), functionLiteralExpression)) { KtTypeReference correspondingPropertyTypeRef = correspondingProperty.getTypeReference(); - KtType propertyType = context.get(BindingContext.TYPE, correspondingPropertyTypeRef); + KotlinType propertyType = context.get(BindingContext.TYPE, correspondingPropertyTypeRef); if (propertyType != null && !KotlinTypeChecker.DEFAULT.isSubtypeOf(eventualFunctionLiteralType, propertyType)) { appropriateQuickFix = new ChangeVariableTypeFix(correspondingProperty, eventualFunctionLiteralType); } @@ -91,7 +91,7 @@ public class ChangeFunctionLiteralReturnTypeFix extends KotlinQuickFixAction + private val parameterTypes: List ) : ChangeFunctionSignatureFix(functionLiteral, functionDescriptor) { override fun getText() = "Change the signature of function literal" @@ -62,7 +62,7 @@ class ChangeFunctionLiteralSignatureFix private constructor( } companion object : KotlinSingleIntentionActionFactoryWithDelegate() { - data class Data(val functionLiteral: KtFunctionLiteral, val descriptor: FunctionDescriptor, val parameterTypes: List) + data class Data(val functionLiteral: KtFunctionLiteral, val descriptor: FunctionDescriptor, val parameterTypes: List) override fun getElementOfInterest(diagnostic: Diagnostic): KtFunctionLiteral? { val diagnosticWithParameters = Errors.EXPECTED_PARAMETERS_NUMBER_MISMATCH.cast(diagnostic) diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/ChangeFunctionReturnTypeFix.java b/idea/src/org/jetbrains/kotlin/idea/quickfix/ChangeFunctionReturnTypeFix.java index 46f64cf6bec..488cc09f12d 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/ChangeFunctionReturnTypeFix.java +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/ChangeFunctionReturnTypeFix.java @@ -44,7 +44,7 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilKt; import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall; import org.jetbrains.kotlin.resolve.dataClassUtils.DataClassUtilsKt; import org.jetbrains.kotlin.types.ErrorUtils; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.checker.KotlinTypeChecker; import java.util.LinkedList; @@ -55,10 +55,10 @@ import static org.jetbrains.kotlin.idea.project.PlatformKt.getPlatform; import static org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt.getBuiltIns; public class ChangeFunctionReturnTypeFix extends KotlinQuickFixAction { - private final KtType type; + private final KotlinType type; private final ChangeFunctionLiteralReturnTypeFix changeFunctionLiteralReturnTypeFix; - public ChangeFunctionReturnTypeFix(@NotNull KtFunction element, @NotNull KtType type) { + public ChangeFunctionReturnTypeFix(@NotNull KtFunction element, @NotNull KotlinType type) { super(element); this.type = type; if (element instanceof KtFunctionLiteral) { @@ -145,7 +145,7 @@ public class ChangeFunctionReturnTypeFix extends KotlinQuickFixAction overriddenMismatchingFunctions = new LinkedList(); for (FunctionDescriptor overriddenFunction: descriptor.getOverriddenDescriptors()) { - KtType overriddenFunctionType = overriddenFunction.getReturnType(); + KotlinType overriddenFunctionType = overriddenFunction.getReturnType(); if (overriddenFunctionType == null) continue; if (!KotlinTypeChecker.DEFAULT.isSubtypeOf(functionType, overriddenFunctionType)) { overriddenMismatchingFunctions.add(overriddenFunction); diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/ChangeParameterTypeFix.java b/idea/src/org/jetbrains/kotlin/idea/quickfix/ChangeParameterTypeFix.java index 93f13e1a383..4c40e740436 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/ChangeParameterTypeFix.java +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/ChangeParameterTypeFix.java @@ -27,14 +27,14 @@ import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers; import org.jetbrains.kotlin.idea.util.ShortenReferences; import org.jetbrains.kotlin.name.FqName; import org.jetbrains.kotlin.psi.*; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; public class ChangeParameterTypeFix extends KotlinQuickFixAction { - private final KtType type; + private final KotlinType type; private final String containingDeclarationName; private final boolean isPrimaryConstructorParameter; - public ChangeParameterTypeFix(@NotNull KtParameter element, @NotNull KtType type) { + public ChangeParameterTypeFix(@NotNull KtParameter element, @NotNull KotlinType type) { super(element); this.type = type; KtNamedDeclaration declaration = PsiTreeUtil.getParentOfType(element, KtNamedDeclaration.class); diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/ChangeTypeFix.java b/idea/src/org/jetbrains/kotlin/idea/quickfix/ChangeTypeFix.java index 8e6690a6904..a44701c1278 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/ChangeTypeFix.java +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/ChangeTypeFix.java @@ -33,13 +33,13 @@ import org.jetbrains.kotlin.psi.KtFile; import org.jetbrains.kotlin.psi.KtParameter; import org.jetbrains.kotlin.psi.KtPsiFactoryKt; import org.jetbrains.kotlin.psi.KtTypeReference; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; public class ChangeTypeFix extends KotlinQuickFixAction { - private final KtType type; + private final KotlinType type; private final String renderedType; - public ChangeTypeFix(@NotNull KtTypeReference element, KtType type) { + public ChangeTypeFix(@NotNull KtTypeReference element, KotlinType type) { super(element); this.type = type; renderedType = IdeDescriptorRenderers.SOURCE_CODE.renderType(type); @@ -70,7 +70,7 @@ public class ChangeTypeFix extends KotlinQuickFixAction { @Nullable @Override public IntentionAction createAction(@NotNull Diagnostic diagnostic) { - DiagnosticWithParameters1 diagnosticWithParameters = Errors.EXPECTED_PARAMETER_TYPE_MISMATCH.cast(diagnostic); + DiagnosticWithParameters1 diagnosticWithParameters = Errors.EXPECTED_PARAMETER_TYPE_MISMATCH.cast(diagnostic); KtTypeReference typeReference = diagnosticWithParameters.getPsiElement().getTypeReference(); assert typeReference != null : "EXPECTED_PARAMETER_TYPE_MISMATCH reported on parameter without explicitly declared type"; return new ChangeTypeFix(typeReference, diagnosticWithParameters.getA()); diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/ChangeVariableTypeFix.java b/idea/src/org/jetbrains/kotlin/idea/quickfix/ChangeVariableTypeFix.java index 79b53ab7abd..6037d3fd130 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/ChangeVariableTypeFix.java +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/ChangeVariableTypeFix.java @@ -40,7 +40,7 @@ import org.jetbrains.kotlin.resolve.BindingContext; import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils; import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall; import org.jetbrains.kotlin.types.ErrorUtils; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.checker.KotlinTypeChecker; import java.util.ArrayList; @@ -50,9 +50,9 @@ import java.util.List; public class ChangeVariableTypeFix extends KotlinQuickFixAction { private final static Logger LOG = Logger.getInstance(ChangeVariableTypeFix.class); - private final KtType type; + private final KotlinType type; - public ChangeVariableTypeFix(@NotNull KtVariableDeclaration element, @NotNull KtType type) { + public ChangeVariableTypeFix(@NotNull KtVariableDeclaration element, @NotNull KotlinType type) { super(element); this.type = type; } @@ -121,7 +121,7 @@ public class ChangeVariableTypeFix extends KotlinQuickFixAction overriddenMismatchingProperties = new LinkedList(); boolean canChangeOverriddenPropertyType = true; for (PropertyDescriptor overriddenProperty: propertyDescriptor.getOverriddenDescriptors()) { - KtType overriddenPropertyType = overriddenProperty.getReturnType(); + KotlinType overriddenPropertyType = overriddenProperty.getReturnType(); if (overriddenPropertyType != null) { if (!KotlinTypeChecker.DEFAULT.isSubtypeOf(propertyType, overriddenPropertyType)) { overriddenMismatchingProperties.add(overriddenProperty); diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixFactoryForTypeMismatchError.java b/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixFactoryForTypeMismatchError.java index f61e411cbfa..28620b52e54 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixFactoryForTypeMismatchError.java +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixFactoryForTypeMismatchError.java @@ -38,7 +38,7 @@ import org.jetbrains.kotlin.resolve.bindingContextUtil.BindingContextUtilsKt; import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilKt; import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall; import org.jetbrains.kotlin.resolve.scopes.LexicalScope; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.typeUtil.TypeUtilsKt; import java.util.Collections; @@ -64,21 +64,21 @@ public class QuickFixFactoryForTypeMismatchError extends JetIntentionActionsFact KtExpression expression = (KtExpression) diagnosticElement; - KtType expectedType; - KtType expressionType; + KotlinType expectedType; + KotlinType expressionType; if (diagnostic.getFactory() == Errors.TYPE_MISMATCH) { - DiagnosticWithParameters2 diagnosticWithParameters = Errors.TYPE_MISMATCH.cast(diagnostic); + DiagnosticWithParameters2 diagnosticWithParameters = Errors.TYPE_MISMATCH.cast(diagnostic); expectedType = diagnosticWithParameters.getA(); expressionType = diagnosticWithParameters.getB(); } else if (diagnostic.getFactory() == Errors.NULL_FOR_NONNULL_TYPE) { - DiagnosticWithParameters1 diagnosticWithParameters = + DiagnosticWithParameters1 diagnosticWithParameters = Errors.NULL_FOR_NONNULL_TYPE.cast(diagnostic); expectedType = diagnosticWithParameters.getA(); expressionType = TypeUtilsKt.makeNullable(expectedType); } else if (diagnostic.getFactory() == Errors.CONSTANT_EXPECTED_TYPE_MISMATCH) { - DiagnosticWithParameters2 diagnosticWithParameters = + DiagnosticWithParameters2 diagnosticWithParameters = Errors.CONSTANT_EXPECTED_TYPE_MISMATCH.cast(diagnostic); expectedType = diagnosticWithParameters.getB(); expressionType = context.getType(expression); @@ -105,7 +105,7 @@ public class QuickFixFactoryForTypeMismatchError extends JetIntentionActionsFact if (QuickFixUtil.canEvaluateTo(initializer, expression) || (getter != null && QuickFixUtil.canFunctionOrGetterReturnExpression(property.getGetter(), expression))) { LexicalScope scope = UtilsKt.getResolutionScope(property, context, ResolutionUtils.getResolutionFacade(property)); - KtType typeToInsert = TypeUtils.approximateWithResolvableType(expressionType, scope, false); + KotlinType typeToInsert = TypeUtils.approximateWithResolvableType(expressionType, scope, false); actions.add(new ChangeVariableTypeFix(property, typeToInsert)); } } @@ -119,7 +119,7 @@ public class QuickFixFactoryForTypeMismatchError extends JetIntentionActionsFact : PsiTreeUtil.getParentOfType(expression, KtFunction.class, true); if (function instanceof KtFunction && QuickFixUtil.canFunctionOrGetterReturnExpression(function, expression)) { LexicalScope scope = UtilsKt.getResolutionScope(function, context, ResolutionUtils.getResolutionFacade(function)); - KtType typeToInsert = TypeUtils.approximateWithResolvableType(expressionType, scope, false); + KotlinType typeToInsert = TypeUtils.approximateWithResolvableType(expressionType, scope, false); actions.add(new ChangeFunctionReturnTypeFix((KtFunction) function, typeToInsert)); } @@ -154,14 +154,14 @@ public class QuickFixFactoryForTypeMismatchError extends JetIntentionActionsFact ValueArgument valueArgument = CallUtilKt.getValueArgumentForExpression(resolvedCall.getCall(), argumentExpression); if (valueArgument != null) { KtParameter correspondingParameter = QuickFixUtil.getParameterDeclarationForValueArgument(resolvedCall, valueArgument); - KtType valueArgumentType = diagnostic.getFactory() == Errors.NULL_FOR_NONNULL_TYPE + KotlinType valueArgumentType = diagnostic.getFactory() == Errors.NULL_FOR_NONNULL_TYPE ? expressionType : context.getType(valueArgument.getArgumentExpression()); if (correspondingParameter != null && valueArgumentType != null) { KtCallableDeclaration callable = PsiTreeUtil.getParentOfType(correspondingParameter, KtCallableDeclaration.class, true); LexicalScope scope = callable != null ? UtilsKt.getResolutionScope(callable, context, ResolutionUtils .getResolutionFacade(callable)) : null; - KtType typeToInsert = TypeUtils.approximateWithResolvableType(valueArgumentType, scope, true); + KotlinType typeToInsert = TypeUtils.approximateWithResolvableType(valueArgumentType, scope, true); actions.add(new ChangeParameterTypeFix(correspondingParameter, typeToInsert)); } } diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/RemovePartsFromPropertyFix.java b/idea/src/org/jetbrains/kotlin/idea/quickfix/RemovePartsFromPropertyFix.java index 8fed1c34696..849e19d7021 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/RemovePartsFromPropertyFix.java +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/RemovePartsFromPropertyFix.java @@ -28,7 +28,7 @@ import org.jetbrains.kotlin.idea.JetBundle; import org.jetbrains.kotlin.idea.core.quickfix.QuickFixUtil; import org.jetbrains.kotlin.idea.intentions.SpecifyTypeExplicitlyIntention; import org.jetbrains.kotlin.psi.*; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; public class RemovePartsFromPropertyFix extends KotlinQuickFixAction { private final boolean removeInitializer; @@ -85,13 +85,13 @@ public class RemovePartsFromPropertyFix extends KotlinQuickFixAction @Override public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) { - KtType type = QuickFixUtil.getDeclarationReturnType(getElement()); + KotlinType type = QuickFixUtil.getDeclarationReturnType(getElement()); return super.isAvailable(project, editor, file) && type != null && !type.isError(); } @Override public void invoke(@NotNull Project project, Editor editor, KtFile file) throws IncorrectOperationException { - KtType type = QuickFixUtil.getDeclarationReturnType(getElement()); + KotlinType type = QuickFixUtil.getDeclarationReturnType(getElement()); KtProperty newElement = (KtProperty) getElement().copy(); KtPropertyAccessor getter = newElement.getGetter(); if (removeGetter && getter != null) { @@ -102,7 +102,7 @@ public class RemovePartsFromPropertyFix extends KotlinQuickFixAction newElement.deleteChildInternal(setter.getNode()); } KtExpression initializer = newElement.getInitializer(); - KtType typeToAdd = null; + KotlinType typeToAdd = null; if (removeInitializer && initializer != null) { PsiElement nameIdentifier = newElement.getNameIdentifier(); assert nameIdentifier != null; diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/SuperClassNotInitialized.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/SuperClassNotInitialized.kt index 36a4169e937..df9e4e744c2 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/SuperClassNotInitialized.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/SuperClassNotInitialized.kt @@ -40,7 +40,7 @@ import org.jetbrains.kotlin.renderer.DescriptorRenderer import org.jetbrains.kotlin.renderer.render import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.types.IndexedParametersSubstitution -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.typeUtil.isSubtypeOf import org.jetbrains.kotlin.utils.addIfNotNull import java.util.* @@ -75,7 +75,7 @@ public object SuperClassNotInitialized : JetIntentionActionsFactory() { .map { it.substitute(substitutor) as ConstructorDescriptor } if (substitutedConstructors.isNotEmpty()) { - val parameterTypes: List> = substitutedConstructors.map { + val parameterTypes: List> = substitutedConstructors.map { it.getValueParameters().map { it.getType() } } diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/CallableBuilder.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/CallableBuilder.kt index eff7e088f50..5bde60ad2c2 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/CallableBuilder.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/CallableBuilder.kt @@ -66,7 +66,7 @@ import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.scopes.* import org.jetbrains.kotlin.resolve.scopes.utils.asJetScope -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeProjectionImpl import org.jetbrains.kotlin.types.Variance import org.jetbrains.kotlin.types.checker.KotlinTypeChecker @@ -83,7 +83,7 @@ private val ATTRIBUTE_FUNCTION_NAME = "FUNCTION_NAME" /** * Represents a single choice for a type (e.g. parameter type or return type). */ -class TypeCandidate(val theType: KtType, scope: KtScope? = null) { +class TypeCandidate(val theType: KotlinType, scope: KtScope? = null) { public val typeParameters: Array var renderedType: String? = null private set @@ -117,7 +117,7 @@ data class RenderedTypeParameter( val text: String ) -fun List.getTypeByRenderedType(renderedType: String): KtType? = +fun List.getTypeByRenderedType(renderedType: String): KotlinType? = firstOrNull { it.renderedType == renderedType }?.theType class CallableBuilderConfiguration( @@ -166,7 +166,7 @@ class CallableBuilder(val config: CallableBuilderConfiguration) { val types = typeInfo.getPossibleTypes(this).asReversed() // We have to use semantic equality here - data class EqWrapper(val _type: KtType) { + data class EqWrapper(val _type: KotlinType) { override fun equals(other: Any?) = this === other || other is EqWrapper && KotlinTypeChecker.DEFAULT.equalTypes(_type, other._type) override fun hashCode() = 0 // no good way to compute hashCode() that would agree with our equals() @@ -291,7 +291,7 @@ class CallableBuilder(val config: CallableBuilderConfiguration) { val fakeFunction: FunctionDescriptor? // figure out type substitutions for type parameters - val substitutionMap = LinkedHashMap() + val substitutionMap = LinkedHashMap() if (config.enableSubstitutions) { collectSubstitutionsForReceiverTypeParameters(receiverType, substitutionMap) val typeArgumentsForFakeFunction = callableInfo.typeParameterInfos @@ -372,8 +372,8 @@ class CallableBuilder(val config: CallableBuilderConfiguration) { } private fun collectSubstitutionsForReceiverTypeParameters( - receiverType: KtType?, - result: MutableMap + receiverType: KotlinType?, + result: MutableMap ) { if (placement is CallablePlacement.NoReceiver) return @@ -386,8 +386,8 @@ class CallableBuilder(val config: CallableBuilderConfiguration) { private fun collectSubstitutionsForCallableTypeParameters( fakeFunction: FunctionDescriptor, - typeArguments: Set, - result: MutableMap) { + typeArguments: Set, + result: MutableMap) { for ((typeArgument, typeParameter) in typeArguments zip fakeFunction.getTypeParameters()) { result[typeArgument] = typeParameter.getDefaultType() } @@ -842,7 +842,7 @@ class CallableBuilder(val config: CallableBuilderConfiguration) { return typeParameters } - private fun replaceWithLongerName(typeRef: KtTypeReference, theType: KtType) { + private fun replaceWithLongerName(typeRef: KtTypeReference, theType: KotlinType) { val fullyQualifiedReceiverTypeRef = KtPsiFactory(typeRef).createType(theType.renderLong(typeParameterNameMap)) typeRef.replace(fullyQualifiedReceiverTypeRef) } diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/CallableInfo.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/CallableInfo.kt index 2b093271730..2955c296326 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/CallableInfo.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/CallableInfo.kt @@ -26,7 +26,7 @@ import org.jetbrains.kotlin.psi.KtExpression import org.jetbrains.kotlin.psi.KtTypeReference import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.types.ErrorUtils -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.Variance import org.jetbrains.kotlin.types.typeUtil.makeNotNullable import org.jetbrains.kotlin.types.typeUtil.supertypes @@ -37,7 +37,7 @@ import java.util.* */ abstract class TypeInfo(val variance: Variance) { object Empty: TypeInfo(Variance.INVARIANT) { - override fun getPossibleTypes(builder: CallableBuilder): List = Collections.emptyList() + override fun getPossibleTypes(builder: CallableBuilder): List = Collections.emptyList() } class ByExpression(val expression: KtExpression, variance: Variance): TypeInfo(variance) { @@ -45,7 +45,7 @@ abstract class TypeInfo(val variance: Variance) { KotlinNameSuggester.suggestNamesByExpressionOnly(expression, { true }).toTypedArray() } - override fun getPossibleTypes(builder: CallableBuilder): List = + override fun getPossibleTypes(builder: CallableBuilder): List = expression.guessTypes( context = builder.currentFileContext, module = builder.currentFileModule, @@ -54,24 +54,24 @@ abstract class TypeInfo(val variance: Variance) { } class ByTypeReference(val typeReference: KtTypeReference, variance: Variance): TypeInfo(variance) { - override fun getPossibleTypes(builder: CallableBuilder): List = + override fun getPossibleTypes(builder: CallableBuilder): List = builder.currentFileContext[BindingContext.TYPE, typeReference].getPossibleSupertypes(variance, builder) } - class ByType(val theType: KtType, variance: Variance): TypeInfo(variance) { - override fun getPossibleTypes(builder: CallableBuilder): List = + class ByType(val theType: KotlinType, variance: Variance): TypeInfo(variance) { + override fun getPossibleTypes(builder: CallableBuilder): List = theType.getPossibleSupertypes(variance, builder) } class ByReceiverType(variance: Variance): TypeInfo(variance) { - override fun getPossibleTypes(builder: CallableBuilder): List = + override fun getPossibleTypes(builder: CallableBuilder): List = (builder.placement as CallablePlacement.WithReceiver).receiverTypeCandidate.theType.getPossibleSupertypes(variance, builder) } abstract class DelegatingTypeInfo(val delegate: TypeInfo): TypeInfo(delegate.variance) { override val substitutionsAllowed: Boolean = delegate.substitutionsAllowed override val possibleNamesFromExpression: Array get() = delegate.possibleNamesFromExpression - override fun getPossibleTypes(builder: CallableBuilder): List = delegate.getPossibleTypes(builder) + override fun getPossibleTypes(builder: CallableBuilder): List = delegate.getPossibleTypes(builder) } class NoSubstitutions(delegate: TypeInfo): DelegatingTypeInfo(delegate) { @@ -85,9 +85,9 @@ abstract class TypeInfo(val variance: Variance) { open val substitutionsAllowed: Boolean = true open val staticContextRequired: Boolean = false open val possibleNamesFromExpression: Array get() = ArrayUtil.EMPTY_STRING_ARRAY - abstract fun getPossibleTypes(builder: CallableBuilder): List + abstract fun getPossibleTypes(builder: CallableBuilder): List - protected fun KtType?.getPossibleSupertypes(variance: Variance, callableBuilder: CallableBuilder): List { + protected fun KotlinType?.getPossibleSupertypes(variance: Variance, callableBuilder: CallableBuilder): List { if (this == null || ErrorUtils.containsErrorType(this)) { return Collections.singletonList(callableBuilder.currentFileModule.builtIns.anyType) } @@ -101,13 +101,13 @@ abstract class TypeInfo(val variance: Variance) { fun TypeInfo(expressionOfType: KtExpression, variance: Variance): TypeInfo = TypeInfo.ByExpression(expressionOfType, variance) fun TypeInfo(typeReference: KtTypeReference, variance: Variance): TypeInfo = TypeInfo.ByTypeReference(typeReference, variance) -fun TypeInfo(theType: KtType, variance: Variance): TypeInfo = TypeInfo.ByType(theType, variance) +fun TypeInfo(theType: KotlinType, variance: Variance): TypeInfo = TypeInfo.ByType(theType, variance) fun TypeInfo.noSubstitutions(): TypeInfo = (this as? TypeInfo.NoSubstitutions) ?: TypeInfo.NoSubstitutions(this) fun TypeInfo.forceNotNull(): TypeInfo { class ForcedNotNull(delegate: TypeInfo): TypeInfo.DelegatingTypeInfo(delegate) { - override fun getPossibleTypes(builder: CallableBuilder): List = + override fun getPossibleTypes(builder: CallableBuilder): List = super.getPossibleTypes(builder).map { it.makeNotNullable() } } diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/typeUtils.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/typeUtils.kt index c90c2e66b8a..1445c86e166 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/typeUtils.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/typeUtils.kt @@ -40,11 +40,11 @@ import org.jetbrains.kotlin.types.checker.KotlinTypeChecker import org.jetbrains.kotlin.types.typeUtil.makeNotNullable import java.util.* -internal fun KtType.contains(inner: KtType): Boolean { +internal fun KotlinType.contains(inner: KotlinType): Boolean { return KotlinTypeChecker.DEFAULT.equalTypes(this, inner) || getArguments().any { inner in it.getType() } } -private fun KtType.render(typeParameterNameMap: Map, fq: Boolean): String { +private fun KotlinType.render(typeParameterNameMap: Map, fq: Boolean): String { val substitution = typeParameterNameMap .mapValues { val name = Name.identifier(it.value) @@ -63,7 +63,7 @@ private fun KtType.render(typeParameterNameMap: Map) = render(typeParameterNameMap, false) -internal fun KtType.renderLong(typeParameterNameMap: Map) = render(typeParameterNameMap, true) +internal fun KotlinType.renderShort(typeParameterNameMap: Map) = render(typeParameterNameMap, false) +internal fun KotlinType.renderLong(typeParameterNameMap: Map) = render(typeParameterNameMap, true) internal fun getTypeParameterNamesNotInScope(typeParameters: Collection, scope: KtScope): List { return typeParameters.filter { typeParameter -> @@ -86,13 +86,13 @@ internal fun getTypeParameterNamesNotInScope(typeParameters: Collection { - val visitedTypes = HashSet() +fun KotlinType.getTypeParameters(): Set { + val visitedTypes = HashSet() val typeParameters = LinkedHashSet() - fun traverseTypes(type: KtType) { + fun traverseTypes(type: KotlinType) { if (!visitedTypes.add(type)) return val arguments = type.arguments @@ -116,7 +116,7 @@ fun KtExpression.guessTypes( module: ModuleDescriptor, pseudocode: Pseudocode? = null, coerceUnusedToUnit: Boolean = true -): Array { +): Array { if (coerceUnusedToUnit && this !is KtDeclaration && isUsedAsStatement(context) @@ -204,7 +204,7 @@ fun KtExpression.guessTypes( } } -private fun KtNamedDeclaration.guessType(context: BindingContext): Array { +private fun KtNamedDeclaration.guessType(context: BindingContext): Array { val expectedTypes = SearchUtils.findAllReferences(this, getUseScope())!!.asSequence().map { ref -> if (ref is KtSimpleNameReference) { context[BindingContext.EXPECTED_EXPRESSION_TYPE, ref.expression] @@ -212,7 +212,7 @@ private fun KtNamedDeclaration.guessType(context: BindingContext): Array else { null } - }.filterNotNullTo(HashSet()) + }.filterNotNullTo(HashSet()) if (expectedTypes.isEmpty() || expectedTypes.any { expectedType -> ErrorUtils.containsErrorType(expectedType) }) { return arrayOf() @@ -228,11 +228,11 @@ private fun KtNamedDeclaration.guessType(context: BindingContext): Array } /** - * Encapsulates a single type substitution of a KtType by another KtType. + * Encapsulates a single type substitution of a KotlinType by another KotlinType. */ -internal class JetTypeSubstitution(public val forType: KtType, public val byType: KtType) +internal class JetTypeSubstitution(public val forType: KotlinType, public val byType: KotlinType) -internal fun KtType.substitute(substitution: JetTypeSubstitution, variance: Variance): KtType { +internal fun KotlinType.substitute(substitution: JetTypeSubstitution, variance: Variance): KotlinType { val nullable = isMarkedNullable() val currentType = makeNotNullable() @@ -248,7 +248,7 @@ internal fun KtType.substitute(substitution: JetTypeSubstitution, variance: Vari val (projection, typeParameter) = pair TypeProjectionImpl(Variance.INVARIANT, projection.getType().substitute(substitution, typeParameter.getVariance())) } - return KtTypeImpl.create(getAnnotations(), getConstructor(), isMarkedNullable(), newArguments, getMemberScope()) + return KotlinTypeImpl.create(getAnnotations(), getConstructor(), isMarkedNullable(), newArguments, getMemberScope()) } } @@ -268,7 +268,7 @@ fun KtCallExpression.getParameterInfos(): List { } } -private fun TypePredicate.getRepresentativeTypes(): Set { +private fun TypePredicate.getRepresentativeTypes(): Set { return when (this) { is SingleType -> Collections.singleton(targetType) is AllSubtypes -> Collections.singleton(upperBound) @@ -276,7 +276,7 @@ private fun TypePredicate.getRepresentativeTypes(): Set { if (typeSets.isEmpty()) AllTypes.getRepresentativeTypes() else typeSets.map { it.getRepresentativeTypes() }.reduce { a, b -> a intersect b } } - is ForSomeType -> typeSets.flatMapTo(LinkedHashSet()) { it.getRepresentativeTypes() } + is ForSomeType -> typeSets.flatMapTo(LinkedHashSet()) { it.getRepresentativeTypes() } is AllTypes -> emptySet() else -> throw AssertionError("Invalid type predicate: ${this}") } diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateIteratorFunctionActionFactory.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateIteratorFunctionActionFactory.kt index 8af1b172aeb..e0c037ffd5e 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateIteratorFunctionActionFactory.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateIteratorFunctionActionFactory.kt @@ -27,7 +27,7 @@ import org.jetbrains.kotlin.idea.quickfix.createFromUsage.callableBuilder.guessT import org.jetbrains.kotlin.psi.KtExpression import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.psi.KtForExpression -import org.jetbrains.kotlin.types.KtTypeImpl +import org.jetbrains.kotlin.types.KotlinTypeImpl import org.jetbrains.kotlin.types.TypeProjectionImpl import org.jetbrains.kotlin.types.Variance import org.jetbrains.kotlin.util.OperatorNameConventions @@ -52,7 +52,7 @@ object CreateIteratorFunctionActionFactory : CreateCallableMemberFromUsageFactor val returnJetTypeParameterType = TypeProjectionImpl(returnJetTypeParameterTypes[0]) val returnJetTypeArguments = Collections.singletonList(returnJetTypeParameterType) - val newReturnJetType = KtTypeImpl.create(returnJetType.annotations, + val newReturnJetType = KotlinTypeImpl.create(returnJetType.annotations, returnJetType.constructor, returnJetType.isMarkedNullable, returnJetTypeArguments, diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createVariable/CreateParameterByRefActionFactory.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createVariable/CreateParameterByRefActionFactory.kt index 6a78e4669fc..cd7dfb21f64 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createVariable/CreateParameterByRefActionFactory.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createVariable/CreateParameterByRefActionFactory.kt @@ -40,7 +40,7 @@ import org.jetbrains.kotlin.psi.psiUtil.parents import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.scopes.utils.asJetScope import org.jetbrains.kotlin.resolve.source.getPsi -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull import java.util.* @@ -131,7 +131,7 @@ object CreateParameterByRefActionFactory : CreateParameterFromUsageFactory) { val typeParameters = resolvedCall.resultingDescriptor.original.typeParameters @@ -267,7 +267,7 @@ private fun ConstructedExpressionWrapper.processTypeParameterUsages(resolvedCall } } -private fun ConstructedExpressionWrapperWithIntroduceFeature.wrapExpressionForSafeCall(receiver: KtExpression, receiverType: KtType?) { +private fun ConstructedExpressionWrapperWithIntroduceFeature.wrapExpressionForSafeCall(receiver: KtExpression, receiverType: KotlinType?) { val qualified = expression as? KtQualifiedExpression if (qualified != null) { if (qualified.receiverExpression[RECEIVER_VALUE_KEY]) { @@ -322,7 +322,7 @@ private fun KtExpression?.shouldKeepValue(usageCount: Int): Boolean { private class Argument( val expression: KtExpression, - val expressionType: KtType?, + val expressionType: KotlinType?, val isNamed: Boolean = false, val isDefaultValue: Boolean = false) @@ -501,7 +501,7 @@ private fun dropArgumentsForDefaultValues(result: KtElement) { } } -private fun arrayOfFunctionName(elementType: KtType): String { +private fun arrayOfFunctionName(elementType: KotlinType): String { return when { KotlinBuiltIns.isInt(elementType) -> "kotlin.intArrayOf" KotlinBuiltIns.isLong(elementType) -> "kotlin.longArrayOf" @@ -629,7 +629,7 @@ private class ConstructedExpressionWrapperWithIntroduceFeature( public fun introduceValue( value: KtExpression, - valueType: KtType?, + valueType: KotlinType?, usages: Collection, nameSuggestion: String? = null, safeCall: Boolean = false @@ -660,7 +660,7 @@ private class ConstructedExpressionWrapperWithIntroduceFeature( val resolutionScope = bindingContext[BindingContext.RESOLUTION_SCOPE, expressionToBeReplaced] if (usages.isNotEmpty()) { - var explicitType: KtType? = null + var explicitType: KotlinType? = null if (valueType != null && !ErrorUtils.containsErrorType(valueType)) { val valueTypeWithoutExpectedType = value.computeTypeInContext( resolutionScope!!, diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/JetRefactoringUtil.java b/idea/src/org/jetbrains/kotlin/idea/refactoring/JetRefactoringUtil.java index 72878f89d06..464a2f02cea 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/JetRefactoringUtil.java +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/JetRefactoringUtil.java @@ -56,7 +56,7 @@ import org.jetbrains.kotlin.resolve.BindingContext; import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils; import org.jetbrains.kotlin.resolve.DescriptorUtils; import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import javax.swing.*; import javax.swing.event.ListSelectionEvent; @@ -402,7 +402,7 @@ public class JetRefactoringUtil { if (addExpression) { KtExpression expression = (KtExpression)element; BindingContext bindingContext = ResolutionUtils.analyze(expression, BodyResolveMode.FULL); - KtType expressionType = bindingContext.getType(expression); + KotlinType expressionType = bindingContext.getType(expression); if (expressionType == null || !KotlinBuiltIns.isUnit(expressionType)) { expressions.add(expression); } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeInfo.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeInfo.kt index 15ac98858a9..00978ccccb4 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeInfo.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeInfo.kt @@ -44,7 +44,7 @@ import org.jetbrains.kotlin.load.java.JvmAbi import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils import org.jetbrains.kotlin.resolve.DescriptorUtils -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.utils.addToStdlib.singletonOrEmptyList import java.util.ArrayList import java.util.HashMap @@ -53,7 +53,7 @@ import java.util.LinkedHashSet public open class JetChangeInfo( val methodDescriptor: JetMethodDescriptor, private var name: String = methodDescriptor.getName(), - val newReturnType: KtType? = methodDescriptor.baseDescriptor.getReturnType(), + val newReturnType: KotlinType? = methodDescriptor.baseDescriptor.getReturnType(), var newReturnTypeText: String = methodDescriptor.renderOriginalReturnType(), var newVisibility: Visibility = methodDescriptor.getVisibility(), parameterInfos: List = methodDescriptor.getParameters(), diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureUsageProcessor.java b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureUsageProcessor.java index 7c78387e268..c566ef20f2a 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureUsageProcessor.java +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureUsageProcessor.java @@ -80,7 +80,7 @@ import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue; import org.jetbrains.kotlin.resolve.scopes.receivers.ThisReceiver; import org.jetbrains.kotlin.resolve.scopes.utils.ScopeUtilsKt; import org.jetbrains.kotlin.resolve.source.KotlinSourceElementKt; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import java.util.*; @@ -471,7 +471,7 @@ public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsagePro FunctionDescriptor functionDescriptor = context.get(BindingContext.FUNCTION, functionLiteral); assert functionDescriptor != null : "No descriptor for " + functionLiteral.getText(); - KtType samCallType = context.getType(callExpression); + KotlinType samCallType = context.getType(callExpression); if (samCallType == null) continue; result.add(new DeferredJavaMethodOverrideOrSAMUsage(functionLiteral, functionDescriptor, samCallType)); @@ -859,10 +859,10 @@ public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsagePro } } - private static List getCallableParameterTypes(CallableDescriptor descriptor) { - return ContainerUtil.map(descriptor.getValueParameters(), new Function() { + private static List getCallableParameterTypes(CallableDescriptor descriptor) { + return ContainerUtil.map(descriptor.getValueParameters(), new Function() { @Override - public KtType fun(ValueParameterDescriptor descriptor) { + public KotlinType fun(ValueParameterDescriptor descriptor) { return descriptor.getType(); } }); diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetParameterInfo.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetParameterInfo.kt index 4b653b8fb90..a9ed1407e43 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetParameterInfo.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetParameterInfo.kt @@ -34,20 +34,20 @@ import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode import org.jetbrains.kotlin.resolve.scopes.receivers.ThisReceiver -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import java.util.* public class JetParameterInfo( val callableDescriptor: CallableDescriptor, val originalIndex: Int = -1, private var name: String, - type: KtType? = null, + type: KotlinType? = null, var defaultValueForParameter: KtExpression? = null, var defaultValueForCall: KtExpression? = null, var valOrVar: JetValVar = JetValVar.None, val modifierList: KtModifierList? = null ): ParameterInfo { - val originalType: KtType? = type + val originalType: KotlinType? = type var currentTypeText: String = getOldTypeText() public val defaultValueParameterReferences: Map diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/changeSignatureUtils.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/changeSignatureUtils.kt index 18aef4ab825..96faf279e0d 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/changeSignatureUtils.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/changeSignatureUtils.kt @@ -27,7 +27,7 @@ import org.jetbrains.kotlin.idea.refactoring.changeSignature.usages.KotlinCaller import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.parentsWithSelf -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeSubstitutor import org.jetbrains.kotlin.types.Variance import org.jetbrains.kotlin.types.substitutions.getCallableSubstitutor @@ -73,7 +73,7 @@ fun getCallableSubstitutor( return getCallableSubstitutor(currentBaseFunction, currentDerivedFunction) } -fun KtType.renderTypeWithSubstitution(substitutor: TypeSubstitutor?, defaultText: String, inArgumentPosition: Boolean): String { +fun KotlinType.renderTypeWithSubstitution(substitutor: TypeSubstitutor?, defaultText: String, inArgumentPosition: Boolean): String { val newType = substitutor?.substitute(this, Variance.INVARIANT) ?: return defaultText val renderer = if (inArgumentPosition) IdeDescriptorRenderers.SOURCE_CODE_FOR_TYPE_ARGUMENTS else IdeDescriptorRenderers.SOURCE_CODE return renderer.renderType(newType) diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JavaMethodDeferredKotlinUsage.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JavaMethodDeferredKotlinUsage.kt index 16a7f28ebf0..5ae4a990070 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JavaMethodDeferredKotlinUsage.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JavaMethodDeferredKotlinUsage.kt @@ -23,7 +23,7 @@ import org.jetbrains.kotlin.idea.refactoring.changeSignature.JetChangeInfo import org.jetbrains.kotlin.psi.KtConstructorDelegationCall import org.jetbrains.kotlin.psi.KtFunction import org.jetbrains.kotlin.psi.KtNamedDeclaration -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType public abstract class JavaMethodDeferredKotlinUsage(element: T) : UsageInfo(element) { abstract fun resolve(javaMethodChangeInfo: JetChangeInfo): JavaMethodKotlinUsageWithDelegate @@ -32,7 +32,7 @@ public abstract class JavaMethodDeferredKotlinUsage(element: T) public class DeferredJavaMethodOverrideOrSAMUsage( val function: KtFunction, val functionDescriptor: FunctionDescriptor, - val samCallType: KtType? + val samCallType: KotlinType? ) : JavaMethodDeferredKotlinUsage(function) { override fun resolve(javaMethodChangeInfo: JetChangeInfo): JavaMethodKotlinUsageWithDelegate { return object : JavaMethodKotlinUsageWithDelegate(function, javaMethodChangeInfo) { diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetCallableDefinitionUsage.java b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetCallableDefinitionUsage.java index fcc72e8504a..5caeba9eff9 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetCallableDefinitionUsage.java +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetCallableDefinitionUsage.java @@ -49,7 +49,7 @@ import org.jetbrains.kotlin.psi.typeRefHelpers.TypeRefHelpersKt; import org.jetbrains.kotlin.resolve.BindingContext; import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils; import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.TypeSubstitutor; import org.jetbrains.kotlin.types.substitutions.SubstitutionUtilsKt; @@ -69,7 +69,7 @@ public class JetCallableDefinitionUsage extends JetUsageIn private final boolean hasExpectedType; @Nullable - private final KtType samCallType; + private final KotlinType samCallType; @Nullable private TypeSubstitutor typeSubstitutor; @@ -78,7 +78,7 @@ public class JetCallableDefinitionUsage extends JetUsageIn @NotNull T function, @NotNull CallableDescriptor originalCallableDescriptor, @Nullable JetCallableDefinitionUsage baseFunction, - @Nullable KtType samCallType + @Nullable KotlinType samCallType ) { super(function); this.originalCallableDescriptor = originalCallableDescriptor; diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetFunctionCallUsage.java b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetFunctionCallUsage.java index c6943d077a9..3178770c22f 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetFunctionCallUsage.java +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetFunctionCallUsage.java @@ -51,7 +51,7 @@ import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver; import org.jetbrains.kotlin.resolve.scopes.receivers.ExtensionReceiver; import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue; import org.jetbrains.kotlin.resolve.scopes.receivers.ThisReceiver; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.checker.KotlinTypeChecker; import org.jetbrains.kotlin.types.expressions.OperatorConventions; @@ -175,7 +175,7 @@ public class JetFunctionCallUsage extends JetUsageInfo { ((ReceiverParameterDescriptor) originalDescriptor).getValue() instanceof ExtensionReceiver; if (currentIsExtension != originalIsExtension) return null; - KtType originalType = originalDescriptor instanceof ReceiverParameterDescriptor + KotlinType originalType = originalDescriptor instanceof ReceiverParameterDescriptor ? ((ReceiverParameterDescriptor) originalDescriptor).getType() : originalDescriptor instanceof ClassDescriptor ? ((ClassDescriptor) originalDescriptor).getDefaultType() diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/inline/KotlinInlineValHandler.java b/idea/src/org/jetbrains/kotlin/idea/refactoring/inline/KotlinInlineValHandler.java index b7548ee2508..35ed8396734 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/inline/KotlinInlineValHandler.java +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/inline/KotlinInlineValHandler.java @@ -65,7 +65,7 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilKt; import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall; import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode; import org.jetbrains.kotlin.types.ErrorUtils; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.expressions.OperatorConventions; import java.util.List; @@ -391,15 +391,15 @@ public class KotlinInlineValHandler extends InlineActionHandler { ResolvedCall call = CallUtilKt.getResolvedCall(initializer, context); if (call == null) return null; - List typeArguments = Lists.newArrayList(); - Map typeArgumentMap = call.getTypeArguments(); + List typeArguments = Lists.newArrayList(); + Map typeArgumentMap = call.getTypeArguments(); for (TypeParameterDescriptor typeParameter : call.getCandidateDescriptor().getTypeParameters()) { typeArguments.add(typeArgumentMap.get(typeParameter)); } - return StringUtil.join(typeArguments, new Function() { + return StringUtil.join(typeArguments, new Function() { @Override - public String fun(KtType type) { + public String fun(KotlinType type) { return IdeDescriptorRenderers.SOURCE_CODE_FOR_TYPE_ARGUMENTS.renderType(type); } }, ", "); diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractFunction/ui/KotlinExtractFunctionDialog.java b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractFunction/ui/KotlinExtractFunctionDialog.java index 2e3cde3ad6f..7ef86809dfc 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractFunction/ui/KotlinExtractFunctionDialog.java +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractFunction/ui/KotlinExtractFunctionDialog.java @@ -35,7 +35,7 @@ import org.jetbrains.kotlin.idea.core.refactoring.JetRefactoringUtilKt; import org.jetbrains.kotlin.idea.refactoring.JetRefactoringBundle; import org.jetbrains.kotlin.idea.refactoring.introduce.extractionEngine.*; import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import javax.swing.*; import java.awt.*; @@ -142,7 +142,7 @@ public class KotlinExtractFunctionDialog extends DialogWrapper { functionNamePanel.add(functionNameField, BorderLayout.CENTER); functionNameLabel.setLabelFor(functionNameField); - List possibleReturnTypes = ExtractableCodeDescriptorKt.getPossibleReturnTypes(extractableCodeDescriptor.getControlFlow()); + List possibleReturnTypes = ExtractableCodeDescriptorKt.getPossibleReturnTypes(extractableCodeDescriptor.getControlFlow()); if (possibleReturnTypes.size() > 1) { DefaultComboBoxModel returnTypeBoxModel = new DefaultComboBoxModel(possibleReturnTypes.toArray()); returnTypeBox.setModel(returnTypeBoxModel); @@ -158,7 +158,7 @@ public class KotlinExtractFunctionDialog extends DialogWrapper { boolean cellHasFocus ) { super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - setText(IdeDescriptorRenderers.SOURCE_CODE_SHORT_NAMES_IN_TYPES.renderType((KtType) value)); + setText(IdeDescriptorRenderers.SOURCE_CODE_SHORT_NAMES_IN_TYPES.renderType((KotlinType) value)); return this; } } @@ -262,7 +262,7 @@ public class KotlinExtractFunctionDialog extends DialogWrapper { getVisibility(), parameterTablePanel.getReceiverInfo(), parameterTablePanel.getParameterInfos(), - (KtType) returnTypeBox.getSelectedItem()); + (KotlinType) returnTypeBox.getSelectedItem()); } @NotNull @@ -276,7 +276,7 @@ public class KotlinExtractFunctionDialog extends DialogWrapper { @NotNull String newVisibility, @Nullable KotlinParameterTablePanel.ParameterInfo newReceiverInfo, @NotNull List newParameterInfos, - @Nullable KtType returnType + @Nullable KotlinType returnType ) { Map oldToNewParameters = ContainerUtil.newLinkedHashMap(); for (KotlinParameterTablePanel.ParameterInfo parameterInfo : newParameterInfos) { diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractFunction/ui/KotlinParameterTablePanel.java b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractFunction/ui/KotlinParameterTablePanel.java index e16214a7760..86f3c7b2cbc 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractFunction/ui/KotlinParameterTablePanel.java +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractFunction/ui/KotlinParameterTablePanel.java @@ -33,7 +33,7 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.idea.core.KotlinNameSuggester; import org.jetbrains.kotlin.idea.refactoring.introduce.extractionEngine.Parameter; import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import javax.swing.*; import javax.swing.table.AbstractTableModel; @@ -51,7 +51,7 @@ public class KotlinParameterTablePanel extends JPanel { private final Parameter originalParameter; private final boolean receiver; private String name; - private KtType type; + private KotlinType type; private boolean enabled = true; public ParameterInfo(Parameter originalParameter, boolean receiver) { @@ -85,11 +85,11 @@ public class KotlinParameterTablePanel extends JPanel { this.name = name; } - public KtType getType() { + public KotlinType getType() { return type; } - public void setType(KtType type) { + public void setType(KotlinType type) { this.type = type; } @@ -156,7 +156,7 @@ public class KotlinParameterTablePanel extends JPanel { public Component getTableCellRendererComponent( @NotNull JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column ) { - myLabel.setText(IdeDescriptorRenderers.SOURCE_CODE_SHORT_NAMES_IN_TYPES.renderType((KtType) value)); + myLabel.setText(IdeDescriptorRenderers.SOURCE_CODE_SHORT_NAMES_IN_TYPES.renderType((KotlinType) value)); myLabel.setBackground(isSelected ? table.getSelectionBackground() : table.getBackground()); myLabel.setForeground(isSelected ? table.getSelectionForeground() : table.getForeground()); if (isSelected) { @@ -189,7 +189,7 @@ public class KotlinParameterTablePanel extends JPanel { myEditorComponent.setToString(new Function() { @Override public String fun(Object o) { - return IdeDescriptorRenderers.SOURCE_CODE_SHORT_NAMES_IN_TYPES.renderType((KtType) o); + return IdeDescriptorRenderers.SOURCE_CODE_SHORT_NAMES_IN_TYPES.renderType((KotlinType) o); } }); @@ -352,7 +352,7 @@ public class KotlinParameterTablePanel extends JPanel { break; } case PARAMETER_TYPE_COLUMN: { - info.setType((KtType) aValue); + info.setType((KotlinType) aValue); updateSignature(); break; } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/ExtractableCodeDescriptor.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/ExtractableCodeDescriptor.kt index a76122bdead..3390a00cdb3 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/ExtractableCodeDescriptor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/ExtractableCodeDescriptor.kt @@ -58,11 +58,11 @@ interface Parameter { val mirrorVarName: String? val receiverCandidate: Boolean - fun getParameterType(allowSpecialClassNames: Boolean): KtType + fun getParameterType(allowSpecialClassNames: Boolean): KotlinType - fun getParameterTypeCandidates(allowSpecialClassNames: Boolean): List + fun getParameterTypeCandidates(allowSpecialClassNames: Boolean): List - fun copy(name: String, parameterType: KtType): Parameter + fun copy(name: String, parameterType: KotlinType): Parameter } val Parameter.nameForRef: String get() = mirrorVarName ?: name @@ -124,12 +124,12 @@ class FqNameReplacement(val fqName: FqName): Replacement { interface OutputValue { val originalExpressions: List - val valueType: KtType + val valueType: KotlinType class ExpressionValue( val callSiteReturn: Boolean, override val originalExpressions: List, - override val valueType: KtType + override val valueType: KotlinType ): OutputValue class Jump( @@ -139,28 +139,28 @@ interface OutputValue { private val builtIns: KotlinBuiltIns ): OutputValue { override val originalExpressions: List get() = elementsToReplace - override val valueType: KtType = with(builtIns) { if (conditional) booleanType else unitType } + override val valueType: KotlinType = with(builtIns) { if (conditional) booleanType else unitType } } class ParameterUpdate( val parameter: Parameter, override val originalExpressions: List ): OutputValue { - override val valueType: KtType get() = parameter.getParameterType(false) + override val valueType: KotlinType get() = parameter.getParameterType(false) } class Initializer( val initializedDeclaration: KtProperty, - override val valueType: KtType + override val valueType: KotlinType ): OutputValue { override val originalExpressions: List get() = Collections.singletonList(initializedDeclaration) } } abstract class OutputValueBoxer(val outputValues: List) { - val outputValueTypes: List get() = outputValues.map { it.valueType } + val outputValueTypes: List get() = outputValues.map { it.valueType } - abstract val returnType: KtType + abstract val returnType: KotlinType protected abstract fun getBoxingExpressionText(arguments: List): String? @@ -206,8 +206,8 @@ abstract class OutputValueBoxer(val outputValues: List) { private val selectors = arrayOf("first", "second", "third") } - override val returnType: KtType by lazy { - fun getType(): KtType { + override val returnType: KotlinType by lazy { + fun getType(): KotlinType { val boxingClass = when (outputValues.size()) { 1 -> return outputValues.first().valueType 2 -> module.resolveTopLevelClass(FqName("kotlin.Pair"), NoLookupLocation.FROM_IDE)!! @@ -251,7 +251,7 @@ abstract class OutputValueBoxer(val outputValues: List) { } class AsList(outputValues: List): OutputValueBoxer(outputValues) { - override val returnType: KtType by lazy { + override val returnType: KotlinType by lazy { assert(outputValues.isNotEmpty()) val builtIns = outputValues.first().valueType.builtIns TypeUtils.substituteParameters( @@ -302,7 +302,7 @@ data class ControlFlow( } } -val ControlFlow.possibleReturnTypes: List +val ControlFlow.possibleReturnTypes: List get() { val returnType = outputValueBoxer.returnType return when { @@ -328,7 +328,7 @@ data class ExtractableCodeDescriptor( val typeParameters: List, val replacementMap: Map, val controlFlow: ControlFlow, - val returnType: KtType + val returnType: KotlinType ) { val name: String get() = suggestedNames.firstOrNull() ?: "" val duplicates: List by lazy { findDuplicates() } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/ExtractionData.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/ExtractionData.kt index fdaed361f99..2ded6d7cd7d 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/ExtractionData.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/ExtractionData.kt @@ -45,7 +45,7 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.isExtension import org.jetbrains.kotlin.resolve.scopes.receivers.ThisReceiver import org.jetbrains.kotlin.resolve.source.getPsi import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import java.util.* data class ExtractionOptions( @@ -71,8 +71,8 @@ data class ResolvedReferenceInfo( val refExpr: KtSimpleNameExpression, val offsetInBody: Int, val resolveResult: ResolveResult, - val smartCast: KtType?, - val possibleTypes: Set + val smartCast: KotlinType?, + val possibleTypes: Set ) data class ExtractionData( @@ -175,7 +175,7 @@ data class ExtractionData( else Collections.emptyMap() } - fun getPossibleTypes(expression: KtExpression, resolvedCall: ResolvedCall<*>?, context: BindingContext): Set { + fun getPossibleTypes(expression: KtExpression, resolvedCall: ResolvedCall<*>?, context: BindingContext): Set { val typeInfo = context[BindingContext.EXPRESSION_TYPE_INFO, expression] ?: return emptySet() (resolvedCall?.getImplicitReceiverValue() as? ThisReceiver)?.let { @@ -201,8 +201,8 @@ data class ExtractionData( val offset = ref.getTextRange()!!.getStartOffset() - startOffset val originalResolveResult = refOffsetToDeclaration[offset] ?: continue - val smartCast: KtType? - val possibleTypes: Set + val smartCast: KotlinType? + val possibleTypes: Set // Qualified property reference: a.b val qualifiedExpression = ref.getQualifiedExpressionForSelector() diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/extractableAnalysisUtil.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/extractableAnalysisUtil.kt index 9c62dbac14b..8d34bd88d45 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/extractableAnalysisUtil.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/extractableAnalysisUtil.kt @@ -89,8 +89,8 @@ import org.jetbrains.kotlin.utils.DFS.Neighbors import org.jetbrains.kotlin.utils.DFS.VisitedWithSet import java.util.* -internal val KotlinBuiltIns.defaultReturnType: KtType get() = unitType -internal val KotlinBuiltIns.defaultParameterType: KtType get() = nullableAnyType +internal val KotlinBuiltIns.defaultReturnType: KotlinType get() = unitType +internal val KotlinBuiltIns.defaultParameterType: KotlinType get() = nullableAnyType private fun DeclarationDescriptor.renderForMessage(): String = IdeDescriptorRenderers.SOURCE_CODE_SHORT_NAMES_IN_TYPES.render(this) @@ -99,12 +99,12 @@ private val TYPE_RENDERER = DescriptorRenderer.FQ_NAMES_IN_TYPES.withOptions { typeNormalizer = IdeDescriptorRenderers.APPROXIMATE_FLEXIBLE_TYPES } -private fun KtType.renderForMessage(): String = TYPE_RENDERER.renderType(this) +private fun KotlinType.renderForMessage(): String = TYPE_RENDERER.renderType(this) private fun KtDeclaration.renderForMessage(bindingContext: BindingContext): String? = bindingContext[BindingContext.DECLARATION_TO_DESCRIPTOR, this]?.renderForMessage() -internal fun KtType.isDefault(): Boolean = KotlinBuiltIns.isUnit(this) +internal fun KotlinType.isDefault(): Boolean = KotlinBuiltIns.isUnit(this) private fun List.getModifiedVarDescriptors(bindingContext: BindingContext): Map> { val result = HashMap>() @@ -149,7 +149,7 @@ private fun List.getResultTypeAndExpressions( targetScope: LexicalScope?, options: ExtractionOptions, module: ModuleDescriptor -): Pair> { +): Pair> { fun instructionToExpression(instruction: Instruction, unwrapReturn: Boolean): KtExpression? { return when (instruction) { is ReturnValueInstruction -> @@ -160,7 +160,7 @@ private fun List.getResultTypeAndExpressions( } } - fun instructionToType(instruction: Instruction): KtType? { + fun instructionToType(instruction: Instruction): KotlinType? { val expression = instructionToExpression(instruction, true) if (expression == null) return null @@ -214,7 +214,7 @@ private fun getCommonNonTrivialSuccessorIfAny(instructions: List): return singleSuccessorCheckingVisitor.target ?: instructions.firstOrNull()?.owner?.getSinkInstruction() } -private fun KtType.isMeaningful(): Boolean { +private fun KotlinType.isMeaningful(): Boolean { return !KotlinBuiltIns.isUnit(this) && !KotlinBuiltIns.isNothing(this) } @@ -415,16 +415,16 @@ fun ExtractionData.createTemporaryDeclaration(functionText: String): KtNamedDecl private fun ExtractionData.createTemporaryCodeBlock(): KtBlockExpression = (createTemporaryDeclaration("fun() {\n$codeFragmentText\n}\n") as KtNamedFunction).getBodyExpression() as KtBlockExpression -private fun KtType.collectReferencedTypes(processTypeArguments: Boolean): List { +private fun KotlinType.collectReferencedTypes(processTypeArguments: Boolean): List { if (!processTypeArguments) return Collections.singletonList(this) return DFS.dfsFromNode( this, - object: Neighbors { - override fun getNeighbors(current: KtType): Iterable = current.getArguments().map { it.getType() } + object: Neighbors { + override fun getNeighbors(current: KotlinType): Iterable = current.getArguments().map { it.getType() } }, VisitedWithSet(), - object: CollectingNodeHandler>(ArrayList()) { - override fun afterChildren(current: KtType) { + object: CollectingNodeHandler>(ArrayList()) { + override fun afterChildren(current: KotlinType) { result.add(current) } } @@ -437,7 +437,7 @@ fun KtTypeParameter.collectRelevantConstraints(): List { return typeConstraints.filter { it.getSubjectTypeParameterName()?.mainReference?.resolve() == this} } -fun TypeParameter.collectReferencedTypes(bindingContext: BindingContext): List { +fun TypeParameter.collectReferencedTypes(bindingContext: BindingContext): List { val typeRefs = ArrayList() originalDeclaration.getExtendsBound()?.let { typeRefs.add(it) } originalConstraints @@ -449,7 +449,7 @@ fun TypeParameter.collectReferencedTypes(bindingContext: BindingContext): List val parameterTypeDescriptor = typeToCheck.getConstructor().getDeclarationDescriptor() as? TypeParameterDescriptor val typeParameter = parameterTypeDescriptor?.let { @@ -460,9 +460,9 @@ private fun KtType.isExtractable(targetScope: LexicalScope?): Boolean { } } -private fun KtType.processTypeIfExtractable( +private fun KotlinType.processTypeIfExtractable( typeParameters: MutableSet, - nonDenotableTypes: MutableSet, + nonDenotableTypes: MutableSet, options: ExtractionOptions, targetScope: LexicalScope?, processTypeArguments: Boolean = true @@ -501,17 +501,17 @@ private class MutableParameter( override val originalDescriptor: DeclarationDescriptor, override val receiverCandidate: Boolean, private val targetScope: LexicalScope?, - private val originalType: KtType, - private val possibleTypes: Set + private val originalType: KotlinType, + private val possibleTypes: Set ): Parameter { // All modifications happen in the same thread private var writable: Boolean = true - private val defaultTypes = LinkedHashSet() + private val defaultTypes = LinkedHashSet() private val typePredicates = HashSet() var refCount: Int = 0 - fun addDefaultType(jetType: KtType) { + fun addDefaultType(jetType: KotlinType) { assert(writable) { "Can't add type to non-writable parameter $currentName" } if (jetType in possibleTypes) { @@ -529,7 +529,7 @@ private class MutableParameter( override var mirrorVarName: String? = null - private val defaultType: KtType by lazy { + private val defaultType: KotlinType by lazy { writable = false if (defaultTypes.isNotEmpty()) { TypeIntersector.intersectTypes(KotlinTypeChecker.DEFAULT, defaultTypes)!! @@ -537,14 +537,14 @@ private class MutableParameter( else originalType } - private val parameterTypeCandidates: List by lazy { + private val parameterTypeCandidates: List by lazy { writable = false val typePredicate = and(typePredicates) val typeSet = if (defaultType.isFlexible()) { val bounds = defaultType.getCapability(javaClass())!! - LinkedHashSet().apply { + LinkedHashSet().apply { if (typePredicate(bounds.upperBound)) add(bounds.upperBound) if (typePredicate(bounds.lowerBound)) add(bounds.lowerBound) } @@ -564,7 +564,7 @@ private class MutableParameter( typeSet.toList() } - override fun getParameterTypeCandidates(allowSpecialClassNames: Boolean): List { + override fun getParameterTypeCandidates(allowSpecialClassNames: Boolean): List { return if (!allowSpecialClassNames) { parameterTypeCandidates.filter { it.isExtractable(targetScope) } } else { @@ -572,19 +572,19 @@ private class MutableParameter( } } - override fun getParameterType(allowSpecialClassNames: Boolean): KtType { + override fun getParameterType(allowSpecialClassNames: Boolean): KotlinType { return getParameterTypeCandidates(allowSpecialClassNames).firstOrNull() ?: defaultType } - override fun copy(name: String, parameterType: KtType): Parameter = DelegatingParameter(this, name, parameterType) + override fun copy(name: String, parameterType: KotlinType): Parameter = DelegatingParameter(this, name, parameterType) } private class DelegatingParameter( val original: Parameter, override val name: String, - val parameterType: KtType + val parameterType: KotlinType ): Parameter by original { - override fun copy(name: String, parameterType: KtType): Parameter = DelegatingParameter(original, name, parameterType) + override fun copy(name: String, parameterType: KotlinType): Parameter = DelegatingParameter(original, name, parameterType) override fun getParameterType(allowSpecialClassNames: Boolean) = parameterType } @@ -594,7 +594,7 @@ private class ParametersInfo { val originalRefToParameter: MutableMap = HashMap() val parameters: MutableSet = HashSet() val typeParameters: MutableSet = HashSet() - val nonDenotableTypes: MutableSet = HashSet() + val nonDenotableTypes: MutableSet = HashSet() } private fun ExtractionData.inferParametersInfo( @@ -615,7 +615,7 @@ private fun ExtractionData.inferParametersInfo( receiverToExtract: ReceiverValue, resolvedCall: ResolvedCall<*>?, useSmartCastsIfPossible: Boolean - ): KtType { + ): KotlinType { val builtIns = originalDescriptor.builtIns return when { extractFunctionRef -> { @@ -809,7 +809,7 @@ private fun ExtractionData.inferParametersInfo( } } - for (typeToCheck in info.typeParameters.flatMapTo(HashSet()) { it.collectReferencedTypes(bindingContext) }) { + for (typeToCheck in info.typeParameters.flatMapTo(HashSet()) { it.collectReferencedTypes(bindingContext) }) { typeToCheck.processTypeIfExtractable(info.typeParameters, info.nonDenotableTypes, options, targetScope) } @@ -951,7 +951,7 @@ fun ExtractionData.performAnalysis(): AnalysisResult { ) } -private fun ExtractionData.suggestFunctionNames(returnType: KtType): List { +private fun ExtractionData.suggestFunctionNames(returnType: KotlinType): List { val functionNames = LinkedHashSet() val validator = diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/extractorUtil.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/extractorUtil.kt index 110b7bcf1ef..f26c5e58270 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/extractorUtil.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/extractorUtil.kt @@ -50,7 +50,7 @@ import org.jetbrains.kotlin.psi.psiUtil.* import org.jetbrains.kotlin.renderer.DescriptorRenderer import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.calls.callUtil.getCalleeExpressionIfAny -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.isFlexible import org.jetbrains.kotlin.types.typeUtil.builtIns import java.util.ArrayList @@ -84,7 +84,7 @@ fun ExtractionGeneratorConfiguration.getDeclarationText( } ) - fun KtType.typeAsString(): String { + fun KotlinType.typeAsString(): String { return if (descriptor.extractionData.options.allowSpecialClassNames && isSpecial()) DEBUG_TYPE_REFERENCE_STRING else descriptorRenderer.renderType(this) } @@ -127,7 +127,7 @@ fun ExtractionGeneratorConfiguration.getDeclarationText( } } -fun KtType.isSpecial(): Boolean { +fun KotlinType.isSpecial(): Boolean { val classDescriptor = this.constructor.declarationDescriptor as? ClassDescriptor ?: return false return classDescriptor.name.isSpecial || DescriptorUtils.isLocal(classDescriptor) } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinInplaceParameterIntroducer.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinInplaceParameterIntroducer.kt index 4c7119ae4ea..4f7be4509c1 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinInplaceParameterIntroducer.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinInplaceParameterIntroducer.kt @@ -38,7 +38,7 @@ import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.getElementTextWithContext import org.jetbrains.kotlin.psi.psiUtil.getValueParameterList import org.jetbrains.kotlin.psi.psiUtil.getValueParameters -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.typeUtil.supertypes import org.jetbrains.kotlin.utils.addToStdlib.singletonList import java.awt.Color @@ -47,7 +47,7 @@ import javax.swing.JCheckBox public class KotlinInplaceParameterIntroducer( val originalDescriptor: IntroduceParameterDescriptor, - val parameterType: KtType, + val parameterType: KotlinType, val suggestedNames: Array, project: Project, editor: Editor diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterDialog.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterDialog.kt index c76c6e0826f..bc6af555e9a 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterDialog.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterDialog.kt @@ -39,7 +39,7 @@ import org.jetbrains.kotlin.idea.refactoring.introduce.extractionEngine.* import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.resolve.AnalyzingUtils -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import java.awt.GridBagConstraints import java.awt.GridBagLayout import java.awt.Insets @@ -56,7 +56,7 @@ public class KotlinIntroduceParameterDialog private constructor( val descriptor: IntroduceParameterDescriptor, val lambdaExtractionDescriptor: ExtractableCodeDescriptor?, nameSuggestions: Array, - val typeSuggestions: List, + val typeSuggestions: List, val helper: KotlinIntroduceParameterHelper ): RefactoringDialog(project, true) { constructor( @@ -64,7 +64,7 @@ public class KotlinIntroduceParameterDialog private constructor( editor: Editor, descriptor: IntroduceParameterDescriptor, nameSuggestions: Array, - typeSuggestions: List, + typeSuggestions: List, helper: KotlinIntroduceParameterHelper ): this(project, editor, descriptor, null, nameSuggestions, typeSuggestions, helper) diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceProperty/KotlinInplacePropertyIntroducer.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceProperty/KotlinInplacePropertyIntroducer.kt index b519867a694..e30848e327a 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceProperty/KotlinInplacePropertyIntroducer.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceProperty/KotlinInplacePropertyIntroducer.kt @@ -36,7 +36,7 @@ import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.psi.KtProperty import org.jetbrains.kotlin.psi.psiUtil.getElementTextWithContext import org.jetbrains.kotlin.psi.psiUtil.parentsWithSelf -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import javax.swing.* import javax.swing.event.PopupMenuEvent @@ -46,7 +46,7 @@ public class KotlinInplacePropertyIntroducer( project: Project, title: String, doNotChangeVar: Boolean, - exprType: KtType?, + exprType: KotlinType?, extractionResult: ExtractionResult, private val availableTargets: List ): KotlinInplaceVariableIntroducer( diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinInplaceVariableIntroducer.java b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinInplaceVariableIntroducer.java index b54376a1507..4bdd6df3458 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinInplaceVariableIntroducer.java +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinInplaceVariableIntroducer.java @@ -46,7 +46,7 @@ import org.jetbrains.kotlin.idea.references.ReferenceUtilKt; import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers; import org.jetbrains.kotlin.lexer.KtTokens; import org.jetbrains.kotlin.psi.*; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import javax.swing.*; import java.awt.*; @@ -120,7 +120,7 @@ public class KotlinInplaceVariableIntroducer ex protected D myDeclaration; private final boolean isVar; private final boolean myDoNotChangeVar; - @Nullable private final KtType myExprType; + @Nullable private final KotlinType myExprType; private final boolean noTypeInference; private final List panelControls = new ArrayList(); private JPanel contentPanel; @@ -130,7 +130,7 @@ public class KotlinInplaceVariableIntroducer ex String title, KtExpression[] occurrences, @Nullable KtExpression expr, boolean replaceOccurrence, D declaration, boolean isVar, boolean doNotChangeVar, - @Nullable KtType exprType, boolean noTypeInference + @Nullable KotlinType exprType, boolean noTypeInference ) { super(elementToRename, editor, project, title, occurrences, expr); this.myReplaceOccurrence = replaceOccurrence; diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinIntroduceVariableHandler.java b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinIntroduceVariableHandler.java index 5126d0100b2..92fc8a002cd 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinIntroduceVariableHandler.java +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinIntroduceVariableHandler.java @@ -64,7 +64,7 @@ import org.jetbrains.kotlin.resolve.bindingContextUtil.BindingContextUtilsKt; import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo; import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode; import org.jetbrains.kotlin.resolve.scopes.KtScope; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.checker.KotlinTypeChecker; import java.util.ArrayList; @@ -137,13 +137,13 @@ public class KotlinIntroduceVariableHandler extends KotlinIntroduceHandlerBase { AnalysisResult analysisResult = ResolutionUtils.analyzeAndGetResult(expression); final BindingContext bindingContext = analysisResult.getBindingContext(); - final KtType expressionType = bindingContext.getType(expression); //can be null or error type + final KotlinType expressionType = bindingContext.getType(expression); //can be null or error type KtScope scope = bindingContext.get(BindingContext.RESOLUTION_SCOPE, expression); if (scope != null) { DataFlowInfo dataFlowInfo = BindingContextUtilsKt.getDataFlowInfo(bindingContext, expression); ObservableBindingTrace bindingTrace = new ObservableBindingTrace(new BindingTraceContext()); - KtType typeNoExpectedType = AnalyzerUtilKt.computeTypeInfoInContext( + KotlinType typeNoExpectedType = AnalyzerUtilKt.computeTypeInfoInContext( expression, scope, expression, bindingTrace, dataFlowInfo ).getType(); if (expressionType != null && typeNoExpectedType != null && !KotlinTypeChecker.DEFAULT.equalTypes(expressionType, @@ -271,7 +271,7 @@ public class KotlinIntroduceVariableHandler extends KotlinIntroduceHandlerBase { final ArrayList references, final Ref reference, final boolean noTypeInference, - final KtType expressionType, + final KotlinType expressionType, final BindingContext bindingContext ) { final KtPsiFactory psiFactory = KtPsiFactoryKt.KtPsiFactory(expression); diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinVariableInplaceIntroducer.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinVariableInplaceIntroducer.kt index e015072c6d1..fc2a82a9a12 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinVariableInplaceIntroducer.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinVariableInplaceIntroducer.kt @@ -37,7 +37,7 @@ import org.jetbrains.kotlin.psi.KtExpression import org.jetbrains.kotlin.psi.KtProperty import org.jetbrains.kotlin.psi.KtPsiFactory import org.jetbrains.kotlin.psi.psiUtil.startOffset -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import java.awt.BorderLayout public class KotlinVariableInplaceIntroducer( @@ -47,7 +47,7 @@ public class KotlinVariableInplaceIntroducer( suggestedNames: Collection, val isVar: Boolean, val doNotChangeVar: Boolean, - val expressionType: KtType?, + val expressionType: KotlinType?, val noTypeInference: Boolean, project: Project, editor: Editor diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/AutomaticVariableRenamer.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/AutomaticVariableRenamer.kt index 6876b2c1c60..ce7e5b2890a 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/AutomaticVariableRenamer.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/AutomaticVariableRenamer.kt @@ -41,7 +41,7 @@ import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns import org.jetbrains.kotlin.resolve.lazy.NoDescriptorForDeclarationException import org.jetbrains.kotlin.resolve.source.PsiSourceElement -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import java.util.* public class AutomaticVariableRenamer( @@ -108,7 +108,7 @@ public class AutomaticVariableRenamer( } } -private fun KtType.isCollectionLikeOf(classPsiElement: PsiNamedElement): Boolean { +private fun KotlinType.isCollectionLikeOf(classPsiElement: PsiNamedElement): Boolean { val klass = this.getConstructor().getDeclarationDescriptor() as? ClassDescriptor ?: return false if (KotlinBuiltIns.isArray(this) || DescriptorUtils.isSubclass(klass, klass.builtIns.getCollection())) { val typeArgument = this.getArguments().singleOrNull()?.getType() ?: return false diff --git a/idea/src/org/jetbrains/kotlin/idea/run/JetRunConfigurationType.java b/idea/src/org/jetbrains/kotlin/idea/run/JetRunConfigurationType.java index f6c162fa047..743fe9656a9 100644 --- a/idea/src/org/jetbrains/kotlin/idea/run/JetRunConfigurationType.java +++ b/idea/src/org/jetbrains/kotlin/idea/run/JetRunConfigurationType.java @@ -19,7 +19,7 @@ package org.jetbrains.kotlin.idea.run; import com.intellij.execution.configurations.*; import com.intellij.openapi.project.Project; import org.jetbrains.annotations.NotNull; -import org.jetbrains.kotlin.idea.KtIcons; +import org.jetbrains.kotlin.idea.KotlinIcons; import org.jetbrains.kotlin.idea.KotlinLanguage; public class JetRunConfigurationType extends ConfigurationTypeBase { @@ -28,7 +28,7 @@ public class JetRunConfigurationType extends ConfigurationTypeBase { } public JetRunConfigurationType() { - super("JetRunConfigurationType", KotlinLanguage.NAME, KotlinLanguage.NAME, KtIcons.LAUNCH); + super("JetRunConfigurationType", KotlinLanguage.NAME, KotlinLanguage.NAME, KotlinIcons.LAUNCH); addFactory(new JetRunConfigurationFactory(this)); } diff --git a/idea/src/org/jetbrains/kotlin/idea/util/psi/patternMatching/JetPsiUnifier.kt b/idea/src/org/jetbrains/kotlin/idea/util/psi/patternMatching/JetPsiUnifier.kt index c03ad8ee5d4..0878cfe2e10 100644 --- a/idea/src/org/jetbrains/kotlin/idea/util/psi/patternMatching/JetPsiUnifier.kt +++ b/idea/src/org/jetbrains/kotlin/idea/util/psi/patternMatching/JetPsiUnifier.kt @@ -25,7 +25,7 @@ import org.jetbrains.kotlin.psi.KtPsiUtil import com.intellij.psi.PsiElement import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import com.intellij.util.containers.ContainerUtil import org.jetbrains.kotlin.types.checker.KotlinTypeChecker import java.util.Collections @@ -125,7 +125,7 @@ public interface UnificationResult { public class UnifierParameter( val descriptor: DeclarationDescriptor, - val expectedType: KtType + val expectedType: KotlinType ) public class JetPsiUnifier( @@ -353,12 +353,12 @@ public class JetPsiUnifier( } } - private fun KtTypeReference.getType(): KtType? { + private fun KtTypeReference.getType(): KotlinType? { val t = bindingContext[BindingContext.TYPE, this] return if (t == null || t.isError()) null else t } - private fun matchTypes(type1: KtType?, type2: KtType?): Status? { + private fun matchTypes(type1: KotlinType?, type2: KotlinType?): Status? { if (type1 != null && type2 != null) { if (type1.isError() || type2.isError()) return null if (TypeUtils.equalTypes(type1, type2)) return MATCHED @@ -381,8 +381,8 @@ public class JetPsiUnifier( return if (type1 == null && type2 == null) null else UNMATCHED } - private fun matchTypes(types1: Collection, types2: Collection): Boolean { - fun sortTypes(types: Collection) = types.sortedBy { DescriptorRenderer.DEBUG_TEXT.renderType(it) } + private fun matchTypes(types1: Collection, types2: Collection): Boolean { + fun sortTypes(types: Collection) = types.sortedBy { DescriptorRenderer.DEBUG_TEXT.renderType(it) } if (types1.size() != types2.size()) return false return (sortTypes(types1) zip sortTypes(types2)).all { matchTypes(it.first, it.second) == MATCHED } diff --git a/idea/tests/org/jetbrains/kotlin/idea/resolve/AbstractPartialBodyResolveTest.kt b/idea/tests/org/jetbrains/kotlin/idea/resolve/AbstractPartialBodyResolveTest.kt index 2df7caf6cb1..d258702c351 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/resolve/AbstractPartialBodyResolveTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/resolve/AbstractPartialBodyResolveTest.kt @@ -28,7 +28,7 @@ import org.jetbrains.kotlin.test.JetTestUtils import java.io.File import org.jetbrains.kotlin.psi.KtBlockExpression import org.junit.Assert -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.renderer.DescriptorRenderer import org.jetbrains.kotlin.descriptors.VariableDescriptor import org.jetbrains.kotlin.psi.KtSimpleNameExpression @@ -138,7 +138,7 @@ public abstract class AbstractPartialBodyResolveTest : JetLightCodeInsightFixtur private data class ResolveData( val target: DeclarationDescriptor?, - val type: KtType?, + val type: KotlinType?, val processedStatements: Collection ) @@ -162,7 +162,7 @@ public abstract class AbstractPartialBodyResolveTest : JetLightCodeInsightFixtur return ResolveData(target, type, processedStatements) } - private fun DeclarationDescriptor?.presentation(type: KtType?): String { + private fun DeclarationDescriptor?.presentation(type: KotlinType?): String { if (this == null) return "null" val s = DescriptorRenderer.COMPACT.render(this) @@ -172,7 +172,7 @@ public abstract class AbstractPartialBodyResolveTest : JetLightCodeInsightFixtur return "$s smart-cast to ${type.presentation()}" } - private fun KtType?.presentation() + private fun KotlinType?.presentation() = if (this != null) DescriptorRenderer.COMPACT.renderType(this) else "unknown type" private fun KtExpression.compactPresentation(): String { diff --git a/js/js.frontend/src/org/jetbrains/kotlin/js/descriptorUtils/descriptorUtils.kt b/js/js.frontend/src/org/jetbrains/kotlin/js/descriptorUtils/descriptorUtils.kt index d0292ab0eb8..98119abbde2 100644 --- a/js/js.frontend/src/org/jetbrains/kotlin/js/descriptorUtils/descriptorUtils.kt +++ b/js/js.frontend/src/org/jetbrains/kotlin/js/descriptorUtils/descriptorUtils.kt @@ -22,9 +22,9 @@ import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType -public val KtType.nameIfStandardType: Name? +public val KotlinType.nameIfStandardType: Name? get() { val descriptor = getConstructor().getDeclarationDescriptor() @@ -35,7 +35,7 @@ public val KtType.nameIfStandardType: Name? return null } -public fun KtType.getJetTypeFqName(printTypeArguments: Boolean): String { +public fun KotlinType.getJetTypeFqName(printTypeArguments: Boolean): String { val declaration = requireNotNull(getConstructor().getDeclarationDescriptor()) if (declaration is TypeParameterDescriptor) { return StringUtil.join(declaration.getUpperBounds(), { type -> type.getJetTypeFqName(printTypeArguments) }, "&") diff --git a/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/diagnostics/ErrorsJs.java b/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/diagnostics/ErrorsJs.java index f1856e7e433..651b56d16c5 100644 --- a/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/diagnostics/ErrorsJs.java +++ b/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/diagnostics/ErrorsJs.java @@ -24,14 +24,14 @@ import org.jetbrains.kotlin.psi.KtDeclaration; import org.jetbrains.kotlin.psi.KtElement; import org.jetbrains.kotlin.psi.KtExpression; import org.jetbrains.kotlin.psi.KtNamedDeclaration; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import static org.jetbrains.kotlin.diagnostics.PositioningStrategies.*; import static org.jetbrains.kotlin.diagnostics.Severity.ERROR; import static org.jetbrains.kotlin.diagnostics.Severity.WARNING; public interface ErrorsJs { - DiagnosticFactory1 NATIVE_ANNOTATIONS_ALLOWED_ONLY_ON_MEMBER_OR_EXTENSION_FUN = DiagnosticFactory1.create(ERROR, DECLARATION_SIGNATURE_OR_DEFAULT); + DiagnosticFactory1 NATIVE_ANNOTATIONS_ALLOWED_ONLY_ON_MEMBER_OR_EXTENSION_FUN = DiagnosticFactory1.create(ERROR, DECLARATION_SIGNATURE_OR_DEFAULT); DiagnosticFactory1 NATIVE_INDEXER_KEY_SHOULD_BE_STRING_OR_NUMBER = DiagnosticFactory1.create(ERROR, DECLARATION_SIGNATURE_OR_DEFAULT); DiagnosticFactory1 NATIVE_INDEXER_CAN_NOT_HAVE_DEFAULT_ARGUMENTS = DiagnosticFactory1.create(ERROR, DECLARATION_SIGNATURE_OR_DEFAULT); DiagnosticFactory0 NATIVE_GETTER_RETURN_TYPE_SHOULD_BE_NULLABLE = DiagnosticFactory0.create(ERROR, DECLARATION_RETURN_TYPE); diff --git a/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinJavascriptAnnotationAndConstantLoader.kt b/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinJavascriptAnnotationAndConstantLoader.kt index 6d34e86f932..b05bd1381eb 100644 --- a/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinJavascriptAnnotationAndConstantLoader.kt +++ b/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinJavascriptAnnotationAndConstantLoader.kt @@ -23,7 +23,7 @@ import org.jetbrains.kotlin.descriptors.annotations.AnnotationWithTarget import org.jetbrains.kotlin.resolve.constants.ConstantValue import org.jetbrains.kotlin.serialization.ProtoBuf import org.jetbrains.kotlin.serialization.deserialization.* -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType class KotlinJavascriptAnnotationAndConstantLoader( module: ModuleDescriptor @@ -82,7 +82,7 @@ class KotlinJavascriptAnnotationAndConstantLoader( override fun loadPropertyConstant( container: ProtoContainer, proto: ProtoBuf.Property, - expectedType: KtType + expectedType: KotlinType ): ConstantValue<*>? { if (!proto.hasExtension(JsProtoBuf.compileTimeValue)) return null val value = proto.getExtension(JsProtoBuf.compileTimeValue) diff --git a/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinJavascriptSerializerExtension.kt b/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinJavascriptSerializerExtension.kt index a477e544f54..4c3c457e112 100644 --- a/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinJavascriptSerializerExtension.kt +++ b/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinJavascriptSerializerExtension.kt @@ -22,7 +22,7 @@ import org.jetbrains.kotlin.serialization.AnnotationSerializer import org.jetbrains.kotlin.serialization.ProtoBuf import org.jetbrains.kotlin.serialization.SerializerExtension import org.jetbrains.kotlin.serialization.StringTableImpl -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType public class KotlinJavascriptSerializerExtension : SerializerExtension() { private val stringTable = StringTableImpl() @@ -64,7 +64,7 @@ public class KotlinJavascriptSerializerExtension : SerializerExtension() { } } - override fun serializeType(type: KtType, proto: ProtoBuf.Type.Builder) { + override fun serializeType(type: KotlinType, proto: ProtoBuf.Type.Builder) { for (annotation in type.annotations) { proto.addExtension(JsProtoBuf.typeAnnotation, annotationSerializer.serializeAnnotation(annotation)) } diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/declaration/ClassTranslator.kt b/js/js.translator/src/org/jetbrains/kotlin/js/translate/declaration/ClassTranslator.kt index 15a6f5779b1..fc821f07365 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/declaration/ClassTranslator.kt +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/declaration/ClassTranslator.kt @@ -48,7 +48,7 @@ import org.jetbrains.kotlin.psi.KtObjectDeclaration import org.jetbrains.kotlin.psi.KtSecondaryConstructor import org.jetbrains.kotlin.resolve.BindingContextUtils import org.jetbrains.kotlin.resolve.DescriptorUtils.* -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeConstructor import org.jetbrains.kotlin.types.TypeUtils.topologicallySortSuperclassesAndRecordAllInstances import org.jetbrains.kotlin.utils.identity @@ -190,7 +190,7 @@ public class ClassTranslator private constructor( for (type in supertypes) { supertypeConstructors.add(type.getConstructor()) } - val sortedAllSuperTypes = topologicallySortSuperclassesAndRecordAllInstances(descriptor.getDefaultType(), HashMap>(), HashSet()) + val sortedAllSuperTypes = topologicallySortSuperclassesAndRecordAllInstances(descriptor.getDefaultType(), HashMap>(), HashSet()) val supertypesRefs = ArrayList() for (typeConstructor in sortedAllSuperTypes) { if (supertypeConstructors.contains(typeConstructor)) { diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/declaration/DeclarationBodyVisitor.java b/js/js.translator/src/org/jetbrains/kotlin/js/translate/declaration/DeclarationBodyVisitor.java index c7ef6c6be8f..9d824cfc23e 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/declaration/DeclarationBodyVisitor.java +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/declaration/DeclarationBodyVisitor.java @@ -33,7 +33,7 @@ import org.jetbrains.kotlin.js.translate.initializer.ClassInitializerTranslator; import org.jetbrains.kotlin.js.translate.utils.BindingUtils; import org.jetbrains.kotlin.js.translate.utils.TranslationUtils; import org.jetbrains.kotlin.psi.*; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import java.util.List; @@ -75,7 +75,7 @@ public class DeclarationBodyVisitor extends TranslatorVisitor { public Void visitEnumEntry(@NotNull KtEnumEntry enumEntry, TranslationContext data) { JsExpression jsEnumEntryCreation; ClassDescriptor descriptor = getClassDescriptor(data.bindingContext(), enumEntry); - List supertypes = getSupertypesWithoutFakes(descriptor); + List supertypes = getSupertypesWithoutFakes(descriptor); if (enumEntry.getBody() != null || supertypes.size() > 1) { jsEnumEntryCreation = ClassTranslator.generateClassCreation(enumEntry, data); } else { diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/expression/ExpressionVisitor.java b/js/js.translator/src/org/jetbrains/kotlin/js/translate/expression/ExpressionVisitor.java index ca656a2eb8e..0e4de84eaca 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/expression/ExpressionVisitor.java +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/expression/ExpressionVisitor.java @@ -45,7 +45,7 @@ import org.jetbrains.kotlin.resolve.constants.ConstantValue; import org.jetbrains.kotlin.resolve.constants.NullValue; import org.jetbrains.kotlin.resolve.constants.evaluate.ConstantExpressionEvaluator; import org.jetbrains.kotlin.resolve.inline.InlineUtil; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.TypeUtils; import java.util.List; @@ -77,7 +77,7 @@ public final class ExpressionVisitor extends TranslatorVisitor { private static JsNode translateConstantExpression(@NotNull KtConstantExpression expression, @NotNull TranslationContext context) { CompileTimeConstant compileTimeValue = ConstantExpressionEvaluator.getConstant(expression, context.bindingContext()); assert compileTimeValue != null : message(expression, "Expression is not compile time value: " + expression.getText() + " "); - KtType expectedType = context.bindingContext().getType(expression); + KotlinType expectedType = context.bindingContext().getType(expression); ConstantValue constant = compileTimeValue.toConstantValue(expectedType != null ? expectedType : TypeUtils.NO_EXPECTED_TYPE); if (constant instanceof NullValue) { return JsLiteral.NULL; @@ -362,8 +362,8 @@ public final class ExpressionVisitor extends TranslatorVisitor { KtTypeReference right = expression.getRight(); assert right != null; - KtType rightType = BindingContextUtils.getNotNull(context.bindingContext(), BindingContext.TYPE, right); - KtType leftType = BindingContextUtils.getTypeNotNull(context.bindingContext(), expression.getLeft()); + KotlinType rightType = BindingContextUtils.getNotNull(context.bindingContext(), BindingContext.TYPE, right); + KotlinType leftType = BindingContextUtils.getTypeNotNull(context.bindingContext(), expression.getLeft()); if (TypeUtils.isNullableType(rightType) || !TypeUtils.isNullableType(leftType)) { return jsExpression.source(expression); } diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/expression/PatternTranslator.java b/js/js.translator/src/org/jetbrains/kotlin/js/translate/expression/PatternTranslator.java index f5421b04d75..5eaf2e46144 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/expression/PatternTranslator.java +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/expression/PatternTranslator.java @@ -33,7 +33,7 @@ import org.jetbrains.kotlin.psi.KtExpression; import org.jetbrains.kotlin.psi.KtIsExpression; import org.jetbrains.kotlin.psi.KtTypeReference; import org.jetbrains.kotlin.resolve.DescriptorUtils; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import static org.jetbrains.kotlin.js.translate.utils.BindingUtils.getTypeByReference; import static org.jetbrains.kotlin.js.translate.utils.JsAstUtils.*; @@ -63,7 +63,7 @@ public final class PatternTranslator extends AbstractTranslator { @NotNull public JsExpression translateIsCheck(@NotNull JsExpression subject, @NotNull KtTypeReference typeReference) { - KtType type = BindingUtils.getTypeByReference(bindingContext(), typeReference); + KotlinType type = BindingUtils.getTypeByReference(bindingContext(), typeReference); JsExpression checkFunReference = getIsTypeCheckCallable(type); JsInvocation isCheck = new JsInvocation(checkFunReference, subject); @@ -75,7 +75,7 @@ public final class PatternTranslator extends AbstractTranslator { } @NotNull - public JsExpression getIsTypeCheckCallable(@NotNull KtType type) { + public JsExpression getIsTypeCheckCallable(@NotNull KotlinType type) { JsExpression builtinCheck = getIsTypeCheckCallableForBuiltin(type); if (builtinCheck != null) return builtinCheck; @@ -94,7 +94,7 @@ public final class PatternTranslator extends AbstractTranslator { } @Nullable - private JsExpression getIsTypeCheckCallableForBuiltin(@NotNull KtType type) { + private JsExpression getIsTypeCheckCallableForBuiltin(@NotNull KotlinType type) { Name typeName = DescriptorUtilsKt.getNameIfStandardType(type); if (NamePredicate.STRING.apply(typeName)) { @@ -147,7 +147,7 @@ public final class PatternTranslator extends AbstractTranslator { } @NotNull - private JsNameRef getClassNameReference(@NotNull KtType type) { + private JsNameRef getClassNameReference(@NotNull KotlinType type) { ClassDescriptor referencedClass = DescriptorUtils.getClassDescriptorForType(type); return context().getQualifiedReference(referencedClass); } diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/expression/StringTemplateTranslator.java b/js/js.translator/src/org/jetbrains/kotlin/js/translate/expression/StringTemplateTranslator.java index 62a8dfda2f9..e42ec00cd38 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/expression/StringTemplateTranslator.java +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/expression/StringTemplateTranslator.java @@ -30,7 +30,7 @@ import org.jetbrains.kotlin.js.translate.general.Translation; import org.jetbrains.kotlin.js.translate.intrinsic.functions.factories.TopLevelFIF; import org.jetbrains.kotlin.name.Name; import org.jetbrains.kotlin.psi.*; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import java.util.Collections; @@ -88,7 +88,7 @@ public final class StringTemplateTranslator extends AbstractTranslator { return; } - KtType type = context().bindingContext().getType(entryExpression); + KotlinType type = context().bindingContext().getType(entryExpression); if (type == null || type.isMarkedNullable()) { append(TopLevelFIF.TO_STRING.apply((JsExpression) null, Collections.singletonList(translatedExpression), context())); } @@ -100,7 +100,7 @@ public final class StringTemplateTranslator extends AbstractTranslator { } } - private boolean mustCallToString(@NotNull KtType type) { + private boolean mustCallToString(@NotNull KotlinType type) { Name typeName = DescriptorUtilsKt.getNameIfStandardType(type); if (typeName != null) { //TODO: this is a hacky optimization, should use some generic approach diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/general/JetTestFunctionDetector.java b/js/js.translator/src/org/jetbrains/kotlin/js/translate/general/JetTestFunctionDetector.java index a4f7d3627de..36a3a473662 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/general/JetTestFunctionDetector.java +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/general/JetTestFunctionDetector.java @@ -32,7 +32,7 @@ import org.jetbrains.kotlin.psi.KtDeclaration; import org.jetbrains.kotlin.psi.KtFile; import org.jetbrains.kotlin.resolve.BindingContext; import org.jetbrains.kotlin.resolve.scopes.KtScope; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import java.util.Collection; import java.util.List; @@ -48,7 +48,7 @@ public class JetTestFunctionDetector { Annotations annotations = functionDescriptor.getAnnotations(); for (AnnotationDescriptor annotation : annotations) { // TODO ideally we should find the fully qualified name here... - KtType type = annotation.getType(); + KotlinType type = annotation.getType(); String name = type.toString(); if (name.equals("Test")) { return true; diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/initializer/ClassInitializerTranslator.java b/js/js.translator/src/org/jetbrains/kotlin/js/translate/initializer/ClassInitializerTranslator.java index 42ea0a08e9b..22d48430304 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/initializer/ClassInitializerTranslator.java +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/initializer/ClassInitializerTranslator.java @@ -32,7 +32,7 @@ import org.jetbrains.kotlin.lexer.KtTokens; import org.jetbrains.kotlin.psi.*; import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilKt; import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import java.util.ArrayList; import java.util.Collections; @@ -114,7 +114,7 @@ public final class ClassInitializerTranslator extends AbstractTranslator { } @NotNull - public JsExpression generateEnumEntryInstanceCreation(@NotNull KtType enumClassType) { + public JsExpression generateEnumEntryInstanceCreation(@NotNull KotlinType enumClassType) { ResolvedCall superCall = getSuperCall(); if (superCall == null) { diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/intrinsic/functions/factories/TopLevelFIF.java b/js/js.translator/src/org/jetbrains/kotlin/js/translate/intrinsic/functions/factories/TopLevelFIF.java index b3f045cd403..c8865ece84c 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/intrinsic/functions/factories/TopLevelFIF.java +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/intrinsic/functions/factories/TopLevelFIF.java @@ -38,7 +38,7 @@ import org.jetbrains.kotlin.psi.KtReferenceExpression; import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall; import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver; import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import java.util.List; @@ -219,7 +219,7 @@ public final class TopLevelFIF extends CompositeFIF { @NotNull List arguments, @NotNull TranslationContext context ) { - KtType keyType = callInfo.getResolvedCall().getTypeArguments().values().iterator().next(); + KotlinType keyType = callInfo.getResolvedCall().getTypeArguments().values().iterator().next(); Name keyTypeName = DescriptorUtilsKt.getNameIfStandardType(keyType); String collectionClassName = null; if (keyTypeName != null) { diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/operation/BinaryOperationTranslator.java b/js/js.translator/src/org/jetbrains/kotlin/js/translate/operation/BinaryOperationTranslator.java index 83d87a607a9..5f445320d5e 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/operation/BinaryOperationTranslator.java +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/operation/BinaryOperationTranslator.java @@ -37,7 +37,7 @@ import org.jetbrains.kotlin.psi.KtExpression; import org.jetbrains.kotlin.resolve.bindingContextUtil.BindingContextUtilsKt; import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilKt; import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.TypeUtils; import org.jetbrains.kotlin.types.expressions.OperatorConventions; @@ -267,8 +267,8 @@ public final class BinaryOperationTranslator extends AbstractTranslator { return new JsBinaryOperation(operator, left, right); } - KtType leftType = context().bindingContext().getType(leftKtExpression); - KtType rightType = context().bindingContext().getType(rightKtExpression); + KotlinType leftType = context().bindingContext().getType(leftKtExpression); + KotlinType rightType = context().bindingContext().getType(rightKtExpression); if (leftType != null && TypeUtils.isNullableType(leftType) || rightType != null && TypeUtils.isNullableType(rightType)) { return mayBeWrapWithNegation(TopLevelFIF.KOTLIN_EQUALS.apply(left, Collections.singletonList(right), context())); diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/operation/UnaryOperationTranslator.java b/js/js.translator/src/org/jetbrains/kotlin/js/translate/operation/UnaryOperationTranslator.java index 520f0a040e1..2e20722f22a 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/operation/UnaryOperationTranslator.java +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/operation/UnaryOperationTranslator.java @@ -34,7 +34,7 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilKt; import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall; import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant; import org.jetbrains.kotlin.resolve.constants.evaluate.ConstantExpressionEvaluator; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import static org.jetbrains.kotlin.js.translate.general.Translation.translateAsExpression; import static org.jetbrains.kotlin.js.translate.utils.BindingUtils.getCompileTimeValue; @@ -55,7 +55,7 @@ public final class UnaryOperationTranslator { IElementType operationToken = expression.getOperationReference().getReferencedNameElementType(); if (operationToken == KtTokens.EXCLEXCL) { KtExpression baseExpression = getBaseExpression(expression); - KtType type = BindingContextUtils.getTypeNotNull(context.bindingContext(), baseExpression); + KotlinType type = BindingContextUtils.getTypeNotNull(context.bindingContext(), baseExpression); JsExpression translatedExpression = translateAsExpression(baseExpression, context); return type.isMarkedNullable() ? sure(translatedExpression, context) : translatedExpression; } diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/reference/CallArgumentTranslator.kt b/js/js.translator/src/org/jetbrains/kotlin/js/translate/reference/CallArgumentTranslator.kt index ca98d5e977b..d04630082d3 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/reference/CallArgumentTranslator.kt +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/reference/CallArgumentTranslator.kt @@ -32,7 +32,7 @@ import org.jetbrains.kotlin.js.translate.utils.* import org.jetbrains.kotlin.psi.KtExpression import org.jetbrains.kotlin.psi.ValueArgument import org.jetbrains.kotlin.resolve.calls.model.* -import org.jetbrains.kotlin.types.KtType +import org.jetbrains.kotlin.types.KotlinType import java.util.ArrayList import java.util.Collections @@ -336,7 +336,7 @@ public class CallArgumentTranslator private constructor( } -private fun Map.addReifiedTypeArgsTo( +private fun Map.addReifiedTypeArgsTo( info: CallArgumentTranslator.ArgumentsInfo, context: TranslationContext ): CallArgumentTranslator.ArgumentsInfo { diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/utils/BindingUtils.java b/js/js.translator/src/org/jetbrains/kotlin/js/translate/utils/BindingUtils.java index db7610a075d..0b5a2b87eb8 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/utils/BindingUtils.java +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/utils/BindingUtils.java @@ -29,7 +29,7 @@ import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall; import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant; import org.jetbrains.kotlin.resolve.constants.evaluate.ConstantExpressionEvaluator; import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.TypeUtils; import java.util.List; @@ -90,7 +90,7 @@ public final class BindingUtils { } @NotNull - public static KtType getTypeByReference(@NotNull BindingContext context, + public static KotlinType getTypeByReference(@NotNull BindingContext context, @NotNull KtTypeReference typeReference) { return BindingContextUtils.getNotNull(context, BindingContext.TYPE, typeReference); } @@ -159,7 +159,7 @@ public final class BindingUtils { @Nullable public static Object getCompileTimeValue(@NotNull BindingContext context, @NotNull KtExpression expression, @NotNull CompileTimeConstant constant) { - KtType expectedType = context.getType(expression); + KotlinType expectedType = context.getType(expression); return constant.getValue(expectedType == null ? TypeUtils.NO_EXPECTED_TYPE : expectedType); } @@ -204,7 +204,7 @@ public final class BindingUtils { } @NotNull - public static KtType getTypeForExpression(@NotNull BindingContext context, + public static KotlinType getTypeForExpression(@NotNull BindingContext context, @NotNull KtExpression expression) { return BindingContextUtils.getTypeNotNull(context, expression); } diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/utils/FunctionBodyTranslator.java b/js/js.translator/src/org/jetbrains/kotlin/js/translate/utils/FunctionBodyTranslator.java index 8c7455e6967..f5dfa163a17 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/utils/FunctionBodyTranslator.java +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/utils/FunctionBodyTranslator.java @@ -28,7 +28,7 @@ import org.jetbrains.kotlin.js.translate.utils.mutator.Mutator; import org.jetbrains.kotlin.psi.KtDeclarationWithBody; import org.jetbrains.kotlin.psi.KtExpression; import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import java.util.ArrayList; import java.util.List; @@ -100,7 +100,7 @@ public final class FunctionBodyTranslator extends AbstractTranslator { } private boolean mustAddReturnToGeneratedFunctionBody() { - KtType functionReturnType = descriptor.getReturnType(); + KotlinType functionReturnType = descriptor.getReturnType(); assert functionReturnType != null : "Function return typed type must be resolved."; return (!declaration.hasBlockBody()) && (!KotlinBuiltIns.isUnit(functionReturnType)); } diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/utils/JsDescriptorUtils.java b/js/js.translator/src/org/jetbrains/kotlin/js/translate/utils/JsDescriptorUtils.java index b9d7528c582..5f6023a6719 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/utils/JsDescriptorUtils.java +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/utils/JsDescriptorUtils.java @@ -31,7 +31,7 @@ import org.jetbrains.kotlin.psi.KtExpression; import org.jetbrains.kotlin.resolve.DescriptorUtils; import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue; import org.jetbrains.kotlin.resolve.scopes.receivers.ThisReceiver; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.util.OperatorNameConventions; import java.util.Collection; @@ -80,11 +80,11 @@ public final class JsDescriptorUtils { } @NotNull - public static List getSupertypesWithoutFakes(ClassDescriptor descriptor) { - Collection supertypes = descriptor.getTypeConstructor().getSupertypes(); - return ContainerUtil.filter(supertypes, new Condition() { + public static List getSupertypesWithoutFakes(ClassDescriptor descriptor) { + Collection supertypes = descriptor.getTypeConstructor().getSupertypes(); + return ContainerUtil.filter(supertypes, new Condition() { @Override - public boolean value(KtType type) { + public boolean value(KotlinType type) { ClassDescriptor classDescriptor = getClassDescriptorForType(type); return !FAKE_CLASSES.contains(getFqNameSafe(classDescriptor).asString()) && @@ -161,7 +161,7 @@ public final class JsDescriptorUtils { @Nullable public static Name getNameIfStandardType(@NotNull KtExpression expression, @NotNull TranslationContext context) { - KtType type = context.bindingContext().getType(expression); + KotlinType type = context.bindingContext().getType(expression); return type != null ? DescriptorUtilsKt.getNameIfStandardType(type) : null; } diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/utils/TranslationUtils.java b/js/js.translator/src/org/jetbrains/kotlin/js/translate/utils/TranslationUtils.java index a249680cfff..521285470a9 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/utils/TranslationUtils.java +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/utils/TranslationUtils.java @@ -27,7 +27,7 @@ import org.jetbrains.kotlin.js.translate.context.TranslationContext; import org.jetbrains.kotlin.js.translate.general.Translation; import org.jetbrains.kotlin.psi.*; import org.jetbrains.kotlin.resolve.DescriptorUtils; -import org.jetbrains.kotlin.types.KtType; +import org.jetbrains.kotlin.types.KotlinType; import java.util.ArrayList; import java.util.Collections; @@ -224,7 +224,7 @@ public final class TranslationUtils { if (operationDescriptor == null || !(operationDescriptor instanceof FunctionDescriptor)) return true; - KtType returnType = operationDescriptor.getReturnType(); + KotlinType returnType = operationDescriptor.getReturnType(); if (returnType != null && (KotlinBuiltIns.isChar(returnType) || KotlinBuiltIns.isLong(returnType))) return false; if (context.intrinsics().getFunctionIntrinsic((FunctionDescriptor) operationDescriptor).exists()) return true;