Skip to content

Commit bca371b

Browse files
Merge pull request #128 from JuliaSIMD/fix/aqua-static-lazymuladd-ambiguity
Resolve Aqua method ambiguity: convert(::Type{Static.{True,False,StaticInt{N}}}, ::LazyMulAdd)
2 parents 50788a6 + 7415b53 commit bca371b

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

src/lazymul.jl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,25 @@ end
2828
::Type{LazyMulAdd{M,O,I}},
2929
a::LazyMulAdd{M,O,I}
3030
) where {M,O,I} = a
31+
# Disambiguate the generic `convert(::Type{T<:Number}, ::LazyMulAdd)` above
32+
# against Static.jl's `convert(::Type{Static.{True,False,StaticInt{N}}},
33+
# ::Number)` methods. Aqua flags both as matching `convert(Static.True,
34+
# ::LazyMulAdd)` etc., since `LazyMulAdd <: Number` and neither method is
35+
# strictly more specific. Forward to `Static`'s convert on the materialized
36+
# value so the StaticBool / StaticInt singletons come out, matching what
37+
# Static.jl produces for any Number input.
38+
@inline Base.convert(
39+
::Type{Static.True},
40+
a::LazyMulAdd{M,O,I}
41+
) where {M,O,I} = convert(Static.True, _materialize(a))
42+
@inline Base.convert(
43+
::Type{Static.False},
44+
a::LazyMulAdd{M,O,I}
45+
) where {M,O,I} = convert(Static.False, _materialize(a))
46+
@inline Base.convert(
47+
::Type{Static.StaticInt{N}},
48+
a::LazyMulAdd{M,O,I}
49+
) where {M,O,I,N} = convert(Static.StaticInt{N}, _materialize(a))
3150
# @inline Base.convert(::Type{LazyMulAdd{M,O,I}}, a::LazyMulAdd{M}) where {M,O,I} = a
3251
# @inline Base.convert(::Type{LazyMulAdd{M,T,I}}, a::LazyMulAdd{M,StaticInt{O},I}) where {M,O,I,T} = a
3352

0 commit comments

Comments
 (0)