With current master:
library(vctrs)
foobar <- function(x = list()) structure(x, class = "vctrs_foobar")
vec_ptype2(unspecified(), foobar())
#> list()
#> attr(,"class")
#> [1] "vctrs_foobar"
vec_ptype2(foobar(), unspecified())
#> Error: `x` must be a vector, not a `vctrs_foobar` object
Created on 2020-02-11 by the reprex package (v0.3.0)
With current master:
Created on 2020-02-11 by the reprex package (v0.3.0)