Conversation
- Reverse pkg_env copy order in full load (impenv first, ns_env second) so
implicit generics created by setMethod() are not overwritten by the
original imported function from impenv
- Same fix in incremental load path
- Process nsInfo$exportMethods and nsInfo$exportClasses when calling
namespaceExport(), so exportMethods() directives in NAMESPACE are honoured
- Add Basket class + setMethod("as.data.table","Basket") to devpackage fixture
- Add exportMethods(as.data.table) to devpackage/NAMESPACE
- Add Stage 1 tests covering implicit generic in ns_env and pkg_env,
search-path dispatch, and namespace exports
- Add Stage 4b incremental reload test for Basket method via pkg_env
Agent-Logs-Url: https://github.com/finccam/loadfast/sessions/1e692b27-bdbc-40af-987c-8cde7d9c14cd
Co-authored-by: felix-andreas-finccam <266759557+felix-andreas-finccam@users.noreply.github.com>
| "as.data.table" %in% getNamespaceExports("devpackage") | ||
| )) | ||
|
|
||
|
|
There was a problem hiding this comment.
@copilot can we also test if normal call works? also for incmrental test. are these new tests exhaustive? can you think of more
basket <- new("Basket", ...)
as.data.table(new()
There was a problem hiding this comment.
Added in e1d67be. Both Stage 1 (full load) and Stage 4b (incremental) now cover:
existsMethod("as.data.table", "Basket")— method is registered- Direct call via
getExportedValue("devpackage", "as.data.table")(basket)— noget()wrapper - Direct call via
evalq(as.data.table(basket), envir = as.environment("package:devpackage"))— natural call syntax in pkg_env scope - Single-element Basket
- Empty Basket → 0-row DT with
itemcolumn - Non-Basket
data.framedispatch still works (regression guard)
Stage 1 additions:
- existsMethod("as.data.table", "Basket") registration check
- Direct call via getExportedValue("devpackage", "as.data.table")(b1)
- Direct call via evalq(as.data.table(b1), envir = pkg_env)
- Single-element Basket edge case
- Empty Basket → 0-row DT edge case
- Non-Basket data.frame dispatch regression test
Stage 4b additions (incremental path):
- existsMethod() still true after reload
- Direct call via getExportedValue() after reload
- Direct call via evalq in pkg_env scope after reload
- Empty Basket edge case after reload
Agent-Logs-Url: https://github.com/finccam/loadfast/sessions/b04d79a4-ae26-4d2c-8d17-24aaa4c3ee10
Co-authored-by: felix-andreas-finccam <266759557+felix-andreas-finccam@users.noreply.github.com>
| importFrom(data.table,":=") | ||
| importFrom(data.table,as.data.table) | ||
| importFrom(data.table,data.table) | ||
| exportMethods(as.data.table) |
There was a problem hiding this comment.
@copilot remove this. we shouldn't export this method. we only import it. we shouldn't rely on an export
There was a problem hiding this comment.
Done in dcc3a12. Removed exportMethods(as.data.table) from devpackage/NAMESPACE. The export test now asserts that as.data.table is not in getNamespaceExports("devpackage"), and all direct-call tests were updated from getExportedValue() (which requires export) to get("as.data.table", pos = "package:devpackage") (search-path lookup).
|
@copilot can we also add a test for implicit generics? (normal an incremental?) |
…pdate tests accordingly Agent-Logs-Url: https://github.com/finccam/loadfast/sessions/867ce387-0440-413c-a48f-d463aca793c4 Co-authored-by: felix-andreas-finccam <266759557+felix-andreas-finccam@users.noreply.github.com>
Agent-Logs-Url: https://github.com/finccam/loadfast/sessions/1626ac4c-08cf-457f-bddc-8ad5aa513549 Co-authored-by: felix-andreas-finccam <266759557+felix-andreas-finccam@users.noreply.github.com>
Added in 387678b. Stage 1 already had the two implicit generic checks (ns_env + pkg_env). Stage 4b now has the same two checks after the incremental reload — verifying |
setMethod()on an imported S3 generic (likedata.table::as.data.table) creates an implicit S4 generic inns_env. The pkg_env population step was overwriting that implicit generic with the original S3 function fromimpenv, silently breaking search-path dispatch while internal namespace dispatch worked fine. Additionally,exportMethods()/exportClasses()directives in NAMESPACE were ignored, so exported generics never appeared ingetNamespaceExports().Fixes in
R/loadfast.Rpkg_envcopy order reversed (both full and incremental paths):impenvis now the base layer,ns_envapplied second so any shadows created during sourcing (implicit generics, deliberate overrides) win over raw importsexportMethods/exportClassesnow processed: namespace export block extended to includensInfo$exportMethodsandnsInfo$exportClassesalongsidensInfo$exportsTest coverage
BasketS4 class +setMethod("as.data.table", "Basket", ...)todevpackagefixture;as.data.tableis imported but intentionally not exported (exportMethodsomitted from NAMESPACE)existsMethod(), implicit generic is agenericFunctionin bothns_envandpkg_env(not overwritten by the raw imported S3 fn), dispatch viaget(), direct calls viaget(..., pos = "package:devpackage")andevalq()in pkg_env scope, single-element and empty Basket edge cases, non-Basketdata.framedispatch regression, confirmsas.data.tableis not ingetNamespaceExports()base.R, plus explicit checks thatas.data.tableremains agenericFunctionin bothns_envandpkg_envafter the reload (not reverted to the plain S3 function), confirming the method remains registered and dispatches correctly through all call paths