Skip to content

Inconsistent restriction when subtyping using typealias #19414

Closed
@martinholters

Description

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.

Metadata

Assignees

No one assigned

    Labels

    types and dispatchTypes, subtyping and method dispatch

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions