Skip to content

Commit cbc32a5

Browse files
committed
add tests for issues #10207, #10178, #12939
1 parent df2438c commit cbc32a5

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

test/core.jl

+16
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,22 @@ _bound_vararg_specificity_1{T}(::Type{Array{T,1}}, d::Int) = 1
8181
@test _bound_vararg_specificity_1(Array{Int,1}, 1) == 1
8282
@test _bound_vararg_specificity_1(Array{Int,2}, 1, 1) == 0
8383

84+
# issue #12939
85+
module Issue12939
86+
abstract type Abs; end
87+
struct Foo <: Abs; end
88+
struct Bar; val::Int64; end
89+
struct Baz; val::Int64; end
90+
f{T}(::Type{T}, x::T) = T(3)
91+
f{T <: Abs}(::Type{Bar}, x::T) = Bar(2)
92+
f(::Type{Bar}, x) = Bar(1)
93+
f(::Type{Baz}, x) = Baz(1)
94+
f{T <: Abs}(::Type{Baz}, x::T) = Baz(2)
95+
end
96+
97+
@test Issue12939.f(Issue12939.Baz,Issue12939.Foo()) === Issue12939.Baz(2)
98+
@test Issue12939.f(Issue12939.Bar,Issue12939.Foo()) === Issue12939.Bar(2)
99+
84100
# issue #11840
85101
TT11840{T} = Tuple{T,T}
86102
f11840(::Type) = "Type"

test/inference.jl

+7
Original file line numberDiff line numberDiff line change
@@ -738,3 +738,10 @@ let e = code_typed(f21175, ())[1].first.code[1]::Expr
738738
@test e.head === :return
739739
@test e.args[1] == Core.QuoteNode(902221)
740740
end
741+
742+
# issue #10207
743+
type T10207{A, B}
744+
a::A
745+
b::B
746+
end
747+
@test code_typed(T10207, (Int,Any))[1].second == T10207{Int,T} where T

test/staged.jl

+12
Original file line numberDiff line numberDiff line change
@@ -213,3 +213,15 @@ end
213213

214214
# issue #19897
215215
@test code_lowered(staged_t1, (Int,Int)) isa Array # check no error thrown
216+
217+
# issue #10178
218+
@generated function f10178(x::X) where X
219+
:(x)
220+
end
221+
g10178(x) = f10178(x)
222+
@test g10178(5) == 5
223+
@generated function f10178(x::X) where X
224+
:(2x)
225+
end
226+
g10178(x) = f10178(x)
227+
@test g10178(5) == 10

0 commit comments

Comments
 (0)