From c9dbe1603bdba0bcd7d5f3fbb11784663e02899e Mon Sep 17 00:00:00 2001 From: Justin Willmert Date: Wed, 9 Sep 2020 17:35:16 -0500 Subject: [PATCH] Help type inference and reduce invalidation possibilities Duplicates improvement made to Base's Enums: JuliaLang/julia#37163 --- src/BitFlags.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/BitFlags.jl b/src/BitFlags.jl index 3cd82e5..98ba752 100644 --- a/src/BitFlags.jl +++ b/src/BitFlags.jl @@ -125,7 +125,7 @@ julia> instances(Items) (apple::Items = 0x00000001, fork::Items = 0x00000002, napkin::Items = 0x00000004) ``` """ -macro bitflag(T, syms...) +macro bitflag(T::Union{Symbol,Expr}, syms...) if isempty(syms) throw(ArgumentError("no arguments given for BitFlag $T")) end @@ -141,7 +141,7 @@ macro bitflag(T, syms...) elseif !isa(T, Symbol) throw(ArgumentError("invalid type expression for bit flag $T")) end - values = basetype[] + values = Vector{basetype}() seen = Set{Symbol}() namemap = Vector{Tuple{basetype,Symbol}}() lo = hi = zero(basetype)