This commit is contained in:
Andrey Breslav
2011-03-25 16:08:57 +03:00
parent badf79aee5
commit 7debc628b5
8 changed files with 18 additions and 18 deletions
@@ -174,7 +174,7 @@ public class ClassDescriptorResolver {
} else {
if (bodyExpression == null) {
semanticServices.getErrorHandler().genericError(function.getNode(), "This function must either declare a return type or have a body expression");
returnType = ErrorType.createErrorType("No type, no body");
returnType = ErrorUtils.createErrorType("No type, no body");
} else {
// TODO : Recursion possible
returnType = semanticServices.getTypeInferrer(trace).safeGetType(parameterScope, bodyExpression, function.hasBlockBody());
@@ -204,7 +204,7 @@ public class ClassDescriptorResolver {
JetType type;
if (typeReference == null) {
semanticServices.getErrorHandler().genericError(valueParameter.getNode(), "A type annotation is required on a value parameter");
type = ErrorType.createErrorType("Type annotation was missing");
type = ErrorUtils.createErrorType("Type annotation was missing");
} else {
type = typeResolver.resolveType(parameterScope, typeReference);
}
@@ -266,7 +266,7 @@ public class ClassDescriptorResolver {
result.add(typeResolver.resolveType(extensibleScope, typeReference));
}
else {
result.add(ErrorType.createErrorType("No type reference"));
result.add(ErrorUtils.createErrorType("No type reference"));
}
}
return result;
@@ -286,7 +286,7 @@ public class ClassDescriptorResolver {
}
else {
// Error is reported by the parser
type = ErrorType.createErrorType("Annotation is absent");
type = ErrorUtils.createErrorType("Annotation is absent");
}
return type;
}
@@ -311,7 +311,7 @@ public class ClassDescriptorResolver {
JetExpression initializer = property.getInitializer();
if (initializer == null) {
semanticServices.getErrorHandler().genericError(property.getNode(), "This property must either have a type annotation or be initialized");
type = ErrorType.createErrorType("No type, no body");
type = ErrorUtils.createErrorType("No type, no body");
} else {
// TODO : ??? Fix-point here: what if we have something like "val a = foo {a.bar()}"
type = semanticServices.getTypeInferrer(trace).getType(scope, initializer, false);
@@ -116,7 +116,7 @@ public class TypeResolver {
});
}
if (result[0] == null) {
return ErrorType.createErrorType(typeElement == null ? "No type element": typeElement.getText());
return ErrorUtils.createErrorType(typeElement == null ? "No type element" : typeElement.getText());
}
return result[0];
}
@@ -30,7 +30,7 @@ public class JavaTypeTransformer {
public JetType visitClassType(PsiClassType classType) {
PsiClass psiClass = classType.resolveGenerics().getElement();
if (psiClass == null) {
return ErrorType.createErrorType("Unresolved java class: " + classType.getPresentableText());
return ErrorUtils.createErrorType("Unresolved java class: " + classType.getPresentableText());
}
if ("java.lang.Object".equals(psiClass.getQualifiedName())) {
@@ -9,7 +9,7 @@ import java.util.*;
/**
* @author abreslav
*/
public class ErrorType {
public class ErrorUtils {
private static final ModuleDescriptor ERROR_MODULE = new ModuleDescriptor("<ERROR MODULE>");
private static final JetScope ERROR_SCOPE = new JetScope() {
@@ -188,5 +188,5 @@ public class ErrorType {
}
}
private ErrorType() {}
private ErrorUtils() {}
}
@@ -303,7 +303,7 @@ public class JetTypeChecker {
}
public boolean isSubtypeOf(@NotNull JetType subtype, @NotNull JetType supertype) {
if (ErrorType.isErrorType(subtype) || ErrorType.isErrorType(supertype)) {
if (ErrorUtils.isErrorType(subtype) || ErrorUtils.isErrorType(supertype)) {
return true;
}
if (!supertype.isNullable() && subtype.isNullable()) {
@@ -78,7 +78,7 @@ public class JetTypeInferrer {
if (type != null) {
return type;
}
return ErrorType.createErrorType("Type for " + expression.getText());
return ErrorUtils.createErrorType("Type for " + expression.getText());
}
@Nullable
@@ -653,7 +653,7 @@ public class JetTypeInferrer {
}
else {
if (expectedParameterType == null) {
expectedParameterType = ErrorType.createErrorType("Error");
expectedParameterType = ErrorUtils.createErrorType("Error");
}
propertyDescriptor = classDescriptorResolver.resolveValueParameterDescriptor(scope.getContainingDeclaration(), loopParameter, expectedParameterType);
}
@@ -730,7 +730,7 @@ public class JetTypeInferrer {
Collections.<JetTypeProjection>emptyList(),
expression.getArguments(),
expression.getFunctionLiteralArguments());
if (constructorReturnedType == null && !ErrorType.isErrorType(receiverType)) {
if (constructorReturnedType == null && !ErrorUtils.isErrorType(receiverType)) {
trace.recordReferenceResolution(referenceExpression, receiverType.getConstructor().getDeclarationDescriptor());
// TODO : more helpful message
JetArgumentList argumentList = expression.getArgumentList();
@@ -961,7 +961,7 @@ public class JetTypeInferrer {
}
else if (inOperations.contains(operationType)) {
if (right == null) {
result = ErrorType.createErrorType("No right argument"); // TODO
result = ErrorUtils.createErrorType("No right argument"); // TODO
return;
}
String name = "contains";
@@ -1030,7 +1030,7 @@ public class JetTypeInferrer {
private boolean isBoolean(@NotNull JetType type) {
TypeConstructor booleanTypeConstructor = semanticServices.getStandardLibrary().getBoolean().getTypeConstructor();
return type.getConstructor().equals(booleanTypeConstructor) || ErrorType.isErrorType(type);
return type.getConstructor().equals(booleanTypeConstructor) || ErrorUtils.isErrorType(type);
}
@Override
@@ -1064,7 +1064,7 @@ public class JetTypeInferrer {
private JetType getTypeForBinaryCall(JetScope scope, JetExpression left, JetSimpleNameExpression operationSign, @NotNull JetExpression right, String name, boolean reportUnresolved) {
JetType leftType = safeGetType(scope, left, false);
JetType rightType = safeGetType(scope, right, false);
if (ErrorType.isErrorType(leftType)) {
if (ErrorUtils.isErrorType(leftType)) {
return null;
}
FunctionDescriptor functionDescriptor = lookupFunction(scope, operationSign, name, leftType, Collections.singletonList(rightType), reportUnresolved);
@@ -30,7 +30,7 @@ public class TypeSubstitutor {
try {
return unsafeSubstitute(substitutionContext, type, howThisTypeIsUsed);
} catch (SubstitutionException e) {
return ErrorType.createErrorType(e.getMessage());
return ErrorUtils.createErrorType(e.getMessage());
}
}
@@ -450,7 +450,7 @@ public class JetTypeCheckerTest extends LightDaemonAnalyzerTestCase {
Project project = getProject();
JetExpression jetExpression = JetChangeUtil.createExpression(project, expression);
JetType type = semanticServices.getTypeInferrer(BindingTrace.DUMMY).safeGetType(classDefinitions.BASIC_SCOPE, jetExpression, false);
assertTrue("Error type expected but " + type + " returned", ErrorType.isErrorType(type));
assertTrue("Error type expected but " + type + " returned", ErrorUtils.isErrorType(type));
}
private void assertType(String contextType, String expression, String expectedType) {