|
| 1 | +macro warnpcfail(ex::Expr) |
| 2 | + modl = __module__ |
| 3 | + file = __source__.file === nothing ? "?" : String(__source__.file) |
| 4 | + line = __source__.line |
| 5 | + quote |
| 6 | + $(esc(ex)) || @warn """precompile directive |
| 7 | + $($(Expr(:quote, ex))) |
| 8 | + failed. Please report an issue in $($modl) (after checking for duplicates) or remove this directive.""" _file=$file _line=$line |
| 9 | + end |
| 10 | +end |
| 11 | + |
1 | 12 | function _precompile_()
|
2 | 13 | ccall(:jl_generating_output, Cint, ()) == 1 || return nothing
|
3 | 14 | normedtypes = (N0f8, N0f16) # precompiled Normed types
|
4 | 15 | realtypes = (Float16, Float32, Float64, Int) # types for mixed Normed/Real operations
|
5 | 16 | for T in normedtypes
|
6 | 17 | for f in (+, -, abs, eps, rand) # unary operations
|
7 |
| - @assert precompile(Tuple{typeof(f),T}) |
| 18 | + @warnpcfail precompile(Tuple{typeof(f),T}) |
8 | 19 | end
|
9 |
| - @assert precompile(Tuple{typeof(rand),T,Tuple{Int}}) |
10 |
| - @assert precompile(Tuple{typeof(rand),T,Tuple{Int,Int}}) |
| 20 | + @warnpcfail precompile(Tuple{typeof(rand),T,Tuple{Int}}) |
| 21 | + @warnpcfail precompile(Tuple{typeof(rand),T,Tuple{Int,Int}}) |
11 | 22 | for f in (trunc, floor, ceil, round) # rounding operations
|
12 |
| - @assert precompile(Tuple{typeof(f),T}) |
13 |
| - @assert precompile(Tuple{typeof(f),Type{Int},T}) |
| 23 | + @warnpcfail precompile(Tuple{typeof(f),T}) |
| 24 | + @warnpcfail precompile(Tuple{typeof(f),Type{Int},T}) |
14 | 25 | end
|
15 | 26 | for f in (+, -, *, /, <, <=, ==) # binary operations
|
16 |
| - @assert precompile(Tuple{typeof(f),T,T}) |
| 27 | + @warnpcfail precompile(Tuple{typeof(f),T,T}) |
17 | 28 | for S in realtypes
|
18 |
| - @assert precompile(Tuple{typeof(f),T,S}) |
19 |
| - @assert precompile(Tuple{typeof(f),S,T}) |
| 29 | + @warnpcfail precompile(Tuple{typeof(f),T,S}) |
| 30 | + @warnpcfail precompile(Tuple{typeof(f),S,T}) |
20 | 31 | end
|
21 | 32 | end
|
22 | 33 | # conversions
|
23 | 34 | for S in realtypes
|
24 |
| - @assert precompile(Tuple{Type{T},S}) |
25 |
| - @assert precompile(Tuple{Type{S},T}) |
26 |
| - @assert precompile(Tuple{typeof(convert),Type{T},S}) |
27 |
| - @assert precompile(Tuple{typeof(convert),Type{S},T}) |
| 35 | + @warnpcfail precompile(Tuple{Type{T},S}) |
| 36 | + @warnpcfail precompile(Tuple{Type{S},T}) |
| 37 | + @warnpcfail precompile(Tuple{typeof(convert),Type{T},S}) |
| 38 | + @warnpcfail precompile(Tuple{typeof(convert),Type{S},T}) |
28 | 39 | end
|
29 | 40 | end
|
30 | 41 | end
|
0 commit comments