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.callUtil.CallUtilKt;
|
||||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt;
|
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.TypeUtils;
|
||||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
|
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
|
||||||
|
|
||||||
@@ -141,7 +141,7 @@ public class CodegenUtil {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static ClassDescriptor getSuperClassByDelegationSpecifier(@NotNull KtDelegationSpecifier specifier, @NotNull BindingContext bindingContext) {
|
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();
|
assert superType != null : "superType should not be null: " + specifier.getText();
|
||||||
|
|
||||||
ClassDescriptor superClassDescriptor = (ClassDescriptor) superType.getConstructor().getDeclarationDescriptor();
|
ClassDescriptor superClassDescriptor = (ClassDescriptor) superType.getConstructor().getDeclarationDescriptor();
|
||||||
@@ -164,13 +164,13 @@ public class CodegenUtil {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean rawTypeMatches(KtType type, ClassifierDescriptor classifier) {
|
private static boolean rawTypeMatches(KotlinType type, ClassifierDescriptor classifier) {
|
||||||
return type.getConstructor().equals(classifier.getTypeConstructor());
|
return type.getConstructor().equals(classifier.getTypeConstructor());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isEnumValueOfMethod(@NotNull FunctionDescriptor functionDescriptor) {
|
public static boolean isEnumValueOfMethod(@NotNull FunctionDescriptor functionDescriptor) {
|
||||||
List<ValueParameterDescriptor> methodTypeParameters = functionDescriptor.getValueParameters();
|
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())
|
return DescriptorUtils.ENUM_VALUE_OF.equals(functionDescriptor.getName())
|
||||||
&& methodTypeParameters.size() == 1
|
&& methodTypeParameters.size() == 1
|
||||||
&& KotlinTypeChecker.DEFAULT.isSubtypeOf(methodTypeParameters.get(0).getType(), nullableString);
|
&& 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.incremental.components.NoLookupLocation
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||||
import org.jetbrains.kotlin.resolve.MemberComparator
|
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.types.isDynamic
|
||||||
import org.jetbrains.kotlin.utils.keysToMapExceptNulls
|
import org.jetbrains.kotlin.utils.keysToMapExceptNulls
|
||||||
import java.util.Comparator
|
import java.util.Comparator
|
||||||
@@ -38,7 +38,7 @@ public object CodegenUtilKt {
|
|||||||
public fun getDelegates(
|
public fun getDelegates(
|
||||||
descriptor: ClassDescriptor,
|
descriptor: ClassDescriptor,
|
||||||
toTrait: ClassDescriptor,
|
toTrait: ClassDescriptor,
|
||||||
delegateExpressionType: KtType? = null
|
delegateExpressionType: KotlinType? = null
|
||||||
): Map<CallableMemberDescriptor, CallableDescriptor> {
|
): Map<CallableMemberDescriptor, CallableDescriptor> {
|
||||||
if (delegateExpressionType?.isDynamic() ?: false) return mapOf();
|
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.name.Name
|
||||||
import org.jetbrains.kotlin.psi.KtSuperExpression
|
import org.jetbrains.kotlin.psi.KtSuperExpression
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||||
import org.jetbrains.kotlin.types.KtType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
|
|
||||||
public class AccessorForConstructorDescriptor(
|
public class AccessorForConstructorDescriptor(
|
||||||
private val calleeDescriptor: ConstructorDescriptor,
|
private val calleeDescriptor: ConstructorDescriptor,
|
||||||
@@ -35,7 +35,7 @@ public class AccessorForConstructorDescriptor(
|
|||||||
|
|
||||||
override fun isPrimary(): Boolean = false
|
override fun isPrimary(): Boolean = false
|
||||||
|
|
||||||
override fun getReturnType(): KtType = super.getReturnType()!!
|
override fun getReturnType(): KotlinType = super.getReturnType()!!
|
||||||
|
|
||||||
override fun getSuperCallExpression(): KtSuperExpression? = superCallExpression
|
override fun getSuperCallExpression(): KtSuperExpression? = superCallExpression
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -20,13 +20,13 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
|
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
|
||||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor;
|
import org.jetbrains.kotlin.descriptors.PropertyDescriptor;
|
||||||
import org.jetbrains.kotlin.types.KtType;
|
import org.jetbrains.kotlin.types.KotlinType;
|
||||||
|
|
||||||
public class AccessorForPropertyBackingFieldInOuterClass extends AccessorForPropertyDescriptor {
|
public class AccessorForPropertyBackingFieldInOuterClass extends AccessorForPropertyDescriptor {
|
||||||
public AccessorForPropertyBackingFieldInOuterClass(
|
public AccessorForPropertyBackingFieldInOuterClass(
|
||||||
@NotNull PropertyDescriptor property,
|
@NotNull PropertyDescriptor property,
|
||||||
@NotNull DeclarationDescriptor containingDeclaration,
|
@NotNull DeclarationDescriptor containingDeclaration,
|
||||||
@Nullable KtType delegationType,
|
@Nullable KotlinType delegationType,
|
||||||
@NotNull String nameSuffix
|
@NotNull String nameSuffix
|
||||||
) {
|
) {
|
||||||
super(property, delegationType != null ? delegationType : property.getType(), null, null, containingDeclaration, null, 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.name.Name;
|
||||||
import org.jetbrains.kotlin.psi.KtSuperExpression;
|
import org.jetbrains.kotlin.psi.KtSuperExpression;
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
||||||
import org.jetbrains.kotlin.types.KtType;
|
import org.jetbrains.kotlin.types.KotlinType;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
@@ -48,8 +48,8 @@ public class AccessorForPropertyDescriptor extends PropertyDescriptorImpl implem
|
|||||||
|
|
||||||
protected AccessorForPropertyDescriptor(
|
protected AccessorForPropertyDescriptor(
|
||||||
@NotNull PropertyDescriptor original,
|
@NotNull PropertyDescriptor original,
|
||||||
@NotNull KtType propertyType,
|
@NotNull KotlinType propertyType,
|
||||||
@Nullable KtType receiverType,
|
@Nullable KotlinType receiverType,
|
||||||
@Nullable ReceiverParameterDescriptor dispatchReceiverParameter,
|
@Nullable ReceiverParameterDescriptor dispatchReceiverParameter,
|
||||||
@NotNull DeclarationDescriptor containingDeclaration,
|
@NotNull DeclarationDescriptor containingDeclaration,
|
||||||
@Nullable KtSuperExpression superCallExpression,
|
@Nullable KtSuperExpression superCallExpression,
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ public abstract class AnnotationCodegen {
|
|||||||
return false;
|
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 (type == null) return;
|
||||||
|
|
||||||
if (isBareTypeParameterWithNullableUpperBound(type)) {
|
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();
|
ClassifierDescriptor classifier = type.getConstructor().getDeclarationDescriptor();
|
||||||
return !type.isMarkedNullable() && classifier instanceof TypeParameterDescriptor && TypeUtils.hasNullableSuperType(type);
|
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
|
AnnotationVisitor visitor = visitAnnotation(null, false); // Parameters are unimportant
|
||||||
genCompileTimeValue(null, value, visitor);
|
genCompileTimeValue(null, value, visitor);
|
||||||
visitor.visitEnd();
|
visitor.visitEnd();
|
||||||
@@ -418,7 +418,7 @@ public abstract class AnnotationCodegen {
|
|||||||
for (ConstantValue<?> value : values) {
|
for (ConstantValue<?> value : values) {
|
||||||
if (value instanceof EnumValue) {
|
if (value instanceof EnumValue) {
|
||||||
ClassDescriptor enumEntry = ((EnumValue) value).getValue();
|
ClassDescriptor enumEntry = ((EnumValue) value).getValue();
|
||||||
KtType classObjectType = DescriptorUtilsKt.getClassObjectType(enumEntry);
|
KotlinType classObjectType = DescriptorUtilsKt.getClassObjectType(enumEntry);
|
||||||
if (classObjectType != null) {
|
if (classObjectType != null) {
|
||||||
if ("java/lang/annotation/ElementType".equals(typeMapper.mapType(classObjectType).getInternalName())) {
|
if ("java/lang/annotation/ElementType".equals(typeMapper.mapType(classObjectType).getInternalName())) {
|
||||||
result.add(ElementType.valueOf(enumEntry.getName().asString()));
|
result.add(ElementType.valueOf(enumEntry.getName().asString()));
|
||||||
@@ -446,7 +446,7 @@ public abstract class AnnotationCodegen {
|
|||||||
ConstantValue<?> compileTimeConstant = valueArguments.iterator().next();
|
ConstantValue<?> compileTimeConstant = valueArguments.iterator().next();
|
||||||
if (compileTimeConstant instanceof EnumValue) {
|
if (compileTimeConstant instanceof EnumValue) {
|
||||||
ClassDescriptor enumEntry = ((EnumValue) compileTimeConstant).getValue();
|
ClassDescriptor enumEntry = ((EnumValue) compileTimeConstant).getValue();
|
||||||
KtType classObjectType = DescriptorUtilsKt.getClassObjectType(enumEntry);
|
KotlinType classObjectType = DescriptorUtilsKt.getClassObjectType(enumEntry);
|
||||||
if (classObjectType != null) {
|
if (classObjectType != null) {
|
||||||
if ("java/lang/annotation/RetentionPolicy".equals(typeMapper.mapType(classObjectType).getInternalName())) {
|
if ("java/lang/annotation/RetentionPolicy".equals(typeMapper.mapType(classObjectType).getInternalName())) {
|
||||||
return RetentionPolicy.valueOf(enumEntry.getName().asString());
|
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.serialization.jvm.BitEncoding;
|
||||||
import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor;
|
import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor;
|
||||||
import org.jetbrains.kotlin.types.FlexibleTypesKt;
|
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.*;
|
||||||
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
|
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
|
||||||
import org.jetbrains.org.objectweb.asm.commons.Method;
|
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)));
|
allFields.add(Pair.create(CAPTURED_THIS_FIELD, typeMapper.mapType(captureThis)));
|
||||||
}
|
}
|
||||||
|
|
||||||
KtType captureReceiverType = closure.getCaptureReceiverType();
|
KotlinType captureReceiverType = closure.getCaptureReceiverType();
|
||||||
if (captureReceiverType != null) {
|
if (captureReceiverType != null) {
|
||||||
allFields.add(Pair.create(CAPTURED_RECEIVER_FIELD, typeMapper.mapType(captureReceiverType)));
|
allFields.add(Pair.create(CAPTURED_RECEIVER_FIELD, typeMapper.mapType(captureReceiverType)));
|
||||||
}
|
}
|
||||||
@@ -638,7 +638,7 @@ public class AsmUtil {
|
|||||||
@NotNull CallableDescriptor parameter,
|
@NotNull CallableDescriptor parameter,
|
||||||
@NotNull String name
|
@NotNull String name
|
||||||
) {
|
) {
|
||||||
KtType type = parameter.getReturnType();
|
KotlinType type = parameter.getReturnType();
|
||||||
if (type == null || isNullableType(type)) return;
|
if (type == null || isNullableType(type)) return;
|
||||||
|
|
||||||
int index = frameMap.getIndex(parameter);
|
int index = frameMap.getIndex(parameter);
|
||||||
@@ -672,7 +672,7 @@ public class AsmUtil {
|
|||||||
|
|
||||||
if (!isDeclaredInJava(descriptor)) return false;
|
if (!isDeclaredInJava(descriptor)) return false;
|
||||||
|
|
||||||
KtType type = descriptor.getReturnType();
|
KotlinType type = descriptor.getReturnType();
|
||||||
if (type == null || isNullableType(FlexibleTypesKt.lowerIfFlexible(type))) return false;
|
if (type == null || isNullableType(FlexibleTypesKt.lowerIfFlexible(type))) return false;
|
||||||
|
|
||||||
Type asmType = state.getTypeMapper().mapReturnType(descriptor);
|
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.resolve.scopes.KtScope;
|
||||||
import org.jetbrains.kotlin.serialization.DescriptorSerializer;
|
import org.jetbrains.kotlin.serialization.DescriptorSerializer;
|
||||||
import org.jetbrains.kotlin.serialization.ProtoBuf;
|
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.util.OperatorNameConventions;
|
||||||
import org.jetbrains.kotlin.utils.FunctionsKt;
|
import org.jetbrains.kotlin.utils.FunctionsKt;
|
||||||
import org.jetbrains.org.objectweb.asm.AnnotationVisitor;
|
import org.jetbrains.org.objectweb.asm.AnnotationVisitor;
|
||||||
@@ -70,8 +70,8 @@ public class ClosureCodegen extends MemberCodegen<KtElement> {
|
|||||||
private final FunctionDescriptor funDescriptor;
|
private final FunctionDescriptor funDescriptor;
|
||||||
private final ClassDescriptor classDescriptor;
|
private final ClassDescriptor classDescriptor;
|
||||||
private final SamType samType;
|
private final SamType samType;
|
||||||
private final KtType superClassType;
|
private final KotlinType superClassType;
|
||||||
private final List<KtType> superInterfaceTypes;
|
private final List<KotlinType> superInterfaceTypes;
|
||||||
private final FunctionDescriptor functionReferenceTarget;
|
private final FunctionDescriptor functionReferenceTarget;
|
||||||
private final FunctionGenerationStrategy strategy;
|
private final FunctionGenerationStrategy strategy;
|
||||||
private final CalculatedClosure closure;
|
private final CalculatedClosure closure;
|
||||||
@@ -100,10 +100,10 @@ public class ClosureCodegen extends MemberCodegen<KtElement> {
|
|||||||
this.strategy = strategy;
|
this.strategy = strategy;
|
||||||
|
|
||||||
if (samType == null) {
|
if (samType == null) {
|
||||||
this.superInterfaceTypes = new ArrayList<KtType>();
|
this.superInterfaceTypes = new ArrayList<KotlinType>();
|
||||||
|
|
||||||
KtType superClassType = null;
|
KotlinType superClassType = null;
|
||||||
for (KtType supertype : classDescriptor.getTypeConstructor().getSupertypes()) {
|
for (KotlinType supertype : classDescriptor.getTypeConstructor().getSupertypes()) {
|
||||||
ClassifierDescriptor classifier = supertype.getConstructor().getDeclarationDescriptor();
|
ClassifierDescriptor classifier = supertype.getConstructor().getDeclarationDescriptor();
|
||||||
if (DescriptorUtils.isInterface(classifier)) {
|
if (DescriptorUtils.isInterface(classifier)) {
|
||||||
superInterfaceTypes.add(supertype);
|
superInterfaceTypes.add(supertype);
|
||||||
@@ -141,7 +141,7 @@ public class ClosureCodegen extends MemberCodegen<KtElement> {
|
|||||||
sw.writeSuperclassEnd();
|
sw.writeSuperclassEnd();
|
||||||
String[] superInterfaceAsmTypes = new String[superInterfaceTypes.size()];
|
String[] superInterfaceAsmTypes = new String[superInterfaceTypes.size()];
|
||||||
for (int i = 0; i < superInterfaceTypes.size(); i++) {
|
for (int i = 0; i < superInterfaceTypes.size(); i++) {
|
||||||
KtType superInterfaceType = superInterfaceTypes.get(i);
|
KotlinType superInterfaceType = superInterfaceTypes.get(i);
|
||||||
sw.writeInterface();
|
sw.writeInterface();
|
||||||
superInterfaceAsmTypes[i] = typeMapper.mapSupertype(superInterfaceType, sw).getInternalName();
|
superInterfaceAsmTypes[i] = typeMapper.mapSupertype(superInterfaceType, sw).getInternalName();
|
||||||
sw.writeInterfaceEnd();
|
sw.writeInterfaceEnd();
|
||||||
@@ -428,7 +428,7 @@ public class ClosureCodegen extends MemberCodegen<KtElement> {
|
|||||||
Type type = typeMapper.mapType(captureThis);
|
Type type = typeMapper.mapType(captureThis);
|
||||||
args.add(FieldInfo.createForHiddenField(ownerType, type, CAPTURED_THIS_FIELD));
|
args.add(FieldInfo.createForHiddenField(ownerType, type, CAPTURED_THIS_FIELD));
|
||||||
}
|
}
|
||||||
KtType captureReceiverType = closure.getCaptureReceiverType();
|
KotlinType captureReceiverType = closure.getCaptureReceiverType();
|
||||||
if (captureReceiverType != null) {
|
if (captureReceiverType != null) {
|
||||||
args.add(FieldInfo.createForHiddenField(ownerType, typeMapper.mapType(captureReceiverType), CAPTURED_RECEIVER_FIELD));
|
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 }
|
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 }
|
this.map { it.getConstructor().getDeclarationDescriptor() as ClassDescriptor }
|
||||||
|
|
||||||
private fun findFakeOverridesForMethodsFromMutableCollection(
|
private fun findFakeOverridesForMethodsFromMutableCollection(
|
||||||
@@ -213,7 +213,7 @@ class CollectionStubMethodGenerator(
|
|||||||
return result
|
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 }
|
val types = this.filter { it.getConstructor().getDeclarationDescriptor() == klass }
|
||||||
if (types.isEmpty()) error("No supertype of $klass in $this")
|
if (types.isEmpty()) error("No supertype of $klass in $this")
|
||||||
if (types.size() == 1) return types.first()
|
if (types.size() == 1) return types.first()
|
||||||
@@ -239,8 +239,8 @@ class CollectionStubMethodGenerator(
|
|||||||
return this.getOverriddenDescriptors().firstOrNull { it.getContainingDeclaration() == classDescriptor }
|
return this.getOverriddenDescriptors().firstOrNull { it.getContainingDeclaration() == classDescriptor }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun newType(classDescriptor: ClassDescriptor, typeArguments: List<TypeProjection>): KtType {
|
private fun newType(classDescriptor: ClassDescriptor, typeArguments: List<TypeProjection>): KotlinType {
|
||||||
return KtTypeImpl.create(Annotations.EMPTY, classDescriptor, false, typeArguments)
|
return KotlinTypeImpl.create(Annotations.EMPTY, classDescriptor, false, typeArguments)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun FunctionDescriptor.signature(): JvmMethodSignature = typeMapper.mapSignature(this)
|
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.jvm.jvmSignature.JvmMethodSignature;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.*;
|
import org.jetbrains.kotlin.resolve.scopes.receivers.*;
|
||||||
import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor;
|
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.TypeProjection;
|
||||||
import org.jetbrains.kotlin.types.TypeUtils;
|
import org.jetbrains.kotlin.types.TypeUtils;
|
||||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
|
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
|
||||||
@@ -225,7 +225,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void addReifiedParametersFromSignature(@NotNull MemberCodegen member, @NotNull ClassDescriptor descriptor) {
|
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()) {
|
for (TypeProjection supertypeArgument : type.getArguments()) {
|
||||||
TypeParameterDescriptor parameterDescriptor = TypeUtils.getTypeParameterDescriptorOrNull(supertypeArgument.getType());
|
TypeParameterDescriptor parameterDescriptor = TypeUtils.getTypeParameterDescriptorOrNull(supertypeArgument.getType());
|
||||||
if (parameterDescriptor != null && parameterDescriptor.isReified()) {
|
if (parameterDescriptor != null && parameterDescriptor.isReified()) {
|
||||||
@@ -377,18 +377,18 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private Type asmType(@NotNull KtType type) {
|
private Type asmType(@NotNull KotlinType type) {
|
||||||
return typeMapper.mapType(type);
|
return typeMapper.mapType(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public Type expressionType(@Nullable KtExpression expression) {
|
public Type expressionType(@Nullable KtExpression expression) {
|
||||||
KtType type = expressionJetType(expression);
|
KotlinType type = expressionJetType(expression);
|
||||||
return type == null ? Type.VOID_TYPE : asmType(type);
|
return type == null ? Type.VOID_TYPE : asmType(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public KtType expressionJetType(@Nullable KtExpression expression) {
|
public KotlinType expressionJetType(@Nullable KtExpression expression) {
|
||||||
return expression != null ? bindingContext.getType(expression) : null;
|
return expression != null ? bindingContext.getType(expression) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -543,7 +543,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
|||||||
|
|
||||||
KtExpression loopRange = forExpression.getLoopRange();
|
KtExpression loopRange = forExpression.getLoopRange();
|
||||||
assert loopRange != null;
|
assert loopRange != null;
|
||||||
KtType loopRangeType = bindingContext.getType(loopRange);
|
KotlinType loopRangeType = bindingContext.getType(loopRange);
|
||||||
assert loopRangeType != null;
|
assert loopRangeType != null;
|
||||||
Type asmLoopRangeType = asmType(loopRangeType);
|
Type asmLoopRangeType = asmType(loopRangeType);
|
||||||
if (asmLoopRangeType.getSort() == Type.ARRAY) {
|
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 Label bodyEnd = new Label();
|
||||||
private final List<Runnable> leaveVariableTasks = Lists.newArrayList();
|
private final List<Runnable> leaveVariableTasks = Lists.newArrayList();
|
||||||
|
|
||||||
protected final KtType elementType;
|
protected final KotlinType elementType;
|
||||||
protected final Type asmElementType;
|
protected final Type asmElementType;
|
||||||
|
|
||||||
protected int loopParameterVar;
|
protected int loopParameterVar;
|
||||||
@@ -616,7 +616,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private KtType getElementType(KtForExpression forExpression) {
|
private KotlinType getElementType(KtForExpression forExpression) {
|
||||||
KtExpression loopRange = forExpression.getLoopRange();
|
KtExpression loopRange = forExpression.getLoopRange();
|
||||||
assert loopRange != null;
|
assert loopRange != null;
|
||||||
ResolvedCall<FunctionDescriptor> nextCall = getNotNull(bindingContext,
|
ResolvedCall<FunctionDescriptor> nextCall = getNotNull(bindingContext,
|
||||||
@@ -765,7 +765,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
|||||||
LOOP_RANGE_ITERATOR_RESOLVED_CALL, loopRange,
|
LOOP_RANGE_ITERATOR_RESOLVED_CALL, loopRange,
|
||||||
"No .iterator() function " + DiagnosticUtils.atLocation(loopRange));
|
"No .iterator() function " + DiagnosticUtils.atLocation(loopRange));
|
||||||
|
|
||||||
KtType iteratorType = iteratorCall.getResultingDescriptor().getReturnType();
|
KotlinType iteratorType = iteratorCall.getResultingDescriptor().getReturnType();
|
||||||
assert iteratorType != null;
|
assert iteratorType != null;
|
||||||
this.asmTypeForIterator = asmType(iteratorType);
|
this.asmTypeForIterator = asmType(iteratorType);
|
||||||
|
|
||||||
@@ -802,7 +802,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
|||||||
result.put(result.type, v);
|
result.put(result.type, v);
|
||||||
|
|
||||||
FunctionDescriptor hasNext = hasNextCall.getResultingDescriptor();
|
FunctionDescriptor hasNext = hasNextCall.getResultingDescriptor();
|
||||||
KtType type = hasNext.getReturnType();
|
KotlinType type = hasNext.getReturnType();
|
||||||
assert type != null && KotlinTypeChecker.DEFAULT.isSubtypeOf(type, DescriptorUtilsKt.getBuiltIns(hasNext).getBooleanType());
|
assert type != null && KotlinTypeChecker.DEFAULT.isSubtypeOf(type, DescriptorUtilsKt.getBuiltIns(hasNext).getBooleanType());
|
||||||
|
|
||||||
Type asmType = asmType(type);
|
Type asmType = asmType(type);
|
||||||
@@ -827,7 +827,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
|||||||
private class ForInArrayLoopGenerator extends AbstractForLoopGenerator {
|
private class ForInArrayLoopGenerator extends AbstractForLoopGenerator {
|
||||||
private int indexVar;
|
private int indexVar;
|
||||||
private int arrayVar;
|
private int arrayVar;
|
||||||
private final KtType loopRangeType;
|
private final KotlinType loopRangeType;
|
||||||
|
|
||||||
private ForInArrayLoopGenerator(@NotNull KtForExpression forExpression) {
|
private ForInArrayLoopGenerator(@NotNull KtForExpression forExpression) {
|
||||||
super(forExpression);
|
super(forExpression);
|
||||||
@@ -1042,7 +1042,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void storeRangeStartAndEnd() {
|
protected void storeRangeStartAndEnd() {
|
||||||
KtType loopRangeType = bindingContext.getType(forExpression.getLoopRange());
|
KotlinType loopRangeType = bindingContext.getType(forExpression.getLoopRange());
|
||||||
assert loopRangeType != null;
|
assert loopRangeType != null;
|
||||||
Type asmLoopRangeType = asmType(loopRangeType);
|
Type asmLoopRangeType = asmType(loopRangeType);
|
||||||
gen(forExpression.getLoopRange(), asmLoopRangeType);
|
gen(forExpression.getLoopRange(), asmLoopRangeType);
|
||||||
@@ -1074,7 +1074,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
|||||||
|
|
||||||
incrementVar = createLoopTempVariable(asmElementType);
|
incrementVar = createLoopTempVariable(asmElementType);
|
||||||
|
|
||||||
KtType loopRangeType = bindingContext.getType(forExpression.getLoopRange());
|
KotlinType loopRangeType = bindingContext.getType(forExpression.getLoopRange());
|
||||||
assert loopRangeType != null;
|
assert loopRangeType != null;
|
||||||
Type asmLoopRangeType = asmType(loopRangeType);
|
Type asmLoopRangeType = asmType(loopRangeType);
|
||||||
|
|
||||||
@@ -1308,7 +1308,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
|||||||
if (compileTimeValue == null) {
|
if (compileTimeValue == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
KtType expectedType = bindingContext.getType(expression);
|
KotlinType expectedType = bindingContext.getType(expression);
|
||||||
return compileTimeValue.toConstantValue(expectedType);
|
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) {
|
if (captureReceiver != null) {
|
||||||
Type asmType = typeMapper.mapType(captureReceiver);
|
Type asmType = typeMapper.mapType(captureReceiver);
|
||||||
StackValue.Local capturedReceiver = StackValue.local(AsmUtil.getReceiverIndex(context, context.getContextDescriptor()), asmType);
|
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());
|
Collection<ExpressionCodegenExtension> codegenExtensions = ExpressionCodegenExtension.Companion.getInstances(state.getProject());
|
||||||
if (!codegenExtensions.isEmpty() && resolvedCall != null) {
|
if (!codegenExtensions.isEmpty() && resolvedCall != null) {
|
||||||
ExpressionCodegenExtension.Context context = new ExpressionCodegenExtension.Context(typeMapper, v);
|
ExpressionCodegenExtension.Context context = new ExpressionCodegenExtension.Context(typeMapper, v);
|
||||||
KtType returnType = propertyDescriptor.getReturnType();
|
KotlinType returnType = propertyDescriptor.getReturnType();
|
||||||
for (ExpressionCodegenExtension extension : codegenExtensions) {
|
for (ExpressionCodegenExtension extension : codegenExtensions) {
|
||||||
if (returnType != null) {
|
if (returnType != null) {
|
||||||
StackValue value = extension.applyProperty(receiver, resolvedCall, context);
|
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) {
|
private StackValue stackValueForLocal(DeclarationDescriptor descriptor, int index) {
|
||||||
if (descriptor instanceof VariableDescriptor) {
|
if (descriptor instanceof VariableDescriptor) {
|
||||||
Type sharedVarType = typeMapper.getSharedVarType(descriptor);
|
Type sharedVarType = typeMapper.getSharedVarType(descriptor);
|
||||||
KtType outType = ((VariableDescriptor) descriptor).getType();
|
KotlinType outType = ((VariableDescriptor) descriptor).getType();
|
||||||
if (sharedVarType != null) {
|
if (sharedVarType != null) {
|
||||||
return StackValue.shared(index, asmType(outType));
|
return StackValue.shared(index, asmType(outType));
|
||||||
}
|
}
|
||||||
@@ -2126,7 +2126,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@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();
|
PropertyGetterDescriptor getter = descriptor.getGetter();
|
||||||
if (getter != null) {
|
if (getter != null) {
|
||||||
Call call = bindingContext.get(DELEGATED_PROPERTY_CALL, getter);
|
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 isSuper = superExpression != null;
|
||||||
boolean isExtensionProperty = propertyDescriptor.getExtensionReceiverParameter() != null;
|
boolean isExtensionProperty = propertyDescriptor.getExtensionReceiverParameter() != null;
|
||||||
|
|
||||||
KtType delegateType = getPropertyDelegateType(propertyDescriptor, bindingContext);
|
KotlinType delegateType = getPropertyDelegateType(propertyDescriptor, bindingContext);
|
||||||
boolean isDelegatedProperty = delegateType != null;
|
boolean isDelegatedProperty = delegateType != null;
|
||||||
|
|
||||||
CallableMethod callableGetter = null;
|
CallableMethod callableGetter = null;
|
||||||
@@ -2504,13 +2504,13 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private CallGenerator getOrCreateCallGenerator(@NotNull ResolvedCall<?> resolvedCall) {
|
private CallGenerator getOrCreateCallGenerator(@NotNull ResolvedCall<?> resolvedCall) {
|
||||||
Map<TypeParameterDescriptor, KtType> typeArguments = resolvedCall.getTypeArguments();
|
Map<TypeParameterDescriptor, KotlinType> typeArguments = resolvedCall.getTypeArguments();
|
||||||
ReifiedTypeParameterMappings mappings = new ReifiedTypeParameterMappings();
|
ReifiedTypeParameterMappings mappings = new ReifiedTypeParameterMappings();
|
||||||
for (Map.Entry<TypeParameterDescriptor, KtType> entry : typeArguments.entrySet()) {
|
for (Map.Entry<TypeParameterDescriptor, KotlinType> entry : typeArguments.entrySet()) {
|
||||||
TypeParameterDescriptor key = entry.getKey();
|
TypeParameterDescriptor key = entry.getKey();
|
||||||
if (!key.isReified()) continue;
|
if (!key.isReified()) continue;
|
||||||
|
|
||||||
KtType type = entry.getValue();
|
KotlinType type = entry.getValue();
|
||||||
TypeParameterDescriptor parameterDescriptor = TypeUtils.getTypeParameterDescriptorOrNull(type);
|
TypeParameterDescriptor parameterDescriptor = TypeUtils.getTypeParameterDescriptorOrNull(type);
|
||||||
if (parameterDescriptor == null) {
|
if (parameterDescriptor == null) {
|
||||||
// type is not generic
|
// 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);
|
Type type = asmType(outType);
|
||||||
assert type.getSort() == Type.ARRAY;
|
assert type.getSort() == Type.ARRAY;
|
||||||
Type elementType = correctElementType(type);
|
Type elementType = correctElementType(type);
|
||||||
@@ -2761,7 +2761,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StackValue visitClassLiteralExpression(@NotNull KtClassLiteralExpression expression, StackValue data) {
|
public StackValue visitClassLiteralExpression(@NotNull KtClassLiteralExpression expression, StackValue data) {
|
||||||
KtType type = bindingContext.getType(expression);
|
KotlinType type = bindingContext.getType(expression);
|
||||||
assert type != null;
|
assert type != null;
|
||||||
|
|
||||||
assert state.getReflectionTypes().getKClass().getTypeConstructor().equals(type.getConstructor())
|
assert state.getReflectionTypes().getKClass().getTypeConstructor().equals(type.getConstructor())
|
||||||
@@ -2813,7 +2813,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@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>() {
|
return StackValue.operation(K_CLASS_TYPE, new Function1<InstructionAdapter, Unit>() {
|
||||||
@Override
|
@Override
|
||||||
public Unit invoke(InstructionAdapter v) {
|
public Unit invoke(InstructionAdapter v) {
|
||||||
@@ -3312,7 +3312,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
|||||||
KtExpression initializer = multiDeclaration.getInitializer();
|
KtExpression initializer = multiDeclaration.getInitializer();
|
||||||
if (initializer == null) return StackValue.none();
|
if (initializer == null) return StackValue.none();
|
||||||
|
|
||||||
KtType initializerType = bindingContext.getType(initializer);
|
KotlinType initializerType = bindingContext.getType(initializer);
|
||||||
assert initializerType != null;
|
assert initializerType != null;
|
||||||
|
|
||||||
Type initializerAsmType = asmType(initializerType);
|
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";
|
assert expression.getValueArguments().size() == 1 : "Size argument expected";
|
||||||
|
|
||||||
final KtExpression sizeExpression = expression.getValueArguments().get(0).getArgumentExpression();
|
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)) {
|
if (KotlinBuiltIns.isArray(arrayType)) {
|
||||||
KtType elementJetType = arrayType.getArguments().get(0).getType();
|
KotlinType elementJetType = arrayType.getArguments().get(0).getType();
|
||||||
putReifierMarkerIfTypeIsReifiedParameter(
|
putReifierMarkerIfTypeIsReifiedParameter(
|
||||||
elementJetType,
|
elementJetType,
|
||||||
ReifiedTypeInliner.NEW_ARRAY_MARKER_METHOD_NAME
|
ReifiedTypeInliner.NEW_ARRAY_MARKER_METHOD_NAME
|
||||||
@@ -3461,7 +3461,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
|||||||
@Override
|
@Override
|
||||||
public StackValue visitArrayAccessExpression(@NotNull KtArrayAccessExpression expression, StackValue receiver) {
|
public StackValue visitArrayAccessExpression(@NotNull KtArrayAccessExpression expression, StackValue receiver) {
|
||||||
KtExpression array = expression.getArrayExpression();
|
KtExpression array = expression.getArrayExpression();
|
||||||
KtType type = array != null ? bindingContext.getType(array) : null;
|
KotlinType type = array != null ? bindingContext.getType(array) : null;
|
||||||
Type arrayType = expressionType(array);
|
Type arrayType = expressionType(array);
|
||||||
List<KtExpression> indices = expression.getIndexExpressions();
|
List<KtExpression> indices = expression.getIndexExpressions();
|
||||||
FunctionDescriptor operationDescriptor = (FunctionDescriptor) bindingContext.get(REFERENCE_TARGET, expression);
|
FunctionDescriptor operationDescriptor = (FunctionDescriptor) bindingContext.get(REFERENCE_TARGET, expression);
|
||||||
@@ -3472,7 +3472,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
|||||||
assert type != null;
|
assert type != null;
|
||||||
Type elementType;
|
Type elementType;
|
||||||
if (KotlinBuiltIns.isArray(type)) {
|
if (KotlinBuiltIns.isArray(type)) {
|
||||||
KtType jetElementType = type.getArguments().get(0).getType();
|
KotlinType jetElementType = type.getArguments().get(0).getType();
|
||||||
elementType = boxType(asmType(jetElementType));
|
elementType = boxType(asmType(jetElementType));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -3564,7 +3564,7 @@ The "returned" value of try expression with no finally is either the last expres
|
|||||||
(or blocks).
|
(or blocks).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
KtType jetType = bindingContext.getType(expression);
|
KotlinType jetType = bindingContext.getType(expression);
|
||||||
assert jetType != null;
|
assert jetType != null;
|
||||||
final Type expectedAsmType = isStatement ? Type.VOID_TYPE : asmType(jetType);
|
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();
|
KtExpression left = expression.getLeft();
|
||||||
final IElementType opToken = expression.getOperationReference().getReferencedNameElementType();
|
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;
|
assert rightType != null;
|
||||||
|
|
||||||
final StackValue value = genQualified(receiver, left);
|
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) {
|
if (expressionToMatch != null) {
|
||||||
Type subjectType = expressionToMatch.type;
|
Type subjectType = expressionToMatch.type;
|
||||||
markStartLineNumber(patternExpression);
|
markStartLineNumber(patternExpression);
|
||||||
KtType condJetType = bindingContext.getType(patternExpression);
|
KotlinType condJetType = bindingContext.getType(patternExpression);
|
||||||
Type condType;
|
Type condType;
|
||||||
if (isNumberPrimitive(subjectType) || subjectType.getSort() == Type.BOOLEAN) {
|
if (isNumberPrimitive(subjectType) || subjectType.getSort() == Type.BOOLEAN) {
|
||||||
assert condJetType != null;
|
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) {
|
private StackValue generateIsCheck(StackValue expressionToMatch, KtTypeReference typeReference, boolean negated) {
|
||||||
KtType jetType = bindingContext.get(TYPE, typeReference);
|
KotlinType jetType = bindingContext.get(TYPE, typeReference);
|
||||||
markStartLineNumber(typeReference);
|
markStartLineNumber(typeReference);
|
||||||
StackValue value = generateInstanceOf(expressionToMatch, jetType, false);
|
StackValue value = generateInstanceOf(expressionToMatch, jetType, false);
|
||||||
return negated ? StackValue.not(value) : value;
|
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>() {
|
return StackValue.operation(Type.BOOLEAN_TYPE, new Function1<InstructionAdapter, Unit>() {
|
||||||
@Override
|
@Override
|
||||||
public Unit invoke(InstructionAdapter v) {
|
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));
|
Type type = boxType(asmType(jetType));
|
||||||
putReifierMarkerIfTypeIsReifiedParameter(jetType, ReifiedTypeInliner.INSTANCEOF_MARKER_METHOD_NAME);
|
putReifierMarkerIfTypeIsReifiedParameter(jetType, ReifiedTypeInliner.INSTANCEOF_MARKER_METHOD_NAME);
|
||||||
TypeIntrinsics.instanceOf(v, jetType, type);
|
TypeIntrinsics.instanceOf(v, jetType, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private StackValue generateCheckCastInstruction(@NotNull KtType jetType, boolean safeAs) {
|
private StackValue generateCheckCastInstruction(@NotNull KotlinType jetType, boolean safeAs) {
|
||||||
Type type = boxType(asmType(jetType));
|
Type type = boxType(asmType(jetType));
|
||||||
putReifierMarkerIfTypeIsReifiedParameter(jetType,
|
putReifierMarkerIfTypeIsReifiedParameter(jetType,
|
||||||
safeAs ? ReifiedTypeInliner.SAFE_CHECKCAST_MARKER_METHOD_NAME
|
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);
|
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);
|
TypeParameterDescriptor typeParameterDescriptor = TypeUtils.getTypeParameterDescriptorOrNull(type);
|
||||||
if (typeParameterDescriptor != null && typeParameterDescriptor.isReified()) {
|
if (typeParameterDescriptor != null && typeParameterDescriptor.isReified()) {
|
||||||
if (typeParameterDescriptor.getContainingDeclaration() != context.getContextDescriptor()) {
|
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) {
|
if (rangeExpression instanceof KtBinaryExpression) {
|
||||||
KtBinaryExpression binaryExpression = (KtBinaryExpression) rangeExpression;
|
KtBinaryExpression binaryExpression = (KtBinaryExpression) rangeExpression;
|
||||||
if (binaryExpression.getOperationReference().getReferencedNameElementType() == KtTokens.RANGE) {
|
if (binaryExpression.getOperationReference().getReferencedNameElementType() == KtTokens.RANGE) {
|
||||||
KtType jetType = bindingContext.getType(rangeExpression);
|
KotlinType jetType = bindingContext.getType(rangeExpression);
|
||||||
assert jetType != null;
|
assert jetType != null;
|
||||||
DeclarationDescriptor descriptor = jetType.getConstructor().getDeclarationDescriptor();
|
DeclarationDescriptor descriptor = jetType.getConstructor().getDeclarationDescriptor();
|
||||||
return DescriptorUtilsKt.getBuiltIns(descriptor).getIntegralRanges().contains(descriptor);
|
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.JvmMethodParameterKind;
|
||||||
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterSignature;
|
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterSignature;
|
||||||
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature;
|
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.*;
|
||||||
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
|
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
|
||||||
import org.jetbrains.org.objectweb.asm.commons.Method;
|
import org.jetbrains.org.objectweb.asm.commons.Method;
|
||||||
@@ -887,7 +887,7 @@ public class FunctionCodegen {
|
|||||||
|
|
||||||
iv.load(1, OBJECT_TYPE);
|
iv.load(1, OBJECT_TYPE);
|
||||||
|
|
||||||
KtType jetType = descriptor.getValueParameters().get(0).getType();
|
KotlinType jetType = descriptor.getValueParameters().get(0).getType();
|
||||||
|
|
||||||
// TODO: reuse logic from ExpressionCodegen
|
// TODO: reuse logic from ExpressionCodegen
|
||||||
if (jetType.isMarkedNullable()) {
|
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.resolve.scopes.receivers.ThisReceiver;
|
||||||
import org.jetbrains.kotlin.serialization.DescriptorSerializer;
|
import org.jetbrains.kotlin.serialization.DescriptorSerializer;
|
||||||
import org.jetbrains.kotlin.serialization.ProtoBuf;
|
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.kotlin.types.checker.KotlinTypeChecker;
|
||||||
import org.jetbrains.org.objectweb.asm.*;
|
import org.jetbrains.org.objectweb.asm.*;
|
||||||
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
|
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 static final String ENUM_VALUES_FIELD_NAME = "$VALUES";
|
||||||
private Type superClassAsmType;
|
private Type superClassAsmType;
|
||||||
@Nullable // null means java/lang/Object
|
@Nullable // null means java/lang/Object
|
||||||
private KtType superClassType;
|
private KotlinType superClassType;
|
||||||
private final Type classAsmType;
|
private final Type classAsmType;
|
||||||
private final boolean isLocal;
|
private final boolean isLocal;
|
||||||
|
|
||||||
@@ -316,7 +316,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
LinkedHashSet<String> superInterfaces = new LinkedHashSet<String>();
|
LinkedHashSet<String> superInterfaces = new LinkedHashSet<String>();
|
||||||
Set<String> kotlinMarkerInterfaces = 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())) {
|
if (isJvmInterface(supertype.getConstructor().getDeclarationDescriptor())) {
|
||||||
sw.writeInterface();
|
sw.writeInterface();
|
||||||
Type jvmInterfaceType = typeMapper.mapSupertype(supertype, sw);
|
Type jvmInterfaceType = typeMapper.mapSupertype(supertype, sw);
|
||||||
@@ -352,7 +352,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (KtType supertype : descriptor.getTypeConstructor().getSupertypes()) {
|
for (KotlinType supertype : descriptor.getTypeConstructor().getSupertypes()) {
|
||||||
ClassifierDescriptor superClass = supertype.getConstructor().getDeclarationDescriptor();
|
ClassifierDescriptor superClass = supertype.getConstructor().getDeclarationDescriptor();
|
||||||
if (superClass != null && !isJvmInterface(superClass)) {
|
if (superClass != null && !isJvmInterface(superClass)) {
|
||||||
superClassAsmType = typeMapper.mapClass(superClass);
|
superClassAsmType = typeMapper.mapClass(superClass);
|
||||||
@@ -421,11 +421,11 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
KtType returnType = function.getReturnType();
|
KotlinType returnType = function.getReturnType();
|
||||||
assert returnType != null : function.toString();
|
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)) {
|
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))
|
if (KotlinTypeChecker.DEFAULT.equalTypes(elementType, DescriptorUtilsKt.getBuiltIns(descriptor).getArrayElementType(returnType))
|
||||||
&& KotlinTypeChecker.DEFAULT.equalTypes(elementType, DescriptorUtilsKt
|
&& KotlinTypeChecker.DEFAULT.equalTypes(elementType, DescriptorUtilsKt
|
||||||
.getBuiltIns(descriptor).getArrayElementType(paramType))) {
|
.getBuiltIns(descriptor).getArrayElementType(paramType))) {
|
||||||
@@ -738,7 +738,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
iv.getfield(classAsmType.getInternalName(), CAPTURED_THIS_FIELD, type.getDescriptor());
|
iv.getfield(classAsmType.getInternalName(), CAPTURED_THIS_FIELD, type.getDescriptor());
|
||||||
}
|
}
|
||||||
|
|
||||||
KtType captureReceiver = closure.getCaptureReceiverType();
|
KotlinType captureReceiver = closure.getCaptureReceiverType();
|
||||||
if (captureReceiver != null) {
|
if (captureReceiver != null) {
|
||||||
iv.load(0, classAsmType);
|
iv.load(0, classAsmType);
|
||||||
Type type = typeMapper.mapType(captureReceiver);
|
Type type = typeMapper.mapType(captureReceiver);
|
||||||
@@ -1150,7 +1150,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
result.addField((KtDelegatorByExpressionSpecifier) specifier, propertyDescriptor);
|
result.addField((KtDelegatorByExpressionSpecifier) specifier, propertyDescriptor);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
KtType expressionType = expression != null ? bindingContext.getType(expression) : null;
|
KotlinType expressionType = expression != null ? bindingContext.getType(expression) : null;
|
||||||
Type asmType =
|
Type asmType =
|
||||||
expressionType != null ? typeMapper.mapType(expressionType) : typeMapper.mapType(getSuperClass(specifier));
|
expressionType != null ? typeMapper.mapType(expressionType) : typeMapper.mapType(getSuperClass(specifier));
|
||||||
result.addField((KtDelegatorByExpressionSpecifier) specifier, asmType, "$delegate_" + n);
|
result.addField((KtDelegatorByExpressionSpecifier) specifier, asmType, "$delegate_" + n);
|
||||||
@@ -1610,7 +1610,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
DelegationFieldsInfo.Field field = delegationFieldsInfo.getInfo((KtDelegatorByExpressionSpecifier) specifier);
|
DelegationFieldsInfo.Field field = delegationFieldsInfo.getInfo((KtDelegatorByExpressionSpecifier) specifier);
|
||||||
generateDelegateField(field);
|
generateDelegateField(field);
|
||||||
KtExpression delegateExpression = ((KtDelegatorByExpressionSpecifier) specifier).getDelegateExpression();
|
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);
|
generateDelegates(getSuperClass(specifier), delegateExpressionType, field);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1623,7 +1623,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
fieldInfo.name, fieldInfo.type.getDescriptor(), /*TODO*/null, null);
|
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()) {
|
for (Map.Entry<CallableMemberDescriptor, CallableDescriptor> entry : CodegenUtilKt.getDelegates(descriptor, toTrait, delegateExpressionType).entrySet()) {
|
||||||
CallableMemberDescriptor callableMemberDescriptor = entry.getKey();
|
CallableMemberDescriptor callableMemberDescriptor = entry.getKey();
|
||||||
CallableDescriptor delegateTo = entry.getValue();
|
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.DescriptorUtils;
|
||||||
import org.jetbrains.kotlin.resolve.inline.InlineUtil;
|
import org.jetbrains.kotlin.resolve.inline.InlineUtil;
|
||||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedCallableMemberDescriptor;
|
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 org.jetbrains.org.objectweb.asm.AnnotationVisitor;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -64,7 +64,7 @@ public class JvmCodegenUtil {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isJvmInterface(KtType type) {
|
public static boolean isJvmInterface(KotlinType type) {
|
||||||
return isJvmInterface(type.getConstructor().getDeclarationDescriptor());
|
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.descriptorUtil.DescriptorUtilsKt;
|
||||||
import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform;
|
import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform;
|
||||||
import org.jetbrains.kotlin.storage.LockBasedStorageManager;
|
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 org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -72,11 +72,11 @@ public class JvmRuntimeTypes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public Collection<KtType> getSupertypesForClosure(@NotNull FunctionDescriptor descriptor) {
|
public Collection<KotlinType> getSupertypesForClosure(@NotNull FunctionDescriptor descriptor) {
|
||||||
ReceiverParameterDescriptor receiverParameter = descriptor.getExtensionReceiverParameter();
|
ReceiverParameterDescriptor receiverParameter = descriptor.getExtensionReceiverParameter();
|
||||||
|
|
||||||
//noinspection ConstantConditions
|
//noinspection ConstantConditions
|
||||||
KtType functionType = DescriptorUtilsKt.getBuiltIns(descriptor).getFunctionType(
|
KotlinType functionType = DescriptorUtilsKt.getBuiltIns(descriptor).getFunctionType(
|
||||||
Annotations.Companion.getEMPTY(),
|
Annotations.Companion.getEMPTY(),
|
||||||
receiverParameter == null ? null : receiverParameter.getType(),
|
receiverParameter == null ? null : receiverParameter.getType(),
|
||||||
ExpressionTypingUtils.getValueParametersTypes(descriptor.getValueParameters()),
|
ExpressionTypingUtils.getValueParametersTypes(descriptor.getValueParameters()),
|
||||||
@@ -87,15 +87,15 @@ public class JvmRuntimeTypes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public Collection<KtType> getSupertypesForFunctionReference(@NotNull FunctionDescriptor descriptor) {
|
public Collection<KotlinType> getSupertypesForFunctionReference(@NotNull FunctionDescriptor descriptor) {
|
||||||
ReceiverParameterDescriptor extensionReceiver = descriptor.getExtensionReceiverParameter();
|
ReceiverParameterDescriptor extensionReceiver = descriptor.getExtensionReceiverParameter();
|
||||||
ReceiverParameterDescriptor dispatchReceiver = descriptor.getDispatchReceiverParameter();
|
ReceiverParameterDescriptor dispatchReceiver = descriptor.getDispatchReceiverParameter();
|
||||||
|
|
||||||
KtType receiverType =
|
KotlinType receiverType =
|
||||||
extensionReceiver != null ? extensionReceiver.getType() : dispatchReceiver != null ? dispatchReceiver.getType() : null;
|
extensionReceiver != null ? extensionReceiver.getType() : dispatchReceiver != null ? dispatchReceiver.getType() : null;
|
||||||
|
|
||||||
//noinspection ConstantConditions
|
//noinspection ConstantConditions
|
||||||
KtType functionType = DescriptorUtilsKt.getBuiltIns(descriptor).getFunctionType(
|
KotlinType functionType = DescriptorUtilsKt.getBuiltIns(descriptor).getFunctionType(
|
||||||
Annotations.Companion.getEMPTY(),
|
Annotations.Companion.getEMPTY(),
|
||||||
receiverType,
|
receiverType,
|
||||||
ExpressionTypingUtils.getValueParametersTypes(descriptor.getValueParameters()),
|
ExpressionTypingUtils.getValueParametersTypes(descriptor.getValueParameters()),
|
||||||
@@ -106,7 +106,7 @@ public class JvmRuntimeTypes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public KtType getSupertypeForPropertyReference(@NotNull PropertyDescriptor descriptor) {
|
public KotlinType getSupertypeForPropertyReference(@NotNull PropertyDescriptor descriptor) {
|
||||||
int arity = (descriptor.getExtensionReceiverParameter() != null ? 1 : 0) +
|
int arity = (descriptor.getExtensionReceiverParameter() != null ? 1 : 0) +
|
||||||
(descriptor.getDispatchReceiverParameter() != null ? 1 : 0);
|
(descriptor.getDispatchReceiverParameter() != null ? 1 : 0);
|
||||||
return (descriptor.isVar() ? mutablePropertyReferences : propertyReferences).get(arity).getDefaultType();
|
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.LockBasedStorageManager;
|
||||||
import org.jetbrains.kotlin.storage.NotNullLazyValue;
|
import org.jetbrains.kotlin.storage.NotNullLazyValue;
|
||||||
import org.jetbrains.kotlin.types.ErrorUtils;
|
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.Label;
|
||||||
import org.jetbrains.org.objectweb.asm.MethodVisitor;
|
import org.jetbrains.org.objectweb.asm.MethodVisitor;
|
||||||
import org.jetbrains.org.objectweb.asm.Type;
|
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;
|
if (initializerValue == null) return state.getClassBuilderMode() != ClassBuilderMode.LIGHT_CLASSES;
|
||||||
|
|
||||||
//TODO: OPTIMIZATION: don't initialize static final fields
|
//TODO: OPTIMIZATION: don't initialize static final fields
|
||||||
KtType jetType = getPropertyOrDelegateType(property, propertyDescriptor);
|
KotlinType jetType = getPropertyOrDelegateType(property, propertyDescriptor);
|
||||||
Type type = typeMapper.mapType(jetType);
|
Type type = typeMapper.mapType(jetType);
|
||||||
return !skipDefaultValue(propertyDescriptor, initializerValue.getValue(), type);
|
return !skipDefaultValue(propertyDescriptor, initializerValue.getValue(), type);
|
||||||
}
|
}
|
||||||
@@ -432,10 +432,10 @@ public abstract class MemberCodegen<T extends KtElement/* TODO: & JetDeclaration
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private KtType getPropertyOrDelegateType(@NotNull KtProperty property, @NotNull PropertyDescriptor descriptor) {
|
private KotlinType getPropertyOrDelegateType(@NotNull KtProperty property, @NotNull PropertyDescriptor descriptor) {
|
||||||
KtExpression delegateExpression = property.getDelegateExpression();
|
KtExpression delegateExpression = property.getDelegateExpression();
|
||||||
if (delegateExpression != null) {
|
if (delegateExpression != null) {
|
||||||
KtType delegateType = bindingContext.getType(delegateExpression);
|
KotlinType delegateType = bindingContext.getType(delegateExpression);
|
||||||
assert delegateType != null : "Type of delegate expression should be recorded";
|
assert delegateType != null : "Type of delegate expression should be recorded";
|
||||||
return delegateType;
|
return delegateType;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import org.jetbrains.kotlin.descriptors.impl.DeclarationDescriptorImpl;
|
|||||||
import org.jetbrains.kotlin.name.Name;
|
import org.jetbrains.kotlin.name.Name;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.KtScope;
|
import org.jetbrains.kotlin.resolve.scopes.KtScope;
|
||||||
import org.jetbrains.kotlin.storage.LockBasedStorageManager;
|
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.TypeConstructor;
|
||||||
import org.jetbrains.kotlin.types.TypeConstructorImpl;
|
import org.jetbrains.kotlin.types.TypeConstructorImpl;
|
||||||
import org.jetbrains.kotlin.types.TypeUtils;
|
import org.jetbrains.kotlin.types.TypeUtils;
|
||||||
@@ -41,7 +41,7 @@ public class MutableClassDescriptor extends ClassDescriptorBase implements Class
|
|||||||
private Visibility visibility;
|
private Visibility visibility;
|
||||||
private TypeConstructor typeConstructor;
|
private TypeConstructor typeConstructor;
|
||||||
private List<TypeParameterDescriptor> typeParameters;
|
private List<TypeParameterDescriptor> typeParameters;
|
||||||
private final Collection<KtType> supertypes = new ArrayList<KtType>();
|
private final Collection<KotlinType> supertypes = new ArrayList<KotlinType>();
|
||||||
|
|
||||||
public MutableClassDescriptor(
|
public MutableClassDescriptor(
|
||||||
@NotNull DeclarationDescriptor containingDeclaration,
|
@NotNull DeclarationDescriptor containingDeclaration,
|
||||||
@@ -116,7 +116,7 @@ public class MutableClassDescriptor extends ClassDescriptorBase implements Class
|
|||||||
return typeConstructor;
|
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";
|
assert !supertype.isError() : "Error types must be filtered out in DescriptorResolver";
|
||||||
if (TypeUtils.getClassDescriptor(supertype) != null) {
|
if (TypeUtils.getClassDescriptor(supertype) != null) {
|
||||||
// See the Errors.SUPERTYPE_NOT_A_CLASS_OR_INTERFACE
|
// See the Errors.SUPERTYPE_NOT_A_CLASS_OR_INTERFACE
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature;
|
|||||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedPropertyDescriptor;
|
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedPropertyDescriptor;
|
||||||
import org.jetbrains.kotlin.storage.LockBasedStorageManager;
|
import org.jetbrains.kotlin.storage.LockBasedStorageManager;
|
||||||
import org.jetbrains.kotlin.types.ErrorUtils;
|
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.FieldVisitor;
|
||||||
import org.jetbrains.org.objectweb.asm.MethodVisitor;
|
import org.jetbrains.org.objectweb.asm.MethodVisitor;
|
||||||
import org.jetbrains.org.objectweb.asm.Opcodes;
|
import org.jetbrains.org.objectweb.asm.Opcodes;
|
||||||
@@ -275,7 +275,7 @@ public class PropertyCodegen {
|
|||||||
KtNamedDeclaration element,
|
KtNamedDeclaration element,
|
||||||
PropertyDescriptor propertyDescriptor,
|
PropertyDescriptor propertyDescriptor,
|
||||||
boolean isDelegate,
|
boolean isDelegate,
|
||||||
KtType jetType,
|
KotlinType jetType,
|
||||||
Object defaultValue,
|
Object defaultValue,
|
||||||
Annotations annotations
|
Annotations annotations
|
||||||
) {
|
) {
|
||||||
@@ -362,7 +362,7 @@ public class PropertyCodegen {
|
|||||||
|
|
||||||
private void generatePropertyDelegateAccess(KtProperty p, PropertyDescriptor propertyDescriptor, Annotations annotations) {
|
private void generatePropertyDelegateAccess(KtProperty p, PropertyDescriptor propertyDescriptor, Annotations annotations) {
|
||||||
KtExpression delegateExpression = p.getDelegateExpression();
|
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 (delegateType == null) {
|
||||||
// If delegate expression is unresolved reference
|
// If delegate expression is unresolved reference
|
||||||
delegateType = ErrorUtils.createErrorType("Delegate type");
|
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.name.Name;
|
||||||
import org.jetbrains.kotlin.psi.*;
|
import org.jetbrains.kotlin.psi.*;
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
||||||
import org.jetbrains.kotlin.types.KtType;
|
import org.jetbrains.kotlin.types.KotlinType;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -53,11 +53,11 @@ public class RangeCodegenUtil {
|
|||||||
|
|
||||||
private RangeCodegenUtil() {}
|
private RangeCodegenUtil() {}
|
||||||
|
|
||||||
public static boolean isRange(KtType rangeType) {
|
public static boolean isRange(KotlinType rangeType) {
|
||||||
return !rangeType.isMarkedNullable() && getPrimitiveRangeElementType(rangeType) != null;
|
return !rangeType.isMarkedNullable() && getPrimitiveRangeElementType(rangeType) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isProgression(KtType rangeType) {
|
public static boolean isProgression(KotlinType rangeType) {
|
||||||
return !rangeType.isMarkedNullable() && getPrimitiveProgressionElementType(rangeType) != null;
|
return !rangeType.isMarkedNullable() && getPrimitiveProgressionElementType(rangeType) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,18 +92,18 @@ public class RangeCodegenUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private static PrimitiveType getPrimitiveRangeElementType(KtType rangeType) {
|
private static PrimitiveType getPrimitiveRangeElementType(KotlinType rangeType) {
|
||||||
return getPrimitiveRangeOrProgressionElementType(rangeType, RANGE_TO_ELEMENT_TYPE);
|
return getPrimitiveRangeOrProgressionElementType(rangeType, RANGE_TO_ELEMENT_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private static PrimitiveType getPrimitiveProgressionElementType(KtType rangeType) {
|
private static PrimitiveType getPrimitiveProgressionElementType(KotlinType rangeType) {
|
||||||
return getPrimitiveRangeOrProgressionElementType(rangeType, PROGRESSION_TO_ELEMENT_TYPE);
|
return getPrimitiveRangeOrProgressionElementType(rangeType, PROGRESSION_TO_ELEMENT_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private static PrimitiveType getPrimitiveRangeOrProgressionElementType(
|
private static PrimitiveType getPrimitiveRangeOrProgressionElementType(
|
||||||
@NotNull KtType rangeOrProgression,
|
@NotNull KotlinType rangeOrProgression,
|
||||||
@NotNull ImmutableMap<FqName, PrimitiveType> map
|
@NotNull ImmutableMap<FqName, PrimitiveType> map
|
||||||
) {
|
) {
|
||||||
ClassifierDescriptor declarationDescriptor = rangeOrProgression.getConstructor().getDeclarationDescriptor();
|
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.descriptors.SimpleFunctionDescriptor;
|
||||||
import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor;
|
import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor;
|
||||||
import org.jetbrains.kotlin.load.java.sam.SingleAbstractMethodUtils;
|
import org.jetbrains.kotlin.load.java.sam.SingleAbstractMethodUtils;
|
||||||
import org.jetbrains.kotlin.types.KtType;
|
import org.jetbrains.kotlin.types.KotlinType;
|
||||||
|
|
||||||
public class SamType {
|
public class SamType {
|
||||||
public static SamType create(@NotNull KtType originalType) {
|
public static SamType create(@NotNull KotlinType originalType) {
|
||||||
if (!SingleAbstractMethodUtils.isSamType(originalType)) return null;
|
if (!SingleAbstractMethodUtils.isSamType(originalType)) return null;
|
||||||
return new SamType(originalType);
|
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;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public KtType getType() {
|
public KotlinType getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ public class SamType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public KtType getKotlinFunctionType() {
|
public KotlinType getKotlinFunctionType() {
|
||||||
//noinspection ConstantConditions
|
//noinspection ConstantConditions
|
||||||
return getJavaClassDescriptor().getFunctionTypeForSamInterface();
|
return getJavaClassDescriptor().getFunctionTypeForSamInterface();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ import org.jetbrains.kotlin.name.Name;
|
|||||||
import org.jetbrains.kotlin.psi.KtFile;
|
import org.jetbrains.kotlin.psi.KtFile;
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
||||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOriginKt;
|
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.kotlin.util.OperatorNameConventions;
|
||||||
import org.jetbrains.org.objectweb.asm.MethodVisitor;
|
import org.jetbrains.org.objectweb.asm.MethodVisitor;
|
||||||
import org.jetbrains.org.objectweb.asm.Type;
|
import org.jetbrains.org.objectweb.asm.Type;
|
||||||
@@ -64,7 +64,7 @@ public class SamWrapperCodegen {
|
|||||||
Type asmType = asmTypeByFqNameWithoutInnerClasses(fqName);
|
Type asmType = asmTypeByFqNameWithoutInnerClasses(fqName);
|
||||||
|
|
||||||
// e.g. (T, T) -> Int
|
// e.g. (T, T) -> Int
|
||||||
KtType functionType = samType.getKotlinFunctionType();
|
KotlinType functionType = samType.getKotlinFunctionType();
|
||||||
|
|
||||||
ClassDescriptor classDescriptor = new ClassDescriptorImpl(
|
ClassDescriptor classDescriptor = new ClassDescriptorImpl(
|
||||||
samType.getJavaClassDescriptor().getContainingDeclaration(),
|
samType.getJavaClassDescriptor().getContainingDeclaration(),
|
||||||
@@ -140,7 +140,7 @@ public class SamWrapperCodegen {
|
|||||||
Type functionType,
|
Type functionType,
|
||||||
ClassBuilder cv,
|
ClassBuilder cv,
|
||||||
SimpleFunctionDescriptor erasedInterfaceFunction,
|
SimpleFunctionDescriptor erasedInterfaceFunction,
|
||||||
KtType functionJetType
|
KotlinType functionJetType
|
||||||
) {
|
) {
|
||||||
// using root context to avoid creating ClassDescriptor and everything else
|
// using root context to avoid creating ClassDescriptor and everything else
|
||||||
FunctionCodegen codegen = new FunctionCodegen(state.getRootContext().intoClass(
|
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.codegen.context.EnclosedValueDescriptor;
|
||||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor;
|
import org.jetbrains.kotlin.descriptors.ClassDescriptor;
|
||||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
|
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 org.jetbrains.org.objectweb.asm.Type;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -33,7 +33,7 @@ public interface CalculatedClosure {
|
|||||||
ClassDescriptor getCaptureThis();
|
ClassDescriptor getCaptureThis();
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
KtType getCaptureReceiverType();
|
KotlinType getCaptureReceiverType();
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
Map<DeclarationDescriptor, EnclosedValueDescriptor> getCaptureVariables();
|
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.constants.NullValue;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.KtScope;
|
import org.jetbrains.kotlin.resolve.scopes.KtScope;
|
||||||
import org.jetbrains.kotlin.resolve.source.KotlinSourceElementKt;
|
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 org.jetbrains.org.objectweb.asm.Type;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -90,7 +90,7 @@ class CodegenAnnotatingVisitor extends KtVisitorVoid {
|
|||||||
private ClassDescriptor recordClassForCallable(
|
private ClassDescriptor recordClassForCallable(
|
||||||
@NotNull KtElement element,
|
@NotNull KtElement element,
|
||||||
@NotNull CallableDescriptor callableDescriptor,
|
@NotNull CallableDescriptor callableDescriptor,
|
||||||
@NotNull Collection<KtType> supertypes,
|
@NotNull Collection<KotlinType> supertypes,
|
||||||
@NotNull String name
|
@NotNull String name
|
||||||
) {
|
) {
|
||||||
String simpleName = name.substring(name.lastIndexOf('/') + 1);
|
String simpleName = name.substring(name.lastIndexOf('/') + 1);
|
||||||
@@ -275,7 +275,7 @@ class CodegenAnnotatingVisitor extends KtVisitorVoid {
|
|||||||
if (functionDescriptor == null) return;
|
if (functionDescriptor == null) return;
|
||||||
|
|
||||||
String name = inventAnonymousClassName();
|
String name = inventAnonymousClassName();
|
||||||
Collection<KtType> supertypes = runtimeTypes.getSupertypesForClosure(functionDescriptor);
|
Collection<KotlinType> supertypes = runtimeTypes.getSupertypesForClosure(functionDescriptor);
|
||||||
ClassDescriptor classDescriptor = recordClassForCallable(functionLiteral, functionDescriptor, supertypes, name);
|
ClassDescriptor classDescriptor = recordClassForCallable(functionLiteral, functionDescriptor, supertypes, name);
|
||||||
recordClosure(classDescriptor, name);
|
recordClosure(classDescriptor, name);
|
||||||
|
|
||||||
@@ -293,7 +293,7 @@ class CodegenAnnotatingVisitor extends KtVisitorVoid {
|
|||||||
CallableDescriptor target = referencedFunction.getResultingDescriptor();
|
CallableDescriptor target = referencedFunction.getResultingDescriptor();
|
||||||
|
|
||||||
CallableDescriptor callableDescriptor;
|
CallableDescriptor callableDescriptor;
|
||||||
Collection<KtType> supertypes;
|
Collection<KotlinType> supertypes;
|
||||||
|
|
||||||
if (target instanceof FunctionDescriptor) {
|
if (target instanceof FunctionDescriptor) {
|
||||||
callableDescriptor = bindingContext.get(FUNCTION, expression);
|
callableDescriptor = bindingContext.get(FUNCTION, expression);
|
||||||
@@ -345,7 +345,7 @@ class CodegenAnnotatingVisitor extends KtVisitorVoid {
|
|||||||
if (delegate != null && descriptor instanceof PropertyDescriptor) {
|
if (delegate != null && descriptor instanceof PropertyDescriptor) {
|
||||||
PropertyDescriptor propertyDescriptor = (PropertyDescriptor) descriptor;
|
PropertyDescriptor propertyDescriptor = (PropertyDescriptor) descriptor;
|
||||||
String name = inventAnonymousClassName();
|
String name = inventAnonymousClassName();
|
||||||
KtType supertype = runtimeTypes.getSupertypeForPropertyReference(propertyDescriptor);
|
KotlinType supertype = runtimeTypes.getSupertypeForPropertyReference(propertyDescriptor);
|
||||||
ClassDescriptor classDescriptor = recordClassForCallable(delegate, propertyDescriptor, Collections.singleton(supertype), name);
|
ClassDescriptor classDescriptor = recordClassForCallable(delegate, propertyDescriptor, Collections.singleton(supertype), name);
|
||||||
recordClosure(classDescriptor, name);
|
recordClosure(classDescriptor, name);
|
||||||
}
|
}
|
||||||
@@ -368,7 +368,7 @@ class CodegenAnnotatingVisitor extends KtVisitorVoid {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
String name = inventAnonymousClassName();
|
String name = inventAnonymousClassName();
|
||||||
Collection<KtType> supertypes = runtimeTypes.getSupertypesForClosure(functionDescriptor);
|
Collection<KotlinType> supertypes = runtimeTypes.getSupertypesForClosure(functionDescriptor);
|
||||||
ClassDescriptor classDescriptor = recordClassForCallable(function, functionDescriptor, supertypes, name);
|
ClassDescriptor classDescriptor = recordClassForCallable(function, functionDescriptor, supertypes, name);
|
||||||
recordClosure(classDescriptor, name);
|
recordClosure(classDescriptor, name);
|
||||||
|
|
||||||
@@ -530,7 +530,7 @@ class CodegenAnnotatingVisitor extends KtVisitorVoid {
|
|||||||
int fieldNumber = mappings.size();
|
int fieldNumber = mappings.size();
|
||||||
|
|
||||||
assert expression.getSubjectExpression() != null : "subject expression should be not null in a valid when by enums";
|
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";
|
assert type != null : "should not be null in a valid when by enums";
|
||||||
ClassDescriptor classDescriptor = (ClassDescriptor) type.getConstructor().getDeclarationDescriptor();
|
ClassDescriptor classDescriptor = (ClassDescriptor) type.getConstructor().getDeclarationDescriptor();
|
||||||
assert classDescriptor != null : "because it's enum";
|
assert classDescriptor != null : "because it's enum";
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.kotlin.codegen.context.EnclosedValueDescriptor;
|
import org.jetbrains.kotlin.codegen.context.EnclosedValueDescriptor;
|
||||||
import org.jetbrains.kotlin.descriptors.*;
|
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 org.jetbrains.org.objectweb.asm.Type;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -71,7 +71,7 @@ public final class MutableClosure implements CalculatedClosure {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KtType getCaptureReceiverType() {
|
public KotlinType getCaptureReceiverType() {
|
||||||
if (captureReceiver) {
|
if (captureReceiver) {
|
||||||
ReceiverParameterDescriptor parameter = getEnclosingReceiverDescriptor();
|
ReceiverParameterDescriptor parameter = getEnclosingReceiverDescriptor();
|
||||||
assert parameter != null : "Receiver parameter should exist in " + enclosingFunWithReceiverDescriptor;
|
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.resolve.DescriptorUtils;
|
||||||
import org.jetbrains.kotlin.storage.LockBasedStorageManager;
|
import org.jetbrains.kotlin.storage.LockBasedStorageManager;
|
||||||
import org.jetbrains.kotlin.storage.NullableLazyValue;
|
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 org.jetbrains.org.objectweb.asm.Type;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -282,7 +282,7 @@ public abstract class CodegenContext<T extends DeclarationDescriptor> {
|
|||||||
public <D extends CallableMemberDescriptor> D getAccessor(
|
public <D extends CallableMemberDescriptor> D getAccessor(
|
||||||
@NotNull D possiblySubstitutedDescriptor,
|
@NotNull D possiblySubstitutedDescriptor,
|
||||||
boolean isForBackingFieldInOuterClass,
|
boolean isForBackingFieldInOuterClass,
|
||||||
@Nullable KtType delegateType,
|
@Nullable KotlinType delegateType,
|
||||||
@Nullable KtSuperExpression superCallExpression
|
@Nullable KtSuperExpression superCallExpression
|
||||||
) {
|
) {
|
||||||
if (accessors == null) {
|
if (accessors == null) {
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import org.jetbrains.kotlin.codegen.state.GenerationState;
|
|||||||
import org.jetbrains.kotlin.descriptors.*;
|
import org.jetbrains.kotlin.descriptors.*;
|
||||||
import org.jetbrains.kotlin.load.java.JvmAbi;
|
import org.jetbrains.kotlin.load.java.JvmAbi;
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
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 org.jetbrains.org.objectweb.asm.Type;
|
||||||
|
|
||||||
import static org.jetbrains.kotlin.codegen.AsmUtil.CAPTURED_RECEIVER_FIELD;
|
import static org.jetbrains.kotlin.codegen.AsmUtil.CAPTURED_RECEIVER_FIELD;
|
||||||
@@ -139,7 +139,7 @@ public interface LocalLookup {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
KtType receiverType = closure.getEnclosingReceiverDescriptor().getType();
|
KotlinType receiverType = closure.getEnclosingReceiverDescriptor().getType();
|
||||||
Type type = state.getTypeMapper().mapType(receiverType);
|
Type type = state.getTypeMapper().mapType(receiverType);
|
||||||
StackValue.StackValueWithSimpleReceiver innerValue = StackValue.field(type, classType, CAPTURED_RECEIVER_FIELD, false,
|
StackValue.StackValueWithSimpleReceiver innerValue = StackValue.field(type, classType, CAPTURED_RECEIVER_FIELD, false,
|
||||||
StackValue.LOCAL_0, d);
|
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.IntrinsicMethods
|
||||||
import org.jetbrains.kotlin.codegen.intrinsics.TypeIntrinsics
|
import org.jetbrains.kotlin.codegen.intrinsics.TypeIntrinsics
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
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.MethodVisitor
|
||||||
import org.jetbrains.org.objectweb.asm.Opcodes
|
import org.jetbrains.org.objectweb.asm.Opcodes
|
||||||
import org.jetbrains.org.objectweb.asm.Type
|
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) =
|
private fun processNewArray(insn: MethodInsnNode, parameter: Type) =
|
||||||
processNextTypeInsn(insn, parameter, Opcodes.ANEWARRAY)
|
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 ->
|
rewriteNextTypeInsn(insn, Opcodes.CHECKCAST) { instanceofInsn: AbstractInsnNode ->
|
||||||
if (instanceofInsn !is TypeInsnNode) return false
|
if (instanceofInsn !is TypeInsnNode) return false
|
||||||
TypeIntrinsics.checkcast(instanceofInsn, instructions, jetType, asmType, safe)
|
TypeIntrinsics.checkcast(instanceofInsn, instructions, jetType, asmType, safe)
|
||||||
return true
|
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 ->
|
rewriteNextTypeInsn(insn, Opcodes.INSTANCEOF) { instanceofInsn: AbstractInsnNode ->
|
||||||
if (instanceofInsn !is TypeInsnNode) return false
|
if (instanceofInsn !is TypeInsnNode) return false
|
||||||
TypeIntrinsics.instanceOf(instanceofInsn, instructions, jetType, asmType)
|
TypeIntrinsics.instanceOf(instanceofInsn, instructions, jetType, asmType)
|
||||||
@@ -213,7 +213,7 @@ public class ReifiedTypeInliner(private val parametersMapping: ReifiedTypeParame
|
|||||||
public class ReifiedTypeParameterMappings() {
|
public class ReifiedTypeParameterMappings() {
|
||||||
private val mappingsByName = hashMapOf<String, ReifiedTypeParameterMapping>()
|
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)
|
mappingsByName[name] = ReifiedTypeParameterMapping(name, type, asmType, newName = null, signature = signature)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,7 +227,7 @@ public class ReifiedTypeParameterMappings() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public class ReifiedTypeParameterMapping(
|
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 {
|
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.calls.model.ResolvedCall
|
||||||
import org.jetbrains.kotlin.resolve.jvm.AsmTypes
|
import org.jetbrains.kotlin.resolve.jvm.AsmTypes
|
||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver
|
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.Type
|
||||||
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
|
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
|
val typeDescriptor = type.constructor.declarationDescriptor
|
||||||
return typeDescriptor is TypeParameterDescriptor && typeDescriptor.isReified
|
return typeDescriptor is TypeParameterDescriptor && typeDescriptor.isReified
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
package org.jetbrains.kotlin.codegen.intrinsics
|
package org.jetbrains.kotlin.codegen.intrinsics
|
||||||
|
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||||
import org.jetbrains.kotlin.types.KtType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
import org.jetbrains.kotlin.types.TypeUtils
|
import org.jetbrains.kotlin.types.TypeUtils
|
||||||
import org.jetbrains.org.objectweb.asm.Opcodes
|
import org.jetbrains.org.objectweb.asm.Opcodes
|
||||||
import org.jetbrains.org.objectweb.asm.Type
|
import org.jetbrains.org.objectweb.asm.Type
|
||||||
@@ -26,7 +26,7 @@ import org.jetbrains.org.objectweb.asm.tree.*
|
|||||||
import kotlin.text.Regex
|
import kotlin.text.Regex
|
||||||
|
|
||||||
public object TypeIntrinsics {
|
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)
|
val functionTypeArity = getFunctionTypeArity(jetType)
|
||||||
if (functionTypeArity >= 0) {
|
if (functionTypeArity >= 0) {
|
||||||
v.iconst(functionTypeArity)
|
v.iconst(functionTypeArity)
|
||||||
@@ -57,7 +57,7 @@ public object TypeIntrinsics {
|
|||||||
LdcInsnNode(Integer(value))
|
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)
|
val functionTypeArity = getFunctionTypeArity(jetType)
|
||||||
if (functionTypeArity >= 0) {
|
if (functionTypeArity >= 0) {
|
||||||
instructions.insertBefore(instanceofInsn, iconstNode(functionTypeArity))
|
instructions.insertBefore(instanceofInsn, iconstNode(functionTypeArity))
|
||||||
@@ -78,7 +78,7 @@ public object TypeIntrinsics {
|
|||||||
instanceofInsn.desc = asmType.internalName
|
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) {
|
if (safe) {
|
||||||
v.checkcast(asmType)
|
v.checkcast(asmType)
|
||||||
return
|
return
|
||||||
@@ -106,7 +106,7 @@ public object TypeIntrinsics {
|
|||||||
v.checkcast(asmType)
|
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) {
|
if (safe) {
|
||||||
checkcastInsn.desc = asmType.internalName
|
checkcastInsn.desc = asmType.internalName
|
||||||
return
|
return
|
||||||
@@ -159,7 +159,7 @@ public object TypeIntrinsics {
|
|||||||
private val IS_MUTABLE_COLLECTION_METHOD_DESCRIPTOR =
|
private val IS_MUTABLE_COLLECTION_METHOD_DESCRIPTOR =
|
||||||
Type.getMethodDescriptor(Type.BOOLEAN_TYPE, Type.getObjectType("java/lang/Object"))
|
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
|
val classDescriptor = TypeUtils.getClassDescriptor(jetType) ?: return null
|
||||||
return DescriptorUtils.getFqName(classDescriptor).asString()
|
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
|
* @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 classFqName = getClassFqName(jetType) ?: return -1
|
||||||
val match = KOTLIN_FUNCTION_INTERFACE_REGEX.match(classFqName) ?: return -1
|
val match = KOTLIN_FUNCTION_INTERFACE_REGEX.match(classFqName) ?: return -1
|
||||||
return Integer.valueOf(match.groups[1]!!.value)
|
return Integer.valueOf(match.groups[1]!!.value)
|
||||||
@@ -182,7 +182,7 @@ public object TypeIntrinsics {
|
|||||||
invokestatic(INTRINSICS_CLASS, methodName, methodDescriptor, false)
|
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)]
|
IS_MUTABLE_COLLECTION_METHOD_NAME[getClassFqName(jetType)]
|
||||||
|
|
||||||
private val CHECKCAST_METHOD_NAME = hashMapOf(
|
private val CHECKCAST_METHOD_NAME = hashMapOf(
|
||||||
@@ -196,7 +196,7 @@ public object TypeIntrinsics {
|
|||||||
"kotlin.MutableMap.MutableEntry" to "asMutableMapEntry"
|
"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 classDescriptor = TypeUtils.getClassDescriptor(jetType) ?: return null
|
||||||
val classFqName = DescriptorUtils.getFqName(classDescriptor).asString()
|
val classFqName = DescriptorUtils.getFqName(classDescriptor).asString()
|
||||||
return CHECKCAST_METHOD_NAME[classFqName]
|
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.StringTable;
|
||||||
import org.jetbrains.kotlin.serialization.jvm.JvmProtoBuf;
|
import org.jetbrains.kotlin.serialization.jvm.JvmProtoBuf;
|
||||||
import org.jetbrains.kotlin.serialization.jvm.JvmProtoBufUtil;
|
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.Type;
|
||||||
import org.jetbrains.org.objectweb.asm.commons.Method;
|
import org.jetbrains.org.objectweb.asm.commons.Method;
|
||||||
|
|
||||||
@@ -70,7 +70,7 @@ public class JvmSerializerExtension extends SerializerExtension {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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
|
// TODO: don't store type annotations in our binary metadata on Java 8, use *TypeAnnotations attributes instead
|
||||||
for (AnnotationDescriptor annotation : type.getAnnotations()) {
|
for (AnnotationDescriptor annotation : type.getAnnotations()) {
|
||||||
proto.addExtension(JvmProtoBuf.typeAnnotation, annotationSerializer.serializeAnnotation(annotation));
|
proto.addExtension(JvmProtoBuf.typeAnnotation, annotationSerializer.serializeAnnotation(annotation));
|
||||||
@@ -200,7 +200,7 @@ public class JvmSerializerExtension extends SerializerExtension {
|
|||||||
|
|
||||||
sb.append(")");
|
sb.append(")");
|
||||||
|
|
||||||
KtType returnType = descriptor.getReturnType();
|
KotlinType returnType = descriptor.getReturnType();
|
||||||
String returnTypeDesc = returnType == null ? "V" : mapTypeDefault(returnType);
|
String returnTypeDesc = returnType == null ? "V" : mapTypeDefault(returnType);
|
||||||
if (returnTypeDesc == null) return true;
|
if (returnTypeDesc == null) return true;
|
||||||
sb.append(returnTypeDesc);
|
sb.append(returnTypeDesc);
|
||||||
@@ -213,7 +213,7 @@ public class JvmSerializerExtension extends SerializerExtension {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private String mapTypeDefault(@NotNull KtType type) {
|
private String mapTypeDefault(@NotNull KotlinType type) {
|
||||||
ClassifierDescriptor classifier = type.getConstructor().getDeclarationDescriptor();
|
ClassifierDescriptor classifier = type.getConstructor().getDeclarationDescriptor();
|
||||||
if (!(classifier instanceof ClassDescriptor)) return null;
|
if (!(classifier instanceof ClassDescriptor)) return null;
|
||||||
ClassId classId = classId((ClassDescriptor) classifier);
|
ClassId classId = classId((ClassDescriptor) classifier);
|
||||||
|
|||||||
@@ -342,7 +342,7 @@ public class JetTypeMapper {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private Type mapReturnType(@NotNull CallableDescriptor descriptor, @Nullable BothSignatureWriter sw) {
|
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;
|
assert returnType != null : "Function has no return type: " + descriptor;
|
||||||
|
|
||||||
if (descriptor instanceof ConstructorDescriptor) {
|
if (descriptor instanceof ConstructorDescriptor) {
|
||||||
@@ -370,17 +370,17 @@ public class JetTypeMapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private Type mapType(@NotNull KtType jetType, @NotNull JetTypeMapperMode mode) {
|
private Type mapType(@NotNull KotlinType jetType, @NotNull JetTypeMapperMode mode) {
|
||||||
return mapType(jetType, null, mode);
|
return mapType(jetType, null, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@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);
|
return mapType(jetType, signatureVisitor, JetTypeMapperMode.SUPER_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@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);
|
return mapType(jetType, signatureVisitor, JetTypeMapperMode.TYPE_PARAMETER);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -390,7 +390,7 @@ public class JetTypeMapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public Type mapType(@NotNull KtType jetType) {
|
public Type mapType(@NotNull KotlinType jetType) {
|
||||||
return mapType(jetType, null, JetTypeMapperMode.VALUE);
|
return mapType(jetType, null, JetTypeMapperMode.VALUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -415,13 +415,13 @@ public class JetTypeMapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@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);
|
return mapType(jetType, signatureVisitor, mode, Variance.INVARIANT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private Type mapType(
|
private Type mapType(
|
||||||
@NotNull KtType jetType,
|
@NotNull KotlinType jetType,
|
||||||
@Nullable BothSignatureWriter signatureVisitor,
|
@Nullable BothSignatureWriter signatureVisitor,
|
||||||
@NotNull JetTypeMapperMode kind,
|
@NotNull JetTypeMapperMode kind,
|
||||||
@NotNull Variance howThisTypeIsUsed
|
@NotNull Variance howThisTypeIsUsed
|
||||||
@@ -450,7 +450,7 @@ public class JetTypeMapper {
|
|||||||
TypeConstructor constructor = jetType.getConstructor();
|
TypeConstructor constructor = jetType.getConstructor();
|
||||||
DeclarationDescriptor descriptor = constructor.getDeclarationDescriptor();
|
DeclarationDescriptor descriptor = constructor.getDeclarationDescriptor();
|
||||||
if (constructor instanceof IntersectionTypeConstructor) {
|
if (constructor instanceof IntersectionTypeConstructor) {
|
||||||
jetType = CommonSupertypes.commonSupertype(new ArrayList<KtType>(constructor.getSupertypes()));
|
jetType = CommonSupertypes.commonSupertype(new ArrayList<KotlinType>(constructor.getSupertypes()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (descriptor == null) {
|
if (descriptor == null) {
|
||||||
@@ -473,7 +473,7 @@ public class JetTypeMapper {
|
|||||||
throw new UnsupportedOperationException("arrays must have one type argument");
|
throw new UnsupportedOperationException("arrays must have one type argument");
|
||||||
}
|
}
|
||||||
TypeProjection memberProjection = jetType.getArguments().get(0);
|
TypeProjection memberProjection = jetType.getArguments().get(0);
|
||||||
KtType memberType = memberProjection.getType();
|
KotlinType memberType = memberProjection.getType();
|
||||||
|
|
||||||
Type arrayElementType;
|
Type arrayElementType;
|
||||||
if (memberProjection.getProjectionKind() == Variance.IN_VARIANCE) {
|
if (memberProjection.getProjectionKind() == Variance.IN_VARIANCE) {
|
||||||
@@ -520,7 +520,7 @@ public class JetTypeMapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private static Type mapBuiltinType(@NotNull KtType type) {
|
private static Type mapBuiltinType(@NotNull KotlinType type) {
|
||||||
DeclarationDescriptor descriptor = type.getConstructor().getDeclarationDescriptor();
|
DeclarationDescriptor descriptor = type.getConstructor().getDeclarationDescriptor();
|
||||||
if (!(descriptor instanceof ClassDescriptor)) return null;
|
if (!(descriptor instanceof ClassDescriptor)) return null;
|
||||||
|
|
||||||
@@ -583,7 +583,7 @@ public class JetTypeMapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@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);
|
PsiElement declarationElement = DescriptorToSourceUtils.descriptorToDeclaration(descriptor);
|
||||||
|
|
||||||
if (declarationElement == null) {
|
if (declarationElement == null) {
|
||||||
@@ -616,7 +616,7 @@ public class JetTypeMapper {
|
|||||||
private void writeGenericType(
|
private void writeGenericType(
|
||||||
BothSignatureWriter signatureVisitor,
|
BothSignatureWriter signatureVisitor,
|
||||||
Type asmType,
|
Type asmType,
|
||||||
KtType jetType,
|
KotlinType jetType,
|
||||||
Variance howThisTypeIsUsed,
|
Variance howThisTypeIsUsed,
|
||||||
boolean projectionsAllowed
|
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>() {
|
boolean hasNothingInArguments = CollectionsKt.any(jetType.getArguments(), new Function1<TypeProjection, Boolean>() {
|
||||||
@Override
|
@Override
|
||||||
public Boolean invoke(TypeProjection projection) {
|
public Boolean invoke(TypeProjection projection) {
|
||||||
@@ -691,7 +691,7 @@ public class JetTypeMapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Type mapKnownAsmType(
|
private Type mapKnownAsmType(
|
||||||
KtType jetType,
|
KotlinType jetType,
|
||||||
Type asmType,
|
Type asmType,
|
||||||
@Nullable BothSignatureWriter signatureVisitor,
|
@Nullable BothSignatureWriter signatureVisitor,
|
||||||
@NotNull Variance howThisTypeIsUsed
|
@NotNull Variance howThisTypeIsUsed
|
||||||
@@ -700,7 +700,7 @@ public class JetTypeMapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Type mapKnownAsmType(
|
private Type mapKnownAsmType(
|
||||||
KtType jetType,
|
KotlinType jetType,
|
||||||
Type asmType,
|
Type asmType,
|
||||||
@Nullable BothSignatureWriter signatureVisitor,
|
@Nullable BothSignatureWriter signatureVisitor,
|
||||||
@NotNull Variance howThisTypeIsUsed,
|
@NotNull Variance howThisTypeIsUsed,
|
||||||
@@ -1092,7 +1092,7 @@ public class JetTypeMapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public String mapFieldSignature(@NotNull KtType backingFieldType) {
|
public String mapFieldSignature(@NotNull KotlinType backingFieldType) {
|
||||||
BothSignatureWriter sw = new BothSignatureWriter(BothSignatureWriter.Mode.TYPE);
|
BothSignatureWriter sw = new BothSignatureWriter(BothSignatureWriter.Mode.TYPE);
|
||||||
mapType(backingFieldType, sw, JetTypeMapperMode.VALUE);
|
mapType(backingFieldType, sw, JetTypeMapperMode.VALUE);
|
||||||
return sw.makeJavaGenericSignature();
|
return sw.makeJavaGenericSignature();
|
||||||
@@ -1143,7 +1143,7 @@ public class JetTypeMapper {
|
|||||||
{
|
{
|
||||||
sw.writeClassBound();
|
sw.writeClassBound();
|
||||||
|
|
||||||
for (KtType jetType : typeParameterDescriptor.getUpperBounds()) {
|
for (KotlinType jetType : typeParameterDescriptor.getUpperBounds()) {
|
||||||
if (jetType.getConstructor().getDeclarationDescriptor() instanceof ClassDescriptor) {
|
if (jetType.getConstructor().getDeclarationDescriptor() instanceof ClassDescriptor) {
|
||||||
if (!isJvmInterface(jetType)) {
|
if (!isJvmInterface(jetType)) {
|
||||||
mapType(jetType, sw, JetTypeMapperMode.TYPE_PARAMETER);
|
mapType(jetType, sw, JetTypeMapperMode.TYPE_PARAMETER);
|
||||||
@@ -1159,7 +1159,7 @@ public class JetTypeMapper {
|
|||||||
}
|
}
|
||||||
sw.writeClassBoundEnd();
|
sw.writeClassBoundEnd();
|
||||||
|
|
||||||
for (KtType jetType : typeParameterDescriptor.getUpperBounds()) {
|
for (KotlinType jetType : typeParameterDescriptor.getUpperBounds()) {
|
||||||
ClassifierDescriptor classifier = jetType.getConstructor().getDeclarationDescriptor();
|
ClassifierDescriptor classifier = jetType.getConstructor().getDeclarationDescriptor();
|
||||||
if (classifier instanceof ClassDescriptor) {
|
if (classifier instanceof ClassDescriptor) {
|
||||||
if (isJvmInterface(jetType)) {
|
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);
|
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);
|
sw.writeParameterType(kind);
|
||||||
mapType(type, sw, JetTypeMapperMode.VALUE);
|
mapType(type, sw, JetTypeMapperMode.VALUE);
|
||||||
sw.writeParameterTypeEnd();
|
sw.writeParameterTypeEnd();
|
||||||
@@ -1203,7 +1203,7 @@ public class JetTypeMapper {
|
|||||||
writeParameter(sw, JvmMethodParameterKind.OUTER, captureThis.getDefaultType());
|
writeParameter(sw, JvmMethodParameterKind.OUTER, captureThis.getDefaultType());
|
||||||
}
|
}
|
||||||
|
|
||||||
KtType captureReceiverType = closure != null ? closure.getCaptureReceiverType() : null;
|
KotlinType captureReceiverType = closure != null ? closure.getCaptureReceiverType() : null;
|
||||||
if (captureReceiverType != null) {
|
if (captureReceiverType != null) {
|
||||||
writeParameter(sw, JvmMethodParameterKind.RECEIVER, captureReceiverType);
|
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.BindingContext;
|
||||||
import org.jetbrains.kotlin.resolve.constants.ConstantValue;
|
import org.jetbrains.kotlin.resolve.constants.ConstantValue;
|
||||||
import org.jetbrains.kotlin.resolve.constants.NullValue;
|
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.kotlin.types.TypeUtils;
|
||||||
import org.jetbrains.org.objectweb.asm.Label;
|
import org.jetbrains.org.objectweb.asm.Label;
|
||||||
import org.jetbrains.org.objectweb.asm.Type;
|
import org.jetbrains.org.objectweb.asm.Type;
|
||||||
@@ -131,7 +131,7 @@ abstract public class SwitchCodegen {
|
|||||||
|
|
||||||
protected void generateNullCheckIfNeeded() {
|
protected void generateNullCheckIfNeeded() {
|
||||||
assert expression.getSubjectExpression() != null : "subject expression can't be null";
|
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)";
|
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.constants.NullValue
|
||||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||||
import org.jetbrains.kotlin.serialization.*
|
import org.jetbrains.kotlin.serialization.*
|
||||||
import org.jetbrains.kotlin.types.KtType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
|
|
||||||
public class BuiltInsSerializerExtension : SerializerExtension() {
|
public class BuiltInsSerializerExtension : SerializerExtension() {
|
||||||
private val stringTable = StringTableImpl()
|
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) {
|
for (annotation in type.annotations) {
|
||||||
proto.addExtension(BuiltInsProtoBuf.typeAnnotation, annotationSerializer.serializeAnnotation(annotation))
|
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.name.Name;
|
||||||
import org.jetbrains.kotlin.resolve.AnalyzerScriptParameter;
|
import org.jetbrains.kotlin.resolve.AnalyzerScriptParameter;
|
||||||
import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform;
|
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.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -35,7 +35,7 @@ public class CommandLineScriptUtils {
|
|||||||
|
|
||||||
public static List<AnalyzerScriptParameter> scriptParameters() {
|
public static List<AnalyzerScriptParameter> scriptParameters() {
|
||||||
KotlinBuiltIns builtIns = JvmPlatform.INSTANCE$.getBuiltIns();
|
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);
|
AnalyzerScriptParameter argsParameter = new AnalyzerScriptParameter(ARGS_NAME, arrayOfStrings);
|
||||||
return Collections.singletonList(argsParameter);
|
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.data.JetClassLikeInfo;
|
||||||
import org.jetbrains.kotlin.resolve.lazy.declarations.*;
|
import org.jetbrains.kotlin.resolve.lazy.declarations.*;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.KtScope;
|
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.kotlin.utils.ExceptionUtilsKt;
|
||||||
import org.jetbrains.org.objectweb.asm.Type;
|
import org.jetbrains.org.objectweb.asm.Type;
|
||||||
|
|
||||||
@@ -356,7 +356,7 @@ public class ReplInterpreter {
|
|||||||
|
|
||||||
earlierLines.add(new EarlierLine(line, scriptDescriptor, scriptClass, scriptInstance, scriptClassType));
|
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));
|
return LineResult.successful(rv, returnType != null && KotlinBuiltIns.isUnit(returnType));
|
||||||
}
|
}
|
||||||
catch (Throwable e) {
|
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.context.ResolutionContext
|
||||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory
|
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory
|
||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
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.TypeUtils
|
||||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
|
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
|
||||||
import org.jetbrains.kotlin.types.upperIfFlexible
|
import org.jetbrains.kotlin.types.upperIfFlexible
|
||||||
@@ -36,20 +36,20 @@ public class RuntimeAssertionInfo(public val needNotNullAssertion: Boolean, publ
|
|||||||
public interface DataFlowExtras {
|
public interface DataFlowExtras {
|
||||||
class OnlyMessage(message: String) : DataFlowExtras {
|
class OnlyMessage(message: String) : DataFlowExtras {
|
||||||
override val canBeNull: Boolean get() = true
|
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
|
override val presentableText: String = message
|
||||||
}
|
}
|
||||||
|
|
||||||
val canBeNull: Boolean
|
val canBeNull: Boolean
|
||||||
val possibleTypes: Set<KtType>
|
val possibleTypes: Set<KotlinType>
|
||||||
val presentableText: String
|
val presentableText: String
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
public fun create(
|
public fun create(
|
||||||
expectedType: KtType,
|
expectedType: KotlinType,
|
||||||
expressionType: KtType,
|
expressionType: KotlinType,
|
||||||
dataFlowExtras: DataFlowExtras
|
dataFlowExtras: DataFlowExtras
|
||||||
): RuntimeAssertionInfo? {
|
): RuntimeAssertionInfo? {
|
||||||
fun assertNotNull(): Boolean {
|
fun assertNotNull(): Boolean {
|
||||||
@@ -78,13 +78,13 @@ public class RuntimeAssertionInfo(public val needNotNullAssertion: Boolean, publ
|
|||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun KtType.hasEnhancedNullability()
|
private fun KotlinType.hasEnhancedNullability()
|
||||||
= getAnnotations().findAnnotation(JvmAnnotationNames.ENHANCED_NULLABILITY_ANNOTATION) != null
|
= getAnnotations().findAnnotation(JvmAnnotationNames.ENHANCED_NULLABILITY_ANNOTATION) != null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public object RuntimeAssertionsTypeChecker : AdditionalTypeChecker {
|
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
|
if (TypeUtils.noExpectedType(c.expectedType)) return
|
||||||
|
|
||||||
val assertionInfo = RuntimeAssertionInfo.create(
|
val assertionInfo = RuntimeAssertionInfo.create(
|
||||||
@@ -93,7 +93,7 @@ public object RuntimeAssertionsTypeChecker : AdditionalTypeChecker {
|
|||||||
object : RuntimeAssertionInfo.DataFlowExtras {
|
object : RuntimeAssertionInfo.DataFlowExtras {
|
||||||
override val canBeNull: Boolean
|
override val canBeNull: Boolean
|
||||||
get() = c.dataFlowInfo.getNullability(dataFlowValue).canBeNull()
|
get() = c.dataFlowInfo.getNullability(dataFlowValue).canBeNull()
|
||||||
override val possibleTypes: Set<KtType>
|
override val possibleTypes: Set<KotlinType>
|
||||||
get() = c.dataFlowInfo.getPossibleTypes(dataFlowValue)
|
get() = c.dataFlowInfo.getPossibleTypes(dataFlowValue)
|
||||||
override val presentableText: String
|
override val presentableText: String
|
||||||
get() = StringUtil.trimMiddle(expression.getText(), 50)
|
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.AlternativeFieldSignatureData;
|
||||||
import org.jetbrains.kotlin.resolve.jvm.kotlinSignature.AlternativeMethodSignatureData;
|
import org.jetbrains.kotlin.resolve.jvm.kotlinSignature.AlternativeMethodSignatureData;
|
||||||
import org.jetbrains.kotlin.resolve.jvm.kotlinSignature.SignaturesPropagationData;
|
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.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -55,8 +55,8 @@ public class TraceBasedExternalSignatureResolver implements ExternalSignatureRes
|
|||||||
public PropagatedMethodSignature resolvePropagatedSignature(
|
public PropagatedMethodSignature resolvePropagatedSignature(
|
||||||
@NotNull JavaMethod method,
|
@NotNull JavaMethod method,
|
||||||
@NotNull ClassDescriptor owner,
|
@NotNull ClassDescriptor owner,
|
||||||
@NotNull KtType returnType,
|
@NotNull KotlinType returnType,
|
||||||
@Nullable KtType receiverType,
|
@Nullable KotlinType receiverType,
|
||||||
@NotNull List<ValueParameterDescriptor> valueParameters,
|
@NotNull List<ValueParameterDescriptor> valueParameters,
|
||||||
@NotNull List<TypeParameterDescriptor> typeParameters
|
@NotNull List<TypeParameterDescriptor> typeParameters
|
||||||
) {
|
) {
|
||||||
@@ -72,8 +72,8 @@ public class TraceBasedExternalSignatureResolver implements ExternalSignatureRes
|
|||||||
public AlternativeMethodSignature resolveAlternativeMethodSignature(
|
public AlternativeMethodSignature resolveAlternativeMethodSignature(
|
||||||
@NotNull JavaMember methodOrConstructor,
|
@NotNull JavaMember methodOrConstructor,
|
||||||
boolean hasSuperMethods,
|
boolean hasSuperMethods,
|
||||||
@Nullable KtType returnType,
|
@Nullable KotlinType returnType,
|
||||||
@Nullable KtType receiverType,
|
@Nullable KotlinType receiverType,
|
||||||
@NotNull List<ValueParameterDescriptor> valueParameters,
|
@NotNull List<ValueParameterDescriptor> valueParameters,
|
||||||
@NotNull List<TypeParameterDescriptor> typeParameters,
|
@NotNull List<TypeParameterDescriptor> typeParameters,
|
||||||
boolean hasStableParameterNames
|
boolean hasStableParameterNames
|
||||||
@@ -102,7 +102,7 @@ public class TraceBasedExternalSignatureResolver implements ExternalSignatureRes
|
|||||||
@NotNull
|
@NotNull
|
||||||
public AlternativeFieldSignature resolveAlternativeFieldSignature(
|
public AlternativeFieldSignature resolveAlternativeFieldSignature(
|
||||||
@NotNull JavaField field,
|
@NotNull JavaField field,
|
||||||
@NotNull KtType returnType,
|
@NotNull KotlinType returnType,
|
||||||
boolean isVar
|
boolean isVar
|
||||||
) {
|
) {
|
||||||
AlternativeFieldSignatureData data = new AlternativeFieldSignatureData(field, returnType, project, 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.*;
|
||||||
import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl;
|
import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl;
|
||||||
import org.jetbrains.kotlin.resolve.ExternalOverridabilityCondition;
|
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.TypeSubstitutor;
|
||||||
import org.jetbrains.kotlin.types.TypeUtils;
|
import org.jetbrains.kotlin.types.TypeUtils;
|
||||||
|
|
||||||
@@ -57,7 +57,7 @@ public class SamAdapterOverridabilityCondition implements ExternalOverridability
|
|||||||
return true;
|
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();
|
DeclarationDescriptor declarationDescriptor1 = type1.getConstructor().getDeclarationDescriptor();
|
||||||
if (declarationDescriptor1 == null) return true; // No class, classes are not equal
|
if (declarationDescriptor1 == null) return true; // No class, classes are not equal
|
||||||
DeclarationDescriptor declarationDescriptor2 = type2.getConstructor().getDeclarationDescriptor();
|
DeclarationDescriptor declarationDescriptor2 = type2.getConstructor().getDeclarationDescriptor();
|
||||||
@@ -100,7 +100,7 @@ public class SamAdapterOverridabilityCondition implements ExternalOverridability
|
|||||||
@Nullable
|
@Nullable
|
||||||
private static SamAdapterInfo getNearestDeclarationOrSynthesized(
|
private static SamAdapterInfo getNearestDeclarationOrSynthesized(
|
||||||
@NotNull SimpleFunctionDescriptor samAdapter,
|
@NotNull SimpleFunctionDescriptor samAdapter,
|
||||||
@NotNull KtType ownerType
|
@NotNull KotlinType ownerType
|
||||||
) {
|
) {
|
||||||
if (samAdapter.getKind() != CallableMemberDescriptor.Kind.FAKE_OVERRIDE) {
|
if (samAdapter.getKind() != CallableMemberDescriptor.Kind.FAKE_OVERRIDE) {
|
||||||
return new SamAdapterInfo(samAdapter, ownerType);
|
return new SamAdapterInfo(samAdapter, ownerType);
|
||||||
@@ -109,7 +109,7 @@ public class SamAdapterOverridabilityCondition implements ExternalOverridability
|
|||||||
for (CallableMemberDescriptor overridden : samAdapter.getOverriddenDescriptors()) {
|
for (CallableMemberDescriptor overridden : samAdapter.getOverriddenDescriptors()) {
|
||||||
ClassDescriptor containingClass = (ClassDescriptor) overridden.getContainingDeclaration();
|
ClassDescriptor containingClass = (ClassDescriptor) overridden.getContainingDeclaration();
|
||||||
|
|
||||||
for (KtType immediateSupertype : TypeUtils.getImmediateSupertypes(ownerType)) {
|
for (KotlinType immediateSupertype : TypeUtils.getImmediateSupertypes(ownerType)) {
|
||||||
if (containingClass != immediateSupertype.getConstructor().getDeclarationDescriptor()) {
|
if (containingClass != immediateSupertype.getConstructor().getDeclarationDescriptor()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -126,9 +126,9 @@ public class SamAdapterOverridabilityCondition implements ExternalOverridability
|
|||||||
|
|
||||||
private static class SamAdapterInfo {
|
private static class SamAdapterInfo {
|
||||||
private final SimpleFunctionDescriptor samAdapter;
|
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.samAdapter = samAdapter;
|
||||||
this.ownerType = ownerType;
|
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.load.java.lazy.descriptors.LazyJavaClassDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||||
import org.jetbrains.kotlin.load.java.structure.JavaMethod
|
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.sources.JavaSourceElement
|
||||||
import org.jetbrains.kotlin.load.java.structure.JavaClass
|
import org.jetbrains.kotlin.load.java.structure.JavaClass
|
||||||
import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor
|
import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor
|
||||||
@@ -51,7 +51,7 @@ public object SamConversionResolverImpl : SamConversionResolver {
|
|||||||
override fun resolveFunctionTypeIfSamInterface(
|
override fun resolveFunctionTypeIfSamInterface(
|
||||||
classDescriptor: JavaClassDescriptor,
|
classDescriptor: JavaClassDescriptor,
|
||||||
resolveMethod: (JavaMethod) -> FunctionDescriptor
|
resolveMethod: (JavaMethod) -> FunctionDescriptor
|
||||||
): KtType? {
|
): KotlinType? {
|
||||||
val jClass = (classDescriptor.getSource() as? JavaSourceElement)?.javaElement as? JavaClass ?: return null
|
val jClass = (classDescriptor.getSource() as? JavaSourceElement)?.javaElement as? JavaClass ?: return null
|
||||||
val samInterfaceMethod = SingleAbstractMethodUtils.getSamInterfaceMethod(jClass) ?: return null
|
val samInterfaceMethod = SingleAbstractMethodUtils.getSamInterfaceMethod(jClass) ?: return null
|
||||||
val abstractMethod = if (jClass.getFqName() == samInterfaceMethod.getContainingClass().getFqName()) {
|
val abstractMethod = if (jClass.getFqName() == samInterfaceMethod.getContainingClass().getFqName()) {
|
||||||
@@ -63,7 +63,7 @@ public object SamConversionResolverImpl : SamConversionResolver {
|
|||||||
return SingleAbstractMethodUtils.getFunctionTypeForAbstractMethod(abstractMethod)
|
return SingleAbstractMethodUtils.getFunctionTypeForAbstractMethod(abstractMethod)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun findFunctionWithMostSpecificReturnType(supertypes: Set<KtType>): SimpleFunctionDescriptor {
|
private fun findFunctionWithMostSpecificReturnType(supertypes: Set<KotlinType>): SimpleFunctionDescriptor {
|
||||||
val candidates = ArrayList<SimpleFunctionDescriptor>(supertypes.size())
|
val candidates = ArrayList<SimpleFunctionDescriptor>(supertypes.size())
|
||||||
for (supertype in supertypes) {
|
for (supertype in supertypes) {
|
||||||
val abstractMembers = SingleAbstractMethodUtils.getAbstractMembers(supertype)
|
val abstractMembers = SingleAbstractMethodUtils.getAbstractMembers(supertype)
|
||||||
|
|||||||
+25
-25
@@ -43,7 +43,7 @@ public class SingleAbstractMethodUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static List<CallableMemberDescriptor> getAbstractMembers(@NotNull KtType type) {
|
public static List<CallableMemberDescriptor> getAbstractMembers(@NotNull KotlinType type) {
|
||||||
List<CallableMemberDescriptor> abstractMembers = new ArrayList<CallableMemberDescriptor>();
|
List<CallableMemberDescriptor> abstractMembers = new ArrayList<CallableMemberDescriptor>();
|
||||||
for (DeclarationDescriptor member : type.getMemberScope().getAllDescriptors()) {
|
for (DeclarationDescriptor member : type.getMemberScope().getAllDescriptors()) {
|
||||||
if (member instanceof CallableMemberDescriptor && ((CallableMemberDescriptor) member).getModality() == Modality.ABSTRACT) {
|
if (member instanceof CallableMemberDescriptor && ((CallableMemberDescriptor) member).getModality() == Modality.ABSTRACT) {
|
||||||
@@ -53,7 +53,7 @@ public class SingleAbstractMethodUtils {
|
|||||||
return abstractMembers;
|
return abstractMembers;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static KtType fixProjections(@NotNull KtType functionType) {
|
private static KotlinType fixProjections(@NotNull KotlinType functionType) {
|
||||||
//removes redundant projection kinds and detects conflicts
|
//removes redundant projection kinds and detects conflicts
|
||||||
|
|
||||||
List<TypeParameterDescriptor> typeParameters = functionType.getConstructor().getParameters();
|
List<TypeParameterDescriptor> typeParameters = functionType.getConstructor().getParameters();
|
||||||
@@ -76,7 +76,7 @@ public class SingleAbstractMethodUtils {
|
|||||||
}
|
}
|
||||||
ClassifierDescriptor classifier = functionType.getConstructor().getDeclarationDescriptor();
|
ClassifierDescriptor classifier = functionType.getConstructor().getDeclarationDescriptor();
|
||||||
assert classifier instanceof ClassDescriptor : "Not class: " + classifier;
|
assert classifier instanceof ClassDescriptor : "Not class: " + classifier;
|
||||||
return KtTypeImpl.create(
|
return KotlinTypeImpl.create(
|
||||||
functionType.getAnnotations(),
|
functionType.getAnnotations(),
|
||||||
functionType.getConstructor(),
|
functionType.getConstructor(),
|
||||||
functionType.isMarkedNullable(),
|
functionType.isMarkedNullable(),
|
||||||
@@ -86,21 +86,21 @@ public class SingleAbstractMethodUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static KtType getFunctionTypeForSamType(@NotNull KtType samType) {
|
public static KotlinType getFunctionTypeForSamType(@NotNull KotlinType samType) {
|
||||||
// e.g. samType == Comparator<String>?
|
// e.g. samType == Comparator<String>?
|
||||||
|
|
||||||
ClassifierDescriptor classifier = samType.getConstructor().getDeclarationDescriptor();
|
ClassifierDescriptor classifier = samType.getConstructor().getDeclarationDescriptor();
|
||||||
if (classifier instanceof JavaClassDescriptor) {
|
if (classifier instanceof JavaClassDescriptor) {
|
||||||
// Function2<T, T, Int>
|
// Function2<T, T, Int>
|
||||||
KtType functionTypeDefault = ((JavaClassDescriptor) classifier).getFunctionTypeForSamInterface();
|
KotlinType functionTypeDefault = ((JavaClassDescriptor) classifier).getFunctionTypeForSamInterface();
|
||||||
|
|
||||||
if (functionTypeDefault != null) {
|
if (functionTypeDefault != null) {
|
||||||
// Function2<String, String, Int>?
|
// 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;
|
if (substitute == null) return null;
|
||||||
|
|
||||||
KtType type = fixProjections(substitute);
|
KotlinType type = fixProjections(substitute);
|
||||||
if (type == null) return null;
|
if (type == null) return null;
|
||||||
|
|
||||||
if (JavaDescriptorResolverKt.getPLATFORM_TYPES() && FlexibleTypesKt.isNullabilityFlexible(samType)) {
|
if (JavaDescriptorResolverKt.getPLATFORM_TYPES() && FlexibleTypesKt.isNullabilityFlexible(samType)) {
|
||||||
@@ -114,11 +114,11 @@ public class SingleAbstractMethodUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static KtType getFunctionTypeForAbstractMethod(@NotNull FunctionDescriptor function) {
|
public static KotlinType getFunctionTypeForAbstractMethod(@NotNull FunctionDescriptor function) {
|
||||||
KtType returnType = function.getReturnType();
|
KotlinType returnType = function.getReturnType();
|
||||||
assert returnType != null : "function is not initialized: " + function;
|
assert returnType != null : "function is not initialized: " + function;
|
||||||
List<ValueParameterDescriptor> valueParameters = function.getValueParameters();
|
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) {
|
for (ValueParameterDescriptor parameter : valueParameters) {
|
||||||
parameterTypes.add(parameter.getType());
|
parameterTypes.add(parameter.getType());
|
||||||
}
|
}
|
||||||
@@ -151,9 +151,9 @@ public class SingleAbstractMethodUtils {
|
|||||||
|
|
||||||
TypeParameters typeParameters = recreateAndInitializeTypeParameters(samInterface.getTypeConstructor().getParameters(), result);
|
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();
|
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 +
|
assert parameterType != null : "couldn't substitute type: " + parameterTypeUnsubstituted +
|
||||||
", substitutor = " + typeParameters.substitutor;
|
", substitutor = " + typeParameters.substitutor;
|
||||||
ValueParameterDescriptor parameter = new ValueParameterDescriptorImpl(
|
ValueParameterDescriptor parameter = new ValueParameterDescriptorImpl(
|
||||||
@@ -163,7 +163,7 @@ public class SingleAbstractMethodUtils {
|
|||||||
/* isNoinline = */ false,
|
/* isNoinline = */ false,
|
||||||
null, SourceElement.NO_SOURCE);
|
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() +
|
assert returnType != null : "couldn't substitute type: " + samInterface.getDefaultType() +
|
||||||
", substitutor = " + typeParameters.substitutor;
|
", substitutor = " + typeParameters.substitutor;
|
||||||
|
|
||||||
@@ -180,7 +180,7 @@ public class SingleAbstractMethodUtils {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isSamType(@NotNull KtType type) {
|
public static boolean isSamType(@NotNull KotlinType type) {
|
||||||
return getFunctionTypeForSamType(type) != null;
|
return getFunctionTypeForSamType(type) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,7 +201,7 @@ public class SingleAbstractMethodUtils {
|
|||||||
public void initialize(
|
public void initialize(
|
||||||
@NotNull List<TypeParameterDescriptor> typeParameters,
|
@NotNull List<TypeParameterDescriptor> typeParameters,
|
||||||
@NotNull List<ValueParameterDescriptor> valueParameters,
|
@NotNull List<ValueParameterDescriptor> valueParameters,
|
||||||
@NotNull KtType returnType
|
@NotNull KotlinType returnType
|
||||||
) {
|
) {
|
||||||
result.initialize(
|
result.initialize(
|
||||||
null,
|
null,
|
||||||
@@ -224,7 +224,7 @@ public class SingleAbstractMethodUtils {
|
|||||||
public void initialize(
|
public void initialize(
|
||||||
@NotNull List<TypeParameterDescriptor> typeParameters,
|
@NotNull List<TypeParameterDescriptor> typeParameters,
|
||||||
@NotNull List<ValueParameterDescriptor> valueParameters,
|
@NotNull List<ValueParameterDescriptor> valueParameters,
|
||||||
@NotNull KtType returnType
|
@NotNull KotlinType returnType
|
||||||
) {
|
) {
|
||||||
result.initialize(typeParameters, valueParameters, original.getVisibility());
|
result.initialize(typeParameters, valueParameters, original.getVisibility());
|
||||||
result.setReturnType(returnType);
|
result.setReturnType(returnType);
|
||||||
@@ -240,11 +240,11 @@ public class SingleAbstractMethodUtils {
|
|||||||
) {
|
) {
|
||||||
TypeParameters typeParameters = recreateAndInitializeTypeParameters(original.getTypeParameters(), adapter);
|
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;
|
assert returnTypeUnsubstituted != null : "Creating SAM adapter for not initialized original: " + original;
|
||||||
|
|
||||||
TypeSubstitutor substitutor = typeParameters.substitutor;
|
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 +
|
assert returnType != null : "couldn't substitute type: " + returnTypeUnsubstituted +
|
||||||
", substitutor = " + substitutor;
|
", substitutor = " + substitutor;
|
||||||
|
|
||||||
@@ -264,10 +264,10 @@ public class SingleAbstractMethodUtils {
|
|||||||
List<ValueParameterDescriptor> originalValueParameters = original.getValueParameters();
|
List<ValueParameterDescriptor> originalValueParameters = original.getValueParameters();
|
||||||
List<ValueParameterDescriptor> valueParameters = new ArrayList<ValueParameterDescriptor>(originalValueParameters.size());
|
List<ValueParameterDescriptor> valueParameters = new ArrayList<ValueParameterDescriptor>(originalValueParameters.size());
|
||||||
for (ValueParameterDescriptor originalParam : originalValueParameters) {
|
for (ValueParameterDescriptor originalParam : originalValueParameters) {
|
||||||
KtType originalType = originalParam.getType();
|
KotlinType originalType = originalParam.getType();
|
||||||
KtType functionType = getFunctionTypeForSamType(originalType);
|
KotlinType functionType = getFunctionTypeForSamType(originalType);
|
||||||
KtType newTypeUnsubstituted = functionType != null ? functionType : originalType;
|
KotlinType newTypeUnsubstituted = functionType != null ? functionType : originalType;
|
||||||
KtType newType = substitutor.substitute(newTypeUnsubstituted, Variance.IN_VARIANCE);
|
KotlinType newType = substitutor.substitute(newTypeUnsubstituted, Variance.IN_VARIANCE);
|
||||||
assert newType != null : "couldn't substitute type: " + newTypeUnsubstituted + ", substitutor = " + substitutor;
|
assert newType != null : "couldn't substitute type: " + newTypeUnsubstituted + ", substitutor = " + substitutor;
|
||||||
|
|
||||||
ValueParameterDescriptor newParam = new ValueParameterDescriptorImpl(
|
ValueParameterDescriptor newParam = new ValueParameterDescriptorImpl(
|
||||||
@@ -295,8 +295,8 @@ public class SingleAbstractMethodUtils {
|
|||||||
TypeParameterDescriptor traitTypeParameter = mapEntry.getKey();
|
TypeParameterDescriptor traitTypeParameter = mapEntry.getKey();
|
||||||
TypeParameterDescriptorImpl funTypeParameter = mapEntry.getValue();
|
TypeParameterDescriptorImpl funTypeParameter = mapEntry.getValue();
|
||||||
|
|
||||||
for (KtType upperBound : traitTypeParameter.getUpperBounds()) {
|
for (KotlinType upperBound : traitTypeParameter.getUpperBounds()) {
|
||||||
KtType upperBoundSubstituted = typeParametersSubstitutor.substitute(upperBound, Variance.INVARIANT);
|
KotlinType upperBoundSubstituted = typeParametersSubstitutor.substitute(upperBound, Variance.INVARIANT);
|
||||||
assert upperBoundSubstituted != null : "couldn't substitute type: " + upperBound + ", substitutor = " + typeParametersSubstitutor;
|
assert upperBoundSubstituted != null : "couldn't substitute type: " + upperBound + ", substitutor = " + typeParametersSubstitutor;
|
||||||
funTypeParameter.addUpperBound(upperBoundSubstituted);
|
funTypeParameter.addUpperBound(upperBoundSubstituted);
|
||||||
}
|
}
|
||||||
@@ -345,7 +345,7 @@ public class SingleAbstractMethodUtils {
|
|||||||
public abstract void initialize(
|
public abstract void initialize(
|
||||||
@NotNull List<TypeParameterDescriptor> typeParameters,
|
@NotNull List<TypeParameterDescriptor> typeParameters,
|
||||||
@NotNull List<ValueParameterDescriptor> valueParameters,
|
@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.ResolvedCall
|
||||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedValueArgument
|
import org.jetbrains.kotlin.resolve.calls.model.ResolvedValueArgument
|
||||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm
|
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 org.jetbrains.kotlin.types.TypeUtils
|
||||||
import java.lang.annotation.Target
|
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.context.BasicCallResolutionContext
|
||||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm
|
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
|
import org.jetbrains.kotlin.types.TypeProjectionImpl
|
||||||
|
|
||||||
public class JavaClassOnCompanionChecker : CallChecker {
|
public class JavaClassOnCompanionChecker : CallChecker {
|
||||||
@@ -42,7 +42,7 @@ public class JavaClassOnCompanionChecker : CallChecker {
|
|||||||
if (companionObject.isCompanionObject) {
|
if (companionObject.isCompanionObject) {
|
||||||
val containingClass = companionObject.containingDeclaration as ClassDescriptor
|
val containingClass = companionObject.containingDeclaration as ClassDescriptor
|
||||||
val javaLangClass = actualType.constructor.declarationDescriptor as? ClassDescriptor ?: return
|
val javaLangClass = actualType.constructor.declarationDescriptor as? ClassDescriptor ?: return
|
||||||
val expectedType = KtTypeImpl.create(
|
val expectedType = KotlinTypeImpl.create(
|
||||||
Annotations.EMPTY, javaLangClass, actualType.isMarkedNullable,
|
Annotations.EMPTY, javaLangClass, actualType.isMarkedNullable,
|
||||||
listOf(TypeProjectionImpl(containingClass.defaultType))
|
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.jvm.diagnostics.ErrorsJvm
|
||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver
|
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver
|
||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
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.TypeUtils
|
||||||
import org.jetbrains.kotlin.types.expressions.SenselessComparisonChecker
|
import org.jetbrains.kotlin.types.expressions.SenselessComparisonChecker
|
||||||
import org.jetbrains.kotlin.types.flexibility
|
import org.jetbrains.kotlin.types.flexibility
|
||||||
import org.jetbrains.kotlin.types.isFlexible
|
import org.jetbrains.kotlin.types.isFlexible
|
||||||
|
|
||||||
public class JavaNullabilityWarningsChecker : AdditionalTypeChecker {
|
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 (!isError() && !isFlexible() && TypeUtils.isNullableType(this)) return ErrorsJvm.NullabilityInformationSource.KOTLIN
|
||||||
|
|
||||||
if (isFlexible() && TypeUtils.isNullableType(flexibility().lowerBound)) return ErrorsJvm.NullabilityInformationSource.KOTLIN
|
if (isFlexible() && TypeUtils.isNullableType(flexibility().lowerBound)) return ErrorsJvm.NullabilityInformationSource.KOTLIN
|
||||||
@@ -52,7 +52,7 @@ public class JavaNullabilityWarningsChecker : AdditionalTypeChecker {
|
|||||||
return null
|
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 (!isError() && !isFlexible() && !TypeUtils.isNullableType(this)) return ErrorsJvm.NullabilityInformationSource.KOTLIN
|
||||||
|
|
||||||
if (isFlexible() && !TypeUtils.isNullableType(flexibility().upperBound)) 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(
|
private fun doCheckType(
|
||||||
expressionType: KtType,
|
expressionType: KotlinType,
|
||||||
expectedType: KtType,
|
expectedType: KotlinType,
|
||||||
dataFlowValue: DataFlowValue,
|
dataFlowValue: DataFlowValue,
|
||||||
dataFlowInfo: DataFlowInfo,
|
dataFlowInfo: DataFlowInfo,
|
||||||
reportWarning: (expectedMustNotBeNull: ErrorsJvm.NullabilityInformationSource, actualMayBeNull: ErrorsJvm.NullabilityInformationSource) -> Unit
|
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(
|
doCheckType(
|
||||||
expressionType,
|
expressionType,
|
||||||
c.expectedType,
|
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.getAnnotationRetention
|
||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.isRepeatableAnnotation
|
import org.jetbrains.kotlin.resolve.descriptorUtil.isRepeatableAnnotation
|
||||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm
|
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 org.jetbrains.kotlin.types.TypeUtils
|
||||||
|
|
||||||
public object RepeatableAnnotationChecker: AdditionalAnnotationChecker {
|
public object RepeatableAnnotationChecker: AdditionalAnnotationChecker {
|
||||||
override fun checkEntries(entries: List<KtAnnotationEntry>, actualTargets: List<KotlinTarget>, trace: BindingTrace) {
|
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) {
|
for (entry in entries) {
|
||||||
val descriptor = trace.get(BindingContext.ANNOTATION, entry) ?: continue
|
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.KtDeclaration;
|
||||||
import org.jetbrains.kotlin.psi.KtElement;
|
import org.jetbrains.kotlin.psi.KtElement;
|
||||||
import org.jetbrains.kotlin.psi.KtExpression;
|
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.PositioningStrategies.*;
|
||||||
import static org.jetbrains.kotlin.diagnostics.Severity.ERROR;
|
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);
|
DiagnosticFactory0<KtElement> NO_REFLECTION_IN_CLASS_PATH = DiagnosticFactory0.create(WARNING);
|
||||||
|
|
||||||
DiagnosticFactory2<KtElement, KtType, KtType> JAVA_CLASS_ON_COMPANION = DiagnosticFactory2.create(WARNING);
|
DiagnosticFactory2<KtElement, KotlinType, KotlinType> JAVA_CLASS_ON_COMPANION = DiagnosticFactory2.create(WARNING);
|
||||||
DiagnosticFactory2<KtExpression, KtType, KtType> JAVA_TYPE_MISMATCH = DiagnosticFactory2.create(ERROR);
|
DiagnosticFactory2<KtExpression, KotlinType, KotlinType> JAVA_TYPE_MISMATCH = DiagnosticFactory2.create(ERROR);
|
||||||
|
|
||||||
DiagnosticFactory2<PsiElement, String, String> DUPLICATE_CLASS_NAMES = 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.load.java.structure.JavaField;
|
||||||
import org.jetbrains.kotlin.psi.KtProperty;
|
import org.jetbrains.kotlin.psi.KtProperty;
|
||||||
import org.jetbrains.kotlin.psi.KtPsiFactoryKt;
|
import org.jetbrains.kotlin.psi.KtPsiFactoryKt;
|
||||||
import org.jetbrains.kotlin.types.KtType;
|
import org.jetbrains.kotlin.types.KotlinType;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
public class AlternativeFieldSignatureData extends ElementAlternativeSignatureData {
|
public class AlternativeFieldSignatureData extends ElementAlternativeSignatureData {
|
||||||
private KtType altReturnType;
|
private KotlinType altReturnType;
|
||||||
|
|
||||||
public AlternativeFieldSignatureData(
|
public AlternativeFieldSignatureData(
|
||||||
@NotNull JavaField field,
|
@NotNull JavaField field,
|
||||||
@NotNull KtType originalReturnType,
|
@NotNull KotlinType originalReturnType,
|
||||||
@NotNull Project project,
|
@NotNull Project project,
|
||||||
boolean isVar
|
boolean isVar
|
||||||
) {
|
) {
|
||||||
@@ -59,7 +59,7 @@ public class AlternativeFieldSignatureData extends ElementAlternativeSignatureDa
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public KtType getReturnType() {
|
public KotlinType getReturnType() {
|
||||||
checkForErrors();
|
checkForErrors();
|
||||||
return altReturnType;
|
return altReturnType;
|
||||||
}
|
}
|
||||||
|
|||||||
+14
-14
@@ -32,7 +32,7 @@ import org.jetbrains.kotlin.name.Name;
|
|||||||
import org.jetbrains.kotlin.psi.*;
|
import org.jetbrains.kotlin.psi.*;
|
||||||
import org.jetbrains.kotlin.resolve.jvm.JavaDescriptorResolverKt;
|
import org.jetbrains.kotlin.resolve.jvm.JavaDescriptorResolverKt;
|
||||||
import org.jetbrains.kotlin.resolve.jvm.JavaResolverUtils;
|
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.TypeSubstitutor;
|
||||||
import org.jetbrains.kotlin.types.TypeUtils;
|
import org.jetbrains.kotlin.types.TypeUtils;
|
||||||
import org.jetbrains.kotlin.types.Variance;
|
import org.jetbrains.kotlin.types.Variance;
|
||||||
@@ -52,17 +52,17 @@ public class AlternativeMethodSignatureData extends ElementAlternativeSignatureD
|
|||||||
private final KtNamedFunction altFunDeclaration;
|
private final KtNamedFunction altFunDeclaration;
|
||||||
|
|
||||||
private List<ValueParameterDescriptor> altValueParameters;
|
private List<ValueParameterDescriptor> altValueParameters;
|
||||||
private KtType altReturnType;
|
private KotlinType altReturnType;
|
||||||
private List<TypeParameterDescriptor> altTypeParameters;
|
private List<TypeParameterDescriptor> altTypeParameters;
|
||||||
|
|
||||||
private Map<TypeParameterDescriptor, TypeParameterDescriptorImpl> originalToAltTypeParameters;
|
private Map<TypeParameterDescriptor, TypeParameterDescriptorImpl> originalToAltTypeParameters;
|
||||||
|
|
||||||
public AlternativeMethodSignatureData(
|
public AlternativeMethodSignatureData(
|
||||||
@NotNull JavaMember methodOrConstructor,
|
@NotNull JavaMember methodOrConstructor,
|
||||||
@Nullable KtType receiverType,
|
@Nullable KotlinType receiverType,
|
||||||
@NotNull Project project,
|
@NotNull Project project,
|
||||||
@NotNull List<ValueParameterDescriptor> valueParameters,
|
@NotNull List<ValueParameterDescriptor> valueParameters,
|
||||||
@Nullable KtType originalReturnType,
|
@Nullable KotlinType originalReturnType,
|
||||||
@NotNull List<TypeParameterDescriptor> methodTypeParameters,
|
@NotNull List<TypeParameterDescriptor> methodTypeParameters,
|
||||||
boolean hasSuperMethods
|
boolean hasSuperMethods
|
||||||
) {
|
) {
|
||||||
@@ -119,7 +119,7 @@ public class AlternativeMethodSignatureData extends ElementAlternativeSignatureD
|
|||||||
private void checkParameterAndReturnTypesForOverridingMethods(
|
private void checkParameterAndReturnTypesForOverridingMethods(
|
||||||
@NotNull List<ValueParameterDescriptor> valueParameters,
|
@NotNull List<ValueParameterDescriptor> valueParameters,
|
||||||
@NotNull List<TypeParameterDescriptor> methodTypeParameters,
|
@NotNull List<TypeParameterDescriptor> methodTypeParameters,
|
||||||
@Nullable KtType returnType
|
@Nullable KotlinType returnType
|
||||||
) {
|
) {
|
||||||
if (JavaDescriptorResolverKt.getPLATFORM_TYPES()) return;
|
if (JavaDescriptorResolverKt.getPLATFORM_TYPES()) return;
|
||||||
TypeSubstitutor substitutor = JavaResolverUtils.createSubstitutorForTypeParameters(originalToAltTypeParameters);
|
TypeSubstitutor substitutor = JavaResolverUtils.createSubstitutorForTypeParameters(originalToAltTypeParameters);
|
||||||
@@ -128,7 +128,7 @@ public class AlternativeMethodSignatureData extends ElementAlternativeSignatureD
|
|||||||
int index = parameter.getIndex();
|
int index = parameter.getIndex();
|
||||||
ValueParameterDescriptor altParameter = altValueParameters.get(index);
|
ValueParameterDescriptor altParameter = altValueParameters.get(index);
|
||||||
|
|
||||||
KtType substituted = substitutor.substitute(parameter.getType(), Variance.INVARIANT);
|
KotlinType substituted = substitutor.substitute(parameter.getType(), Variance.INVARIANT);
|
||||||
assert substituted != null;
|
assert substituted != null;
|
||||||
|
|
||||||
if (!TypeUtils.equalTypes(substituted, altParameter.getType())) {
|
if (!TypeUtils.equalTypes(substituted, altParameter.getType())) {
|
||||||
@@ -143,7 +143,7 @@ public class AlternativeMethodSignatureData extends ElementAlternativeSignatureD
|
|||||||
for (TypeParameterDescriptor parameter : methodTypeParameters) {
|
for (TypeParameterDescriptor parameter : methodTypeParameters) {
|
||||||
int index = parameter.getIndex();
|
int index = parameter.getIndex();
|
||||||
|
|
||||||
KtType substituted = substitutor.substitute(parameter.getUpperBoundsAsType(), Variance.INVARIANT);
|
KotlinType substituted = substitutor.substitute(parameter.getUpperBoundsAsType(), Variance.INVARIANT);
|
||||||
assert substituted != null;
|
assert substituted != null;
|
||||||
|
|
||||||
if (!TypeUtils.equalTypes(substituted, altTypeParameters.get(index).getUpperBoundsAsType())) {
|
if (!TypeUtils.equalTypes(substituted, altTypeParameters.get(index).getUpperBoundsAsType())) {
|
||||||
@@ -154,7 +154,7 @@ public class AlternativeMethodSignatureData extends ElementAlternativeSignatureD
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (returnType != null) {
|
if (returnType != null) {
|
||||||
KtType substitutedReturnType = substitutor.substitute(returnType, Variance.INVARIANT);
|
KotlinType substitutedReturnType = substitutor.substitute(returnType, Variance.INVARIANT);
|
||||||
assert substitutedReturnType != null;
|
assert substitutedReturnType != null;
|
||||||
|
|
||||||
if (!KotlinTypeChecker.DEFAULT.isSubtypeOf(altReturnType, substitutedReturnType)) {
|
if (!KotlinTypeChecker.DEFAULT.isSubtypeOf(altReturnType, substitutedReturnType)) {
|
||||||
@@ -171,7 +171,7 @@ public class AlternativeMethodSignatureData extends ElementAlternativeSignatureD
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public KtType getReturnType() {
|
public KotlinType getReturnType() {
|
||||||
checkForErrors();
|
checkForErrors();
|
||||||
return altReturnType;
|
return altReturnType;
|
||||||
}
|
}
|
||||||
@@ -197,10 +197,10 @@ public class AlternativeMethodSignatureData extends ElementAlternativeSignatureD
|
|||||||
KtTypeElement alternativeTypeElement = annotationValueParameter.getTypeReference().getTypeElement();
|
KtTypeElement alternativeTypeElement = annotationValueParameter.getTypeReference().getTypeElement();
|
||||||
assert alternativeTypeElement != null;
|
assert alternativeTypeElement != null;
|
||||||
|
|
||||||
KtType alternativeType;
|
KotlinType alternativeType;
|
||||||
KtType alternativeVarargElementType;
|
KotlinType alternativeVarargElementType;
|
||||||
|
|
||||||
KtType originalParamVarargElementType = originalParameterDescriptor.getVarargElementType();
|
KotlinType originalParamVarargElementType = originalParameterDescriptor.getVarargElementType();
|
||||||
if (originalParamVarargElementType == null) {
|
if (originalParamVarargElementType == null) {
|
||||||
if (annotationValueParameter.isVarArg()) {
|
if (annotationValueParameter.isVarArg()) {
|
||||||
throw new AlternativeSignatureMismatchException("Parameter in method signature is not vararg, but in alternative signature it is vararg");
|
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);
|
TypeParameterDescriptorImpl altParamDescriptor = originalToAltTypeParameters.get(originalTypeParamDescriptor);
|
||||||
KtTypeParameter altTypeParameter = altFunDeclaration.getTypeParameters().get(i);
|
KtTypeParameter altTypeParameter = altFunDeclaration.getTypeParameters().get(i);
|
||||||
|
|
||||||
Set<KtType> originalUpperBounds = originalTypeParamDescriptor.getUpperBounds();
|
Set<KotlinType> originalUpperBounds = originalTypeParamDescriptor.getUpperBounds();
|
||||||
List<KtTypeReference> altUpperBounds = getUpperBounds(altFunDeclaration, altTypeParameter);
|
List<KtTypeReference> altUpperBounds = getUpperBounds(altFunDeclaration, altTypeParameter);
|
||||||
if (altUpperBounds.size() != originalUpperBounds.size()) {
|
if (altUpperBounds.size() != originalUpperBounds.size()) {
|
||||||
if (altUpperBounds.isEmpty()
|
if (altUpperBounds.isEmpty()
|
||||||
@@ -274,7 +274,7 @@ public class AlternativeMethodSignatureData extends ElementAlternativeSignatureD
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int upperBoundIndex = 0;
|
int upperBoundIndex = 0;
|
||||||
for (KtType upperBound : originalUpperBounds) {
|
for (KotlinType upperBound : originalUpperBounds) {
|
||||||
|
|
||||||
KtTypeElement altTypeElement = altUpperBounds.get(upperBoundIndex).getTypeElement();
|
KtTypeElement altTypeElement = altUpperBounds.get(upperBoundIndex).getTypeElement();
|
||||||
assert altTypeElement != null;
|
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.psi.KtTypeReference;
|
||||||
import org.jetbrains.kotlin.renderer.DescriptorRenderer;
|
import org.jetbrains.kotlin.renderer.DescriptorRenderer;
|
||||||
import org.jetbrains.kotlin.resolve.AnalyzingUtils;
|
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.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -86,8 +86,8 @@ public abstract class ElementAlternativeSignatureData {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static KtType computeReturnType(
|
protected static KotlinType computeReturnType(
|
||||||
@NotNull KtType originalType,
|
@NotNull KotlinType originalType,
|
||||||
@Nullable KtTypeReference altReturnTypeReference,
|
@Nullable KtTypeReference altReturnTypeReference,
|
||||||
@NotNull Map<TypeParameterDescriptor, TypeParameterDescriptorImpl> originalToAltTypeParameters) {
|
@NotNull Map<TypeParameterDescriptor, TypeParameterDescriptorImpl> originalToAltTypeParameters) {
|
||||||
if (altReturnTypeReference == null) {
|
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.descriptors.TypeParameterDescriptor;
|
||||||
import org.jetbrains.kotlin.renderer.DescriptorRenderer;
|
import org.jetbrains.kotlin.renderer.DescriptorRenderer;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.KtScope;
|
import org.jetbrains.kotlin.resolve.scopes.KtScope;
|
||||||
import org.jetbrains.kotlin.types.KtType;
|
import org.jetbrains.kotlin.types.KotlinType;
|
||||||
import org.jetbrains.kotlin.types.KtTypeImpl;
|
import org.jetbrains.kotlin.types.KotlinTypeImpl;
|
||||||
import org.jetbrains.kotlin.types.TypeProjectionImpl;
|
import org.jetbrains.kotlin.types.TypeProjectionImpl;
|
||||||
import org.jetbrains.kotlin.types.Variance;
|
import org.jetbrains.kotlin.types.Variance;
|
||||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
|
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[]
|
// Checks for case when method returning Super[] is overridden with method returning Sub[]
|
||||||
static void checkArrayInReturnType(
|
static void checkArrayInReturnType(
|
||||||
@NotNull SignaturesPropagationData data,
|
@NotNull SignaturesPropagationData data,
|
||||||
@NotNull KtType type,
|
@NotNull KotlinType type,
|
||||||
@NotNull List<SignaturesPropagationData.TypeAndVariance> typesFromSuper
|
@NotNull List<SignaturesPropagationData.TypeAndVariance> typesFromSuper
|
||||||
) {
|
) {
|
||||||
List<SignaturesPropagationData.TypeAndVariance> arrayTypesFromSuper = ContainerUtil
|
List<SignaturesPropagationData.TypeAndVariance> arrayTypesFromSuper = ContainerUtil
|
||||||
@@ -55,14 +55,14 @@ class PropagationHeuristics {
|
|||||||
assert type.getArguments().size() == 1;
|
assert type.getArguments().size() == 1;
|
||||||
if (type.getArguments().get(0).getProjectionKind() == Variance.INVARIANT) {
|
if (type.getArguments().get(0).getProjectionKind() == Variance.INVARIANT) {
|
||||||
for (SignaturesPropagationData.TypeAndVariance typeAndVariance : arrayTypesFromSuper) {
|
for (SignaturesPropagationData.TypeAndVariance typeAndVariance : arrayTypesFromSuper) {
|
||||||
KtType arrayTypeFromSuper = typeAndVariance.type;
|
KotlinType arrayTypeFromSuper = typeAndVariance.type;
|
||||||
assert arrayTypeFromSuper.getArguments().size() == 1;
|
assert arrayTypeFromSuper.getArguments().size() == 1;
|
||||||
KtType elementTypeInSuper = arrayTypeFromSuper.getArguments().get(0).getType();
|
KotlinType elementTypeInSuper = arrayTypeFromSuper.getArguments().get(0).getType();
|
||||||
KtType elementType = type.getArguments().get(0).getType();
|
KotlinType elementType = type.getArguments().get(0).getType();
|
||||||
|
|
||||||
if (KotlinTypeChecker.DEFAULT.isSubtypeOf(elementType, elementTypeInSuper)
|
if (KotlinTypeChecker.DEFAULT.isSubtypeOf(elementType, elementTypeInSuper)
|
||||||
&& !KotlinTypeChecker.DEFAULT.equalTypes(elementType, elementTypeInSuper)) {
|
&& !KotlinTypeChecker.DEFAULT.equalTypes(elementType, elementTypeInSuper)) {
|
||||||
KtTypeImpl betterTypeInSuper = KtTypeImpl.create(
|
KotlinTypeImpl betterTypeInSuper = KotlinTypeImpl.create(
|
||||||
arrayTypeFromSuper.getAnnotations(),
|
arrayTypeFromSuper.getAnnotations(),
|
||||||
arrayTypeFromSuper.getConstructor(),
|
arrayTypeFromSuper.getConstructor(),
|
||||||
arrayTypeFromSuper.isMarkedNullable(),
|
arrayTypeFromSuper.isMarkedNullable(),
|
||||||
|
|||||||
+43
-43
@@ -66,7 +66,7 @@ public class SignaturesPropagationData {
|
|||||||
private final List<TypeParameterDescriptor> modifiedTypeParameters;
|
private final List<TypeParameterDescriptor> modifiedTypeParameters;
|
||||||
private final ValueParameters modifiedValueParameters;
|
private final ValueParameters modifiedValueParameters;
|
||||||
|
|
||||||
private final KtType modifiedReturnType;
|
private final KotlinType modifiedReturnType;
|
||||||
private final List<String> signatureErrors = Lists.newArrayList();
|
private final List<String> signatureErrors = Lists.newArrayList();
|
||||||
private final List<FunctionDescriptor> superFunctions;
|
private final List<FunctionDescriptor> superFunctions;
|
||||||
private final Map<TypeParameterDescriptor, TypeParameterDescriptorImpl> autoTypeParameterToModified;
|
private final Map<TypeParameterDescriptor, TypeParameterDescriptorImpl> autoTypeParameterToModified;
|
||||||
@@ -74,8 +74,8 @@ public class SignaturesPropagationData {
|
|||||||
|
|
||||||
public SignaturesPropagationData(
|
public SignaturesPropagationData(
|
||||||
@NotNull ClassDescriptor containingClass,
|
@NotNull ClassDescriptor containingClass,
|
||||||
@NotNull KtType autoReturnType, // type built by JavaTypeTransformer from Java signature and @NotNull annotations
|
@NotNull KotlinType autoReturnType, // type built by JavaTypeTransformer from Java signature and @NotNull annotations
|
||||||
@Nullable KtType receiverType,
|
@Nullable KotlinType receiverType,
|
||||||
@NotNull List<ValueParameterDescriptor> autoValueParameters, // descriptors built by parameters resolver
|
@NotNull List<ValueParameterDescriptor> autoValueParameters, // descriptors built by parameters resolver
|
||||||
@NotNull List<TypeParameterDescriptor> autoTypeParameters, // descriptors built by signature resolver
|
@NotNull List<TypeParameterDescriptor> autoTypeParameters, // descriptors built by signature resolver
|
||||||
@NotNull JavaMethod method
|
@NotNull JavaMethod method
|
||||||
@@ -97,8 +97,8 @@ public class SignaturesPropagationData {
|
|||||||
@NotNull
|
@NotNull
|
||||||
private static JavaMethodDescriptor createAutoMethodDescriptor(
|
private static JavaMethodDescriptor createAutoMethodDescriptor(
|
||||||
@NotNull ClassDescriptor containingClass,
|
@NotNull ClassDescriptor containingClass,
|
||||||
@NotNull JavaMethod method, KtType autoReturnType,
|
@NotNull JavaMethod method, KotlinType autoReturnType,
|
||||||
@Nullable KtType receiverType,
|
@Nullable KotlinType receiverType,
|
||||||
@NotNull List<ValueParameterDescriptor> autoValueParameters,
|
@NotNull List<ValueParameterDescriptor> autoValueParameters,
|
||||||
@NotNull List<TypeParameterDescriptor> autoTypeParameters
|
@NotNull List<TypeParameterDescriptor> autoTypeParameters
|
||||||
) {
|
) {
|
||||||
@@ -125,7 +125,7 @@ public class SignaturesPropagationData {
|
|||||||
return modifiedTypeParameters;
|
return modifiedTypeParameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
public KtType getModifiedReceiverType() {
|
public KotlinType getModifiedReceiverType() {
|
||||||
return modifiedValueParameters.receiverType;
|
return modifiedValueParameters.receiverType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,7 +137,7 @@ public class SignaturesPropagationData {
|
|||||||
return modifiedValueParameters.hasStableParameterNames;
|
return modifiedValueParameters.hasStableParameterNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
public KtType getModifiedReturnType() {
|
public KotlinType getModifiedReturnType() {
|
||||||
return modifiedReturnType;
|
return modifiedReturnType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,8 +153,8 @@ public class SignaturesPropagationData {
|
|||||||
signatureErrors.add(error);
|
signatureErrors.add(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
private KtType modifyReturnTypeAccordingToSuperMethods(
|
private KotlinType modifyReturnTypeAccordingToSuperMethods(
|
||||||
@NotNull KtType autoType // type built by JavaTypeTransformer
|
@NotNull KotlinType autoType // type built by JavaTypeTransformer
|
||||||
) {
|
) {
|
||||||
if (JavaDescriptorResolverKt.getPLATFORM_TYPES()) return autoType;
|
if (JavaDescriptorResolverKt.getPLATFORM_TYPES()) return autoType;
|
||||||
|
|
||||||
@@ -179,24 +179,24 @@ public class SignaturesPropagationData {
|
|||||||
int index = autoParameter.getIndex();
|
int index = autoParameter.getIndex();
|
||||||
TypeParameterDescriptorImpl modifiedTypeParameter = autoTypeParameterToModified.get(autoParameter);
|
TypeParameterDescriptorImpl modifiedTypeParameter = autoTypeParameterToModified.get(autoParameter);
|
||||||
|
|
||||||
List<Iterator<KtType>> upperBoundFromSuperFunctionsIterators = Lists.newArrayList();
|
List<Iterator<KotlinType>> upperBoundFromSuperFunctionsIterators = Lists.newArrayList();
|
||||||
for (FunctionDescriptor superFunction : superFunctions) {
|
for (FunctionDescriptor superFunction : superFunctions) {
|
||||||
upperBoundFromSuperFunctionsIterators.add(superFunction.getTypeParameters().get(index).getUpperBounds().iterator());
|
upperBoundFromSuperFunctionsIterators.add(superFunction.getTypeParameters().get(index).getUpperBounds().iterator());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (KtType autoUpperBound : autoParameter.getUpperBounds()) {
|
for (KotlinType autoUpperBound : autoParameter.getUpperBounds()) {
|
||||||
List<TypeAndVariance> upperBoundsFromSuperFunctions = Lists.newArrayList();
|
List<TypeAndVariance> upperBoundsFromSuperFunctions = Lists.newArrayList();
|
||||||
|
|
||||||
for (Iterator<KtType> iterator : upperBoundFromSuperFunctionsIterators) {
|
for (Iterator<KotlinType> iterator : upperBoundFromSuperFunctionsIterators) {
|
||||||
assert iterator.hasNext();
|
assert iterator.hasNext();
|
||||||
upperBoundsFromSuperFunctions.add(new TypeAndVariance(iterator.next(), INVARIANT));
|
upperBoundsFromSuperFunctions.add(new TypeAndVariance(iterator.next(), INVARIANT));
|
||||||
}
|
}
|
||||||
|
|
||||||
KtType modifiedUpperBound = modifyTypeAccordingToSuperMethods(autoUpperBound, upperBoundsFromSuperFunctions, UPPER_BOUND);
|
KotlinType modifiedUpperBound = modifyTypeAccordingToSuperMethods(autoUpperBound, upperBoundsFromSuperFunctions, UPPER_BOUND);
|
||||||
modifiedTypeParameter.addUpperBound(modifiedUpperBound);
|
modifiedTypeParameter.addUpperBound(modifiedUpperBound);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Iterator<KtType> iterator : upperBoundFromSuperFunctionsIterators) {
|
for (Iterator<KotlinType> iterator : upperBoundFromSuperFunctionsIterators) {
|
||||||
assert !iterator.hasNext();
|
assert !iterator.hasNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -208,14 +208,14 @@ public class SignaturesPropagationData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private ValueParameters modifyValueParametersAccordingToSuperMethods(
|
private ValueParameters modifyValueParametersAccordingToSuperMethods(
|
||||||
@Nullable KtType receiverType,
|
@Nullable KotlinType receiverType,
|
||||||
@NotNull List<ValueParameterDescriptor> parameters // descriptors built by parameters resolver
|
@NotNull List<ValueParameterDescriptor> parameters // descriptors built by parameters resolver
|
||||||
) {
|
) {
|
||||||
assert receiverType == null : "Parameters before propagation have receiver type," +
|
assert receiverType == null : "Parameters before propagation have receiver type," +
|
||||||
" but propagation should be disabled for functions compiled from Kotlin in class: " +
|
" but propagation should be disabled for functions compiled from Kotlin in class: " +
|
||||||
DescriptorUtils.getFqName(containingClass);
|
DescriptorUtils.getFqName(containingClass);
|
||||||
|
|
||||||
KtType resultReceiverType = null;
|
KotlinType resultReceiverType = null;
|
||||||
List<ValueParameterDescriptor> resultParameters = new ArrayList<ValueParameterDescriptor>(parameters.size());
|
List<ValueParameterDescriptor> resultParameters = new ArrayList<ValueParameterDescriptor>(parameters.size());
|
||||||
|
|
||||||
boolean shouldBeExtension = checkIfShouldBeExtension();
|
boolean shouldBeExtension = checkIfShouldBeExtension();
|
||||||
@@ -239,9 +239,9 @@ public class SignaturesPropagationData {
|
|||||||
|
|
||||||
VarargCheckResult varargCheckResult = checkVarargInSuperFunctions(originalParam);
|
VarargCheckResult varargCheckResult = checkVarargInSuperFunctions(originalParam);
|
||||||
|
|
||||||
KtType altType = modifyTypeAccordingToSuperMethods(varargCheckResult.parameterType,
|
KotlinType altType = modifyTypeAccordingToSuperMethods(varargCheckResult.parameterType,
|
||||||
convertToTypeVarianceList(typesFromSuperMethods),
|
convertToTypeVarianceList(typesFromSuperMethods),
|
||||||
MEMBER_SIGNATURE_CONTRAVARIANT);
|
MEMBER_SIGNATURE_CONTRAVARIANT);
|
||||||
|
|
||||||
if (shouldBeExtension && originalIndex == 0) {
|
if (shouldBeExtension && originalIndex == 0) {
|
||||||
resultReceiverType = altType;
|
resultReceiverType = altType;
|
||||||
@@ -304,7 +304,7 @@ public class SignaturesPropagationData {
|
|||||||
// TODO: Add propagation for other kotlin descriptors (KT-3621)
|
// TODO: Add propagation for other kotlin descriptors (KT-3621)
|
||||||
Name name = method.getName();
|
Name name = method.getName();
|
||||||
JvmMethodSignature autoSignature = SIGNATURE_MAPPER.mapToJvmMethodSignature(autoMethodDescriptor);
|
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);
|
Collection<FunctionDescriptor> superFunctionCandidates = supertype.getMemberScope().getFunctions(name, NoLookupLocation.WHEN_GET_SUPER_MEMBERS);
|
||||||
for (FunctionDescriptor candidate : superFunctionCandidates) {
|
for (FunctionDescriptor candidate : superFunctionCandidates) {
|
||||||
JvmMethodSignature candidateSignature = SIGNATURE_MAPPER.mapToJvmMethodSignature(candidate);
|
JvmMethodSignature candidateSignature = SIGNATURE_MAPPER.mapToJvmMethodSignature(candidate);
|
||||||
@@ -365,8 +365,8 @@ public class SignaturesPropagationData {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
KtType originalVarargElementType = originalParam.getVarargElementType();
|
KotlinType originalVarargElementType = originalParam.getVarargElementType();
|
||||||
KtType originalType = originalParam.getType();
|
KotlinType originalType = originalParam.getType();
|
||||||
|
|
||||||
if (someSupersVararg && someSupersNotVararg) {
|
if (someSupersVararg && someSupersNotVararg) {
|
||||||
reportError("Incompatible super methods: some have vararg parameter, some have not");
|
reportError("Incompatible super methods: some have vararg parameter, some have not");
|
||||||
@@ -389,8 +389,8 @@ public class SignaturesPropagationData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private KtType modifyTypeAccordingToSuperMethods(
|
private KotlinType modifyTypeAccordingToSuperMethods(
|
||||||
@NotNull KtType autoType,
|
@NotNull KotlinType autoType,
|
||||||
@NotNull List<TypeAndVariance> typesFromSuper,
|
@NotNull List<TypeAndVariance> typesFromSuper,
|
||||||
@NotNull TypeUsage howThisTypeIsUsed
|
@NotNull TypeUsage howThisTypeIsUsed
|
||||||
) {
|
) {
|
||||||
@@ -409,11 +409,11 @@ public class SignaturesPropagationData {
|
|||||||
resultScope = autoType.getMemberScope();
|
resultScope = autoType.getMemberScope();
|
||||||
}
|
}
|
||||||
|
|
||||||
KtType type = KtTypeImpl.create(autoType.getAnnotations(),
|
KotlinType type = KotlinTypeImpl.create(autoType.getAnnotations(),
|
||||||
resultClassifier.getTypeConstructor(),
|
resultClassifier.getTypeConstructor(),
|
||||||
resultNullable,
|
resultNullable,
|
||||||
resultArguments,
|
resultArguments,
|
||||||
resultScope);
|
resultScope);
|
||||||
|
|
||||||
PropagationHeuristics.checkArrayInReturnType(this, type, typesFromSuper);
|
PropagationHeuristics.checkArrayInReturnType(this, type, typesFromSuper);
|
||||||
return type;
|
return type;
|
||||||
@@ -421,7 +421,7 @@ public class SignaturesPropagationData {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private List<TypeProjection> getTypeArgsOfType(
|
private List<TypeProjection> getTypeArgsOfType(
|
||||||
@NotNull KtType autoType,
|
@NotNull KotlinType autoType,
|
||||||
@NotNull ClassifierDescriptor classifier,
|
@NotNull ClassifierDescriptor classifier,
|
||||||
@NotNull List<TypeAndVariance> typesFromSuper
|
@NotNull List<TypeAndVariance> typesFromSuper
|
||||||
) {
|
) {
|
||||||
@@ -444,11 +444,11 @@ public class SignaturesPropagationData {
|
|||||||
for (TypeParameterDescriptor parameter : classifier.getTypeConstructor().getParameters()) {
|
for (TypeParameterDescriptor parameter : classifier.getTypeConstructor().getParameters()) {
|
||||||
TypeProjection argument = autoArguments.get(parameter.getIndex());
|
TypeProjection argument = autoArguments.get(parameter.getIndex());
|
||||||
|
|
||||||
KtType argumentType = argument.getType();
|
KotlinType argumentType = argument.getType();
|
||||||
List<TypeProjectionAndVariance> projectionsFromSuper = typeArgumentsFromSuper.get(parameter.getIndex());
|
List<TypeProjectionAndVariance> projectionsFromSuper = typeArgumentsFromSuper.get(parameter.getIndex());
|
||||||
List<TypeAndVariance> argTypesFromSuper = getTypes(projectionsFromSuper);
|
List<TypeAndVariance> argTypesFromSuper = getTypes(projectionsFromSuper);
|
||||||
|
|
||||||
KtType type = modifyTypeAccordingToSuperMethods(argumentType, argTypesFromSuper, TYPE_ARGUMENT);
|
KotlinType type = modifyTypeAccordingToSuperMethods(argumentType, argTypesFromSuper, TYPE_ARGUMENT);
|
||||||
Variance projectionKind = calculateArgumentProjectionKindFromSuper(argument, projectionsFromSuper);
|
Variance projectionKind = calculateArgumentProjectionKindFromSuper(argument, projectionsFromSuper);
|
||||||
|
|
||||||
resultArguments.add(new TypeProjectionImpl(projectionKind, type));
|
resultArguments.add(new TypeProjectionImpl(projectionKind, type));
|
||||||
@@ -567,7 +567,7 @@ public class SignaturesPropagationData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean typeMustBeNullable(
|
private boolean typeMustBeNullable(
|
||||||
@NotNull KtType autoType,
|
@NotNull KotlinType autoType,
|
||||||
@NotNull List<TypeAndVariance> typesFromSuper,
|
@NotNull List<TypeAndVariance> typesFromSuper,
|
||||||
@NotNull TypeUsage howThisTypeIsUsed
|
@NotNull TypeUsage howThisTypeIsUsed
|
||||||
) {
|
) {
|
||||||
@@ -611,7 +611,7 @@ public class SignaturesPropagationData {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private ClassifierDescriptor modifyTypeClassifier(
|
private ClassifierDescriptor modifyTypeClassifier(
|
||||||
@NotNull KtType autoType,
|
@NotNull KotlinType autoType,
|
||||||
@NotNull List<TypeAndVariance> typesFromSuper
|
@NotNull List<TypeAndVariance> typesFromSuper
|
||||||
) {
|
) {
|
||||||
ClassifierDescriptor classifier = autoType.getConstructor().getDeclarationDescriptor();
|
ClassifierDescriptor classifier = autoType.getConstructor().getDeclarationDescriptor();
|
||||||
@@ -666,15 +666,15 @@ public class SignaturesPropagationData {
|
|||||||
return fixed != null ? fixed : classifier;
|
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);
|
return KotlinBuiltIns.isArray(type) || KotlinBuiltIns.isPrimitiveArray(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class VarargCheckResult {
|
private static class VarargCheckResult {
|
||||||
public final KtType parameterType;
|
public final KotlinType parameterType;
|
||||||
public final boolean isVararg;
|
public final boolean isVararg;
|
||||||
|
|
||||||
public VarargCheckResult(KtType parameterType, boolean isVararg) {
|
public VarargCheckResult(KotlinType parameterType, boolean isVararg) {
|
||||||
this.parameterType = parameterType;
|
this.parameterType = parameterType;
|
||||||
this.isVararg = isVararg;
|
this.isVararg = isVararg;
|
||||||
}
|
}
|
||||||
@@ -695,10 +695,10 @@ public class SignaturesPropagationData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static class TypeAndVariance {
|
static class TypeAndVariance {
|
||||||
public final KtType type;
|
public final KotlinType type;
|
||||||
public final Variance varianceOfPosition;
|
public final Variance varianceOfPosition;
|
||||||
|
|
||||||
public TypeAndVariance(KtType type, Variance varianceOfPosition) {
|
public TypeAndVariance(KotlinType type, Variance varianceOfPosition) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.varianceOfPosition = varianceOfPosition;
|
this.varianceOfPosition = varianceOfPosition;
|
||||||
}
|
}
|
||||||
@@ -709,22 +709,22 @@ public class SignaturesPropagationData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static class TypeAndName {
|
private static class TypeAndName {
|
||||||
public final KtType type;
|
public final KotlinType type;
|
||||||
public final Name name;
|
public final Name name;
|
||||||
|
|
||||||
public TypeAndName(KtType type, Name name) {
|
public TypeAndName(KotlinType type, Name name) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ValueParameters {
|
private static class ValueParameters {
|
||||||
private final KtType receiverType;
|
private final KotlinType receiverType;
|
||||||
private final List<ValueParameterDescriptor> descriptors;
|
private final List<ValueParameterDescriptor> descriptors;
|
||||||
private final boolean hasStableParameterNames;
|
private final boolean hasStableParameterNames;
|
||||||
|
|
||||||
public ValueParameters(
|
public ValueParameters(
|
||||||
@Nullable KtType receiverType,
|
@Nullable KotlinType receiverType,
|
||||||
@NotNull List<ValueParameterDescriptor> descriptors,
|
@NotNull List<ValueParameterDescriptor> descriptors,
|
||||||
boolean hasStableParameterNames
|
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.load.java.components.TypeUsage.TYPE_ARGUMENT;
|
||||||
import static org.jetbrains.kotlin.types.Variance.INVARIANT;
|
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 static boolean strictMode = false;
|
||||||
|
|
||||||
private final KtType originalType;
|
private final KotlinType originalType;
|
||||||
private final Map<TypeParameterDescriptor, TypeParameterDescriptorImpl> originalToAltTypeParameters;
|
private final Map<TypeParameterDescriptor, TypeParameterDescriptorImpl> originalToAltTypeParameters;
|
||||||
|
|
||||||
private final TypeUsage typeUsage;
|
private final TypeUsage typeUsage;
|
||||||
|
|
||||||
private TypeTransformingVisitor(
|
private TypeTransformingVisitor(
|
||||||
KtType originalType,
|
KotlinType originalType,
|
||||||
Map<TypeParameterDescriptor, TypeParameterDescriptorImpl> originalToAltTypeParameters,
|
Map<TypeParameterDescriptor, TypeParameterDescriptorImpl> originalToAltTypeParameters,
|
||||||
TypeUsage typeUsage
|
TypeUsage typeUsage
|
||||||
) {
|
) {
|
||||||
@@ -61,19 +61,19 @@ public class TypeTransformingVisitor extends KtVisitor<KtType, Void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static KtType computeType(
|
public static KotlinType computeType(
|
||||||
@NotNull KtTypeElement alternativeTypeElement,
|
@NotNull KtTypeElement alternativeTypeElement,
|
||||||
@NotNull KtType originalType,
|
@NotNull KotlinType originalType,
|
||||||
@NotNull Map<TypeParameterDescriptor, TypeParameterDescriptorImpl> originalToAltTypeParameters,
|
@NotNull Map<TypeParameterDescriptor, TypeParameterDescriptorImpl> originalToAltTypeParameters,
|
||||||
@NotNull TypeUsage typeUsage
|
@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);
|
assert (computedType != null);
|
||||||
return computedType;
|
return computedType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KtType visitNullableType(@NotNull KtNullableType nullableType, Void aVoid) {
|
public KotlinType visitNullableType(@NotNull KtNullableType nullableType, Void aVoid) {
|
||||||
if (!TypeUtils.isNullableType(originalType) && typeUsage != TYPE_ARGUMENT) {
|
if (!TypeUtils.isNullableType(originalType) && typeUsage != TYPE_ARGUMENT) {
|
||||||
throw new AlternativeSignatureMismatchException("Auto type '%s' is not-null, while type in alternative signature is nullable: '%s'",
|
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());
|
DescriptorRenderer.FQ_NAMES_IN_TYPES.renderType(originalType), nullableType.getText());
|
||||||
@@ -84,7 +84,7 @@ public class TypeTransformingVisitor extends KtVisitor<KtType, Void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KtType visitFunctionType(@NotNull KtFunctionType type, Void data) {
|
public KotlinType visitFunctionType(@NotNull KtFunctionType type, Void data) {
|
||||||
KotlinBuiltIns builtIns = JvmPlatform.INSTANCE$.getBuiltIns();
|
KotlinBuiltIns builtIns = JvmPlatform.INSTANCE$.getBuiltIns();
|
||||||
return visitCommonType(type.getReceiverTypeReference() == null
|
return visitCommonType(type.getReceiverTypeReference() == null
|
||||||
? builtIns.getFunction(type.getParameters().size())
|
? builtIns.getFunction(type.getParameters().size())
|
||||||
@@ -92,7 +92,7 @@ public class TypeTransformingVisitor extends KtVisitor<KtType, Void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KtType visitUserType(@NotNull KtUserType type, Void data) {
|
public KotlinType visitUserType(@NotNull KtUserType type, Void data) {
|
||||||
KtUserType qualifier = type.getQualifier();
|
KtUserType qualifier = type.getQualifier();
|
||||||
|
|
||||||
//noinspection ConstantConditions
|
//noinspection ConstantConditions
|
||||||
@@ -102,12 +102,12 @@ public class TypeTransformingVisitor extends KtVisitor<KtType, Void> {
|
|||||||
return visitCommonType(longName, type);
|
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);
|
return visitCommonType(DescriptorUtils.getFqNameSafe(classDescriptor).asString(), type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private KtType visitCommonType(@NotNull String qualifiedName, @NotNull KtTypeElement type) {
|
private KotlinType visitCommonType(@NotNull String qualifiedName, @NotNull KtTypeElement type) {
|
||||||
if (originalType.isError()) {
|
if (originalType.isError()) {
|
||||||
return originalType;
|
return originalType;
|
||||||
}
|
}
|
||||||
@@ -159,7 +159,7 @@ public class TypeTransformingVisitor extends KtVisitor<KtType, Void> {
|
|||||||
throw new AssertionError("Unexpected class of type constructor classifier "
|
throw new AssertionError("Unexpected class of type constructor classifier "
|
||||||
+ (typeConstructorClassifier == null ? "null" : typeConstructorClassifier.getClass().getName()));
|
+ (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
|
@NotNull
|
||||||
@@ -183,7 +183,7 @@ public class TypeTransformingVisitor extends KtVisitor<KtType, Void> {
|
|||||||
assert argumentAlternativeTypeElement != null;
|
assert argumentAlternativeTypeElement != null;
|
||||||
|
|
||||||
TypeParameterDescriptor parameter = typeConstructor.getParameters().get(i);
|
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 projectionKind = originalArgument.getProjectionKind();
|
||||||
Variance altProjectionKind;
|
Variance altProjectionKind;
|
||||||
if (type instanceof KtUserType) {
|
if (type instanceof KtUserType) {
|
||||||
@@ -234,7 +234,7 @@ public class TypeTransformingVisitor extends KtVisitor<KtType, Void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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");
|
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
|
// JavaClass.fillWithDefaultObjects(x) // using `x` after this call may lead to CCE
|
||||||
override fun checkType(
|
override fun checkType(
|
||||||
expression: KtExpression,
|
expression: KtExpression,
|
||||||
expressionType: KtType,
|
expressionType: KotlinType,
|
||||||
expressionTypeWithSmartCast: KtType,
|
expressionTypeWithSmartCast: KotlinType,
|
||||||
c: ResolutionContext<*>
|
c: ResolutionContext<*>
|
||||||
) {
|
) {
|
||||||
val expectedType = c.expectedType
|
val expectedType = c.expectedType
|
||||||
|
|||||||
+3
-3
@@ -129,7 +129,7 @@ class JavaSyntheticPropertiesScope(storageManager: StorageManager) : KtScopeImpl
|
|||||||
return null
|
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!
|
//TODO: use location parameter!
|
||||||
|
|
||||||
var result: SmartList<PropertyDescriptor>? = null
|
var result: SmartList<PropertyDescriptor>? = null
|
||||||
@@ -161,7 +161,7 @@ class JavaSyntheticPropertiesScope(storageManager: StorageManager) : KtScopeImpl
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KtType>): Collection<PropertyDescriptor> {
|
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KotlinType>): Collection<PropertyDescriptor> {
|
||||||
val result = ArrayList<PropertyDescriptor>()
|
val result = ArrayList<PropertyDescriptor>()
|
||||||
val processedTypes = HashSet<TypeConstructor>()
|
val processedTypes = HashSet<TypeConstructor>()
|
||||||
receiverTypes.forEach { result.collectSyntheticProperties(it.constructor, processedTypes) }
|
receiverTypes.forEach { result.collectSyntheticProperties(it.constructor, processedTypes) }
|
||||||
@@ -252,7 +252,7 @@ class JavaSyntheticPropertiesScope(storageManager: StorageManager) : KtScopeImpl
|
|||||||
private set
|
private set
|
||||||
|
|
||||||
companion object {
|
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 visibility = syntheticExtensionVisibility(getMethod)
|
||||||
val descriptor = MyPropertyDescriptor(DescriptorUtils.getContainingModule(ownerClass),
|
val descriptor = MyPropertyDescriptor(DescriptorUtils.getContainingModule(ownerClass),
|
||||||
null,
|
null,
|
||||||
|
|||||||
+4
-4
@@ -52,7 +52,7 @@ class SamAdapterFunctionsScope(storageManager: StorageManager) : KtScope by KtSc
|
|||||||
return MyFunctionDescriptor.create(enhancedFunction)
|
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
|
var result: SmartList<FunctionDescriptor>? = null
|
||||||
for (type in receiverTypes) {
|
for (type in receiverTypes) {
|
||||||
for (function in type.memberScope.getFunctions(name, location)) {
|
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 ->
|
return receiverTypes.flatMapTo(LinkedHashSet<FunctionDescriptor>()) { type ->
|
||||||
type.memberScope.getDescriptors(DescriptorKindFilter.FUNCTIONS)
|
type.memberScope.getDescriptors(DescriptorKindFilter.FUNCTIONS)
|
||||||
.filterIsInstance<FunctionDescriptor>()
|
.filterIsInstance<FunctionDescriptor>()
|
||||||
@@ -156,8 +156,8 @@ class SamAdapterFunctionsScope(storageManager: StorageManager) : KtScope by KtSc
|
|||||||
copyOverrides: Boolean,
|
copyOverrides: Boolean,
|
||||||
kind: CallableMemberDescriptor.Kind,
|
kind: CallableMemberDescriptor.Kind,
|
||||||
newValueParameterDescriptors: MutableList<ValueParameterDescriptor>,
|
newValueParameterDescriptors: MutableList<ValueParameterDescriptor>,
|
||||||
newExtensionReceiverParameterType: KtType?,
|
newExtensionReceiverParameterType: KotlinType?,
|
||||||
newReturnType: KtType
|
newReturnType: KotlinType
|
||||||
): FunctionDescriptor? {
|
): FunctionDescriptor? {
|
||||||
val descriptor = super<SimpleFunctionDescriptorImpl>.doSubstitute(
|
val descriptor = super<SimpleFunctionDescriptorImpl>.doSubstitute(
|
||||||
originalSubstitutor, newOwner, newModality, newVisibility,
|
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.ReceiverValue;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ThisReceiver;
|
import org.jetbrains.kotlin.resolve.scopes.receivers.ThisReceiver;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.TransientReceiver;
|
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 org.jetbrains.kotlin.types.expressions.OperatorConventions;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -109,7 +109,7 @@ public class JetControlFlowProcessor {
|
|||||||
CallableDescriptor subroutineDescriptor = (CallableDescriptor) trace.get(BindingContext.DECLARATION_TO_DESCRIPTOR, subroutine);
|
CallableDescriptor subroutineDescriptor = (CallableDescriptor) trace.get(BindingContext.DECLARATION_TO_DESCRIPTOR, subroutine);
|
||||||
if (subroutineDescriptor == null) return;
|
if (subroutineDescriptor == null) return;
|
||||||
|
|
||||||
KtType returnType = subroutineDescriptor.getReturnType();
|
KotlinType returnType = subroutineDescriptor.getReturnType();
|
||||||
if (returnType != null && KotlinBuiltIns.isUnit(returnType) && subroutineDescriptor instanceof AnonymousFunctionDescriptor) return;
|
if (returnType != null && KotlinBuiltIns.isUnit(returnType) && subroutineDescriptor instanceof AnonymousFunctionDescriptor) return;
|
||||||
|
|
||||||
PseudoValue returnValue = builder.getBoundValue(bodyExpression);
|
PseudoValue returnValue = builder.getBoundValue(bodyExpression);
|
||||||
@@ -199,7 +199,7 @@ public class JetControlFlowProcessor {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
KtType type = trace.getBindingContext().getType(expression);
|
KotlinType type = trace.getBindingContext().getType(expression);
|
||||||
if (type != null && KotlinBuiltIns.isNothing(type)) {
|
if (type != null && KotlinBuiltIns.isNothing(type)) {
|
||||||
builder.jumpToError(expression);
|
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.model.ResolvedCall;
|
||||||
import org.jetbrains.kotlin.resolve.calls.resolvedCallUtil.ResolvedCallUtilKt;
|
import org.jetbrains.kotlin.resolve.calls.resolvedCallUtil.ResolvedCallUtilKt;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
|
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 org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -129,7 +129,7 @@ public class JetFlowInformationProvider {
|
|||||||
markWhenWithoutElse();
|
markWhenWithoutElse();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkFunction(@Nullable KtType expectedReturnType) {
|
public void checkFunction(@Nullable KotlinType expectedReturnType) {
|
||||||
UnreachableCode unreachableCode = collectUnreachableCode();
|
UnreachableCode unreachableCode = collectUnreachableCode();
|
||||||
reportUnreachableCode(unreachableCode);
|
reportUnreachableCode(unreachableCode);
|
||||||
|
|
||||||
@@ -208,7 +208,7 @@ public class JetFlowInformationProvider {
|
|||||||
|
|
||||||
CallableDescriptor functionDescriptor =
|
CallableDescriptor functionDescriptor =
|
||||||
(CallableDescriptor) trace.getBindingContext().get(BindingContext.DECLARATION_TO_DESCRIPTOR, localDeclaration);
|
(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 =
|
JetFlowInformationProvider providerForLocalDeclaration =
|
||||||
new JetFlowInformationProvider(localDeclaration, trace, localDeclarationInstruction.getBody());
|
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;
|
assert subroutine instanceof KtDeclarationWithBody;
|
||||||
KtDeclarationWithBody function = (KtDeclarationWithBody) subroutine;
|
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.DescriptorUtils;
|
||||||
import org.jetbrains.kotlin.resolve.bindingContextUtil.BindingContextUtilsKt;
|
import org.jetbrains.kotlin.resolve.bindingContextUtil.BindingContextUtilsKt;
|
||||||
import org.jetbrains.kotlin.types.FlexibleTypesKt;
|
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 org.jetbrains.kotlin.types.TypeUtils;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@@ -41,7 +41,7 @@ public final class WhenChecker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean mustHaveElse(@NotNull KtWhenExpression expression, @NotNull BindingTrace trace) {
|
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);
|
boolean isUnit = expectedType != null && KotlinBuiltIns.isUnit(expectedType);
|
||||||
// Some "statements" are actually expressions returned from lambdas, their expected types are non-null
|
// Some "statements" are actually expressions returned from lambdas, their expected types are non-null
|
||||||
boolean isStatement = BindingContextUtilsKt.isUsedAsStatement(expression, trace.getBindingContext()) && expectedType == null;
|
boolean isStatement = BindingContextUtilsKt.isUsedAsStatement(expression, trace.getBindingContext()) && expectedType == null;
|
||||||
@@ -54,7 +54,7 @@ public final class WhenChecker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static ClassDescriptor getClassDescriptorOfTypeIfEnum(@Nullable KtType type) {
|
public static ClassDescriptor getClassDescriptorOfTypeIfEnum(@Nullable KotlinType type) {
|
||||||
if (type == null) return null;
|
if (type == null) return null;
|
||||||
ClassDescriptor classDescriptor = TypeUtils.getClassDescriptor(type);
|
ClassDescriptor classDescriptor = TypeUtils.getClassDescriptor(type);
|
||||||
if (classDescriptor == null) return null;
|
if (classDescriptor == null) return null;
|
||||||
@@ -64,7 +64,7 @@ public final class WhenChecker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@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();
|
KtExpression subjectExpression = expression.getSubjectExpression();
|
||||||
return subjectExpression == null ? null : context.getType(subjectExpression);
|
return subjectExpression == null ? null : context.getType(subjectExpression);
|
||||||
}
|
}
|
||||||
@@ -136,7 +136,7 @@ public final class WhenChecker {
|
|||||||
*/
|
*/
|
||||||
private static boolean isNullableTypeWithoutPossibleSmartCast(
|
private static boolean isNullableTypeWithoutPossibleSmartCast(
|
||||||
@Nullable KtExpression expression,
|
@Nullable KtExpression expression,
|
||||||
@NotNull KtType type,
|
@NotNull KotlinType type,
|
||||||
@NotNull BindingContext context
|
@NotNull BindingContext context
|
||||||
) {
|
) {
|
||||||
if (expression == null) return false; // Normally should not happen
|
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) {
|
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;
|
if (type == null) return false;
|
||||||
ClassDescriptor enumClassDescriptor = getClassDescriptorOfTypeIfEnum(type);
|
ClassDescriptor enumClassDescriptor = getClassDescriptorOfTypeIfEnum(type);
|
||||||
|
|
||||||
@@ -196,7 +196,7 @@ public final class WhenChecker {
|
|||||||
ClassDescriptor checkedDescriptor = null;
|
ClassDescriptor checkedDescriptor = null;
|
||||||
if (condition instanceof KtWhenConditionIsPattern) {
|
if (condition instanceof KtWhenConditionIsPattern) {
|
||||||
KtWhenConditionIsPattern conditionIsPattern = (KtWhenConditionIsPattern) condition;
|
KtWhenConditionIsPattern conditionIsPattern = (KtWhenConditionIsPattern) condition;
|
||||||
KtType checkedType = trace.get(BindingContext.TYPE, conditionIsPattern.getTypeReference());
|
KotlinType checkedType = trace.get(BindingContext.TYPE, conditionIsPattern.getTypeReference());
|
||||||
if (checkedType != null) {
|
if (checkedType != null) {
|
||||||
checkedDescriptor = TypeUtils.getClassDescriptor(checkedType);
|
checkedDescriptor = TypeUtils.getClassDescriptor(checkedType);
|
||||||
}
|
}
|
||||||
@@ -243,7 +243,7 @@ public final class WhenChecker {
|
|||||||
if (condition instanceof KtWhenConditionWithExpression) {
|
if (condition instanceof KtWhenConditionWithExpression) {
|
||||||
KtWhenConditionWithExpression conditionWithExpression = (KtWhenConditionWithExpression) condition;
|
KtWhenConditionWithExpression conditionWithExpression = (KtWhenConditionWithExpression) condition;
|
||||||
if (conditionWithExpression.getExpression() != null) {
|
if (conditionWithExpression.getExpression() != null) {
|
||||||
KtType type = trace.getBindingContext().getType(conditionWithExpression.getExpression());
|
KotlinType type = trace.getBindingContext().getType(conditionWithExpression.getExpression());
|
||||||
if (type != null && KotlinBuiltIns.isNothingOrNullableNothing(type)) {
|
if (type != null && KotlinBuiltIns.isNothingOrNullableNothing(type)) {
|
||||||
return true;
|
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.calls.model.ResolvedCall;
|
||||||
import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant;
|
import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
|
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
|
||||||
import org.jetbrains.kotlin.types.KtType;
|
import org.jetbrains.kotlin.types.KotlinType;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@@ -476,7 +476,7 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd
|
|||||||
@NotNull Map<PseudoValue, ReceiverValue> receiverValues,
|
@NotNull Map<PseudoValue, ReceiverValue> receiverValues,
|
||||||
@NotNull Map<PseudoValue, ValueParameterDescriptor> arguments
|
@NotNull Map<PseudoValue, ValueParameterDescriptor> arguments
|
||||||
) {
|
) {
|
||||||
KtType returnType = resolvedCall.getResultingDescriptor().getReturnType();
|
KotlinType returnType = resolvedCall.getResultingDescriptor().getReturnType();
|
||||||
CallInstruction instruction = new CallInstruction(
|
CallInstruction instruction = new CallInstruction(
|
||||||
valueElement,
|
valueElement,
|
||||||
getCurrentScope(),
|
getCurrentScope(),
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ import org.jetbrains.kotlin.resolve.BindingContextUtils;
|
|||||||
import org.jetbrains.kotlin.resolve.BindingTrace;
|
import org.jetbrains.kotlin.resolve.BindingTrace;
|
||||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
||||||
import org.jetbrains.kotlin.resolve.calls.resolvedCallUtil.ResolvedCallUtilKt;
|
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.ReadOnlySlice;
|
||||||
import org.jetbrains.kotlin.util.slicedMap.WritableSlice;
|
import org.jetbrains.kotlin.util.slicedMap.WritableSlice;
|
||||||
|
|
||||||
@@ -72,12 +72,12 @@ public class PseudocodeUtil {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public KtType getType(@NotNull KtExpression expression) {
|
public KotlinType getType(@NotNull KtExpression expression) {
|
||||||
return bindingContext.getType(expression);
|
return bindingContext.getType(expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void recordType(@NotNull KtExpression expression, @Nullable KtType type) {
|
public void recordType(@NotNull KtExpression expression, @Nullable KotlinType type) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -19,39 +19,39 @@ package org.jetbrains.kotlin.cfg.pseudocode
|
|||||||
import com.intellij.util.SmartFMap
|
import com.intellij.util.SmartFMap
|
||||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||||
import org.jetbrains.kotlin.renderer.DescriptorRenderer
|
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.TypeUtils
|
||||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
|
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
|
||||||
|
|
||||||
public interface TypePredicate: (KtType) -> Boolean {
|
public interface TypePredicate: (KotlinType) -> Boolean {
|
||||||
override fun invoke(typeToCheck: KtType): Boolean
|
override fun invoke(typeToCheck: KotlinType): Boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
public data class SingleType(val targetType: KtType): TypePredicate {
|
public data class SingleType(val targetType: KotlinType): TypePredicate {
|
||||||
override fun invoke(typeToCheck: KtType): Boolean = KotlinTypeChecker.DEFAULT.equalTypes(typeToCheck, targetType)
|
override fun invoke(typeToCheck: KotlinType): Boolean = KotlinTypeChecker.DEFAULT.equalTypes(typeToCheck, targetType)
|
||||||
override fun toString(): String = targetType.render()
|
override fun toString(): String = targetType.render()
|
||||||
}
|
}
|
||||||
|
|
||||||
public data class AllSubtypes(val upperBound: KtType): TypePredicate {
|
public data class AllSubtypes(val upperBound: KotlinType): TypePredicate {
|
||||||
override fun invoke(typeToCheck: KtType): Boolean = KotlinTypeChecker.DEFAULT.isSubtypeOf(typeToCheck, upperBound)
|
override fun invoke(typeToCheck: KotlinType): Boolean = KotlinTypeChecker.DEFAULT.isSubtypeOf(typeToCheck, upperBound)
|
||||||
|
|
||||||
override fun toString(): String = "{<: ${upperBound.render()}}"
|
override fun toString(): String = "{<: ${upperBound.render()}}"
|
||||||
}
|
}
|
||||||
|
|
||||||
public data class ForAllTypes(val typeSets: List<TypePredicate>): TypePredicate {
|
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(", ")}}"
|
override fun toString(): String = "AND{${typeSets.joinToString(", ")}}"
|
||||||
}
|
}
|
||||||
|
|
||||||
public data class ForSomeType(val typeSets: List<TypePredicate>): TypePredicate {
|
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(", ")}}"
|
override fun toString(): String = "OR{${typeSets.joinToString(", ")}}"
|
||||||
}
|
}
|
||||||
|
|
||||||
public object AllTypes : TypePredicate {
|
public object AllTypes : TypePredicate {
|
||||||
override fun invoke(typeToCheck: KtType): Boolean = true
|
override fun invoke(typeToCheck: KotlinType): Boolean = true
|
||||||
|
|
||||||
override fun toString(): String = "*"
|
override fun toString(): String = "*"
|
||||||
}
|
}
|
||||||
@@ -71,7 +71,7 @@ public fun or(predicates: Collection<TypePredicate>): TypePredicate? =
|
|||||||
else -> ForSomeType(predicates.toList())
|
else -> ForSomeType(predicates.toList())
|
||||||
}
|
}
|
||||||
|
|
||||||
fun KtType.getSubtypesPredicate(): TypePredicate {
|
fun KotlinType.getSubtypesPredicate(): TypePredicate {
|
||||||
return when {
|
return when {
|
||||||
KotlinBuiltIns.isAnyOrNullableAny(this) && isMarkedNullable() -> AllTypes
|
KotlinBuiltIns.isAnyOrNullableAny(this) && isMarkedNullable() -> AllTypes
|
||||||
TypeUtils.canHaveSubtypes(KotlinTypeChecker.DEFAULT, this) -> AllSubtypes(this)
|
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> =
|
public fun <T> TypePredicate.expectedTypeFor(keys: Iterable<T>): Map<T, TypePredicate> =
|
||||||
keys.fold(SmartFMap.emptyMap<T, TypePredicate>()) { map, key -> map.plus(key, this) }
|
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.ResolutionCandidate
|
||||||
import org.jetbrains.kotlin.resolve.calls.tasks.TracingStrategy
|
import org.jetbrains.kotlin.resolve.calls.tasks.TracingStrategy
|
||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
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.TypeUtils
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
@@ -77,7 +77,7 @@ public fun getExpectedTypePredicate(
|
|||||||
val pseudocode = value.createdAt?.owner ?: return AllTypes
|
val pseudocode = value.createdAt?.owner ?: return AllTypes
|
||||||
val typePredicates = LinkedHashSet<TypePredicate?>()
|
val typePredicates = LinkedHashSet<TypePredicate?>()
|
||||||
|
|
||||||
fun addSubtypesOf(jetType: KtType?) = typePredicates.add(jetType?.getSubtypesPredicate())
|
fun addSubtypesOf(jetType: KotlinType?) = typePredicates.add(jetType?.getSubtypesPredicate())
|
||||||
|
|
||||||
fun addByExplicitReceiver(resolvedCall: ResolvedCall<*>?) {
|
fun addByExplicitReceiver(resolvedCall: ResolvedCall<*>?) {
|
||||||
val receiverValue = (resolvedCall ?: return).getExplicitReceiverValue()
|
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.model.ResolvedCall;
|
||||||
import org.jetbrains.kotlin.resolve.calls.tasks.DynamicCallsKt;
|
import org.jetbrains.kotlin.resolve.calls.tasks.DynamicCallsKt;
|
||||||
import org.jetbrains.kotlin.types.ErrorUtils;
|
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 org.jetbrains.kotlin.util.slicedMap.WritableSlice;
|
||||||
|
|
||||||
import java.util.Collection;
|
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')
|
// if 'foo' in 'foo[i]' is unresolved it means 'foo[i]' is unresolved (otherwise 'foo[i]' is marked as 'missing unresolved')
|
||||||
markedWithError = true;
|
markedWithError = true;
|
||||||
}
|
}
|
||||||
KtType expressionType = bindingContext.getType(expression);
|
KotlinType expressionType = bindingContext.getType(expression);
|
||||||
DiagnosticFactory<?> factory = markedWithErrorElements.get(expression);
|
DiagnosticFactory<?> factory = markedWithErrorElements.get(expression);
|
||||||
if (declarationDescriptor != null &&
|
if (declarationDescriptor != null &&
|
||||||
(ErrorUtils.isError(declarationDescriptor) || ErrorUtils.containsErrorType(expressionType))) {
|
(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.*;
|
||||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
||||||
import org.jetbrains.kotlin.name.Name;
|
import org.jetbrains.kotlin.name.Name;
|
||||||
import org.jetbrains.kotlin.types.KtType;
|
import org.jetbrains.kotlin.types.KotlinType;
|
||||||
import org.jetbrains.kotlin.types.TypeSubstitutor;
|
import org.jetbrains.kotlin.types.TypeSubstitutor;
|
||||||
|
|
||||||
public class LocalVariableDescriptor extends VariableDescriptorWithInitializerImpl {
|
public class LocalVariableDescriptor extends VariableDescriptorWithInitializerImpl {
|
||||||
@@ -29,7 +29,7 @@ public class LocalVariableDescriptor extends VariableDescriptorWithInitializerIm
|
|||||||
@NotNull DeclarationDescriptor containingDeclaration,
|
@NotNull DeclarationDescriptor containingDeclaration,
|
||||||
@NotNull Annotations annotations,
|
@NotNull Annotations annotations,
|
||||||
@NotNull Name name,
|
@NotNull Name name,
|
||||||
@Nullable KtType type,
|
@Nullable KotlinType type,
|
||||||
boolean mutable,
|
boolean mutable,
|
||||||
@NotNull SourceElement source
|
@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.inference.InferenceErrorData;
|
||||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
||||||
import org.jetbrains.kotlin.resolve.varianceChecker.VarianceChecker.VarianceConflictDiagnosticData;
|
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.Field;
|
||||||
import java.lang.reflect.Modifier;
|
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);
|
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);
|
DiagnosticFactory0<KtNullableType> REDUNDANT_NULLABLE = DiagnosticFactory0.create(WARNING, NULLABLE_TYPE);
|
||||||
DiagnosticFactory1<KtElement, Integer> WRONG_NUMBER_OF_TYPE_ARGUMENTS = DiagnosticFactory1.create(ERROR);
|
DiagnosticFactory1<KtElement, Integer> WRONG_NUMBER_OF_TYPE_ARGUMENTS = DiagnosticFactory1.create(ERROR);
|
||||||
DiagnosticFactory2<KtTypeReference, Integer, String> NO_TYPE_ARGUMENTS_ON_RHS = DiagnosticFactory2.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_NOT_TOP_LEVEL_OR_OBJECT = DiagnosticFactory0.create(ERROR);
|
||||||
DiagnosticFactory0<PsiElement> CONST_VAL_WITH_GETTER = DiagnosticFactory0.create(ERROR);
|
DiagnosticFactory0<PsiElement> CONST_VAL_WITH_GETTER = DiagnosticFactory0.create(ERROR);
|
||||||
DiagnosticFactory0<PsiElement> CONST_VAL_WITH_DELEGATE = 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<PsiElement> CONST_VAL_WITHOUT_INITIALIZER = DiagnosticFactory0.create(ERROR);
|
||||||
DiagnosticFactory0<KtExpression> CONST_VAL_WITH_NON_CONST_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> MANY_CLASSES_IN_SUPERTYPE_LIST = DiagnosticFactory0.create(ERROR);
|
||||||
DiagnosticFactory0<KtTypeReference> SUPERTYPE_APPEARS_TWICE = 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);
|
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);
|
INCONSISTENT_TYPE_PARAMETER_BOUNDS = DiagnosticFactory3.create(ERROR);
|
||||||
|
|
||||||
|
|
||||||
@@ -253,7 +253,7 @@ public interface Errors {
|
|||||||
|
|
||||||
// Type parameter declarations
|
// 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);
|
DiagnosticFactory0<KtTypeReference> DYNAMIC_UPPER_BOUND = DiagnosticFactory0.create(ERROR);
|
||||||
|
|
||||||
DiagnosticFactory1<KtNamedDeclaration, TypeParameterDescriptor> CONFLICTING_UPPER_BOUNDS =
|
DiagnosticFactory1<KtNamedDeclaration, TypeParameterDescriptor> CONFLICTING_UPPER_BOUNDS =
|
||||||
@@ -322,7 +322,7 @@ public interface Errors {
|
|||||||
DiagnosticFactory2.create(ERROR, DECLARATION_NAME);
|
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);
|
DiagnosticFactory1.create(ERROR, DECLARATION_SIGNATURE);
|
||||||
|
|
||||||
// Property-specific
|
// Property-specific
|
||||||
@@ -334,7 +334,7 @@ public interface Errors {
|
|||||||
DiagnosticFactory0<PsiElement> GETTER_VISIBILITY_DIFFERS_FROM_PROPERTY_VISIBILITY = DiagnosticFactory0.create(ERROR);
|
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> PRIVATE_SETTER_ON_NON_PRIVATE_LATE_INIT_VAR = DiagnosticFactory0.create(ERROR);
|
||||||
DiagnosticFactory0<PsiElement> ACCESSOR_VISIBILITY_FOR_ABSTRACT_PROPERTY = 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>
|
DiagnosticFactory0<KtModifierListOwner>
|
||||||
ABSTRACT_PROPERTY_IN_PRIMARY_CONSTRUCTOR_PARAMETERS = DiagnosticFactory0.create(ERROR, ABSTRACT_MODIFIER);
|
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);
|
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
|
// Function-specific
|
||||||
|
|
||||||
@@ -452,7 +452,7 @@ public interface Errors {
|
|||||||
|
|
||||||
DiagnosticFactory1<KtElement, ValueParameterDescriptor> NO_VALUE_FOR_PARAMETER = DiagnosticFactory1.create(ERROR, VALUE_ARGUMENTS);
|
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);
|
DiagnosticFactory0<KtExpression> NO_RECEIVER_ALLOWED = DiagnosticFactory0.create(ERROR);
|
||||||
|
|
||||||
// Call resolution
|
// Call resolution
|
||||||
@@ -461,7 +461,7 @@ public interface Errors {
|
|||||||
|
|
||||||
DiagnosticFactory0<PsiElement> SAFE_CALL_IN_QUALIFIER = DiagnosticFactory0.create(ERROR);
|
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);
|
DiagnosticFactory2<KtExpression, KtExpression, Boolean> FUNCTION_CALL_EXPECTED = DiagnosticFactory2.create(ERROR, CALL_EXPRESSION);
|
||||||
|
|
||||||
DiagnosticFactory0<PsiElement> NON_TAIL_RECURSIVE_CALL = DiagnosticFactory0.create(WARNING, 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, KtExpression> INVOKE_EXTENSION_ON_NOT_EXTENSION_FUNCTION = DiagnosticFactory1.create(ERROR);
|
||||||
|
|
||||||
DiagnosticFactory1<PsiElement, TypeParameterDescriptor> TYPE_PARAMETER_AS_REIFIED = 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
|
// Type inference
|
||||||
|
|
||||||
@@ -491,7 +491,7 @@ public interface Errors {
|
|||||||
DiagnosticFactory0<PsiElement> TYPE_INFERENCE_INCORPORATION_ERROR = DiagnosticFactory0.create(ERROR);
|
DiagnosticFactory0<PsiElement> TYPE_INFERENCE_INCORPORATION_ERROR = DiagnosticFactory0.create(ERROR);
|
||||||
DiagnosticFactory1<PsiElement, TypeParameterDescriptor> TYPE_INFERENCE_ONLY_INPUT_TYPES = DiagnosticFactory1.create(ERROR);
|
DiagnosticFactory1<PsiElement, TypeParameterDescriptor> TYPE_INFERENCE_ONLY_INPUT_TYPES = DiagnosticFactory1.create(ERROR);
|
||||||
DiagnosticFactory1<PsiElement, InferenceErrorData> TYPE_INFERENCE_UPPER_BOUND_VIOLATED = 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
|
// Reflection
|
||||||
|
|
||||||
@@ -506,9 +506,9 @@ public interface Errors {
|
|||||||
// Multi-declarations
|
// Multi-declarations
|
||||||
|
|
||||||
DiagnosticFactory0<KtMultiDeclaration> INITIALIZER_REQUIRED_FOR_MULTIDECLARATION = DiagnosticFactory0.create(ERROR, DEFAULT);
|
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);
|
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
|
// Super calls
|
||||||
|
|
||||||
@@ -535,30 +535,30 @@ public interface Errors {
|
|||||||
ASSIGN_OPERATOR_AMBIGUITY = DiagnosticFactory1.create(ERROR);
|
ASSIGN_OPERATOR_AMBIGUITY = DiagnosticFactory1.create(ERROR);
|
||||||
|
|
||||||
DiagnosticFactory0<KtSimpleNameExpression> EQUALS_MISSING = DiagnosticFactory0.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);
|
DiagnosticFactory3.create(ERROR);
|
||||||
|
|
||||||
|
|
||||||
DiagnosticFactory1<KtExpression, KtType> HAS_NEXT_MISSING = DiagnosticFactory1.create(ERROR);
|
DiagnosticFactory1<KtExpression, KotlinType> HAS_NEXT_MISSING = DiagnosticFactory1.create(ERROR);
|
||||||
DiagnosticFactory1<KtExpression, KtType> HAS_NEXT_FUNCTION_AMBIGUITY = DiagnosticFactory1.create(ERROR);
|
DiagnosticFactory1<KtExpression, KotlinType> HAS_NEXT_FUNCTION_AMBIGUITY = DiagnosticFactory1.create(ERROR);
|
||||||
DiagnosticFactory1<KtExpression, KtType> HAS_NEXT_FUNCTION_NONE_APPLICABLE = DiagnosticFactory1.create(ERROR);
|
DiagnosticFactory1<KtExpression, KotlinType> HAS_NEXT_FUNCTION_NONE_APPLICABLE = DiagnosticFactory1.create(ERROR);
|
||||||
DiagnosticFactory1<KtExpression, KtType> HAS_NEXT_FUNCTION_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR);
|
DiagnosticFactory1<KtExpression, KotlinType> HAS_NEXT_FUNCTION_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR);
|
||||||
|
|
||||||
DiagnosticFactory1<KtExpression, KtType> NEXT_AMBIGUITY = DiagnosticFactory1.create(ERROR);
|
DiagnosticFactory1<KtExpression, KotlinType> NEXT_AMBIGUITY = DiagnosticFactory1.create(ERROR);
|
||||||
DiagnosticFactory1<KtExpression, KtType> NEXT_MISSING = DiagnosticFactory1.create(ERROR);
|
DiagnosticFactory1<KtExpression, KotlinType> NEXT_MISSING = DiagnosticFactory1.create(ERROR);
|
||||||
DiagnosticFactory1<KtExpression, KtType> NEXT_NONE_APPLICABLE = DiagnosticFactory1.create(ERROR);
|
DiagnosticFactory1<KtExpression, KotlinType> NEXT_NONE_APPLICABLE = DiagnosticFactory1.create(ERROR);
|
||||||
|
|
||||||
DiagnosticFactory0<KtExpression> ITERATOR_MISSING = DiagnosticFactory0.create(ERROR);
|
DiagnosticFactory0<KtExpression> ITERATOR_MISSING = DiagnosticFactory0.create(ERROR);
|
||||||
DiagnosticFactory1<PsiElement, Collection<? extends ResolvedCall<?>>> ITERATOR_AMBIGUITY = DiagnosticFactory1.create(ERROR);
|
DiagnosticFactory1<PsiElement, Collection<? extends ResolvedCall<?>>> ITERATOR_AMBIGUITY = DiagnosticFactory1.create(ERROR);
|
||||||
|
|
||||||
DiagnosticFactory2<KtExpression, String, KtType> DELEGATE_SPECIAL_FUNCTION_MISSING = DiagnosticFactory2.create(ERROR);
|
DiagnosticFactory2<KtExpression, String, KotlinType> DELEGATE_SPECIAL_FUNCTION_MISSING = DiagnosticFactory2.create(ERROR);
|
||||||
DiagnosticFactory3<PsiElement, FunctionDescriptor, KtType, String> DELEGATE_RESOLVED_TO_DEPRECATED_CONVENTION = DiagnosticFactory3.create(WARNING);
|
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_AMBIGUITY = DiagnosticFactory2.create(ERROR);
|
||||||
DiagnosticFactory2<KtExpression, String, Collection<? extends ResolvedCall<?>>> DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE = 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);
|
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);
|
DiagnosticFactory0<PsiElement> UNDERSCORE_IS_RESERVED = DiagnosticFactory0.create(ERROR);
|
||||||
DiagnosticFactory1<PsiElement, String> INVALID_CHARACTERS = DiagnosticFactory1.create(ERROR);
|
DiagnosticFactory1<PsiElement, String> INVALID_CHARACTERS = DiagnosticFactory1.create(ERROR);
|
||||||
@@ -616,14 +616,14 @@ public interface Errors {
|
|||||||
|
|
||||||
// Nullability
|
// 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);
|
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);
|
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);
|
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);
|
DiagnosticFactory0<PsiElement> USELESS_ELVIS_ON_FUNCTION_LITERAL = DiagnosticFactory0.create(WARNING);
|
||||||
|
|
||||||
// Compile-time values
|
// Compile-time values
|
||||||
@@ -633,27 +633,27 @@ public interface Errors {
|
|||||||
DiagnosticFactory0<KtConstantExpression> WRONG_LONG_SUFFIX = DiagnosticFactory0.create(ERROR, LONG_LITERAL_SUFFIX);
|
DiagnosticFactory0<KtConstantExpression> WRONG_LONG_SUFFIX = DiagnosticFactory0.create(ERROR, LONG_LITERAL_SUFFIX);
|
||||||
DiagnosticFactory0<KtConstantExpression> INT_LITERAL_OUT_OF_RANGE = DiagnosticFactory0.create(ERROR);
|
DiagnosticFactory0<KtConstantExpression> INT_LITERAL_OUT_OF_RANGE = DiagnosticFactory0.create(ERROR);
|
||||||
DiagnosticFactory0<KtConstantExpression> FLOAT_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> INCORRECT_CHARACTER_LITERAL = DiagnosticFactory0.create(ERROR);
|
||||||
DiagnosticFactory0<KtConstantExpression> EMPTY_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<KtConstantExpression, KtConstantExpression> TOO_MANY_CHARACTERS_IN_CHARACTER_LITERAL = DiagnosticFactory1.create(ERROR);
|
||||||
DiagnosticFactory1<KtElement, KtElement> ILLEGAL_ESCAPE = DiagnosticFactory1.create(ERROR, CUT_CHAR_QUOTES);
|
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);
|
DiagnosticFactory0<KtEscapeStringTemplateEntry> ILLEGAL_ESCAPE_SEQUENCE = DiagnosticFactory0.create(ERROR);
|
||||||
|
|
||||||
// Casts and is-checks
|
// Casts and is-checks
|
||||||
|
|
||||||
DiagnosticFactory1<KtElement, KtType> CANNOT_CHECK_FOR_ERASED = DiagnosticFactory1.create(ERROR);
|
DiagnosticFactory1<KtElement, KotlinType> CANNOT_CHECK_FOR_ERASED = DiagnosticFactory1.create(ERROR);
|
||||||
DiagnosticFactory2<KtBinaryExpressionWithTypeRHS, KtType, KtType> UNCHECKED_CAST = DiagnosticFactory2.create(WARNING);
|
DiagnosticFactory2<KtBinaryExpressionWithTypeRHS, KotlinType, KotlinType> UNCHECKED_CAST = DiagnosticFactory2.create(WARNING);
|
||||||
|
|
||||||
DiagnosticFactory0<KtBinaryExpressionWithTypeRHS> USELESS_CAST = DiagnosticFactory0.create(WARNING, AS_TYPE);
|
DiagnosticFactory0<KtBinaryExpressionWithTypeRHS> USELESS_CAST = DiagnosticFactory0.create(WARNING, AS_TYPE);
|
||||||
DiagnosticFactory0<KtSimpleNameExpression> CAST_NEVER_SUCCEEDS = DiagnosticFactory0.create(WARNING);
|
DiagnosticFactory0<KtSimpleNameExpression> CAST_NEVER_SUCCEEDS = DiagnosticFactory0.create(WARNING);
|
||||||
DiagnosticFactory0<KtTypeReference> DYNAMIC_NOT_ALLOWED = DiagnosticFactory0.create(ERROR);
|
DiagnosticFactory0<KtTypeReference> DYNAMIC_NOT_ALLOWED = DiagnosticFactory0.create(ERROR);
|
||||||
DiagnosticFactory0<KtTypeReference> IS_ENUM_ENTRY = 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);
|
DiagnosticFactory0<KtNullableType> USELESS_NULLABLE_CHECK = DiagnosticFactory0.create(WARNING, NULLABLE_TYPE);
|
||||||
|
|
||||||
@@ -686,20 +686,20 @@ public interface Errors {
|
|||||||
|
|
||||||
// Type mismatch
|
// Type mismatch
|
||||||
|
|
||||||
DiagnosticFactory2<KtExpression, KtType, KtType> TYPE_MISMATCH = DiagnosticFactory2.create(ERROR);
|
DiagnosticFactory2<KtExpression, KotlinType, KotlinType> TYPE_MISMATCH = DiagnosticFactory2.create(ERROR);
|
||||||
DiagnosticFactory1<KtExpression, KtType> RETURN_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR);
|
DiagnosticFactory1<KtExpression, KotlinType> RETURN_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR);
|
||||||
DiagnosticFactory1<KtExpression, KtType> EXPECTED_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR);
|
DiagnosticFactory1<KtExpression, KotlinType> EXPECTED_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR);
|
||||||
DiagnosticFactory1<KtBinaryExpression, KtType> ASSIGNMENT_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR);
|
DiagnosticFactory1<KtBinaryExpression, KotlinType> ASSIGNMENT_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR);
|
||||||
DiagnosticFactory2<KtTypeReference, KtType, KtType> TYPE_MISMATCH_IN_FOR_LOOP = DiagnosticFactory2.create(ERROR);
|
DiagnosticFactory2<KtTypeReference, KotlinType, KotlinType> TYPE_MISMATCH_IN_FOR_LOOP = DiagnosticFactory2.create(ERROR);
|
||||||
DiagnosticFactory1<KtElement, KtType> TYPE_MISMATCH_IN_CONDITION = DiagnosticFactory1.create(ERROR);
|
DiagnosticFactory1<KtElement, KotlinType> TYPE_MISMATCH_IN_CONDITION = DiagnosticFactory1.create(ERROR);
|
||||||
DiagnosticFactory3<KtExpression, String, KtType, KtType> RESULT_TYPE_MISMATCH = DiagnosticFactory3.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);
|
DiagnosticFactory0<KtWhenConditionInRange> TYPE_MISMATCH_IN_RANGE = DiagnosticFactory0.create(ERROR, WHEN_CONDITION_IN_RANGE);
|
||||||
|
|
||||||
DiagnosticFactory1<KtParameter, KtType> EXPECTED_PARAMETER_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR);
|
DiagnosticFactory1<KtParameter, KotlinType> EXPECTED_PARAMETER_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR);
|
||||||
DiagnosticFactory2<KtFunction, Integer, List<KtType>> EXPECTED_PARAMETERS_NUMBER_MISMATCH =
|
DiagnosticFactory2<KtFunction, Integer, List<KotlinType>> EXPECTED_PARAMETERS_NUMBER_MISMATCH =
|
||||||
DiagnosticFactory2.create(ERROR, FUNCTION_PARAMETERS);
|
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);
|
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.MultiRenderer;
|
||||||
import org.jetbrains.kotlin.renderer.Renderer;
|
import org.jetbrains.kotlin.renderer.Renderer;
|
||||||
import org.jetbrains.kotlin.resolve.varianceChecker.VarianceChecker.VarianceConflictDiagnosticData;
|
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.MappedExtensionProvider;
|
||||||
import org.jetbrains.kotlin.util.OperatorNameConventions;
|
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. " +
|
MAP.put(FUNCTION_EXPECTED, "Expression ''{0}''{1} cannot be invoked as a function. " +
|
||||||
"The function '" + OperatorNameConventions.INVOKE.asString() + "()' is not found",
|
"The function '" + OperatorNameConventions.INVOKE.asString() + "()' is not found",
|
||||||
ELEMENT_TEXT, new Renderer<KtType>() {
|
ELEMENT_TEXT, new Renderer<KotlinType>() {
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public String render(@NotNull KtType type) {
|
public String render(@NotNull KotlinType type) {
|
||||||
if (type.isError()) return "";
|
if (type.isError()) return "";
|
||||||
return " of type '" + RENDER_TYPE.render(type) + "'";
|
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.RECEIVER_POSITION
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind.VALUE_PARAMETER_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.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.TypeUtils
|
||||||
import org.jetbrains.kotlin.types.Variance
|
import org.jetbrains.kotlin.types.Variance
|
||||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
|
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_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 {
|
public val RENDER_POSITION_VARIANCE: Renderer<Variance> = Renderer {
|
||||||
variance: Variance ->
|
variance: Variance ->
|
||||||
@@ -179,7 +179,7 @@ public object Renderers {
|
|||||||
val receiverType = DescriptorUtils.getReceiverParameterType(substitutedDescriptor.getExtensionReceiverParameter())
|
val receiverType = DescriptorUtils.getReceiverParameterType(substitutedDescriptor.getExtensionReceiverParameter())
|
||||||
|
|
||||||
val errorPositions = Sets.newHashSet<ConstraintPosition>()
|
val errorPositions = Sets.newHashSet<ConstraintPosition>()
|
||||||
val parameterTypes = Lists.newArrayList<KtType>()
|
val parameterTypes = Lists.newArrayList<KotlinType>()
|
||||||
for (valueParameterDescriptor in substitutedDescriptor.getValueParameters()) {
|
for (valueParameterDescriptor in substitutedDescriptor.getValueParameters()) {
|
||||||
parameterTypes.add(valueParameterDescriptor.getType())
|
parameterTypes.add(valueParameterDescriptor.getType())
|
||||||
if (valueParameterDescriptor.getIndex() >= inferenceErrorData.valueArgumentsTypes.size()) continue
|
if (valueParameterDescriptor.getIndex() >= inferenceErrorData.valueArgumentsTypes.size()) continue
|
||||||
@@ -279,7 +279,7 @@ public object Renderers {
|
|||||||
.table(newTable()
|
.table(newTable()
|
||||||
.descriptor(inferenceErrorData.descriptor))
|
.descriptor(inferenceErrorData.descriptor))
|
||||||
|
|
||||||
var violatedUpperBound: KtType? = null
|
var violatedUpperBound: KotlinType? = null
|
||||||
for (upperBound in typeParameterDescriptor.getUpperBounds()) {
|
for (upperBound in typeParameterDescriptor.getUpperBounds()) {
|
||||||
val upperBoundWithSubstitutedInferredTypes = systemWithoutWeakConstraints.getResultingSubstitutor().substitute(upperBound, Variance.INVARIANT)
|
val upperBoundWithSubstitutedInferredTypes = systemWithoutWeakConstraints.getResultingSubstitutor().substitute(upperBound, Variance.INVARIANT)
|
||||||
if (upperBoundWithSubstitutedInferredTypes != null
|
if (upperBoundWithSubstitutedInferredTypes != null
|
||||||
@@ -356,9 +356,9 @@ public object Renderers {
|
|||||||
}.toString()
|
}.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 {
|
private fun renderConstraintSystem(constraintSystem: ConstraintSystem, renderTypeBounds: Renderer<TypeBounds>): String {
|
||||||
val typeVariables = constraintSystem.getTypeVariables()
|
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.DescriptorRenderer;
|
||||||
import org.jetbrains.kotlin.renderer.Renderer;
|
import org.jetbrains.kotlin.renderer.Renderer;
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPosition;
|
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.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -50,11 +50,11 @@ public class TabledDescriptorRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class FunctionArgumentsRow implements TableRow {
|
public static class FunctionArgumentsRow implements TableRow {
|
||||||
public final KtType receiverType;
|
public final KotlinType receiverType;
|
||||||
public final List<KtType> argumentTypes;
|
public final List<KotlinType> argumentTypes;
|
||||||
public final Predicate<ConstraintPosition> isErrorPosition;
|
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.receiverType = receiverType;
|
||||||
this.argumentTypes = argumentTypes;
|
this.argumentTypes = argumentTypes;
|
||||||
this.isErrorPosition = isErrorPosition;
|
this.isErrorPosition = isErrorPosition;
|
||||||
@@ -68,13 +68,13 @@ public class TabledDescriptorRenderer {
|
|||||||
return this;
|
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());
|
return functionArgumentTypeList(receiverType, argumentTypes, Predicates.<ConstraintPosition>alwaysFalse());
|
||||||
}
|
}
|
||||||
|
|
||||||
public TableRenderer functionArgumentTypeList(@Nullable KtType receiverType,
|
public TableRenderer functionArgumentTypeList(@Nullable KotlinType receiverType,
|
||||||
@NotNull List<KtType> argumentTypes,
|
@NotNull List<KotlinType> argumentTypes,
|
||||||
@NotNull Predicate<ConstraintPosition> isErrorPosition) {
|
@NotNull Predicate<ConstraintPosition> isErrorPosition) {
|
||||||
rows.add(new FunctionArgumentsRow(receiverType, argumentTypes, isErrorPosition));
|
rows.add(new FunctionArgumentsRow(receiverType, argumentTypes, isErrorPosition));
|
||||||
return this;
|
return this;
|
||||||
@@ -156,7 +156,7 @@ public class TabledDescriptorRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public Renderer<KtType> getTypeRenderer() {
|
public Renderer<KotlinType> getTypeRenderer() {
|
||||||
return Renderers.RENDER_TYPE;
|
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;
|
boolean hasReceiver = receiverType != null;
|
||||||
if (hasReceiver) {
|
if (hasReceiver) {
|
||||||
result.append("receiver: ");
|
result.append("receiver: ");
|
||||||
@@ -196,8 +196,8 @@ public class TabledDescriptorRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
result.append("(");
|
result.append("(");
|
||||||
for (Iterator<KtType> iterator = argumentTypes.iterator(); iterator.hasNext(); ) {
|
for (Iterator<KotlinType> iterator = argumentTypes.iterator(); iterator.hasNext(); ) {
|
||||||
KtType argumentType = iterator.next();
|
KotlinType argumentType = iterator.next();
|
||||||
String renderedArgument = getTypeRenderer().render(argumentType);
|
String renderedArgument = getTypeRenderer().render(argumentType);
|
||||||
|
|
||||||
result.append(renderedArgument);
|
result.append(renderedArgument);
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import org.jetbrains.kotlin.psi.KtNamedFunction;
|
|||||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
import org.jetbrains.kotlin.resolve.BindingContext;
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
||||||
import org.jetbrains.kotlin.resolve.annotations.AnnotationUtilKt;
|
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.TypeProjection;
|
||||||
import org.jetbrains.kotlin.types.Variance;
|
import org.jetbrains.kotlin.types.Variance;
|
||||||
|
|
||||||
@@ -89,13 +89,13 @@ public class MainFunctionDetector {
|
|||||||
if (parameters.size() != 1) return false;
|
if (parameters.size() != 1) return false;
|
||||||
|
|
||||||
ValueParameterDescriptor parameter = parameters.get(0);
|
ValueParameterDescriptor parameter = parameters.get(0);
|
||||||
KtType parameterType = parameter.getType();
|
KotlinType parameterType = parameter.getType();
|
||||||
if (!KotlinBuiltIns.isArray(parameterType)) return false;
|
if (!KotlinBuiltIns.isArray(parameterType)) return false;
|
||||||
|
|
||||||
List<TypeProjection> typeArguments = parameterType.getArguments();
|
List<TypeProjection> typeArguments = parameterType.getArguments();
|
||||||
if (typeArguments.size() != 1) return false;
|
if (typeArguments.size() != 1) return false;
|
||||||
|
|
||||||
KtType typeArgument = typeArguments.get(0).getType();
|
KotlinType typeArgument = typeArguments.get(0).getType();
|
||||||
if (!KotlinBuiltIns.isString(typeArgument)) {
|
if (!KotlinBuiltIns.isString(typeArgument)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import com.intellij.psi.search.GlobalSearchScope
|
|||||||
import com.intellij.psi.tree.IElementType
|
import com.intellij.psi.tree.IElementType
|
||||||
import com.intellij.testFramework.LightVirtualFile
|
import com.intellij.testFramework.LightVirtualFile
|
||||||
import org.jetbrains.kotlin.idea.KotlinFileType
|
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 org.jetbrains.kotlin.utils.addToStdlib.check
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
@@ -131,7 +131,7 @@ public abstract class KtCodeFragment(
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
public val IMPORT_SEPARATOR: String = ","
|
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")
|
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.KtCodeFragment
|
||||||
import org.jetbrains.kotlin.psi.KtFile
|
import org.jetbrains.kotlin.psi.KtFile
|
||||||
import org.jetbrains.kotlin.psi.KtTypeReference
|
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")
|
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_REFERENCE_STRING: String = "DebugTypeKotlinRulezzzz"
|
||||||
|
|
||||||
public val DEBUG_TYPE_INFO: Key<KtType> = Key.create<KtType>("DEBUG_TYPE_INFO")
|
public val DEBUG_TYPE_INFO: Key<KotlinType> = Key.create<KotlinType>("DEBUG_TYPE_INFO")
|
||||||
public var KtTypeReference.debugTypeInfo: KtType?
|
public var KtTypeReference.debugTypeInfo: KotlinType?
|
||||||
get() = getUserData(DEBUG_TYPE_INFO)
|
get() = getUserData(DEBUG_TYPE_INFO)
|
||||||
set(type: KtType?) {
|
set(type: KotlinType?) {
|
||||||
if (type != null && this.getText() == DEBUG_TYPE_REFERENCE_STRING) {
|
if (type != null && this.getText() == DEBUG_TYPE_REFERENCE_STRING) {
|
||||||
putUserData(DEBUG_TYPE_INFO, type)
|
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.name.Name
|
||||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||||
import org.jetbrains.kotlin.resolve.scopes.KtScope
|
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
|
import org.jetbrains.kotlin.utils.Printer
|
||||||
|
|
||||||
class AllUnderImportsScope(descriptor: DeclarationDescriptor) : KtScope {
|
class AllUnderImportsScope(descriptor: DeclarationDescriptor) : KtScope {
|
||||||
@@ -51,19 +51,19 @@ class AllUnderImportsScope(descriptor: DeclarationDescriptor) : KtScope {
|
|||||||
return scopes.flatMap { it.getFunctions(name, location) }
|
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) }
|
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) }
|
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) }
|
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) }
|
return scopes.flatMap { it.getSyntheticExtensionFunctions(receiverTypes) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,15 +18,15 @@ package org.jetbrains.kotlin.resolve;
|
|||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.kotlin.name.Name;
|
import org.jetbrains.kotlin.name.Name;
|
||||||
import org.jetbrains.kotlin.types.KtType;
|
import org.jetbrains.kotlin.types.KotlinType;
|
||||||
|
|
||||||
public class AnalyzerScriptParameter {
|
public class AnalyzerScriptParameter {
|
||||||
@NotNull
|
@NotNull
|
||||||
private final Name name;
|
private final Name name;
|
||||||
@NotNull
|
@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.name = name;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
@@ -37,7 +37,7 @@ public class AnalyzerScriptParameter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public KtType getType() {
|
public KotlinType getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import org.jetbrains.kotlin.psi.*
|
|||||||
import org.jetbrains.kotlin.psi.psiUtil.getAnnotationEntries
|
import org.jetbrains.kotlin.psi.psiUtil.getAnnotationEntries
|
||||||
import org.jetbrains.kotlin.resolve.constants.ArrayValue
|
import org.jetbrains.kotlin.resolve.constants.ArrayValue
|
||||||
import org.jetbrains.kotlin.resolve.constants.EnumValue
|
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.types.TypeUtils
|
||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.isRepeatableAnnotation
|
import org.jetbrains.kotlin.resolve.descriptorUtil.isRepeatableAnnotation
|
||||||
import org.jetbrains.kotlin.descriptors.annotations.KotlinTarget.*
|
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) {
|
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) {
|
for (entry in entries) {
|
||||||
checkAnnotationEntry(entry, actualTargets, trace)
|
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.resolve.scopes.receivers.ReceiverValue;
|
||||||
import org.jetbrains.kotlin.storage.StorageManager;
|
import org.jetbrains.kotlin.storage.StorageManager;
|
||||||
import org.jetbrains.kotlin.types.ErrorUtils;
|
import org.jetbrains.kotlin.types.ErrorUtils;
|
||||||
import org.jetbrains.kotlin.types.KtType;
|
import org.jetbrains.kotlin.types.KotlinType;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -147,13 +147,13 @@ public class AnnotationResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@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();
|
KtTypeReference typeReference = entryElement.getTypeReference();
|
||||||
if (typeReference == null) {
|
if (typeReference == null) {
|
||||||
return ErrorUtils.createErrorType("No type reference: " + entryElement.getText());
|
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)) {
|
if (!(type.getConstructor().getDeclarationDescriptor() instanceof ClassDescriptor)) {
|
||||||
return ErrorUtils.createErrorType("Not an annotation: " + type);
|
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.LexicalScope;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.Qualifier;
|
import org.jetbrains.kotlin.resolve.scopes.receivers.Qualifier;
|
||||||
import org.jetbrains.kotlin.types.DeferredType;
|
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.CaptureKind;
|
||||||
import org.jetbrains.kotlin.types.expressions.JetTypeInfo;
|
import org.jetbrains.kotlin.types.expressions.JetTypeInfo;
|
||||||
import org.jetbrains.kotlin.types.expressions.PreliminaryDeclarationVisitor;
|
import org.jetbrains.kotlin.types.expressions.PreliminaryDeclarationVisitor;
|
||||||
@@ -77,7 +77,7 @@ public interface BindingContext {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public KtType getType(@NotNull KtExpression expression) {
|
public KotlinType getType(@NotNull KtExpression expression) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,10 +91,10 @@ public interface BindingContext {
|
|||||||
|
|
||||||
WritableSlice<KtExpression, CompileTimeConstant<?>> COMPILE_TIME_VALUE = Slices.createSimpleSlice();
|
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, JetTypeInfo> EXPRESSION_TYPE_INFO = new BasicWritableSlice<KtExpression, JetTypeInfo>(DO_NOTHING);
|
||||||
WritableSlice<KtExpression, KtType> EXPECTED_EXPRESSION_TYPE = new BasicWritableSlice<KtExpression, KtType>(DO_NOTHING);
|
WritableSlice<KtExpression, KotlinType> EXPECTED_EXPRESSION_TYPE = new BasicWritableSlice<KtExpression, KotlinType>(DO_NOTHING);
|
||||||
WritableSlice<KtFunction, KtType> EXPECTED_RETURN_TYPE = new BasicWritableSlice<KtFunction, KtType>(DO_NOTHING);
|
WritableSlice<KtFunction, KotlinType> EXPECTED_RETURN_TYPE = new BasicWritableSlice<KtFunction, KotlinType>(DO_NOTHING);
|
||||||
WritableSlice<KtExpression, DataFlowInfo> DATAFLOW_INFO_AFTER_CONDITION = Slices.createSimpleSlice();
|
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_GET = Slices.createSimpleSlice();
|
||||||
WritableSlice<KtExpression, ResolvedCall<FunctionDescriptor>> INDEXED_LVALUE_SET = 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();
|
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);
|
<K, V> ImmutableMap<K, V> getSliceContents(@NotNull ReadOnlySlice<K, V> slice);
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
KtType getType(@NotNull KtExpression expression);
|
KotlinType getType(@NotNull KtExpression expression);
|
||||||
|
|
||||||
void addOwnDataTo(@NotNull BindingTrace trace, boolean commitDiagnostics);
|
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.model.VariableAsFunctionResolvedCall;
|
||||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
|
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
|
||||||
import org.jetbrains.kotlin.resolve.diagnostics.MutableDiagnosticsWithSuppression;
|
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.TypeUtils;
|
||||||
import org.jetbrains.kotlin.types.expressions.JetTypeInfo;
|
import org.jetbrains.kotlin.types.expressions.JetTypeInfo;
|
||||||
import org.jetbrains.kotlin.types.expressions.typeInfoFactory.TypeInfoFactoryKt;
|
import org.jetbrains.kotlin.types.expressions.typeInfoFactory.TypeInfoFactoryKt;
|
||||||
@@ -81,11 +81,11 @@ public class BindingContextUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static KtType getTypeNotNull(
|
public static KotlinType getTypeNotNull(
|
||||||
@NotNull BindingContext bindingContext,
|
@NotNull BindingContext bindingContext,
|
||||||
@NotNull KtExpression expression
|
@NotNull KtExpression expression
|
||||||
) {
|
) {
|
||||||
KtType result = bindingContext.getType(expression);
|
KotlinType result = bindingContext.getType(expression);
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
throw new IllegalStateException("Type must be not null for " + expression);
|
throw new IllegalStateException("Type must be not null for " + expression);
|
||||||
}
|
}
|
||||||
@@ -140,8 +140,8 @@ public class BindingContextUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static KtType updateRecordedType(
|
public static KotlinType updateRecordedType(
|
||||||
@Nullable KtType type,
|
@Nullable KotlinType type,
|
||||||
@NotNull KtExpression expression,
|
@NotNull KtExpression expression,
|
||||||
@NotNull BindingTrace trace,
|
@NotNull BindingTrace trace,
|
||||||
boolean shouldBeMadeNullable
|
boolean shouldBeMadeNullable
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.kotlin.diagnostics.DiagnosticSink;
|
import org.jetbrains.kotlin.diagnostics.DiagnosticSink;
|
||||||
import org.jetbrains.kotlin.psi.KtExpression;
|
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.ReadOnlySlice;
|
||||||
import org.jetbrains.kotlin.util.slicedMap.WritableSlice;
|
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
|
* Expression type should be taken from EXPRESSION_TYPE_INFO slice
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
KtType getType(@NotNull KtExpression expression);
|
KotlinType getType(@NotNull KtExpression expression);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Expression type should be recorded into EXPRESSION_TYPE_INFO slice
|
* Expression type should be recorded into EXPRESSION_TYPE_INFO slice
|
||||||
* (either updated old or a new one)
|
* (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.psi.KtExpression;
|
||||||
import org.jetbrains.kotlin.resolve.diagnostics.Diagnostics;
|
import org.jetbrains.kotlin.resolve.diagnostics.Diagnostics;
|
||||||
import org.jetbrains.kotlin.resolve.diagnostics.MutableDiagnosticsWithSuppression;
|
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.JetTypeInfo;
|
||||||
import org.jetbrains.kotlin.types.expressions.typeInfoFactory.TypeInfoFactoryKt;
|
import org.jetbrains.kotlin.types.expressions.typeInfoFactory.TypeInfoFactoryKt;
|
||||||
import org.jetbrains.kotlin.util.slicedMap.*;
|
import org.jetbrains.kotlin.util.slicedMap.*;
|
||||||
@@ -67,7 +67,7 @@ public class BindingTraceContext implements BindingTrace {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public KtType getType(@NotNull KtExpression expression) {
|
public KotlinType getType(@NotNull KtExpression expression) {
|
||||||
return BindingTraceContext.this.getType(expression);
|
return BindingTraceContext.this.getType(expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,13 +131,13 @@ public class BindingTraceContext implements BindingTrace {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public KtType getType(@NotNull KtExpression expression) {
|
public KotlinType getType(@NotNull KtExpression expression) {
|
||||||
JetTypeInfo typeInfo = get(BindingContext.EXPRESSION_TYPE_INFO, expression);
|
JetTypeInfo typeInfo = get(BindingContext.EXPRESSION_TYPE_INFO, expression);
|
||||||
return typeInfo != null ? typeInfo.getType() : null;
|
return typeInfo != null ? typeInfo.getType() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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);
|
JetTypeInfo typeInfo = get(BindingContext.EXPRESSION_TYPE_INFO, expression);
|
||||||
typeInfo = typeInfo != null ? typeInfo.replaceType(type) : TypeInfoFactoryKt.createTypeInfo(type);
|
typeInfo = typeInfo != null ? typeInfo.replaceType(type) : TypeInfoFactoryKt.createTypeInfo(type);
|
||||||
record(BindingContext.EXPRESSION_TYPE_INFO, expression, typeInfo);
|
record(BindingContext.EXPRESSION_TYPE_INFO, expression, typeInfo);
|
||||||
|
|||||||
@@ -262,10 +262,10 @@ public class BodyResolver {
|
|||||||
: FunctionDescriptorUtil.getFunctionInnerScope(scopeForSupertypeResolution, primaryConstructor, trace);
|
: FunctionDescriptorUtil.getFunctionInnerScope(scopeForSupertypeResolution, primaryConstructor, trace);
|
||||||
final ExpressionTypingServices typeInferrer = expressionTypingServices; // TODO : flow
|
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];
|
final ResolvedCall<?>[] primaryConstructorDelegationCall = new ResolvedCall[1];
|
||||||
KtVisitorVoid visitor = new KtVisitorVoid() {
|
KtVisitorVoid visitor = new KtVisitorVoid() {
|
||||||
private void recordSupertype(KtTypeReference typeReference, KtType supertype) {
|
private void recordSupertype(KtTypeReference typeReference, KotlinType supertype) {
|
||||||
if (supertype == null) return;
|
if (supertype == null) return;
|
||||||
supertypes.put(typeReference, supertype);
|
supertypes.put(typeReference, supertype);
|
||||||
}
|
}
|
||||||
@@ -275,7 +275,7 @@ public class BodyResolver {
|
|||||||
if (descriptor.getKind() == ClassKind.INTERFACE) {
|
if (descriptor.getKind() == ClassKind.INTERFACE) {
|
||||||
trace.report(DELEGATION_IN_INTERFACE.on(specifier));
|
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);
|
recordSupertype(specifier.getTypeReference(), supertype);
|
||||||
if (supertype != null) {
|
if (supertype != null) {
|
||||||
DeclarationDescriptor declarationDescriptor = supertype.getConstructor().getDeclarationDescriptor();
|
DeclarationDescriptor declarationDescriptor = supertype.getConstructor().getDeclarationDescriptor();
|
||||||
@@ -289,7 +289,7 @@ public class BodyResolver {
|
|||||||
KtExpression delegateExpression = specifier.getDelegateExpression();
|
KtExpression delegateExpression = specifier.getDelegateExpression();
|
||||||
if (delegateExpression != null) {
|
if (delegateExpression != null) {
|
||||||
LexicalScope scope = scopeForConstructor == null ? scopeForMemberResolution : scopeForConstructor;
|
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);
|
typeInferrer.getType(scope, delegateExpression, expectedType, outerDataFlowInfo, trace);
|
||||||
}
|
}
|
||||||
if (primaryConstructor == null) {
|
if (primaryConstructor == null) {
|
||||||
@@ -317,7 +317,7 @@ public class BodyResolver {
|
|||||||
trace, scopeForConstructor,
|
trace, scopeForConstructor,
|
||||||
CallMaker.makeCall(ReceiverValue.NO_RECEIVER, null, call), NO_EXPECTED_TYPE, outerDataFlowInfo, false);
|
CallMaker.makeCall(ReceiverValue.NO_RECEIVER, null, call), NO_EXPECTED_TYPE, outerDataFlowInfo, false);
|
||||||
if (results.isSuccess()) {
|
if (results.isSuccess()) {
|
||||||
KtType supertype = results.getResultingDescriptor().getReturnType();
|
KotlinType supertype = results.getResultingDescriptor().getReturnType();
|
||||||
recordSupertype(typeReference, supertype);
|
recordSupertype(typeReference, supertype);
|
||||||
ClassDescriptor classDescriptor = TypeUtils.getClassDescriptor(supertype);
|
ClassDescriptor classDescriptor = TypeUtils.getClassDescriptor(supertype);
|
||||||
if (classDescriptor != null) {
|
if (classDescriptor != null) {
|
||||||
@@ -342,7 +342,7 @@ public class BodyResolver {
|
|||||||
@Override
|
@Override
|
||||||
public void visitDelegationToSuperClassSpecifier(@NotNull KtDelegatorToSuperClass specifier) {
|
public void visitDelegationToSuperClassSpecifier(@NotNull KtDelegatorToSuperClass specifier) {
|
||||||
KtTypeReference typeReference = specifier.getTypeReference();
|
KtTypeReference typeReference = specifier.getTypeReference();
|
||||||
KtType supertype = trace.getBindingContext().get(BindingContext.TYPE, typeReference);
|
KotlinType supertype = trace.getBindingContext().get(BindingContext.TYPE, typeReference);
|
||||||
recordSupertype(typeReference, supertype);
|
recordSupertype(typeReference, supertype);
|
||||||
if (supertype == null) return;
|
if (supertype == null) return;
|
||||||
ClassDescriptor superClass = TypeUtils.getClassDescriptor(supertype);
|
ClassDescriptor superClass = TypeUtils.getClassDescriptor(supertype);
|
||||||
@@ -419,15 +419,15 @@ public class BodyResolver {
|
|||||||
|
|
||||||
private void checkSupertypeList(
|
private void checkSupertypeList(
|
||||||
@NotNull ClassDescriptor supertypeOwner,
|
@NotNull ClassDescriptor supertypeOwner,
|
||||||
@NotNull Map<KtTypeReference, KtType> supertypes,
|
@NotNull Map<KtTypeReference, KotlinType> supertypes,
|
||||||
@NotNull KtClassOrObject jetClass
|
@NotNull KtClassOrObject jetClass
|
||||||
) {
|
) {
|
||||||
Set<TypeConstructor> allowedFinalSupertypes = getAllowedFinalSupertypes(supertypeOwner, jetClass);
|
Set<TypeConstructor> allowedFinalSupertypes = getAllowedFinalSupertypes(supertypeOwner, jetClass);
|
||||||
Set<TypeConstructor> typeConstructors = Sets.newHashSet();
|
Set<TypeConstructor> typeConstructors = Sets.newHashSet();
|
||||||
boolean classAppeared = false;
|
boolean classAppeared = false;
|
||||||
for (Map.Entry<KtTypeReference, KtType> entry : supertypes.entrySet()) {
|
for (Map.Entry<KtTypeReference, KotlinType> entry : supertypes.entrySet()) {
|
||||||
KtTypeReference typeReference = entry.getKey();
|
KtTypeReference typeReference = entry.getKey();
|
||||||
KtType supertype = entry.getValue();
|
KotlinType supertype = entry.getValue();
|
||||||
|
|
||||||
KtTypeElement typeElement = typeReference.getTypeElement();
|
KtTypeElement typeElement = typeReference.getTypeElement();
|
||||||
if (typeElement instanceof KtFunctionType) {
|
if (typeElement instanceof KtFunctionType) {
|
||||||
@@ -709,7 +709,7 @@ public class BodyResolver {
|
|||||||
LexicalScope accessorScope = JetScopeUtils.makeScopeForPropertyAccessor(
|
LexicalScope accessorScope = JetScopeUtils.makeScopeForPropertyAccessor(
|
||||||
propertyDescriptor, parentScopeForAccessor, trace);
|
propertyDescriptor, parentScopeForAccessor, trace);
|
||||||
|
|
||||||
KtType delegateType = delegatedPropertyResolver.resolveDelegateExpression(
|
KotlinType delegateType = delegatedPropertyResolver.resolveDelegateExpression(
|
||||||
delegateExpression, jetProperty, propertyDescriptor, propertyDeclarationInnerScope, accessorScope, trace,
|
delegateExpression, jetProperty, propertyDescriptor, propertyDeclarationInnerScope, accessorScope, trace,
|
||||||
outerDataFlowInfo);
|
outerDataFlowInfo);
|
||||||
|
|
||||||
@@ -734,7 +734,7 @@ public class BodyResolver {
|
|||||||
) {
|
) {
|
||||||
LexicalScope propertyDeclarationInnerScope = JetScopeUtils.getPropertyDeclarationInnerScopeForInitializer(
|
LexicalScope propertyDeclarationInnerScope = JetScopeUtils.getPropertyDeclarationInnerScopeForInitializer(
|
||||||
propertyDescriptor, scope, propertyDescriptor.getTypeParameters(), null, trace);
|
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) {
|
if (propertyDescriptor.getCompileTimeInitializer() == null) {
|
||||||
expressionTypingServices.getType(propertyDeclarationInnerScope, initializer, expectedTypeForInitializer,
|
expressionTypingServices.getType(propertyDeclarationInnerScope, initializer, expectedTypeForInitializer,
|
||||||
outerDataFlowInfo, trace);
|
outerDataFlowInfo, trace);
|
||||||
@@ -850,7 +850,7 @@ public class BodyResolver {
|
|||||||
valueParameterResolver.resolveValueParameters(valueParameters, valueParameterDescriptors, scope, outerDataFlowInfo, trace);
|
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
|
// handle type inference loop: function or property body contains a reference to itself
|
||||||
// fun f() = { f() }
|
// fun f() = { f() }
|
||||||
// val x = x
|
// 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.ConstantValue;
|
||||||
import org.jetbrains.kotlin.resolve.constants.TypedCompileTimeConstant;
|
import org.jetbrains.kotlin.resolve.constants.TypedCompileTimeConstant;
|
||||||
import org.jetbrains.kotlin.resolve.constants.evaluate.ConstantExpressionEvaluator;
|
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.TypeProjection;
|
||||||
import org.jetbrains.kotlin.types.TypeUtils;
|
import org.jetbrains.kotlin.types.TypeUtils;
|
||||||
|
|
||||||
@@ -60,7 +60,7 @@ public class CompileTimeConstantUtils {
|
|||||||
for (KtParameter parameter : parameters) {
|
for (KtParameter parameter : parameters) {
|
||||||
VariableDescriptor parameterDescriptor = trace.getBindingContext().get(VALUE_PARAMETER, parameter);
|
VariableDescriptor parameterDescriptor = trace.getBindingContext().get(VALUE_PARAMETER, parameter);
|
||||||
if (parameterDescriptor == null) continue;
|
if (parameterDescriptor == null) continue;
|
||||||
KtType parameterType = parameterDescriptor.getType();
|
KotlinType parameterType = parameterDescriptor.getType();
|
||||||
KtTypeReference typeReference = parameter.getTypeReference();
|
KtTypeReference typeReference = parameter.getTypeReference();
|
||||||
if (typeReference != null) {
|
if (typeReference != null) {
|
||||||
if (parameterType.isMarkedNullable()) {
|
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);
|
ClassDescriptor typeDescriptor = TypeUtils.getClassDescriptor(parameterType);
|
||||||
if (typeDescriptor == null) {
|
if (typeDescriptor == null) {
|
||||||
return false;
|
return false;
|
||||||
@@ -91,7 +91,7 @@ public class CompileTimeConstantUtils {
|
|||||||
if (KotlinBuiltIns.isArray(parameterType)) {
|
if (KotlinBuiltIns.isArray(parameterType)) {
|
||||||
List<TypeProjection> arguments = parameterType.getArguments();
|
List<TypeProjection> arguments = parameterType.getArguments();
|
||||||
if (arguments.size() == 1) {
|
if (arguments.size() == 1) {
|
||||||
KtType arrayType = arguments.get(0).getType();
|
KotlinType arrayType = arguments.get(0).getType();
|
||||||
if (arrayType.isMarkedNullable()) {
|
if (arrayType.isMarkedNullable()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,12 +24,12 @@ import com.intellij.psi.PsiElement
|
|||||||
import com.intellij.openapi.util.ModificationTracker
|
import com.intellij.openapi.util.ModificationTracker
|
||||||
import org.jetbrains.kotlin.psi.KtExpression
|
import org.jetbrains.kotlin.psi.KtExpression
|
||||||
import org.jetbrains.kotlin.resolve.diagnostics.Diagnostics
|
import org.jetbrains.kotlin.resolve.diagnostics.Diagnostics
|
||||||
import org.jetbrains.kotlin.types.KtType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
|
|
||||||
public class CompositeBindingContext private constructor(
|
public class CompositeBindingContext private constructor(
|
||||||
private val delegates: List<BindingContext>
|
private val delegates: List<BindingContext>
|
||||||
) : BindingContext {
|
) : BindingContext {
|
||||||
override fun getType(expression: KtExpression): KtType? {
|
override fun getType(expression: KtExpression): KotlinType? {
|
||||||
return delegates.asSequence().map { it.getType(expression) }.firstOrNull { it != null }
|
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.PropertyDescriptor;
|
||||||
import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor;
|
import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor;
|
||||||
import org.jetbrains.kotlin.psi.*;
|
import org.jetbrains.kotlin.psi.*;
|
||||||
import org.jetbrains.kotlin.types.KtType;
|
import org.jetbrains.kotlin.types.KotlinType;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ public class ControlFlowAnalyzer {
|
|||||||
for (Map.Entry<KtNamedFunction, SimpleFunctionDescriptor> entry : c.getFunctions().entrySet()) {
|
for (Map.Entry<KtNamedFunction, SimpleFunctionDescriptor> entry : c.getFunctions().entrySet()) {
|
||||||
KtNamedFunction function = entry.getKey();
|
KtNamedFunction function = entry.getKey();
|
||||||
SimpleFunctionDescriptor functionDescriptor = entry.getValue();
|
SimpleFunctionDescriptor functionDescriptor = entry.getValue();
|
||||||
KtType expectedReturnType = !function.hasBlockBody() && !function.hasDeclaredReturnType()
|
KotlinType expectedReturnType = !function.hasBlockBody() && !function.hasDeclaredReturnType()
|
||||||
? NO_EXPECTED_TYPE
|
? NO_EXPECTED_TYPE
|
||||||
: functionDescriptor.getReturnType();
|
: functionDescriptor.getReturnType();
|
||||||
checkFunction(c, function, expectedReturnType);
|
checkFunction(c, function, expectedReturnType);
|
||||||
@@ -87,12 +87,12 @@ public class ControlFlowAnalyzer {
|
|||||||
? propertyDescriptor.getGetter()
|
? propertyDescriptor.getGetter()
|
||||||
: propertyDescriptor.getSetter();
|
: propertyDescriptor.getSetter();
|
||||||
assert accessorDescriptor != null : "no property accessor descriptor " + accessor.getText();
|
assert accessorDescriptor != null : "no property accessor descriptor " + accessor.getText();
|
||||||
KtType returnType = accessorDescriptor.getReturnType();
|
KotlinType returnType = accessorDescriptor.getReturnType();
|
||||||
checkFunction(c, accessor, returnType);
|
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;
|
if (!function.hasBody()) return;
|
||||||
JetFlowInformationProvider flowInformationProvider = new JetFlowInformationProvider(function, trace);
|
JetFlowInformationProvider flowInformationProvider = new JetFlowInformationProvider(function, trace);
|
||||||
if (c.getTopDownAnalysisMode().isLocalDeclarations()) {
|
if (c.getTopDownAnalysisMode().isLocalDeclarations()) {
|
||||||
|
|||||||
@@ -168,7 +168,7 @@ public class DeclarationsChecker {
|
|||||||
|
|
||||||
private void checkBoundsForTypeInClassHeader(@Nullable KtTypeReference typeReference) {
|
private void checkBoundsForTypeInClassHeader(@Nullable KtTypeReference typeReference) {
|
||||||
if (typeReference != null) {
|
if (typeReference != null) {
|
||||||
KtType type = trace.getBindingContext().get(TYPE, typeReference);
|
KotlinType type = trace.getBindingContext().get(TYPE, typeReference);
|
||||||
if (type != null) {
|
if (type != null) {
|
||||||
DescriptorResolver.checkBounds(typeReference, type, trace);
|
DescriptorResolver.checkBounds(typeReference, type, trace);
|
||||||
}
|
}
|
||||||
@@ -177,7 +177,7 @@ public class DeclarationsChecker {
|
|||||||
|
|
||||||
private void checkFinalUpperBounds(@Nullable KtTypeReference typeReference) {
|
private void checkFinalUpperBounds(@Nullable KtTypeReference typeReference) {
|
||||||
if (typeReference != null) {
|
if (typeReference != null) {
|
||||||
KtType type = trace.getBindingContext().get(TYPE, typeReference);
|
KotlinType type = trace.getBindingContext().get(TYPE, typeReference);
|
||||||
if (type != null) {
|
if (type != null) {
|
||||||
DescriptorResolver.checkUpperBoundType(typeReference, type, trace);
|
DescriptorResolver.checkUpperBoundType(typeReference, type, trace);
|
||||||
}
|
}
|
||||||
@@ -213,7 +213,7 @@ public class DeclarationsChecker {
|
|||||||
TypeParameterDescriptor typeParameterDescriptor = (TypeParameterDescriptor) declarationDescriptor;
|
TypeParameterDescriptor typeParameterDescriptor = (TypeParameterDescriptor) declarationDescriptor;
|
||||||
|
|
||||||
// Immediate arguments of supertypes cannot be projected
|
// Immediate arguments of supertypes cannot be projected
|
||||||
Set<KtType> conflictingTypes = Sets.newLinkedHashSet();
|
Set<KotlinType> conflictingTypes = Sets.newLinkedHashSet();
|
||||||
for (TypeProjection projection : projections) {
|
for (TypeProjection projection : projections) {
|
||||||
conflictingTypes.add(projection.getType());
|
conflictingTypes.add(projection.getType());
|
||||||
}
|
}
|
||||||
@@ -254,7 +254,7 @@ public class DeclarationsChecker {
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
for (TypeParameterDescriptor typeParameterDescriptor : classDescriptor.getTypeConstructor().getParameters()) {
|
for (TypeParameterDescriptor typeParameterDescriptor : classDescriptor.getTypeConstructor().getParameters()) {
|
||||||
if (i >= typeParameterList.size()) return;
|
if (i >= typeParameterList.size()) return;
|
||||||
for (KtType upperBound : typeParameterDescriptor.getUpperBounds()) {
|
for (KotlinType upperBound : typeParameterDescriptor.getUpperBounds()) {
|
||||||
EffectiveVisibility upperBoundVisibility = EffectiveVisibility.Companion.forType(upperBound);
|
EffectiveVisibility upperBoundVisibility = EffectiveVisibility.Companion.forType(upperBound);
|
||||||
if (!upperBoundVisibility.sameOrMorePermissive(classVisibility)) {
|
if (!upperBoundVisibility.sameOrMorePermissive(classVisibility)) {
|
||||||
KtTypeParameter typeParameter = typeParameterList.get(i);
|
KtTypeParameter typeParameter = typeParameterList.get(i);
|
||||||
@@ -271,7 +271,7 @@ public class DeclarationsChecker {
|
|||||||
boolean isInterface = classDescriptor.getKind() == ClassKind.INTERFACE;
|
boolean isInterface = classDescriptor.getKind() == ClassKind.INTERFACE;
|
||||||
List<KtDelegationSpecifier> delegationList = klass.getDelegationSpecifiers();
|
List<KtDelegationSpecifier> delegationList = klass.getDelegationSpecifiers();
|
||||||
int i = -1;
|
int i = -1;
|
||||||
for (KtType superType : classDescriptor.getTypeConstructor().getSupertypes()) {
|
for (KotlinType superType : classDescriptor.getTypeConstructor().getSupertypes()) {
|
||||||
i++;
|
i++;
|
||||||
if (i >= delegationList.size()) return;
|
if (i >= delegationList.size()) return;
|
||||||
ClassDescriptor superDescriptor = TypeUtils.getClassDescriptor(superType);
|
ClassDescriptor superDescriptor = TypeUtils.getClassDescriptor(superType);
|
||||||
@@ -294,10 +294,10 @@ public class DeclarationsChecker {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void removeDuplicateTypes(Set<KtType> conflictingTypes) {
|
private static void removeDuplicateTypes(Set<KotlinType> conflictingTypes) {
|
||||||
for (Iterator<KtType> iterator = conflictingTypes.iterator(); iterator.hasNext(); ) {
|
for (Iterator<KotlinType> iterator = conflictingTypes.iterator(); iterator.hasNext(); ) {
|
||||||
KtType type = iterator.next();
|
KotlinType type = iterator.next();
|
||||||
for (KtType otherType : conflictingTypes) {
|
for (KotlinType otherType : conflictingTypes) {
|
||||||
boolean subtypeOf = KotlinTypeChecker.DEFAULT.equalTypes(type, otherType);
|
boolean subtypeOf = KotlinTypeChecker.DEFAULT.equalTypes(type, otherType);
|
||||||
if (type != otherType && subtypeOf) {
|
if (type != otherType && subtypeOf) {
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
@@ -524,9 +524,9 @@ public class DeclarationsChecker {
|
|||||||
ReceiverParameterDescriptor receiverParameter = descriptor.getExtensionReceiverParameter();
|
ReceiverParameterDescriptor receiverParameter = descriptor.getExtensionReceiverParameter();
|
||||||
if (receiverParameter == null) return false;
|
if (receiverParameter == null) return false;
|
||||||
|
|
||||||
return TypeUtils.containsSpecialType(receiverParameter.getType(), new Function1<KtType, Boolean>() {
|
return TypeUtils.containsSpecialType(receiverParameter.getType(), new Function1<KotlinType, Boolean>() {
|
||||||
@Override
|
@Override
|
||||||
public Boolean invoke(KtType type) {
|
public Boolean invoke(KotlinType type) {
|
||||||
return parameter.equals(type.getConstructor().getDeclarationDescriptor());
|
return parameter.equals(type.getConstructor().getDeclarationDescriptor());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -545,7 +545,7 @@ public class DeclarationsChecker {
|
|||||||
boolean returnTypeIsNullable = true;
|
boolean returnTypeIsNullable = true;
|
||||||
boolean returnTypeIsPrimitive = true;
|
boolean returnTypeIsPrimitive = true;
|
||||||
|
|
||||||
KtType returnType = propertyDescriptor.getReturnType();
|
KotlinType returnType = propertyDescriptor.getReturnType();
|
||||||
if (returnType != null) {
|
if (returnType != null) {
|
||||||
returnTypeIsNullable = TypeUtils.isNullableType(returnType);
|
returnTypeIsNullable = TypeUtils.isNullableType(returnType);
|
||||||
returnTypeIsPrimitive = KotlinBuiltIns.isPrimitiveType(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.OperatorValidator;
|
||||||
import org.jetbrains.kotlin.resolve.validation.SymbolUsageValidator;
|
import org.jetbrains.kotlin.resolve.validation.SymbolUsageValidator;
|
||||||
import org.jetbrains.kotlin.types.DeferredType;
|
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.TypeUtils;
|
||||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
|
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
|
||||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingContext;
|
import org.jetbrains.kotlin.types.expressions.ExpressionTypingContext;
|
||||||
@@ -83,10 +83,10 @@ public class DelegatedPropertyResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public KtType getDelegatedPropertyGetMethodReturnType(
|
public KotlinType getDelegatedPropertyGetMethodReturnType(
|
||||||
@NotNull PropertyDescriptor propertyDescriptor,
|
@NotNull PropertyDescriptor propertyDescriptor,
|
||||||
@NotNull KtExpression delegateExpression,
|
@NotNull KtExpression delegateExpression,
|
||||||
@NotNull KtType delegateType,
|
@NotNull KotlinType delegateType,
|
||||||
@NotNull BindingTrace trace,
|
@NotNull BindingTrace trace,
|
||||||
@NotNull LexicalScope scope
|
@NotNull LexicalScope scope
|
||||||
) {
|
) {
|
||||||
@@ -99,13 +99,13 @@ public class DelegatedPropertyResolver {
|
|||||||
public void resolveDelegatedPropertyGetMethod(
|
public void resolveDelegatedPropertyGetMethod(
|
||||||
@NotNull PropertyDescriptor propertyDescriptor,
|
@NotNull PropertyDescriptor propertyDescriptor,
|
||||||
@NotNull KtExpression delegateExpression,
|
@NotNull KtExpression delegateExpression,
|
||||||
@NotNull KtType delegateType,
|
@NotNull KotlinType delegateType,
|
||||||
@NotNull BindingTrace trace,
|
@NotNull BindingTrace trace,
|
||||||
@NotNull LexicalScope scope
|
@NotNull LexicalScope scope
|
||||||
) {
|
) {
|
||||||
KtType returnType = getDelegatedPropertyGetMethodReturnType(
|
KotlinType returnType = getDelegatedPropertyGetMethodReturnType(
|
||||||
propertyDescriptor, delegateExpression, delegateType, trace, scope);
|
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 */
|
/* 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)) {
|
if (!(propertyType instanceof DeferredType) && returnType != null && !KotlinTypeChecker.DEFAULT.isSubtypeOf(returnType, propertyType)) {
|
||||||
@@ -119,7 +119,7 @@ public class DelegatedPropertyResolver {
|
|||||||
public void resolveDelegatedPropertySetMethod(
|
public void resolveDelegatedPropertySetMethod(
|
||||||
@NotNull PropertyDescriptor propertyDescriptor,
|
@NotNull PropertyDescriptor propertyDescriptor,
|
||||||
@NotNull KtExpression delegateExpression,
|
@NotNull KtExpression delegateExpression,
|
||||||
@NotNull KtType delegateType,
|
@NotNull KotlinType delegateType,
|
||||||
@NotNull BindingTrace trace,
|
@NotNull BindingTrace trace,
|
||||||
@NotNull LexicalScope scope
|
@NotNull LexicalScope scope
|
||||||
) {
|
) {
|
||||||
@@ -134,7 +134,7 @@ public class DelegatedPropertyResolver {
|
|||||||
public void resolveDelegatedPropertyPDMethod(
|
public void resolveDelegatedPropertyPDMethod(
|
||||||
@NotNull PropertyDescriptor propertyDescriptor,
|
@NotNull PropertyDescriptor propertyDescriptor,
|
||||||
@NotNull KtExpression delegateExpression,
|
@NotNull KtExpression delegateExpression,
|
||||||
@NotNull KtType delegateType,
|
@NotNull KotlinType delegateType,
|
||||||
@NotNull BindingTrace trace,
|
@NotNull BindingTrace trace,
|
||||||
@NotNull LexicalScope scope
|
@NotNull LexicalScope scope
|
||||||
) {
|
) {
|
||||||
@@ -172,7 +172,7 @@ public class DelegatedPropertyResolver {
|
|||||||
private void resolveDelegatedPropertyConventionMethod(
|
private void resolveDelegatedPropertyConventionMethod(
|
||||||
@NotNull PropertyDescriptor propertyDescriptor,
|
@NotNull PropertyDescriptor propertyDescriptor,
|
||||||
@NotNull KtExpression delegateExpression,
|
@NotNull KtExpression delegateExpression,
|
||||||
@NotNull KtType delegateType,
|
@NotNull KotlinType delegateType,
|
||||||
@NotNull BindingTrace trace,
|
@NotNull BindingTrace trace,
|
||||||
@NotNull LexicalScope scope,
|
@NotNull LexicalScope scope,
|
||||||
boolean isGet
|
boolean isGet
|
||||||
@@ -231,7 +231,7 @@ public class DelegatedPropertyResolver {
|
|||||||
public OverloadResolutionResults<FunctionDescriptor> getDelegatedPropertyConventionMethod(
|
public OverloadResolutionResults<FunctionDescriptor> getDelegatedPropertyConventionMethod(
|
||||||
@NotNull PropertyDescriptor propertyDescriptor,
|
@NotNull PropertyDescriptor propertyDescriptor,
|
||||||
@NotNull KtExpression delegateExpression,
|
@NotNull KtExpression delegateExpression,
|
||||||
@NotNull KtType delegateType,
|
@NotNull KotlinType delegateType,
|
||||||
@NotNull BindingTrace trace,
|
@NotNull BindingTrace trace,
|
||||||
@NotNull LexicalScope scope,
|
@NotNull LexicalScope scope,
|
||||||
boolean isGet,
|
boolean isGet,
|
||||||
@@ -240,7 +240,7 @@ public class DelegatedPropertyResolver {
|
|||||||
PropertyAccessorDescriptor accessor = isGet ? propertyDescriptor.getGetter() : propertyDescriptor.getSetter();
|
PropertyAccessorDescriptor accessor = isGet ? propertyDescriptor.getGetter() : propertyDescriptor.getSetter();
|
||||||
assert accessor != null : "Delegated property should have getter/setter " + propertyDescriptor + " " + delegateExpression.getText();
|
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;
|
? propertyDescriptor.getType() : TypeUtils.NO_EXPECTED_TYPE;
|
||||||
|
|
||||||
ExpressionTypingContext context = ExpressionTypingContext.newContext(
|
ExpressionTypingContext context = ExpressionTypingContext.newContext(
|
||||||
@@ -305,7 +305,7 @@ public class DelegatedPropertyResolver {
|
|||||||
assert calleeExpression != null : "CalleeExpression should exists for fake call of convention method";
|
assert calleeExpression != null : "CalleeExpression should exists for fake call of convention method";
|
||||||
StringBuilder builder = new StringBuilder(calleeExpression.getText());
|
StringBuilder builder = new StringBuilder(calleeExpression.getText());
|
||||||
builder.append("(");
|
builder.append("(");
|
||||||
List<KtType> argumentTypes = Lists.newArrayList();
|
List<KotlinType> argumentTypes = Lists.newArrayList();
|
||||||
for (ValueArgument argument : call.getValueArguments()) {
|
for (ValueArgument argument : call.getValueArguments()) {
|
||||||
argumentTypes.add(context.getType(argument.getArgumentExpression()));
|
argumentTypes.add(context.getType(argument.getArgumentExpression()));
|
||||||
|
|
||||||
@@ -316,7 +316,7 @@ public class DelegatedPropertyResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public KtType resolveDelegateExpression(
|
public KotlinType resolveDelegateExpression(
|
||||||
@NotNull KtExpression delegateExpression,
|
@NotNull KtExpression delegateExpression,
|
||||||
@NotNull KtProperty jetProperty,
|
@NotNull KtProperty jetProperty,
|
||||||
@NotNull PropertyDescriptor propertyDescriptor,
|
@NotNull PropertyDescriptor propertyDescriptor,
|
||||||
@@ -332,8 +332,8 @@ public class DelegatedPropertyResolver {
|
|||||||
if (calleeExpression != null) {
|
if (calleeExpression != null) {
|
||||||
traceToResolveDelegatedProperty.record(CONSTRAINT_SYSTEM_COMPLETER, calleeExpression, completer);
|
traceToResolveDelegatedProperty.record(CONSTRAINT_SYSTEM_COMPLETER, calleeExpression, completer);
|
||||||
}
|
}
|
||||||
KtType delegateType = expressionTypingServices.safeGetType(propertyDeclarationInnerScope, delegateExpression, NO_EXPECTED_TYPE,
|
KotlinType delegateType = expressionTypingServices.safeGetType(propertyDeclarationInnerScope, delegateExpression, NO_EXPECTED_TYPE,
|
||||||
dataFlowInfo, traceToResolveDelegatedProperty);
|
dataFlowInfo, traceToResolveDelegatedProperty);
|
||||||
traceToResolveDelegatedProperty.commit(new TraceEntryFilter() {
|
traceToResolveDelegatedProperty.commit(new TraceEntryFilter() {
|
||||||
@Override
|
@Override
|
||||||
public boolean accept(@Nullable WritableSlice<?, ?> slice, Object key) {
|
public boolean accept(@Nullable WritableSlice<?, ?> slice, Object key) {
|
||||||
@@ -351,13 +351,13 @@ public class DelegatedPropertyResolver {
|
|||||||
@NotNull final LexicalScope accessorScope,
|
@NotNull final LexicalScope accessorScope,
|
||||||
@NotNull final BindingTrace trace
|
@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() {
|
return new ConstraintSystemCompleter() {
|
||||||
@Override
|
@Override
|
||||||
public void completeConstraintSystem(
|
public void completeConstraintSystem(
|
||||||
@NotNull ConstraintSystem constraintSystem, @NotNull ResolvedCall<?> resolvedCall
|
@NotNull ConstraintSystem constraintSystem, @NotNull ResolvedCall<?> resolvedCall
|
||||||
) {
|
) {
|
||||||
KtType returnType = resolvedCall.getCandidateDescriptor().getReturnType();
|
KotlinType returnType = resolvedCall.getCandidateDescriptor().getReturnType();
|
||||||
if (returnType == null) return;
|
if (returnType == null) return;
|
||||||
|
|
||||||
TemporaryBindingTrace traceToResolveConventionMethods =
|
TemporaryBindingTrace traceToResolveConventionMethods =
|
||||||
@@ -370,7 +370,7 @@ public class DelegatedPropertyResolver {
|
|||||||
|
|
||||||
if (conventionMethodFound(getMethodResults)) {
|
if (conventionMethodFound(getMethodResults)) {
|
||||||
FunctionDescriptor descriptor = getMethodResults.getResultingDescriptor();
|
FunctionDescriptor descriptor = getMethodResults.getResultingDescriptor();
|
||||||
KtType returnTypeOfGetMethod = descriptor.getReturnType();
|
KotlinType returnTypeOfGetMethod = descriptor.getReturnType();
|
||||||
if (returnTypeOfGetMethod != null) {
|
if (returnTypeOfGetMethod != null) {
|
||||||
constraintSystem.addSupertypeConstraint(expectedType, returnTypeOfGetMethod, FROM_COMPLETER.position());
|
constraintSystem.addSupertypeConstraint(expectedType, returnTypeOfGetMethod, FROM_COMPLETER.position());
|
||||||
}
|
}
|
||||||
@@ -413,7 +413,7 @@ public class DelegatedPropertyResolver {
|
|||||||
private void addConstraintForThisValue(ConstraintSystem constraintSystem, FunctionDescriptor resultingDescriptor) {
|
private void addConstraintForThisValue(ConstraintSystem constraintSystem, FunctionDescriptor resultingDescriptor) {
|
||||||
ReceiverParameterDescriptor extensionReceiver = propertyDescriptor.getExtensionReceiverParameter();
|
ReceiverParameterDescriptor extensionReceiver = propertyDescriptor.getExtensionReceiverParameter();
|
||||||
ReceiverParameterDescriptor dispatchReceiver = propertyDescriptor.getDispatchReceiverParameter();
|
ReceiverParameterDescriptor dispatchReceiver = propertyDescriptor.getDispatchReceiverParameter();
|
||||||
KtType typeOfThis =
|
KotlinType typeOfThis =
|
||||||
extensionReceiver != null ? extensionReceiver.getType() :
|
extensionReceiver != null ? extensionReceiver.getType() :
|
||||||
dispatchReceiver != null ? dispatchReceiver.getType() :
|
dispatchReceiver != null ? dispatchReceiver.getType() :
|
||||||
builtIns.getNullableNothingType();
|
builtIns.getNullableNothingType();
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import org.jetbrains.kotlin.diagnostics.Diagnostic;
|
|||||||
import org.jetbrains.kotlin.psi.KtExpression;
|
import org.jetbrains.kotlin.psi.KtExpression;
|
||||||
import org.jetbrains.kotlin.resolve.diagnostics.Diagnostics;
|
import org.jetbrains.kotlin.resolve.diagnostics.Diagnostics;
|
||||||
import org.jetbrains.kotlin.resolve.diagnostics.MutableDiagnosticsWithSuppression;
|
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.JetTypeInfo;
|
||||||
import org.jetbrains.kotlin.types.expressions.typeInfoFactory.TypeInfoFactoryKt;
|
import org.jetbrains.kotlin.types.expressions.typeInfoFactory.TypeInfoFactoryKt;
|
||||||
import org.jetbrains.kotlin.util.slicedMap.*;
|
import org.jetbrains.kotlin.util.slicedMap.*;
|
||||||
@@ -58,7 +58,7 @@ public class DelegatingBindingTrace implements BindingTrace {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public KtType getType(@NotNull KtExpression expression) {
|
public KotlinType getType(@NotNull KtExpression expression) {
|
||||||
return DelegatingBindingTrace.this.getType(expression);
|
return DelegatingBindingTrace.this.getType(expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -139,13 +139,13 @@ public class DelegatingBindingTrace implements BindingTrace {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public KtType getType(@NotNull KtExpression expression) {
|
public KotlinType getType(@NotNull KtExpression expression) {
|
||||||
JetTypeInfo typeInfo = get(BindingContext.EXPRESSION_TYPE_INFO, expression);
|
JetTypeInfo typeInfo = get(BindingContext.EXPRESSION_TYPE_INFO, expression);
|
||||||
return typeInfo != null ? typeInfo.getType() : null;
|
return typeInfo != null ? typeInfo.getType() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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);
|
JetTypeInfo typeInfo = get(BindingContext.EXPRESSION_TYPE_INFO, expression);
|
||||||
if (typeInfo == null) {
|
if (typeInfo == null) {
|
||||||
typeInfo = TypeInfoFactoryKt.createTypeInfo(type);
|
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.KtDelegationSpecifier;
|
||||||
import org.jetbrains.kotlin.psi.KtDelegatorByExpressionSpecifier;
|
import org.jetbrains.kotlin.psi.KtDelegatorByExpressionSpecifier;
|
||||||
import org.jetbrains.kotlin.psi.KtTypeReference;
|
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 org.jetbrains.kotlin.types.TypeUtils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -88,7 +88,7 @@ public final class DelegationResolver<T extends CallableMemberDescriptor> {
|
|||||||
if (typeReference == null) {
|
if (typeReference == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
KtType delegatedTraitType = typeResolver.resolve(typeReference);
|
KotlinType delegatedTraitType = typeResolver.resolve(typeReference);
|
||||||
if (delegatedTraitType == null || delegatedTraitType.isError()) {
|
if (delegatedTraitType == null || delegatedTraitType.isError()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -101,7 +101,7 @@ public final class DelegationResolver<T extends CallableMemberDescriptor> {
|
|||||||
@NotNull
|
@NotNull
|
||||||
private Collection<T> generateDelegatesForTrait(
|
private Collection<T> generateDelegatesForTrait(
|
||||||
@NotNull Collection<T> existingDelegates,
|
@NotNull Collection<T> existingDelegates,
|
||||||
@NotNull KtType delegatedTraitType
|
@NotNull KotlinType delegatedTraitType
|
||||||
) {
|
) {
|
||||||
Collection<T> result = new HashSet<T>();
|
Collection<T> result = new HashSet<T>();
|
||||||
Collection<T> candidates = generateDelegationCandidates(delegatedTraitType);
|
Collection<T> candidates = generateDelegationCandidates(delegatedTraitType);
|
||||||
@@ -120,7 +120,7 @@ public final class DelegationResolver<T extends CallableMemberDescriptor> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private Collection<T> generateDelegationCandidates(@NotNull KtType delegatedTraitType) {
|
private Collection<T> generateDelegationCandidates(@NotNull KotlinType delegatedTraitType) {
|
||||||
Collection<T> descriptorsToDelegate = overridableMembersNotFromSuperClassOfTrait(delegatedTraitType);
|
Collection<T> descriptorsToDelegate = overridableMembersNotFromSuperClassOfTrait(delegatedTraitType);
|
||||||
Collection<T> result = new ArrayList<T>(descriptorsToDelegate.size());
|
Collection<T> result = new ArrayList<T>(descriptorsToDelegate.size());
|
||||||
for (T memberDescriptor : descriptorsToDelegate) {
|
for (T memberDescriptor : descriptorsToDelegate) {
|
||||||
@@ -156,7 +156,7 @@ public final class DelegationResolver<T extends CallableMemberDescriptor> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private Collection<T> overridableMembersNotFromSuperClassOfTrait(@NotNull KtType trait) {
|
private Collection<T> overridableMembersNotFromSuperClassOfTrait(@NotNull KotlinType trait) {
|
||||||
final Collection<T> membersToSkip = getMembersFromClassSupertypeOfTrait(trait);
|
final Collection<T> membersToSkip = getMembersFromClassSupertypeOfTrait(trait);
|
||||||
return Collections2.filter(
|
return Collections2.filter(
|
||||||
memberExtractor.getMembersByType(trait),
|
memberExtractor.getMembersByType(trait),
|
||||||
@@ -182,9 +182,9 @@ public final class DelegationResolver<T extends CallableMemberDescriptor> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private Collection<T> getMembersFromClassSupertypeOfTrait(@NotNull KtType traitType) {
|
private Collection<T> getMembersFromClassSupertypeOfTrait(@NotNull KotlinType traitType) {
|
||||||
KtType classSupertype = null;
|
KotlinType classSupertype = null;
|
||||||
for (KtType supertype : TypeUtils.getAllSupertypes(traitType)) {
|
for (KotlinType supertype : TypeUtils.getAllSupertypes(traitType)) {
|
||||||
if (isNotTrait(supertype.getConstructor().getDeclarationDescriptor())) {
|
if (isNotTrait(supertype.getConstructor().getDeclarationDescriptor())) {
|
||||||
classSupertype = supertype;
|
classSupertype = supertype;
|
||||||
break;
|
break;
|
||||||
@@ -203,11 +203,11 @@ public final class DelegationResolver<T extends CallableMemberDescriptor> {
|
|||||||
|
|
||||||
public interface MemberExtractor<T extends CallableMemberDescriptor> {
|
public interface MemberExtractor<T extends CallableMemberDescriptor> {
|
||||||
@NotNull
|
@NotNull
|
||||||
Collection<T> getMembersByType(@NotNull KtType type);
|
Collection<T> getMembersByType(@NotNull KotlinType type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface TypeResolver {
|
public interface TypeResolver {
|
||||||
@Nullable
|
@Nullable
|
||||||
KtType resolve(@NotNull KtTypeReference reference);
|
KotlinType resolve(@NotNull KtTypeReference reference);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,20 +96,20 @@ public class DescriptorResolver {
|
|||||||
this.constantExpressionEvaluator = constantExpressionEvaluator;
|
this.constantExpressionEvaluator = constantExpressionEvaluator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<KtType> resolveSupertypes(
|
public List<KotlinType> resolveSupertypes(
|
||||||
@NotNull LexicalScope scope,
|
@NotNull LexicalScope scope,
|
||||||
@NotNull ClassDescriptor classDescriptor,
|
@NotNull ClassDescriptor classDescriptor,
|
||||||
@NotNull KtClassOrObject jetClass,
|
@NotNull KtClassOrObject jetClass,
|
||||||
BindingTrace trace
|
BindingTrace trace
|
||||||
) {
|
) {
|
||||||
List<KtType> supertypes = Lists.newArrayList();
|
List<KotlinType> supertypes = Lists.newArrayList();
|
||||||
List<KtDelegationSpecifier> delegationSpecifiers = jetClass.getDelegationSpecifiers();
|
List<KtDelegationSpecifier> delegationSpecifiers = jetClass.getDelegationSpecifiers();
|
||||||
Collection<KtType> declaredSupertypes = resolveDelegationSpecifiers(
|
Collection<KotlinType> declaredSupertypes = resolveDelegationSpecifiers(
|
||||||
scope,
|
scope,
|
||||||
delegationSpecifiers,
|
delegationSpecifiers,
|
||||||
typeResolver, trace, false);
|
typeResolver, trace, false);
|
||||||
|
|
||||||
for (KtType declaredSupertype : declaredSupertypes) {
|
for (KotlinType declaredSupertype : declaredSupertypes) {
|
||||||
addValidSupertype(supertypes, declaredSupertype);
|
addValidSupertype(supertypes, declaredSupertype);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,21 +118,21 @@ public class DescriptorResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (supertypes.isEmpty()) {
|
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);
|
addValidSupertype(supertypes, defaultSupertype);
|
||||||
}
|
}
|
||||||
|
|
||||||
return supertypes;
|
return supertypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void addValidSupertype(List<KtType> supertypes, KtType declaredSupertype) {
|
private static void addValidSupertype(List<KotlinType> supertypes, KotlinType declaredSupertype) {
|
||||||
if (!declaredSupertype.isError()) {
|
if (!declaredSupertype.isError()) {
|
||||||
supertypes.add(declaredSupertype);
|
supertypes.add(declaredSupertype);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean containsClass(Collection<KtType> result) {
|
private boolean containsClass(Collection<KotlinType> result) {
|
||||||
for (KtType type : result) {
|
for (KotlinType type : result) {
|
||||||
ClassifierDescriptor descriptor = type.getConstructor().getDeclarationDescriptor();
|
ClassifierDescriptor descriptor = type.getConstructor().getDeclarationDescriptor();
|
||||||
if (descriptor instanceof ClassDescriptor && ((ClassDescriptor) descriptor).getKind() != ClassKind.INTERFACE) {
|
if (descriptor instanceof ClassDescriptor && ((ClassDescriptor) descriptor).getKind() != ClassKind.INTERFACE) {
|
||||||
return true;
|
return true;
|
||||||
@@ -141,7 +141,7 @@ public class DescriptorResolver {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private KtType getDefaultSupertype(KtClassOrObject jetClass, BindingTrace trace, boolean isAnnotation) {
|
private KotlinType getDefaultSupertype(KtClassOrObject jetClass, BindingTrace trace, boolean isAnnotation) {
|
||||||
// TODO : beautify
|
// TODO : beautify
|
||||||
if (jetClass instanceof KtEnumEntry) {
|
if (jetClass instanceof KtEnumEntry) {
|
||||||
KtClassOrObject parent = KtStubbedPsiUtil.getContainingDeclaration(jetClass, KtClassOrObject.class);
|
KtClassOrObject parent = KtStubbedPsiUtil.getContainingDeclaration(jetClass, KtClassOrObject.class);
|
||||||
@@ -160,7 +160,7 @@ public class DescriptorResolver {
|
|||||||
return builtIns.getAnyType();
|
return builtIns.getAnyType();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<KtType> resolveDelegationSpecifiers(
|
public Collection<KotlinType> resolveDelegationSpecifiers(
|
||||||
LexicalScope extensibleScope,
|
LexicalScope extensibleScope,
|
||||||
List<KtDelegationSpecifier> delegationSpecifiers,
|
List<KtDelegationSpecifier> delegationSpecifiers,
|
||||||
@NotNull TypeResolver resolver,
|
@NotNull TypeResolver resolver,
|
||||||
@@ -170,11 +170,11 @@ public class DescriptorResolver {
|
|||||||
if (delegationSpecifiers.isEmpty()) {
|
if (delegationSpecifiers.isEmpty()) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
Collection<KtType> result = Lists.newArrayList();
|
Collection<KotlinType> result = Lists.newArrayList();
|
||||||
for (KtDelegationSpecifier delegationSpecifier : delegationSpecifiers) {
|
for (KtDelegationSpecifier delegationSpecifier : delegationSpecifiers) {
|
||||||
KtTypeReference typeReference = delegationSpecifier.getTypeReference();
|
KtTypeReference typeReference = delegationSpecifier.getTypeReference();
|
||||||
if (typeReference != null) {
|
if (typeReference != null) {
|
||||||
KtType supertype = resolver.resolveType(extensibleScope, typeReference, trace, checkBounds);
|
KotlinType supertype = resolver.resolveType(extensibleScope, typeReference, trace, checkBounds);
|
||||||
if (DynamicTypesKt.isDynamic(supertype)) {
|
if (DynamicTypesKt.isDynamic(supertype)) {
|
||||||
trace.report(DYNAMIC_SUPERTYPE.on(typeReference));
|
trace.report(DYNAMIC_SUPERTYPE.on(typeReference));
|
||||||
}
|
}
|
||||||
@@ -225,7 +225,7 @@ public class DescriptorResolver {
|
|||||||
@NotNull BindingTrace trace
|
@NotNull BindingTrace trace
|
||||||
) {
|
) {
|
||||||
Name functionName = DataClassUtilsKt.createComponentName(parameterIndex);
|
Name functionName = DataClassUtilsKt.createComponentName(parameterIndex);
|
||||||
KtType returnType = property.getType();
|
KotlinType returnType = property.getType();
|
||||||
|
|
||||||
SimpleFunctionDescriptorImpl functionDescriptor = SimpleFunctionDescriptorImpl.create(
|
SimpleFunctionDescriptorImpl functionDescriptor = SimpleFunctionDescriptorImpl.create(
|
||||||
classDescriptor,
|
classDescriptor,
|
||||||
@@ -257,7 +257,7 @@ public class DescriptorResolver {
|
|||||||
@NotNull ClassDescriptor classDescriptor,
|
@NotNull ClassDescriptor classDescriptor,
|
||||||
@NotNull BindingTrace trace
|
@NotNull BindingTrace trace
|
||||||
) {
|
) {
|
||||||
KtType returnType = classDescriptor.getDefaultType();
|
KotlinType returnType = classDescriptor.getDefaultType();
|
||||||
|
|
||||||
SimpleFunctionDescriptorImpl functionDescriptor = SimpleFunctionDescriptorImpl.create(
|
SimpleFunctionDescriptorImpl functionDescriptor = SimpleFunctionDescriptorImpl.create(
|
||||||
classDescriptor,
|
classDescriptor,
|
||||||
@@ -333,10 +333,10 @@ public class DescriptorResolver {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public ValueParameterDescriptorImpl resolveValueParameterDescriptor(
|
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;
|
KotlinType varargElementType = null;
|
||||||
KtType variableType = type;
|
KotlinType variableType = type;
|
||||||
if (valueParameter.hasModifier(VARARG_KEYWORD)) {
|
if (valueParameter.hasModifier(VARARG_KEYWORD)) {
|
||||||
varargElementType = type;
|
varargElementType = type;
|
||||||
variableType = getVarargParameterType(type);
|
variableType = getVarargParameterType(type);
|
||||||
@@ -378,8 +378,8 @@ public class DescriptorResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private KtType getVarargParameterType(@NotNull KtType elementType) {
|
private KotlinType getVarargParameterType(@NotNull KotlinType elementType) {
|
||||||
KtType primitiveArrayType = builtIns.getPrimitiveArrayJetTypeByPrimitiveJetType(elementType);
|
KotlinType primitiveArrayType = builtIns.getPrimitiveArrayJetTypeByPrimitiveJetType(elementType);
|
||||||
if (primitiveArrayType != null) {
|
if (primitiveArrayType != null) {
|
||||||
return primitiveArrayType;
|
return primitiveArrayType;
|
||||||
}
|
}
|
||||||
@@ -449,21 +449,21 @@ public class DescriptorResolver {
|
|||||||
|
|
||||||
static final class UpperBoundCheckerTask {
|
static final class UpperBoundCheckerTask {
|
||||||
KtTypeReference upperBound;
|
KtTypeReference upperBound;
|
||||||
KtType upperBoundType;
|
KotlinType upperBoundType;
|
||||||
|
|
||||||
private UpperBoundCheckerTask(KtTypeReference upperBound, KtType upperBoundType) {
|
private UpperBoundCheckerTask(KtTypeReference upperBound, KotlinType upperBoundType) {
|
||||||
this.upperBound = upperBound;
|
this.upperBound = upperBound;
|
||||||
this.upperBoundType = upperBoundType;
|
this.upperBoundType = upperBoundType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public KtType resolveTypeParameterExtendsBound(
|
public KotlinType resolveTypeParameterExtendsBound(
|
||||||
@NotNull TypeParameterDescriptor typeParameterDescriptor,
|
@NotNull TypeParameterDescriptor typeParameterDescriptor,
|
||||||
@NotNull KtTypeReference extendsBound,
|
@NotNull KtTypeReference extendsBound,
|
||||||
LexicalScope scope,
|
LexicalScope scope,
|
||||||
BindingTrace trace
|
BindingTrace trace
|
||||||
) {
|
) {
|
||||||
KtType type = typeResolver.resolveType(scope, extendsBound, trace, false);
|
KotlinType type = typeResolver.resolveType(scope, extendsBound, trace, false);
|
||||||
if (type.getConstructor().equals(typeParameterDescriptor.getTypeConstructor())) {
|
if (type.getConstructor().equals(typeParameterDescriptor.getTypeConstructor())) {
|
||||||
trace.report(Errors.CYCLIC_GENERIC_UPPER_BOUND.on(extendsBound));
|
trace.report(Errors.CYCLIC_GENERIC_UPPER_BOUND.on(extendsBound));
|
||||||
type = ErrorUtils.createErrorType("Cyclic upper bound: " + type);
|
type = ErrorUtils.createErrorType("Cyclic upper bound: " + type);
|
||||||
@@ -490,7 +490,7 @@ public class DescriptorResolver {
|
|||||||
|
|
||||||
KtTypeReference extendsBound = jetTypeParameter.getExtendsBound();
|
KtTypeReference extendsBound = jetTypeParameter.getExtendsBound();
|
||||||
if (extendsBound != null) {
|
if (extendsBound != null) {
|
||||||
KtType type = resolveTypeParameterExtendsBound(typeParameterDescriptor, extendsBound, scope, trace);
|
KotlinType type = resolveTypeParameterExtendsBound(typeParameterDescriptor, extendsBound, scope, trace);
|
||||||
typeParameterDescriptor.addUpperBound(type);
|
typeParameterDescriptor.addUpperBound(type);
|
||||||
deferredUpperBoundCheckerTasks.add(new UpperBoundCheckerTask(extendsBound, type));
|
deferredUpperBoundCheckerTasks.add(new UpperBoundCheckerTask(extendsBound, type));
|
||||||
}
|
}
|
||||||
@@ -503,7 +503,7 @@ public class DescriptorResolver {
|
|||||||
Name referencedName = subjectTypeParameterName.getReferencedNameAsName();
|
Name referencedName = subjectTypeParameterName.getReferencedNameAsName();
|
||||||
TypeParameterDescriptorImpl typeParameterDescriptor = parameterByName.get(referencedName);
|
TypeParameterDescriptorImpl typeParameterDescriptor = parameterByName.get(referencedName);
|
||||||
KtTypeReference boundTypeReference = constraint.getBoundTypeReference();
|
KtTypeReference boundTypeReference = constraint.getBoundTypeReference();
|
||||||
KtType bound = null;
|
KotlinType bound = null;
|
||||||
if (boundTypeReference != null) {
|
if (boundTypeReference != null) {
|
||||||
bound = typeResolver.resolveType(scope, boundTypeReference, trace, false);
|
bound = typeResolver.resolveType(scope, boundTypeReference, trace, false);
|
||||||
deferredUpperBoundCheckerTasks.add(new UpperBoundCheckerTask(boundTypeReference, bound));
|
deferredUpperBoundCheckerTasks.add(new UpperBoundCheckerTask(boundTypeReference, bound));
|
||||||
@@ -577,7 +577,7 @@ public class DescriptorResolver {
|
|||||||
|
|
||||||
public static void checkUpperBoundType(
|
public static void checkUpperBoundType(
|
||||||
KtTypeReference upperBound,
|
KtTypeReference upperBound,
|
||||||
@NotNull KtType upperBoundType,
|
@NotNull KotlinType upperBoundType,
|
||||||
BindingTrace trace
|
BindingTrace trace
|
||||||
) {
|
) {
|
||||||
if (!TypeUtils.canHaveSubtypes(KotlinTypeChecker.DEFAULT, upperBoundType)) {
|
if (!TypeUtils.canHaveSubtypes(KotlinTypeChecker.DEFAULT, upperBoundType)) {
|
||||||
@@ -598,13 +598,13 @@ public class DescriptorResolver {
|
|||||||
@NotNull KtParameter parameter,
|
@NotNull KtParameter parameter,
|
||||||
BindingTrace trace
|
BindingTrace trace
|
||||||
) {
|
) {
|
||||||
KtType type = resolveParameterType(scope, parameter, trace);
|
KotlinType type = resolveParameterType(scope, parameter, trace);
|
||||||
return resolveLocalVariableDescriptor(parameter, type, trace, scope);
|
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();
|
KtTypeReference typeReference = parameter.getTypeReference();
|
||||||
KtType type;
|
KotlinType type;
|
||||||
if (typeReference != null) {
|
if (typeReference != null) {
|
||||||
type = typeResolver.resolveType(scope, typeReference, trace, true);
|
type = typeResolver.resolveType(scope, typeReference, trace, true);
|
||||||
}
|
}
|
||||||
@@ -620,7 +620,7 @@ public class DescriptorResolver {
|
|||||||
|
|
||||||
public VariableDescriptor resolveLocalVariableDescriptor(
|
public VariableDescriptor resolveLocalVariableDescriptor(
|
||||||
@NotNull KtParameter parameter,
|
@NotNull KtParameter parameter,
|
||||||
@NotNull KtType type,
|
@NotNull KotlinType type,
|
||||||
BindingTrace trace,
|
BindingTrace trace,
|
||||||
@NotNull LexicalScope scope
|
@NotNull LexicalScope scope
|
||||||
) {
|
) {
|
||||||
@@ -647,7 +647,7 @@ public class DescriptorResolver {
|
|||||||
) {
|
) {
|
||||||
DeclarationDescriptor containingDeclaration = scope.getOwnerDescriptor();
|
DeclarationDescriptor containingDeclaration = scope.getOwnerDescriptor();
|
||||||
VariableDescriptor result;
|
VariableDescriptor result;
|
||||||
KtType type;
|
KotlinType type;
|
||||||
// SCRIPT: Create property descriptors
|
// SCRIPT: Create property descriptors
|
||||||
if (KtPsiUtil.isScriptDeclaration(variable)) {
|
if (KtPsiUtil.isScriptDeclaration(variable)) {
|
||||||
PropertyDescriptorImpl propertyDescriptor = PropertyDescriptorImpl.create(
|
PropertyDescriptorImpl propertyDescriptor = PropertyDescriptorImpl.create(
|
||||||
@@ -666,7 +666,7 @@ public class DescriptorResolver {
|
|||||||
type = getVariableType(propertyDescriptor, scope, variable, dataFlowInfo, false, trace);
|
type = getVariableType(propertyDescriptor, scope, variable, dataFlowInfo, false, trace);
|
||||||
|
|
||||||
ReceiverParameterDescriptor receiverParameter = ((ScriptDescriptor) containingDeclaration).getThisAsReceiverParameter();
|
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);
|
initializeWithDefaultGetterSetter(propertyDescriptor);
|
||||||
trace.record(BindingContext.VARIABLE, variable, propertyDescriptor);
|
trace.record(BindingContext.VARIABLE, variable, propertyDescriptor);
|
||||||
result = propertyDescriptor;
|
result = propertyDescriptor;
|
||||||
@@ -702,7 +702,7 @@ public class DescriptorResolver {
|
|||||||
public LocalVariableDescriptor resolveLocalVariableDescriptorWithType(
|
public LocalVariableDescriptor resolveLocalVariableDescriptorWithType(
|
||||||
@NotNull LexicalScope scope,
|
@NotNull LexicalScope scope,
|
||||||
@NotNull KtVariableDeclaration variable,
|
@NotNull KtVariableDeclaration variable,
|
||||||
@Nullable KtType type,
|
@Nullable KotlinType type,
|
||||||
@NotNull BindingTrace trace
|
@NotNull BindingTrace trace
|
||||||
) {
|
) {
|
||||||
LocalVariableDescriptor variableDescriptor = new LocalVariableDescriptor(
|
LocalVariableDescriptor variableDescriptor = new LocalVariableDescriptor(
|
||||||
@@ -765,7 +765,7 @@ public class DescriptorResolver {
|
|||||||
|
|
||||||
List<TypeParameterDescriptorImpl> typeParameterDescriptors;
|
List<TypeParameterDescriptorImpl> typeParameterDescriptors;
|
||||||
LexicalScope scopeWithTypeParameters;
|
LexicalScope scopeWithTypeParameters;
|
||||||
KtType receiverType = null;
|
KotlinType receiverType = null;
|
||||||
|
|
||||||
{
|
{
|
||||||
List<KtTypeParameter> typeParameters = property.getTypeParameters();
|
List<KtTypeParameter> typeParameters = property.getTypeParameters();
|
||||||
@@ -798,7 +798,7 @@ public class DescriptorResolver {
|
|||||||
LexicalScope propertyScope = JetScopeUtils.getPropertyDeclarationInnerScope(propertyDescriptor, scope, typeParameterDescriptors,
|
LexicalScope propertyScope = JetScopeUtils.getPropertyDeclarationInnerScope(propertyDescriptor, scope, typeParameterDescriptors,
|
||||||
implicitInitializerReceiver, trace);
|
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),
|
propertyDescriptor.setType(type, typeParameterDescriptors, getDispatchReceiverParameterIfNeeded(containingDeclaration),
|
||||||
receiverDescriptor);
|
receiverDescriptor);
|
||||||
@@ -831,7 +831,7 @@ public class DescriptorResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private KtType getVariableType(
|
private KotlinType getVariableType(
|
||||||
@NotNull final VariableDescriptorWithInitializerImpl variableDescriptor,
|
@NotNull final VariableDescriptorWithInitializerImpl variableDescriptor,
|
||||||
@NotNull final LexicalScope scope,
|
@NotNull final LexicalScope scope,
|
||||||
@NotNull final KtVariableDeclaration variable,
|
@NotNull final KtVariableDeclaration variable,
|
||||||
@@ -850,9 +850,9 @@ public class DescriptorResolver {
|
|||||||
return DeferredType.createRecursionIntolerant(
|
return DeferredType.createRecursionIntolerant(
|
||||||
storageManager,
|
storageManager,
|
||||||
trace,
|
trace,
|
||||||
new Function0<KtType>() {
|
new Function0<KotlinType>() {
|
||||||
@Override
|
@Override
|
||||||
public KtType invoke() {
|
public KotlinType invoke() {
|
||||||
return resolveDelegatedPropertyType(property, (PropertyDescriptor) variableDescriptor, scope,
|
return resolveDelegatedPropertyType(property, (PropertyDescriptor) variableDescriptor, scope,
|
||||||
property.getDelegateExpression(), dataFlowInfo, trace);
|
property.getDelegateExpression(), dataFlowInfo, trace);
|
||||||
}
|
}
|
||||||
@@ -869,11 +869,12 @@ public class DescriptorResolver {
|
|||||||
return DeferredType.createRecursionIntolerant(
|
return DeferredType.createRecursionIntolerant(
|
||||||
storageManager,
|
storageManager,
|
||||||
trace,
|
trace,
|
||||||
new Function0<KtType>() {
|
new Function0<KotlinType>() {
|
||||||
@Override
|
@Override
|
||||||
public KtType invoke() {
|
public KotlinType invoke() {
|
||||||
PreliminaryDeclarationVisitor.Companion.createForDeclaration(variable, trace);
|
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);
|
setConstantForVariableIfNeeded(variableDescriptor, scope, variable, dataFlowInfo, initializerType, trace);
|
||||||
return transformAnonymousTypeIfNeeded(variableDescriptor, variable, initializerType, trace);
|
return transformAnonymousTypeIfNeeded(variableDescriptor, variable, initializerType, trace);
|
||||||
}
|
}
|
||||||
@@ -881,14 +882,14 @@ public class DescriptorResolver {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
KtType initializerType = resolveInitializerType(scope, variable.getInitializer(), dataFlowInfo, trace);
|
KotlinType initializerType = resolveInitializerType(scope, variable.getInitializer(), dataFlowInfo, trace);
|
||||||
setConstantForVariableIfNeeded(variableDescriptor, scope, variable, dataFlowInfo, initializerType, trace);
|
setConstantForVariableIfNeeded(variableDescriptor, scope, variable, dataFlowInfo, initializerType, trace);
|
||||||
return initializerType;
|
return initializerType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
KtType type = typeResolver.resolveType(scope, propertyTypeRef, trace, true);
|
KotlinType type = typeResolver.resolveType(scope, propertyTypeRef, trace, true);
|
||||||
setConstantForVariableIfNeeded(variableDescriptor, scope, variable, dataFlowInfo, type, trace);
|
setConstantForVariableIfNeeded(variableDescriptor, scope, variable, dataFlowInfo, type, trace);
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
@@ -899,7 +900,7 @@ public class DescriptorResolver {
|
|||||||
@NotNull final LexicalScope scope,
|
@NotNull final LexicalScope scope,
|
||||||
@NotNull final KtVariableDeclaration variable,
|
@NotNull final KtVariableDeclaration variable,
|
||||||
@NotNull final DataFlowInfo dataFlowInfo,
|
@NotNull final DataFlowInfo dataFlowInfo,
|
||||||
@NotNull final KtType variableType,
|
@NotNull final KotlinType variableType,
|
||||||
@NotNull final BindingTrace trace
|
@NotNull final BindingTrace trace
|
||||||
) {
|
) {
|
||||||
if (!shouldRecordInitializerForProperty(variableDescriptor, variableType)) return;
|
if (!shouldRecordInitializerForProperty(variableDescriptor, variableType)) return;
|
||||||
@@ -912,7 +913,7 @@ public class DescriptorResolver {
|
|||||||
@Override
|
@Override
|
||||||
public ConstantValue<?> invoke() {
|
public ConstantValue<?> invoke() {
|
||||||
KtExpression initializer = variable.getInitializer();
|
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);
|
CompileTimeConstant<?> constant = constantExpressionEvaluator.evaluateExpression(initializer, trace, initializerType);
|
||||||
|
|
||||||
if (constant == null) return null;
|
if (constant == null) return null;
|
||||||
@@ -928,7 +929,7 @@ public class DescriptorResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private KtType resolveDelegatedPropertyType(
|
private KotlinType resolveDelegatedPropertyType(
|
||||||
@NotNull KtProperty property,
|
@NotNull KtProperty property,
|
||||||
@NotNull PropertyDescriptor propertyDescriptor,
|
@NotNull PropertyDescriptor propertyDescriptor,
|
||||||
@NotNull LexicalScope scope,
|
@NotNull LexicalScope scope,
|
||||||
@@ -938,11 +939,11 @@ public class DescriptorResolver {
|
|||||||
) {
|
) {
|
||||||
LexicalScope accessorScope = JetScopeUtils.makeScopeForPropertyAccessor(propertyDescriptor, scope, trace);
|
LexicalScope accessorScope = JetScopeUtils.makeScopeForPropertyAccessor(propertyDescriptor, scope, trace);
|
||||||
|
|
||||||
KtType type = delegatedPropertyResolver.resolveDelegateExpression(
|
KotlinType type = delegatedPropertyResolver.resolveDelegateExpression(
|
||||||
delegateExpression, property, propertyDescriptor, scope, accessorScope, trace, dataFlowInfo);
|
delegateExpression, property, propertyDescriptor, scope, accessorScope, trace, dataFlowInfo);
|
||||||
|
|
||||||
if (type != null) {
|
if (type != null) {
|
||||||
KtType getterReturnType = delegatedPropertyResolver
|
KotlinType getterReturnType = delegatedPropertyResolver
|
||||||
.getDelegatedPropertyGetMethodReturnType(propertyDescriptor, delegateExpression, type, trace, accessorScope);
|
.getDelegatedPropertyGetMethodReturnType(propertyDescriptor, delegateExpression, type, trace, accessorScope);
|
||||||
if (getterReturnType != null) {
|
if (getterReturnType != null) {
|
||||||
return getterReturnType;
|
return getterReturnType;
|
||||||
@@ -952,10 +953,10 @@ public class DescriptorResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
/*package*/ static KtType transformAnonymousTypeIfNeeded(
|
/*package*/ static KotlinType transformAnonymousTypeIfNeeded(
|
||||||
@NotNull DeclarationDescriptorWithVisibility descriptor,
|
@NotNull DeclarationDescriptorWithVisibility descriptor,
|
||||||
@NotNull KtNamedDeclaration declaration,
|
@NotNull KtNamedDeclaration declaration,
|
||||||
@NotNull KtType type,
|
@NotNull KotlinType type,
|
||||||
@NotNull BindingTrace trace
|
@NotNull BindingTrace trace
|
||||||
) {
|
) {
|
||||||
ClassifierDescriptor classifier = type.getConstructor().getDeclarationDescriptor();
|
ClassifierDescriptor classifier = type.getConstructor().getDeclarationDescriptor();
|
||||||
@@ -977,7 +978,7 @@ public class DescriptorResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private KtType resolveInitializerType(
|
private KotlinType resolveInitializerType(
|
||||||
@NotNull LexicalScope scope,
|
@NotNull LexicalScope scope,
|
||||||
@NotNull KtExpression initializer,
|
@NotNull KtExpression initializer,
|
||||||
@NotNull DataFlowInfo dataFlowInfo,
|
@NotNull DataFlowInfo dataFlowInfo,
|
||||||
@@ -1015,14 +1016,14 @@ public class DescriptorResolver {
|
|||||||
trace.report(SETTER_PARAMETER_WITH_DEFAULT_VALUE.on(parameter.getDefaultValue()));
|
trace.report(SETTER_PARAMETER_WITH_DEFAULT_VALUE.on(parameter.getDefaultValue()));
|
||||||
}
|
}
|
||||||
|
|
||||||
KtType type;
|
KotlinType type;
|
||||||
KtTypeReference typeReference = parameter.getTypeReference();
|
KtTypeReference typeReference = parameter.getTypeReference();
|
||||||
if (typeReference == null) {
|
if (typeReference == null) {
|
||||||
type = propertyDescriptor.getType(); // TODO : this maybe unknown at this point
|
type = propertyDescriptor.getType(); // TODO : this maybe unknown at this point
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
type = typeResolver.resolveType(scope, typeReference, trace, true);
|
type = typeResolver.resolveType(scope, typeReference, trace, true);
|
||||||
KtType inType = propertyDescriptor.getType();
|
KotlinType inType = propertyDescriptor.getType();
|
||||||
if (inType != null) {
|
if (inType != null) {
|
||||||
if (!TypeUtils.equalTypes(type, inType)) {
|
if (!TypeUtils.equalTypes(type, inType)) {
|
||||||
trace.report(WRONG_SETTER_PARAMETER_TYPE.on(typeReference, inType, type));
|
trace.report(WRONG_SETTER_PARAMETER_TYPE.on(typeReference, inType, type));
|
||||||
@@ -1073,8 +1074,8 @@ public class DescriptorResolver {
|
|||||||
annotationSplitter.getAnnotationsForTarget(PROPERTY_GETTER),
|
annotationSplitter.getAnnotationsForTarget(PROPERTY_GETTER),
|
||||||
annotationResolver.resolveAnnotationsWithoutArguments(scope, getter.getModifierList(), trace)));
|
annotationResolver.resolveAnnotationsWithoutArguments(scope, getter.getModifierList(), trace)));
|
||||||
|
|
||||||
KtType outType = propertyDescriptor.getType();
|
KotlinType outType = propertyDescriptor.getType();
|
||||||
KtType returnType = outType;
|
KotlinType returnType = outType;
|
||||||
KtTypeReference returnTypeReference = getter.getReturnTypeReference();
|
KtTypeReference returnTypeReference = getter.getReturnTypeReference();
|
||||||
if (returnTypeReference != null) {
|
if (returnTypeReference != null) {
|
||||||
returnType = typeResolver.resolveType(scope, returnTypeReference, trace, true);
|
returnType = typeResolver.resolveType(scope, returnTypeReference, trace, true);
|
||||||
@@ -1108,7 +1109,7 @@ public class DescriptorResolver {
|
|||||||
@NotNull LexicalScope scope,
|
@NotNull LexicalScope scope,
|
||||||
@NotNull KtParameter parameter, final BindingTrace trace
|
@NotNull KtParameter parameter, final BindingTrace trace
|
||||||
) {
|
) {
|
||||||
KtType type = resolveParameterType(scope, parameter, trace);
|
KotlinType type = resolveParameterType(scope, parameter, trace);
|
||||||
Name name = parameter.getNameAsSafeName();
|
Name name = parameter.getNameAsSafeName();
|
||||||
boolean isMutable = parameter.isMutable();
|
boolean isMutable = parameter.isMutable();
|
||||||
KtModifierList modifierList = parameter.getModifierList();
|
KtModifierList modifierList = parameter.getModifierList();
|
||||||
@@ -1165,7 +1166,7 @@ public class DescriptorResolver {
|
|||||||
return propertyDescriptor;
|
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;
|
if (type.isError()) return;
|
||||||
|
|
||||||
KtTypeElement typeElement = typeReference.getTypeElement();
|
KtTypeElement typeElement = typeReference.getTypeElement();
|
||||||
@@ -1197,7 +1198,7 @@ public class DescriptorResolver {
|
|||||||
|
|
||||||
if (jetTypeArgument == null) continue;
|
if (jetTypeArgument == null) continue;
|
||||||
|
|
||||||
KtType typeArgument = arguments.get(i).getType();
|
KotlinType typeArgument = arguments.get(i).getType();
|
||||||
checkBounds(jetTypeArgument, typeArgument, trace);
|
checkBounds(jetTypeArgument, typeArgument, trace);
|
||||||
|
|
||||||
TypeParameterDescriptor typeParameterDescriptor = parameters.get(i);
|
TypeParameterDescriptor typeParameterDescriptor = parameters.get(i);
|
||||||
@@ -1207,13 +1208,13 @@ public class DescriptorResolver {
|
|||||||
|
|
||||||
public static void checkBounds(
|
public static void checkBounds(
|
||||||
@NotNull KtTypeReference jetTypeArgument,
|
@NotNull KtTypeReference jetTypeArgument,
|
||||||
@NotNull KtType typeArgument,
|
@NotNull KotlinType typeArgument,
|
||||||
@NotNull TypeParameterDescriptor typeParameterDescriptor,
|
@NotNull TypeParameterDescriptor typeParameterDescriptor,
|
||||||
@NotNull TypeSubstitutor substitutor,
|
@NotNull TypeSubstitutor substitutor,
|
||||||
@NotNull BindingTrace trace
|
@NotNull BindingTrace trace
|
||||||
) {
|
) {
|
||||||
for (KtType bound : typeParameterDescriptor.getUpperBounds()) {
|
for (KotlinType bound : typeParameterDescriptor.getUpperBounds()) {
|
||||||
KtType substitutedBound = substitutor.safeSubstitute(bound, Variance.INVARIANT);
|
KotlinType substitutedBound = substitutor.safeSubstitute(bound, Variance.INVARIANT);
|
||||||
if (!KotlinTypeChecker.DEFAULT.isSubtypeOf(typeArgument, substitutedBound)) {
|
if (!KotlinTypeChecker.DEFAULT.isSubtypeOf(typeArgument, substitutedBound)) {
|
||||||
trace.report(UPPER_BOUND_VIOLATED.on(jetTypeArgument, substitutedBound, typeArgument));
|
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.storage.StorageManager
|
||||||
import org.jetbrains.kotlin.types.DeferredType
|
import org.jetbrains.kotlin.types.DeferredType
|
||||||
import org.jetbrains.kotlin.types.ErrorUtils
|
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.TypeUtils
|
||||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
|
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
|
||||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices
|
import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices
|
||||||
@@ -84,7 +84,7 @@ class FunctionDescriptorResolver(
|
|||||||
function: KtNamedFunction,
|
function: KtNamedFunction,
|
||||||
trace: BindingTrace,
|
trace: BindingTrace,
|
||||||
dataFlowInfo: DataFlowInfo,
|
dataFlowInfo: DataFlowInfo,
|
||||||
expectedFunctionType: KtType
|
expectedFunctionType: KotlinType
|
||||||
): SimpleFunctionDescriptor = resolveFunctionDescriptor(
|
): SimpleFunctionDescriptor = resolveFunctionDescriptor(
|
||||||
::FunctionExpressionDescriptor, containingDescriptor, scope, function, trace, dataFlowInfo, expectedFunctionType)
|
::FunctionExpressionDescriptor, containingDescriptor, scope, function, trace, dataFlowInfo, expectedFunctionType)
|
||||||
|
|
||||||
@@ -95,7 +95,7 @@ class FunctionDescriptorResolver(
|
|||||||
function: KtNamedFunction,
|
function: KtNamedFunction,
|
||||||
trace: BindingTrace,
|
trace: BindingTrace,
|
||||||
dataFlowInfo: DataFlowInfo,
|
dataFlowInfo: DataFlowInfo,
|
||||||
expectedFunctionType: KtType
|
expectedFunctionType: KotlinType
|
||||||
): SimpleFunctionDescriptor {
|
): SimpleFunctionDescriptor {
|
||||||
val functionDescriptor = functionConstructor(
|
val functionDescriptor = functionConstructor(
|
||||||
containingDescriptor,
|
containingDescriptor,
|
||||||
@@ -143,7 +143,7 @@ class FunctionDescriptorResolver(
|
|||||||
function: KtFunction,
|
function: KtFunction,
|
||||||
functionDescriptor: SimpleFunctionDescriptorImpl,
|
functionDescriptor: SimpleFunctionDescriptorImpl,
|
||||||
trace: BindingTrace,
|
trace: BindingTrace,
|
||||||
expectedFunctionType: KtType
|
expectedFunctionType: KotlinType
|
||||||
) {
|
) {
|
||||||
val innerScope = LexicalWritableScope(scope, functionDescriptor, true, null,
|
val innerScope = LexicalWritableScope(scope, functionDescriptor, true, null,
|
||||||
TraceBasedRedeclarationHandler(trace), "Function descriptor header scope")
|
TraceBasedRedeclarationHandler(trace), "Function descriptor header scope")
|
||||||
@@ -194,7 +194,7 @@ class FunctionDescriptorResolver(
|
|||||||
functionDescriptor: SimpleFunctionDescriptorImpl,
|
functionDescriptor: SimpleFunctionDescriptorImpl,
|
||||||
innerScope: LexicalWritableScope,
|
innerScope: LexicalWritableScope,
|
||||||
trace: BindingTrace,
|
trace: BindingTrace,
|
||||||
expectedFunctionType: KtType
|
expectedFunctionType: KotlinType
|
||||||
): List<ValueParameterDescriptor> {
|
): List<ValueParameterDescriptor> {
|
||||||
val expectedValueParameters = expectedFunctionType.getValueParameters(functionDescriptor)
|
val expectedValueParameters = expectedFunctionType.getValueParameters(functionDescriptor)
|
||||||
if (expectedValueParameters != null) {
|
if (expectedValueParameters != null) {
|
||||||
@@ -225,11 +225,11 @@ class FunctionDescriptorResolver(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun KtType.functionTypeExpected() = !TypeUtils.noExpectedType(this) && KotlinBuiltIns.isFunctionOrExtensionFunctionType(this)
|
private fun KotlinType.functionTypeExpected() = !TypeUtils.noExpectedType(this) && KotlinBuiltIns.isFunctionOrExtensionFunctionType(this)
|
||||||
private fun KtType.getReceiverType(): KtType? =
|
private fun KotlinType.getReceiverType(): KotlinType? =
|
||||||
if (functionTypeExpected()) KotlinBuiltIns.getReceiverType(this) else null
|
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
|
if (functionTypeExpected()) KotlinBuiltIns.getValueParameters(owner, this) else null
|
||||||
|
|
||||||
public fun resolvePrimaryConstructorDescriptor(
|
public fun resolvePrimaryConstructorDescriptor(
|
||||||
@@ -322,7 +322,7 @@ class FunctionDescriptorResolver(
|
|||||||
val typeReference = valueParameter.getTypeReference()
|
val typeReference = valueParameter.getTypeReference()
|
||||||
val expectedType = expectedValueParameters?.let { if (i < it.size()) it[i].getType() else null }
|
val expectedType = expectedValueParameters?.let { if (i < it.size()) it[i].getType() else null }
|
||||||
|
|
||||||
val type: KtType
|
val type: KotlinType
|
||||||
if (typeReference != null) {
|
if (typeReference != null) {
|
||||||
type = typeResolver.resolveType(parameterScope, typeReference, trace, true)
|
type = typeResolver.resolveType(parameterScope, typeReference, trace, true)
|
||||||
if (expectedType != null && !TypeUtils.noExpectedType(expectedType)) {
|
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() {
|
private static final TypeSubstitutor MAKE_TYPE_PARAMETERS_FRESH = TypeSubstitutor.create(new TypeSubstitution() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TypeProjection get(@NotNull KtType key) {
|
public TypeProjection get(@NotNull KotlinType key) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ public class FunctionDescriptorUtil {
|
|||||||
|
|
||||||
public static TypeSubstitution createSubstitution(
|
public static TypeSubstitution createSubstitution(
|
||||||
@NotNull FunctionDescriptor functionDescriptor,
|
@NotNull FunctionDescriptor functionDescriptor,
|
||||||
@NotNull List<KtType> typeArguments
|
@NotNull List<KotlinType> typeArguments
|
||||||
) {
|
) {
|
||||||
if (functionDescriptor.getTypeParameters().isEmpty()) return TypeSubstitution.getEMPTY();
|
if (functionDescriptor.getTypeParameters().isEmpty()) return TypeSubstitution.getEMPTY();
|
||||||
|
|
||||||
@@ -90,7 +90,7 @@ public class FunctionDescriptorUtil {
|
|||||||
|
|
||||||
public static void initializeFromFunctionType(
|
public static void initializeFromFunctionType(
|
||||||
@NotNull FunctionDescriptorImpl functionDescriptor,
|
@NotNull FunctionDescriptorImpl functionDescriptor,
|
||||||
@NotNull KtType functionType,
|
@NotNull KotlinType functionType,
|
||||||
@Nullable ReceiverParameterDescriptor dispatchReceiverParameter,
|
@Nullable ReceiverParameterDescriptor dispatchReceiverParameter,
|
||||||
@NotNull Modality modality,
|
@NotNull Modality modality,
|
||||||
@NotNull Visibility visibility
|
@NotNull Visibility visibility
|
||||||
@@ -129,7 +129,7 @@ public class FunctionDescriptorUtil {
|
|||||||
List<ValueParameterDescriptor> parameters = new ArrayList<ValueParameterDescriptor>(newParameters.size());
|
List<ValueParameterDescriptor> parameters = new ArrayList<ValueParameterDescriptor>(newParameters.size());
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
for (ValueParameterDescriptor parameter : newParameters) {
|
for (ValueParameterDescriptor parameter : newParameters) {
|
||||||
KtType returnType = parameter.getReturnType();
|
KotlinType returnType = parameter.getReturnType();
|
||||||
assert returnType != null;
|
assert returnType != null;
|
||||||
|
|
||||||
parameters.add(
|
parameters.add(
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.kotlin.diagnostics.Diagnostic;
|
import org.jetbrains.kotlin.diagnostics.Diagnostic;
|
||||||
import org.jetbrains.kotlin.psi.KtExpression;
|
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.ReadOnlySlice;
|
||||||
import org.jetbrains.kotlin.util.slicedMap.WritableSlice;
|
import org.jetbrains.kotlin.util.slicedMap.WritableSlice;
|
||||||
|
|
||||||
@@ -78,12 +78,12 @@ public class ObservableBindingTrace implements BindingTrace {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public KtType getType(@NotNull KtExpression expression) {
|
public KotlinType getType(@NotNull KtExpression expression) {
|
||||||
return originalTrace.getType(expression);
|
return originalTrace.getType(expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void recordType(@NotNull KtExpression expression, @Nullable KtType type) {
|
public void recordType(@NotNull KtExpression expression, @Nullable KotlinType type) {
|
||||||
originalTrace.recordType(expression, 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.ConstructorDescriptor;
|
||||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor;
|
import org.jetbrains.kotlin.descriptors.PropertyDescriptor;
|
||||||
import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor;
|
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.TypeCapabilitiesKt;
|
||||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
|
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
|
||||||
|
|
||||||
@@ -65,12 +65,12 @@ public class OverloadUtil {
|
|||||||
return receiverAndParameterResult;
|
return receiverAndParameterResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<KtType> superValueParameters = OverridingUtil.compiledValueParameters(superDescriptor);
|
List<KotlinType> superValueParameters = OverridingUtil.compiledValueParameters(superDescriptor);
|
||||||
List<KtType> subValueParameters = OverridingUtil.compiledValueParameters(subDescriptor);
|
List<KotlinType> subValueParameters = OverridingUtil.compiledValueParameters(subDescriptor);
|
||||||
|
|
||||||
for (int i = 0; i < superValueParameters.size(); ++i) {
|
for (int i = 0; i < superValueParameters.size(); ++i) {
|
||||||
KtType superValueParameterType = OverridingUtil.getUpperBound(superValueParameters.get(i));
|
KotlinType superValueParameterType = OverridingUtil.getUpperBound(superValueParameters.get(i));
|
||||||
KtType subValueParameterType = OverridingUtil.getUpperBound(subValueParameters.get(i));
|
KotlinType subValueParameterType = OverridingUtil.getUpperBound(subValueParameters.get(i));
|
||||||
if (!KotlinTypeChecker.DEFAULT.equalTypes(superValueParameterType, subValueParameterType)
|
if (!KotlinTypeChecker.DEFAULT.equalTypes(superValueParameterType, subValueParameterType)
|
||||||
|| TypeCapabilitiesKt.oneMoreSpecificThanAnother(subValueParameterType, superValueParameterType)) {
|
|| TypeCapabilitiesKt.oneMoreSpecificThanAnother(subValueParameterType, superValueParameterType)) {
|
||||||
return OverridingUtil.OverrideCompatibilityInfo
|
return OverridingUtil.OverrideCompatibilityInfo
|
||||||
|
|||||||
@@ -235,13 +235,13 @@ public class OverrideResolver {
|
|||||||
|
|
||||||
private static List<CallableMemberDescriptor> getCallableMembersFromSupertypes(ClassDescriptor classDescriptor) {
|
private static List<CallableMemberDescriptor> getCallableMembersFromSupertypes(ClassDescriptor classDescriptor) {
|
||||||
Set<CallableMemberDescriptor> r = Sets.newLinkedHashSet();
|
Set<CallableMemberDescriptor> r = Sets.newLinkedHashSet();
|
||||||
for (KtType supertype : classDescriptor.getTypeConstructor().getSupertypes()) {
|
for (KotlinType supertype : classDescriptor.getTypeConstructor().getSupertypes()) {
|
||||||
r.addAll(getCallableMembersFromType(supertype));
|
r.addAll(getCallableMembersFromType(supertype));
|
||||||
}
|
}
|
||||||
return new ArrayList<CallableMemberDescriptor>(r);
|
return new ArrayList<CallableMemberDescriptor>(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<CallableMemberDescriptor> getCallableMembersFromType(KtType type) {
|
private static List<CallableMemberDescriptor> getCallableMembersFromType(KotlinType type) {
|
||||||
List<CallableMemberDescriptor> r = Lists.newArrayList();
|
List<CallableMemberDescriptor> r = Lists.newArrayList();
|
||||||
for (DeclarationDescriptor decl : type.getMemberScope().getAllDescriptors()) {
|
for (DeclarationDescriptor decl : type.getMemberScope().getAllDescriptors()) {
|
||||||
if (decl instanceof PropertyDescriptor || decl instanceof SimpleFunctionDescriptor) {
|
if (decl instanceof PropertyDescriptor || decl instanceof SimpleFunctionDescriptor) {
|
||||||
@@ -687,13 +687,13 @@ public class OverrideResolver {
|
|||||||
TypeSubstitutor typeSubstitutor = prepareTypeSubstitutor(superDescriptor, subDescriptor);
|
TypeSubstitutor typeSubstitutor = prepareTypeSubstitutor(superDescriptor, subDescriptor);
|
||||||
if (typeSubstitutor == null) return false;
|
if (typeSubstitutor == null) return false;
|
||||||
|
|
||||||
KtType superReturnType = superDescriptor.getReturnType();
|
KotlinType superReturnType = superDescriptor.getReturnType();
|
||||||
assert superReturnType != null;
|
assert superReturnType != null;
|
||||||
|
|
||||||
KtType subReturnType = subDescriptor.getReturnType();
|
KotlinType subReturnType = subDescriptor.getReturnType();
|
||||||
assert subReturnType != null;
|
assert subReturnType != null;
|
||||||
|
|
||||||
KtType substitutedSuperReturnType = typeSubstitutor.substitute(superReturnType, Variance.OUT_VARIANCE);
|
KotlinType substitutedSuperReturnType = typeSubstitutor.substitute(superReturnType, Variance.OUT_VARIANCE);
|
||||||
assert substitutedSuperReturnType != null;
|
assert substitutedSuperReturnType != null;
|
||||||
|
|
||||||
return KotlinTypeChecker.DEFAULT.isSubtypeOf(subReturnType, substitutedSuperReturnType);
|
return KotlinTypeChecker.DEFAULT.isSubtypeOf(subReturnType, substitutedSuperReturnType);
|
||||||
@@ -725,7 +725,7 @@ public class OverrideResolver {
|
|||||||
|
|
||||||
if (!superDescriptor.isVar()) return true;
|
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;
|
assert substitutedSuperReturnType != null;
|
||||||
return KotlinTypeChecker.DEFAULT.equalTypes(subDescriptor.getType(), substitutedSuperReturnType);
|
return KotlinTypeChecker.DEFAULT.equalTypes(subDescriptor.getType(), substitutedSuperReturnType);
|
||||||
}
|
}
|
||||||
@@ -792,7 +792,7 @@ public class OverrideResolver {
|
|||||||
@NotNull CallableMemberDescriptor declared,
|
@NotNull CallableMemberDescriptor declared,
|
||||||
@NotNull ClassDescriptor declaringClass
|
@NotNull ClassDescriptor declaringClass
|
||||||
) {
|
) {
|
||||||
for (KtType supertype : declaringClass.getTypeConstructor().getSupertypes()) {
|
for (KotlinType supertype : declaringClass.getTypeConstructor().getSupertypes()) {
|
||||||
Set<CallableMemberDescriptor> all = Sets.newLinkedHashSet();
|
Set<CallableMemberDescriptor> all = Sets.newLinkedHashSet();
|
||||||
all.addAll(supertype.getMemberScope().getFunctions(declared.getName(), NoLookupLocation.UNSORTED));
|
all.addAll(supertype.getMemberScope().getFunctions(declared.getName(), NoLookupLocation.UNSORTED));
|
||||||
//noinspection unchecked
|
//noinspection unchecked
|
||||||
|
|||||||
@@ -48,15 +48,15 @@ public class PossiblyBareType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static PossiblyBareType type(@NotNull KtType actualType) {
|
public static PossiblyBareType type(@NotNull KotlinType actualType) {
|
||||||
return new PossiblyBareType(actualType, null, false);
|
return new PossiblyBareType(actualType, null, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final KtType actualType;
|
private final KotlinType actualType;
|
||||||
private final TypeConstructor bareTypeConstructor;
|
private final TypeConstructor bareTypeConstructor;
|
||||||
private final boolean nullable;
|
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.actualType = actualType;
|
||||||
this.bareTypeConstructor = bareTypeConstructor;
|
this.bareTypeConstructor = bareTypeConstructor;
|
||||||
this.nullable = nullable;
|
this.nullable = nullable;
|
||||||
@@ -67,7 +67,7 @@ public class PossiblyBareType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public KtType getActualType() {
|
public KotlinType getActualType() {
|
||||||
//noinspection ConstantConditions
|
//noinspection ConstantConditions
|
||||||
return actualType;
|
return actualType;
|
||||||
}
|
}
|
||||||
@@ -95,18 +95,18 @@ public class PossiblyBareType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public TypeReconstructionResult reconstruct(@NotNull KtType subjectType) {
|
public TypeReconstructionResult reconstruct(@NotNull KotlinType subjectType) {
|
||||||
if (!isBare()) return new TypeReconstructionResult(getActualType(), true);
|
if (!isBare()) return new TypeReconstructionResult(getActualType(), true);
|
||||||
|
|
||||||
TypeReconstructionResult reconstructionResult = CastDiagnosticsUtil.findStaticallyKnownSubtype(
|
TypeReconstructionResult reconstructionResult = CastDiagnosticsUtil.findStaticallyKnownSubtype(
|
||||||
TypeUtils.makeNotNullable(subjectType),
|
TypeUtils.makeNotNullable(subjectType),
|
||||||
getBareTypeConstructor()
|
getBareTypeConstructor()
|
||||||
);
|
);
|
||||||
KtType type = reconstructionResult.getResultingType();
|
KotlinType type = reconstructionResult.getResultingType();
|
||||||
// No need to make an absent type nullable
|
// No need to make an absent type nullable
|
||||||
if (type == null) return reconstructionResult;
|
if (type == null) return reconstructionResult;
|
||||||
|
|
||||||
KtType resultingType = TypeUtils.makeNullableAsSpecified(type, isBareTypeNullable());
|
KotlinType resultingType = TypeUtils.makeNullableAsSpecified(type, isBareTypeNullable());
|
||||||
return new TypeReconstructionResult(resultingType, reconstructionResult.isAllArgumentsInferred());
|
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.calls.smartcasts.DataFlowInfo;
|
||||||
import org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil;
|
import org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil;
|
||||||
import org.jetbrains.kotlin.types.ErrorUtils;
|
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.CoercionStrategy;
|
||||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingContext;
|
import org.jetbrains.kotlin.types.expressions.ExpressionTypingContext;
|
||||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices;
|
import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices;
|
||||||
@@ -52,7 +52,7 @@ public class ScriptBodyResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public KtType resolveScriptReturnType(
|
public KotlinType resolveScriptReturnType(
|
||||||
@NotNull KtScript script,
|
@NotNull KtScript script,
|
||||||
@NotNull ScriptDescriptor scriptDescriptor,
|
@NotNull ScriptDescriptor scriptDescriptor,
|
||||||
@NotNull BindingTrace trace
|
@NotNull BindingTrace trace
|
||||||
@@ -65,7 +65,7 @@ public class ScriptBodyResolver {
|
|||||||
NO_EXPECTED_TYPE
|
NO_EXPECTED_TYPE
|
||||||
);
|
);
|
||||||
PreliminaryDeclarationVisitor.Companion.createForDeclaration(script, trace);
|
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) {
|
if (returnType == null) {
|
||||||
returnType = ErrorUtils.createErrorType("getBlockReturnedType returned null");
|
returnType = ErrorUtils.createErrorType("getBlockReturnedType returned null");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.resolve.typeBinding
|
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 org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||||
import com.intellij.psi.PsiElement
|
import com.intellij.psi.PsiElement
|
||||||
import org.jetbrains.kotlin.psi.KtTypeElement
|
import org.jetbrains.kotlin.psi.KtTypeElement
|
||||||
@@ -30,7 +30,7 @@ import org.jetbrains.kotlin.types.TypeProjectionImpl
|
|||||||
|
|
||||||
interface TypeBinding<out P : PsiElement> {
|
interface TypeBinding<out P : PsiElement> {
|
||||||
val psiElement: P
|
val psiElement: P
|
||||||
val jetType: KtType
|
val jetType: KotlinType
|
||||||
fun getArgumentBindings(): List<TypeArgumentBinding<P>?>
|
fun getArgumentBindings(): List<TypeArgumentBinding<P>?>
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,7 +70,7 @@ private class TypeArgumentBindingImpl<out P: PsiElement>(
|
|||||||
private class ExplicitTypeBinding(
|
private class ExplicitTypeBinding(
|
||||||
private val trace: BindingContext,
|
private val trace: BindingContext,
|
||||||
override val psiElement: KtTypeElement,
|
override val psiElement: KtTypeElement,
|
||||||
override val jetType: KtType
|
override val jetType: KotlinType
|
||||||
) : TypeBinding<KtTypeElement> {
|
) : TypeBinding<KtTypeElement> {
|
||||||
|
|
||||||
override fun getArgumentBindings(): List<TypeArgumentBinding<KtTypeElement>?> {
|
override fun getArgumentBindings(): List<TypeArgumentBinding<KtTypeElement>?> {
|
||||||
@@ -111,7 +111,7 @@ private class ExplicitTypeBinding(
|
|||||||
private class NoTypeElementBinding<out P : PsiElement>(
|
private class NoTypeElementBinding<out P : PsiElement>(
|
||||||
private val trace: BindingContext,
|
private val trace: BindingContext,
|
||||||
override val psiElement: P,
|
override val psiElement: P,
|
||||||
override val jetType: KtType
|
override val jetType: KotlinType
|
||||||
): TypeBinding<P> {
|
): TypeBinding<P> {
|
||||||
|
|
||||||
override fun getArgumentBindings(): List<TypeArgumentBinding<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
|
// bare types are not allowed
|
||||||
return resolveType(TypeResolutionContext(scope, trace, checkBounds, false), typeReference)
|
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" }
|
assert(!c.allowBareTypes) { "Use resolvePossiblyBareType() when bare types are allowed" }
|
||||||
return resolvePossiblyBareType(c, typeReference).getActualType()
|
return resolvePossiblyBareType(c, typeReference).getActualType()
|
||||||
}
|
}
|
||||||
@@ -136,7 +136,7 @@ public class TypeResolver(
|
|||||||
*
|
*
|
||||||
* todo: find another way after release
|
* todo: find another way after release
|
||||||
*/
|
*/
|
||||||
private fun forceResolveTypeContents(type: KtType) {
|
private fun forceResolveTypeContents(type: KotlinType) {
|
||||||
type.annotations // force read type annotations
|
type.annotations // force read type annotations
|
||||||
if (type.isFlexible()) {
|
if (type.isFlexible()) {
|
||||||
forceResolveTypeContents(type.flexibility().lowerBound)
|
forceResolveTypeContents(type.flexibility().lowerBound)
|
||||||
@@ -180,7 +180,7 @@ public class TypeResolver(
|
|||||||
result = if (scopeForTypeParameter is ErrorUtils.ErrorScope)
|
result = if (scopeForTypeParameter is ErrorUtils.ErrorScope)
|
||||||
type(ErrorUtils.createErrorType("?"))
|
type(ErrorUtils.createErrorType("?"))
|
||||||
else
|
else
|
||||||
type(KtTypeImpl.create(
|
type(KotlinTypeImpl.create(
|
||||||
annotations,
|
annotations,
|
||||||
classifierDescriptor.getTypeConstructor(),
|
classifierDescriptor.getTypeConstructor(),
|
||||||
TypeUtils.hasNullableLowerBound(classifierDescriptor),
|
TypeUtils.hasNullableLowerBound(classifierDescriptor),
|
||||||
@@ -234,7 +234,7 @@ public class TypeResolver(
|
|||||||
)
|
)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
val resultingType = KtTypeImpl.create(annotations, classifierDescriptor, false, arguments)
|
val resultingType = KotlinTypeImpl.create(annotations, classifierDescriptor, false, arguments)
|
||||||
result = type(resultingType)
|
result = type(resultingType)
|
||||||
if (c.checkBounds) {
|
if (c.checkBounds) {
|
||||||
val substitutor = TypeSubstitutor.create(resultingType)
|
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.psi.KtCallableDeclaration
|
||||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||||
import org.jetbrains.kotlin.resolve.TopDownAnalysisContext
|
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.KtClass
|
||||||
import org.jetbrains.kotlin.psi.KtTypeReference
|
import org.jetbrains.kotlin.psi.KtTypeReference
|
||||||
import org.jetbrains.kotlin.types.Variance.*
|
import org.jetbrains.kotlin.types.Variance.*
|
||||||
@@ -74,7 +74,7 @@ class VarianceChecker(private val trace: BindingTrace) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class VarianceConflictDiagnosticData(
|
class VarianceConflictDiagnosticData(
|
||||||
val containingType: KtType,
|
val containingType: KotlinType,
|
||||||
val typeParameter: TypeParameterDescriptor,
|
val typeParameter: TypeParameterDescriptor,
|
||||||
val occurrencePosition: Variance
|
val occurrencePosition: Variance
|
||||||
)
|
)
|
||||||
@@ -158,7 +158,7 @@ class VarianceChecker(private val trace: BindingTrace) {
|
|||||||
private fun TypeBinding<PsiElement>.checkTypePosition(position: Variance, diagnosticSink: DiagnosticSink)
|
private fun TypeBinding<PsiElement>.checkTypePosition(position: Variance, diagnosticSink: DiagnosticSink)
|
||||||
= checkTypePosition(jetType, position, 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()
|
val classifierDescriptor = jetType.getConstructor().getDeclarationDescriptor()
|
||||||
if (classifierDescriptor is TypeParameterDescriptor) {
|
if (classifierDescriptor is TypeParameterDescriptor) {
|
||||||
val declarationVariance = classifierDescriptor.getVariance()
|
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.scopes.utils.memberScopeAsFileScope
|
||||||
import org.jetbrains.kotlin.resolve.source.toSourceElement
|
import org.jetbrains.kotlin.resolve.source.toSourceElement
|
||||||
import org.jetbrains.kotlin.types.FunctionPlaceholders
|
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.TypeUtils
|
||||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils
|
import org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils
|
||||||
import org.jetbrains.kotlin.utils.ThrowingList
|
import org.jetbrains.kotlin.utils.ThrowingList
|
||||||
@@ -55,7 +55,7 @@ public fun resolveCallableReferenceReceiverType(
|
|||||||
callableReferenceExpression: KtCallableReferenceExpression,
|
callableReferenceExpression: KtCallableReferenceExpression,
|
||||||
context: ResolutionContext<*>,
|
context: ResolutionContext<*>,
|
||||||
typeResolver: TypeResolver
|
typeResolver: TypeResolver
|
||||||
): KtType? =
|
): KotlinType? =
|
||||||
callableReferenceExpression.typeReference?.let {
|
callableReferenceExpression.typeReference?.let {
|
||||||
typeResolver.resolveType(context.scope, it, context.trace, false)
|
typeResolver.resolveType(context.scope, it, context.trace, false)
|
||||||
}
|
}
|
||||||
@@ -93,7 +93,7 @@ private fun OverloadResolutionResults<*>.isSomething(): Boolean = !isNothing()
|
|||||||
|
|
||||||
public fun resolvePossiblyAmbiguousCallableReference(
|
public fun resolvePossiblyAmbiguousCallableReference(
|
||||||
callableReferenceExpression: KtCallableReferenceExpression,
|
callableReferenceExpression: KtCallableReferenceExpression,
|
||||||
lhsType: KtType?,
|
lhsType: KotlinType?,
|
||||||
context: ResolutionContext<*>,
|
context: ResolutionContext<*>,
|
||||||
resolutionMode: ResolveArgumentsMode,
|
resolutionMode: ResolveArgumentsMode,
|
||||||
callResolver: CallResolver
|
callResolver: CallResolver
|
||||||
@@ -142,7 +142,7 @@ public fun resolvePossiblyAmbiguousCallableReference(
|
|||||||
|
|
||||||
public fun resolveCallableReferenceTarget(
|
public fun resolveCallableReferenceTarget(
|
||||||
callableReferenceExpression: KtCallableReferenceExpression,
|
callableReferenceExpression: KtCallableReferenceExpression,
|
||||||
lhsType: KtType?,
|
lhsType: KotlinType?,
|
||||||
context: ResolutionContext<*>,
|
context: ResolutionContext<*>,
|
||||||
resolvedToSomething: BooleanArray,
|
resolvedToSomething: BooleanArray,
|
||||||
callResolver: CallResolver
|
callResolver: CallResolver
|
||||||
@@ -164,9 +164,9 @@ public fun resolveCallableReferenceTarget(
|
|||||||
|
|
||||||
private fun createReflectionTypeForFunction(
|
private fun createReflectionTypeForFunction(
|
||||||
descriptor: FunctionDescriptor,
|
descriptor: FunctionDescriptor,
|
||||||
receiverType: KtType?,
|
receiverType: KotlinType?,
|
||||||
reflectionTypes: ReflectionTypes
|
reflectionTypes: ReflectionTypes
|
||||||
): KtType? {
|
): KotlinType? {
|
||||||
val returnType = descriptor.getReturnType() ?: return null
|
val returnType = descriptor.getReturnType() ?: return null
|
||||||
val valueParametersTypes = ExpressionTypingUtils.getValueParametersTypes(descriptor.getValueParameters())
|
val valueParametersTypes = ExpressionTypingUtils.getValueParametersTypes(descriptor.getValueParameters())
|
||||||
return reflectionTypes.getKFunctionType(Annotations.EMPTY, receiverType, valueParametersTypes, returnType)
|
return reflectionTypes.getKFunctionType(Annotations.EMPTY, receiverType, valueParametersTypes, returnType)
|
||||||
@@ -174,13 +174,13 @@ private fun createReflectionTypeForFunction(
|
|||||||
|
|
||||||
private fun createReflectionTypeForProperty(
|
private fun createReflectionTypeForProperty(
|
||||||
descriptor: PropertyDescriptor,
|
descriptor: PropertyDescriptor,
|
||||||
receiverType: KtType?,
|
receiverType: KotlinType?,
|
||||||
reflectionTypes: ReflectionTypes
|
reflectionTypes: ReflectionTypes
|
||||||
): KtType {
|
): KotlinType {
|
||||||
return reflectionTypes.getKPropertyType(Annotations.EMPTY, receiverType, descriptor.getType(), descriptor.isVar())
|
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(
|
val functionDescriptor = AnonymousFunctionDescriptor(
|
||||||
context.scope.ownerDescriptor,
|
context.scope.ownerDescriptor,
|
||||||
Annotations.EMPTY,
|
Annotations.EMPTY,
|
||||||
@@ -192,7 +192,7 @@ private fun bindFunctionReference(expression: KtCallableReferenceExpression, ref
|
|||||||
context.trace.record(BindingContext.FUNCTION, expression, functionDescriptor)
|
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>"),
|
val localVariable = LocalVariableDescriptor(context.scope.ownerDescriptor, Annotations.EMPTY, Name.special("<anonymous>"),
|
||||||
referenceType, /* mutable = */ false, expression.toSourceElement())
|
referenceType, /* mutable = */ false, expression.toSourceElement())
|
||||||
|
|
||||||
@@ -201,11 +201,11 @@ private fun bindPropertyReference(expression: KtCallableReferenceExpression, ref
|
|||||||
|
|
||||||
private fun createReflectionTypeForCallableDescriptor(
|
private fun createReflectionTypeForCallableDescriptor(
|
||||||
descriptor: CallableDescriptor,
|
descriptor: CallableDescriptor,
|
||||||
lhsType: KtType?,
|
lhsType: KotlinType?,
|
||||||
reflectionTypes: ReflectionTypes,
|
reflectionTypes: ReflectionTypes,
|
||||||
trace: BindingTrace?,
|
trace: BindingTrace?,
|
||||||
reportOn: KtExpression?
|
reportOn: KtExpression?
|
||||||
): KtType? {
|
): KotlinType? {
|
||||||
val extensionReceiver = descriptor.extensionReceiverParameter
|
val extensionReceiver = descriptor.extensionReceiverParameter
|
||||||
val dispatchReceiver = descriptor.dispatchReceiverParameter?.let { dispatchReceiver ->
|
val dispatchReceiver = descriptor.dispatchReceiverParameter?.let { dispatchReceiver ->
|
||||||
// See CallableDescriptor#getOwnerForEffectiveDispatchReceiverParameter
|
// See CallableDescriptor#getOwnerForEffectiveDispatchReceiverParameter
|
||||||
@@ -245,16 +245,16 @@ private fun createReflectionTypeForCallableDescriptor(
|
|||||||
public fun getReflectionTypeForCandidateDescriptor(
|
public fun getReflectionTypeForCandidateDescriptor(
|
||||||
descriptor: CallableDescriptor,
|
descriptor: CallableDescriptor,
|
||||||
reflectionTypes: ReflectionTypes
|
reflectionTypes: ReflectionTypes
|
||||||
): KtType? =
|
): KotlinType? =
|
||||||
createReflectionTypeForCallableDescriptor(descriptor, null, reflectionTypes, null, null)
|
createReflectionTypeForCallableDescriptor(descriptor, null, reflectionTypes, null, null)
|
||||||
|
|
||||||
public fun createReflectionTypeForResolvedCallableReference(
|
public fun createReflectionTypeForResolvedCallableReference(
|
||||||
reference: KtCallableReferenceExpression,
|
reference: KtCallableReferenceExpression,
|
||||||
lhsType: KtType?,
|
lhsType: KotlinType?,
|
||||||
descriptor: CallableDescriptor,
|
descriptor: CallableDescriptor,
|
||||||
context: ResolutionContext<*>,
|
context: ResolutionContext<*>,
|
||||||
reflectionTypes: ReflectionTypes
|
reflectionTypes: ReflectionTypes
|
||||||
): KtType? {
|
): KotlinType? {
|
||||||
val type = createReflectionTypeForCallableDescriptor(
|
val type = createReflectionTypeForCallableDescriptor(
|
||||||
descriptor, lhsType, reflectionTypes, context.trace, reference.getCallableReference()
|
descriptor, lhsType, reflectionTypes, context.trace, reference.getCallableReference()
|
||||||
) ?: return null
|
) ?: return null
|
||||||
@@ -271,14 +271,14 @@ public fun createReflectionTypeForResolvedCallableReference(
|
|||||||
|
|
||||||
public fun getResolvedCallableReferenceShapeType(
|
public fun getResolvedCallableReferenceShapeType(
|
||||||
reference: KtCallableReferenceExpression,
|
reference: KtCallableReferenceExpression,
|
||||||
lhsType: KtType?,
|
lhsType: KotlinType?,
|
||||||
overloadResolutionResults: OverloadResolutionResults<CallableDescriptor>?,
|
overloadResolutionResults: OverloadResolutionResults<CallableDescriptor>?,
|
||||||
context: ResolutionContext<*>,
|
context: ResolutionContext<*>,
|
||||||
expectedTypeUnknown: Boolean,
|
expectedTypeUnknown: Boolean,
|
||||||
reflectionTypes: ReflectionTypes,
|
reflectionTypes: ReflectionTypes,
|
||||||
builtIns: KotlinBuiltIns,
|
builtIns: KotlinBuiltIns,
|
||||||
functionPlaceholders: FunctionPlaceholders
|
functionPlaceholders: FunctionPlaceholders
|
||||||
): KtType? =
|
): KotlinType? =
|
||||||
when {
|
when {
|
||||||
overloadResolutionResults == null ->
|
overloadResolutionResults == null ->
|
||||||
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.resolve.scopes.receivers.ReceiverValue;
|
||||||
import org.jetbrains.kotlin.types.FunctionPlaceholders;
|
import org.jetbrains.kotlin.types.FunctionPlaceholders;
|
||||||
import org.jetbrains.kotlin.types.FunctionPlaceholdersKt;
|
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.TypeUtils;
|
||||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
|
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
|
||||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices;
|
import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices;
|
||||||
@@ -94,11 +94,11 @@ public class ArgumentTypeResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isSubtypeOfForArgumentType(
|
public static boolean isSubtypeOfForArgumentType(
|
||||||
@NotNull KtType actualType,
|
@NotNull KotlinType actualType,
|
||||||
@NotNull KtType expectedType
|
@NotNull KotlinType expectedType
|
||||||
) {
|
) {
|
||||||
if (FunctionPlaceholdersKt.isFunctionPlaceholder(actualType)) {
|
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(functionType, expectedType);
|
||||||
}
|
}
|
||||||
return KotlinTypeChecker.DEFAULT.isSubtypeOf(actualType, expectedType);
|
return KotlinTypeChecker.DEFAULT.isSubtypeOf(actualType, expectedType);
|
||||||
@@ -231,19 +231,19 @@ public class ArgumentTypeResolver {
|
|||||||
@NotNull ResolveArgumentsMode resolveArgumentsMode
|
@NotNull ResolveArgumentsMode resolveArgumentsMode
|
||||||
) {
|
) {
|
||||||
if (resolveArgumentsMode == SHAPE_FUNCTION_ARGUMENTS) {
|
if (resolveArgumentsMode == SHAPE_FUNCTION_ARGUMENTS) {
|
||||||
KtType type = getShapeTypeOfCallableReference(callableReferenceExpression, context, true);
|
KotlinType type = getShapeTypeOfCallableReference(callableReferenceExpression, context, true);
|
||||||
return TypeInfoFactoryKt.createTypeInfo(type);
|
return TypeInfoFactoryKt.createTypeInfo(type);
|
||||||
}
|
}
|
||||||
return expressionTypingServices.getTypeInfo(expression, context.replaceContextDependency(INDEPENDENT));
|
return expressionTypingServices.getTypeInfo(expression, context.replaceContextDependency(INDEPENDENT));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public KtType getShapeTypeOfCallableReference(
|
public KotlinType getShapeTypeOfCallableReference(
|
||||||
@NotNull KtCallableReferenceExpression callableReferenceExpression,
|
@NotNull KtCallableReferenceExpression callableReferenceExpression,
|
||||||
@NotNull CallResolutionContext<?> context,
|
@NotNull CallResolutionContext<?> context,
|
||||||
boolean expectedTypeIsUnknown
|
boolean expectedTypeIsUnknown
|
||||||
) {
|
) {
|
||||||
KtType receiverType =
|
KotlinType receiverType =
|
||||||
CallableReferencesResolutionUtilsKt.resolveCallableReferenceReceiverType(callableReferenceExpression, context, typeResolver);
|
CallableReferencesResolutionUtilsKt.resolveCallableReferenceReceiverType(callableReferenceExpression, context, typeResolver);
|
||||||
OverloadResolutionResults<CallableDescriptor> overloadResolutionResults =
|
OverloadResolutionResults<CallableDescriptor> overloadResolutionResults =
|
||||||
CallableReferencesResolutionUtilsKt.resolvePossiblyAmbiguousCallableReference(
|
CallableReferencesResolutionUtilsKt.resolvePossiblyAmbiguousCallableReference(
|
||||||
@@ -262,14 +262,14 @@ public class ArgumentTypeResolver {
|
|||||||
@NotNull ResolveArgumentsMode resolveArgumentsMode
|
@NotNull ResolveArgumentsMode resolveArgumentsMode
|
||||||
) {
|
) {
|
||||||
if (resolveArgumentsMode == SHAPE_FUNCTION_ARGUMENTS) {
|
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 TypeInfoFactoryKt.createTypeInfo(type, context);
|
||||||
}
|
}
|
||||||
return expressionTypingServices.getTypeInfo(expression, context.replaceContextDependency(INDEPENDENT));
|
return expressionTypingServices.getTypeInfo(expression, context.replaceContextDependency(INDEPENDENT));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public KtType getShapeTypeOfFunctionLiteral(
|
public KotlinType getShapeTypeOfFunctionLiteral(
|
||||||
@NotNull KtFunction function,
|
@NotNull KtFunction function,
|
||||||
@NotNull LexicalScope scope,
|
@NotNull LexicalScope scope,
|
||||||
@NotNull BindingTrace trace,
|
@NotNull BindingTrace trace,
|
||||||
@@ -279,19 +279,19 @@ public class ArgumentTypeResolver {
|
|||||||
if (function.getValueParameterList() == null && isFunctionLiteral) {
|
if (function.getValueParameterList() == null && isFunctionLiteral) {
|
||||||
return expectedTypeIsUnknown
|
return expectedTypeIsUnknown
|
||||||
? functionPlaceholders
|
? functionPlaceholders
|
||||||
.createFunctionPlaceholderType(Collections.<KtType>emptyList(), /* hasDeclaredArguments = */ false)
|
.createFunctionPlaceholderType(Collections.<KotlinType>emptyList(), /* hasDeclaredArguments = */ false)
|
||||||
: builtIns.getFunctionType(Annotations.Companion.getEMPTY(), null, Collections.<KtType>emptyList(), DONT_CARE);
|
: builtIns.getFunctionType(Annotations.Companion.getEMPTY(), null, Collections.<KotlinType>emptyList(), DONT_CARE);
|
||||||
}
|
}
|
||||||
List<KtParameter> valueParameters = function.getValueParameters();
|
List<KtParameter> valueParameters = function.getValueParameters();
|
||||||
TemporaryBindingTrace temporaryTrace = TemporaryBindingTrace.create(
|
TemporaryBindingTrace temporaryTrace = TemporaryBindingTrace.create(
|
||||||
trace, "trace to resolve function literal parameter types");
|
trace, "trace to resolve function literal parameter types");
|
||||||
List<KtType> parameterTypes = Lists.newArrayList();
|
List<KotlinType> parameterTypes = Lists.newArrayList();
|
||||||
for (KtParameter parameter : valueParameters) {
|
for (KtParameter parameter : valueParameters) {
|
||||||
parameterTypes.add(resolveTypeRefWithDefault(parameter.getTypeReference(), scope, temporaryTrace, DONT_CARE));
|
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;
|
assert returnType != null;
|
||||||
KtType receiverType = resolveTypeRefWithDefault(function.getReceiverTypeReference(), scope, temporaryTrace, null);
|
KotlinType receiverType = resolveTypeRefWithDefault(function.getReceiverTypeReference(), scope, temporaryTrace, null);
|
||||||
|
|
||||||
return expectedTypeIsUnknown && isFunctionLiteral
|
return expectedTypeIsUnknown && isFunctionLiteral
|
||||||
? functionPlaceholders.createFunctionPlaceholderType(parameterTypes, /* hasDeclaredArguments = */ true)
|
? functionPlaceholders.createFunctionPlaceholderType(parameterTypes, /* hasDeclaredArguments = */ true)
|
||||||
@@ -299,11 +299,11 @@ public class ArgumentTypeResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public KtType resolveTypeRefWithDefault(
|
public KotlinType resolveTypeRefWithDefault(
|
||||||
@Nullable KtTypeReference returnTypeRef,
|
@Nullable KtTypeReference returnTypeRef,
|
||||||
@NotNull LexicalScope scope,
|
@NotNull LexicalScope scope,
|
||||||
@NotNull BindingTrace trace,
|
@NotNull BindingTrace trace,
|
||||||
@Nullable KtType defaultValue
|
@Nullable KotlinType defaultValue
|
||||||
) {
|
) {
|
||||||
if (returnTypeRef != null) {
|
if (returnTypeRef != null) {
|
||||||
return typeResolver.resolveType(scope, returnTypeRef, trace, true);
|
return typeResolver.resolveType(scope, returnTypeRef, trace, true);
|
||||||
@@ -347,15 +347,15 @@ public class ArgumentTypeResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public KtType updateResultArgumentTypeIfNotDenotable(
|
public KotlinType updateResultArgumentTypeIfNotDenotable(
|
||||||
@NotNull ResolutionContext context,
|
@NotNull ResolutionContext context,
|
||||||
@NotNull KtExpression expression
|
@NotNull KtExpression expression
|
||||||
) {
|
) {
|
||||||
KtType type = context.trace.getType(expression);
|
KotlinType type = context.trace.getType(expression);
|
||||||
if (type != null && !type.getConstructor().isDenotable()) {
|
if (type != null && !type.getConstructor().isDenotable()) {
|
||||||
if (type.getConstructor() instanceof IntegerValueTypeConstructor) {
|
if (type.getConstructor() instanceof IntegerValueTypeConstructor) {
|
||||||
IntegerValueTypeConstructor constructor = (IntegerValueTypeConstructor) type.getConstructor();
|
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);
|
constantExpressionEvaluator.updateNumberType(primitiveType, expression, context.statementFilter, context.trace);
|
||||||
return primitiveType;
|
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.calls.tasks.TracingStrategy
|
||||||
import org.jetbrains.kotlin.resolve.validation.SymbolUsageValidator
|
import org.jetbrains.kotlin.resolve.validation.SymbolUsageValidator
|
||||||
import org.jetbrains.kotlin.types.ErrorUtils
|
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.TypeUtils
|
||||||
import org.jetbrains.kotlin.types.expressions.DataFlowAnalyzer
|
import org.jetbrains.kotlin.types.expressions.DataFlowAnalyzer
|
||||||
import java.util.*
|
import java.util.*
|
||||||
@@ -136,7 +136,7 @@ public class CallCompleter(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun <D : CallableDescriptor> MutableResolvedCall<D>.completeConstraintSystem(
|
private fun <D : CallableDescriptor> MutableResolvedCall<D>.completeConstraintSystem(
|
||||||
expectedType: KtType,
|
expectedType: KotlinType,
|
||||||
trace: BindingTrace
|
trace: BindingTrace
|
||||||
) {
|
) {
|
||||||
fun updateSystemIfSuccessful(update: (ConstraintSystemImpl) -> Boolean) {
|
fun updateSystemIfSuccessful(update: (ConstraintSystemImpl) -> Boolean) {
|
||||||
@@ -240,7 +240,7 @@ public class CallCompleter(
|
|||||||
val deparenthesized = KtPsiUtil.getLastElementDeparenthesized(expression, context.statementFilter) ?: return
|
val deparenthesized = KtPsiUtil.getLastElementDeparenthesized(expression, context.statementFilter) ?: return
|
||||||
|
|
||||||
val recordedType = expression.let { context.trace.getType(it) }
|
val recordedType = expression.let { context.trace.getType(it) }
|
||||||
var updatedType: KtType? = recordedType
|
var updatedType: KotlinType? = recordedType
|
||||||
|
|
||||||
val results = completeCallForArgument(deparenthesized, context)
|
val results = completeCallForArgument(deparenthesized, context)
|
||||||
if (results != null && results.isSingleResult()) {
|
if (results != null && results.isSingleResult()) {
|
||||||
@@ -288,11 +288,11 @@ public class CallCompleter(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun updateRecordedTypeForArgument(
|
private fun updateRecordedTypeForArgument(
|
||||||
updatedType: KtType?,
|
updatedType: KotlinType?,
|
||||||
recordedType: KtType?,
|
recordedType: KotlinType?,
|
||||||
argumentExpression: KtExpression,
|
argumentExpression: KtExpression,
|
||||||
trace: BindingTrace
|
trace: BindingTrace
|
||||||
): KtType? {
|
): KotlinType? {
|
||||||
//workaround for KT-8218
|
//workaround for KT-8218
|
||||||
if ((!ErrorUtils.containsErrorType(recordedType) && recordedType == updatedType) || updatedType == null) return updatedType
|
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.scopes.receivers.*;
|
||||||
import org.jetbrains.kotlin.resolve.validation.SymbolUsageValidator;
|
import org.jetbrains.kotlin.resolve.validation.SymbolUsageValidator;
|
||||||
import org.jetbrains.kotlin.types.ErrorUtils;
|
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.TypeUtils;
|
||||||
import org.jetbrains.kotlin.types.expressions.DataFlowAnalyzer;
|
import org.jetbrains.kotlin.types.expressions.DataFlowAnalyzer;
|
||||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingContext;
|
import org.jetbrains.kotlin.types.expressions.ExpressionTypingContext;
|
||||||
@@ -103,7 +103,7 @@ public class CallExpressionResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private KtType getVariableType(
|
private KotlinType getVariableType(
|
||||||
@NotNull KtSimpleNameExpression nameExpression, @NotNull ReceiverValue receiver,
|
@NotNull KtSimpleNameExpression nameExpression, @NotNull ReceiverValue receiver,
|
||||||
@Nullable ASTNode callOperationNode, @NotNull ExpressionTypingContext context, @NotNull boolean[] result
|
@Nullable ASTNode callOperationNode, @NotNull ExpressionTypingContext context, @NotNull boolean[] result
|
||||||
) {
|
) {
|
||||||
@@ -149,7 +149,7 @@ public class CallExpressionResolver {
|
|||||||
|
|
||||||
TemporaryTraceAndCache temporaryForVariable = TemporaryTraceAndCache.create(
|
TemporaryTraceAndCache temporaryForVariable = TemporaryTraceAndCache.create(
|
||||||
context, "trace to resolve as variable", nameExpression);
|
context, "trace to resolve as variable", nameExpression);
|
||||||
KtType type =
|
KotlinType type =
|
||||||
getVariableType(nameExpression, receiver, callOperationNode, context.replaceTraceAndCache(temporaryForVariable), result);
|
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
|
// 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():
|
// 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
|
// Extracting jump out possible and jump point flow info from arguments, if any
|
||||||
List<? extends ValueArgument> arguments = callExpression.getValueArguments();
|
List<? extends ValueArgument> arguments = callExpression.getValueArguments();
|
||||||
DataFlowInfo resultFlowInfo = resolvedCall.getDataFlowInfoForArguments().getResultInfo();
|
DataFlowInfo resultFlowInfo = resolvedCall.getDataFlowInfoForArguments().getResultInfo();
|
||||||
@@ -257,8 +257,8 @@ public class CallExpressionResolver {
|
|||||||
if (calleeExpression instanceof KtSimpleNameExpression && callExpression.getTypeArgumentList() == null) {
|
if (calleeExpression instanceof KtSimpleNameExpression && callExpression.getTypeArgumentList() == null) {
|
||||||
TemporaryTraceAndCache temporaryForVariable = TemporaryTraceAndCache.create(
|
TemporaryTraceAndCache temporaryForVariable = TemporaryTraceAndCache.create(
|
||||||
context, "trace to resolve as variable with 'invoke' call", callExpression);
|
context, "trace to resolve as variable with 'invoke' call", callExpression);
|
||||||
KtType type = getVariableType((KtSimpleNameExpression) calleeExpression, receiver, callOperationNode,
|
KotlinType type = getVariableType((KtSimpleNameExpression) calleeExpression, receiver, callOperationNode,
|
||||||
context.replaceTraceAndCache(temporaryForVariable), result);
|
context.replaceTraceAndCache(temporaryForVariable), result);
|
||||||
Qualifier qualifier = temporaryForVariable.trace.get(BindingContext.QUALIFIER, calleeExpression);
|
Qualifier qualifier = temporaryForVariable.trace.get(BindingContext.QUALIFIER, calleeExpression);
|
||||||
if (result[0] && (qualifier == null || qualifier.getPackageView() == null)) {
|
if (result[0] && (qualifier == null || qualifier.getPackageView() == null)) {
|
||||||
temporaryForVariable.commit();
|
temporaryForVariable.commit();
|
||||||
@@ -350,7 +350,7 @@ public class CallExpressionResolver {
|
|||||||
replaceInsideCallChain(true); // Enter call chain
|
replaceInsideCallChain(true); // Enter call chain
|
||||||
// Visit receiver (x in x.y or x?.z) here. Recursion is possible.
|
// Visit receiver (x in x.y or x?.z) here. Recursion is possible.
|
||||||
JetTypeInfo receiverTypeInfo = expressionTypingServices.getTypeInfo(receiverExpression, contextForReceiver);
|
JetTypeInfo receiverTypeInfo = expressionTypingServices.getTypeInfo(receiverExpression, contextForReceiver);
|
||||||
KtType receiverType = receiverTypeInfo.getType();
|
KotlinType receiverType = receiverTypeInfo.getType();
|
||||||
QualifierReceiver qualifierReceiver = (QualifierReceiver) context.trace.get(BindingContext.QUALIFIER, receiverExpression);
|
QualifierReceiver qualifierReceiver = (QualifierReceiver) context.trace.get(BindingContext.QUALIFIER, receiverExpression);
|
||||||
|
|
||||||
if (receiverType == null) receiverType = ErrorUtils.createErrorType("Type for " + expression.getText());
|
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.
|
// Visit selector (y in x.y) here. Recursion is also possible.
|
||||||
JetTypeInfo selectorReturnTypeInfo = getSelectorReturnTypeInfo(
|
JetTypeInfo selectorReturnTypeInfo = getSelectorReturnTypeInfo(
|
||||||
receiver, expression.getOperationTokenNode(), selectorExpression, context);
|
receiver, expression.getOperationTokenNode(), selectorExpression, context);
|
||||||
KtType selectorReturnType = selectorReturnTypeInfo.getType();
|
KotlinType selectorReturnType = selectorReturnTypeInfo.getType();
|
||||||
|
|
||||||
resolveDeferredReceiverInQualifiedExpression(qualifierReceiver, expression, context);
|
resolveDeferredReceiverInQualifiedExpression(qualifierReceiver, expression, context);
|
||||||
checkNestedClassAccess(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