@@ -192,6 +192,12 @@ constructorof(::Type{N}) where {N<:AbstractNode} = Base.typename(N).wrapper
192
192
constructorof (:: Type{<:Node} ) = Node
193
193
constructorof (:: Type{<:GraphNode} ) = GraphNode
194
194
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
+
195
201
""" Trait declaring whether nodes share children or not."""
196
202
preserve_sharing (:: Type{<:AbstractNode} ) = false
197
203
preserve_sharing (:: Type{<:Node} ) = false
@@ -220,18 +226,24 @@ function (::Type{N})(
220
226
op:: Integer , l:: AbstractExpressionNode{T}
221
227
) where {T,N<: AbstractExpressionNode }
222
228
@assert l isa N
229
+ if ! (N isa UnionAll)
230
+ @warn " Ignoring specified type parameters in binary operator constructor."
231
+ end
223
232
return constructorof (N)(1 , false , nothing , 0 , op, l)
224
233
end
225
234
function (:: Type{N} )(
226
235
op:: Integer , l:: AbstractExpressionNode{T1} , r:: AbstractExpressionNode{T2}
227
236
) where {T1,T2,N<: AbstractExpressionNode }
228
237
@assert l isa N && r isa N
238
+ if ! (N isa UnionAll)
239
+ @warn " Ignoring specified type parameters in binary operator constructor."
240
+ end
229
241
# Get highest type:
230
242
if T1 != T2
231
243
T = promote_type (T1, T2)
232
244
# 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)
235
247
end
236
248
return constructorof (N)(2 , false , nothing , 0 , op, l, r)
237
249
end
0 commit comments