lifecycle
lifecycle copied to clipboard
Unable to deprecate an R6 class
I am unable to deprecate an entire R6 class. There was an issue for deprecating an R6 method (https://github.com/r-lib/lifecycle/issues/54) that was fixed, but that does not seem to work within initialize. If I'm missing something, please let me know.
Minimal reprex:
A <- R6::R6Class("A", list(
initialize = function() {
lifecycle::deprecate_soft('1.0.0', 'A$new()')
}
))
A$new()
# No deprecation warning
A non-soft deprecation works:
A <- R6::R6Class("A", list(
initialize = function() {
lifecycle::deprecate_warn('1.0.0', 'A$new()')
}
))
A$new()
#> Warning: `A$new()` was deprecated in <NA> 1.0.0.
#> ℹ The deprecated feature was likely used in the R6 package.
#> Please report the issue at <https://github.com/r-lib/R6/issues>.
#> <A>
#> Public:
#> clone: function (deep = FALSE)
#> initialize: function ()
Created on 2023-11-02 with reprex v2.0.2
I think the problem here is that initialize() is not called directly by the user, so the soft deprecation path doesn't trigger. Not sure if there's anything we can do about this