docs: public static final boolean isInstance(SoyType type, SoyValue value, SourceLocation location) {
      switch (type.getKind()) {
        case ANY:
        case UNKNOWN:
          return true;
        case ATTRIBUTES:
          return isSanitizedofKind(value, ContentKind.ATTRIBUTES);
        case CSS:
          return isSanitizedofKind(value, ContentKind.CSS);
        case BOOL:
          return value instanceof BooleanData;
        case FLOAT:
          return value instanceof FloatData;
        case HTML:
          return isSanitizedofKind(value, ContentKind.HTML);
        case INT:
          return value instanceof IntegerData;
        case JS:
          return isSanitizedofKind(value, ContentKind.JS);
        case LIST:
          return value instanceof SoyList;
        case MAP:
          return value instanceof SoyMap;
        case LEGACY_OBJECT_MAP:
          return value instanceof SoyLegacyObjectMap;
        case NULL:
          return value == NullData.INSTANCE || value == UndefinedData.INSTANCE;
        case PROTO:
          // proto descriptors use instance equality.
          return value instanceof SoyProtoValue
              && ((SoyProtoValue) value).getProto().getDescriptorForType()
                  == ((SoyProtoType) type).getDescriptor();
        case PROTO_ENUM:
          // TODO(lukes): this should also assert that the value is in range
          return value instanceof IntegerData;
        case RECORD:
          return value instanceof SoyRecord;
        case STRING:
          if (Flags.stringIsNotSanitizedContent()) {
            return value instanceof SoyString;
          } else {
            if (value instanceof SoyString
                && value instanceof SanitizedContent
                && ((SanitizedContent) value).getContentKind() != ContentKind.TEXT
                && logger.isLoggable(Level.WARNING)) {
              logger.log(
                  Level.WARNING,
                  String.format(
                      "Passing in sanitized content into a template that accepts only string is "
                          + "forbidden. Please modify the template at %s to take in "
                          + "%s instead of just %s.",
                      location != null ? location.toString() : "unknown",
                      ((SanitizedContent) value).getContentKind(), type.toString()));
            }
            return value instanceof SoyString || value instanceof SanitizedContent;
          }
        case TRUSTED_RESOURCE_URI:
          return isSanitizedofKind(value, ContentKind.TRUSTED_RESOURCE_URI);
        case UNION:
          for (SoyType memberType : ((UnionType) type).getMembers()) {
            if (isInstance(memberType, value, location)) {
              return true;
            }
          }
          return false;
        case URI:
          return isSanitizedofKind(value, ContentKind.URI);
        case VE:
        case VE_DATA:
          // Dynamic VE support is minimally implemented in Tofu: ve and ve_data objects are always
          // null.
          return value == NullData.INSTANCE;
        case ERROR:
          // continue
      }
      throw new AssertionError("invalid type: " + type);
    }