Fix instanceof checks after introducing the TypeParameterDescriptor interface
This commit is contained in:
@@ -1093,7 +1093,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (descriptor instanceof TypeParameterDescriptorImpl) {
|
if (descriptor instanceof TypeParameterDescriptor) {
|
||||||
TypeParameterDescriptor typeParameterDescriptor = (TypeParameterDescriptor) descriptor;
|
TypeParameterDescriptor typeParameterDescriptor = (TypeParameterDescriptor) descriptor;
|
||||||
v.invokevirtual("jet/TypeInfo", "getClassObject", "()Ljava/lang/Object;");
|
v.invokevirtual("jet/TypeInfo", "getClassObject", "()Ljava/lang/Object;");
|
||||||
v.checkcast(asmType(typeParameterDescriptor.getClassObjectType()));
|
v.checkcast(asmType(typeParameterDescriptor.getClassObjectType()));
|
||||||
@@ -2614,7 +2614,7 @@ If finally block is present, its last expression is the value of try expression.
|
|||||||
JetExpression left = expression.getLeft();
|
JetExpression left = expression.getLeft();
|
||||||
JetType leftType = bindingContext.get(BindingContext.EXPRESSION_TYPE, left);
|
JetType leftType = bindingContext.get(BindingContext.EXPRESSION_TYPE, left);
|
||||||
DeclarationDescriptor descriptor = rightType.getConstructor().getDeclarationDescriptor();
|
DeclarationDescriptor descriptor = rightType.getConstructor().getDeclarationDescriptor();
|
||||||
if (descriptor instanceof ClassDescriptor || descriptor instanceof TypeParameterDescriptorImpl) {
|
if (descriptor instanceof ClassDescriptor || descriptor instanceof TypeParameterDescriptor) {
|
||||||
StackValue value = genQualified(receiver, left);
|
StackValue value = genQualified(receiver, left);
|
||||||
value.put(JetTypeMapper.boxType(value.type), v);
|
value.put(JetTypeMapper.boxType(value.type), v);
|
||||||
assert leftType != null;
|
assert leftType != null;
|
||||||
|
|||||||
@@ -463,7 +463,7 @@ public class JetTypeMapper {
|
|||||||
return asmType;
|
return asmType;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (descriptor instanceof TypeParameterDescriptorImpl) {
|
if (descriptor instanceof TypeParameterDescriptor) {
|
||||||
|
|
||||||
Type type = mapType(((TypeParameterDescriptor) descriptor).getUpperBoundsAsType(), kind);
|
Type type = mapType(((TypeParameterDescriptor) descriptor).getUpperBoundsAsType(), kind);
|
||||||
if (signatureVisitor != null) {
|
if (signatureVisitor != null) {
|
||||||
@@ -722,7 +722,7 @@ public class JetTypeMapper {
|
|||||||
signatureVisitor.writeInterfaceBoundEnd();
|
signatureVisitor.writeInterfaceBoundEnd();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (jetType.getConstructor().getDeclarationDescriptor() instanceof TypeParameterDescriptorImpl) {
|
if (jetType.getConstructor().getDeclarationDescriptor() instanceof TypeParameterDescriptor) {
|
||||||
signatureVisitor.writeInterfaceBound();
|
signatureVisitor.writeInterfaceBound();
|
||||||
mapType(jetType, signatureVisitor, MapTypeMode.TYPE_PARAMETER);
|
mapType(jetType, signatureVisitor, MapTypeMode.TYPE_PARAMETER);
|
||||||
signatureVisitor.writeInterfaceBoundEnd();
|
signatureVisitor.writeInterfaceBoundEnd();
|
||||||
@@ -988,7 +988,7 @@ public class JetTypeMapper {
|
|||||||
|
|
||||||
public boolean isGenericsArray(JetType type) {
|
public boolean isGenericsArray(JetType type) {
|
||||||
DeclarationDescriptor declarationDescriptor = type.getConstructor().getDeclarationDescriptor();
|
DeclarationDescriptor declarationDescriptor = type.getConstructor().getDeclarationDescriptor();
|
||||||
if(declarationDescriptor instanceof TypeParameterDescriptorImpl)
|
if(declarationDescriptor instanceof TypeParameterDescriptor)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if(standardLibrary.getArray().equals(declarationDescriptor))
|
if(standardLibrary.getArray().equals(declarationDescriptor))
|
||||||
|
|||||||
@@ -236,7 +236,7 @@ public class DescriptorUtils {
|
|||||||
ClassDescriptor clazz = (ClassDescriptor) classifier;
|
ClassDescriptor clazz = (ClassDescriptor) classifier;
|
||||||
return clazz.getKind() == ClassKind.OBJECT || clazz.getKind() == ClassKind.ENUM_ENTRY;
|
return clazz.getKind() == ClassKind.OBJECT || clazz.getKind() == ClassKind.ENUM_ENTRY;
|
||||||
}
|
}
|
||||||
else if (classifier instanceof TypeParameterDescriptorImpl) {
|
else if (classifier instanceof TypeParameterDescriptor) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -212,7 +212,7 @@ public class OverridingUtil {
|
|||||||
if (type.getConstructor().getDeclarationDescriptor() instanceof ClassDescriptor) {
|
if (type.getConstructor().getDeclarationDescriptor() instanceof ClassDescriptor) {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
else if (type.getConstructor().getDeclarationDescriptor() instanceof TypeParameterDescriptorImpl) {
|
else if (type.getConstructor().getDeclarationDescriptor() instanceof TypeParameterDescriptor) {
|
||||||
return ((TypeParameterDescriptor) type.getConstructor().getDeclarationDescriptor()).getUpperBoundsAsType();
|
return ((TypeParameterDescriptor) type.getConstructor().getDeclarationDescriptor()).getUpperBoundsAsType();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -18,14 +18,16 @@ package org.jetbrains.jet.lang.resolve;
|
|||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.lang.descriptors.*;
|
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||||
|
import org.jetbrains.jet.lang.descriptors.ClassifierDescriptor;
|
||||||
|
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||||
|
import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||||
import org.jetbrains.jet.lang.psi.*;
|
import org.jetbrains.jet.lang.psi.*;
|
||||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||||
import org.jetbrains.jet.lang.resolve.scopes.LazyScopeAdapter;
|
import org.jetbrains.jet.lang.resolve.scopes.LazyScopeAdapter;
|
||||||
import org.jetbrains.jet.lang.types.*;
|
import org.jetbrains.jet.lang.types.*;
|
||||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||||
import org.jetbrains.jet.lang.types.ref.JetTypeName;
|
|
||||||
import org.jetbrains.jet.util.lazy.LazyValue;
|
import org.jetbrains.jet.util.lazy.LazyValue;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
@@ -34,7 +36,8 @@ import java.util.Collection;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static org.jetbrains.jet.lang.diagnostics.Errors.*;
|
import static org.jetbrains.jet.lang.diagnostics.Errors.UNSUPPORTED;
|
||||||
|
import static org.jetbrains.jet.lang.diagnostics.Errors.WRONG_NUMBER_OF_TYPE_ARGUMENTS;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author abreslav
|
* @author abreslav
|
||||||
@@ -96,7 +99,7 @@ public class TypeResolver {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (classifierDescriptor instanceof TypeParameterDescriptorImpl) {
|
if (classifierDescriptor instanceof TypeParameterDescriptor) {
|
||||||
TypeParameterDescriptor typeParameterDescriptor = (TypeParameterDescriptor) classifierDescriptor;
|
TypeParameterDescriptor typeParameterDescriptor = (TypeParameterDescriptor) classifierDescriptor;
|
||||||
|
|
||||||
trace.record(BindingContext.REFERENCE_TARGET, referenceExpression, typeParameterDescriptor);
|
trace.record(BindingContext.REFERENCE_TARGET, referenceExpression, typeParameterDescriptor);
|
||||||
|
|||||||
+2
-3
@@ -21,7 +21,6 @@ import com.google.common.collect.Sets;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor;
|
import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptorImpl;
|
|
||||||
import org.jetbrains.jet.lang.types.*;
|
import org.jetbrains.jet.lang.types.*;
|
||||||
import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
|
import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
|
||||||
import org.jetbrains.jet.lang.types.checker.TypeCheckingProcedure;
|
import org.jetbrains.jet.lang.types.checker.TypeCheckingProcedure;
|
||||||
@@ -89,7 +88,7 @@ public class ConstraintSystemWithPriorities implements ConstraintSystem {
|
|||||||
@NotNull
|
@NotNull
|
||||||
private TypeValue getTypeValueFor(@NotNull JetType type) {
|
private TypeValue getTypeValueFor(@NotNull JetType type) {
|
||||||
DeclarationDescriptor declarationDescriptor = type.getConstructor().getDeclarationDescriptor();
|
DeclarationDescriptor declarationDescriptor = type.getConstructor().getDeclarationDescriptor();
|
||||||
if (declarationDescriptor instanceof TypeParameterDescriptorImpl) {
|
if (declarationDescriptor instanceof TypeParameterDescriptor) {
|
||||||
TypeParameterDescriptor typeParameterDescriptor = (TypeParameterDescriptor) declarationDescriptor;
|
TypeParameterDescriptor typeParameterDescriptor = (TypeParameterDescriptor) declarationDescriptor;
|
||||||
// Checking that this is not a T?, but exactly T
|
// Checking that this is not a T?, but exactly T
|
||||||
if (typeParameterDescriptor.getDefaultType().isNullable() == type.isNullable()) {
|
if (typeParameterDescriptor.getDefaultType().isNullable() == type.isNullable()) {
|
||||||
@@ -489,7 +488,7 @@ public class ConstraintSystemWithPriorities implements ConstraintSystem {
|
|||||||
@Override
|
@Override
|
||||||
public TypeProjection get(TypeConstructor key) {
|
public TypeProjection get(TypeConstructor key) {
|
||||||
DeclarationDescriptor declarationDescriptor = key.getDeclarationDescriptor();
|
DeclarationDescriptor declarationDescriptor = key.getDeclarationDescriptor();
|
||||||
if (declarationDescriptor instanceof TypeParameterDescriptorImpl) {
|
if (declarationDescriptor instanceof TypeParameterDescriptor) {
|
||||||
TypeParameterDescriptor descriptor = (TypeParameterDescriptor) declarationDescriptor;
|
TypeParameterDescriptor descriptor = (TypeParameterDescriptor) declarationDescriptor;
|
||||||
|
|
||||||
if (!unknownTypes.containsKey(descriptor)) return null;
|
if (!unknownTypes.containsKey(descriptor)) return null;
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import com.google.common.collect.Multimap;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor;
|
import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptorImpl;
|
|
||||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||||
import org.jetbrains.jet.util.CommonSuppliers;
|
import org.jetbrains.jet.util.CommonSuppliers;
|
||||||
|
|
||||||
@@ -112,7 +111,7 @@ public class SubstitutionUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hasUnsubstitutedTypeParameters(JetType type) {
|
public static boolean hasUnsubstitutedTypeParameters(JetType type) {
|
||||||
if (type.getConstructor().getDeclarationDescriptor() instanceof TypeParameterDescriptorImpl) {
|
if (type.getConstructor().getDeclarationDescriptor() instanceof TypeParameterDescriptor) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -219,7 +219,7 @@ public class TypeUtils {
|
|||||||
|
|
||||||
private static void processAllTypeParameters(JetType type, Variance howThiTypeIsUsed, Processor<TypeParameterUsage> result) {
|
private static void processAllTypeParameters(JetType type, Variance howThiTypeIsUsed, Processor<TypeParameterUsage> result) {
|
||||||
ClassifierDescriptor descriptor = type.getConstructor().getDeclarationDescriptor();
|
ClassifierDescriptor descriptor = type.getConstructor().getDeclarationDescriptor();
|
||||||
if (descriptor instanceof TypeParameterDescriptorImpl) {
|
if (descriptor instanceof TypeParameterDescriptor) {
|
||||||
result.process(new TypeParameterUsage((TypeParameterDescriptor)descriptor, howThiTypeIsUsed));
|
result.process(new TypeParameterUsage((TypeParameterDescriptor)descriptor, howThiTypeIsUsed));
|
||||||
}
|
}
|
||||||
for (TypeProjection projection : type.getArguments()) {
|
for (TypeProjection projection : type.getArguments()) {
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ public class DescriptorRenderer implements Renderer<DeclarationDescriptor> {
|
|||||||
|
|
||||||
Object typeNameObject;
|
Object typeNameObject;
|
||||||
|
|
||||||
if (cd == null || cd instanceof TypeParameterDescriptorImpl) {
|
if (cd == null || cd instanceof TypeParameterDescriptor) {
|
||||||
typeNameObject = type.getConstructor();
|
typeNameObject = type.getConstructor();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ public final class JetDescriptorIconProvider {
|
|||||||
return ((VariableDescriptor) descriptor).isVar() ? JetIcons.FIELD_VAR : JetIcons.FIELD_VAL;
|
return ((VariableDescriptor) descriptor).isVar() ? JetIcons.FIELD_VAR : JetIcons.FIELD_VAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (descriptor instanceof TypeParameterDescriptorImpl) {
|
if (descriptor instanceof TypeParameterDescriptor) {
|
||||||
return PlatformIcons.CLASS_ICON;
|
return PlatformIcons.CLASS_ICON;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ public class JetCompletionContributor extends CompletionContributor {
|
|||||||
DeclarationDescriptor descriptor = ((JetLookupObject)object).getDescriptor();
|
DeclarationDescriptor descriptor = ((JetLookupObject)object).getDescriptor();
|
||||||
return (descriptor instanceof ClassDescriptor) ||
|
return (descriptor instanceof ClassDescriptor) ||
|
||||||
(descriptor instanceof NamespaceDescriptor) ||
|
(descriptor instanceof NamespaceDescriptor) ||
|
||||||
(descriptor instanceof TypeParameterDescriptorImpl);
|
(descriptor instanceof TypeParameterDescriptor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user