Skip to content

Commit 518a6b8

Browse files
authored
Merge pull request #63 from JuliaObjects/less_generated
less generated for NamedTupleConstructor
2 parents 9fa5044 + fa46076 commit 518a6b8

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/ConstructionBase.jl

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,8 @@ constructorof(::Type{<:NamedTuple{names}}) where names =
3434

3535
struct NamedTupleConstructor{names} end
3636

37-
@generated function (::NamedTupleConstructor{names})(args...) where names
38-
quote
39-
Base.@_inline_meta
40-
$(NamedTuple{names, Tuple{args...}})(args)
41-
end
37+
@inline function (::NamedTupleConstructor{names})(args...) where names
38+
NamedTuple{names}(args)
4239
end
4340

4441
getproperties(o::NamedTuple) = o
@@ -157,6 +154,7 @@ setproperties_object(obj, patch::Tuple{}) = obj
157154
obj = $obj
158155
patch = $patch
159156
"""
157+
throw(ArgumentError(msg))
160158
end
161159
setproperties_object(obj, patch::NamedTuple{()}) = obj
162160
function setproperties_object(obj, patch)

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ end
4545
@test setproperties((a=1,), ()) === (a=1,)
4646
@test setproperties((a=1,), NamedTuple()) === (a=1,)
4747
@test setproperties(AB(1,2), ()) === AB(1,2)
48+
@test_throws ArgumentError setproperties(AB(1,2), (10,))
4849
@test setproperties(AB(1,2), NamedTuple()) === AB(1,2)
4950

5051
@test setproperties(AB(1,2), (a=2, b=3)) === AB(2,3)

0 commit comments

Comments
 (0)