in java/src/com/google/template/soy/passes/KeyCommandPass.java [130:182]
private void checkNodeIsSupportedType(ExprRootNode exprRootNode) {
SoyType exprType = exprRootNode.getRoot().getType();
Collection<SoyType> unwrapped =
exprType.getKind() == Kind.UNION
? ((UnionType) exprType).getMembers()
: ImmutableSet.of(exprType);
boolean isSupportedType = true;
for (SoyType type : unwrapped) {
switch (type.getKind()) {
case NULL:
case INT:
case FLOAT:
case STRING:
case PROTO_ENUM:
// these are all fine.
// null should potentially be rejected, but it is often hard to avoid nullable expressions
break;
case BOOL:
case HTML:
case ELEMENT:
case ATTRIBUTES:
case JS:
case CSS:
case URI:
case TRUSTED_RESOURCE_URI:
case LIST:
case RECORD:
case LEGACY_OBJECT_MAP:
case MAP:
case MESSAGE:
case PROTO:
case TEMPLATE:
case VE:
case VE_DATA:
case ANY:
case UNKNOWN:
isSupportedType = false;
break;
case UNION:
case PROTO_TYPE:
case PROTO_ENUM_TYPE:
case PROTO_EXTENSION:
case PROTO_MODULE:
case TEMPLATE_TYPE:
case TEMPLATE_MODULE:
case FUNCTION:
throw new AssertionError("impossible");
}
}
if (!isSupportedType) {
errorReporter.report(exprRootNode.getSourceLocation(), UNSUPPORTED_TYPE, exprType);
}
}