rename Kt to Kotlin in KtType, KtIcons
This commit is contained in:
@@ -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<ValueParameterDescriptor> 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);
|
||||
|
||||
@@ -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<CallableMemberDescriptor, CallableDescriptor> {
|
||||
if (delegateExpressionType?.isDynamic() ?: false) return mapOf();
|
||||
|
||||
|
||||
+2
-2
@@ -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
|
||||
|
||||
|
||||
+2
-2
@@ -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);
|
||||
|
||||
+3
-3
@@ -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,
|
||||
|
||||
@@ -157,7 +157,7 @@ public abstract class AnnotationCodegen {
|
||||
return false;
|
||||
}
|
||||
|
||||
private void generateNullabilityAnnotation(@Nullable KtType type, @NotNull Set<String> annotationDescriptorsAlreadyPresent) {
|
||||
private void generateNullabilityAnnotation(@Nullable KotlinType type, @NotNull Set<String> 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());
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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<KtElement> {
|
||||
private final FunctionDescriptor funDescriptor;
|
||||
private final ClassDescriptor classDescriptor;
|
||||
private final SamType samType;
|
||||
private final KtType superClassType;
|
||||
private final List<KtType> superInterfaceTypes;
|
||||
private final KotlinType superClassType;
|
||||
private final List<KotlinType> superInterfaceTypes;
|
||||
private final FunctionDescriptor functionReferenceTarget;
|
||||
private final FunctionGenerationStrategy strategy;
|
||||
private final CalculatedClosure closure;
|
||||
@@ -100,10 +100,10 @@ public class ClosureCodegen extends MemberCodegen<KtElement> {
|
||||
this.strategy = strategy;
|
||||
|
||||
if (samType == null) {
|
||||
this.superInterfaceTypes = new ArrayList<KtType>();
|
||||
this.superInterfaceTypes = new ArrayList<KotlinType>();
|
||||
|
||||
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<KtElement> {
|
||||
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<KtElement> {
|
||||
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));
|
||||
}
|
||||
|
||||
@@ -187,7 +187,7 @@ class CollectionStubMethodGenerator(
|
||||
return ourSuperCollectionClasses.filter { klass -> klass.readOnlyClass !in redundantClasses }
|
||||
}
|
||||
|
||||
private fun Collection<KtType>.classes(): Collection<ClassDescriptor> =
|
||||
private fun Collection<KotlinType>.classes(): Collection<ClassDescriptor> =
|
||||
this.map { it.getConstructor().getDeclarationDescriptor() as ClassDescriptor }
|
||||
|
||||
private fun findFakeOverridesForMethodsFromMutableCollection(
|
||||
@@ -213,7 +213,7 @@ class CollectionStubMethodGenerator(
|
||||
return result
|
||||
}
|
||||
|
||||
private fun Collection<KtType>.findMostSpecificTypeForClass(klass: ClassDescriptor): KtType {
|
||||
private fun Collection<KotlinType>.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<TypeProjection>): KtType {
|
||||
return KtTypeImpl.create(Annotations.EMPTY, classDescriptor, false, typeArguments)
|
||||
private fun newType(classDescriptor: ClassDescriptor, typeArguments: List<TypeProjection>): KotlinType {
|
||||
return KotlinTypeImpl.create(Annotations.EMPTY, classDescriptor, false, typeArguments)
|
||||
}
|
||||
|
||||
private fun FunctionDescriptor.signature(): JvmMethodSignature = typeMapper.mapSignature(this)
|
||||
|
||||
@@ -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<StackValue, StackValue> 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<StackValue, StackValue> 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<StackValue, StackValue> 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<StackValue, StackValue> impleme
|
||||
private final Label bodyEnd = new Label();
|
||||
private final List<Runnable> 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<StackValue, StackValue> impleme
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private KtType getElementType(KtForExpression forExpression) {
|
||||
private KotlinType getElementType(KtForExpression forExpression) {
|
||||
KtExpression loopRange = forExpression.getLoopRange();
|
||||
assert loopRange != null;
|
||||
ResolvedCall<FunctionDescriptor> nextCall = getNotNull(bindingContext,
|
||||
@@ -765,7 +765,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> 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<StackValue, StackValue> 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<StackValue, StackValue> 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<StackValue, StackValue> 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<StackValue, StackValue> 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<StackValue, StackValue> 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<StackValue, StackValue> 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<StackValue, StackValue> impleme
|
||||
Collection<ExpressionCodegenExtension> 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<StackValue, StackValue> 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<StackValue, StackValue> 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<StackValue, StackValue> 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<StackValue, StackValue> impleme
|
||||
|
||||
@NotNull
|
||||
private CallGenerator getOrCreateCallGenerator(@NotNull ResolvedCall<?> resolvedCall) {
|
||||
Map<TypeParameterDescriptor, KtType> typeArguments = resolvedCall.getTypeArguments();
|
||||
Map<TypeParameterDescriptor, KotlinType> typeArguments = resolvedCall.getTypeArguments();
|
||||
ReifiedTypeParameterMappings mappings = new ReifiedTypeParameterMappings();
|
||||
for (Map.Entry<TypeParameterDescriptor, KtType> entry : typeArguments.entrySet()) {
|
||||
for (Map.Entry<TypeParameterDescriptor, KotlinType> 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<StackValue, StackValue> 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<StackValue, StackValue> 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<StackValue, StackValue> 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<InstructionAdapter, Unit>() {
|
||||
@Override
|
||||
public Unit invoke(InstructionAdapter v) {
|
||||
@@ -3312,7 +3312,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> 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<StackValue, StackValue> 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<StackValue, StackValue> 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<StackValue, StackValue> 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<KtExpression> indices = expression.getIndexExpressions();
|
||||
FunctionDescriptor operationDescriptor = (FunctionDescriptor) bindingContext.get(REFERENCE_TARGET, expression);
|
||||
@@ -3472,7 +3472,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> 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<InstructionAdapter, Unit>() {
|
||||
@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);
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
@@ -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<String> superInterfaces = new LinkedHashSet<String>();
|
||||
Set<String> kotlinMarkerInterfaces = new LinkedHashSet<String>();
|
||||
|
||||
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<CallableMemberDescriptor, CallableDescriptor> entry : CodegenUtilKt.getDelegates(descriptor, toTrait, delegateExpressionType).entrySet()) {
|
||||
CallableMemberDescriptor callableMemberDescriptor = entry.getKey();
|
||||
CallableDescriptor delegateTo = entry.getValue();
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
@@ -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<KtType> getSupertypesForClosure(@NotNull FunctionDescriptor descriptor) {
|
||||
public Collection<KotlinType> 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<KtType> getSupertypesForFunctionReference(@NotNull FunctionDescriptor descriptor) {
|
||||
public Collection<KotlinType> 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();
|
||||
|
||||
@@ -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<T extends KtElement/* TODO: & JetDeclaration
|
||||
if (initializerValue == null) return state.getClassBuilderMode() != ClassBuilderMode.LIGHT_CLASSES;
|
||||
|
||||
//TODO: OPTIMIZATION: don't initialize static final fields
|
||||
KtType jetType = getPropertyOrDelegateType(property, propertyDescriptor);
|
||||
KotlinType jetType = getPropertyOrDelegateType(property, propertyDescriptor);
|
||||
Type type = typeMapper.mapType(jetType);
|
||||
return !skipDefaultValue(propertyDescriptor, initializerValue.getValue(), type);
|
||||
}
|
||||
@@ -432,10 +432,10 @@ public abstract class MemberCodegen<T extends KtElement/* TODO: & JetDeclaration
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private KtType getPropertyOrDelegateType(@NotNull KtProperty property, @NotNull PropertyDescriptor descriptor) {
|
||||
private KotlinType getPropertyOrDelegateType(@NotNull KtProperty property, @NotNull PropertyDescriptor descriptor) {
|
||||
KtExpression delegateExpression = property.getDelegateExpression();
|
||||
if (delegateExpression != null) {
|
||||
KtType delegateType = bindingContext.getType(delegateExpression);
|
||||
KotlinType delegateType = bindingContext.getType(delegateExpression);
|
||||
assert delegateType != null : "Type of delegate expression should be recorded";
|
||||
return delegateType;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.jetbrains.kotlin.descriptors.impl.DeclarationDescriptorImpl;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.resolve.scopes.KtScope;
|
||||
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.TypeUtils;
|
||||
@@ -41,7 +41,7 @@ public class MutableClassDescriptor extends ClassDescriptorBase implements Class
|
||||
private Visibility visibility;
|
||||
private TypeConstructor typeConstructor;
|
||||
private List<TypeParameterDescriptor> typeParameters;
|
||||
private final Collection<KtType> supertypes = new ArrayList<KtType>();
|
||||
private final Collection<KotlinType> supertypes = new ArrayList<KotlinType>();
|
||||
|
||||
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
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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<FqName, PrimitiveType> map
|
||||
) {
|
||||
ClassifierDescriptor declarationDescriptor = rangeOrProgression.getConstructor().getDeclarationDescriptor();
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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<DeclarationDescriptor, EnclosedValueDescriptor> getCaptureVariables();
|
||||
|
||||
+7
-7
@@ -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<KtType> supertypes,
|
||||
@NotNull Collection<KotlinType> 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<KtType> supertypes = runtimeTypes.getSupertypesForClosure(functionDescriptor);
|
||||
Collection<KotlinType> 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<KtType> supertypes;
|
||||
Collection<KotlinType> 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<KtType> supertypes = runtimeTypes.getSupertypesForClosure(functionDescriptor);
|
||||
Collection<KotlinType> 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";
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<T extends DeclarationDescriptor> {
|
||||
public <D extends CallableMemberDescriptor> D getAccessor(
|
||||
@NotNull D possiblySubstitutedDescriptor,
|
||||
boolean isForBackingFieldInOuterClass,
|
||||
@Nullable KtType delegateType,
|
||||
@Nullable KotlinType delegateType,
|
||||
@Nullable KtSuperExpression superCallExpression
|
||||
) {
|
||||
if (accessors == null) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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<String, ReifiedTypeParameterMapping>()
|
||||
|
||||
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 {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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]
|
||||
|
||||
+4
-4
@@ -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);
|
||||
|
||||
@@ -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<KtType>(constructor.getSupertypes()));
|
||||
jetType = CommonSupertypes.commonSupertype(new ArrayList<KotlinType>(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<TypeProjection, Boolean>() {
|
||||
@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);
|
||||
}
|
||||
|
||||
@@ -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)";
|
||||
|
||||
|
||||
+2
-2
@@ -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))
|
||||
}
|
||||
|
||||
@@ -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<AnalyzerScriptParameter> 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);
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -27,7 +27,7 @@ import org.jetbrains.kotlin.resolve.calls.context.CallResolutionContext
|
||||
import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
|
||||
import org.jetbrains.kotlin.types.upperIfFlexible
|
||||
@@ -36,20 +36,20 @@ public class RuntimeAssertionInfo(public val needNotNullAssertion: Boolean, publ
|
||||
public interface DataFlowExtras {
|
||||
class OnlyMessage(message: String) : DataFlowExtras {
|
||||
override val canBeNull: Boolean get() = true
|
||||
override val possibleTypes: Set<KtType> get() = setOf()
|
||||
override val possibleTypes: Set<KotlinType> get() = setOf()
|
||||
override val presentableText: String = message
|
||||
}
|
||||
|
||||
val canBeNull: Boolean
|
||||
val possibleTypes: Set<KtType>
|
||||
val possibleTypes: Set<KotlinType>
|
||||
val presentableText: String
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
public fun create(
|
||||
expectedType: KtType,
|
||||
expressionType: KtType,
|
||||
expectedType: KotlinType,
|
||||
expressionType: KotlinType,
|
||||
dataFlowExtras: DataFlowExtras
|
||||
): RuntimeAssertionInfo? {
|
||||
fun assertNotNull(): Boolean {
|
||||
@@ -78,13 +78,13 @@ public class RuntimeAssertionInfo(public val needNotNullAssertion: Boolean, publ
|
||||
null
|
||||
}
|
||||
|
||||
private fun KtType.hasEnhancedNullability()
|
||||
private fun KotlinType.hasEnhancedNullability()
|
||||
= getAnnotations().findAnnotation(JvmAnnotationNames.ENHANCED_NULLABILITY_ANNOTATION) != null
|
||||
}
|
||||
}
|
||||
|
||||
public object RuntimeAssertionsTypeChecker : AdditionalTypeChecker {
|
||||
override fun checkType(expression: KtExpression, expressionType: KtType, expressionTypeWithSmartCast: KtType, c: ResolutionContext<*>) {
|
||||
override fun checkType(expression: KtExpression, expressionType: KotlinType, expressionTypeWithSmartCast: KotlinType, c: ResolutionContext<*>) {
|
||||
if (TypeUtils.noExpectedType(c.expectedType)) return
|
||||
|
||||
val assertionInfo = RuntimeAssertionInfo.create(
|
||||
@@ -93,7 +93,7 @@ public object RuntimeAssertionsTypeChecker : AdditionalTypeChecker {
|
||||
object : RuntimeAssertionInfo.DataFlowExtras {
|
||||
override val canBeNull: Boolean
|
||||
get() = c.dataFlowInfo.getNullability(dataFlowValue).canBeNull()
|
||||
override val possibleTypes: Set<KtType>
|
||||
override val possibleTypes: Set<KotlinType>
|
||||
get() = c.dataFlowInfo.getPossibleTypes(dataFlowValue)
|
||||
override val presentableText: String
|
||||
get() = StringUtil.trimMiddle(expression.getText(), 50)
|
||||
|
||||
+6
-6
@@ -33,7 +33,7 @@ import org.jetbrains.kotlin.resolve.jvm.JavaDescriptorResolverKt;
|
||||
import org.jetbrains.kotlin.resolve.jvm.kotlinSignature.AlternativeFieldSignatureData;
|
||||
import org.jetbrains.kotlin.resolve.jvm.kotlinSignature.AlternativeMethodSignatureData;
|
||||
import org.jetbrains.kotlin.resolve.jvm.kotlinSignature.SignaturesPropagationData;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -55,8 +55,8 @@ public class TraceBasedExternalSignatureResolver implements ExternalSignatureRes
|
||||
public PropagatedMethodSignature resolvePropagatedSignature(
|
||||
@NotNull JavaMethod method,
|
||||
@NotNull ClassDescriptor owner,
|
||||
@NotNull KtType returnType,
|
||||
@Nullable KtType receiverType,
|
||||
@NotNull KotlinType returnType,
|
||||
@Nullable KotlinType receiverType,
|
||||
@NotNull List<ValueParameterDescriptor> valueParameters,
|
||||
@NotNull List<TypeParameterDescriptor> typeParameters
|
||||
) {
|
||||
@@ -72,8 +72,8 @@ public class TraceBasedExternalSignatureResolver implements ExternalSignatureRes
|
||||
public AlternativeMethodSignature resolveAlternativeMethodSignature(
|
||||
@NotNull JavaMember methodOrConstructor,
|
||||
boolean hasSuperMethods,
|
||||
@Nullable KtType returnType,
|
||||
@Nullable KtType receiverType,
|
||||
@Nullable KotlinType returnType,
|
||||
@Nullable KotlinType receiverType,
|
||||
@NotNull List<ValueParameterDescriptor> valueParameters,
|
||||
@NotNull List<TypeParameterDescriptor> typeParameters,
|
||||
boolean hasStableParameterNames
|
||||
@@ -102,7 +102,7 @@ public class TraceBasedExternalSignatureResolver implements ExternalSignatureRes
|
||||
@NotNull
|
||||
public AlternativeFieldSignature resolveAlternativeFieldSignature(
|
||||
@NotNull JavaField field,
|
||||
@NotNull KtType returnType,
|
||||
@NotNull KotlinType returnType,
|
||||
boolean isVar
|
||||
) {
|
||||
AlternativeFieldSignatureData data = new AlternativeFieldSignatureData(field, returnType, project, isVar);
|
||||
|
||||
+6
-6
@@ -21,7 +21,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl;
|
||||
import org.jetbrains.kotlin.resolve.ExternalOverridabilityCondition;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.TypeSubstitutor;
|
||||
import org.jetbrains.kotlin.types.TypeUtils;
|
||||
|
||||
@@ -57,7 +57,7 @@ public class SamAdapterOverridabilityCondition implements ExternalOverridability
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean differentClasses(@NotNull KtType type1, @NotNull KtType type2) {
|
||||
private static boolean differentClasses(@NotNull KotlinType type1, @NotNull KotlinType type2) {
|
||||
DeclarationDescriptor declarationDescriptor1 = type1.getConstructor().getDeclarationDescriptor();
|
||||
if (declarationDescriptor1 == null) return true; // No class, classes are not equal
|
||||
DeclarationDescriptor declarationDescriptor2 = type2.getConstructor().getDeclarationDescriptor();
|
||||
@@ -100,7 +100,7 @@ public class SamAdapterOverridabilityCondition implements ExternalOverridability
|
||||
@Nullable
|
||||
private static SamAdapterInfo getNearestDeclarationOrSynthesized(
|
||||
@NotNull SimpleFunctionDescriptor samAdapter,
|
||||
@NotNull KtType ownerType
|
||||
@NotNull KotlinType ownerType
|
||||
) {
|
||||
if (samAdapter.getKind() != CallableMemberDescriptor.Kind.FAKE_OVERRIDE) {
|
||||
return new SamAdapterInfo(samAdapter, ownerType);
|
||||
@@ -109,7 +109,7 @@ public class SamAdapterOverridabilityCondition implements ExternalOverridability
|
||||
for (CallableMemberDescriptor overridden : samAdapter.getOverriddenDescriptors()) {
|
||||
ClassDescriptor containingClass = (ClassDescriptor) overridden.getContainingDeclaration();
|
||||
|
||||
for (KtType immediateSupertype : TypeUtils.getImmediateSupertypes(ownerType)) {
|
||||
for (KotlinType immediateSupertype : TypeUtils.getImmediateSupertypes(ownerType)) {
|
||||
if (containingClass != immediateSupertype.getConstructor().getDeclarationDescriptor()) {
|
||||
continue;
|
||||
}
|
||||
@@ -126,9 +126,9 @@ public class SamAdapterOverridabilityCondition implements ExternalOverridability
|
||||
|
||||
private static class SamAdapterInfo {
|
||||
private final SimpleFunctionDescriptor samAdapter;
|
||||
private final KtType ownerType;
|
||||
private final KotlinType ownerType;
|
||||
|
||||
private SamAdapterInfo(@NotNull SimpleFunctionDescriptor samAdapter, @NotNull KtType ownerType) {
|
||||
private SamAdapterInfo(@NotNull SimpleFunctionDescriptor samAdapter, @NotNull KotlinType ownerType) {
|
||||
this.samAdapter = samAdapter;
|
||||
this.ownerType = ownerType;
|
||||
}
|
||||
|
||||
+3
-3
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.load.java.descriptors.*
|
||||
import org.jetbrains.kotlin.load.java.lazy.descriptors.LazyJavaClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaMethod
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.load.java.sources.JavaSourceElement
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaClass
|
||||
import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor
|
||||
@@ -51,7 +51,7 @@ public object SamConversionResolverImpl : SamConversionResolver {
|
||||
override fun resolveFunctionTypeIfSamInterface(
|
||||
classDescriptor: JavaClassDescriptor,
|
||||
resolveMethod: (JavaMethod) -> FunctionDescriptor
|
||||
): KtType? {
|
||||
): KotlinType? {
|
||||
val jClass = (classDescriptor.getSource() as? JavaSourceElement)?.javaElement as? JavaClass ?: return null
|
||||
val samInterfaceMethod = SingleAbstractMethodUtils.getSamInterfaceMethod(jClass) ?: return null
|
||||
val abstractMethod = if (jClass.getFqName() == samInterfaceMethod.getContainingClass().getFqName()) {
|
||||
@@ -63,7 +63,7 @@ public object SamConversionResolverImpl : SamConversionResolver {
|
||||
return SingleAbstractMethodUtils.getFunctionTypeForAbstractMethod(abstractMethod)
|
||||
}
|
||||
|
||||
private fun findFunctionWithMostSpecificReturnType(supertypes: Set<KtType>): SimpleFunctionDescriptor {
|
||||
private fun findFunctionWithMostSpecificReturnType(supertypes: Set<KotlinType>): SimpleFunctionDescriptor {
|
||||
val candidates = ArrayList<SimpleFunctionDescriptor>(supertypes.size())
|
||||
for (supertype in supertypes) {
|
||||
val abstractMembers = SingleAbstractMethodUtils.getAbstractMembers(supertype)
|
||||
|
||||
+25
-25
@@ -43,7 +43,7 @@ public class SingleAbstractMethodUtils {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static List<CallableMemberDescriptor> getAbstractMembers(@NotNull KtType type) {
|
||||
public static List<CallableMemberDescriptor> getAbstractMembers(@NotNull KotlinType type) {
|
||||
List<CallableMemberDescriptor> abstractMembers = new ArrayList<CallableMemberDescriptor>();
|
||||
for (DeclarationDescriptor member : type.getMemberScope().getAllDescriptors()) {
|
||||
if (member instanceof CallableMemberDescriptor && ((CallableMemberDescriptor) member).getModality() == Modality.ABSTRACT) {
|
||||
@@ -53,7 +53,7 @@ public class SingleAbstractMethodUtils {
|
||||
return abstractMembers;
|
||||
}
|
||||
|
||||
private static KtType fixProjections(@NotNull KtType functionType) {
|
||||
private static KotlinType fixProjections(@NotNull KotlinType functionType) {
|
||||
//removes redundant projection kinds and detects conflicts
|
||||
|
||||
List<TypeParameterDescriptor> typeParameters = functionType.getConstructor().getParameters();
|
||||
@@ -76,7 +76,7 @@ public class SingleAbstractMethodUtils {
|
||||
}
|
||||
ClassifierDescriptor classifier = functionType.getConstructor().getDeclarationDescriptor();
|
||||
assert classifier instanceof ClassDescriptor : "Not class: " + classifier;
|
||||
return KtTypeImpl.create(
|
||||
return KotlinTypeImpl.create(
|
||||
functionType.getAnnotations(),
|
||||
functionType.getConstructor(),
|
||||
functionType.isMarkedNullable(),
|
||||
@@ -86,21 +86,21 @@ public class SingleAbstractMethodUtils {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static KtType getFunctionTypeForSamType(@NotNull KtType samType) {
|
||||
public static KotlinType getFunctionTypeForSamType(@NotNull KotlinType samType) {
|
||||
// e.g. samType == Comparator<String>?
|
||||
|
||||
ClassifierDescriptor classifier = samType.getConstructor().getDeclarationDescriptor();
|
||||
if (classifier instanceof JavaClassDescriptor) {
|
||||
// Function2<T, T, Int>
|
||||
KtType functionTypeDefault = ((JavaClassDescriptor) classifier).getFunctionTypeForSamInterface();
|
||||
KotlinType functionTypeDefault = ((JavaClassDescriptor) classifier).getFunctionTypeForSamInterface();
|
||||
|
||||
if (functionTypeDefault != null) {
|
||||
// Function2<String, String, Int>?
|
||||
KtType substitute = TypeSubstitutor.create(samType).substitute(functionTypeDefault, Variance.INVARIANT);
|
||||
KotlinType substitute = TypeSubstitutor.create(samType).substitute(functionTypeDefault, Variance.INVARIANT);
|
||||
|
||||
if (substitute == null) return null;
|
||||
|
||||
KtType type = fixProjections(substitute);
|
||||
KotlinType type = fixProjections(substitute);
|
||||
if (type == null) return null;
|
||||
|
||||
if (JavaDescriptorResolverKt.getPLATFORM_TYPES() && FlexibleTypesKt.isNullabilityFlexible(samType)) {
|
||||
@@ -114,11 +114,11 @@ public class SingleAbstractMethodUtils {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static KtType getFunctionTypeForAbstractMethod(@NotNull FunctionDescriptor function) {
|
||||
KtType returnType = function.getReturnType();
|
||||
public static KotlinType getFunctionTypeForAbstractMethod(@NotNull FunctionDescriptor function) {
|
||||
KotlinType returnType = function.getReturnType();
|
||||
assert returnType != null : "function is not initialized: " + function;
|
||||
List<ValueParameterDescriptor> valueParameters = function.getValueParameters();
|
||||
List<KtType> parameterTypes = new ArrayList<KtType>(valueParameters.size());
|
||||
List<KotlinType> parameterTypes = new ArrayList<KotlinType>(valueParameters.size());
|
||||
for (ValueParameterDescriptor parameter : valueParameters) {
|
||||
parameterTypes.add(parameter.getType());
|
||||
}
|
||||
@@ -151,9 +151,9 @@ public class SingleAbstractMethodUtils {
|
||||
|
||||
TypeParameters typeParameters = recreateAndInitializeTypeParameters(samInterface.getTypeConstructor().getParameters(), result);
|
||||
|
||||
KtType parameterTypeUnsubstituted = getFunctionTypeForSamType(samInterface.getDefaultType());
|
||||
KotlinType parameterTypeUnsubstituted = getFunctionTypeForSamType(samInterface.getDefaultType());
|
||||
assert parameterTypeUnsubstituted != null : "couldn't get function type for SAM type " + samInterface.getDefaultType();
|
||||
KtType parameterType = typeParameters.substitutor.substitute(parameterTypeUnsubstituted, Variance.IN_VARIANCE);
|
||||
KotlinType parameterType = typeParameters.substitutor.substitute(parameterTypeUnsubstituted, Variance.IN_VARIANCE);
|
||||
assert parameterType != null : "couldn't substitute type: " + parameterTypeUnsubstituted +
|
||||
", substitutor = " + typeParameters.substitutor;
|
||||
ValueParameterDescriptor parameter = new ValueParameterDescriptorImpl(
|
||||
@@ -163,7 +163,7 @@ public class SingleAbstractMethodUtils {
|
||||
/* isNoinline = */ false,
|
||||
null, SourceElement.NO_SOURCE);
|
||||
|
||||
KtType returnType = typeParameters.substitutor.substitute(samInterface.getDefaultType(), Variance.OUT_VARIANCE);
|
||||
KotlinType returnType = typeParameters.substitutor.substitute(samInterface.getDefaultType(), Variance.OUT_VARIANCE);
|
||||
assert returnType != null : "couldn't substitute type: " + samInterface.getDefaultType() +
|
||||
", substitutor = " + typeParameters.substitutor;
|
||||
|
||||
@@ -180,7 +180,7 @@ public class SingleAbstractMethodUtils {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static boolean isSamType(@NotNull KtType type) {
|
||||
public static boolean isSamType(@NotNull KotlinType type) {
|
||||
return getFunctionTypeForSamType(type) != null;
|
||||
}
|
||||
|
||||
@@ -201,7 +201,7 @@ public class SingleAbstractMethodUtils {
|
||||
public void initialize(
|
||||
@NotNull List<TypeParameterDescriptor> typeParameters,
|
||||
@NotNull List<ValueParameterDescriptor> valueParameters,
|
||||
@NotNull KtType returnType
|
||||
@NotNull KotlinType returnType
|
||||
) {
|
||||
result.initialize(
|
||||
null,
|
||||
@@ -224,7 +224,7 @@ public class SingleAbstractMethodUtils {
|
||||
public void initialize(
|
||||
@NotNull List<TypeParameterDescriptor> typeParameters,
|
||||
@NotNull List<ValueParameterDescriptor> valueParameters,
|
||||
@NotNull KtType returnType
|
||||
@NotNull KotlinType returnType
|
||||
) {
|
||||
result.initialize(typeParameters, valueParameters, original.getVisibility());
|
||||
result.setReturnType(returnType);
|
||||
@@ -240,11 +240,11 @@ public class SingleAbstractMethodUtils {
|
||||
) {
|
||||
TypeParameters typeParameters = recreateAndInitializeTypeParameters(original.getTypeParameters(), adapter);
|
||||
|
||||
KtType returnTypeUnsubstituted = original.getReturnType();
|
||||
KotlinType returnTypeUnsubstituted = original.getReturnType();
|
||||
assert returnTypeUnsubstituted != null : "Creating SAM adapter for not initialized original: " + original;
|
||||
|
||||
TypeSubstitutor substitutor = typeParameters.substitutor;
|
||||
KtType returnType = substitutor.substitute(returnTypeUnsubstituted, Variance.INVARIANT);
|
||||
KotlinType returnType = substitutor.substitute(returnTypeUnsubstituted, Variance.INVARIANT);
|
||||
assert returnType != null : "couldn't substitute type: " + returnTypeUnsubstituted +
|
||||
", substitutor = " + substitutor;
|
||||
|
||||
@@ -264,10 +264,10 @@ public class SingleAbstractMethodUtils {
|
||||
List<ValueParameterDescriptor> originalValueParameters = original.getValueParameters();
|
||||
List<ValueParameterDescriptor> valueParameters = new ArrayList<ValueParameterDescriptor>(originalValueParameters.size());
|
||||
for (ValueParameterDescriptor originalParam : originalValueParameters) {
|
||||
KtType originalType = originalParam.getType();
|
||||
KtType functionType = getFunctionTypeForSamType(originalType);
|
||||
KtType newTypeUnsubstituted = functionType != null ? functionType : originalType;
|
||||
KtType newType = substitutor.substitute(newTypeUnsubstituted, Variance.IN_VARIANCE);
|
||||
KotlinType originalType = originalParam.getType();
|
||||
KotlinType functionType = getFunctionTypeForSamType(originalType);
|
||||
KotlinType newTypeUnsubstituted = functionType != null ? functionType : originalType;
|
||||
KotlinType newType = substitutor.substitute(newTypeUnsubstituted, Variance.IN_VARIANCE);
|
||||
assert newType != null : "couldn't substitute type: " + newTypeUnsubstituted + ", substitutor = " + substitutor;
|
||||
|
||||
ValueParameterDescriptor newParam = new ValueParameterDescriptorImpl(
|
||||
@@ -295,8 +295,8 @@ public class SingleAbstractMethodUtils {
|
||||
TypeParameterDescriptor traitTypeParameter = mapEntry.getKey();
|
||||
TypeParameterDescriptorImpl funTypeParameter = mapEntry.getValue();
|
||||
|
||||
for (KtType upperBound : traitTypeParameter.getUpperBounds()) {
|
||||
KtType upperBoundSubstituted = typeParametersSubstitutor.substitute(upperBound, Variance.INVARIANT);
|
||||
for (KotlinType upperBound : traitTypeParameter.getUpperBounds()) {
|
||||
KotlinType upperBoundSubstituted = typeParametersSubstitutor.substitute(upperBound, Variance.INVARIANT);
|
||||
assert upperBoundSubstituted != null : "couldn't substitute type: " + upperBound + ", substitutor = " + typeParametersSubstitutor;
|
||||
funTypeParameter.addUpperBound(upperBoundSubstituted);
|
||||
}
|
||||
@@ -345,7 +345,7 @@ public class SingleAbstractMethodUtils {
|
||||
public abstract void initialize(
|
||||
@NotNull List<TypeParameterDescriptor> typeParameters,
|
||||
@NotNull List<ValueParameterDescriptor> valueParameters,
|
||||
@NotNull KtType returnType
|
||||
@NotNull KotlinType returnType
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ import org.jetbrains.kotlin.resolve.calls.model.ExpressionValueArgument
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedValueArgument
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
import java.lang.annotation.Target
|
||||
|
||||
|
||||
+2
-2
@@ -25,7 +25,7 @@ import org.jetbrains.kotlin.resolve.calls.checkers.CallChecker
|
||||
import org.jetbrains.kotlin.resolve.calls.context.BasicCallResolutionContext
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm
|
||||
import org.jetbrains.kotlin.types.KtTypeImpl
|
||||
import org.jetbrains.kotlin.types.KotlinTypeImpl
|
||||
import org.jetbrains.kotlin.types.TypeProjectionImpl
|
||||
|
||||
public class JavaClassOnCompanionChecker : CallChecker {
|
||||
@@ -42,7 +42,7 @@ public class JavaClassOnCompanionChecker : CallChecker {
|
||||
if (companionObject.isCompanionObject) {
|
||||
val containingClass = companionObject.containingDeclaration as ClassDescriptor
|
||||
val javaLangClass = actualType.constructor.declarationDescriptor as? ClassDescriptor ?: return
|
||||
val expectedType = KtTypeImpl.create(
|
||||
val expectedType = KotlinTypeImpl.create(
|
||||
Annotations.EMPTY, javaLangClass, actualType.isMarkedNullable,
|
||||
listOf(TypeProjectionImpl(containingClass.defaultType))
|
||||
)
|
||||
|
||||
+6
-6
@@ -36,14 +36,14 @@ import org.jetbrains.kotlin.resolve.calls.smartcasts.Nullability
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
import org.jetbrains.kotlin.types.expressions.SenselessComparisonChecker
|
||||
import org.jetbrains.kotlin.types.flexibility
|
||||
import org.jetbrains.kotlin.types.isFlexible
|
||||
|
||||
public class JavaNullabilityWarningsChecker : AdditionalTypeChecker {
|
||||
private fun KtType.mayBeNull(): ErrorsJvm.NullabilityInformationSource? {
|
||||
private fun KotlinType.mayBeNull(): ErrorsJvm.NullabilityInformationSource? {
|
||||
if (!isError() && !isFlexible() && TypeUtils.isNullableType(this)) return ErrorsJvm.NullabilityInformationSource.KOTLIN
|
||||
|
||||
if (isFlexible() && TypeUtils.isNullableType(flexibility().lowerBound)) return ErrorsJvm.NullabilityInformationSource.KOTLIN
|
||||
@@ -52,7 +52,7 @@ public class JavaNullabilityWarningsChecker : AdditionalTypeChecker {
|
||||
return null
|
||||
}
|
||||
|
||||
private fun KtType.mustNotBeNull(): ErrorsJvm.NullabilityInformationSource? {
|
||||
private fun KotlinType.mustNotBeNull(): ErrorsJvm.NullabilityInformationSource? {
|
||||
if (!isError() && !isFlexible() && !TypeUtils.isNullableType(this)) return ErrorsJvm.NullabilityInformationSource.KOTLIN
|
||||
|
||||
if (isFlexible() && !TypeUtils.isNullableType(flexibility().upperBound)) return ErrorsJvm.NullabilityInformationSource.KOTLIN
|
||||
@@ -62,8 +62,8 @@ public class JavaNullabilityWarningsChecker : AdditionalTypeChecker {
|
||||
}
|
||||
|
||||
private fun doCheckType(
|
||||
expressionType: KtType,
|
||||
expectedType: KtType,
|
||||
expressionType: KotlinType,
|
||||
expectedType: KotlinType,
|
||||
dataFlowValue: DataFlowValue,
|
||||
dataFlowInfo: DataFlowInfo,
|
||||
reportWarning: (expectedMustNotBeNull: ErrorsJvm.NullabilityInformationSource, actualMayBeNull: ErrorsJvm.NullabilityInformationSource) -> Unit
|
||||
@@ -85,7 +85,7 @@ public class JavaNullabilityWarningsChecker : AdditionalTypeChecker {
|
||||
}
|
||||
}
|
||||
|
||||
override fun checkType(expression: KtExpression, expressionType: KtType, expressionTypeWithSmartCast: KtType, c: ResolutionContext<*>) {
|
||||
override fun checkType(expression: KtExpression, expressionType: KotlinType, expressionTypeWithSmartCast: KotlinType, c: ResolutionContext<*>) {
|
||||
doCheckType(
|
||||
expressionType,
|
||||
c.expectedType,
|
||||
|
||||
+2
-2
@@ -30,12 +30,12 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.classId
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.getAnnotationRetention
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.isRepeatableAnnotation
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
|
||||
public object RepeatableAnnotationChecker: AdditionalAnnotationChecker {
|
||||
override fun checkEntries(entries: List<KtAnnotationEntry>, actualTargets: List<KotlinTarget>, trace: BindingTrace) {
|
||||
val entryTypesWithAnnotations = hashMapOf<KtType, MutableList<AnnotationUseSiteTarget?>>()
|
||||
val entryTypesWithAnnotations = hashMapOf<KotlinType, MutableList<AnnotationUseSiteTarget?>>()
|
||||
|
||||
for (entry in entries) {
|
||||
val descriptor = trace.get(BindingContext.ANNOTATION, entry) ?: continue
|
||||
|
||||
+3
-3
@@ -27,7 +27,7 @@ import org.jetbrains.kotlin.psi.KtAnnotationEntry;
|
||||
import org.jetbrains.kotlin.psi.KtDeclaration;
|
||||
import org.jetbrains.kotlin.psi.KtElement;
|
||||
import org.jetbrains.kotlin.psi.KtExpression;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
import static org.jetbrains.kotlin.diagnostics.PositioningStrategies.*;
|
||||
import static org.jetbrains.kotlin.diagnostics.Severity.ERROR;
|
||||
@@ -74,8 +74,8 @@ public interface ErrorsJvm {
|
||||
|
||||
DiagnosticFactory0<KtElement> NO_REFLECTION_IN_CLASS_PATH = DiagnosticFactory0.create(WARNING);
|
||||
|
||||
DiagnosticFactory2<KtElement, KtType, KtType> JAVA_CLASS_ON_COMPANION = DiagnosticFactory2.create(WARNING);
|
||||
DiagnosticFactory2<KtExpression, KtType, KtType> JAVA_TYPE_MISMATCH = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory2<KtElement, KotlinType, KotlinType> JAVA_CLASS_ON_COMPANION = DiagnosticFactory2.create(WARNING);
|
||||
DiagnosticFactory2<KtExpression, KotlinType, KotlinType> JAVA_TYPE_MISMATCH = DiagnosticFactory2.create(ERROR);
|
||||
|
||||
DiagnosticFactory2<PsiElement, String, String> DUPLICATE_CLASS_NAMES = DiagnosticFactory2.create(ERROR);
|
||||
|
||||
|
||||
+4
-4
@@ -24,16 +24,16 @@ import org.jetbrains.kotlin.descriptors.impl.TypeParameterDescriptorImpl;
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaField;
|
||||
import org.jetbrains.kotlin.psi.KtProperty;
|
||||
import org.jetbrains.kotlin.psi.KtPsiFactoryKt;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class AlternativeFieldSignatureData extends ElementAlternativeSignatureData {
|
||||
private KtType altReturnType;
|
||||
private KotlinType altReturnType;
|
||||
|
||||
public AlternativeFieldSignatureData(
|
||||
@NotNull JavaField field,
|
||||
@NotNull KtType originalReturnType,
|
||||
@NotNull KotlinType originalReturnType,
|
||||
@NotNull Project project,
|
||||
boolean isVar
|
||||
) {
|
||||
@@ -59,7 +59,7 @@ public class AlternativeFieldSignatureData extends ElementAlternativeSignatureDa
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public KtType getReturnType() {
|
||||
public KotlinType getReturnType() {
|
||||
checkForErrors();
|
||||
return altReturnType;
|
||||
}
|
||||
|
||||
+14
-14
@@ -32,7 +32,7 @@ import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.psi.*;
|
||||
import org.jetbrains.kotlin.resolve.jvm.JavaDescriptorResolverKt;
|
||||
import org.jetbrains.kotlin.resolve.jvm.JavaResolverUtils;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.TypeSubstitutor;
|
||||
import org.jetbrains.kotlin.types.TypeUtils;
|
||||
import org.jetbrains.kotlin.types.Variance;
|
||||
@@ -52,17 +52,17 @@ public class AlternativeMethodSignatureData extends ElementAlternativeSignatureD
|
||||
private final KtNamedFunction altFunDeclaration;
|
||||
|
||||
private List<ValueParameterDescriptor> altValueParameters;
|
||||
private KtType altReturnType;
|
||||
private KotlinType altReturnType;
|
||||
private List<TypeParameterDescriptor> altTypeParameters;
|
||||
|
||||
private Map<TypeParameterDescriptor, TypeParameterDescriptorImpl> originalToAltTypeParameters;
|
||||
|
||||
public AlternativeMethodSignatureData(
|
||||
@NotNull JavaMember methodOrConstructor,
|
||||
@Nullable KtType receiverType,
|
||||
@Nullable KotlinType receiverType,
|
||||
@NotNull Project project,
|
||||
@NotNull List<ValueParameterDescriptor> valueParameters,
|
||||
@Nullable KtType originalReturnType,
|
||||
@Nullable KotlinType originalReturnType,
|
||||
@NotNull List<TypeParameterDescriptor> methodTypeParameters,
|
||||
boolean hasSuperMethods
|
||||
) {
|
||||
@@ -119,7 +119,7 @@ public class AlternativeMethodSignatureData extends ElementAlternativeSignatureD
|
||||
private void checkParameterAndReturnTypesForOverridingMethods(
|
||||
@NotNull List<ValueParameterDescriptor> valueParameters,
|
||||
@NotNull List<TypeParameterDescriptor> methodTypeParameters,
|
||||
@Nullable KtType returnType
|
||||
@Nullable KotlinType returnType
|
||||
) {
|
||||
if (JavaDescriptorResolverKt.getPLATFORM_TYPES()) return;
|
||||
TypeSubstitutor substitutor = JavaResolverUtils.createSubstitutorForTypeParameters(originalToAltTypeParameters);
|
||||
@@ -128,7 +128,7 @@ public class AlternativeMethodSignatureData extends ElementAlternativeSignatureD
|
||||
int index = parameter.getIndex();
|
||||
ValueParameterDescriptor altParameter = altValueParameters.get(index);
|
||||
|
||||
KtType substituted = substitutor.substitute(parameter.getType(), Variance.INVARIANT);
|
||||
KotlinType substituted = substitutor.substitute(parameter.getType(), Variance.INVARIANT);
|
||||
assert substituted != null;
|
||||
|
||||
if (!TypeUtils.equalTypes(substituted, altParameter.getType())) {
|
||||
@@ -143,7 +143,7 @@ public class AlternativeMethodSignatureData extends ElementAlternativeSignatureD
|
||||
for (TypeParameterDescriptor parameter : methodTypeParameters) {
|
||||
int index = parameter.getIndex();
|
||||
|
||||
KtType substituted = substitutor.substitute(parameter.getUpperBoundsAsType(), Variance.INVARIANT);
|
||||
KotlinType substituted = substitutor.substitute(parameter.getUpperBoundsAsType(), Variance.INVARIANT);
|
||||
assert substituted != null;
|
||||
|
||||
if (!TypeUtils.equalTypes(substituted, altTypeParameters.get(index).getUpperBoundsAsType())) {
|
||||
@@ -154,7 +154,7 @@ public class AlternativeMethodSignatureData extends ElementAlternativeSignatureD
|
||||
}
|
||||
|
||||
if (returnType != null) {
|
||||
KtType substitutedReturnType = substitutor.substitute(returnType, Variance.INVARIANT);
|
||||
KotlinType substitutedReturnType = substitutor.substitute(returnType, Variance.INVARIANT);
|
||||
assert substitutedReturnType != null;
|
||||
|
||||
if (!KotlinTypeChecker.DEFAULT.isSubtypeOf(altReturnType, substitutedReturnType)) {
|
||||
@@ -171,7 +171,7 @@ public class AlternativeMethodSignatureData extends ElementAlternativeSignatureD
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public KtType getReturnType() {
|
||||
public KotlinType getReturnType() {
|
||||
checkForErrors();
|
||||
return altReturnType;
|
||||
}
|
||||
@@ -197,10 +197,10 @@ public class AlternativeMethodSignatureData extends ElementAlternativeSignatureD
|
||||
KtTypeElement alternativeTypeElement = annotationValueParameter.getTypeReference().getTypeElement();
|
||||
assert alternativeTypeElement != null;
|
||||
|
||||
KtType alternativeType;
|
||||
KtType alternativeVarargElementType;
|
||||
KotlinType alternativeType;
|
||||
KotlinType alternativeVarargElementType;
|
||||
|
||||
KtType originalParamVarargElementType = originalParameterDescriptor.getVarargElementType();
|
||||
KotlinType originalParamVarargElementType = originalParameterDescriptor.getVarargElementType();
|
||||
if (originalParamVarargElementType == null) {
|
||||
if (annotationValueParameter.isVarArg()) {
|
||||
throw new AlternativeSignatureMismatchException("Parameter in method signature is not vararg, but in alternative signature it is vararg");
|
||||
@@ -253,7 +253,7 @@ public class AlternativeMethodSignatureData extends ElementAlternativeSignatureD
|
||||
TypeParameterDescriptorImpl altParamDescriptor = originalToAltTypeParameters.get(originalTypeParamDescriptor);
|
||||
KtTypeParameter altTypeParameter = altFunDeclaration.getTypeParameters().get(i);
|
||||
|
||||
Set<KtType> originalUpperBounds = originalTypeParamDescriptor.getUpperBounds();
|
||||
Set<KotlinType> originalUpperBounds = originalTypeParamDescriptor.getUpperBounds();
|
||||
List<KtTypeReference> altUpperBounds = getUpperBounds(altFunDeclaration, altTypeParameter);
|
||||
if (altUpperBounds.size() != originalUpperBounds.size()) {
|
||||
if (altUpperBounds.isEmpty()
|
||||
@@ -274,7 +274,7 @@ public class AlternativeMethodSignatureData extends ElementAlternativeSignatureD
|
||||
}
|
||||
else {
|
||||
int upperBoundIndex = 0;
|
||||
for (KtType upperBound : originalUpperBounds) {
|
||||
for (KotlinType upperBound : originalUpperBounds) {
|
||||
|
||||
KtTypeElement altTypeElement = altUpperBounds.get(upperBoundIndex).getTypeElement();
|
||||
assert altTypeElement != null;
|
||||
|
||||
+3
-3
@@ -27,7 +27,7 @@ import org.jetbrains.kotlin.psi.KtTypeElement;
|
||||
import org.jetbrains.kotlin.psi.KtTypeReference;
|
||||
import org.jetbrains.kotlin.renderer.DescriptorRenderer;
|
||||
import org.jetbrains.kotlin.resolve.AnalyzingUtils;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -86,8 +86,8 @@ public abstract class ElementAlternativeSignatureData {
|
||||
}
|
||||
}
|
||||
|
||||
protected static KtType computeReturnType(
|
||||
@NotNull KtType originalType,
|
||||
protected static KotlinType computeReturnType(
|
||||
@NotNull KotlinType originalType,
|
||||
@Nullable KtTypeReference altReturnTypeReference,
|
||||
@NotNull Map<TypeParameterDescriptor, TypeParameterDescriptorImpl> originalToAltTypeParameters) {
|
||||
if (altReturnTypeReference == null) {
|
||||
|
||||
+7
-7
@@ -25,8 +25,8 @@ import org.jetbrains.kotlin.descriptors.ClassifierDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor;
|
||||
import org.jetbrains.kotlin.renderer.DescriptorRenderer;
|
||||
import org.jetbrains.kotlin.resolve.scopes.KtScope;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KtTypeImpl;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.KotlinTypeImpl;
|
||||
import org.jetbrains.kotlin.types.TypeProjectionImpl;
|
||||
import org.jetbrains.kotlin.types.Variance;
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
|
||||
@@ -41,7 +41,7 @@ class PropagationHeuristics {
|
||||
// Checks for case when method returning Super[] is overridden with method returning Sub[]
|
||||
static void checkArrayInReturnType(
|
||||
@NotNull SignaturesPropagationData data,
|
||||
@NotNull KtType type,
|
||||
@NotNull KotlinType type,
|
||||
@NotNull List<SignaturesPropagationData.TypeAndVariance> typesFromSuper
|
||||
) {
|
||||
List<SignaturesPropagationData.TypeAndVariance> arrayTypesFromSuper = ContainerUtil
|
||||
@@ -55,14 +55,14 @@ class PropagationHeuristics {
|
||||
assert type.getArguments().size() == 1;
|
||||
if (type.getArguments().get(0).getProjectionKind() == Variance.INVARIANT) {
|
||||
for (SignaturesPropagationData.TypeAndVariance typeAndVariance : arrayTypesFromSuper) {
|
||||
KtType arrayTypeFromSuper = typeAndVariance.type;
|
||||
KotlinType arrayTypeFromSuper = typeAndVariance.type;
|
||||
assert arrayTypeFromSuper.getArguments().size() == 1;
|
||||
KtType elementTypeInSuper = arrayTypeFromSuper.getArguments().get(0).getType();
|
||||
KtType elementType = type.getArguments().get(0).getType();
|
||||
KotlinType elementTypeInSuper = arrayTypeFromSuper.getArguments().get(0).getType();
|
||||
KotlinType elementType = type.getArguments().get(0).getType();
|
||||
|
||||
if (KotlinTypeChecker.DEFAULT.isSubtypeOf(elementType, elementTypeInSuper)
|
||||
&& !KotlinTypeChecker.DEFAULT.equalTypes(elementType, elementTypeInSuper)) {
|
||||
KtTypeImpl betterTypeInSuper = KtTypeImpl.create(
|
||||
KotlinTypeImpl betterTypeInSuper = KotlinTypeImpl.create(
|
||||
arrayTypeFromSuper.getAnnotations(),
|
||||
arrayTypeFromSuper.getConstructor(),
|
||||
arrayTypeFromSuper.isMarkedNullable(),
|
||||
|
||||
+43
-43
@@ -66,7 +66,7 @@ public class SignaturesPropagationData {
|
||||
private final List<TypeParameterDescriptor> modifiedTypeParameters;
|
||||
private final ValueParameters modifiedValueParameters;
|
||||
|
||||
private final KtType modifiedReturnType;
|
||||
private final KotlinType modifiedReturnType;
|
||||
private final List<String> signatureErrors = Lists.newArrayList();
|
||||
private final List<FunctionDescriptor> superFunctions;
|
||||
private final Map<TypeParameterDescriptor, TypeParameterDescriptorImpl> autoTypeParameterToModified;
|
||||
@@ -74,8 +74,8 @@ public class SignaturesPropagationData {
|
||||
|
||||
public SignaturesPropagationData(
|
||||
@NotNull ClassDescriptor containingClass,
|
||||
@NotNull KtType autoReturnType, // type built by JavaTypeTransformer from Java signature and @NotNull annotations
|
||||
@Nullable KtType receiverType,
|
||||
@NotNull KotlinType autoReturnType, // type built by JavaTypeTransformer from Java signature and @NotNull annotations
|
||||
@Nullable KotlinType receiverType,
|
||||
@NotNull List<ValueParameterDescriptor> autoValueParameters, // descriptors built by parameters resolver
|
||||
@NotNull List<TypeParameterDescriptor> autoTypeParameters, // descriptors built by signature resolver
|
||||
@NotNull JavaMethod method
|
||||
@@ -97,8 +97,8 @@ public class SignaturesPropagationData {
|
||||
@NotNull
|
||||
private static JavaMethodDescriptor createAutoMethodDescriptor(
|
||||
@NotNull ClassDescriptor containingClass,
|
||||
@NotNull JavaMethod method, KtType autoReturnType,
|
||||
@Nullable KtType receiverType,
|
||||
@NotNull JavaMethod method, KotlinType autoReturnType,
|
||||
@Nullable KotlinType receiverType,
|
||||
@NotNull List<ValueParameterDescriptor> autoValueParameters,
|
||||
@NotNull List<TypeParameterDescriptor> autoTypeParameters
|
||||
) {
|
||||
@@ -125,7 +125,7 @@ public class SignaturesPropagationData {
|
||||
return modifiedTypeParameters;
|
||||
}
|
||||
|
||||
public KtType getModifiedReceiverType() {
|
||||
public KotlinType getModifiedReceiverType() {
|
||||
return modifiedValueParameters.receiverType;
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ public class SignaturesPropagationData {
|
||||
return modifiedValueParameters.hasStableParameterNames;
|
||||
}
|
||||
|
||||
public KtType getModifiedReturnType() {
|
||||
public KotlinType getModifiedReturnType() {
|
||||
return modifiedReturnType;
|
||||
}
|
||||
|
||||
@@ -153,8 +153,8 @@ public class SignaturesPropagationData {
|
||||
signatureErrors.add(error);
|
||||
}
|
||||
|
||||
private KtType modifyReturnTypeAccordingToSuperMethods(
|
||||
@NotNull KtType autoType // type built by JavaTypeTransformer
|
||||
private KotlinType modifyReturnTypeAccordingToSuperMethods(
|
||||
@NotNull KotlinType autoType // type built by JavaTypeTransformer
|
||||
) {
|
||||
if (JavaDescriptorResolverKt.getPLATFORM_TYPES()) return autoType;
|
||||
|
||||
@@ -179,24 +179,24 @@ public class SignaturesPropagationData {
|
||||
int index = autoParameter.getIndex();
|
||||
TypeParameterDescriptorImpl modifiedTypeParameter = autoTypeParameterToModified.get(autoParameter);
|
||||
|
||||
List<Iterator<KtType>> upperBoundFromSuperFunctionsIterators = Lists.newArrayList();
|
||||
List<Iterator<KotlinType>> upperBoundFromSuperFunctionsIterators = Lists.newArrayList();
|
||||
for (FunctionDescriptor superFunction : superFunctions) {
|
||||
upperBoundFromSuperFunctionsIterators.add(superFunction.getTypeParameters().get(index).getUpperBounds().iterator());
|
||||
}
|
||||
|
||||
for (KtType autoUpperBound : autoParameter.getUpperBounds()) {
|
||||
for (KotlinType autoUpperBound : autoParameter.getUpperBounds()) {
|
||||
List<TypeAndVariance> upperBoundsFromSuperFunctions = Lists.newArrayList();
|
||||
|
||||
for (Iterator<KtType> iterator : upperBoundFromSuperFunctionsIterators) {
|
||||
for (Iterator<KotlinType> iterator : upperBoundFromSuperFunctionsIterators) {
|
||||
assert iterator.hasNext();
|
||||
upperBoundsFromSuperFunctions.add(new TypeAndVariance(iterator.next(), INVARIANT));
|
||||
}
|
||||
|
||||
KtType modifiedUpperBound = modifyTypeAccordingToSuperMethods(autoUpperBound, upperBoundsFromSuperFunctions, UPPER_BOUND);
|
||||
KotlinType modifiedUpperBound = modifyTypeAccordingToSuperMethods(autoUpperBound, upperBoundsFromSuperFunctions, UPPER_BOUND);
|
||||
modifiedTypeParameter.addUpperBound(modifiedUpperBound);
|
||||
}
|
||||
|
||||
for (Iterator<KtType> iterator : upperBoundFromSuperFunctionsIterators) {
|
||||
for (Iterator<KotlinType> iterator : upperBoundFromSuperFunctionsIterators) {
|
||||
assert !iterator.hasNext();
|
||||
}
|
||||
|
||||
@@ -208,14 +208,14 @@ public class SignaturesPropagationData {
|
||||
}
|
||||
|
||||
private ValueParameters modifyValueParametersAccordingToSuperMethods(
|
||||
@Nullable KtType receiverType,
|
||||
@Nullable KotlinType receiverType,
|
||||
@NotNull List<ValueParameterDescriptor> parameters // descriptors built by parameters resolver
|
||||
) {
|
||||
assert receiverType == null : "Parameters before propagation have receiver type," +
|
||||
" but propagation should be disabled for functions compiled from Kotlin in class: " +
|
||||
DescriptorUtils.getFqName(containingClass);
|
||||
|
||||
KtType resultReceiverType = null;
|
||||
KotlinType resultReceiverType = null;
|
||||
List<ValueParameterDescriptor> resultParameters = new ArrayList<ValueParameterDescriptor>(parameters.size());
|
||||
|
||||
boolean shouldBeExtension = checkIfShouldBeExtension();
|
||||
@@ -239,9 +239,9 @@ public class SignaturesPropagationData {
|
||||
|
||||
VarargCheckResult varargCheckResult = checkVarargInSuperFunctions(originalParam);
|
||||
|
||||
KtType altType = modifyTypeAccordingToSuperMethods(varargCheckResult.parameterType,
|
||||
convertToTypeVarianceList(typesFromSuperMethods),
|
||||
MEMBER_SIGNATURE_CONTRAVARIANT);
|
||||
KotlinType altType = modifyTypeAccordingToSuperMethods(varargCheckResult.parameterType,
|
||||
convertToTypeVarianceList(typesFromSuperMethods),
|
||||
MEMBER_SIGNATURE_CONTRAVARIANT);
|
||||
|
||||
if (shouldBeExtension && originalIndex == 0) {
|
||||
resultReceiverType = altType;
|
||||
@@ -304,7 +304,7 @@ public class SignaturesPropagationData {
|
||||
// TODO: Add propagation for other kotlin descriptors (KT-3621)
|
||||
Name name = method.getName();
|
||||
JvmMethodSignature autoSignature = SIGNATURE_MAPPER.mapToJvmMethodSignature(autoMethodDescriptor);
|
||||
for (KtType supertype : containingClass.getTypeConstructor().getSupertypes()) {
|
||||
for (KotlinType supertype : containingClass.getTypeConstructor().getSupertypes()) {
|
||||
Collection<FunctionDescriptor> superFunctionCandidates = supertype.getMemberScope().getFunctions(name, NoLookupLocation.WHEN_GET_SUPER_MEMBERS);
|
||||
for (FunctionDescriptor candidate : superFunctionCandidates) {
|
||||
JvmMethodSignature candidateSignature = SIGNATURE_MAPPER.mapToJvmMethodSignature(candidate);
|
||||
@@ -365,8 +365,8 @@ public class SignaturesPropagationData {
|
||||
}
|
||||
}
|
||||
|
||||
KtType originalVarargElementType = originalParam.getVarargElementType();
|
||||
KtType originalType = originalParam.getType();
|
||||
KotlinType originalVarargElementType = originalParam.getVarargElementType();
|
||||
KotlinType originalType = originalParam.getType();
|
||||
|
||||
if (someSupersVararg && someSupersNotVararg) {
|
||||
reportError("Incompatible super methods: some have vararg parameter, some have not");
|
||||
@@ -389,8 +389,8 @@ public class SignaturesPropagationData {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private KtType modifyTypeAccordingToSuperMethods(
|
||||
@NotNull KtType autoType,
|
||||
private KotlinType modifyTypeAccordingToSuperMethods(
|
||||
@NotNull KotlinType autoType,
|
||||
@NotNull List<TypeAndVariance> typesFromSuper,
|
||||
@NotNull TypeUsage howThisTypeIsUsed
|
||||
) {
|
||||
@@ -409,11 +409,11 @@ public class SignaturesPropagationData {
|
||||
resultScope = autoType.getMemberScope();
|
||||
}
|
||||
|
||||
KtType type = KtTypeImpl.create(autoType.getAnnotations(),
|
||||
resultClassifier.getTypeConstructor(),
|
||||
resultNullable,
|
||||
resultArguments,
|
||||
resultScope);
|
||||
KotlinType type = KotlinTypeImpl.create(autoType.getAnnotations(),
|
||||
resultClassifier.getTypeConstructor(),
|
||||
resultNullable,
|
||||
resultArguments,
|
||||
resultScope);
|
||||
|
||||
PropagationHeuristics.checkArrayInReturnType(this, type, typesFromSuper);
|
||||
return type;
|
||||
@@ -421,7 +421,7 @@ public class SignaturesPropagationData {
|
||||
|
||||
@NotNull
|
||||
private List<TypeProjection> getTypeArgsOfType(
|
||||
@NotNull KtType autoType,
|
||||
@NotNull KotlinType autoType,
|
||||
@NotNull ClassifierDescriptor classifier,
|
||||
@NotNull List<TypeAndVariance> typesFromSuper
|
||||
) {
|
||||
@@ -444,11 +444,11 @@ public class SignaturesPropagationData {
|
||||
for (TypeParameterDescriptor parameter : classifier.getTypeConstructor().getParameters()) {
|
||||
TypeProjection argument = autoArguments.get(parameter.getIndex());
|
||||
|
||||
KtType argumentType = argument.getType();
|
||||
KotlinType argumentType = argument.getType();
|
||||
List<TypeProjectionAndVariance> projectionsFromSuper = typeArgumentsFromSuper.get(parameter.getIndex());
|
||||
List<TypeAndVariance> argTypesFromSuper = getTypes(projectionsFromSuper);
|
||||
|
||||
KtType type = modifyTypeAccordingToSuperMethods(argumentType, argTypesFromSuper, TYPE_ARGUMENT);
|
||||
KotlinType type = modifyTypeAccordingToSuperMethods(argumentType, argTypesFromSuper, TYPE_ARGUMENT);
|
||||
Variance projectionKind = calculateArgumentProjectionKindFromSuper(argument, projectionsFromSuper);
|
||||
|
||||
resultArguments.add(new TypeProjectionImpl(projectionKind, type));
|
||||
@@ -567,7 +567,7 @@ public class SignaturesPropagationData {
|
||||
}
|
||||
|
||||
private boolean typeMustBeNullable(
|
||||
@NotNull KtType autoType,
|
||||
@NotNull KotlinType autoType,
|
||||
@NotNull List<TypeAndVariance> typesFromSuper,
|
||||
@NotNull TypeUsage howThisTypeIsUsed
|
||||
) {
|
||||
@@ -611,7 +611,7 @@ public class SignaturesPropagationData {
|
||||
|
||||
@NotNull
|
||||
private ClassifierDescriptor modifyTypeClassifier(
|
||||
@NotNull KtType autoType,
|
||||
@NotNull KotlinType autoType,
|
||||
@NotNull List<TypeAndVariance> typesFromSuper
|
||||
) {
|
||||
ClassifierDescriptor classifier = autoType.getConstructor().getDeclarationDescriptor();
|
||||
@@ -666,15 +666,15 @@ public class SignaturesPropagationData {
|
||||
return fixed != null ? fixed : classifier;
|
||||
}
|
||||
|
||||
private static boolean isArrayType(@NotNull KtType type) {
|
||||
private static boolean isArrayType(@NotNull KotlinType type) {
|
||||
return KotlinBuiltIns.isArray(type) || KotlinBuiltIns.isPrimitiveArray(type);
|
||||
}
|
||||
|
||||
private static class VarargCheckResult {
|
||||
public final KtType parameterType;
|
||||
public final KotlinType parameterType;
|
||||
public final boolean isVararg;
|
||||
|
||||
public VarargCheckResult(KtType parameterType, boolean isVararg) {
|
||||
public VarargCheckResult(KotlinType parameterType, boolean isVararg) {
|
||||
this.parameterType = parameterType;
|
||||
this.isVararg = isVararg;
|
||||
}
|
||||
@@ -695,10 +695,10 @@ public class SignaturesPropagationData {
|
||||
}
|
||||
|
||||
static class TypeAndVariance {
|
||||
public final KtType type;
|
||||
public final KotlinType type;
|
||||
public final Variance varianceOfPosition;
|
||||
|
||||
public TypeAndVariance(KtType type, Variance varianceOfPosition) {
|
||||
public TypeAndVariance(KotlinType type, Variance varianceOfPosition) {
|
||||
this.type = type;
|
||||
this.varianceOfPosition = varianceOfPosition;
|
||||
}
|
||||
@@ -709,22 +709,22 @@ public class SignaturesPropagationData {
|
||||
}
|
||||
|
||||
private static class TypeAndName {
|
||||
public final KtType type;
|
||||
public final KotlinType type;
|
||||
public final Name name;
|
||||
|
||||
public TypeAndName(KtType type, Name name) {
|
||||
public TypeAndName(KotlinType type, Name name) {
|
||||
this.type = type;
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
||||
private static class ValueParameters {
|
||||
private final KtType receiverType;
|
||||
private final KotlinType receiverType;
|
||||
private final List<ValueParameterDescriptor> descriptors;
|
||||
private final boolean hasStableParameterNames;
|
||||
|
||||
public ValueParameters(
|
||||
@Nullable KtType receiverType,
|
||||
@Nullable KotlinType receiverType,
|
||||
@NotNull List<ValueParameterDescriptor> descriptors,
|
||||
boolean hasStableParameterNames
|
||||
) {
|
||||
|
||||
+14
-14
@@ -42,16 +42,16 @@ import java.util.*;
|
||||
import static org.jetbrains.kotlin.load.java.components.TypeUsage.TYPE_ARGUMENT;
|
||||
import static org.jetbrains.kotlin.types.Variance.INVARIANT;
|
||||
|
||||
public class TypeTransformingVisitor extends KtVisitor<KtType, Void> {
|
||||
public class TypeTransformingVisitor extends KtVisitor<KotlinType, Void> {
|
||||
private static boolean strictMode = false;
|
||||
|
||||
private final KtType originalType;
|
||||
private final KotlinType originalType;
|
||||
private final Map<TypeParameterDescriptor, TypeParameterDescriptorImpl> originalToAltTypeParameters;
|
||||
|
||||
private final TypeUsage typeUsage;
|
||||
|
||||
private TypeTransformingVisitor(
|
||||
KtType originalType,
|
||||
KotlinType originalType,
|
||||
Map<TypeParameterDescriptor, TypeParameterDescriptorImpl> originalToAltTypeParameters,
|
||||
TypeUsage typeUsage
|
||||
) {
|
||||
@@ -61,19 +61,19 @@ public class TypeTransformingVisitor extends KtVisitor<KtType, Void> {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static KtType computeType(
|
||||
public static KotlinType computeType(
|
||||
@NotNull KtTypeElement alternativeTypeElement,
|
||||
@NotNull KtType originalType,
|
||||
@NotNull KotlinType originalType,
|
||||
@NotNull Map<TypeParameterDescriptor, TypeParameterDescriptorImpl> originalToAltTypeParameters,
|
||||
@NotNull TypeUsage typeUsage
|
||||
) {
|
||||
KtType computedType = alternativeTypeElement.accept(new TypeTransformingVisitor(originalType, originalToAltTypeParameters, typeUsage), null);
|
||||
KotlinType computedType = alternativeTypeElement.accept(new TypeTransformingVisitor(originalType, originalToAltTypeParameters, typeUsage), null);
|
||||
assert (computedType != null);
|
||||
return computedType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KtType visitNullableType(@NotNull KtNullableType nullableType, Void aVoid) {
|
||||
public KotlinType visitNullableType(@NotNull KtNullableType nullableType, Void aVoid) {
|
||||
if (!TypeUtils.isNullableType(originalType) && typeUsage != TYPE_ARGUMENT) {
|
||||
throw new AlternativeSignatureMismatchException("Auto type '%s' is not-null, while type in alternative signature is nullable: '%s'",
|
||||
DescriptorRenderer.FQ_NAMES_IN_TYPES.renderType(originalType), nullableType.getText());
|
||||
@@ -84,7 +84,7 @@ public class TypeTransformingVisitor extends KtVisitor<KtType, Void> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public KtType visitFunctionType(@NotNull KtFunctionType type, Void data) {
|
||||
public KotlinType visitFunctionType(@NotNull KtFunctionType type, Void data) {
|
||||
KotlinBuiltIns builtIns = JvmPlatform.INSTANCE$.getBuiltIns();
|
||||
return visitCommonType(type.getReceiverTypeReference() == null
|
||||
? builtIns.getFunction(type.getParameters().size())
|
||||
@@ -92,7 +92,7 @@ public class TypeTransformingVisitor extends KtVisitor<KtType, Void> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public KtType visitUserType(@NotNull KtUserType type, Void data) {
|
||||
public KotlinType visitUserType(@NotNull KtUserType type, Void data) {
|
||||
KtUserType qualifier = type.getQualifier();
|
||||
|
||||
//noinspection ConstantConditions
|
||||
@@ -102,12 +102,12 @@ public class TypeTransformingVisitor extends KtVisitor<KtType, Void> {
|
||||
return visitCommonType(longName, type);
|
||||
}
|
||||
|
||||
private KtType visitCommonType(@NotNull ClassDescriptor classDescriptor, @NotNull KtTypeElement type) {
|
||||
private KotlinType visitCommonType(@NotNull ClassDescriptor classDescriptor, @NotNull KtTypeElement type) {
|
||||
return visitCommonType(DescriptorUtils.getFqNameSafe(classDescriptor).asString(), type);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private KtType visitCommonType(@NotNull String qualifiedName, @NotNull KtTypeElement type) {
|
||||
private KotlinType visitCommonType(@NotNull String qualifiedName, @NotNull KtTypeElement type) {
|
||||
if (originalType.isError()) {
|
||||
return originalType;
|
||||
}
|
||||
@@ -159,7 +159,7 @@ public class TypeTransformingVisitor extends KtVisitor<KtType, Void> {
|
||||
throw new AssertionError("Unexpected class of type constructor classifier "
|
||||
+ (typeConstructorClassifier == null ? "null" : typeConstructorClassifier.getClass().getName()));
|
||||
}
|
||||
return KtTypeImpl.create(originalType.getAnnotations(), typeConstructor, false, altArguments, memberScope);
|
||||
return KotlinTypeImpl.create(originalType.getAnnotations(), typeConstructor, false, altArguments, memberScope);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -183,7 +183,7 @@ public class TypeTransformingVisitor extends KtVisitor<KtType, Void> {
|
||||
assert argumentAlternativeTypeElement != null;
|
||||
|
||||
TypeParameterDescriptor parameter = typeConstructor.getParameters().get(i);
|
||||
KtType alternativeArgumentType = computeType(argumentAlternativeTypeElement, originalArgument.getType(), originalToAltTypeParameters, TYPE_ARGUMENT);
|
||||
KotlinType alternativeArgumentType = computeType(argumentAlternativeTypeElement, originalArgument.getType(), originalToAltTypeParameters, TYPE_ARGUMENT);
|
||||
Variance projectionKind = originalArgument.getProjectionKind();
|
||||
Variance altProjectionKind;
|
||||
if (type instanceof KtUserType) {
|
||||
@@ -234,7 +234,7 @@ public class TypeTransformingVisitor extends KtVisitor<KtType, Void> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public KtType visitSelfType(@NotNull KtSelfType type, Void data) {
|
||||
public KotlinType visitSelfType(@NotNull KtSelfType type, Void data) {
|
||||
throw new UnsupportedOperationException("Self-types are not supported yet");
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -39,8 +39,8 @@ public object JavaGenericVarianceViolationTypeChecker : AdditionalTypeChecker {
|
||||
// JavaClass.fillWithDefaultObjects(x) // using `x` after this call may lead to CCE
|
||||
override fun checkType(
|
||||
expression: KtExpression,
|
||||
expressionType: KtType,
|
||||
expressionTypeWithSmartCast: KtType,
|
||||
expressionType: KotlinType,
|
||||
expressionTypeWithSmartCast: KotlinType,
|
||||
c: ResolutionContext<*>
|
||||
) {
|
||||
val expectedType = c.expectedType
|
||||
|
||||
+3
-3
@@ -129,7 +129,7 @@ class JavaSyntheticPropertiesScope(storageManager: StorageManager) : KtScopeImpl
|
||||
return null
|
||||
}
|
||||
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KtType>, name: Name, location: LookupLocation): Collection<PropertyDescriptor> {
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KotlinType>, name: Name, location: LookupLocation): Collection<PropertyDescriptor> {
|
||||
//TODO: use location parameter!
|
||||
|
||||
var result: SmartList<PropertyDescriptor>? = null
|
||||
@@ -161,7 +161,7 @@ class JavaSyntheticPropertiesScope(storageManager: StorageManager) : KtScopeImpl
|
||||
return result
|
||||
}
|
||||
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KtType>): Collection<PropertyDescriptor> {
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KotlinType>): Collection<PropertyDescriptor> {
|
||||
val result = ArrayList<PropertyDescriptor>()
|
||||
val processedTypes = HashSet<TypeConstructor>()
|
||||
receiverTypes.forEach { result.collectSyntheticProperties(it.constructor, processedTypes) }
|
||||
@@ -252,7 +252,7 @@ class JavaSyntheticPropertiesScope(storageManager: StorageManager) : KtScopeImpl
|
||||
private set
|
||||
|
||||
companion object {
|
||||
fun create(ownerClass: ClassDescriptor, getMethod: FunctionDescriptor, setMethod: FunctionDescriptor?, name: Name, type: KtType): MyPropertyDescriptor {
|
||||
fun create(ownerClass: ClassDescriptor, getMethod: FunctionDescriptor, setMethod: FunctionDescriptor?, name: Name, type: KotlinType): MyPropertyDescriptor {
|
||||
val visibility = syntheticExtensionVisibility(getMethod)
|
||||
val descriptor = MyPropertyDescriptor(DescriptorUtils.getContainingModule(ownerClass),
|
||||
null,
|
||||
|
||||
+4
-4
@@ -52,7 +52,7 @@ class SamAdapterFunctionsScope(storageManager: StorageManager) : KtScope by KtSc
|
||||
return MyFunctionDescriptor.create(enhancedFunction)
|
||||
}
|
||||
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<KtType>, name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<KotlinType>, name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
|
||||
var result: SmartList<FunctionDescriptor>? = null
|
||||
for (type in receiverTypes) {
|
||||
for (function in type.memberScope.getFunctions(name, location)) {
|
||||
@@ -72,7 +72,7 @@ class SamAdapterFunctionsScope(storageManager: StorageManager) : KtScope by KtSc
|
||||
}
|
||||
}
|
||||
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<KtType>): Collection<FunctionDescriptor> {
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<KotlinType>): Collection<FunctionDescriptor> {
|
||||
return receiverTypes.flatMapTo(LinkedHashSet<FunctionDescriptor>()) { type ->
|
||||
type.memberScope.getDescriptors(DescriptorKindFilter.FUNCTIONS)
|
||||
.filterIsInstance<FunctionDescriptor>()
|
||||
@@ -156,8 +156,8 @@ class SamAdapterFunctionsScope(storageManager: StorageManager) : KtScope by KtSc
|
||||
copyOverrides: Boolean,
|
||||
kind: CallableMemberDescriptor.Kind,
|
||||
newValueParameterDescriptors: MutableList<ValueParameterDescriptor>,
|
||||
newExtensionReceiverParameterType: KtType?,
|
||||
newReturnType: KtType
|
||||
newExtensionReceiverParameterType: KotlinType?,
|
||||
newReturnType: KotlinType
|
||||
): FunctionDescriptor? {
|
||||
val descriptor = super<SimpleFunctionDescriptorImpl>.doSubstitute(
|
||||
originalSubstitutor, newOwner, newModality, newVisibility,
|
||||
|
||||
@@ -56,7 +56,7 @@ import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver;
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ThisReceiver;
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.TransientReceiver;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.expressions.OperatorConventions;
|
||||
|
||||
import java.util.*;
|
||||
@@ -109,7 +109,7 @@ public class JetControlFlowProcessor {
|
||||
CallableDescriptor subroutineDescriptor = (CallableDescriptor) trace.get(BindingContext.DECLARATION_TO_DESCRIPTOR, subroutine);
|
||||
if (subroutineDescriptor == null) return;
|
||||
|
||||
KtType returnType = subroutineDescriptor.getReturnType();
|
||||
KotlinType returnType = subroutineDescriptor.getReturnType();
|
||||
if (returnType != null && KotlinBuiltIns.isUnit(returnType) && subroutineDescriptor instanceof AnonymousFunctionDescriptor) return;
|
||||
|
||||
PseudoValue returnValue = builder.getBoundValue(bodyExpression);
|
||||
@@ -199,7 +199,7 @@ public class JetControlFlowProcessor {
|
||||
return;
|
||||
}
|
||||
|
||||
KtType type = trace.getBindingContext().getType(expression);
|
||||
KotlinType type = trace.getBindingContext().getType(expression);
|
||||
if (type != null && KotlinBuiltIns.isNothing(type)) {
|
||||
builder.jumpToError(expression);
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilKt;
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.kotlin.resolve.calls.resolvedCallUtil.ResolvedCallUtilKt;
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils;
|
||||
|
||||
import java.util.*;
|
||||
@@ -129,7 +129,7 @@ public class JetFlowInformationProvider {
|
||||
markWhenWithoutElse();
|
||||
}
|
||||
|
||||
public void checkFunction(@Nullable KtType expectedReturnType) {
|
||||
public void checkFunction(@Nullable KotlinType expectedReturnType) {
|
||||
UnreachableCode unreachableCode = collectUnreachableCode();
|
||||
reportUnreachableCode(unreachableCode);
|
||||
|
||||
@@ -208,7 +208,7 @@ public class JetFlowInformationProvider {
|
||||
|
||||
CallableDescriptor functionDescriptor =
|
||||
(CallableDescriptor) trace.getBindingContext().get(BindingContext.DECLARATION_TO_DESCRIPTOR, localDeclaration);
|
||||
KtType expectedType = functionDescriptor != null ? functionDescriptor.getReturnType() : null;
|
||||
KotlinType expectedType = functionDescriptor != null ? functionDescriptor.getReturnType() : null;
|
||||
|
||||
JetFlowInformationProvider providerForLocalDeclaration =
|
||||
new JetFlowInformationProvider(localDeclaration, trace, localDeclarationInstruction.getBody());
|
||||
@@ -218,7 +218,7 @@ public class JetFlowInformationProvider {
|
||||
}
|
||||
}
|
||||
|
||||
public void checkDefiniteReturn(final @NotNull KtType expectedReturnType, @NotNull final UnreachableCode unreachableCode) {
|
||||
public void checkDefiniteReturn(final @NotNull KotlinType expectedReturnType, @NotNull final UnreachableCode unreachableCode) {
|
||||
assert subroutine instanceof KtDeclarationWithBody;
|
||||
KtDeclarationWithBody function = (KtDeclarationWithBody) subroutine;
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ import org.jetbrains.kotlin.resolve.CompileTimeConstantUtils;
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
||||
import org.jetbrains.kotlin.resolve.bindingContextUtil.BindingContextUtilsKt;
|
||||
import org.jetbrains.kotlin.types.FlexibleTypesKt;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.TypeUtils;
|
||||
|
||||
import java.util.HashSet;
|
||||
@@ -41,7 +41,7 @@ public final class WhenChecker {
|
||||
}
|
||||
|
||||
public static boolean mustHaveElse(@NotNull KtWhenExpression expression, @NotNull BindingTrace trace) {
|
||||
KtType expectedType = trace.get(BindingContext.EXPECTED_EXPRESSION_TYPE, expression);
|
||||
KotlinType expectedType = trace.get(BindingContext.EXPECTED_EXPRESSION_TYPE, expression);
|
||||
boolean isUnit = expectedType != null && KotlinBuiltIns.isUnit(expectedType);
|
||||
// Some "statements" are actually expressions returned from lambdas, their expected types are non-null
|
||||
boolean isStatement = BindingContextUtilsKt.isUsedAsStatement(expression, trace.getBindingContext()) && expectedType == null;
|
||||
@@ -54,7 +54,7 @@ public final class WhenChecker {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static ClassDescriptor getClassDescriptorOfTypeIfEnum(@Nullable KtType type) {
|
||||
public static ClassDescriptor getClassDescriptorOfTypeIfEnum(@Nullable KotlinType type) {
|
||||
if (type == null) return null;
|
||||
ClassDescriptor classDescriptor = TypeUtils.getClassDescriptor(type);
|
||||
if (classDescriptor == null) return null;
|
||||
@@ -64,7 +64,7 @@ public final class WhenChecker {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static KtType whenSubjectType(@NotNull KtWhenExpression expression, @NotNull BindingContext context) {
|
||||
private static KotlinType whenSubjectType(@NotNull KtWhenExpression expression, @NotNull BindingContext context) {
|
||||
KtExpression subjectExpression = expression.getSubjectExpression();
|
||||
return subjectExpression == null ? null : context.getType(subjectExpression);
|
||||
}
|
||||
@@ -136,7 +136,7 @@ public final class WhenChecker {
|
||||
*/
|
||||
private static boolean isNullableTypeWithoutPossibleSmartCast(
|
||||
@Nullable KtExpression expression,
|
||||
@NotNull KtType type,
|
||||
@NotNull KotlinType type,
|
||||
@NotNull BindingContext context
|
||||
) {
|
||||
if (expression == null) return false; // Normally should not happen
|
||||
@@ -152,7 +152,7 @@ public final class WhenChecker {
|
||||
}
|
||||
|
||||
public static boolean isWhenExhaustive(@NotNull KtWhenExpression expression, @NotNull BindingTrace trace) {
|
||||
KtType type = whenSubjectType(expression, trace.getBindingContext());
|
||||
KotlinType type = whenSubjectType(expression, trace.getBindingContext());
|
||||
if (type == null) return false;
|
||||
ClassDescriptor enumClassDescriptor = getClassDescriptorOfTypeIfEnum(type);
|
||||
|
||||
@@ -196,7 +196,7 @@ public final class WhenChecker {
|
||||
ClassDescriptor checkedDescriptor = null;
|
||||
if (condition instanceof KtWhenConditionIsPattern) {
|
||||
KtWhenConditionIsPattern conditionIsPattern = (KtWhenConditionIsPattern) condition;
|
||||
KtType checkedType = trace.get(BindingContext.TYPE, conditionIsPattern.getTypeReference());
|
||||
KotlinType checkedType = trace.get(BindingContext.TYPE, conditionIsPattern.getTypeReference());
|
||||
if (checkedType != null) {
|
||||
checkedDescriptor = TypeUtils.getClassDescriptor(checkedType);
|
||||
}
|
||||
@@ -243,7 +243,7 @@ public final class WhenChecker {
|
||||
if (condition instanceof KtWhenConditionWithExpression) {
|
||||
KtWhenConditionWithExpression conditionWithExpression = (KtWhenConditionWithExpression) condition;
|
||||
if (conditionWithExpression.getExpression() != null) {
|
||||
KtType type = trace.getBindingContext().getType(conditionWithExpression.getExpression());
|
||||
KotlinType type = trace.getBindingContext().getType(conditionWithExpression.getExpression());
|
||||
if (type != null && KotlinBuiltIns.isNothingOrNullableNothing(type)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
+2
-2
@@ -31,7 +31,7 @@ import org.jetbrains.kotlin.psi.*;
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant;
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -476,7 +476,7 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd
|
||||
@NotNull Map<PseudoValue, ReceiverValue> receiverValues,
|
||||
@NotNull Map<PseudoValue, ValueParameterDescriptor> arguments
|
||||
) {
|
||||
KtType returnType = resolvedCall.getResultingDescriptor().getReturnType();
|
||||
KotlinType returnType = resolvedCall.getResultingDescriptor().getReturnType();
|
||||
CallInstruction instruction = new CallInstruction(
|
||||
valueElement,
|
||||
getCurrentScope(),
|
||||
|
||||
@@ -35,7 +35,7 @@ import org.jetbrains.kotlin.resolve.BindingContextUtils;
|
||||
import org.jetbrains.kotlin.resolve.BindingTrace;
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.kotlin.resolve.calls.resolvedCallUtil.ResolvedCallUtilKt;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.util.slicedMap.ReadOnlySlice;
|
||||
import org.jetbrains.kotlin.util.slicedMap.WritableSlice;
|
||||
|
||||
@@ -72,12 +72,12 @@ public class PseudocodeUtil {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public KtType getType(@NotNull KtExpression expression) {
|
||||
public KotlinType getType(@NotNull KtExpression expression) {
|
||||
return bindingContext.getType(expression);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recordType(@NotNull KtExpression expression, @Nullable KtType type) {
|
||||
public void recordType(@NotNull KtExpression expression, @Nullable KotlinType type) {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,39 +19,39 @@ package org.jetbrains.kotlin.cfg.pseudocode
|
||||
import com.intellij.util.SmartFMap
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.renderer.DescriptorRenderer
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
|
||||
|
||||
public interface TypePredicate: (KtType) -> Boolean {
|
||||
override fun invoke(typeToCheck: KtType): Boolean
|
||||
public interface TypePredicate: (KotlinType) -> Boolean {
|
||||
override fun invoke(typeToCheck: KotlinType): Boolean
|
||||
}
|
||||
|
||||
public data class SingleType(val targetType: KtType): TypePredicate {
|
||||
override fun invoke(typeToCheck: KtType): Boolean = KotlinTypeChecker.DEFAULT.equalTypes(typeToCheck, targetType)
|
||||
public data class SingleType(val targetType: KotlinType): TypePredicate {
|
||||
override fun invoke(typeToCheck: KotlinType): Boolean = KotlinTypeChecker.DEFAULT.equalTypes(typeToCheck, targetType)
|
||||
override fun toString(): String = targetType.render()
|
||||
}
|
||||
|
||||
public data class AllSubtypes(val upperBound: KtType): TypePredicate {
|
||||
override fun invoke(typeToCheck: KtType): Boolean = KotlinTypeChecker.DEFAULT.isSubtypeOf(typeToCheck, upperBound)
|
||||
public data class AllSubtypes(val upperBound: KotlinType): TypePredicate {
|
||||
override fun invoke(typeToCheck: KotlinType): Boolean = KotlinTypeChecker.DEFAULT.isSubtypeOf(typeToCheck, upperBound)
|
||||
|
||||
override fun toString(): String = "{<: ${upperBound.render()}}"
|
||||
}
|
||||
|
||||
public data class ForAllTypes(val typeSets: List<TypePredicate>): TypePredicate {
|
||||
override fun invoke(typeToCheck: KtType): Boolean = typeSets.all { it(typeToCheck) }
|
||||
override fun invoke(typeToCheck: KotlinType): Boolean = typeSets.all { it(typeToCheck) }
|
||||
|
||||
override fun toString(): String = "AND{${typeSets.joinToString(", ")}}"
|
||||
}
|
||||
|
||||
public data class ForSomeType(val typeSets: List<TypePredicate>): TypePredicate {
|
||||
override fun invoke(typeToCheck: KtType): Boolean = typeSets.any { it(typeToCheck) }
|
||||
override fun invoke(typeToCheck: KotlinType): Boolean = typeSets.any { it(typeToCheck) }
|
||||
|
||||
override fun toString(): String = "OR{${typeSets.joinToString(", ")}}"
|
||||
}
|
||||
|
||||
public object AllTypes : TypePredicate {
|
||||
override fun invoke(typeToCheck: KtType): Boolean = true
|
||||
override fun invoke(typeToCheck: KotlinType): Boolean = true
|
||||
|
||||
override fun toString(): String = "*"
|
||||
}
|
||||
@@ -71,7 +71,7 @@ public fun or(predicates: Collection<TypePredicate>): TypePredicate? =
|
||||
else -> ForSomeType(predicates.toList())
|
||||
}
|
||||
|
||||
fun KtType.getSubtypesPredicate(): TypePredicate {
|
||||
fun KotlinType.getSubtypesPredicate(): TypePredicate {
|
||||
return when {
|
||||
KotlinBuiltIns.isAnyOrNullableAny(this) && isMarkedNullable() -> AllTypes
|
||||
TypeUtils.canHaveSubtypes(KotlinTypeChecker.DEFAULT, this) -> AllSubtypes(this)
|
||||
@@ -80,7 +80,7 @@ fun KtType.getSubtypesPredicate(): TypePredicate {
|
||||
}
|
||||
|
||||
|
||||
private fun KtType.render(): String = DescriptorRenderer.SHORT_NAMES_IN_TYPES.renderType(this)
|
||||
private fun KotlinType.render(): String = DescriptorRenderer.SHORT_NAMES_IN_TYPES.renderType(this)
|
||||
|
||||
public fun <T> TypePredicate.expectedTypeFor(keys: Iterable<T>): Map<T, TypePredicate> =
|
||||
keys.fold(SmartFMap.emptyMap<T, TypePredicate>()) { map, key -> map.plus(key, this) }
|
||||
|
||||
@@ -46,7 +46,7 @@ import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind
|
||||
import org.jetbrains.kotlin.resolve.calls.tasks.ResolutionCandidate
|
||||
import org.jetbrains.kotlin.resolve.calls.tasks.TracingStrategy
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
import java.util.*
|
||||
|
||||
@@ -77,7 +77,7 @@ public fun getExpectedTypePredicate(
|
||||
val pseudocode = value.createdAt?.owner ?: return AllTypes
|
||||
val typePredicates = LinkedHashSet<TypePredicate?>()
|
||||
|
||||
fun addSubtypesOf(jetType: KtType?) = typePredicates.add(jetType?.getSubtypesPredicate())
|
||||
fun addSubtypesOf(jetType: KotlinType?) = typePredicates.add(jetType?.getSubtypesPredicate())
|
||||
|
||||
fun addByExplicitReceiver(resolvedCall: ResolvedCall<*>?) {
|
||||
val receiverValue = (resolvedCall ?: return).getExplicitReceiverValue()
|
||||
|
||||
@@ -38,7 +38,7 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilKt;
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.kotlin.resolve.calls.tasks.DynamicCallsKt;
|
||||
import org.jetbrains.kotlin.types.ErrorUtils;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.util.slicedMap.WritableSlice;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -196,7 +196,7 @@ public class DebugInfoUtil {
|
||||
// if 'foo' in 'foo[i]' is unresolved it means 'foo[i]' is unresolved (otherwise 'foo[i]' is marked as 'missing unresolved')
|
||||
markedWithError = true;
|
||||
}
|
||||
KtType expressionType = bindingContext.getType(expression);
|
||||
KotlinType expressionType = bindingContext.getType(expression);
|
||||
DiagnosticFactory<?> factory = markedWithErrorElements.get(expression);
|
||||
if (declarationDescriptor != null &&
|
||||
(ErrorUtils.isError(declarationDescriptor) || ErrorUtils.containsErrorType(expressionType))) {
|
||||
|
||||
+2
-2
@@ -21,7 +21,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.TypeSubstitutor;
|
||||
|
||||
public class LocalVariableDescriptor extends VariableDescriptorWithInitializerImpl {
|
||||
@@ -29,7 +29,7 @@ public class LocalVariableDescriptor extends VariableDescriptorWithInitializerIm
|
||||
@NotNull DeclarationDescriptor containingDeclaration,
|
||||
@NotNull Annotations annotations,
|
||||
@NotNull Name name,
|
||||
@Nullable KtType type,
|
||||
@Nullable KotlinType type,
|
||||
boolean mutable,
|
||||
@NotNull SourceElement source
|
||||
) {
|
||||
|
||||
@@ -30,7 +30,7 @@ import org.jetbrains.kotlin.psi.*;
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.InferenceErrorData;
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.kotlin.resolve.varianceChecker.VarianceChecker.VarianceConflictDiagnosticData;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
@@ -91,7 +91,7 @@ public interface Errors {
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
DiagnosticFactory0<KtTypeProjection> PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT = DiagnosticFactory0.create(ERROR, VARIANCE_IN_PROJECTION);
|
||||
DiagnosticFactory2<KtTypeReference, KtType, KtType> UPPER_BOUND_VIOLATED = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory2<KtTypeReference, KotlinType, KotlinType> UPPER_BOUND_VIOLATED = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory0<KtNullableType> REDUNDANT_NULLABLE = DiagnosticFactory0.create(WARNING, NULLABLE_TYPE);
|
||||
DiagnosticFactory1<KtElement, Integer> WRONG_NUMBER_OF_TYPE_ARGUMENTS = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory2<KtTypeReference, Integer, String> NO_TYPE_ARGUMENTS_ON_RHS = DiagnosticFactory2.create(ERROR);
|
||||
@@ -148,7 +148,7 @@ public interface Errors {
|
||||
DiagnosticFactory0<PsiElement> CONST_VAL_NOT_TOP_LEVEL_OR_OBJECT = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<PsiElement> CONST_VAL_WITH_GETTER = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<PsiElement> CONST_VAL_WITH_DELEGATE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, KtType> TYPE_CANT_BE_USED_FOR_CONST_VAL = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, KotlinType> TYPE_CANT_BE_USED_FOR_CONST_VAL = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory0<PsiElement> CONST_VAL_WITHOUT_INITIALIZER = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtExpression> CONST_VAL_WITH_NON_CONST_INITIALIZER = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
@@ -180,9 +180,9 @@ public interface Errors {
|
||||
|
||||
DiagnosticFactory0<KtTypeReference> MANY_CLASSES_IN_SUPERTYPE_LIST = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtTypeReference> SUPERTYPE_APPEARS_TWICE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory3<KtDelegationSpecifierList, TypeParameterDescriptor, ClassDescriptor, Collection<KtType>>
|
||||
DiagnosticFactory3<KtDelegationSpecifierList, TypeParameterDescriptor, ClassDescriptor, Collection<KotlinType>>
|
||||
INCONSISTENT_TYPE_PARAMETER_VALUES = DiagnosticFactory3.create(ERROR);
|
||||
DiagnosticFactory3<KtTypeParameter, TypeParameterDescriptor, ClassDescriptor, Collection<KtType>>
|
||||
DiagnosticFactory3<KtTypeParameter, TypeParameterDescriptor, ClassDescriptor, Collection<KotlinType>>
|
||||
INCONSISTENT_TYPE_PARAMETER_BOUNDS = DiagnosticFactory3.create(ERROR);
|
||||
|
||||
|
||||
@@ -253,7 +253,7 @@ public interface Errors {
|
||||
|
||||
// Type parameter declarations
|
||||
|
||||
DiagnosticFactory1<KtTypeReference, KtType> FINAL_UPPER_BOUND = DiagnosticFactory1.create(WARNING);
|
||||
DiagnosticFactory1<KtTypeReference, KotlinType> FINAL_UPPER_BOUND = DiagnosticFactory1.create(WARNING);
|
||||
DiagnosticFactory0<KtTypeReference> DYNAMIC_UPPER_BOUND = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory1<KtNamedDeclaration, TypeParameterDescriptor> CONFLICTING_UPPER_BOUNDS =
|
||||
@@ -322,7 +322,7 @@ public interface Errors {
|
||||
DiagnosticFactory2.create(ERROR, DECLARATION_NAME);
|
||||
|
||||
|
||||
DiagnosticFactory1<KtNamedDeclaration, Collection<KtType>> AMBIGUOUS_ANONYMOUS_TYPE_INFERRED =
|
||||
DiagnosticFactory1<KtNamedDeclaration, Collection<KotlinType>> AMBIGUOUS_ANONYMOUS_TYPE_INFERRED =
|
||||
DiagnosticFactory1.create(ERROR, DECLARATION_SIGNATURE);
|
||||
|
||||
// Property-specific
|
||||
@@ -334,7 +334,7 @@ public interface Errors {
|
||||
DiagnosticFactory0<PsiElement> GETTER_VISIBILITY_DIFFERS_FROM_PROPERTY_VISIBILITY = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<PsiElement> PRIVATE_SETTER_ON_NON_PRIVATE_LATE_INIT_VAR = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<PsiElement> ACCESSOR_VISIBILITY_FOR_ABSTRACT_PROPERTY = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory2<KtTypeReference, KtType, KtType> WRONG_GETTER_RETURN_TYPE = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory2<KtTypeReference, KotlinType, KotlinType> WRONG_GETTER_RETURN_TYPE = DiagnosticFactory2.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<KtModifierListOwner>
|
||||
ABSTRACT_PROPERTY_IN_PRIMARY_CONSTRUCTOR_PARAMETERS = DiagnosticFactory0.create(ERROR, ABSTRACT_MODIFIER);
|
||||
@@ -370,7 +370,7 @@ public interface Errors {
|
||||
|
||||
DiagnosticFactory0<KtExpression> SETTER_PARAMETER_WITH_DEFAULT_VALUE = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory2<KtTypeReference, KtType, KtType> WRONG_SETTER_PARAMETER_TYPE = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory2<KtTypeReference, KotlinType, KotlinType> WRONG_SETTER_PARAMETER_TYPE = DiagnosticFactory2.create(ERROR);
|
||||
|
||||
// Function-specific
|
||||
|
||||
@@ -452,7 +452,7 @@ public interface Errors {
|
||||
|
||||
DiagnosticFactory1<KtElement, ValueParameterDescriptor> NO_VALUE_FOR_PARAMETER = DiagnosticFactory1.create(ERROR, VALUE_ARGUMENTS);
|
||||
|
||||
DiagnosticFactory1<KtExpression, KtType> MISSING_RECEIVER = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtExpression, KotlinType> MISSING_RECEIVER = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory0<KtExpression> NO_RECEIVER_ALLOWED = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
// Call resolution
|
||||
@@ -461,7 +461,7 @@ public interface Errors {
|
||||
|
||||
DiagnosticFactory0<PsiElement> SAFE_CALL_IN_QUALIFIER = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory2<KtExpression, KtExpression, KtType> FUNCTION_EXPECTED = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory2<KtExpression, KtExpression, KotlinType> FUNCTION_EXPECTED = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory2<KtExpression, KtExpression, Boolean> FUNCTION_CALL_EXPECTED = DiagnosticFactory2.create(ERROR, CALL_EXPRESSION);
|
||||
|
||||
DiagnosticFactory0<PsiElement> NON_TAIL_RECURSIVE_CALL = DiagnosticFactory0.create(WARNING, CALL_EXPRESSION);
|
||||
@@ -478,7 +478,7 @@ public interface Errors {
|
||||
DiagnosticFactory1<PsiElement, KtExpression> INVOKE_EXTENSION_ON_NOT_EXTENSION_FUNCTION = DiagnosticFactory1.create(ERROR);
|
||||
|
||||
DiagnosticFactory1<PsiElement, TypeParameterDescriptor> TYPE_PARAMETER_AS_REIFIED = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, KtType> REIFIED_TYPE_FORBIDDEN_SUBSTITUTION = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, KotlinType> REIFIED_TYPE_FORBIDDEN_SUBSTITUTION = DiagnosticFactory1.create(ERROR);
|
||||
|
||||
// Type inference
|
||||
|
||||
@@ -491,7 +491,7 @@ public interface Errors {
|
||||
DiagnosticFactory0<PsiElement> TYPE_INFERENCE_INCORPORATION_ERROR = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, TypeParameterDescriptor> TYPE_INFERENCE_ONLY_INPUT_TYPES = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, InferenceErrorData> TYPE_INFERENCE_UPPER_BOUND_VIOLATED = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory2<KtElement, KtType, KtType> TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory2<KtElement, KotlinType, KotlinType> TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH = DiagnosticFactory2.create(ERROR);
|
||||
|
||||
// Reflection
|
||||
|
||||
@@ -506,9 +506,9 @@ public interface Errors {
|
||||
// Multi-declarations
|
||||
|
||||
DiagnosticFactory0<KtMultiDeclaration> INITIALIZER_REQUIRED_FOR_MULTIDECLARATION = DiagnosticFactory0.create(ERROR, DEFAULT);
|
||||
DiagnosticFactory2<KtExpression, Name, KtType> COMPONENT_FUNCTION_MISSING = DiagnosticFactory2.create(ERROR, DEFAULT);
|
||||
DiagnosticFactory2<KtExpression, Name, KotlinType> COMPONENT_FUNCTION_MISSING = DiagnosticFactory2.create(ERROR, DEFAULT);
|
||||
DiagnosticFactory2<KtExpression, Name, Collection<? extends ResolvedCall<?>>> COMPONENT_FUNCTION_AMBIGUITY = DiagnosticFactory2.create(ERROR, DEFAULT);
|
||||
DiagnosticFactory3<KtExpression, Name, KtType, KtType> COMPONENT_FUNCTION_RETURN_TYPE_MISMATCH = DiagnosticFactory3.create(ERROR, DEFAULT);
|
||||
DiagnosticFactory3<KtExpression, Name, KotlinType, KotlinType> COMPONENT_FUNCTION_RETURN_TYPE_MISMATCH = DiagnosticFactory3.create(ERROR, DEFAULT);
|
||||
|
||||
// Super calls
|
||||
|
||||
@@ -535,30 +535,30 @@ public interface Errors {
|
||||
ASSIGN_OPERATOR_AMBIGUITY = DiagnosticFactory1.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<KtSimpleNameExpression> EQUALS_MISSING = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory3<KtBinaryExpression, KtSimpleNameExpression, KtType, KtType> EQUALITY_NOT_APPLICABLE =
|
||||
DiagnosticFactory3<KtBinaryExpression, KtSimpleNameExpression, KotlinType, KotlinType> EQUALITY_NOT_APPLICABLE =
|
||||
DiagnosticFactory3.create(ERROR);
|
||||
|
||||
|
||||
DiagnosticFactory1<KtExpression, KtType> HAS_NEXT_MISSING = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtExpression, KtType> HAS_NEXT_FUNCTION_AMBIGUITY = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtExpression, KtType> HAS_NEXT_FUNCTION_NONE_APPLICABLE = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtExpression, KtType> HAS_NEXT_FUNCTION_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtExpression, KotlinType> HAS_NEXT_MISSING = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtExpression, KotlinType> HAS_NEXT_FUNCTION_AMBIGUITY = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtExpression, KotlinType> HAS_NEXT_FUNCTION_NONE_APPLICABLE = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtExpression, KotlinType> HAS_NEXT_FUNCTION_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR);
|
||||
|
||||
DiagnosticFactory1<KtExpression, KtType> NEXT_AMBIGUITY = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtExpression, KtType> NEXT_MISSING = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtExpression, KtType> NEXT_NONE_APPLICABLE = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtExpression, KotlinType> NEXT_AMBIGUITY = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtExpression, KotlinType> NEXT_MISSING = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtExpression, KotlinType> NEXT_NONE_APPLICABLE = DiagnosticFactory1.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<KtExpression> ITERATOR_MISSING = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, Collection<? extends ResolvedCall<?>>> ITERATOR_AMBIGUITY = DiagnosticFactory1.create(ERROR);
|
||||
|
||||
DiagnosticFactory2<KtExpression, String, KtType> DELEGATE_SPECIAL_FUNCTION_MISSING = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory3<PsiElement, FunctionDescriptor, KtType, String> DELEGATE_RESOLVED_TO_DEPRECATED_CONVENTION = DiagnosticFactory3.create(WARNING);
|
||||
DiagnosticFactory2<KtExpression, String, KotlinType> DELEGATE_SPECIAL_FUNCTION_MISSING = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory3<PsiElement, FunctionDescriptor, KotlinType, String> DELEGATE_RESOLVED_TO_DEPRECATED_CONVENTION = DiagnosticFactory3.create(WARNING);
|
||||
DiagnosticFactory2<KtExpression, String, Collection<? extends ResolvedCall<?>>> DELEGATE_SPECIAL_FUNCTION_AMBIGUITY = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory2<KtExpression, String, Collection<? extends ResolvedCall<?>>> DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory3<KtExpression, String, KtType, KtType> DELEGATE_SPECIAL_FUNCTION_RETURN_TYPE_MISMATCH = DiagnosticFactory3.create(ERROR);
|
||||
DiagnosticFactory3<KtExpression, String, KotlinType, KotlinType> DELEGATE_SPECIAL_FUNCTION_RETURN_TYPE_MISMATCH = DiagnosticFactory3.create(ERROR);
|
||||
DiagnosticFactory2<KtExpression, String, Collection<? extends ResolvedCall<?>>> DELEGATE_PD_METHOD_NONE_APPLICABLE = DiagnosticFactory2.create(WARNING);
|
||||
|
||||
DiagnosticFactory1<KtSimpleNameExpression, KtType> COMPARE_TO_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtSimpleNameExpression, KotlinType> COMPARE_TO_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<PsiElement> UNDERSCORE_IS_RESERVED = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, String> INVALID_CHARACTERS = DiagnosticFactory1.create(ERROR);
|
||||
@@ -616,14 +616,14 @@ public interface Errors {
|
||||
|
||||
// Nullability
|
||||
|
||||
DiagnosticFactory1<PsiElement, KtType> UNSAFE_CALL = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, KotlinType> UNSAFE_CALL = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory3<KtExpression, String, String, String> UNSAFE_INFIX_CALL = DiagnosticFactory3.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, KtType> UNNECESSARY_SAFE_CALL = DiagnosticFactory1.create(WARNING);
|
||||
DiagnosticFactory1<PsiElement, KotlinType> UNNECESSARY_SAFE_CALL = DiagnosticFactory1.create(WARNING);
|
||||
DiagnosticFactory0<PsiElement> UNEXPECTED_SAFE_CALL = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, KtType> UNNECESSARY_NOT_NULL_ASSERTION = DiagnosticFactory1.create(WARNING);
|
||||
DiagnosticFactory1<PsiElement, KotlinType> UNNECESSARY_NOT_NULL_ASSERTION = DiagnosticFactory1.create(WARNING);
|
||||
DiagnosticFactory0<PsiElement> NOT_NULL_ASSERTION_ON_FUNCTION_LITERAL = DiagnosticFactory0.create(WARNING);
|
||||
|
||||
DiagnosticFactory1<KtBinaryExpression, KtType> USELESS_ELVIS = DiagnosticFactory1.create(WARNING, PositioningStrategies.USELESS_ELVIS);
|
||||
DiagnosticFactory1<KtBinaryExpression, KotlinType> USELESS_ELVIS = DiagnosticFactory1.create(WARNING, PositioningStrategies.USELESS_ELVIS);
|
||||
DiagnosticFactory0<PsiElement> USELESS_ELVIS_ON_FUNCTION_LITERAL = DiagnosticFactory0.create(WARNING);
|
||||
|
||||
// Compile-time values
|
||||
@@ -633,27 +633,27 @@ public interface Errors {
|
||||
DiagnosticFactory0<KtConstantExpression> WRONG_LONG_SUFFIX = DiagnosticFactory0.create(ERROR, LONG_LITERAL_SUFFIX);
|
||||
DiagnosticFactory0<KtConstantExpression> INT_LITERAL_OUT_OF_RANGE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtConstantExpression> FLOAT_LITERAL_OUT_OF_RANGE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory2<KtConstantExpression, String, KtType> CONSTANT_EXPECTED_TYPE_MISMATCH = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory2<KtConstantExpression, String, KotlinType> CONSTANT_EXPECTED_TYPE_MISMATCH = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory0<KtConstantExpression> INCORRECT_CHARACTER_LITERAL = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtConstantExpression> EMPTY_CHARACTER_LITERAL = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory1<KtConstantExpression, KtConstantExpression> TOO_MANY_CHARACTERS_IN_CHARACTER_LITERAL = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtElement, KtElement> ILLEGAL_ESCAPE = DiagnosticFactory1.create(ERROR, CUT_CHAR_QUOTES);
|
||||
DiagnosticFactory1<KtConstantExpression, KtType> NULL_FOR_NONNULL_TYPE = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtConstantExpression, KotlinType> NULL_FOR_NONNULL_TYPE = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory0<KtEscapeStringTemplateEntry> ILLEGAL_ESCAPE_SEQUENCE = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
// Casts and is-checks
|
||||
|
||||
DiagnosticFactory1<KtElement, KtType> CANNOT_CHECK_FOR_ERASED = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory2<KtBinaryExpressionWithTypeRHS, KtType, KtType> UNCHECKED_CAST = DiagnosticFactory2.create(WARNING);
|
||||
DiagnosticFactory1<KtElement, KotlinType> CANNOT_CHECK_FOR_ERASED = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory2<KtBinaryExpressionWithTypeRHS, KotlinType, KotlinType> UNCHECKED_CAST = DiagnosticFactory2.create(WARNING);
|
||||
|
||||
DiagnosticFactory0<KtBinaryExpressionWithTypeRHS> USELESS_CAST = DiagnosticFactory0.create(WARNING, AS_TYPE);
|
||||
DiagnosticFactory0<KtSimpleNameExpression> CAST_NEVER_SUCCEEDS = DiagnosticFactory0.create(WARNING);
|
||||
DiagnosticFactory0<KtTypeReference> DYNAMIC_NOT_ALLOWED = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtTypeReference> IS_ENUM_ENTRY = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory1<KtExpression, KtType> IMPLICIT_CAST_TO_UNIT_OR_ANY = DiagnosticFactory1.create(WARNING);
|
||||
DiagnosticFactory1<KtExpression, KotlinType> IMPLICIT_CAST_TO_UNIT_OR_ANY = DiagnosticFactory1.create(WARNING);
|
||||
|
||||
DiagnosticFactory2<KtExpression, KtType, String> SMARTCAST_IMPOSSIBLE = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory2<KtExpression, KotlinType, String> SMARTCAST_IMPOSSIBLE = DiagnosticFactory2.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<KtNullableType> USELESS_NULLABLE_CHECK = DiagnosticFactory0.create(WARNING, NULLABLE_TYPE);
|
||||
|
||||
@@ -686,20 +686,20 @@ public interface Errors {
|
||||
|
||||
// Type mismatch
|
||||
|
||||
DiagnosticFactory2<KtExpression, KtType, KtType> TYPE_MISMATCH = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory1<KtExpression, KtType> RETURN_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtExpression, KtType> EXPECTED_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtBinaryExpression, KtType> ASSIGNMENT_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory2<KtTypeReference, KtType, KtType> TYPE_MISMATCH_IN_FOR_LOOP = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory1<KtElement, KtType> TYPE_MISMATCH_IN_CONDITION = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory3<KtExpression, String, KtType, KtType> RESULT_TYPE_MISMATCH = DiagnosticFactory3.create(ERROR);
|
||||
DiagnosticFactory2<KtExpression, KotlinType, KotlinType> TYPE_MISMATCH = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory1<KtExpression, KotlinType> RETURN_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtExpression, KotlinType> EXPECTED_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtBinaryExpression, KotlinType> ASSIGNMENT_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory2<KtTypeReference, KotlinType, KotlinType> TYPE_MISMATCH_IN_FOR_LOOP = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory1<KtElement, KotlinType> TYPE_MISMATCH_IN_CONDITION = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory3<KtExpression, String, KotlinType, KotlinType> RESULT_TYPE_MISMATCH = DiagnosticFactory3.create(ERROR);
|
||||
DiagnosticFactory0<KtWhenConditionInRange> TYPE_MISMATCH_IN_RANGE = DiagnosticFactory0.create(ERROR, WHEN_CONDITION_IN_RANGE);
|
||||
|
||||
DiagnosticFactory1<KtParameter, KtType> EXPECTED_PARAMETER_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory2<KtFunction, Integer, List<KtType>> EXPECTED_PARAMETERS_NUMBER_MISMATCH =
|
||||
DiagnosticFactory1<KtParameter, KotlinType> EXPECTED_PARAMETER_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory2<KtFunction, Integer, List<KotlinType>> EXPECTED_PARAMETERS_NUMBER_MISMATCH =
|
||||
DiagnosticFactory2.create(ERROR, FUNCTION_PARAMETERS);
|
||||
|
||||
DiagnosticFactory2<KtElement, KtType, KtType> INCOMPATIBLE_TYPES = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory2<KtElement, KotlinType, KotlinType> INCOMPATIBLE_TYPES = DiagnosticFactory2.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<PsiElement> IMPLICIT_NOTHING_RETURN_TYPE = DiagnosticFactory0.create(WARNING);
|
||||
|
||||
|
||||
+3
-3
@@ -33,7 +33,7 @@ import org.jetbrains.kotlin.renderer.DescriptorRendererOptions;
|
||||
import org.jetbrains.kotlin.renderer.MultiRenderer;
|
||||
import org.jetbrains.kotlin.renderer.Renderer;
|
||||
import org.jetbrains.kotlin.resolve.varianceChecker.VarianceChecker.VarianceConflictDiagnosticData;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.util.MappedExtensionProvider;
|
||||
import org.jetbrains.kotlin.util.OperatorNameConventions;
|
||||
|
||||
@@ -566,10 +566,10 @@ public class DefaultErrorMessages {
|
||||
|
||||
MAP.put(FUNCTION_EXPECTED, "Expression ''{0}''{1} cannot be invoked as a function. " +
|
||||
"The function '" + OperatorNameConventions.INVOKE.asString() + "()' is not found",
|
||||
ELEMENT_TEXT, new Renderer<KtType>() {
|
||||
ELEMENT_TEXT, new Renderer<KotlinType>() {
|
||||
@NotNull
|
||||
@Override
|
||||
public String render(@NotNull KtType type) {
|
||||
public String render(@NotNull KotlinType type) {
|
||||
if (type.isError()) return "";
|
||||
return " of type '" + RENDER_TYPE.render(type) + "'";
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.Constrain
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind.RECEIVER_POSITION
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind.VALUE_PARAMETER_POSITION
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
|
||||
@@ -93,7 +93,7 @@ public object Renderers {
|
||||
|
||||
public val RENDER_CLASS_OR_OBJECT_NAME: Renderer<ClassDescriptor> = Renderer { it.renderKindWithName() }
|
||||
|
||||
public val RENDER_TYPE: Renderer<KtType> = Renderer { DescriptorRenderer.FQ_NAMES_IN_TYPES.renderType(it) }
|
||||
public val RENDER_TYPE: Renderer<KotlinType> = Renderer { DescriptorRenderer.FQ_NAMES_IN_TYPES.renderType(it) }
|
||||
|
||||
public val RENDER_POSITION_VARIANCE: Renderer<Variance> = Renderer {
|
||||
variance: Variance ->
|
||||
@@ -179,7 +179,7 @@ public object Renderers {
|
||||
val receiverType = DescriptorUtils.getReceiverParameterType(substitutedDescriptor.getExtensionReceiverParameter())
|
||||
|
||||
val errorPositions = Sets.newHashSet<ConstraintPosition>()
|
||||
val parameterTypes = Lists.newArrayList<KtType>()
|
||||
val parameterTypes = Lists.newArrayList<KotlinType>()
|
||||
for (valueParameterDescriptor in substitutedDescriptor.getValueParameters()) {
|
||||
parameterTypes.add(valueParameterDescriptor.getType())
|
||||
if (valueParameterDescriptor.getIndex() >= inferenceErrorData.valueArgumentsTypes.size()) continue
|
||||
@@ -279,7 +279,7 @@ public object Renderers {
|
||||
.table(newTable()
|
||||
.descriptor(inferenceErrorData.descriptor))
|
||||
|
||||
var violatedUpperBound: KtType? = null
|
||||
var violatedUpperBound: KotlinType? = null
|
||||
for (upperBound in typeParameterDescriptor.getUpperBounds()) {
|
||||
val upperBoundWithSubstitutedInferredTypes = systemWithoutWeakConstraints.getResultingSubstitutor().substitute(upperBound, Variance.INVARIANT)
|
||||
if (upperBoundWithSubstitutedInferredTypes != null
|
||||
@@ -356,9 +356,9 @@ public object Renderers {
|
||||
}.toString()
|
||||
}
|
||||
|
||||
private fun renderTypes(types: Collection<KtType>) = StringUtil.join(types, { RENDER_TYPE.render(it) }, ", ")
|
||||
private fun renderTypes(types: Collection<KotlinType>) = StringUtil.join(types, { RENDER_TYPE.render(it) }, ", ")
|
||||
|
||||
public val RENDER_COLLECTION_OF_TYPES: Renderer<Collection<KtType>> = Renderer { renderTypes(it) }
|
||||
public val RENDER_COLLECTION_OF_TYPES: Renderer<Collection<KotlinType>> = Renderer { renderTypes(it) }
|
||||
|
||||
private fun renderConstraintSystem(constraintSystem: ConstraintSystem, renderTypeBounds: Renderer<TypeBounds>): String {
|
||||
val typeVariables = constraintSystem.getTypeVariables()
|
||||
|
||||
+11
-11
@@ -29,7 +29,7 @@ import org.jetbrains.kotlin.diagnostics.rendering.TabledDescriptorRenderer.TextR
|
||||
import org.jetbrains.kotlin.renderer.DescriptorRenderer;
|
||||
import org.jetbrains.kotlin.renderer.Renderer;
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPosition;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
@@ -50,11 +50,11 @@ public class TabledDescriptorRenderer {
|
||||
}
|
||||
|
||||
public static class FunctionArgumentsRow implements TableRow {
|
||||
public final KtType receiverType;
|
||||
public final List<KtType> argumentTypes;
|
||||
public final KotlinType receiverType;
|
||||
public final List<KotlinType> argumentTypes;
|
||||
public final Predicate<ConstraintPosition> isErrorPosition;
|
||||
|
||||
public FunctionArgumentsRow(KtType receiverType, List<KtType> argumentTypes, Predicate<ConstraintPosition> isErrorPosition) {
|
||||
public FunctionArgumentsRow(KotlinType receiverType, List<KotlinType> argumentTypes, Predicate<ConstraintPosition> isErrorPosition) {
|
||||
this.receiverType = receiverType;
|
||||
this.argumentTypes = argumentTypes;
|
||||
this.isErrorPosition = isErrorPosition;
|
||||
@@ -68,13 +68,13 @@ public class TabledDescriptorRenderer {
|
||||
return this;
|
||||
}
|
||||
|
||||
public TableRenderer functionArgumentTypeList(@Nullable KtType receiverType, @NotNull List<KtType> argumentTypes) {
|
||||
public TableRenderer functionArgumentTypeList(@Nullable KotlinType receiverType, @NotNull List<KotlinType> argumentTypes) {
|
||||
|
||||
return functionArgumentTypeList(receiverType, argumentTypes, Predicates.<ConstraintPosition>alwaysFalse());
|
||||
}
|
||||
|
||||
public TableRenderer functionArgumentTypeList(@Nullable KtType receiverType,
|
||||
@NotNull List<KtType> argumentTypes,
|
||||
public TableRenderer functionArgumentTypeList(@Nullable KotlinType receiverType,
|
||||
@NotNull List<KotlinType> argumentTypes,
|
||||
@NotNull Predicate<ConstraintPosition> isErrorPosition) {
|
||||
rows.add(new FunctionArgumentsRow(receiverType, argumentTypes, isErrorPosition));
|
||||
return this;
|
||||
@@ -156,7 +156,7 @@ public class TabledDescriptorRenderer {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Renderer<KtType> getTypeRenderer() {
|
||||
public Renderer<KotlinType> getTypeRenderer() {
|
||||
return Renderers.RENDER_TYPE;
|
||||
}
|
||||
|
||||
@@ -183,7 +183,7 @@ public class TabledDescriptorRenderer {
|
||||
}
|
||||
}
|
||||
|
||||
private void renderFunctionArguments(@Nullable KtType receiverType, @NotNull List<KtType> argumentTypes, StringBuilder result) {
|
||||
private void renderFunctionArguments(@Nullable KotlinType receiverType, @NotNull List<KotlinType> argumentTypes, StringBuilder result) {
|
||||
boolean hasReceiver = receiverType != null;
|
||||
if (hasReceiver) {
|
||||
result.append("receiver: ");
|
||||
@@ -196,8 +196,8 @@ public class TabledDescriptorRenderer {
|
||||
}
|
||||
|
||||
result.append("(");
|
||||
for (Iterator<KtType> iterator = argumentTypes.iterator(); iterator.hasNext(); ) {
|
||||
KtType argumentType = iterator.next();
|
||||
for (Iterator<KotlinType> iterator = argumentTypes.iterator(); iterator.hasNext(); ) {
|
||||
KotlinType argumentType = iterator.next();
|
||||
String renderedArgument = getTypeRenderer().render(argumentType);
|
||||
|
||||
result.append(renderedArgument);
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.jetbrains.kotlin.psi.KtNamedFunction;
|
||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
||||
import org.jetbrains.kotlin.resolve.annotations.AnnotationUtilKt;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.TypeProjection;
|
||||
import org.jetbrains.kotlin.types.Variance;
|
||||
|
||||
@@ -89,13 +89,13 @@ public class MainFunctionDetector {
|
||||
if (parameters.size() != 1) return false;
|
||||
|
||||
ValueParameterDescriptor parameter = parameters.get(0);
|
||||
KtType parameterType = parameter.getType();
|
||||
KotlinType parameterType = parameter.getType();
|
||||
if (!KotlinBuiltIns.isArray(parameterType)) return false;
|
||||
|
||||
List<TypeProjection> typeArguments = parameterType.getArguments();
|
||||
if (typeArguments.size() != 1) return false;
|
||||
|
||||
KtType typeArgument = typeArguments.get(0).getType();
|
||||
KotlinType typeArgument = typeArguments.get(0).getType();
|
||||
if (!KotlinBuiltIns.isString(typeArgument)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ import com.intellij.psi.search.GlobalSearchScope
|
||||
import com.intellij.psi.tree.IElementType
|
||||
import com.intellij.testFramework.LightVirtualFile
|
||||
import org.jetbrains.kotlin.idea.KotlinFileType
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.check
|
||||
import java.util.*
|
||||
|
||||
@@ -131,7 +131,7 @@ public abstract class KtCodeFragment(
|
||||
|
||||
companion object {
|
||||
public val IMPORT_SEPARATOR: String = ","
|
||||
public val RUNTIME_TYPE_EVALUATOR: Key<Function1<KtExpression, KtType?>> = Key.create("RUNTIME_TYPE_EVALUATOR")
|
||||
public val RUNTIME_TYPE_EVALUATOR: Key<Function1<KtExpression, KotlinType?>> = Key.create("RUNTIME_TYPE_EVALUATOR")
|
||||
public val ADDITIONAL_CONTEXT_FOR_LAMBDA: Key<Function0<KtElement?>> = Key.create("ADDITIONAL_CONTEXT_FOR_LAMBDA")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import com.intellij.openapi.util.Key
|
||||
import org.jetbrains.kotlin.psi.KtCodeFragment
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.psi.KtTypeReference
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
public val SUPPRESS_DIAGNOSTICS_IN_DEBUG_MODE: Key<Boolean> = Key.create<Boolean>("SUPPRESS_DIAGNOSTICS_IN_DEBUG_MODE")
|
||||
|
||||
@@ -36,10 +36,10 @@ public var KtFile.suppressDiagnosticsInDebugMode: Boolean
|
||||
|
||||
public val DEBUG_TYPE_REFERENCE_STRING: String = "DebugTypeKotlinRulezzzz"
|
||||
|
||||
public val DEBUG_TYPE_INFO: Key<KtType> = Key.create<KtType>("DEBUG_TYPE_INFO")
|
||||
public var KtTypeReference.debugTypeInfo: KtType?
|
||||
public val DEBUG_TYPE_INFO: Key<KotlinType> = Key.create<KotlinType>("DEBUG_TYPE_INFO")
|
||||
public var KtTypeReference.debugTypeInfo: KotlinType?
|
||||
get() = getUserData(DEBUG_TYPE_INFO)
|
||||
set(type: KtType?) {
|
||||
set(type: KotlinType?) {
|
||||
if (type != null && this.getText() == DEBUG_TYPE_REFERENCE_STRING) {
|
||||
putUserData(DEBUG_TYPE_INFO, type)
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ import org.jetbrains.kotlin.incremental.components.LookupLocation
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||
import org.jetbrains.kotlin.resolve.scopes.KtScope
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.utils.Printer
|
||||
|
||||
class AllUnderImportsScope(descriptor: DeclarationDescriptor) : KtScope {
|
||||
@@ -51,19 +51,19 @@ class AllUnderImportsScope(descriptor: DeclarationDescriptor) : KtScope {
|
||||
return scopes.flatMap { it.getFunctions(name, location) }
|
||||
}
|
||||
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KtType>, name: Name, location: LookupLocation): Collection<PropertyDescriptor> {
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KotlinType>, name: Name, location: LookupLocation): Collection<PropertyDescriptor> {
|
||||
return scopes.flatMap { it.getSyntheticExtensionProperties(receiverTypes, name, location) }
|
||||
}
|
||||
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<KtType>, name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<KotlinType>, name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
|
||||
return scopes.flatMap { it.getSyntheticExtensionFunctions(receiverTypes, name, location) }
|
||||
}
|
||||
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KtType>): Collection<PropertyDescriptor> {
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KotlinType>): Collection<PropertyDescriptor> {
|
||||
return scopes.flatMap { it.getSyntheticExtensionProperties(receiverTypes) }
|
||||
}
|
||||
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<KtType>): Collection<FunctionDescriptor> {
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<KotlinType>): Collection<FunctionDescriptor> {
|
||||
return scopes.flatMap { it.getSyntheticExtensionFunctions(receiverTypes) }
|
||||
}
|
||||
|
||||
|
||||
@@ -18,15 +18,15 @@ package org.jetbrains.kotlin.resolve;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
public class AnalyzerScriptParameter {
|
||||
@NotNull
|
||||
private final Name name;
|
||||
@NotNull
|
||||
private final KtType type;
|
||||
private final KotlinType type;
|
||||
|
||||
public AnalyzerScriptParameter(@NotNull Name name, @NotNull KtType type) {
|
||||
public AnalyzerScriptParameter(@NotNull Name name, @NotNull KotlinType type) {
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
}
|
||||
@@ -37,7 +37,7 @@ public class AnalyzerScriptParameter {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public KtType getType() {
|
||||
public KotlinType getType() {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getAnnotationEntries
|
||||
import org.jetbrains.kotlin.resolve.constants.ArrayValue
|
||||
import org.jetbrains.kotlin.resolve.constants.EnumValue
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.isRepeatableAnnotation
|
||||
import org.jetbrains.kotlin.descriptors.annotations.KotlinTarget.*
|
||||
@@ -71,7 +71,7 @@ public class AnnotationChecker(private val additionalCheckers: Iterable<Addition
|
||||
}
|
||||
|
||||
private fun checkEntries(entries: List<KtAnnotationEntry>, actualTargets: TargetList, trace: BindingTrace) {
|
||||
val entryTypesWithAnnotations = hashMapOf<KtType, MutableList<AnnotationUseSiteTarget?>>()
|
||||
val entryTypesWithAnnotations = hashMapOf<KotlinType, MutableList<AnnotationUseSiteTarget?>>()
|
||||
|
||||
for (entry in entries) {
|
||||
checkAnnotationEntry(entry, actualTargets, trace)
|
||||
|
||||
@@ -36,7 +36,7 @@ import org.jetbrains.kotlin.resolve.scopes.LexicalScope;
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
|
||||
import org.jetbrains.kotlin.storage.StorageManager;
|
||||
import org.jetbrains.kotlin.types.ErrorUtils;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.ArrayList;
|
||||
@@ -147,13 +147,13 @@ public class AnnotationResolver {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public KtType resolveAnnotationType(@NotNull LexicalScope scope, @NotNull KtAnnotationEntry entryElement, @NotNull BindingTrace trace) {
|
||||
public KotlinType resolveAnnotationType(@NotNull LexicalScope scope, @NotNull KtAnnotationEntry entryElement, @NotNull BindingTrace trace) {
|
||||
KtTypeReference typeReference = entryElement.getTypeReference();
|
||||
if (typeReference == null) {
|
||||
return ErrorUtils.createErrorType("No type reference: " + entryElement.getText());
|
||||
}
|
||||
|
||||
KtType type = typeResolver.resolveType(scope, typeReference, trace, true);
|
||||
KotlinType type = typeResolver.resolveType(scope, typeReference, trace, true);
|
||||
if (!(type.getConstructor().getDeclarationDescriptor() instanceof ClassDescriptor)) {
|
||||
return ErrorUtils.createErrorType("Not an annotation: " + type);
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ import org.jetbrains.kotlin.resolve.scopes.KtScope;
|
||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope;
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.Qualifier;
|
||||
import org.jetbrains.kotlin.types.DeferredType;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.expressions.CaptureKind;
|
||||
import org.jetbrains.kotlin.types.expressions.JetTypeInfo;
|
||||
import org.jetbrains.kotlin.types.expressions.PreliminaryDeclarationVisitor;
|
||||
@@ -77,7 +77,7 @@ public interface BindingContext {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public KtType getType(@NotNull KtExpression expression) {
|
||||
public KotlinType getType(@NotNull KtExpression expression) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -91,10 +91,10 @@ public interface BindingContext {
|
||||
|
||||
WritableSlice<KtExpression, CompileTimeConstant<?>> COMPILE_TIME_VALUE = Slices.createSimpleSlice();
|
||||
|
||||
WritableSlice<KtTypeReference, KtType> TYPE = Slices.createSimpleSlice();
|
||||
WritableSlice<KtTypeReference, KotlinType> TYPE = Slices.createSimpleSlice();
|
||||
WritableSlice<KtExpression, JetTypeInfo> EXPRESSION_TYPE_INFO = new BasicWritableSlice<KtExpression, JetTypeInfo>(DO_NOTHING);
|
||||
WritableSlice<KtExpression, KtType> EXPECTED_EXPRESSION_TYPE = new BasicWritableSlice<KtExpression, KtType>(DO_NOTHING);
|
||||
WritableSlice<KtFunction, KtType> EXPECTED_RETURN_TYPE = new BasicWritableSlice<KtFunction, KtType>(DO_NOTHING);
|
||||
WritableSlice<KtExpression, KotlinType> EXPECTED_EXPRESSION_TYPE = new BasicWritableSlice<KtExpression, KotlinType>(DO_NOTHING);
|
||||
WritableSlice<KtFunction, KotlinType> EXPECTED_RETURN_TYPE = new BasicWritableSlice<KtFunction, KotlinType>(DO_NOTHING);
|
||||
WritableSlice<KtExpression, DataFlowInfo> DATAFLOW_INFO_AFTER_CONDITION = Slices.createSimpleSlice();
|
||||
|
||||
/**
|
||||
@@ -131,7 +131,7 @@ public interface BindingContext {
|
||||
WritableSlice<KtExpression, ResolvedCall<FunctionDescriptor>> INDEXED_LVALUE_GET = Slices.createSimpleSlice();
|
||||
WritableSlice<KtExpression, ResolvedCall<FunctionDescriptor>> INDEXED_LVALUE_SET = Slices.createSimpleSlice();
|
||||
|
||||
WritableSlice<KtExpression, KtType> SMARTCAST = Slices.createSimpleSlice();
|
||||
WritableSlice<KtExpression, KotlinType> SMARTCAST = Slices.createSimpleSlice();
|
||||
|
||||
WritableSlice<KtWhenExpression, Boolean> EXHAUSTIVE_WHEN = Slices.createSimpleSlice();
|
||||
|
||||
@@ -256,7 +256,7 @@ public interface BindingContext {
|
||||
<K, V> ImmutableMap<K, V> getSliceContents(@NotNull ReadOnlySlice<K, V> slice);
|
||||
|
||||
@Nullable
|
||||
KtType getType(@NotNull KtExpression expression);
|
||||
KotlinType getType(@NotNull KtExpression expression);
|
||||
|
||||
void addOwnDataTo(@NotNull BindingTrace trace, boolean commitDiagnostics);
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.kotlin.resolve.calls.model.VariableAsFunctionResolvedCall;
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
|
||||
import org.jetbrains.kotlin.resolve.diagnostics.MutableDiagnosticsWithSuppression;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.TypeUtils;
|
||||
import org.jetbrains.kotlin.types.expressions.JetTypeInfo;
|
||||
import org.jetbrains.kotlin.types.expressions.typeInfoFactory.TypeInfoFactoryKt;
|
||||
@@ -81,11 +81,11 @@ public class BindingContextUtils {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static KtType getTypeNotNull(
|
||||
public static KotlinType getTypeNotNull(
|
||||
@NotNull BindingContext bindingContext,
|
||||
@NotNull KtExpression expression
|
||||
) {
|
||||
KtType result = bindingContext.getType(expression);
|
||||
KotlinType result = bindingContext.getType(expression);
|
||||
if (result == null) {
|
||||
throw new IllegalStateException("Type must be not null for " + expression);
|
||||
}
|
||||
@@ -140,8 +140,8 @@ public class BindingContextUtils {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static KtType updateRecordedType(
|
||||
@Nullable KtType type,
|
||||
public static KotlinType updateRecordedType(
|
||||
@Nullable KotlinType type,
|
||||
@NotNull KtExpression expression,
|
||||
@NotNull BindingTrace trace,
|
||||
boolean shouldBeMadeNullable
|
||||
|
||||
@@ -20,7 +20,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticSink;
|
||||
import org.jetbrains.kotlin.psi.KtExpression;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.util.slicedMap.ReadOnlySlice;
|
||||
import org.jetbrains.kotlin.util.slicedMap.WritableSlice;
|
||||
|
||||
@@ -47,11 +47,11 @@ public interface BindingTrace extends DiagnosticSink {
|
||||
* Expression type should be taken from EXPRESSION_TYPE_INFO slice
|
||||
*/
|
||||
@Nullable
|
||||
KtType getType(@NotNull KtExpression expression);
|
||||
KotlinType getType(@NotNull KtExpression expression);
|
||||
|
||||
/**
|
||||
* Expression type should be recorded into EXPRESSION_TYPE_INFO slice
|
||||
* (either updated old or a new one)
|
||||
*/
|
||||
void recordType(@NotNull KtExpression expression, @Nullable KtType type);
|
||||
void recordType(@NotNull KtExpression expression, @Nullable KotlinType type);
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.jetbrains.kotlin.diagnostics.Diagnostic;
|
||||
import org.jetbrains.kotlin.psi.KtExpression;
|
||||
import org.jetbrains.kotlin.resolve.diagnostics.Diagnostics;
|
||||
import org.jetbrains.kotlin.resolve.diagnostics.MutableDiagnosticsWithSuppression;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.expressions.JetTypeInfo;
|
||||
import org.jetbrains.kotlin.types.expressions.typeInfoFactory.TypeInfoFactoryKt;
|
||||
import org.jetbrains.kotlin.util.slicedMap.*;
|
||||
@@ -67,7 +67,7 @@ public class BindingTraceContext implements BindingTrace {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public KtType getType(@NotNull KtExpression expression) {
|
||||
public KotlinType getType(@NotNull KtExpression expression) {
|
||||
return BindingTraceContext.this.getType(expression);
|
||||
}
|
||||
|
||||
@@ -131,13 +131,13 @@ public class BindingTraceContext implements BindingTrace {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public KtType getType(@NotNull KtExpression expression) {
|
||||
public KotlinType getType(@NotNull KtExpression expression) {
|
||||
JetTypeInfo typeInfo = get(BindingContext.EXPRESSION_TYPE_INFO, expression);
|
||||
return typeInfo != null ? typeInfo.getType() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recordType(@NotNull KtExpression expression, @Nullable KtType type) {
|
||||
public void recordType(@NotNull KtExpression expression, @Nullable KotlinType type) {
|
||||
JetTypeInfo typeInfo = get(BindingContext.EXPRESSION_TYPE_INFO, expression);
|
||||
typeInfo = typeInfo != null ? typeInfo.replaceType(type) : TypeInfoFactoryKt.createTypeInfo(type);
|
||||
record(BindingContext.EXPRESSION_TYPE_INFO, expression, typeInfo);
|
||||
|
||||
@@ -262,10 +262,10 @@ public class BodyResolver {
|
||||
: FunctionDescriptorUtil.getFunctionInnerScope(scopeForSupertypeResolution, primaryConstructor, trace);
|
||||
final ExpressionTypingServices typeInferrer = expressionTypingServices; // TODO : flow
|
||||
|
||||
final Map<KtTypeReference, KtType> supertypes = Maps.newLinkedHashMap();
|
||||
final Map<KtTypeReference, KotlinType> supertypes = Maps.newLinkedHashMap();
|
||||
final ResolvedCall<?>[] primaryConstructorDelegationCall = new ResolvedCall[1];
|
||||
KtVisitorVoid visitor = new KtVisitorVoid() {
|
||||
private void recordSupertype(KtTypeReference typeReference, KtType supertype) {
|
||||
private void recordSupertype(KtTypeReference typeReference, KotlinType supertype) {
|
||||
if (supertype == null) return;
|
||||
supertypes.put(typeReference, supertype);
|
||||
}
|
||||
@@ -275,7 +275,7 @@ public class BodyResolver {
|
||||
if (descriptor.getKind() == ClassKind.INTERFACE) {
|
||||
trace.report(DELEGATION_IN_INTERFACE.on(specifier));
|
||||
}
|
||||
KtType supertype = trace.getBindingContext().get(BindingContext.TYPE, specifier.getTypeReference());
|
||||
KotlinType supertype = trace.getBindingContext().get(BindingContext.TYPE, specifier.getTypeReference());
|
||||
recordSupertype(specifier.getTypeReference(), supertype);
|
||||
if (supertype != null) {
|
||||
DeclarationDescriptor declarationDescriptor = supertype.getConstructor().getDeclarationDescriptor();
|
||||
@@ -289,7 +289,7 @@ public class BodyResolver {
|
||||
KtExpression delegateExpression = specifier.getDelegateExpression();
|
||||
if (delegateExpression != null) {
|
||||
LexicalScope scope = scopeForConstructor == null ? scopeForMemberResolution : scopeForConstructor;
|
||||
KtType expectedType = supertype != null ? supertype : NO_EXPECTED_TYPE;
|
||||
KotlinType expectedType = supertype != null ? supertype : NO_EXPECTED_TYPE;
|
||||
typeInferrer.getType(scope, delegateExpression, expectedType, outerDataFlowInfo, trace);
|
||||
}
|
||||
if (primaryConstructor == null) {
|
||||
@@ -317,7 +317,7 @@ public class BodyResolver {
|
||||
trace, scopeForConstructor,
|
||||
CallMaker.makeCall(ReceiverValue.NO_RECEIVER, null, call), NO_EXPECTED_TYPE, outerDataFlowInfo, false);
|
||||
if (results.isSuccess()) {
|
||||
KtType supertype = results.getResultingDescriptor().getReturnType();
|
||||
KotlinType supertype = results.getResultingDescriptor().getReturnType();
|
||||
recordSupertype(typeReference, supertype);
|
||||
ClassDescriptor classDescriptor = TypeUtils.getClassDescriptor(supertype);
|
||||
if (classDescriptor != null) {
|
||||
@@ -342,7 +342,7 @@ public class BodyResolver {
|
||||
@Override
|
||||
public void visitDelegationToSuperClassSpecifier(@NotNull KtDelegatorToSuperClass specifier) {
|
||||
KtTypeReference typeReference = specifier.getTypeReference();
|
||||
KtType supertype = trace.getBindingContext().get(BindingContext.TYPE, typeReference);
|
||||
KotlinType supertype = trace.getBindingContext().get(BindingContext.TYPE, typeReference);
|
||||
recordSupertype(typeReference, supertype);
|
||||
if (supertype == null) return;
|
||||
ClassDescriptor superClass = TypeUtils.getClassDescriptor(supertype);
|
||||
@@ -419,15 +419,15 @@ public class BodyResolver {
|
||||
|
||||
private void checkSupertypeList(
|
||||
@NotNull ClassDescriptor supertypeOwner,
|
||||
@NotNull Map<KtTypeReference, KtType> supertypes,
|
||||
@NotNull Map<KtTypeReference, KotlinType> supertypes,
|
||||
@NotNull KtClassOrObject jetClass
|
||||
) {
|
||||
Set<TypeConstructor> allowedFinalSupertypes = getAllowedFinalSupertypes(supertypeOwner, jetClass);
|
||||
Set<TypeConstructor> typeConstructors = Sets.newHashSet();
|
||||
boolean classAppeared = false;
|
||||
for (Map.Entry<KtTypeReference, KtType> entry : supertypes.entrySet()) {
|
||||
for (Map.Entry<KtTypeReference, KotlinType> entry : supertypes.entrySet()) {
|
||||
KtTypeReference typeReference = entry.getKey();
|
||||
KtType supertype = entry.getValue();
|
||||
KotlinType supertype = entry.getValue();
|
||||
|
||||
KtTypeElement typeElement = typeReference.getTypeElement();
|
||||
if (typeElement instanceof KtFunctionType) {
|
||||
@@ -709,7 +709,7 @@ public class BodyResolver {
|
||||
LexicalScope accessorScope = JetScopeUtils.makeScopeForPropertyAccessor(
|
||||
propertyDescriptor, parentScopeForAccessor, trace);
|
||||
|
||||
KtType delegateType = delegatedPropertyResolver.resolveDelegateExpression(
|
||||
KotlinType delegateType = delegatedPropertyResolver.resolveDelegateExpression(
|
||||
delegateExpression, jetProperty, propertyDescriptor, propertyDeclarationInnerScope, accessorScope, trace,
|
||||
outerDataFlowInfo);
|
||||
|
||||
@@ -734,7 +734,7 @@ public class BodyResolver {
|
||||
) {
|
||||
LexicalScope propertyDeclarationInnerScope = JetScopeUtils.getPropertyDeclarationInnerScopeForInitializer(
|
||||
propertyDescriptor, scope, propertyDescriptor.getTypeParameters(), null, trace);
|
||||
KtType expectedTypeForInitializer = property.getTypeReference() != null ? propertyDescriptor.getType() : NO_EXPECTED_TYPE;
|
||||
KotlinType expectedTypeForInitializer = property.getTypeReference() != null ? propertyDescriptor.getType() : NO_EXPECTED_TYPE;
|
||||
if (propertyDescriptor.getCompileTimeInitializer() == null) {
|
||||
expressionTypingServices.getType(propertyDeclarationInnerScope, initializer, expectedTypeForInitializer,
|
||||
outerDataFlowInfo, trace);
|
||||
@@ -850,7 +850,7 @@ public class BodyResolver {
|
||||
valueParameterResolver.resolveValueParameters(valueParameters, valueParameterDescriptors, scope, outerDataFlowInfo, trace);
|
||||
}
|
||||
|
||||
private static void computeDeferredType(KtType type) {
|
||||
private static void computeDeferredType(KotlinType type) {
|
||||
// handle type inference loop: function or property body contains a reference to itself
|
||||
// fun f() = { f() }
|
||||
// val x = x
|
||||
|
||||
@@ -35,7 +35,7 @@ import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant;
|
||||
import org.jetbrains.kotlin.resolve.constants.ConstantValue;
|
||||
import org.jetbrains.kotlin.resolve.constants.TypedCompileTimeConstant;
|
||||
import org.jetbrains.kotlin.resolve.constants.evaluate.ConstantExpressionEvaluator;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.TypeProjection;
|
||||
import org.jetbrains.kotlin.types.TypeUtils;
|
||||
|
||||
@@ -60,7 +60,7 @@ public class CompileTimeConstantUtils {
|
||||
for (KtParameter parameter : parameters) {
|
||||
VariableDescriptor parameterDescriptor = trace.getBindingContext().get(VALUE_PARAMETER, parameter);
|
||||
if (parameterDescriptor == null) continue;
|
||||
KtType parameterType = parameterDescriptor.getType();
|
||||
KotlinType parameterType = parameterDescriptor.getType();
|
||||
KtTypeReference typeReference = parameter.getTypeReference();
|
||||
if (typeReference != null) {
|
||||
if (parameterType.isMarkedNullable()) {
|
||||
@@ -73,7 +73,7 @@ public class CompileTimeConstantUtils {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isAcceptableTypeForAnnotationParameter(@NotNull KtType parameterType) {
|
||||
private static boolean isAcceptableTypeForAnnotationParameter(@NotNull KotlinType parameterType) {
|
||||
ClassDescriptor typeDescriptor = TypeUtils.getClassDescriptor(parameterType);
|
||||
if (typeDescriptor == null) {
|
||||
return false;
|
||||
@@ -91,7 +91,7 @@ public class CompileTimeConstantUtils {
|
||||
if (KotlinBuiltIns.isArray(parameterType)) {
|
||||
List<TypeProjection> arguments = parameterType.getArguments();
|
||||
if (arguments.size() == 1) {
|
||||
KtType arrayType = arguments.get(0).getType();
|
||||
KotlinType arrayType = arguments.get(0).getType();
|
||||
if (arrayType.isMarkedNullable()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -24,12 +24,12 @@ import com.intellij.psi.PsiElement
|
||||
import com.intellij.openapi.util.ModificationTracker
|
||||
import org.jetbrains.kotlin.psi.KtExpression
|
||||
import org.jetbrains.kotlin.resolve.diagnostics.Diagnostics
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
public class CompositeBindingContext private constructor(
|
||||
private val delegates: List<BindingContext>
|
||||
) : BindingContext {
|
||||
override fun getType(expression: KtExpression): KtType? {
|
||||
override fun getType(expression: KtExpression): KotlinType? {
|
||||
return delegates.asSequence().map { it.getType(expression) }.firstOrNull { it != null }
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.jetbrains.kotlin.descriptors.PropertyAccessorDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor;
|
||||
import org.jetbrains.kotlin.psi.*;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -52,7 +52,7 @@ public class ControlFlowAnalyzer {
|
||||
for (Map.Entry<KtNamedFunction, SimpleFunctionDescriptor> entry : c.getFunctions().entrySet()) {
|
||||
KtNamedFunction function = entry.getKey();
|
||||
SimpleFunctionDescriptor functionDescriptor = entry.getValue();
|
||||
KtType expectedReturnType = !function.hasBlockBody() && !function.hasDeclaredReturnType()
|
||||
KotlinType expectedReturnType = !function.hasBlockBody() && !function.hasDeclaredReturnType()
|
||||
? NO_EXPECTED_TYPE
|
||||
: functionDescriptor.getReturnType();
|
||||
checkFunction(c, function, expectedReturnType);
|
||||
@@ -87,12 +87,12 @@ public class ControlFlowAnalyzer {
|
||||
? propertyDescriptor.getGetter()
|
||||
: propertyDescriptor.getSetter();
|
||||
assert accessorDescriptor != null : "no property accessor descriptor " + accessor.getText();
|
||||
KtType returnType = accessorDescriptor.getReturnType();
|
||||
KotlinType returnType = accessorDescriptor.getReturnType();
|
||||
checkFunction(c, accessor, returnType);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkFunction(@NotNull BodiesResolveContext c, @NotNull KtDeclarationWithBody function, @Nullable KtType expectedReturnType) {
|
||||
private void checkFunction(@NotNull BodiesResolveContext c, @NotNull KtDeclarationWithBody function, @Nullable KotlinType expectedReturnType) {
|
||||
if (!function.hasBody()) return;
|
||||
JetFlowInformationProvider flowInformationProvider = new JetFlowInformationProvider(function, trace);
|
||||
if (c.getTopDownAnalysisMode().isLocalDeclarations()) {
|
||||
|
||||
@@ -168,7 +168,7 @@ public class DeclarationsChecker {
|
||||
|
||||
private void checkBoundsForTypeInClassHeader(@Nullable KtTypeReference typeReference) {
|
||||
if (typeReference != null) {
|
||||
KtType type = trace.getBindingContext().get(TYPE, typeReference);
|
||||
KotlinType type = trace.getBindingContext().get(TYPE, typeReference);
|
||||
if (type != null) {
|
||||
DescriptorResolver.checkBounds(typeReference, type, trace);
|
||||
}
|
||||
@@ -177,7 +177,7 @@ public class DeclarationsChecker {
|
||||
|
||||
private void checkFinalUpperBounds(@Nullable KtTypeReference typeReference) {
|
||||
if (typeReference != null) {
|
||||
KtType type = trace.getBindingContext().get(TYPE, typeReference);
|
||||
KotlinType type = trace.getBindingContext().get(TYPE, typeReference);
|
||||
if (type != null) {
|
||||
DescriptorResolver.checkUpperBoundType(typeReference, type, trace);
|
||||
}
|
||||
@@ -213,7 +213,7 @@ public class DeclarationsChecker {
|
||||
TypeParameterDescriptor typeParameterDescriptor = (TypeParameterDescriptor) declarationDescriptor;
|
||||
|
||||
// Immediate arguments of supertypes cannot be projected
|
||||
Set<KtType> conflictingTypes = Sets.newLinkedHashSet();
|
||||
Set<KotlinType> conflictingTypes = Sets.newLinkedHashSet();
|
||||
for (TypeProjection projection : projections) {
|
||||
conflictingTypes.add(projection.getType());
|
||||
}
|
||||
@@ -254,7 +254,7 @@ public class DeclarationsChecker {
|
||||
int i = 0;
|
||||
for (TypeParameterDescriptor typeParameterDescriptor : classDescriptor.getTypeConstructor().getParameters()) {
|
||||
if (i >= typeParameterList.size()) return;
|
||||
for (KtType upperBound : typeParameterDescriptor.getUpperBounds()) {
|
||||
for (KotlinType upperBound : typeParameterDescriptor.getUpperBounds()) {
|
||||
EffectiveVisibility upperBoundVisibility = EffectiveVisibility.Companion.forType(upperBound);
|
||||
if (!upperBoundVisibility.sameOrMorePermissive(classVisibility)) {
|
||||
KtTypeParameter typeParameter = typeParameterList.get(i);
|
||||
@@ -271,7 +271,7 @@ public class DeclarationsChecker {
|
||||
boolean isInterface = classDescriptor.getKind() == ClassKind.INTERFACE;
|
||||
List<KtDelegationSpecifier> delegationList = klass.getDelegationSpecifiers();
|
||||
int i = -1;
|
||||
for (KtType superType : classDescriptor.getTypeConstructor().getSupertypes()) {
|
||||
for (KotlinType superType : classDescriptor.getTypeConstructor().getSupertypes()) {
|
||||
i++;
|
||||
if (i >= delegationList.size()) return;
|
||||
ClassDescriptor superDescriptor = TypeUtils.getClassDescriptor(superType);
|
||||
@@ -294,10 +294,10 @@ public class DeclarationsChecker {
|
||||
}
|
||||
}
|
||||
|
||||
private static void removeDuplicateTypes(Set<KtType> conflictingTypes) {
|
||||
for (Iterator<KtType> iterator = conflictingTypes.iterator(); iterator.hasNext(); ) {
|
||||
KtType type = iterator.next();
|
||||
for (KtType otherType : conflictingTypes) {
|
||||
private static void removeDuplicateTypes(Set<KotlinType> conflictingTypes) {
|
||||
for (Iterator<KotlinType> iterator = conflictingTypes.iterator(); iterator.hasNext(); ) {
|
||||
KotlinType type = iterator.next();
|
||||
for (KotlinType otherType : conflictingTypes) {
|
||||
boolean subtypeOf = KotlinTypeChecker.DEFAULT.equalTypes(type, otherType);
|
||||
if (type != otherType && subtypeOf) {
|
||||
iterator.remove();
|
||||
@@ -524,9 +524,9 @@ public class DeclarationsChecker {
|
||||
ReceiverParameterDescriptor receiverParameter = descriptor.getExtensionReceiverParameter();
|
||||
if (receiverParameter == null) return false;
|
||||
|
||||
return TypeUtils.containsSpecialType(receiverParameter.getType(), new Function1<KtType, Boolean>() {
|
||||
return TypeUtils.containsSpecialType(receiverParameter.getType(), new Function1<KotlinType, Boolean>() {
|
||||
@Override
|
||||
public Boolean invoke(KtType type) {
|
||||
public Boolean invoke(KotlinType type) {
|
||||
return parameter.equals(type.getConstructor().getDeclarationDescriptor());
|
||||
}
|
||||
});
|
||||
@@ -545,7 +545,7 @@ public class DeclarationsChecker {
|
||||
boolean returnTypeIsNullable = true;
|
||||
boolean returnTypeIsPrimitive = true;
|
||||
|
||||
KtType returnType = propertyDescriptor.getReturnType();
|
||||
KotlinType returnType = propertyDescriptor.getReturnType();
|
||||
if (returnType != null) {
|
||||
returnTypeIsNullable = TypeUtils.isNullableType(returnType);
|
||||
returnTypeIsPrimitive = KotlinBuiltIns.isPrimitiveType(returnType);
|
||||
|
||||
@@ -37,7 +37,7 @@ import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver;
|
||||
import org.jetbrains.kotlin.resolve.validation.OperatorValidator;
|
||||
import org.jetbrains.kotlin.resolve.validation.SymbolUsageValidator;
|
||||
import org.jetbrains.kotlin.types.DeferredType;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.TypeUtils;
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
|
||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingContext;
|
||||
@@ -83,10 +83,10 @@ public class DelegatedPropertyResolver {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public KtType getDelegatedPropertyGetMethodReturnType(
|
||||
public KotlinType getDelegatedPropertyGetMethodReturnType(
|
||||
@NotNull PropertyDescriptor propertyDescriptor,
|
||||
@NotNull KtExpression delegateExpression,
|
||||
@NotNull KtType delegateType,
|
||||
@NotNull KotlinType delegateType,
|
||||
@NotNull BindingTrace trace,
|
||||
@NotNull LexicalScope scope
|
||||
) {
|
||||
@@ -99,13 +99,13 @@ public class DelegatedPropertyResolver {
|
||||
public void resolveDelegatedPropertyGetMethod(
|
||||
@NotNull PropertyDescriptor propertyDescriptor,
|
||||
@NotNull KtExpression delegateExpression,
|
||||
@NotNull KtType delegateType,
|
||||
@NotNull KotlinType delegateType,
|
||||
@NotNull BindingTrace trace,
|
||||
@NotNull LexicalScope scope
|
||||
) {
|
||||
KtType returnType = getDelegatedPropertyGetMethodReturnType(
|
||||
KotlinType returnType = getDelegatedPropertyGetMethodReturnType(
|
||||
propertyDescriptor, delegateExpression, delegateType, trace, scope);
|
||||
KtType propertyType = propertyDescriptor.getType();
|
||||
KotlinType propertyType = propertyDescriptor.getType();
|
||||
|
||||
/* Do not check return type of get() method of delegate for properties with DeferredType because property type is taken from it */
|
||||
if (!(propertyType instanceof DeferredType) && returnType != null && !KotlinTypeChecker.DEFAULT.isSubtypeOf(returnType, propertyType)) {
|
||||
@@ -119,7 +119,7 @@ public class DelegatedPropertyResolver {
|
||||
public void resolveDelegatedPropertySetMethod(
|
||||
@NotNull PropertyDescriptor propertyDescriptor,
|
||||
@NotNull KtExpression delegateExpression,
|
||||
@NotNull KtType delegateType,
|
||||
@NotNull KotlinType delegateType,
|
||||
@NotNull BindingTrace trace,
|
||||
@NotNull LexicalScope scope
|
||||
) {
|
||||
@@ -134,7 +134,7 @@ public class DelegatedPropertyResolver {
|
||||
public void resolveDelegatedPropertyPDMethod(
|
||||
@NotNull PropertyDescriptor propertyDescriptor,
|
||||
@NotNull KtExpression delegateExpression,
|
||||
@NotNull KtType delegateType,
|
||||
@NotNull KotlinType delegateType,
|
||||
@NotNull BindingTrace trace,
|
||||
@NotNull LexicalScope scope
|
||||
) {
|
||||
@@ -172,7 +172,7 @@ public class DelegatedPropertyResolver {
|
||||
private void resolveDelegatedPropertyConventionMethod(
|
||||
@NotNull PropertyDescriptor propertyDescriptor,
|
||||
@NotNull KtExpression delegateExpression,
|
||||
@NotNull KtType delegateType,
|
||||
@NotNull KotlinType delegateType,
|
||||
@NotNull BindingTrace trace,
|
||||
@NotNull LexicalScope scope,
|
||||
boolean isGet
|
||||
@@ -231,7 +231,7 @@ public class DelegatedPropertyResolver {
|
||||
public OverloadResolutionResults<FunctionDescriptor> getDelegatedPropertyConventionMethod(
|
||||
@NotNull PropertyDescriptor propertyDescriptor,
|
||||
@NotNull KtExpression delegateExpression,
|
||||
@NotNull KtType delegateType,
|
||||
@NotNull KotlinType delegateType,
|
||||
@NotNull BindingTrace trace,
|
||||
@NotNull LexicalScope scope,
|
||||
boolean isGet,
|
||||
@@ -240,7 +240,7 @@ public class DelegatedPropertyResolver {
|
||||
PropertyAccessorDescriptor accessor = isGet ? propertyDescriptor.getGetter() : propertyDescriptor.getSetter();
|
||||
assert accessor != null : "Delegated property should have getter/setter " + propertyDescriptor + " " + delegateExpression.getText();
|
||||
|
||||
KtType expectedType = isComplete && isGet && !(propertyDescriptor.getType() instanceof DeferredType)
|
||||
KotlinType expectedType = isComplete && isGet && !(propertyDescriptor.getType() instanceof DeferredType)
|
||||
? propertyDescriptor.getType() : TypeUtils.NO_EXPECTED_TYPE;
|
||||
|
||||
ExpressionTypingContext context = ExpressionTypingContext.newContext(
|
||||
@@ -305,7 +305,7 @@ public class DelegatedPropertyResolver {
|
||||
assert calleeExpression != null : "CalleeExpression should exists for fake call of convention method";
|
||||
StringBuilder builder = new StringBuilder(calleeExpression.getText());
|
||||
builder.append("(");
|
||||
List<KtType> argumentTypes = Lists.newArrayList();
|
||||
List<KotlinType> argumentTypes = Lists.newArrayList();
|
||||
for (ValueArgument argument : call.getValueArguments()) {
|
||||
argumentTypes.add(context.getType(argument.getArgumentExpression()));
|
||||
|
||||
@@ -316,7 +316,7 @@ public class DelegatedPropertyResolver {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public KtType resolveDelegateExpression(
|
||||
public KotlinType resolveDelegateExpression(
|
||||
@NotNull KtExpression delegateExpression,
|
||||
@NotNull KtProperty jetProperty,
|
||||
@NotNull PropertyDescriptor propertyDescriptor,
|
||||
@@ -332,8 +332,8 @@ public class DelegatedPropertyResolver {
|
||||
if (calleeExpression != null) {
|
||||
traceToResolveDelegatedProperty.record(CONSTRAINT_SYSTEM_COMPLETER, calleeExpression, completer);
|
||||
}
|
||||
KtType delegateType = expressionTypingServices.safeGetType(propertyDeclarationInnerScope, delegateExpression, NO_EXPECTED_TYPE,
|
||||
dataFlowInfo, traceToResolveDelegatedProperty);
|
||||
KotlinType delegateType = expressionTypingServices.safeGetType(propertyDeclarationInnerScope, delegateExpression, NO_EXPECTED_TYPE,
|
||||
dataFlowInfo, traceToResolveDelegatedProperty);
|
||||
traceToResolveDelegatedProperty.commit(new TraceEntryFilter() {
|
||||
@Override
|
||||
public boolean accept(@Nullable WritableSlice<?, ?> slice, Object key) {
|
||||
@@ -351,13 +351,13 @@ public class DelegatedPropertyResolver {
|
||||
@NotNull final LexicalScope accessorScope,
|
||||
@NotNull final BindingTrace trace
|
||||
) {
|
||||
final KtType expectedType = property.getTypeReference() != null ? propertyDescriptor.getType() : NO_EXPECTED_TYPE;
|
||||
final KotlinType expectedType = property.getTypeReference() != null ? propertyDescriptor.getType() : NO_EXPECTED_TYPE;
|
||||
return new ConstraintSystemCompleter() {
|
||||
@Override
|
||||
public void completeConstraintSystem(
|
||||
@NotNull ConstraintSystem constraintSystem, @NotNull ResolvedCall<?> resolvedCall
|
||||
) {
|
||||
KtType returnType = resolvedCall.getCandidateDescriptor().getReturnType();
|
||||
KotlinType returnType = resolvedCall.getCandidateDescriptor().getReturnType();
|
||||
if (returnType == null) return;
|
||||
|
||||
TemporaryBindingTrace traceToResolveConventionMethods =
|
||||
@@ -370,7 +370,7 @@ public class DelegatedPropertyResolver {
|
||||
|
||||
if (conventionMethodFound(getMethodResults)) {
|
||||
FunctionDescriptor descriptor = getMethodResults.getResultingDescriptor();
|
||||
KtType returnTypeOfGetMethod = descriptor.getReturnType();
|
||||
KotlinType returnTypeOfGetMethod = descriptor.getReturnType();
|
||||
if (returnTypeOfGetMethod != null) {
|
||||
constraintSystem.addSupertypeConstraint(expectedType, returnTypeOfGetMethod, FROM_COMPLETER.position());
|
||||
}
|
||||
@@ -413,7 +413,7 @@ public class DelegatedPropertyResolver {
|
||||
private void addConstraintForThisValue(ConstraintSystem constraintSystem, FunctionDescriptor resultingDescriptor) {
|
||||
ReceiverParameterDescriptor extensionReceiver = propertyDescriptor.getExtensionReceiverParameter();
|
||||
ReceiverParameterDescriptor dispatchReceiver = propertyDescriptor.getDispatchReceiverParameter();
|
||||
KtType typeOfThis =
|
||||
KotlinType typeOfThis =
|
||||
extensionReceiver != null ? extensionReceiver.getType() :
|
||||
dispatchReceiver != null ? dispatchReceiver.getType() :
|
||||
builtIns.getNullableNothingType();
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.jetbrains.kotlin.diagnostics.Diagnostic;
|
||||
import org.jetbrains.kotlin.psi.KtExpression;
|
||||
import org.jetbrains.kotlin.resolve.diagnostics.Diagnostics;
|
||||
import org.jetbrains.kotlin.resolve.diagnostics.MutableDiagnosticsWithSuppression;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.expressions.JetTypeInfo;
|
||||
import org.jetbrains.kotlin.types.expressions.typeInfoFactory.TypeInfoFactoryKt;
|
||||
import org.jetbrains.kotlin.util.slicedMap.*;
|
||||
@@ -58,7 +58,7 @@ public class DelegatingBindingTrace implements BindingTrace {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public KtType getType(@NotNull KtExpression expression) {
|
||||
public KotlinType getType(@NotNull KtExpression expression) {
|
||||
return DelegatingBindingTrace.this.getType(expression);
|
||||
}
|
||||
|
||||
@@ -139,13 +139,13 @@ public class DelegatingBindingTrace implements BindingTrace {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public KtType getType(@NotNull KtExpression expression) {
|
||||
public KotlinType getType(@NotNull KtExpression expression) {
|
||||
JetTypeInfo typeInfo = get(BindingContext.EXPRESSION_TYPE_INFO, expression);
|
||||
return typeInfo != null ? typeInfo.getType() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recordType(@NotNull KtExpression expression, @Nullable KtType type) {
|
||||
public void recordType(@NotNull KtExpression expression, @Nullable KotlinType type) {
|
||||
JetTypeInfo typeInfo = get(BindingContext.EXPRESSION_TYPE_INFO, expression);
|
||||
if (typeInfo == null) {
|
||||
typeInfo = TypeInfoFactoryKt.createTypeInfo(type);
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.jetbrains.kotlin.psi.KtClassOrObject;
|
||||
import org.jetbrains.kotlin.psi.KtDelegationSpecifier;
|
||||
import org.jetbrains.kotlin.psi.KtDelegatorByExpressionSpecifier;
|
||||
import org.jetbrains.kotlin.psi.KtTypeReference;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.TypeUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -88,7 +88,7 @@ public final class DelegationResolver<T extends CallableMemberDescriptor> {
|
||||
if (typeReference == null) {
|
||||
continue;
|
||||
}
|
||||
KtType delegatedTraitType = typeResolver.resolve(typeReference);
|
||||
KotlinType delegatedTraitType = typeResolver.resolve(typeReference);
|
||||
if (delegatedTraitType == null || delegatedTraitType.isError()) {
|
||||
continue;
|
||||
}
|
||||
@@ -101,7 +101,7 @@ public final class DelegationResolver<T extends CallableMemberDescriptor> {
|
||||
@NotNull
|
||||
private Collection<T> generateDelegatesForTrait(
|
||||
@NotNull Collection<T> existingDelegates,
|
||||
@NotNull KtType delegatedTraitType
|
||||
@NotNull KotlinType delegatedTraitType
|
||||
) {
|
||||
Collection<T> result = new HashSet<T>();
|
||||
Collection<T> candidates = generateDelegationCandidates(delegatedTraitType);
|
||||
@@ -120,7 +120,7 @@ public final class DelegationResolver<T extends CallableMemberDescriptor> {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Collection<T> generateDelegationCandidates(@NotNull KtType delegatedTraitType) {
|
||||
private Collection<T> generateDelegationCandidates(@NotNull KotlinType delegatedTraitType) {
|
||||
Collection<T> descriptorsToDelegate = overridableMembersNotFromSuperClassOfTrait(delegatedTraitType);
|
||||
Collection<T> result = new ArrayList<T>(descriptorsToDelegate.size());
|
||||
for (T memberDescriptor : descriptorsToDelegate) {
|
||||
@@ -156,7 +156,7 @@ public final class DelegationResolver<T extends CallableMemberDescriptor> {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Collection<T> overridableMembersNotFromSuperClassOfTrait(@NotNull KtType trait) {
|
||||
private Collection<T> overridableMembersNotFromSuperClassOfTrait(@NotNull KotlinType trait) {
|
||||
final Collection<T> membersToSkip = getMembersFromClassSupertypeOfTrait(trait);
|
||||
return Collections2.filter(
|
||||
memberExtractor.getMembersByType(trait),
|
||||
@@ -182,9 +182,9 @@ public final class DelegationResolver<T extends CallableMemberDescriptor> {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Collection<T> getMembersFromClassSupertypeOfTrait(@NotNull KtType traitType) {
|
||||
KtType classSupertype = null;
|
||||
for (KtType supertype : TypeUtils.getAllSupertypes(traitType)) {
|
||||
private Collection<T> getMembersFromClassSupertypeOfTrait(@NotNull KotlinType traitType) {
|
||||
KotlinType classSupertype = null;
|
||||
for (KotlinType supertype : TypeUtils.getAllSupertypes(traitType)) {
|
||||
if (isNotTrait(supertype.getConstructor().getDeclarationDescriptor())) {
|
||||
classSupertype = supertype;
|
||||
break;
|
||||
@@ -203,11 +203,11 @@ public final class DelegationResolver<T extends CallableMemberDescriptor> {
|
||||
|
||||
public interface MemberExtractor<T extends CallableMemberDescriptor> {
|
||||
@NotNull
|
||||
Collection<T> getMembersByType(@NotNull KtType type);
|
||||
Collection<T> getMembersByType(@NotNull KotlinType type);
|
||||
}
|
||||
|
||||
public interface TypeResolver {
|
||||
@Nullable
|
||||
KtType resolve(@NotNull KtTypeReference reference);
|
||||
KotlinType resolve(@NotNull KtTypeReference reference);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,20 +96,20 @@ public class DescriptorResolver {
|
||||
this.constantExpressionEvaluator = constantExpressionEvaluator;
|
||||
}
|
||||
|
||||
public List<KtType> resolveSupertypes(
|
||||
public List<KotlinType> resolveSupertypes(
|
||||
@NotNull LexicalScope scope,
|
||||
@NotNull ClassDescriptor classDescriptor,
|
||||
@NotNull KtClassOrObject jetClass,
|
||||
BindingTrace trace
|
||||
) {
|
||||
List<KtType> supertypes = Lists.newArrayList();
|
||||
List<KotlinType> supertypes = Lists.newArrayList();
|
||||
List<KtDelegationSpecifier> delegationSpecifiers = jetClass.getDelegationSpecifiers();
|
||||
Collection<KtType> declaredSupertypes = resolveDelegationSpecifiers(
|
||||
Collection<KotlinType> declaredSupertypes = resolveDelegationSpecifiers(
|
||||
scope,
|
||||
delegationSpecifiers,
|
||||
typeResolver, trace, false);
|
||||
|
||||
for (KtType declaredSupertype : declaredSupertypes) {
|
||||
for (KotlinType declaredSupertype : declaredSupertypes) {
|
||||
addValidSupertype(supertypes, declaredSupertype);
|
||||
}
|
||||
|
||||
@@ -118,21 +118,21 @@ public class DescriptorResolver {
|
||||
}
|
||||
|
||||
if (supertypes.isEmpty()) {
|
||||
KtType defaultSupertype = getDefaultSupertype(jetClass, trace, classDescriptor.getKind() == ClassKind.ANNOTATION_CLASS);
|
||||
KotlinType defaultSupertype = getDefaultSupertype(jetClass, trace, classDescriptor.getKind() == ClassKind.ANNOTATION_CLASS);
|
||||
addValidSupertype(supertypes, defaultSupertype);
|
||||
}
|
||||
|
||||
return supertypes;
|
||||
}
|
||||
|
||||
private static void addValidSupertype(List<KtType> supertypes, KtType declaredSupertype) {
|
||||
private static void addValidSupertype(List<KotlinType> supertypes, KotlinType declaredSupertype) {
|
||||
if (!declaredSupertype.isError()) {
|
||||
supertypes.add(declaredSupertype);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean containsClass(Collection<KtType> result) {
|
||||
for (KtType type : result) {
|
||||
private boolean containsClass(Collection<KotlinType> result) {
|
||||
for (KotlinType type : result) {
|
||||
ClassifierDescriptor descriptor = type.getConstructor().getDeclarationDescriptor();
|
||||
if (descriptor instanceof ClassDescriptor && ((ClassDescriptor) descriptor).getKind() != ClassKind.INTERFACE) {
|
||||
return true;
|
||||
@@ -141,7 +141,7 @@ public class DescriptorResolver {
|
||||
return false;
|
||||
}
|
||||
|
||||
private KtType getDefaultSupertype(KtClassOrObject jetClass, BindingTrace trace, boolean isAnnotation) {
|
||||
private KotlinType getDefaultSupertype(KtClassOrObject jetClass, BindingTrace trace, boolean isAnnotation) {
|
||||
// TODO : beautify
|
||||
if (jetClass instanceof KtEnumEntry) {
|
||||
KtClassOrObject parent = KtStubbedPsiUtil.getContainingDeclaration(jetClass, KtClassOrObject.class);
|
||||
@@ -160,7 +160,7 @@ public class DescriptorResolver {
|
||||
return builtIns.getAnyType();
|
||||
}
|
||||
|
||||
public Collection<KtType> resolveDelegationSpecifiers(
|
||||
public Collection<KotlinType> resolveDelegationSpecifiers(
|
||||
LexicalScope extensibleScope,
|
||||
List<KtDelegationSpecifier> delegationSpecifiers,
|
||||
@NotNull TypeResolver resolver,
|
||||
@@ -170,11 +170,11 @@ public class DescriptorResolver {
|
||||
if (delegationSpecifiers.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
Collection<KtType> result = Lists.newArrayList();
|
||||
Collection<KotlinType> result = Lists.newArrayList();
|
||||
for (KtDelegationSpecifier delegationSpecifier : delegationSpecifiers) {
|
||||
KtTypeReference typeReference = delegationSpecifier.getTypeReference();
|
||||
if (typeReference != null) {
|
||||
KtType supertype = resolver.resolveType(extensibleScope, typeReference, trace, checkBounds);
|
||||
KotlinType supertype = resolver.resolveType(extensibleScope, typeReference, trace, checkBounds);
|
||||
if (DynamicTypesKt.isDynamic(supertype)) {
|
||||
trace.report(DYNAMIC_SUPERTYPE.on(typeReference));
|
||||
}
|
||||
@@ -225,7 +225,7 @@ public class DescriptorResolver {
|
||||
@NotNull BindingTrace trace
|
||||
) {
|
||||
Name functionName = DataClassUtilsKt.createComponentName(parameterIndex);
|
||||
KtType returnType = property.getType();
|
||||
KotlinType returnType = property.getType();
|
||||
|
||||
SimpleFunctionDescriptorImpl functionDescriptor = SimpleFunctionDescriptorImpl.create(
|
||||
classDescriptor,
|
||||
@@ -257,7 +257,7 @@ public class DescriptorResolver {
|
||||
@NotNull ClassDescriptor classDescriptor,
|
||||
@NotNull BindingTrace trace
|
||||
) {
|
||||
KtType returnType = classDescriptor.getDefaultType();
|
||||
KotlinType returnType = classDescriptor.getDefaultType();
|
||||
|
||||
SimpleFunctionDescriptorImpl functionDescriptor = SimpleFunctionDescriptorImpl.create(
|
||||
classDescriptor,
|
||||
@@ -333,10 +333,10 @@ public class DescriptorResolver {
|
||||
|
||||
@NotNull
|
||||
public ValueParameterDescriptorImpl resolveValueParameterDescriptor(
|
||||
LexicalScope scope, FunctionDescriptor owner, KtParameter valueParameter, int index, KtType type, BindingTrace trace
|
||||
LexicalScope scope, FunctionDescriptor owner, KtParameter valueParameter, int index, KotlinType type, BindingTrace trace
|
||||
) {
|
||||
KtType varargElementType = null;
|
||||
KtType variableType = type;
|
||||
KotlinType varargElementType = null;
|
||||
KotlinType variableType = type;
|
||||
if (valueParameter.hasModifier(VARARG_KEYWORD)) {
|
||||
varargElementType = type;
|
||||
variableType = getVarargParameterType(type);
|
||||
@@ -378,8 +378,8 @@ public class DescriptorResolver {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private KtType getVarargParameterType(@NotNull KtType elementType) {
|
||||
KtType primitiveArrayType = builtIns.getPrimitiveArrayJetTypeByPrimitiveJetType(elementType);
|
||||
private KotlinType getVarargParameterType(@NotNull KotlinType elementType) {
|
||||
KotlinType primitiveArrayType = builtIns.getPrimitiveArrayJetTypeByPrimitiveJetType(elementType);
|
||||
if (primitiveArrayType != null) {
|
||||
return primitiveArrayType;
|
||||
}
|
||||
@@ -449,21 +449,21 @@ public class DescriptorResolver {
|
||||
|
||||
static final class UpperBoundCheckerTask {
|
||||
KtTypeReference upperBound;
|
||||
KtType upperBoundType;
|
||||
KotlinType upperBoundType;
|
||||
|
||||
private UpperBoundCheckerTask(KtTypeReference upperBound, KtType upperBoundType) {
|
||||
private UpperBoundCheckerTask(KtTypeReference upperBound, KotlinType upperBoundType) {
|
||||
this.upperBound = upperBound;
|
||||
this.upperBoundType = upperBoundType;
|
||||
}
|
||||
}
|
||||
|
||||
public KtType resolveTypeParameterExtendsBound(
|
||||
public KotlinType resolveTypeParameterExtendsBound(
|
||||
@NotNull TypeParameterDescriptor typeParameterDescriptor,
|
||||
@NotNull KtTypeReference extendsBound,
|
||||
LexicalScope scope,
|
||||
BindingTrace trace
|
||||
) {
|
||||
KtType type = typeResolver.resolveType(scope, extendsBound, trace, false);
|
||||
KotlinType type = typeResolver.resolveType(scope, extendsBound, trace, false);
|
||||
if (type.getConstructor().equals(typeParameterDescriptor.getTypeConstructor())) {
|
||||
trace.report(Errors.CYCLIC_GENERIC_UPPER_BOUND.on(extendsBound));
|
||||
type = ErrorUtils.createErrorType("Cyclic upper bound: " + type);
|
||||
@@ -490,7 +490,7 @@ public class DescriptorResolver {
|
||||
|
||||
KtTypeReference extendsBound = jetTypeParameter.getExtendsBound();
|
||||
if (extendsBound != null) {
|
||||
KtType type = resolveTypeParameterExtendsBound(typeParameterDescriptor, extendsBound, scope, trace);
|
||||
KotlinType type = resolveTypeParameterExtendsBound(typeParameterDescriptor, extendsBound, scope, trace);
|
||||
typeParameterDescriptor.addUpperBound(type);
|
||||
deferredUpperBoundCheckerTasks.add(new UpperBoundCheckerTask(extendsBound, type));
|
||||
}
|
||||
@@ -503,7 +503,7 @@ public class DescriptorResolver {
|
||||
Name referencedName = subjectTypeParameterName.getReferencedNameAsName();
|
||||
TypeParameterDescriptorImpl typeParameterDescriptor = parameterByName.get(referencedName);
|
||||
KtTypeReference boundTypeReference = constraint.getBoundTypeReference();
|
||||
KtType bound = null;
|
||||
KotlinType bound = null;
|
||||
if (boundTypeReference != null) {
|
||||
bound = typeResolver.resolveType(scope, boundTypeReference, trace, false);
|
||||
deferredUpperBoundCheckerTasks.add(new UpperBoundCheckerTask(boundTypeReference, bound));
|
||||
@@ -577,7 +577,7 @@ public class DescriptorResolver {
|
||||
|
||||
public static void checkUpperBoundType(
|
||||
KtTypeReference upperBound,
|
||||
@NotNull KtType upperBoundType,
|
||||
@NotNull KotlinType upperBoundType,
|
||||
BindingTrace trace
|
||||
) {
|
||||
if (!TypeUtils.canHaveSubtypes(KotlinTypeChecker.DEFAULT, upperBoundType)) {
|
||||
@@ -598,13 +598,13 @@ public class DescriptorResolver {
|
||||
@NotNull KtParameter parameter,
|
||||
BindingTrace trace
|
||||
) {
|
||||
KtType type = resolveParameterType(scope, parameter, trace);
|
||||
KotlinType type = resolveParameterType(scope, parameter, trace);
|
||||
return resolveLocalVariableDescriptor(parameter, type, trace, scope);
|
||||
}
|
||||
|
||||
private KtType resolveParameterType(LexicalScope scope, KtParameter parameter, BindingTrace trace) {
|
||||
private KotlinType resolveParameterType(LexicalScope scope, KtParameter parameter, BindingTrace trace) {
|
||||
KtTypeReference typeReference = parameter.getTypeReference();
|
||||
KtType type;
|
||||
KotlinType type;
|
||||
if (typeReference != null) {
|
||||
type = typeResolver.resolveType(scope, typeReference, trace, true);
|
||||
}
|
||||
@@ -620,7 +620,7 @@ public class DescriptorResolver {
|
||||
|
||||
public VariableDescriptor resolveLocalVariableDescriptor(
|
||||
@NotNull KtParameter parameter,
|
||||
@NotNull KtType type,
|
||||
@NotNull KotlinType type,
|
||||
BindingTrace trace,
|
||||
@NotNull LexicalScope scope
|
||||
) {
|
||||
@@ -647,7 +647,7 @@ public class DescriptorResolver {
|
||||
) {
|
||||
DeclarationDescriptor containingDeclaration = scope.getOwnerDescriptor();
|
||||
VariableDescriptor result;
|
||||
KtType type;
|
||||
KotlinType type;
|
||||
// SCRIPT: Create property descriptors
|
||||
if (KtPsiUtil.isScriptDeclaration(variable)) {
|
||||
PropertyDescriptorImpl propertyDescriptor = PropertyDescriptorImpl.create(
|
||||
@@ -666,7 +666,7 @@ public class DescriptorResolver {
|
||||
type = getVariableType(propertyDescriptor, scope, variable, dataFlowInfo, false, trace);
|
||||
|
||||
ReceiverParameterDescriptor receiverParameter = ((ScriptDescriptor) containingDeclaration).getThisAsReceiverParameter();
|
||||
propertyDescriptor.setType(type, Collections.<TypeParameterDescriptor>emptyList(), receiverParameter, (KtType) null);
|
||||
propertyDescriptor.setType(type, Collections.<TypeParameterDescriptor>emptyList(), receiverParameter, (KotlinType) null);
|
||||
initializeWithDefaultGetterSetter(propertyDescriptor);
|
||||
trace.record(BindingContext.VARIABLE, variable, propertyDescriptor);
|
||||
result = propertyDescriptor;
|
||||
@@ -702,7 +702,7 @@ public class DescriptorResolver {
|
||||
public LocalVariableDescriptor resolveLocalVariableDescriptorWithType(
|
||||
@NotNull LexicalScope scope,
|
||||
@NotNull KtVariableDeclaration variable,
|
||||
@Nullable KtType type,
|
||||
@Nullable KotlinType type,
|
||||
@NotNull BindingTrace trace
|
||||
) {
|
||||
LocalVariableDescriptor variableDescriptor = new LocalVariableDescriptor(
|
||||
@@ -765,7 +765,7 @@ public class DescriptorResolver {
|
||||
|
||||
List<TypeParameterDescriptorImpl> typeParameterDescriptors;
|
||||
LexicalScope scopeWithTypeParameters;
|
||||
KtType receiverType = null;
|
||||
KotlinType receiverType = null;
|
||||
|
||||
{
|
||||
List<KtTypeParameter> typeParameters = property.getTypeParameters();
|
||||
@@ -798,7 +798,7 @@ public class DescriptorResolver {
|
||||
LexicalScope propertyScope = JetScopeUtils.getPropertyDeclarationInnerScope(propertyDescriptor, scope, typeParameterDescriptors,
|
||||
implicitInitializerReceiver, trace);
|
||||
|
||||
KtType type = getVariableType(propertyDescriptor, propertyScope, property, dataFlowInfo, true, trace);
|
||||
KotlinType type = getVariableType(propertyDescriptor, propertyScope, property, dataFlowInfo, true, trace);
|
||||
|
||||
propertyDescriptor.setType(type, typeParameterDescriptors, getDispatchReceiverParameterIfNeeded(containingDeclaration),
|
||||
receiverDescriptor);
|
||||
@@ -831,7 +831,7 @@ public class DescriptorResolver {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private KtType getVariableType(
|
||||
private KotlinType getVariableType(
|
||||
@NotNull final VariableDescriptorWithInitializerImpl variableDescriptor,
|
||||
@NotNull final LexicalScope scope,
|
||||
@NotNull final KtVariableDeclaration variable,
|
||||
@@ -850,9 +850,9 @@ public class DescriptorResolver {
|
||||
return DeferredType.createRecursionIntolerant(
|
||||
storageManager,
|
||||
trace,
|
||||
new Function0<KtType>() {
|
||||
new Function0<KotlinType>() {
|
||||
@Override
|
||||
public KtType invoke() {
|
||||
public KotlinType invoke() {
|
||||
return resolveDelegatedPropertyType(property, (PropertyDescriptor) variableDescriptor, scope,
|
||||
property.getDelegateExpression(), dataFlowInfo, trace);
|
||||
}
|
||||
@@ -869,11 +869,12 @@ public class DescriptorResolver {
|
||||
return DeferredType.createRecursionIntolerant(
|
||||
storageManager,
|
||||
trace,
|
||||
new Function0<KtType>() {
|
||||
new Function0<KotlinType>() {
|
||||
@Override
|
||||
public KtType invoke() {
|
||||
public KotlinType invoke() {
|
||||
PreliminaryDeclarationVisitor.Companion.createForDeclaration(variable, trace);
|
||||
KtType initializerType = resolveInitializerType(scope, variable.getInitializer(), dataFlowInfo, trace);
|
||||
KotlinType
|
||||
initializerType = resolveInitializerType(scope, variable.getInitializer(), dataFlowInfo, trace);
|
||||
setConstantForVariableIfNeeded(variableDescriptor, scope, variable, dataFlowInfo, initializerType, trace);
|
||||
return transformAnonymousTypeIfNeeded(variableDescriptor, variable, initializerType, trace);
|
||||
}
|
||||
@@ -881,14 +882,14 @@ public class DescriptorResolver {
|
||||
);
|
||||
}
|
||||
else {
|
||||
KtType initializerType = resolveInitializerType(scope, variable.getInitializer(), dataFlowInfo, trace);
|
||||
KotlinType initializerType = resolveInitializerType(scope, variable.getInitializer(), dataFlowInfo, trace);
|
||||
setConstantForVariableIfNeeded(variableDescriptor, scope, variable, dataFlowInfo, initializerType, trace);
|
||||
return initializerType;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
KtType type = typeResolver.resolveType(scope, propertyTypeRef, trace, true);
|
||||
KotlinType type = typeResolver.resolveType(scope, propertyTypeRef, trace, true);
|
||||
setConstantForVariableIfNeeded(variableDescriptor, scope, variable, dataFlowInfo, type, trace);
|
||||
return type;
|
||||
}
|
||||
@@ -899,7 +900,7 @@ public class DescriptorResolver {
|
||||
@NotNull final LexicalScope scope,
|
||||
@NotNull final KtVariableDeclaration variable,
|
||||
@NotNull final DataFlowInfo dataFlowInfo,
|
||||
@NotNull final KtType variableType,
|
||||
@NotNull final KotlinType variableType,
|
||||
@NotNull final BindingTrace trace
|
||||
) {
|
||||
if (!shouldRecordInitializerForProperty(variableDescriptor, variableType)) return;
|
||||
@@ -912,7 +913,7 @@ public class DescriptorResolver {
|
||||
@Override
|
||||
public ConstantValue<?> invoke() {
|
||||
KtExpression initializer = variable.getInitializer();
|
||||
KtType initializerType = expressionTypingServices.safeGetType(scope, initializer, variableType, dataFlowInfo, trace);
|
||||
KotlinType initializerType = expressionTypingServices.safeGetType(scope, initializer, variableType, dataFlowInfo, trace);
|
||||
CompileTimeConstant<?> constant = constantExpressionEvaluator.evaluateExpression(initializer, trace, initializerType);
|
||||
|
||||
if (constant == null) return null;
|
||||
@@ -928,7 +929,7 @@ public class DescriptorResolver {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private KtType resolveDelegatedPropertyType(
|
||||
private KotlinType resolveDelegatedPropertyType(
|
||||
@NotNull KtProperty property,
|
||||
@NotNull PropertyDescriptor propertyDescriptor,
|
||||
@NotNull LexicalScope scope,
|
||||
@@ -938,11 +939,11 @@ public class DescriptorResolver {
|
||||
) {
|
||||
LexicalScope accessorScope = JetScopeUtils.makeScopeForPropertyAccessor(propertyDescriptor, scope, trace);
|
||||
|
||||
KtType type = delegatedPropertyResolver.resolveDelegateExpression(
|
||||
KotlinType type = delegatedPropertyResolver.resolveDelegateExpression(
|
||||
delegateExpression, property, propertyDescriptor, scope, accessorScope, trace, dataFlowInfo);
|
||||
|
||||
if (type != null) {
|
||||
KtType getterReturnType = delegatedPropertyResolver
|
||||
KotlinType getterReturnType = delegatedPropertyResolver
|
||||
.getDelegatedPropertyGetMethodReturnType(propertyDescriptor, delegateExpression, type, trace, accessorScope);
|
||||
if (getterReturnType != null) {
|
||||
return getterReturnType;
|
||||
@@ -952,10 +953,10 @@ public class DescriptorResolver {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
/*package*/ static KtType transformAnonymousTypeIfNeeded(
|
||||
/*package*/ static KotlinType transformAnonymousTypeIfNeeded(
|
||||
@NotNull DeclarationDescriptorWithVisibility descriptor,
|
||||
@NotNull KtNamedDeclaration declaration,
|
||||
@NotNull KtType type,
|
||||
@NotNull KotlinType type,
|
||||
@NotNull BindingTrace trace
|
||||
) {
|
||||
ClassifierDescriptor classifier = type.getConstructor().getDeclarationDescriptor();
|
||||
@@ -977,7 +978,7 @@ public class DescriptorResolver {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private KtType resolveInitializerType(
|
||||
private KotlinType resolveInitializerType(
|
||||
@NotNull LexicalScope scope,
|
||||
@NotNull KtExpression initializer,
|
||||
@NotNull DataFlowInfo dataFlowInfo,
|
||||
@@ -1015,14 +1016,14 @@ public class DescriptorResolver {
|
||||
trace.report(SETTER_PARAMETER_WITH_DEFAULT_VALUE.on(parameter.getDefaultValue()));
|
||||
}
|
||||
|
||||
KtType type;
|
||||
KotlinType type;
|
||||
KtTypeReference typeReference = parameter.getTypeReference();
|
||||
if (typeReference == null) {
|
||||
type = propertyDescriptor.getType(); // TODO : this maybe unknown at this point
|
||||
}
|
||||
else {
|
||||
type = typeResolver.resolveType(scope, typeReference, trace, true);
|
||||
KtType inType = propertyDescriptor.getType();
|
||||
KotlinType inType = propertyDescriptor.getType();
|
||||
if (inType != null) {
|
||||
if (!TypeUtils.equalTypes(type, inType)) {
|
||||
trace.report(WRONG_SETTER_PARAMETER_TYPE.on(typeReference, inType, type));
|
||||
@@ -1073,8 +1074,8 @@ public class DescriptorResolver {
|
||||
annotationSplitter.getAnnotationsForTarget(PROPERTY_GETTER),
|
||||
annotationResolver.resolveAnnotationsWithoutArguments(scope, getter.getModifierList(), trace)));
|
||||
|
||||
KtType outType = propertyDescriptor.getType();
|
||||
KtType returnType = outType;
|
||||
KotlinType outType = propertyDescriptor.getType();
|
||||
KotlinType returnType = outType;
|
||||
KtTypeReference returnTypeReference = getter.getReturnTypeReference();
|
||||
if (returnTypeReference != null) {
|
||||
returnType = typeResolver.resolveType(scope, returnTypeReference, trace, true);
|
||||
@@ -1108,7 +1109,7 @@ public class DescriptorResolver {
|
||||
@NotNull LexicalScope scope,
|
||||
@NotNull KtParameter parameter, final BindingTrace trace
|
||||
) {
|
||||
KtType type = resolveParameterType(scope, parameter, trace);
|
||||
KotlinType type = resolveParameterType(scope, parameter, trace);
|
||||
Name name = parameter.getNameAsSafeName();
|
||||
boolean isMutable = parameter.isMutable();
|
||||
KtModifierList modifierList = parameter.getModifierList();
|
||||
@@ -1165,7 +1166,7 @@ public class DescriptorResolver {
|
||||
return propertyDescriptor;
|
||||
}
|
||||
|
||||
public static void checkBounds(@NotNull KtTypeReference typeReference, @NotNull KtType type, @NotNull BindingTrace trace) {
|
||||
public static void checkBounds(@NotNull KtTypeReference typeReference, @NotNull KotlinType type, @NotNull BindingTrace trace) {
|
||||
if (type.isError()) return;
|
||||
|
||||
KtTypeElement typeElement = typeReference.getTypeElement();
|
||||
@@ -1197,7 +1198,7 @@ public class DescriptorResolver {
|
||||
|
||||
if (jetTypeArgument == null) continue;
|
||||
|
||||
KtType typeArgument = arguments.get(i).getType();
|
||||
KotlinType typeArgument = arguments.get(i).getType();
|
||||
checkBounds(jetTypeArgument, typeArgument, trace);
|
||||
|
||||
TypeParameterDescriptor typeParameterDescriptor = parameters.get(i);
|
||||
@@ -1207,13 +1208,13 @@ public class DescriptorResolver {
|
||||
|
||||
public static void checkBounds(
|
||||
@NotNull KtTypeReference jetTypeArgument,
|
||||
@NotNull KtType typeArgument,
|
||||
@NotNull KotlinType typeArgument,
|
||||
@NotNull TypeParameterDescriptor typeParameterDescriptor,
|
||||
@NotNull TypeSubstitutor substitutor,
|
||||
@NotNull BindingTrace trace
|
||||
) {
|
||||
for (KtType bound : typeParameterDescriptor.getUpperBounds()) {
|
||||
KtType substitutedBound = substitutor.safeSubstitute(bound, Variance.INVARIANT);
|
||||
for (KotlinType bound : typeParameterDescriptor.getUpperBounds()) {
|
||||
KotlinType substitutedBound = substitutor.safeSubstitute(bound, Variance.INVARIANT);
|
||||
if (!KotlinTypeChecker.DEFAULT.isSubtypeOf(typeArgument, substitutedBound)) {
|
||||
trace.report(UPPER_BOUND_VIOLATED.on(jetTypeArgument, substitutedBound, typeArgument));
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ import org.jetbrains.kotlin.resolve.source.toSourceElement
|
||||
import org.jetbrains.kotlin.storage.StorageManager
|
||||
import org.jetbrains.kotlin.types.DeferredType
|
||||
import org.jetbrains.kotlin.types.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
|
||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices
|
||||
@@ -84,7 +84,7 @@ class FunctionDescriptorResolver(
|
||||
function: KtNamedFunction,
|
||||
trace: BindingTrace,
|
||||
dataFlowInfo: DataFlowInfo,
|
||||
expectedFunctionType: KtType
|
||||
expectedFunctionType: KotlinType
|
||||
): SimpleFunctionDescriptor = resolveFunctionDescriptor(
|
||||
::FunctionExpressionDescriptor, containingDescriptor, scope, function, trace, dataFlowInfo, expectedFunctionType)
|
||||
|
||||
@@ -95,7 +95,7 @@ class FunctionDescriptorResolver(
|
||||
function: KtNamedFunction,
|
||||
trace: BindingTrace,
|
||||
dataFlowInfo: DataFlowInfo,
|
||||
expectedFunctionType: KtType
|
||||
expectedFunctionType: KotlinType
|
||||
): SimpleFunctionDescriptor {
|
||||
val functionDescriptor = functionConstructor(
|
||||
containingDescriptor,
|
||||
@@ -143,7 +143,7 @@ class FunctionDescriptorResolver(
|
||||
function: KtFunction,
|
||||
functionDescriptor: SimpleFunctionDescriptorImpl,
|
||||
trace: BindingTrace,
|
||||
expectedFunctionType: KtType
|
||||
expectedFunctionType: KotlinType
|
||||
) {
|
||||
val innerScope = LexicalWritableScope(scope, functionDescriptor, true, null,
|
||||
TraceBasedRedeclarationHandler(trace), "Function descriptor header scope")
|
||||
@@ -194,7 +194,7 @@ class FunctionDescriptorResolver(
|
||||
functionDescriptor: SimpleFunctionDescriptorImpl,
|
||||
innerScope: LexicalWritableScope,
|
||||
trace: BindingTrace,
|
||||
expectedFunctionType: KtType
|
||||
expectedFunctionType: KotlinType
|
||||
): List<ValueParameterDescriptor> {
|
||||
val expectedValueParameters = expectedFunctionType.getValueParameters(functionDescriptor)
|
||||
if (expectedValueParameters != null) {
|
||||
@@ -225,11 +225,11 @@ class FunctionDescriptorResolver(
|
||||
)
|
||||
}
|
||||
|
||||
private fun KtType.functionTypeExpected() = !TypeUtils.noExpectedType(this) && KotlinBuiltIns.isFunctionOrExtensionFunctionType(this)
|
||||
private fun KtType.getReceiverType(): KtType? =
|
||||
private fun KotlinType.functionTypeExpected() = !TypeUtils.noExpectedType(this) && KotlinBuiltIns.isFunctionOrExtensionFunctionType(this)
|
||||
private fun KotlinType.getReceiverType(): KotlinType? =
|
||||
if (functionTypeExpected()) KotlinBuiltIns.getReceiverType(this) else null
|
||||
|
||||
private fun KtType.getValueParameters(owner: FunctionDescriptor): List<ValueParameterDescriptor>? =
|
||||
private fun KotlinType.getValueParameters(owner: FunctionDescriptor): List<ValueParameterDescriptor>? =
|
||||
if (functionTypeExpected()) KotlinBuiltIns.getValueParameters(owner, this) else null
|
||||
|
||||
public fun resolvePrimaryConstructorDescriptor(
|
||||
@@ -322,7 +322,7 @@ class FunctionDescriptorResolver(
|
||||
val typeReference = valueParameter.getTypeReference()
|
||||
val expectedType = expectedValueParameters?.let { if (i < it.size()) it[i].getType() else null }
|
||||
|
||||
val type: KtType
|
||||
val type: KotlinType
|
||||
if (typeReference != null) {
|
||||
type = typeResolver.resolveType(parameterScope, typeReference, trace, true)
|
||||
if (expectedType != null && !TypeUtils.noExpectedType(expectedType)) {
|
||||
|
||||
@@ -38,7 +38,7 @@ public class FunctionDescriptorUtil {
|
||||
private static final TypeSubstitutor MAKE_TYPE_PARAMETERS_FRESH = TypeSubstitutor.create(new TypeSubstitution() {
|
||||
|
||||
@Override
|
||||
public TypeProjection get(@NotNull KtType key) {
|
||||
public TypeProjection get(@NotNull KotlinType key) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ public class FunctionDescriptorUtil {
|
||||
|
||||
public static TypeSubstitution createSubstitution(
|
||||
@NotNull FunctionDescriptor functionDescriptor,
|
||||
@NotNull List<KtType> typeArguments
|
||||
@NotNull List<KotlinType> typeArguments
|
||||
) {
|
||||
if (functionDescriptor.getTypeParameters().isEmpty()) return TypeSubstitution.getEMPTY();
|
||||
|
||||
@@ -90,7 +90,7 @@ public class FunctionDescriptorUtil {
|
||||
|
||||
public static void initializeFromFunctionType(
|
||||
@NotNull FunctionDescriptorImpl functionDescriptor,
|
||||
@NotNull KtType functionType,
|
||||
@NotNull KotlinType functionType,
|
||||
@Nullable ReceiverParameterDescriptor dispatchReceiverParameter,
|
||||
@NotNull Modality modality,
|
||||
@NotNull Visibility visibility
|
||||
@@ -129,7 +129,7 @@ public class FunctionDescriptorUtil {
|
||||
List<ValueParameterDescriptor> parameters = new ArrayList<ValueParameterDescriptor>(newParameters.size());
|
||||
int idx = 0;
|
||||
for (ValueParameterDescriptor parameter : newParameters) {
|
||||
KtType returnType = parameter.getReturnType();
|
||||
KotlinType returnType = parameter.getReturnType();
|
||||
assert returnType != null;
|
||||
|
||||
parameters.add(
|
||||
|
||||
@@ -21,7 +21,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic;
|
||||
import org.jetbrains.kotlin.psi.KtExpression;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.util.slicedMap.ReadOnlySlice;
|
||||
import org.jetbrains.kotlin.util.slicedMap.WritableSlice;
|
||||
|
||||
@@ -78,12 +78,12 @@ public class ObservableBindingTrace implements BindingTrace {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public KtType getType(@NotNull KtExpression expression) {
|
||||
public KotlinType getType(@NotNull KtExpression expression) {
|
||||
return originalTrace.getType(expression);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recordType(@NotNull KtExpression expression, @Nullable KtType type) {
|
||||
public void recordType(@NotNull KtExpression expression, @Nullable KotlinType type) {
|
||||
originalTrace.recordType(expression, type);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ import org.jetbrains.kotlin.descriptors.CallableDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.ConstructorDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.TypeCapabilitiesKt;
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
|
||||
|
||||
@@ -65,12 +65,12 @@ public class OverloadUtil {
|
||||
return receiverAndParameterResult;
|
||||
}
|
||||
|
||||
List<KtType> superValueParameters = OverridingUtil.compiledValueParameters(superDescriptor);
|
||||
List<KtType> subValueParameters = OverridingUtil.compiledValueParameters(subDescriptor);
|
||||
List<KotlinType> superValueParameters = OverridingUtil.compiledValueParameters(superDescriptor);
|
||||
List<KotlinType> subValueParameters = OverridingUtil.compiledValueParameters(subDescriptor);
|
||||
|
||||
for (int i = 0; i < superValueParameters.size(); ++i) {
|
||||
KtType superValueParameterType = OverridingUtil.getUpperBound(superValueParameters.get(i));
|
||||
KtType subValueParameterType = OverridingUtil.getUpperBound(subValueParameters.get(i));
|
||||
KotlinType superValueParameterType = OverridingUtil.getUpperBound(superValueParameters.get(i));
|
||||
KotlinType subValueParameterType = OverridingUtil.getUpperBound(subValueParameters.get(i));
|
||||
if (!KotlinTypeChecker.DEFAULT.equalTypes(superValueParameterType, subValueParameterType)
|
||||
|| TypeCapabilitiesKt.oneMoreSpecificThanAnother(subValueParameterType, superValueParameterType)) {
|
||||
return OverridingUtil.OverrideCompatibilityInfo
|
||||
|
||||
@@ -235,13 +235,13 @@ public class OverrideResolver {
|
||||
|
||||
private static List<CallableMemberDescriptor> getCallableMembersFromSupertypes(ClassDescriptor classDescriptor) {
|
||||
Set<CallableMemberDescriptor> r = Sets.newLinkedHashSet();
|
||||
for (KtType supertype : classDescriptor.getTypeConstructor().getSupertypes()) {
|
||||
for (KotlinType supertype : classDescriptor.getTypeConstructor().getSupertypes()) {
|
||||
r.addAll(getCallableMembersFromType(supertype));
|
||||
}
|
||||
return new ArrayList<CallableMemberDescriptor>(r);
|
||||
}
|
||||
|
||||
private static List<CallableMemberDescriptor> getCallableMembersFromType(KtType type) {
|
||||
private static List<CallableMemberDescriptor> getCallableMembersFromType(KotlinType type) {
|
||||
List<CallableMemberDescriptor> r = Lists.newArrayList();
|
||||
for (DeclarationDescriptor decl : type.getMemberScope().getAllDescriptors()) {
|
||||
if (decl instanceof PropertyDescriptor || decl instanceof SimpleFunctionDescriptor) {
|
||||
@@ -687,13 +687,13 @@ public class OverrideResolver {
|
||||
TypeSubstitutor typeSubstitutor = prepareTypeSubstitutor(superDescriptor, subDescriptor);
|
||||
if (typeSubstitutor == null) return false;
|
||||
|
||||
KtType superReturnType = superDescriptor.getReturnType();
|
||||
KotlinType superReturnType = superDescriptor.getReturnType();
|
||||
assert superReturnType != null;
|
||||
|
||||
KtType subReturnType = subDescriptor.getReturnType();
|
||||
KotlinType subReturnType = subDescriptor.getReturnType();
|
||||
assert subReturnType != null;
|
||||
|
||||
KtType substitutedSuperReturnType = typeSubstitutor.substitute(superReturnType, Variance.OUT_VARIANCE);
|
||||
KotlinType substitutedSuperReturnType = typeSubstitutor.substitute(superReturnType, Variance.OUT_VARIANCE);
|
||||
assert substitutedSuperReturnType != null;
|
||||
|
||||
return KotlinTypeChecker.DEFAULT.isSubtypeOf(subReturnType, substitutedSuperReturnType);
|
||||
@@ -725,7 +725,7 @@ public class OverrideResolver {
|
||||
|
||||
if (!superDescriptor.isVar()) return true;
|
||||
|
||||
KtType substitutedSuperReturnType = typeSubstitutor.substitute(superDescriptor.getType(), Variance.OUT_VARIANCE);
|
||||
KotlinType substitutedSuperReturnType = typeSubstitutor.substitute(superDescriptor.getType(), Variance.OUT_VARIANCE);
|
||||
assert substitutedSuperReturnType != null;
|
||||
return KotlinTypeChecker.DEFAULT.equalTypes(subDescriptor.getType(), substitutedSuperReturnType);
|
||||
}
|
||||
@@ -792,7 +792,7 @@ public class OverrideResolver {
|
||||
@NotNull CallableMemberDescriptor declared,
|
||||
@NotNull ClassDescriptor declaringClass
|
||||
) {
|
||||
for (KtType supertype : declaringClass.getTypeConstructor().getSupertypes()) {
|
||||
for (KotlinType supertype : declaringClass.getTypeConstructor().getSupertypes()) {
|
||||
Set<CallableMemberDescriptor> all = Sets.newLinkedHashSet();
|
||||
all.addAll(supertype.getMemberScope().getFunctions(declared.getName(), NoLookupLocation.UNSORTED));
|
||||
//noinspection unchecked
|
||||
|
||||
@@ -48,15 +48,15 @@ public class PossiblyBareType {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static PossiblyBareType type(@NotNull KtType actualType) {
|
||||
public static PossiblyBareType type(@NotNull KotlinType actualType) {
|
||||
return new PossiblyBareType(actualType, null, false);
|
||||
}
|
||||
|
||||
private final KtType actualType;
|
||||
private final KotlinType actualType;
|
||||
private final TypeConstructor bareTypeConstructor;
|
||||
private final boolean nullable;
|
||||
|
||||
private PossiblyBareType(@Nullable KtType actualType, @Nullable TypeConstructor bareTypeConstructor, boolean nullable) {
|
||||
private PossiblyBareType(@Nullable KotlinType actualType, @Nullable TypeConstructor bareTypeConstructor, boolean nullable) {
|
||||
this.actualType = actualType;
|
||||
this.bareTypeConstructor = bareTypeConstructor;
|
||||
this.nullable = nullable;
|
||||
@@ -67,7 +67,7 @@ public class PossiblyBareType {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public KtType getActualType() {
|
||||
public KotlinType getActualType() {
|
||||
//noinspection ConstantConditions
|
||||
return actualType;
|
||||
}
|
||||
@@ -95,18 +95,18 @@ public class PossiblyBareType {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public TypeReconstructionResult reconstruct(@NotNull KtType subjectType) {
|
||||
public TypeReconstructionResult reconstruct(@NotNull KotlinType subjectType) {
|
||||
if (!isBare()) return new TypeReconstructionResult(getActualType(), true);
|
||||
|
||||
TypeReconstructionResult reconstructionResult = CastDiagnosticsUtil.findStaticallyKnownSubtype(
|
||||
TypeUtils.makeNotNullable(subjectType),
|
||||
getBareTypeConstructor()
|
||||
);
|
||||
KtType type = reconstructionResult.getResultingType();
|
||||
KotlinType type = reconstructionResult.getResultingType();
|
||||
// No need to make an absent type nullable
|
||||
if (type == null) return reconstructionResult;
|
||||
|
||||
KtType resultingType = TypeUtils.makeNullableAsSpecified(type, isBareTypeNullable());
|
||||
KotlinType resultingType = TypeUtils.makeNullableAsSpecified(type, isBareTypeNullable());
|
||||
return new TypeReconstructionResult(resultingType, reconstructionResult.isAllArgumentsInferred());
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.psi.KtScript;
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
|
||||
import org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil;
|
||||
import org.jetbrains.kotlin.types.ErrorUtils;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.expressions.CoercionStrategy;
|
||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingContext;
|
||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices;
|
||||
@@ -52,7 +52,7 @@ public class ScriptBodyResolver {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public KtType resolveScriptReturnType(
|
||||
public KotlinType resolveScriptReturnType(
|
||||
@NotNull KtScript script,
|
||||
@NotNull ScriptDescriptor scriptDescriptor,
|
||||
@NotNull BindingTrace trace
|
||||
@@ -65,7 +65,7 @@ public class ScriptBodyResolver {
|
||||
NO_EXPECTED_TYPE
|
||||
);
|
||||
PreliminaryDeclarationVisitor.Companion.createForDeclaration(script, trace);
|
||||
KtType returnType = expressionTypingServices.getBlockReturnedType(script.getBlockExpression(), CoercionStrategy.NO_COERCION, context).getType();
|
||||
KotlinType returnType = expressionTypingServices.getBlockReturnedType(script.getBlockExpression(), CoercionStrategy.NO_COERCION, context).getType();
|
||||
if (returnType == null) {
|
||||
returnType = ErrorUtils.createErrorType("getBlockReturnedType returned null");
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.resolve.typeBinding
|
||||
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.psi.KtTypeElement
|
||||
@@ -30,7 +30,7 @@ import org.jetbrains.kotlin.types.TypeProjectionImpl
|
||||
|
||||
interface TypeBinding<out P : PsiElement> {
|
||||
val psiElement: P
|
||||
val jetType: KtType
|
||||
val jetType: KotlinType
|
||||
fun getArgumentBindings(): List<TypeArgumentBinding<P>?>
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ private class TypeArgumentBindingImpl<out P: PsiElement>(
|
||||
private class ExplicitTypeBinding(
|
||||
private val trace: BindingContext,
|
||||
override val psiElement: KtTypeElement,
|
||||
override val jetType: KtType
|
||||
override val jetType: KotlinType
|
||||
) : TypeBinding<KtTypeElement> {
|
||||
|
||||
override fun getArgumentBindings(): List<TypeArgumentBinding<KtTypeElement>?> {
|
||||
@@ -111,7 +111,7 @@ private class ExplicitTypeBinding(
|
||||
private class NoTypeElementBinding<out P : PsiElement>(
|
||||
private val trace: BindingContext,
|
||||
override val psiElement: P,
|
||||
override val jetType: KtType
|
||||
override val jetType: KotlinType
|
||||
): TypeBinding<P> {
|
||||
|
||||
override fun getArgumentBindings(): List<TypeArgumentBinding<P>?> {
|
||||
|
||||
@@ -62,12 +62,12 @@ public class TypeResolver(
|
||||
}
|
||||
}
|
||||
|
||||
public fun resolveType(scope: LexicalScope, typeReference: KtTypeReference, trace: BindingTrace, checkBounds: Boolean): KtType {
|
||||
public fun resolveType(scope: LexicalScope, typeReference: KtTypeReference, trace: BindingTrace, checkBounds: Boolean): KotlinType {
|
||||
// bare types are not allowed
|
||||
return resolveType(TypeResolutionContext(scope, trace, checkBounds, false), typeReference)
|
||||
}
|
||||
|
||||
private fun resolveType(c: TypeResolutionContext, typeReference: KtTypeReference): KtType {
|
||||
private fun resolveType(c: TypeResolutionContext, typeReference: KtTypeReference): KotlinType {
|
||||
assert(!c.allowBareTypes) { "Use resolvePossiblyBareType() when bare types are allowed" }
|
||||
return resolvePossiblyBareType(c, typeReference).getActualType()
|
||||
}
|
||||
@@ -136,7 +136,7 @@ public class TypeResolver(
|
||||
*
|
||||
* todo: find another way after release
|
||||
*/
|
||||
private fun forceResolveTypeContents(type: KtType) {
|
||||
private fun forceResolveTypeContents(type: KotlinType) {
|
||||
type.annotations // force read type annotations
|
||||
if (type.isFlexible()) {
|
||||
forceResolveTypeContents(type.flexibility().lowerBound)
|
||||
@@ -180,7 +180,7 @@ public class TypeResolver(
|
||||
result = if (scopeForTypeParameter is ErrorUtils.ErrorScope)
|
||||
type(ErrorUtils.createErrorType("?"))
|
||||
else
|
||||
type(KtTypeImpl.create(
|
||||
type(KotlinTypeImpl.create(
|
||||
annotations,
|
||||
classifierDescriptor.getTypeConstructor(),
|
||||
TypeUtils.hasNullableLowerBound(classifierDescriptor),
|
||||
@@ -234,7 +234,7 @@ public class TypeResolver(
|
||||
)
|
||||
return
|
||||
}
|
||||
val resultingType = KtTypeImpl.create(annotations, classifierDescriptor, false, arguments)
|
||||
val resultingType = KotlinTypeImpl.create(annotations, classifierDescriptor, false, arguments)
|
||||
result = type(resultingType)
|
||||
if (c.checkBounds) {
|
||||
val substitutor = TypeSubstitutor.create(resultingType)
|
||||
|
||||
@@ -32,7 +32,7 @@ import org.jetbrains.kotlin.resolve.typeBinding.createTypeBindingForReturnType
|
||||
import org.jetbrains.kotlin.psi.KtCallableDeclaration
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
import org.jetbrains.kotlin.resolve.TopDownAnalysisContext
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.psi.KtClass
|
||||
import org.jetbrains.kotlin.psi.KtTypeReference
|
||||
import org.jetbrains.kotlin.types.Variance.*
|
||||
@@ -74,7 +74,7 @@ class VarianceChecker(private val trace: BindingTrace) {
|
||||
}
|
||||
|
||||
class VarianceConflictDiagnosticData(
|
||||
val containingType: KtType,
|
||||
val containingType: KotlinType,
|
||||
val typeParameter: TypeParameterDescriptor,
|
||||
val occurrencePosition: Variance
|
||||
)
|
||||
@@ -158,7 +158,7 @@ class VarianceChecker(private val trace: BindingTrace) {
|
||||
private fun TypeBinding<PsiElement>.checkTypePosition(position: Variance, diagnosticSink: DiagnosticSink)
|
||||
= checkTypePosition(jetType, position, diagnosticSink)
|
||||
|
||||
private fun TypeBinding<PsiElement>.checkTypePosition(containingType: KtType, position: Variance, diagnosticSink: DiagnosticSink): Boolean {
|
||||
private fun TypeBinding<PsiElement>.checkTypePosition(containingType: KotlinType, position: Variance, diagnosticSink: DiagnosticSink): Boolean {
|
||||
val classifierDescriptor = jetType.getConstructor().getDeclarationDescriptor()
|
||||
if (classifierDescriptor is TypeParameterDescriptor) {
|
||||
val declarationVariance = classifierDescriptor.getVariance()
|
||||
|
||||
+17
-17
@@ -46,7 +46,7 @@ import org.jetbrains.kotlin.resolve.scopes.receivers.TransientReceiver
|
||||
import org.jetbrains.kotlin.resolve.scopes.utils.memberScopeAsFileScope
|
||||
import org.jetbrains.kotlin.resolve.source.toSourceElement
|
||||
import org.jetbrains.kotlin.types.FunctionPlaceholders
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils
|
||||
import org.jetbrains.kotlin.utils.ThrowingList
|
||||
@@ -55,7 +55,7 @@ public fun resolveCallableReferenceReceiverType(
|
||||
callableReferenceExpression: KtCallableReferenceExpression,
|
||||
context: ResolutionContext<*>,
|
||||
typeResolver: TypeResolver
|
||||
): KtType? =
|
||||
): KotlinType? =
|
||||
callableReferenceExpression.typeReference?.let {
|
||||
typeResolver.resolveType(context.scope, it, context.trace, false)
|
||||
}
|
||||
@@ -93,7 +93,7 @@ private fun OverloadResolutionResults<*>.isSomething(): Boolean = !isNothing()
|
||||
|
||||
public fun resolvePossiblyAmbiguousCallableReference(
|
||||
callableReferenceExpression: KtCallableReferenceExpression,
|
||||
lhsType: KtType?,
|
||||
lhsType: KotlinType?,
|
||||
context: ResolutionContext<*>,
|
||||
resolutionMode: ResolveArgumentsMode,
|
||||
callResolver: CallResolver
|
||||
@@ -142,7 +142,7 @@ public fun resolvePossiblyAmbiguousCallableReference(
|
||||
|
||||
public fun resolveCallableReferenceTarget(
|
||||
callableReferenceExpression: KtCallableReferenceExpression,
|
||||
lhsType: KtType?,
|
||||
lhsType: KotlinType?,
|
||||
context: ResolutionContext<*>,
|
||||
resolvedToSomething: BooleanArray,
|
||||
callResolver: CallResolver
|
||||
@@ -164,9 +164,9 @@ public fun resolveCallableReferenceTarget(
|
||||
|
||||
private fun createReflectionTypeForFunction(
|
||||
descriptor: FunctionDescriptor,
|
||||
receiverType: KtType?,
|
||||
receiverType: KotlinType?,
|
||||
reflectionTypes: ReflectionTypes
|
||||
): KtType? {
|
||||
): KotlinType? {
|
||||
val returnType = descriptor.getReturnType() ?: return null
|
||||
val valueParametersTypes = ExpressionTypingUtils.getValueParametersTypes(descriptor.getValueParameters())
|
||||
return reflectionTypes.getKFunctionType(Annotations.EMPTY, receiverType, valueParametersTypes, returnType)
|
||||
@@ -174,13 +174,13 @@ private fun createReflectionTypeForFunction(
|
||||
|
||||
private fun createReflectionTypeForProperty(
|
||||
descriptor: PropertyDescriptor,
|
||||
receiverType: KtType?,
|
||||
receiverType: KotlinType?,
|
||||
reflectionTypes: ReflectionTypes
|
||||
): KtType {
|
||||
): KotlinType {
|
||||
return reflectionTypes.getKPropertyType(Annotations.EMPTY, receiverType, descriptor.getType(), descriptor.isVar())
|
||||
}
|
||||
|
||||
private fun bindFunctionReference(expression: KtCallableReferenceExpression, referenceType: KtType, context: ResolutionContext<*>) {
|
||||
private fun bindFunctionReference(expression: KtCallableReferenceExpression, referenceType: KotlinType, context: ResolutionContext<*>) {
|
||||
val functionDescriptor = AnonymousFunctionDescriptor(
|
||||
context.scope.ownerDescriptor,
|
||||
Annotations.EMPTY,
|
||||
@@ -192,7 +192,7 @@ private fun bindFunctionReference(expression: KtCallableReferenceExpression, ref
|
||||
context.trace.record(BindingContext.FUNCTION, expression, functionDescriptor)
|
||||
}
|
||||
|
||||
private fun bindPropertyReference(expression: KtCallableReferenceExpression, referenceType: KtType, context: ResolutionContext<*>) {
|
||||
private fun bindPropertyReference(expression: KtCallableReferenceExpression, referenceType: KotlinType, context: ResolutionContext<*>) {
|
||||
val localVariable = LocalVariableDescriptor(context.scope.ownerDescriptor, Annotations.EMPTY, Name.special("<anonymous>"),
|
||||
referenceType, /* mutable = */ false, expression.toSourceElement())
|
||||
|
||||
@@ -201,11 +201,11 @@ private fun bindPropertyReference(expression: KtCallableReferenceExpression, ref
|
||||
|
||||
private fun createReflectionTypeForCallableDescriptor(
|
||||
descriptor: CallableDescriptor,
|
||||
lhsType: KtType?,
|
||||
lhsType: KotlinType?,
|
||||
reflectionTypes: ReflectionTypes,
|
||||
trace: BindingTrace?,
|
||||
reportOn: KtExpression?
|
||||
): KtType? {
|
||||
): KotlinType? {
|
||||
val extensionReceiver = descriptor.extensionReceiverParameter
|
||||
val dispatchReceiver = descriptor.dispatchReceiverParameter?.let { dispatchReceiver ->
|
||||
// See CallableDescriptor#getOwnerForEffectiveDispatchReceiverParameter
|
||||
@@ -245,16 +245,16 @@ private fun createReflectionTypeForCallableDescriptor(
|
||||
public fun getReflectionTypeForCandidateDescriptor(
|
||||
descriptor: CallableDescriptor,
|
||||
reflectionTypes: ReflectionTypes
|
||||
): KtType? =
|
||||
): KotlinType? =
|
||||
createReflectionTypeForCallableDescriptor(descriptor, null, reflectionTypes, null, null)
|
||||
|
||||
public fun createReflectionTypeForResolvedCallableReference(
|
||||
reference: KtCallableReferenceExpression,
|
||||
lhsType: KtType?,
|
||||
lhsType: KotlinType?,
|
||||
descriptor: CallableDescriptor,
|
||||
context: ResolutionContext<*>,
|
||||
reflectionTypes: ReflectionTypes
|
||||
): KtType? {
|
||||
): KotlinType? {
|
||||
val type = createReflectionTypeForCallableDescriptor(
|
||||
descriptor, lhsType, reflectionTypes, context.trace, reference.getCallableReference()
|
||||
) ?: return null
|
||||
@@ -271,14 +271,14 @@ public fun createReflectionTypeForResolvedCallableReference(
|
||||
|
||||
public fun getResolvedCallableReferenceShapeType(
|
||||
reference: KtCallableReferenceExpression,
|
||||
lhsType: KtType?,
|
||||
lhsType: KotlinType?,
|
||||
overloadResolutionResults: OverloadResolutionResults<CallableDescriptor>?,
|
||||
context: ResolutionContext<*>,
|
||||
expectedTypeUnknown: Boolean,
|
||||
reflectionTypes: ReflectionTypes,
|
||||
builtIns: KotlinBuiltIns,
|
||||
functionPlaceholders: FunctionPlaceholders
|
||||
): KtType? =
|
||||
): KotlinType? =
|
||||
when {
|
||||
overloadResolutionResults == null ->
|
||||
null
|
||||
|
||||
+19
-19
@@ -47,7 +47,7 @@ import org.jetbrains.kotlin.resolve.scopes.receivers.QualifierReceiver;
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
|
||||
import org.jetbrains.kotlin.types.FunctionPlaceholders;
|
||||
import org.jetbrains.kotlin.types.FunctionPlaceholdersKt;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.TypeUtils;
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
|
||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices;
|
||||
@@ -94,11 +94,11 @@ public class ArgumentTypeResolver {
|
||||
}
|
||||
|
||||
public static boolean isSubtypeOfForArgumentType(
|
||||
@NotNull KtType actualType,
|
||||
@NotNull KtType expectedType
|
||||
@NotNull KotlinType actualType,
|
||||
@NotNull KotlinType expectedType
|
||||
) {
|
||||
if (FunctionPlaceholdersKt.isFunctionPlaceholder(actualType)) {
|
||||
KtType functionType = ConstraintSystemImplKt.createTypeForFunctionPlaceholder(actualType, expectedType);
|
||||
KotlinType functionType = ConstraintSystemImplKt.createTypeForFunctionPlaceholder(actualType, expectedType);
|
||||
return KotlinTypeChecker.DEFAULT.isSubtypeOf(functionType, expectedType);
|
||||
}
|
||||
return KotlinTypeChecker.DEFAULT.isSubtypeOf(actualType, expectedType);
|
||||
@@ -231,19 +231,19 @@ public class ArgumentTypeResolver {
|
||||
@NotNull ResolveArgumentsMode resolveArgumentsMode
|
||||
) {
|
||||
if (resolveArgumentsMode == SHAPE_FUNCTION_ARGUMENTS) {
|
||||
KtType type = getShapeTypeOfCallableReference(callableReferenceExpression, context, true);
|
||||
KotlinType type = getShapeTypeOfCallableReference(callableReferenceExpression, context, true);
|
||||
return TypeInfoFactoryKt.createTypeInfo(type);
|
||||
}
|
||||
return expressionTypingServices.getTypeInfo(expression, context.replaceContextDependency(INDEPENDENT));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public KtType getShapeTypeOfCallableReference(
|
||||
public KotlinType getShapeTypeOfCallableReference(
|
||||
@NotNull KtCallableReferenceExpression callableReferenceExpression,
|
||||
@NotNull CallResolutionContext<?> context,
|
||||
boolean expectedTypeIsUnknown
|
||||
) {
|
||||
KtType receiverType =
|
||||
KotlinType receiverType =
|
||||
CallableReferencesResolutionUtilsKt.resolveCallableReferenceReceiverType(callableReferenceExpression, context, typeResolver);
|
||||
OverloadResolutionResults<CallableDescriptor> overloadResolutionResults =
|
||||
CallableReferencesResolutionUtilsKt.resolvePossiblyAmbiguousCallableReference(
|
||||
@@ -262,14 +262,14 @@ public class ArgumentTypeResolver {
|
||||
@NotNull ResolveArgumentsMode resolveArgumentsMode
|
||||
) {
|
||||
if (resolveArgumentsMode == SHAPE_FUNCTION_ARGUMENTS) {
|
||||
KtType type = getShapeTypeOfFunctionLiteral(functionLiteral, context.scope, context.trace, true);
|
||||
KotlinType type = getShapeTypeOfFunctionLiteral(functionLiteral, context.scope, context.trace, true);
|
||||
return TypeInfoFactoryKt.createTypeInfo(type, context);
|
||||
}
|
||||
return expressionTypingServices.getTypeInfo(expression, context.replaceContextDependency(INDEPENDENT));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public KtType getShapeTypeOfFunctionLiteral(
|
||||
public KotlinType getShapeTypeOfFunctionLiteral(
|
||||
@NotNull KtFunction function,
|
||||
@NotNull LexicalScope scope,
|
||||
@NotNull BindingTrace trace,
|
||||
@@ -279,19 +279,19 @@ public class ArgumentTypeResolver {
|
||||
if (function.getValueParameterList() == null && isFunctionLiteral) {
|
||||
return expectedTypeIsUnknown
|
||||
? functionPlaceholders
|
||||
.createFunctionPlaceholderType(Collections.<KtType>emptyList(), /* hasDeclaredArguments = */ false)
|
||||
: builtIns.getFunctionType(Annotations.Companion.getEMPTY(), null, Collections.<KtType>emptyList(), DONT_CARE);
|
||||
.createFunctionPlaceholderType(Collections.<KotlinType>emptyList(), /* hasDeclaredArguments = */ false)
|
||||
: builtIns.getFunctionType(Annotations.Companion.getEMPTY(), null, Collections.<KotlinType>emptyList(), DONT_CARE);
|
||||
}
|
||||
List<KtParameter> valueParameters = function.getValueParameters();
|
||||
TemporaryBindingTrace temporaryTrace = TemporaryBindingTrace.create(
|
||||
trace, "trace to resolve function literal parameter types");
|
||||
List<KtType> parameterTypes = Lists.newArrayList();
|
||||
List<KotlinType> parameterTypes = Lists.newArrayList();
|
||||
for (KtParameter parameter : valueParameters) {
|
||||
parameterTypes.add(resolveTypeRefWithDefault(parameter.getTypeReference(), scope, temporaryTrace, DONT_CARE));
|
||||
}
|
||||
KtType returnType = resolveTypeRefWithDefault(function.getTypeReference(), scope, temporaryTrace, DONT_CARE);
|
||||
KotlinType returnType = resolveTypeRefWithDefault(function.getTypeReference(), scope, temporaryTrace, DONT_CARE);
|
||||
assert returnType != null;
|
||||
KtType receiverType = resolveTypeRefWithDefault(function.getReceiverTypeReference(), scope, temporaryTrace, null);
|
||||
KotlinType receiverType = resolveTypeRefWithDefault(function.getReceiverTypeReference(), scope, temporaryTrace, null);
|
||||
|
||||
return expectedTypeIsUnknown && isFunctionLiteral
|
||||
? functionPlaceholders.createFunctionPlaceholderType(parameterTypes, /* hasDeclaredArguments = */ true)
|
||||
@@ -299,11 +299,11 @@ public class ArgumentTypeResolver {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public KtType resolveTypeRefWithDefault(
|
||||
public KotlinType resolveTypeRefWithDefault(
|
||||
@Nullable KtTypeReference returnTypeRef,
|
||||
@NotNull LexicalScope scope,
|
||||
@NotNull BindingTrace trace,
|
||||
@Nullable KtType defaultValue
|
||||
@Nullable KotlinType defaultValue
|
||||
) {
|
||||
if (returnTypeRef != null) {
|
||||
return typeResolver.resolveType(scope, returnTypeRef, trace, true);
|
||||
@@ -347,15 +347,15 @@ public class ArgumentTypeResolver {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public KtType updateResultArgumentTypeIfNotDenotable(
|
||||
public KotlinType updateResultArgumentTypeIfNotDenotable(
|
||||
@NotNull ResolutionContext context,
|
||||
@NotNull KtExpression expression
|
||||
) {
|
||||
KtType type = context.trace.getType(expression);
|
||||
KotlinType type = context.trace.getType(expression);
|
||||
if (type != null && !type.getConstructor().isDenotable()) {
|
||||
if (type.getConstructor() instanceof IntegerValueTypeConstructor) {
|
||||
IntegerValueTypeConstructor constructor = (IntegerValueTypeConstructor) type.getConstructor();
|
||||
KtType primitiveType = TypeUtils.getPrimitiveNumberType(constructor, context.expectedType);
|
||||
KotlinType primitiveType = TypeUtils.getPrimitiveNumberType(constructor, context.expectedType);
|
||||
constantExpressionEvaluator.updateNumberType(primitiveType, expression, context.statementFilter, context.trace);
|
||||
return primitiveType;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo
|
||||
import org.jetbrains.kotlin.resolve.calls.tasks.TracingStrategy
|
||||
import org.jetbrains.kotlin.resolve.validation.SymbolUsageValidator
|
||||
import org.jetbrains.kotlin.types.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
import org.jetbrains.kotlin.types.expressions.DataFlowAnalyzer
|
||||
import java.util.*
|
||||
@@ -136,7 +136,7 @@ public class CallCompleter(
|
||||
}
|
||||
|
||||
private fun <D : CallableDescriptor> MutableResolvedCall<D>.completeConstraintSystem(
|
||||
expectedType: KtType,
|
||||
expectedType: KotlinType,
|
||||
trace: BindingTrace
|
||||
) {
|
||||
fun updateSystemIfSuccessful(update: (ConstraintSystemImpl) -> Boolean) {
|
||||
@@ -240,7 +240,7 @@ public class CallCompleter(
|
||||
val deparenthesized = KtPsiUtil.getLastElementDeparenthesized(expression, context.statementFilter) ?: return
|
||||
|
||||
val recordedType = expression.let { context.trace.getType(it) }
|
||||
var updatedType: KtType? = recordedType
|
||||
var updatedType: KotlinType? = recordedType
|
||||
|
||||
val results = completeCallForArgument(deparenthesized, context)
|
||||
if (results != null && results.isSingleResult()) {
|
||||
@@ -288,11 +288,11 @@ public class CallCompleter(
|
||||
}
|
||||
|
||||
private fun updateRecordedTypeForArgument(
|
||||
updatedType: KtType?,
|
||||
recordedType: KtType?,
|
||||
updatedType: KotlinType?,
|
||||
recordedType: KotlinType?,
|
||||
argumentExpression: KtExpression,
|
||||
trace: BindingTrace
|
||||
): KtType? {
|
||||
): KotlinType? {
|
||||
//workaround for KT-8218
|
||||
if ((!ErrorUtils.containsErrorType(recordedType) && recordedType == updatedType) || updatedType == null) return updatedType
|
||||
|
||||
|
||||
+8
-8
@@ -43,7 +43,7 @@ import org.jetbrains.kotlin.resolve.constants.evaluate.ConstantExpressionEvaluat
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.*;
|
||||
import org.jetbrains.kotlin.resolve.validation.SymbolUsageValidator;
|
||||
import org.jetbrains.kotlin.types.ErrorUtils;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.TypeUtils;
|
||||
import org.jetbrains.kotlin.types.expressions.DataFlowAnalyzer;
|
||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingContext;
|
||||
@@ -103,7 +103,7 @@ public class CallExpressionResolver {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private KtType getVariableType(
|
||||
private KotlinType getVariableType(
|
||||
@NotNull KtSimpleNameExpression nameExpression, @NotNull ReceiverValue receiver,
|
||||
@Nullable ASTNode callOperationNode, @NotNull ExpressionTypingContext context, @NotNull boolean[] result
|
||||
) {
|
||||
@@ -149,7 +149,7 @@ public class CallExpressionResolver {
|
||||
|
||||
TemporaryTraceAndCache temporaryForVariable = TemporaryTraceAndCache.create(
|
||||
context, "trace to resolve as variable", nameExpression);
|
||||
KtType type =
|
||||
KotlinType type =
|
||||
getVariableType(nameExpression, receiver, callOperationNode, context.replaceTraceAndCache(temporaryForVariable), result);
|
||||
// TODO: for a safe call, it's necessary to set receiver != null here, as inside ArgumentTypeResolver.analyzeArgumentsAndRecordTypes
|
||||
// Unfortunately it provokes problems with x?.y!!.foo() with the following x!!.bar():
|
||||
@@ -236,7 +236,7 @@ public class CallExpressionResolver {
|
||||
}
|
||||
}
|
||||
|
||||
KtType type = functionDescriptor.getReturnType();
|
||||
KotlinType type = functionDescriptor.getReturnType();
|
||||
// Extracting jump out possible and jump point flow info from arguments, if any
|
||||
List<? extends ValueArgument> arguments = callExpression.getValueArguments();
|
||||
DataFlowInfo resultFlowInfo = resolvedCall.getDataFlowInfoForArguments().getResultInfo();
|
||||
@@ -257,8 +257,8 @@ public class CallExpressionResolver {
|
||||
if (calleeExpression instanceof KtSimpleNameExpression && callExpression.getTypeArgumentList() == null) {
|
||||
TemporaryTraceAndCache temporaryForVariable = TemporaryTraceAndCache.create(
|
||||
context, "trace to resolve as variable with 'invoke' call", callExpression);
|
||||
KtType type = getVariableType((KtSimpleNameExpression) calleeExpression, receiver, callOperationNode,
|
||||
context.replaceTraceAndCache(temporaryForVariable), result);
|
||||
KotlinType type = getVariableType((KtSimpleNameExpression) calleeExpression, receiver, callOperationNode,
|
||||
context.replaceTraceAndCache(temporaryForVariable), result);
|
||||
Qualifier qualifier = temporaryForVariable.trace.get(BindingContext.QUALIFIER, calleeExpression);
|
||||
if (result[0] && (qualifier == null || qualifier.getPackageView() == null)) {
|
||||
temporaryForVariable.commit();
|
||||
@@ -350,7 +350,7 @@ public class CallExpressionResolver {
|
||||
replaceInsideCallChain(true); // Enter call chain
|
||||
// Visit receiver (x in x.y or x?.z) here. Recursion is possible.
|
||||
JetTypeInfo receiverTypeInfo = expressionTypingServices.getTypeInfo(receiverExpression, contextForReceiver);
|
||||
KtType receiverType = receiverTypeInfo.getType();
|
||||
KotlinType receiverType = receiverTypeInfo.getType();
|
||||
QualifierReceiver qualifierReceiver = (QualifierReceiver) context.trace.get(BindingContext.QUALIFIER, receiverExpression);
|
||||
|
||||
if (receiverType == null) receiverType = ErrorUtils.createErrorType("Type for " + expression.getText());
|
||||
@@ -363,7 +363,7 @@ public class CallExpressionResolver {
|
||||
// Visit selector (y in x.y) here. Recursion is also possible.
|
||||
JetTypeInfo selectorReturnTypeInfo = getSelectorReturnTypeInfo(
|
||||
receiver, expression.getOperationTokenNode(), selectorExpression, context);
|
||||
KtType selectorReturnType = selectorReturnTypeInfo.getType();
|
||||
KotlinType selectorReturnType = selectorReturnTypeInfo.getType();
|
||||
|
||||
resolveDeferredReceiverInQualifiedExpression(qualifierReceiver, expression, context);
|
||||
checkNestedClassAccess(expression, context);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user