@@ -192,6 +192,12 @@ constructorof(::Type{N}) where {N<:AbstractNode} = Base.typename(N).wrapper
192192constructorof (:: Type{<:Node} ) = Node
193193constructorof (:: Type{<:GraphNode} ) = GraphNode
194194
195+ function with_type_parameters (:: Type{N} , :: Type{T} ) where {N<: AbstractExpressionNode ,T}
196+ return constructorof (N){T}
197+ end
198+ with_type_parameters (:: Type{<:Node} , :: Type{T} ) where {T} = Node{T}
199+ with_type_parameters (:: Type{<:GraphNode} , :: Type{T} ) where {T} = GraphNode{T}
200+
195201""" Trait declaring whether nodes share children or not."""
196202preserve_sharing (:: Type{<:AbstractNode} ) = false
197203preserve_sharing (:: Type{<:Node} ) = false
@@ -220,18 +226,24 @@ function (::Type{N})(
220226 op:: Integer , l:: AbstractExpressionNode{T}
221227) where {T,N<: AbstractExpressionNode }
222228 @assert l isa N
229+ if ! (N isa UnionAll)
230+ @warn " Ignoring specified type parameters in binary operator constructor."
231+ end
223232 return constructorof (N)(1 , false , nothing , 0 , op, l)
224233end
225234function (:: Type{N} )(
226235 op:: Integer , l:: AbstractExpressionNode{T1} , r:: AbstractExpressionNode{T2}
227236) where {T1,T2,N<: AbstractExpressionNode }
228237 @assert l isa N && r isa N
238+ if ! (N isa UnionAll)
239+ @warn " Ignoring specified type parameters in binary operator constructor."
240+ end
229241 # Get highest type:
230242 if T1 != T2
231243 T = promote_type (T1, T2)
232244 # TODO : This might slow things down
233- l = convert (N{T} , l)
234- r = convert (N{T} , r)
245+ l = convert (with_type_parameters (N, T) , l)
246+ r = convert (with_type_parameters (N, T) , r)
235247 end
236248 return constructorof (N)(2 , false , nothing , 0 , op, l, r)
237249end
0 commit comments