Skip to content

Commit 81245b0

Browse files
authored
Merge pull request #670 from JuliaRobotics/feat/3Q20/expandconvert
convertStructType for ::UnionAll too
2 parents 10bf5c3 + 448dfaa commit 81245b0

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/Common.jl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,13 @@ _getname(t::T) where T = T.name.name
55

66

77
convertPackedType(t::Union{T, Type{T}}) where {T <: FunctorInferenceType} = getfield(_getmodule(t), Symbol("Packed$(_getname(t))"))
8-
convertStructType(::Type{PT}) where {PT <: PackedInferenceType} = getfield(PT.name.module, Symbol(string(PT.name.name)[7:end]))
9-
8+
function convertStructType(::Type{PT}) where {PT <: PackedInferenceType}
9+
# see #668 for expanded reasoning. PT may be ::UnionAll if the type is of template type.
10+
ptt = PT isa DataType ? PT.name.name : PT
11+
moduleName = PT isa DataType ? PT.name.module : Main
12+
symbolName = Symbol(string(ptt)[7:end])
13+
getfield(moduleName, symbolName)
14+
end
1015

1116
##==============================================================================
1217
## Sorting

0 commit comments

Comments
 (0)