Skip to content

Commit a58d00a

Browse files
ararslanfredrikekre
authored andcommitted
Revert "Add function-first finalizers (#416)"
This reverts commit 5ab47d1 due to method ambiguities. add at-compat for finalizer instead at-compat finalizer
1 parent 4aaff07 commit a58d00a

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,8 @@ Currently, the `@compat` macro supports the following syntaxes:
192192

193193
* `Uninitialized` and `uninitialized` with corresponding `Array` constructors ([#24652]).
194194

195-
* `finalizer` accepts the finalizer to run as the first argument and the object to be finalized
196-
as the second ([#24605])
195+
* `@compat finalizer(func, obj)` with the finalizer to run as the first argument and the object to be finalized
196+
as the second ([#24605]).
197197

198198
## Renaming
199199

src/Compat.jl

+5-8
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ function _compat(ex::Expr)
100100
end
101101
end
102102
end
103+
if VERSION < v"0.7.0-DEV.2562"
104+
if ex.head == :call && ex.args[1] == :finalizer
105+
ex.args[2], ex.args[3] = ex.args[3], ex.args[2]
106+
end
107+
end
103108
return Expr(ex.head, map(_compat, ex.args)...)
104109
end
105110

@@ -825,14 +830,6 @@ end
825830
export Uninitialized, uninitialized
826831
end
827832

828-
if VERSION < v"0.7.0-DEV.2562"
829-
import Base: finalizer
830-
finalizer(f::Function, o) = finalizer(o, f)
831-
finalizer(f::Ptr{Void}, o) = finalizer(o, f)
832-
finalizer(f::Ptr{Void}, o::Ptr{Void}) = invoke(finalizer, Tuple{Ptr{Void}, Any}, f, o)
833-
finalizer(f::Ptr{Void}, o::Function) = invoke(finalizer, Tuple{Ptr{Void}, Any}, f, o)
834-
end
835-
836833
include("deprecated.jl")
837834

838835
end # module Compat

test/runtests.jl

+2-1
Original file line numberDiff line numberDiff line change
@@ -916,10 +916,11 @@ module Test24361
916916
using Compat.Test
917917
@test String(Compat.Base64.base64decode("SGVsbG8h")) == "Hello!"
918918
end
919+
919920
# 0.7
920921
let A = [1]
921922
local x = 0
922-
finalizer(a->(x+=1), A)
923+
@compat finalizer(a->(x+=1), A)
923924
finalize(A)
924925
@test x == 1
925926
A = 0

0 commit comments

Comments
 (0)