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

subtypes function not working as in 0.5 #20086

Closed
thofma opened this issue Jan 17, 2017 · 4 comments
Closed

subtypes function not working as in 0.5 #20086

thofma opened this issue Jan 17, 2017 · 4 comments
Labels
regression Regression in behavior compared to a previous version types and dispatch Types, subtyping and method dispatch

Comments

@thofma
Copy link
Contributor

thofma commented Jan 17, 2017

On 0.5:

julia> abstract C{T}

julia> type B{Int} <: C{Int} end

julia> subtypes(C)
1-element Array{Any,1}:
 B{Int}

On latest master:

julia> abstract C{T}

julia> type B{Int} <: C{Int} end

julia> subtypes(C)
ERROR: MethodError: no method matching subtypes(::Type{C})
Closest candidates are:
  subtypes(::Module, ::DataType) at reflection.jl:316
  subtypes(::DataType) at reflection.jl:333

julia> B{Int} <: C
true

julia> versioninfo()
Julia Version 0.6.0-dev.2130
Commit 00b1c77* (2017-01-17 05:46 UTC)
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: Intel(R) Core(TM) i7 CPU         860  @ 2.80GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Nehalem)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.9.1 (ORCJIT, nehalem)
@kshyatt kshyatt added the types and dispatch Types, subtyping and method dispatch label Jan 17, 2017
@mauro3
Copy link
Contributor

mauro3 commented Jan 17, 2017

Seems to be related to the parameter which makes typeof(AbstractArray)==UnionAll:

julia> subtypes(Integer)
4-element Array{DataType,1}:
 BigInt  
 Bool    
 Signed  
 Unsigned

julia> subtypes(AbstractArray)
ERROR: MethodError: no method matching subtypes(::Type{AbstractArray})
Closest candidates are:
  subtypes(::Module, ::DataType) at reflection.jl:316
  subtypes(::DataType) at reflection.jl:333

Other regressions/problems in reflection.jl are Base.datatype_name, datatype_module,

@mauro3
Copy link
Contributor

mauro3 commented Jan 17, 2017

I tried to fix this but could not figure out how to redefine:

datatype_name(t::DataType) = t.name.name

to work with UnionAll-abstract types. Anyway, here the test-case to save someone a few keystrokes:

# Issue #20086
@test subtypes(Integer) == Type[BigInt, Bool, Signed, Unsigned]
abstract A212323{T}
immutable B212323{T} <: A212323{T} end
@test subtypes(A212323) == Type[B212323]
@test subtypes(A212323{Int}) == Type[B212323{Int}]

@tkelman
Copy link
Contributor

tkelman commented Jan 17, 2017

xref attempt at #20084

@ghost
Copy link

ghost commented Jan 17, 2017

reopened #20084, but it is not very pretty, somebody should do it better.

@thofma thofma mentioned this issue Jan 19, 2017
53 tasks
@vtjnash vtjnash added the regression Regression in behavior compared to a previous version label Jan 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
regression Regression in behavior compared to a previous version types and dispatch Types, subtyping and method dispatch
Projects
None yet
Development

No branches or pull requests

5 participants