Skip to content

Commit

Permalink
Revert "Add function-first finalizers (#416)"
Browse files Browse the repository at this point in the history
This reverts commit 5ab47d1 due to
method ambiguities.

add at-compat for finalizer instead

at-compat finalizer
  • Loading branch information
ararslan authored and fredrikekre committed Dec 1, 2017
1 parent 4aaff07 commit a58d00a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ Currently, the `@compat` macro supports the following syntaxes:

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

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

## Renaming

Expand Down
13 changes: 5 additions & 8 deletions src/Compat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ function _compat(ex::Expr)
end
end
end
if VERSION < v"0.7.0-DEV.2562"
if ex.head == :call && ex.args[1] == :finalizer
ex.args[2], ex.args[3] = ex.args[3], ex.args[2]
end
end
return Expr(ex.head, map(_compat, ex.args)...)
end

Expand Down Expand Up @@ -825,14 +830,6 @@ end
export Uninitialized, uninitialized
end

if VERSION < v"0.7.0-DEV.2562"
import Base: finalizer
finalizer(f::Function, o) = finalizer(o, f)
finalizer(f::Ptr{Void}, o) = finalizer(o, f)
finalizer(f::Ptr{Void}, o::Ptr{Void}) = invoke(finalizer, Tuple{Ptr{Void}, Any}, f, o)
finalizer(f::Ptr{Void}, o::Function) = invoke(finalizer, Tuple{Ptr{Void}, Any}, f, o)
end

include("deprecated.jl")

end # module Compat
3 changes: 2 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -916,10 +916,11 @@ module Test24361
using Compat.Test
@test String(Compat.Base64.base64decode("SGVsbG8h")) == "Hello!"
end

# 0.7
let A = [1]
local x = 0
finalizer(a->(x+=1), A)
@compat finalizer(a->(x+=1), A)
finalize(A)
@test x == 1
A = 0
Expand Down

0 comments on commit a58d00a

Please sign in to comment.