Skip to content

Commit 5a544f5

Browse files
committed
allow supertypes on struct definitions
1 parent 6b87580 commit 5a544f5

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-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: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,21 @@ 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+
# parametric with supertype
59+
@aml mutable struct MyParentedType2{T} <: AbstractTestType "MyParentedType2"
60+
myfield::T, "~"
61+
end
62+
4863
################################################################
4964

5065
# empty or no aml

0 commit comments

Comments
 (0)