diff --git a/NEWS.md b/NEWS.md index f7bfb25f..491f452f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,8 @@ # covr (development version) +* Fixed a performance regression and an error triggered by a change in R + 4.4.0. (@kyleam, #588) + * Fixed an issue where attempting to generate code coverage on an already-loaded package could fail on Windows. (@kevinushey, #574) diff --git a/R/parse_data.R b/R/parse_data.R index a2f14d4b..68d30c58 100644 --- a/R/parse_data.R +++ b/R/parse_data.R @@ -140,7 +140,16 @@ clean_parse_data <- function() { rm(list = ls(package_parse_data), envir = package_parse_data) } -# Needed to work around https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=16756 get_tokens <- function(srcref) { - getParseData(srcref) %||% get_parse_data(attr(getSrcref(srcref), "srcfile")) + # Before R 4.4.0, covr's custom get_parse_data is necessary because + # utils::getParseData returns parse data for only the last file in the + # package. That issue (bug#16756) is fixed in R 4.4.0 (r84538). + # + # On R 4.4.0, continue to use get_parse_data because covr's code expects the + # result to be limited to the srcref file. getParseData will return parse data + # for all of the package's files. + get_parse_data(attr(getSrcref(srcref), "srcfile")) %||% + # This covers the non-installed file case where the source file isn't a + # concatenated file with "line N" directives. + getParseData(srcref) }