abstract type MyType end
function Base.getproperty(x::Type{A}, key::Symbol) where {A<:MyType}
println(key)
println(x)
end
[foo() for i in 1:2 for j in 1:2]
I think this code is comitting type piracy, because the user owns MyType but not Type{<:MyType}.
It’s technically piracy, but just becaues A <: MyType can be A = Union{}. But even without straight piracy, redefining any aspects for Type{MyType} may easily mess with Julia internals expectation. Better not to do that (: At best, maybe you can add properties, but surely should keep existing ones.
Are you sure you need to define this for ::Type{<:AbstractNewType} (for the subtypes) and not just ::AbstractNewType (an instance of the abstract type)?
I’ve never felt the need to define properties for types themselves (and, for that matter, I seldom define a non-default getproperty for any object). If you find this necessary, an alternative is to instead define some accessor functions and use those rather than getproperty. E.g., flavor(::Type{<:AbstractNewType}) = :chocolate.