Skip to content

Commit

Permalink
Merge pull request #422 from JuliaLang/aa/revert-finalizer
Browse files Browse the repository at this point in the history
Revert function first finalizers due to ambiguities
  • Loading branch information
ararslan authored Dec 2, 2017
2 parents 4aaff07 + 5ac29d9 commit bda7613
Show file tree
Hide file tree
Showing 3 changed files with 11 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
5 changes: 4 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using Compat
using Compat.Test

@test isempty(detect_ambiguities(Base, Core, Compat))

const struct_sym = VERSION < v"0.7.0-DEV.1263" ? :type : :struct

# Issue #291
Expand Down Expand Up @@ -916,10 +918,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 bda7613

Please sign in to comment.