@@ -16770,15 +16770,15 @@ registerS3method("format_col", "complex", format_col.default)
1677016770# then i) test 1610.1 fails if test.data.table() is rerun, ii) user display of complex data would be affected
1677116771# did try wrapping with on.exit(,add=TRUE) but perhaps because this is a script that is sys.source'd, it ran straight away
1677216772
16773- # format method for column takes predecedence over format method for each list item
16773+ # as of #6637, format individual list items but not the whole list
1677416774registerS3method("format", "myclass2130", function(x, ...) paste0("<", class(x)[1L], ":", x$id, ">"))
1677516775DT = data.table(row=1:2, objs=list(structure(list(id="foo"), class="myclass2130"), structure(list(id="bar"), class="myclass2130")))
1677616776test(2130.13, print(DT), output="myclass2130:foo.*myclass2130:bar")
1677716777setattr(DT$objs, "class", "foo2130")
1677816778registerS3method("format", "foo2130", function(x, ...) "All hail foo")
1677916779test(2130.14, print(DT), output="myclass2130:foo.*myclass2130:bar") # because length 1 from format but needs to be length(x)
1678016780registerS3method("format", "foo2130", function(x, ...) rep("All hail foo",length(x)))
16781- test(2130.15, print(DT), output="All hail foo") # e.g. sf:::format.sfc rather than sf::: format.sfg on each item
16781+ test(2130.15, print(DT), output="myclass2130: foo.*myclass2130:bar ") # used to call format(column), not vapply_1c(column, format)
1678216782setattr(DT$objs, "class", "bar2130_with_no_method")
1678316783test(2130.16, print(DT), output="myclass2130:foo.*myclass2130:bar")
1678416784registerS3method("format", "myclass2130", format.default)
0 commit comments