Replace some usages of ERROR_CLASS with new instance creation
Because when some class is unresolved, we can still hold some information such as its FQ name, for debugging purposes and better error messages
This commit is contained in:
+2
-2
@@ -37,7 +37,7 @@ import org.jetbrains.jet.lang.resolve.java.resolver.DescriptorResolverUtils;
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.ErrorReporter;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.DependencyClassByQualifiedNameResolver;
|
||||
import org.jetbrains.jet.lang.types.ErrorUtils;
|
||||
import org.jetbrains.jet.lang.types.error.ErrorClassDescriptor;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.io.IOException;
|
||||
@@ -177,7 +177,7 @@ public class AnnotationDescriptorDeserializer extends BaseDescriptorDeserializer
|
||||
@NotNull
|
||||
private static ClassDescriptor resolveClass(@NotNull JvmClassName className, DependencyClassByQualifiedNameResolver classResolver) {
|
||||
ClassDescriptor annotationClass = classResolver.resolveClass(className.getFqNameForClassNameWithoutDollars());
|
||||
return annotationClass != null ? annotationClass : ErrorUtils.getErrorClass();
|
||||
return annotationClass != null ? annotationClass : new ErrorClassDescriptor(className.getInternalName());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -83,7 +83,7 @@ public class ErrorUtils {
|
||||
|
||||
@Override
|
||||
public ClassifierDescriptor getClassifier(@NotNull Name name) {
|
||||
return ERROR_CLASS;
|
||||
return new ErrorClassDescriptor(name.asString());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -269,7 +269,7 @@ public class ErrorUtils {
|
||||
|
||||
@NotNull
|
||||
private static SimpleFunctionDescriptor createErrorFunction(@NotNull ErrorScope ownerScope) {
|
||||
ErrorSimpleFunctionDescriptorImpl function = new ErrorSimpleFunctionDescriptorImpl(ownerScope);
|
||||
ErrorSimpleFunctionDescriptorImpl function = new ErrorSimpleFunctionDescriptorImpl(ERROR_CLASS, ownerScope);
|
||||
function.initialize(
|
||||
null,
|
||||
ReceiverParameterDescriptor.NO_RECEIVER_PARAMETER,
|
||||
@@ -304,11 +304,6 @@ public class ErrorUtils {
|
||||
Collections.singleton(KotlinBuiltIns.getInstance().getAnyType()));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static ClassDescriptor getErrorClass() {
|
||||
return ERROR_CLASS;
|
||||
}
|
||||
|
||||
public static boolean containsErrorType(@Nullable JetType type) {
|
||||
if (type == null) return false;
|
||||
if (type instanceof PackageType) return false;
|
||||
|
||||
@@ -43,7 +43,7 @@ public class ErrorClassDescriptor extends ClassDescriptorImpl {
|
||||
Visibilities.INTERNAL, false);
|
||||
errorConstructor.setReturnType(createErrorType("<ERROR RETURN TYPE>"));
|
||||
|
||||
initialize(createErrorScope("ERROR_CLASS"), Collections.<ConstructorDescriptor>singleton(errorConstructor), errorConstructor);
|
||||
initialize(createErrorScope(getName().asString()), Collections.<ConstructorDescriptor>singleton(errorConstructor), errorConstructor);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+3
-3
@@ -27,11 +27,11 @@ import org.jetbrains.jet.lang.types.ErrorUtils;
|
||||
|
||||
public class ErrorSimpleFunctionDescriptorImpl extends SimpleFunctionDescriptorImpl {
|
||||
// used for diagnostic only
|
||||
@NotNull
|
||||
@SuppressWarnings({"UnusedDeclaration", "FieldCanBeLocal"})
|
||||
private final ErrorUtils.ErrorScope ownerScope;
|
||||
|
||||
public ErrorSimpleFunctionDescriptorImpl(ErrorUtils.ErrorScope ownerScope) {
|
||||
super(ErrorUtils.getErrorClass(), null, Annotations.EMPTY, Name.special("<ERROR FUNCTION>"), Kind.DECLARATION);
|
||||
public ErrorSimpleFunctionDescriptorImpl(@NotNull ClassDescriptor containingDeclaration, @NotNull ErrorUtils.ErrorScope ownerScope) {
|
||||
super(containingDeclaration, null, Annotations.EMPTY, Name.special("<ERROR FUNCTION>"), Kind.DECLARATION);
|
||||
this.ownerScope = ownerScope;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user