From e8b10b3e4d67b6b1ad8ce7143880354abb378459 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Wed, 18 Sep 2013 16:46:07 +0400 Subject: [PATCH] Delete ErrorUtils.isError(TypeConstructor) --- .../serialization/TypeDeserializer.java | 3 +- .../jet/lang/resolve/BodyResolver.java | 2 +- .../jet/lang/resolve/TypeResolver.java | 2 +- .../tasks/CallableDescriptorCollectors.java | 5 ++- .../jetbrains/jet/lang/types/ErrorUtils.java | 36 ++++++------------- .../jetbrains/jet/lang/types/TypeUtils.java | 10 ++---- 6 files changed, 20 insertions(+), 38 deletions(-) diff --git a/compiler/frontend/serialization/src/org/jetbrains/jet/descriptors/serialization/TypeDeserializer.java b/compiler/frontend/serialization/src/org/jetbrains/jet/descriptors/serialization/TypeDeserializer.java index 4dd8e04dc90..f538c20c48d 100644 --- a/compiler/frontend/serialization/src/org/jetbrains/jet/descriptors/serialization/TypeDeserializer.java +++ b/compiler/frontend/serialization/src/org/jetbrains/jet/descriptors/serialization/TypeDeserializer.java @@ -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 diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BodyResolver.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BodyResolver.java index 7cca5d9219d..6541148a2fa 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BodyResolver.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BodyResolver.java @@ -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)); } } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/TypeResolver.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/TypeResolver.java index 70733620826..35ec03ab50e 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/TypeResolver.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/TypeResolver.java @@ -146,7 +146,7 @@ public class TypeResolver { List 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 { diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/tasks/CallableDescriptorCollectors.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/tasks/CallableDescriptorCollectors.java index ef5ab5513be..32aad6db26e 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/tasks/CallableDescriptorCollectors.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/tasks/CallableDescriptorCollectors.java @@ -72,9 +72,8 @@ public class CallableDescriptorCollectors { private static void addConstructors(JetScope scope, Name name, Collection 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()); } } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/ErrorUtils.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/ErrorUtils.java index e1915513038..c9904c0ba25 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/ErrorUtils.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/ErrorUtils.java @@ -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 annotations, - boolean sealed, - @NotNull String debugName, - @NotNull List parameters, - @NotNull Collection supertypes - ) { - super(classifierDescriptor, annotations, sealed, debugName, parameters, supertypes); - } - } - private static final Set ERROR_CONSTRUCTOR_GROUP = Collections.singleton(createErrorConstructor()); private static final ConstructorDescriptor ERROR_CONSTRUCTOR = new ConstructorDescriptorImpl(ERROR_CLASS, Collections.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.emptyList(), false, debugName, - Collections.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.emptyList(), false, debugName, + Collections.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; diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/TypeUtils.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/TypeUtils.java index b508ec2db26..249e09ae5fb 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/TypeUtils.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/TypeUtils.java @@ -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 arguments = getDefaultTypeProjections(typeConstructor.getParameters()); return new JetTypeImpl( Collections.emptyList(),