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

Allow supertypes on struct definitions #152

Merged
merged 2 commits into from
Nov 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/@aml/@aml_create.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ function aml_create(expr::Expr, args_param, args_defaultvalue, args_type, args_v

end # endfor
################################################################
# Remove supertype if it is present
if T isa Expr && T.head == :<:
T = T.args[1]
aminya marked this conversation as resolved.
Show resolved Hide resolved
end
################################################################
# Type name is a single name (symbol)
if T isa Symbol
S = T
Expand Down
20 changes: 20 additions & 0 deletions test/struct_definition.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,26 @@ pprint(pxml_vector)
@aml mutable struct MyGeneralXML2{T} "MyGeneralXML2"
myfield::T, "~"
end

################################################################

abstract type AbstractTestType end

# non-parametric with supertype
@aml mutable struct MyParentedType <: AbstractTestType "MyParentedType"
myfield::String, "~"
end

@test MyParentedType <: AbstractTestType

# parametric with supertype
@aml mutable struct MyParentedType2{T} <: AbstractTestType "MyParentedType2"
myfield::T, "~"
end

@test MyParentedType2 <: AbstractTestType
@test MyParentedType2{String} <: AbstractTestType

################################################################

# empty or no aml
Expand Down