File tree Expand file tree Collapse file tree 2 files changed +4
-5
lines changed
Expand file tree Collapse file tree 2 files changed +4
-5
lines changed Original file line number Diff line number Diff 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)
2626end
2727base_numeric_type (x) = base_numeric_type (typeof (x))
2828
Original file line number Diff line number Diff line change @@ -7,7 +7,6 @@ using StaticArrays: StaticArrays
77using Unitful: Unitful
88
99expected_type_pairs = [
10- Float32 => Float32,
1110 Float32 => Float32,
1211 Array{Float64,1 } => Float64,
1312 ComplexF64 => Float64,
@@ -26,7 +25,7 @@ expected_type_pairs = [
2625for (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)
3029end
3130
3231@test base_numeric_type (1.5 DynamicQuantities. u " km/s" ) == base_numeric_type (typeof (1.5 DynamicQuantities. u " km/s" ))
You can’t perform that action at this time.
0 commit comments