Skip to content

Commit 44a0cc8

Browse files
authored
Merge pull request #152 from alhirzel/allow-supertypes
2 parents 6b87580 + 3760114 commit 44a0cc8

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/@aml/@aml_create.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ function aml_create(expr::Expr, args_param, args_defaultvalue, args_type, args_v
7373

7474
end # endfor
7575
################################################################
76+
# Remove supertype if it is present
77+
if T isa Expr && T.head == :<:
78+
T = T.args[1]
79+
end
80+
################################################################
7681
# Type name is a single name (symbol)
7782
if T isa Symbol
7883
S = T

test/struct_definition.jl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,26 @@ pprint(pxml_vector)
4545
@aml mutable struct MyGeneralXML2{T} "MyGeneralXML2"
4646
myfield::T, "~"
4747
end
48+
49+
################################################################
50+
51+
abstract type AbstractTestType end
52+
53+
# non-parametric with supertype
54+
@aml mutable struct MyParentedType <: AbstractTestType "MyParentedType"
55+
myfield::String, "~"
56+
end
57+
58+
@test MyParentedType <: AbstractTestType
59+
60+
# parametric with supertype
61+
@aml mutable struct MyParentedType2{T} <: AbstractTestType "MyParentedType2"
62+
myfield::T, "~"
63+
end
64+
65+
@test MyParentedType2 <: AbstractTestType
66+
@test MyParentedType2{String} <: AbstractTestType
67+
4868
################################################################
4969

5070
# empty or no aml

0 commit comments

Comments
 (0)