From 871a395f66d4aaf6292cef395764cc789195970d Mon Sep 17 00:00:00 2001 From: Alexander Plavin Date: Thu, 23 Feb 2023 13:39:53 +0300 Subject: [PATCH 1/4] fix #72 --- .github/workflows/CI.yml | 2 ++ .github/workflows/Downstream.yml | 2 +- src/ConstructionBase.jl | 37 ++++++++++++++++++++++++-------- 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index d2be379..d14d01c 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -17,7 +17,9 @@ jobs: - '1.3' - '1.5' - '1.6' + - '1.7' - '1' + - '1.9-nightly' - 'nightly' os: - ubuntu-latest diff --git a/.github/workflows/Downstream.yml b/.github/workflows/Downstream.yml index 805c696..162e912 100644 --- a/.github/workflows/Downstream.yml +++ b/.github/workflows/Downstream.yml @@ -10,7 +10,7 @@ jobs: strategy: fail-fast: false matrix: - julia-version: [1.6, 1, nightly] + julia-version: [1.6, 1, 1.9-nightly, nightly] os: [ubuntu-latest] package: - {repo: JuliaObjects/Accessors.jl} diff --git a/src/ConstructionBase.jl b/src/ConstructionBase.jl index 546eae5..482a5c2 100644 --- a/src/ConstructionBase.jl +++ b/src/ConstructionBase.jl @@ -48,13 +48,9 @@ getfields(x::NamedTuple) = x getproperties(o::NamedTuple) = o getproperties(o::Tuple) = o -function is_propertynames_overloaded(T::Type)::Bool - which(propertynames, Tuple{T}).sig !== Tuple{typeof(propertynames), Any} -end - -@generated function check_properties_are_fields(obj) - if is_propertynames_overloaded(obj) - return quote +if VERSION >= v"1.7" + function check_properties_are_fields(obj) + if propertynames(obj) != fieldnames(typeof(obj)) T = typeof(obj) msg = """ The function `Base.propertynames` was overloaded for type `$T`. @@ -65,9 +61,32 @@ end ``` """ error(msg) + else + :(nothing) + end + end +else + function is_propertynames_overloaded(T::Type)::Bool + which(propertynames, Tuple{T}).sig !== Tuple{typeof(propertynames), Any} + end + + @generated function check_properties_are_fields(obj) + if is_propertynames_overloaded(obj) + return quote + T = typeof(obj) + msg = """ + The function `Base.propertynames` was overloaded for type `$T`. + Please make sure the following methods are also overloaded for this type: + ```julia + ConstructionBase.setproperties + ConstructionBase.getproperties # optional in VERSION >= julia v1.7 + ``` + """ + error(msg) + end + else + :(nothing) end - else - :(nothing) end end From 376bffb570023c71bfb462f1d2062fa8eeb0729f Mon Sep 17 00:00:00 2001 From: Alexander Plavin Date: Thu, 23 Feb 2023 14:12:46 +0300 Subject: [PATCH 2/4] simplify --- src/ConstructionBase.jl | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/ConstructionBase.jl b/src/ConstructionBase.jl index 482a5c2..6174be0 100644 --- a/src/ConstructionBase.jl +++ b/src/ConstructionBase.jl @@ -51,18 +51,10 @@ getproperties(o::Tuple) = o if VERSION >= v"1.7" function check_properties_are_fields(obj) if propertynames(obj) != fieldnames(typeof(obj)) - T = typeof(obj) - msg = """ - The function `Base.propertynames` was overloaded for type `$T`. - Please make sure the following methods are also overloaded for this type: - ```julia - ConstructionBase.setproperties - ConstructionBase.getproperties # optional in VERSION >= julia v1.7 - ``` - """ - error(msg) - else - :(nothing) + error(""" + The function `Base.propertynames` was overloaded for type `$(typeof(obj))`. + Please make sure `ConstructionBase.setproperties` is also overloaded for this type. + """) end end else From 375ae551680ffe640b6b89b741c4743ffe54f2ea Mon Sep 17 00:00:00 2001 From: Alexander Plavin Date: Thu, 23 Feb 2023 14:14:33 +0300 Subject: [PATCH 3/4] bump --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 13543cd..7611b5c 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "ConstructionBase" uuid = "187b0558-2788-49d3-abe0-74a17ed4e7c9" authors = ["Takafumi Arakaki", "Rafael Schouten", "Jan Weidner"] -version = "1.5.0" +version = "1.5.1" [deps] LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" From 5f08dd3c4f28c4b0cdc22cf95723fd5e2721d389 Mon Sep 17 00:00:00 2001 From: Alexander Plavin Date: Thu, 23 Feb 2023 14:15:20 +0300 Subject: [PATCH 4/4] remove 1.9-nightly CI --- .github/workflows/CI.yml | 1 - .github/workflows/Downstream.yml | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index d14d01c..f70b68b 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -19,7 +19,6 @@ jobs: - '1.6' - '1.7' - '1' - - '1.9-nightly' - 'nightly' os: - ubuntu-latest diff --git a/.github/workflows/Downstream.yml b/.github/workflows/Downstream.yml index 162e912..805c696 100644 --- a/.github/workflows/Downstream.yml +++ b/.github/workflows/Downstream.yml @@ -10,7 +10,7 @@ jobs: strategy: fail-fast: false matrix: - julia-version: [1.6, 1, 1.9-nightly, nightly] + julia-version: [1.6, 1, nightly] os: [ubuntu-latest] package: - {repo: JuliaObjects/Accessors.jl}