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

Inconsistent restriction when subtyping using typealias #19414

Closed
martinholters opened this issue Nov 25, 2016 · 2 comments
Closed

Inconsistent restriction when subtyping using typealias #19414

martinholters opened this issue Nov 25, 2016 · 2 comments
Labels
types and dispatch Types, subtyping and method dispatch

Comments

@martinholters
Copy link
Member

julia> abstract Foo{T}

julia> typealias Bar{T} Foo{T}
Foo{T}

julia> typealias Baz Foo
Foo{T}

julia> type A <: Foo; end

julia> type B <: Bar; end
ERROR: invalid subtyping in definition of B

julia> type C <: Baz; end

Arguably, having a supertype with unfixed parameters is not very useful (or am I missing something?), but if it works for A and C, why shouldn't it for B?

Somewhat more concrete:

julia> type UntypedVector <: AbstractVector; end
ERROR: invalid subtyping in definition of UntypedVector

julia> type UntypedVector <: AbstractArray{TypeVar(:T),1}; end # then try this instead

julia> supertype(UntypedVector) == AbstractVector
true

The root cause seems to be that in the cases that work, the given supertype is a DataType, while in those that don't, it is a TypeConstructor. Might make sense the way it is, but for a casual observer, above examples just look really inconsistent.

@kshyatt kshyatt added the types and dispatch Types, subtyping and method dispatch label Nov 26, 2016
@JeffBezanson
Copy link
Member

closed by #18457 - Now all of these cases are disallowed.

@tkelman
Copy link
Contributor

tkelman commented Jan 16, 2017

@JeffBezanson you have or are adding test cases for each of these issues you're closing, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
types and dispatch Types, subtyping and method dispatch
Projects
None yet
Development

No branches or pull requests

4 participants