Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add tests for issues #10207, #10178, #12939 #21342

Merged
merged 1 commit into from
Apr 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,22 @@ _bound_vararg_specificity_1{T}(::Type{Array{T,1}}, d::Int) = 1
@test _bound_vararg_specificity_1(Array{Int,1}, 1) == 1
@test _bound_vararg_specificity_1(Array{Int,2}, 1, 1) == 0

# issue #12939
module Issue12939
abstract type Abs; end
struct Foo <: Abs; end
struct Bar; val::Int64; end
struct Baz; val::Int64; end
f{T}(::Type{T}, x::T) = T(3)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason not to use where here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was just copying this from the issue comment.

f{T <: Abs}(::Type{Bar}, x::T) = Bar(2)
f(::Type{Bar}, x) = Bar(1)
f(::Type{Baz}, x) = Baz(1)
f{T <: Abs}(::Type{Baz}, x::T) = Baz(2)
end

@test Issue12939.f(Issue12939.Baz,Issue12939.Foo()) === Issue12939.Baz(2)
@test Issue12939.f(Issue12939.Bar,Issue12939.Foo()) === Issue12939.Bar(2)

# issue #11840
TT11840{T} = Tuple{T,T}
f11840(::Type) = "Type"
Expand Down
7 changes: 7 additions & 0 deletions test/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -738,3 +738,10 @@ let e = code_typed(f21175, ())[1].first.code[1]::Expr
@test e.head === :return
@test e.args[1] == Core.QuoteNode(902221)
end

# issue #10207
type T10207{A, B}
a::A
b::B
end
@test code_typed(T10207, (Int,Any))[1].second == T10207{Int,T} where T
12 changes: 12 additions & 0 deletions test/staged.jl
Original file line number Diff line number Diff line change
Expand Up @@ -213,3 +213,15 @@ end

# issue #19897
@test code_lowered(staged_t1, (Int,Int)) isa Array # check no error thrown

# issue #10178
@generated function f10178(x::X) where X
:(x)
end
g10178(x) = f10178(x)
@test g10178(5) == 5
@generated function f10178(x::X) where X
:(2x)
end
g10178(x) = f10178(x)
@test g10178(5) == 10