Repository: JuliaLang/julia
File: test/core.jl (Julia)

Code before:
    methods(j59327)[1].specializations
)

@noinline l59327(f::Base.Callable, x) = Any[f, x]
m59327(x) = l59327(+, Any[x][1])
m59327(1)
@test any(
    mi->mi isa Core.MethodInstance && mi.specTypes == Tuple{typeof(l59327), Function, Int},
    methods(l59327)[1].specializations
)

# _do_ specialize if the signature has a `where`
@noinline n59327(f::F, x) where F = Any[f, x]
o59327(x) = n59327(+, Any[x][1])
o59327(1)
@test !any(
    mi->mi isa Core.MethodInstance && mi.specTypes == Tuple{typeof(n59327), Function, Int},
    methods(n59327)[1].specializations
)
@test any(
    mi->mi isa Core.MethodInstance && mi.specTypes == Tuple{typeof(n59327), typeof(+), Int},
    methods(n59327)[1].specializations
)

# _do_ specialize if the signature is specific
@noinline n59327(f::typeof(+), x) where F = Any[f, x]
o59327(x) = n59327(+, Any[x][1])
o59327(1)
@test !any(
    mi->mi isa Core.MethodInstance && mi.specTypes == Tuple{typeof(n59327), Function, Int},
    methods(n59327)[1].specializations
)
@test any(
    mi->mi isa Core.MethodInstance && mi.specTypes == Tuple{typeof(n59327), typeof(+), Int},
    methods(n59327)[1].specializations
)

# issue #20511
f20511(x::DataType) = 0
f20511(x) = 1
Type{AbstractSet}  # cache this
@test f20511(Union{AbstractSet,Set{T}} where T) == 1

# join
@test typejoin(Int8,Int16) === Signed
@test typejoin(Int,AbstractString) === Any
@test typejoin(Array{Float64},BitArray) <: AbstractArray
@test typejoin(Array{Bool},BitArray) <: AbstractArray{Bool}
@test typejoin(Tuple{Int,Int8},Tuple{Int8,Float64}) === Tuple{Signed,Real}
@test typejoin(Tuple{String,String}, Tuple{GenericString,String},
               Tuple{String,GenericString}, Tuple{Int,String,Int}) ==

Review comment (suggestion):
is there a typo here? 
```suggestion
@noinline n59327(f::typeof(+), x) = Any[f, x]
```

Code after:
    methods(j59327)[1].specializations
)

@noinline l59327(f::Base.Callable, x) = Any[f, x]
m59327(x) = l59327(+, Any[x][1])
m59327(1)
@test any(
    mi->mi isa Core.MethodInstance && mi.specTypes == Tuple{typeof(l59327), Function, Int},
    methods(l59327)[1].specializations
)

# _do_ specialize if the signature has a `where`
@noinline n59327(f::F, x) where F = Any[f, x]
o59327(x) = n59327(+, Any[x][1])
o59327(1)
@test !any(
    mi->mi isa Core.MethodInstance && mi.specTypes == Tuple{typeof(n59327), Function, Int},
    methods(n59327)[1].specializations
)
@test any(
    mi->mi isa Core.MethodInstance && mi.specTypes == Tuple{typeof(n59327), typeof(+), Int},
    methods(n59327)[1].specializations
)

# _do_ specialize if the signature is specific
@noinline n59327(f::typeof(+), x) = Any[f, x]
o59327(x) = n59327(+, Any[x][1])
o59327(1)
@test !any(
    mi->mi isa Core.MethodInstance && mi.specTypes == Tuple{typeof(n59327), Function, Int},
    methods(n59327)[1].specializations
)
@test any(
    mi->mi isa Core.MethodInstance && mi.specTypes == Tuple{typeof(n59327), typeof(+), Int},
    methods(n59327)[1].specializations
)

# issue #20511
f20511(x::DataType) = 0
f20511(x) = 1
Type{AbstractSet}  # cache this
@test f20511(Union{AbstractSet,Set{T}} where T) == 1

# join
@test typejoin(Int8,Int16) === Signed
@test typejoin(Int,AbstractString) === Any
@test typejoin(Array{Float64},BitArray) <: AbstractArray
@test typejoin(Array{Bool},BitArray) <: AbstractArray{Bool}
@test typejoin(Tuple{Int,Int8},Tuple{Int8,Float64}) === Tuple{Signed,Real}
@test typejoin(Tuple{String,String}, Tuple{GenericString,String},
               Tuple{String,GenericString}, Tuple{Int,String,Int}) ==