} else if (isTypeNameInAsExpression(node)) {
reportErrorForNode(StaticWarningCode.CAST_TO_NON_TYPE, typeName, typeName.getName());
} else if (isTypeNameInIsExpression(node)) {
reportErrorForNode(StaticWarningCode.TYPE_TEST_NON_TYPE, typeName, typeName.getName());
} else if ((redirectingConstructorKind = getRedirectingConstructorKind(node)) != null) {
ErrorCode errorCode = redirectingConstructorKind == RedirectingConstructorKind.CONST
? CompileTimeErrorCode.REDIRECT_TO_NON_CLASS : StaticWarningCode.REDIRECT_TO_NON_CLASS;
reportErrorForNode(errorCode, typeName, typeName.getName());
} else if (isTypeNameInTypeArgumentList(node)) {
reportErrorForNode(
StaticTypeWarningCode.NON_TYPE_AS_TYPE_ARGUMENT,
typeName,
typeName.getName());
} else {
reportErrorForNode(StaticWarningCode.UNDEFINED_CLASS, typeName, typeName.getName());
}
elementValid = false;
}
if (!elementValid) {
if (element instanceof MultiplyDefinedElement) {
setElement(typeName, element);
} else {
setElement(typeName, dynamicType.getElement());
}
typeName.setStaticType(dynamicType);
node.setType(dynamicType);
return null;
}
Type type = null;
if (element instanceof ClassElement) {
setElement(typeName, element);
type = ((ClassElement) element).getType();
} else if (element instanceof FunctionTypeAliasElement) {
setElement(typeName, element);
type = ((FunctionTypeAliasElement) element).getType();
} else if (element instanceof TypeParameterElement) {
setElement(typeName, element);
type = ((TypeParameterElement) element).getType();
if (argumentList != null) {
// Type parameters cannot have type arguments.
// TODO(brianwilkerson) Report this error.
// resolver.reportError(ResolverErrorCode.?, keyType);
}
} else if (element instanceof MultiplyDefinedElement) {
Element[] elements = ((MultiplyDefinedElement) element).getConflictingElements();
type = getTypeWhenMultiplyDefined(elements);
if (type != null) {
node.setType(type);
}
} else {
// The name does not represent a type.
RedirectingConstructorKind redirectingConstructorKind;
if (isTypeNameInCatchClause(node)) {
reportErrorForNode(StaticWarningCode.NON_TYPE_IN_CATCH_CLAUSE, typeName, typeName.getName());
} else if (isTypeNameInAsExpression(node)) {
reportErrorForNode(StaticWarningCode.CAST_TO_NON_TYPE, typeName, typeName.getName());
} else if (isTypeNameInIsExpression(node)) {
reportErrorForNode(StaticWarningCode.TYPE_TEST_NON_TYPE, typeName, typeName.getName());
} else if ((redirectingConstructorKind = getRedirectingConstructorKind(node)) != null) {
ErrorCode errorCode = redirectingConstructorKind == RedirectingConstructorKind.CONST
? CompileTimeErrorCode.REDIRECT_TO_NON_CLASS : StaticWarningCode.REDIRECT_TO_NON_CLASS;
reportErrorForNode(errorCode, typeName, typeName.getName());
} else if (isTypeNameInTypeArgumentList(node)) {
reportErrorForNode(
StaticTypeWarningCode.NON_TYPE_AS_TYPE_ARGUMENT,