Skip to content

Commit c3a5598

Browse files
committed
Allow simple concrete union fields for FieldRef
1 parent 90ea93f commit c3a5598

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
name = "LibAwsCommon"
22
uuid = "c6e421ba-b5f8-4792-a1c4-42948de3ed9d"
3-
version = "1.3.2"
3+
version = "1.3.3"
44

55
[deps]
66
CEnum = "fa961155-64e5-5f13-b03f-caf6b980ea82"
77
aws_c_common_jll = "73048d1d-b8c4-5092-a58d-866c5e8d1e50"
88

99
[compat]
10-
Aqua = "0.7"
10+
Aqua = "0.7,0.8"
1111
CEnum = "0.5"
1212
aws_c_common_jll = "=0.12.3"
1313
julia = "1.6"

src/LibAwsCommon.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ function init(allocator=default_aws_allocator())
7272
end
7373

7474
# utilities for interacting with AWS library APIs
75+
concrete_or_concreteunion(T) =
76+
isconcretetype(T) || (T isa Union && concrete_or_concreteunion(T.a) && concrete_or_concreteunion(T.b))
7577

7678
# like a Ref, but for a field of a struct
7779
# many AWS APIs take a pointer to an aws struct, so this makes it convenient to to pass
@@ -83,7 +85,7 @@ struct FieldRef{T, S}
8385
function FieldRef(x::T, field::Symbol) where {T}
8486
@assert isconcretetype(T) && ismutabletype(T) "only fields of mutable types are supported with FieldRef"
8587
S = fieldtype(T, field)
86-
@assert isconcretetype(S) && !ismutabletype(S) "field type must be concrete and immutable for FieldRef"
88+
@assert concrete_or_concreteunion(S) && !ismutabletype(S) "field type must be concrete and immutable for FieldRef"
8789
return new{T, S}(x, field)
8890
end
8991
end

0 commit comments

Comments
 (0)