diff --git a/core/descriptors/src/org/jetbrains/jet/lang/types/ErrorUtils.java b/core/descriptors/src/org/jetbrains/jet/lang/types/ErrorUtils.java index f70b09625b2..eeb0b6d913c 100644 --- a/core/descriptors/src/org/jetbrains/jet/lang/types/ErrorUtils.java +++ b/core/descriptors/src/org/jetbrains/jet/lang/types/ErrorUtils.java @@ -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 getParameters() { + return errorTypeConstructor.getParameters(); + } + + @NotNull + @Override + public Collection 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() {} diff --git a/core/descriptors/src/org/jetbrains/jet/renderer/DescriptorRendererImpl.java b/core/descriptors/src/org/jetbrains/jet/renderer/DescriptorRendererImpl.java index 5d52d875f14..976ba88c90a 100644 --- a/core/descriptors/src/org/jetbrains/jet/renderer/DescriptorRendererImpl.java +++ b/core/descriptors/src/org/jetbrains/jet/renderer/DescriptorRendererImpl.java @@ -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 "???"; }