Created
September 4, 2015 00:21
-
-
Save maximsch2/6557c1805325673531c3 to your computer and use it in GitHub Desktop.
Julia 0.4 method dispatch bug?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract Abs | |
type Foo <: Abs | |
end | |
type Bar | |
val::Int64 | |
end | |
type Baz | |
val::Int64 | |
end | |
import Base.convert | |
convert{T <: Abs}(::Type{Bar}, x::T) = Bar(2) | |
convert(::Type{Bar}, x) = Bar(1) | |
convert(::Type{Baz}, x) = Baz(1) | |
convert{T <: Abs}(::Type{Baz}, x::T) = Baz(2) | |
bar(y) = convert(Bar, y) | |
baz(y) = convert(Baz, y) | |
@show bar(Foo()) | |
@show baz(Foo()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment