11abstract type AbstractCablePart end
22
3+ @inline r_ex (p:: AbstractCablePart ) = r_ex (p. shape)
4+
35struct ConductorPart{L, T, S <: AbstractShape{L, T} } <: AbstractCablePart
46 tag:: Symbol
57 shape:: S
@@ -10,19 +12,15 @@ function ConductorPart(
1012 tag:: Symbol ,
1113 shape:: AbstractShape{L, T_shape} ,
1214 mat:: Material{T_mat} ,
13- ) where {L, T_shape, T_mat}
15+ ) where {L, T_shape <: Real , T_mat <: Real }
1416 # 1. Ask the compiler what the safest common type is.
15- T_common = promote_type (T_shape, T_mat)
17+ T = promote_type (T_shape, T_mat)
1618
1719 # 2. Let native dispatch handle the translation.
18- shape_promoted = convert (AbstractShape{L, T_common}, shape)
19- mat_promoted = convert (Material{T_common}, mat)
20-
21- return ConductorPart {L, T_common, typeof(shape_promoted)} (
22- tag,
23- shape_promoted,
24- mat_promoted,
25- )
20+ s = convert (AbstractShape{L, T}, shape)
21+ m = convert (Material{T}, mat)
22+
23+ return ConductorPart {L, T, typeof(s)} (tag, s, m)
2624end
2725
2826struct InsulatorPart{L, T, S <: AbstractShape{L, T} } <: AbstractCablePart
@@ -35,17 +33,13 @@ function InsulatorPart(
3533 tag:: Symbol ,
3634 shape:: AbstractShape{L, T_shape} ,
3735 mat:: Material{T_mat} ,
38- ) where {L, T_shape, T_mat}
36+ ) where {L, T_shape <: Real , T_mat <: Real }
3937 # 1. Ask the compiler what the safest common type is.
40- T_common = promote_type (T_shape, T_mat)
38+ T = promote_type (T_shape, T_mat)
4139
4240 # 2. Let native dispatch handle the translation.
43- shape_promoted = convert (AbstractShape{L, T_common}, shape)
44- mat_promoted = convert (Material{T_common}, mat)
45-
46- return InsulatorPart {L, T_common, typeof(shape_promoted)} (
47- tag,
48- shape_promoted,
49- mat_promoted,
50- )
41+ s = convert (AbstractShape{L, T}, shape)
42+ m = convert (Material{T}, mat)
43+
44+ return InsulatorPart {L, T, typeof(s)} (tag, s, m)
5145end
0 commit comments