提交 37bc1068 编写于 作者: A Andrey Breslav

Fix instanceof checks after introducing the TypeParameterDescriptor interface

上级 ebb0d25b
......@@ -1093,7 +1093,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
}
}
if (descriptor instanceof TypeParameterDescriptorImpl) {
if (descriptor instanceof TypeParameterDescriptor) {
TypeParameterDescriptor typeParameterDescriptor = (TypeParameterDescriptor) descriptor;
v.invokevirtual("jet/TypeInfo", "getClassObject", "()Ljava/lang/Object;");
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();
JetType leftType = bindingContext.get(BindingContext.EXPRESSION_TYPE, left);
DeclarationDescriptor descriptor = rightType.getConstructor().getDeclarationDescriptor();
if (descriptor instanceof ClassDescriptor || descriptor instanceof TypeParameterDescriptorImpl) {
if (descriptor instanceof ClassDescriptor || descriptor instanceof TypeParameterDescriptor) {
StackValue value = genQualified(receiver, left);
value.put(JetTypeMapper.boxType(value.type), v);
assert leftType != null;
......
......@@ -463,7 +463,7 @@ public class JetTypeMapper {
return asmType;
}
if (descriptor instanceof TypeParameterDescriptorImpl) {
if (descriptor instanceof TypeParameterDescriptor) {
Type type = mapType(((TypeParameterDescriptor) descriptor).getUpperBoundsAsType(), kind);
if (signatureVisitor != null) {
......@@ -722,7 +722,7 @@ public class JetTypeMapper {
signatureVisitor.writeInterfaceBoundEnd();
}
}
if (jetType.getConstructor().getDeclarationDescriptor() instanceof TypeParameterDescriptorImpl) {
if (jetType.getConstructor().getDeclarationDescriptor() instanceof TypeParameterDescriptor) {
signatureVisitor.writeInterfaceBound();
mapType(jetType, signatureVisitor, MapTypeMode.TYPE_PARAMETER);
signatureVisitor.writeInterfaceBoundEnd();
......@@ -988,7 +988,7 @@ public class JetTypeMapper {
public boolean isGenericsArray(JetType type) {
DeclarationDescriptor declarationDescriptor = type.getConstructor().getDeclarationDescriptor();
if(declarationDescriptor instanceof TypeParameterDescriptorImpl)
if(declarationDescriptor instanceof TypeParameterDescriptor)
return true;
if(standardLibrary.getArray().equals(declarationDescriptor))
......
......@@ -236,7 +236,7 @@ public class DescriptorUtils {
ClassDescriptor clazz = (ClassDescriptor) classifier;
return clazz.getKind() == ClassKind.OBJECT || clazz.getKind() == ClassKind.ENUM_ENTRY;
}
else if (classifier instanceof TypeParameterDescriptorImpl) {
else if (classifier instanceof TypeParameterDescriptor) {
return false;
}
else {
......
......@@ -212,7 +212,7 @@ public class OverridingUtil {
if (type.getConstructor().getDeclarationDescriptor() instanceof ClassDescriptor) {
return type;
}
else if (type.getConstructor().getDeclarationDescriptor() instanceof TypeParameterDescriptorImpl) {
else if (type.getConstructor().getDeclarationDescriptor() instanceof TypeParameterDescriptor) {
return ((TypeParameterDescriptor) type.getConstructor().getDeclarationDescriptor()).getUpperBoundsAsType();
}
else {
......
......@@ -18,14 +18,16 @@ package org.jetbrains.jet.lang.resolve;
import org.jetbrains.annotations.NotNull;
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.psi.*;
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
import org.jetbrains.jet.lang.resolve.scopes.LazyScopeAdapter;
import org.jetbrains.jet.lang.types.*;
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
import org.jetbrains.jet.lang.types.ref.JetTypeName;
import org.jetbrains.jet.util.lazy.LazyValue;
import javax.inject.Inject;
......@@ -34,7 +36,8 @@ import java.util.Collection;
import java.util.Collections;
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
......@@ -96,7 +99,7 @@ public class TypeResolver {
return;
}
if (classifierDescriptor instanceof TypeParameterDescriptorImpl) {
if (classifierDescriptor instanceof TypeParameterDescriptor) {
TypeParameterDescriptor typeParameterDescriptor = (TypeParameterDescriptor) classifierDescriptor;
trace.record(BindingContext.REFERENCE_TARGET, referenceExpression, typeParameterDescriptor);
......
......@@ -21,7 +21,6 @@ import com.google.common.collect.Sets;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
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.checker.JetTypeChecker;
import org.jetbrains.jet.lang.types.checker.TypeCheckingProcedure;
......@@ -89,7 +88,7 @@ public class ConstraintSystemWithPriorities implements ConstraintSystem {
@NotNull
private TypeValue getTypeValueFor(@NotNull JetType type) {
DeclarationDescriptor declarationDescriptor = type.getConstructor().getDeclarationDescriptor();
if (declarationDescriptor instanceof TypeParameterDescriptorImpl) {
if (declarationDescriptor instanceof TypeParameterDescriptor) {
TypeParameterDescriptor typeParameterDescriptor = (TypeParameterDescriptor) declarationDescriptor;
// Checking that this is not a T?, but exactly T
if (typeParameterDescriptor.getDefaultType().isNullable() == type.isNullable()) {
......@@ -489,7 +488,7 @@ public class ConstraintSystemWithPriorities implements ConstraintSystem {
@Override
public TypeProjection get(TypeConstructor key) {
DeclarationDescriptor declarationDescriptor = key.getDeclarationDescriptor();
if (declarationDescriptor instanceof TypeParameterDescriptorImpl) {
if (declarationDescriptor instanceof TypeParameterDescriptor) {
TypeParameterDescriptor descriptor = (TypeParameterDescriptor) declarationDescriptor;
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.Nullable;
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.util.CommonSuppliers;
......@@ -112,7 +111,7 @@ public class SubstitutionUtils {
}
public static boolean hasUnsubstitutedTypeParameters(JetType type) {
if (type.getConstructor().getDeclarationDescriptor() instanceof TypeParameterDescriptorImpl) {
if (type.getConstructor().getDeclarationDescriptor() instanceof TypeParameterDescriptor) {
return true;
}
......
......@@ -219,7 +219,7 @@ public class TypeUtils {
private static void processAllTypeParameters(JetType type, Variance howThiTypeIsUsed, Processor<TypeParameterUsage> result) {
ClassifierDescriptor descriptor = type.getConstructor().getDeclarationDescriptor();
if (descriptor instanceof TypeParameterDescriptorImpl) {
if (descriptor instanceof TypeParameterDescriptor) {
result.process(new TypeParameterUsage((TypeParameterDescriptor)descriptor, howThiTypeIsUsed));
}
for (TypeProjection projection : type.getArguments()) {
......
......@@ -146,7 +146,7 @@ public class DescriptorRenderer implements Renderer<DeclarationDescriptor> {
Object typeNameObject;
if (cd == null || cd instanceof TypeParameterDescriptorImpl) {
if (cd == null || cd instanceof TypeParameterDescriptor) {
typeNameObject = type.getConstructor();
}
else {
......
......@@ -115,7 +115,7 @@ public final class JetDescriptorIconProvider {
return ((VariableDescriptor) descriptor).isVar() ? JetIcons.FIELD_VAR : JetIcons.FIELD_VAL;
}
if (descriptor instanceof TypeParameterDescriptorImpl) {
if (descriptor instanceof TypeParameterDescriptor) {
return PlatformIcons.CLASS_ICON;
}
......
......@@ -185,7 +185,7 @@ public class JetCompletionContributor extends CompletionContributor {
DeclarationDescriptor descriptor = ((JetLookupObject)object).getDescriptor();
return (descriptor instanceof ClassDescriptor) ||
(descriptor instanceof NamespaceDescriptor) ||
(descriptor instanceof TypeParameterDescriptorImpl);
(descriptor instanceof TypeParameterDescriptor);
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册