Skip to content

Commit 86f06b6

Browse files
committed
Return struct with inline references as references again
This was broken by JuliaLang/julia#43953 Fix #25
1 parent 2b76f6f commit 86f06b6

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/FunctionWrappers.jl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ else
3535
Base.@pure pass_by_value(T) = isbitstype(T)
3636
end
3737

38+
if VERSION >= v"1.8.0-DEV.1460"
39+
# Restriction from https://github.com/JuliaLang/julia/pull/43953
40+
Base.@pure pass_by_value_ret(T) = isbitstype(T)
41+
else
42+
Base.@pure pass_by_value_ret(T) = pass_by_value(T)
43+
end
44+
3845
Base.@pure is_singleton(@nospecialize(T)) = isdefined(T, :instance)
3946
# Base.@pure get_instance(@nospecialize(T)) = Base.getfield(T, :instance)
4047

@@ -61,7 +68,7 @@ end
6168

6269
# Convert return type and generates cfunction signatures
6370
Base.@pure map_rettype(T) =
64-
(pass_by_value(T) || T === Any || is_singleton(T)) ? T : Ref{T}
71+
(pass_by_value_ret(T) || T === Any || is_singleton(T)) ? T : Ref{T}
6572
Base.@pure function map_cfunc_argtype(T)
6673
if is_singleton(T)
6774
return Ref{T}

test/runtests.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,13 @@ end
8181
@test identityF64Int(1) === 1.0
8282
@test identityF64Int(1.0) === 1.0
8383
end
84+
85+
struct InlineRefStruct
86+
x::Vector{Int}
87+
end
88+
89+
@testset "Inline struct with Ref" begin
90+
f = @inferred FunctionWrapper{InlineRefStruct,Tuple{InlineRefStruct}}(identity)
91+
v = InlineRefStruct([1, 2, 3])
92+
@test @inferred(f(v)) === v
93+
end

0 commit comments

Comments
 (0)