Skip to content

Commit 7f1ca48

Browse files
committed
Fix type inference test
1 parent 9a95ae3 commit 7f1ca48

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/BaseType.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ For example,
2020
]
2121
```
2222
"""
23-
function base_numeric_type(x::Type)
24-
params = x isa UnionAll ? x.body.parameters : x.parameters
25-
return length(params) == 0 ? x : first(params)
23+
function base_numeric_type(::Type{T}) where {T}
24+
params = T isa UnionAll ? T.body.parameters : T.parameters
25+
return isempty(params) ? T : first(params)
2626
end
2727
base_numeric_type(x) = base_numeric_type(typeof(x))
2828

test/unittests.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ using StaticArrays: StaticArrays
77
using Unitful: Unitful
88

99
expected_type_pairs = [
10-
Float32 => Float32,
1110
Float32 => Float32,
1211
Array{Float64,1} => Float64,
1312
ComplexF64 => Float64,
@@ -26,7 +25,7 @@ expected_type_pairs = [
2625
for (x, y) in expected_type_pairs
2726
@eval @test base_numeric_type($x) == $y
2827
# Make sure compiler can inline it:
29-
@eval @inferred typeof($y) base_numeric_type($x)
28+
@eval @inferred $y base_numeric_type($x)
3029
end
3130

3231
@test base_numeric_type(1.5DynamicQuantities.u"km/s") == base_numeric_type(typeof(1.5DynamicQuantities.u"km/s"))

0 commit comments

Comments
 (0)