Replaced UninferredParameterType with error type

and UninferredParameterTypeConstructor
This commit is contained in:
Svetlana Isakova
2014-08-29 16:01:16 +04:00
parent 17c3eeb7bd
commit b794b827f9
2 changed files with 46 additions and 11 deletions
@@ -433,7 +433,7 @@ public class ErrorUtils {
}
public static boolean isUninferredParameter(@Nullable JetType type) {
return type instanceof UninferredParameterType;
return type != null && type.getConstructor() instanceof UninferredParameterTypeConstructor;
}
public static boolean containsUninferredParameter(@Nullable JetType type) {
@@ -445,25 +445,60 @@ public class ErrorUtils {
});
}
public static UninferredParameterType createUninferredParameterType(@NotNull TypeParameterDescriptor typeParameterDescriptor) {
return new UninferredParameterType(typeParameterDescriptor);
@NotNull
public static JetType createUninferredParameterType(@NotNull TypeParameterDescriptor typeParameterDescriptor) {
return new ErrorTypeImpl(
new UninferredParameterTypeConstructor(typeParameterDescriptor),
createErrorScope("Scope for error type for not inferred parameter: " + typeParameterDescriptor.getName()));
}
public static class UninferredParameterType extends ErrorTypeImpl {
public static class UninferredParameterTypeConstructor implements TypeConstructor {
private final TypeParameterDescriptor typeParameterDescriptor;
private final TypeConstructor errorTypeConstructor;
private UninferredParameterType(
@NotNull TypeParameterDescriptor descriptor
) {
super(createErrorTypeConstructorWithCustomDebugName("CANT_INFER_TYPE_PARAMETER: " + descriptor.getName()),
createErrorScope("Scope for error type for not inferred parameter: " + descriptor.getName()));
public UninferredParameterTypeConstructor(@NotNull TypeParameterDescriptor descriptor) {
typeParameterDescriptor = descriptor;
errorTypeConstructor = createErrorTypeConstructorWithCustomDebugName("CANT_INFER_TYPE_PARAMETER: " + descriptor.getName());
}
@NotNull
public TypeParameterDescriptor getTypeParameterDescriptor() {
return typeParameterDescriptor;
}
@NotNull
@Override
public List<TypeParameterDescriptor> getParameters() {
return errorTypeConstructor.getParameters();
}
@NotNull
@Override
public Collection<JetType> getSupertypes() {
return errorTypeConstructor.getSupertypes();
}
@Override
public boolean isFinal() {
return errorTypeConstructor.isFinal();
}
@Override
public boolean isDenotable() {
return errorTypeConstructor.isDenotable();
}
@Nullable
@Override
public ClassifierDescriptor getDeclarationDescriptor() {
return errorTypeConstructor.getDeclarationDescriptor();
}
@NotNull
@Override
public Annotations getAnnotations() {
return errorTypeConstructor.getAnnotations();
}
}
private ErrorUtils() {}
@@ -34,13 +34,13 @@ import org.jetbrains.jet.lang.resolve.name.FqNameBase;
import org.jetbrains.jet.lang.resolve.name.FqNameUnsafe;
import org.jetbrains.jet.lang.resolve.name.Name;
import org.jetbrains.jet.lang.types.*;
import org.jetbrains.jet.lang.types.ErrorUtils.UninferredParameterTypeConstructor;
import org.jetbrains.jet.lang.types.error.MissingDependencyErrorClass;
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
import org.jetbrains.jet.utils.UtilsPackage;
import java.util.*;
import static org.jetbrains.jet.lang.types.ErrorUtils.UninferredParameterType;
import static org.jetbrains.jet.lang.types.TypeUtils.CANT_INFER_LAMBDA_PARAM_TYPE;
import static org.jetbrains.jet.lang.types.TypeUtils.DONT_CARE;
@@ -282,7 +282,7 @@ public class DescriptorRendererImpl implements DescriptorRenderer {
}
if (ErrorUtils.isUninferredParameter(type)) {
if (uninferredTypeParameterAsName) {
return renderError(((UninferredParameterType) type).getTypeParameterDescriptor().getName().toString());
return renderError(((UninferredParameterTypeConstructor) type.getConstructor()).getTypeParameterDescriptor().getName().toString());
}
return "???";
}