Delete ErrorUtils.isError(TypeConstructor)

This commit is contained in:
Alexander Udalov
2013-09-18 16:46:07 +04:00
parent dea1e6650f
commit e8b10b3e4d
6 changed files with 20 additions and 38 deletions
@@ -259,7 +259,8 @@ public class TypeDeserializer {
@Override
public boolean isError() {
return ErrorUtils.isError(getConstructor());
ClassifierDescriptor descriptor = getConstructor().getDeclarationDescriptor();
return descriptor != null && ErrorUtils.isError(descriptor);
}
@Override
@@ -264,7 +264,7 @@ public class BodyResolver {
ClassDescriptor classDescriptor = TypeUtils.getClassDescriptor(supertype);
if (classDescriptor == null) return;
if (descriptor.getKind() != ClassKind.TRAIT && !classDescriptor.getConstructors().isEmpty() &&
!ErrorUtils.isError(classDescriptor.getTypeConstructor()) && classDescriptor.getKind() != ClassKind.TRAIT) {
!ErrorUtils.isError(classDescriptor) && classDescriptor.getKind() != ClassKind.TRAIT) {
trace.report(SUPERTYPE_NOT_INITIALIZED.on(specifier));
}
}
@@ -146,7 +146,7 @@ public class TypeResolver {
List<TypeParameterDescriptor> parameters = typeConstructor.getParameters();
int expectedArgumentCount = parameters.size();
int actualArgumentCount = arguments.size();
if (ErrorUtils.isError(typeConstructor)) {
if (ErrorUtils.isError(classDescriptor)) {
result[0] = type(ErrorUtils.createErrorType("[Error type: " + typeConstructor + "]"));
}
else {
@@ -72,9 +72,8 @@ public class CallableDescriptorCollectors {
private static void addConstructors(JetScope scope, Name name, Collection<FunctionDescriptor> functions) {
ClassifierDescriptor classifier = scope.getClassifier(name);
if (classifier instanceof ClassDescriptor && !ErrorUtils.isError(classifier.getTypeConstructor())) {
ClassDescriptor classDescriptor = (ClassDescriptor) classifier;
functions.addAll(classDescriptor.getConstructors());
if (classifier instanceof ClassDescriptor && !ErrorUtils.isError(classifier)) {
functions.addAll(((ClassDescriptor) classifier).getConstructors());
}
}
@@ -255,19 +255,6 @@ public class ErrorUtils {
private static final ErrorClassDescriptor ERROR_CLASS = new ErrorClassDescriptor("");
private static final class ErrorTypeConstructor extends TypeConstructorImpl {
private ErrorTypeConstructor(
@Nullable ClassifierDescriptor classifierDescriptor,
@NotNull List<AnnotationDescriptor> annotations,
boolean sealed,
@NotNull String debugName,
@NotNull List<? extends TypeParameterDescriptor> parameters,
@NotNull Collection<JetType> supertypes
) {
super(classifierDescriptor, annotations, sealed, debugName, parameters, supertypes);
}
}
private static final Set<ConstructorDescriptor> ERROR_CONSTRUCTOR_GROUP = Collections.singleton(createErrorConstructor());
private static final ConstructorDescriptor ERROR_CONSTRUCTOR = new ConstructorDescriptorImpl(ERROR_CLASS, Collections.<AnnotationDescriptor>emptyList(), true);
@@ -343,21 +330,24 @@ public class ErrorUtils {
@NotNull
public static JetType createErrorType(@NotNull String debugMessage) {
return createErrorTypeWithCustomDebugName(createErrorScope(debugMessage), "[ERROR : " + debugMessage + "]");
return new ErrorTypeImpl(createErrorTypeConstructor(debugMessage), createErrorScope(debugMessage));
}
@NotNull
public static JetType createErrorTypeWithCustomDebugName(@NotNull String debugName) {
return createErrorTypeWithCustomDebugName(createErrorScope(debugName), debugName);
return new ErrorTypeImpl(createErrorTypeConstructorWithCustomDebugName(debugName), createErrorScope(debugName));
}
@NotNull
private static JetType createErrorTypeWithCustomDebugName(@NotNull JetScope memberScope, @NotNull String debugName) {
TypeConstructorImpl constructor =
new ErrorTypeConstructor(ERROR_CLASS, Collections.<AnnotationDescriptor>emptyList(), false, debugName,
Collections.<TypeParameterDescriptorImpl>emptyList(),
Collections.singleton(KotlinBuiltIns.getInstance().getAnyType()));
return new ErrorTypeImpl(constructor, memberScope);
public static TypeConstructor createErrorTypeConstructor(@NotNull String debugMessage) {
return createErrorTypeConstructorWithCustomDebugName("[ERROR : " + debugMessage + "]");
}
@NotNull
private static TypeConstructor createErrorTypeConstructorWithCustomDebugName(@NotNull String debugName) {
return new TypeConstructorImpl(ERROR_CLASS, Collections.<AnnotationDescriptor>emptyList(), false, debugName,
Collections.<TypeParameterDescriptorImpl>emptyList(),
Collections.singleton(KotlinBuiltIns.getInstance().getAnyType()));
}
@NotNull
@@ -365,10 +355,6 @@ public class ErrorUtils {
return ERROR_CLASS;
}
public static boolean isError(@NotNull TypeConstructor typeConstructor) {
return typeConstructor == ERROR_CLASS.getTypeConstructor() || typeConstructor instanceof ErrorTypeConstructor;
}
public static boolean containsErrorType(@Nullable JetType type) {
if (type == null) return false;
if (type instanceof NamespaceType) return false;
@@ -359,14 +359,10 @@ public class TypeUtils {
@NotNull
public static JetType makeUnsubstitutedType(ClassDescriptor classDescriptor, JetScope unsubstitutedMemberScope) {
return makeUnsubstitutedType(classDescriptor.getTypeConstructor(), unsubstitutedMemberScope);
}
@NotNull
public static JetType makeUnsubstitutedType(TypeConstructor typeConstructor, JetScope unsubstitutedMemberScope) {
if (ErrorUtils.isError(typeConstructor)) {
return ErrorUtils.createErrorType("Unsubstituted type for " + typeConstructor);
if (ErrorUtils.isError(classDescriptor)) {
return ErrorUtils.createErrorType("Unsubstituted type for " + classDescriptor);
}
TypeConstructor typeConstructor = classDescriptor.getTypeConstructor();
List<TypeProjection> arguments = getDefaultTypeProjections(typeConstructor.getParameters());
return new JetTypeImpl(
Collections.<AnnotationDescriptor>emptyList(),