@@ -1176,26 +1176,24 @@ function analyze_single_call!(
1176
1176
end
1177
1177
end
1178
1178
1179
- # if the signature is fully covered and there is only one applicable method,
1179
+ # if the signature is fully or mostly covered and there is only one applicable method,
1180
1180
# we can try to inline it even if the signature is not a dispatch tuple
1181
- if atype <: signature_union
1182
- if length (cases) == 0 && only_method isa Method
1183
- if length (infos) > 1
1184
- (metharg, methsp) = ccall (:jl_type_intersection_with_env , Any, (Any, Any),
1185
- atype, only_method. sig):: SimpleVector
1186
- match = MethodMatch (metharg, methsp:: SimpleVector , only_method, true )
1187
- else
1188
- meth = meth:: MethodLookupResult
1189
- @assert length (meth) == 1
1190
- match = meth[1 ]
1191
- end
1192
- item = analyze_method! (match, argtypes, flag, state)
1193
- item === nothing && return
1194
- push! (cases, InliningCase (match. spec_types, item))
1195
- fully_covered = true
1181
+ if length (cases) == 0 && only_method isa Method
1182
+ if length (infos) > 1
1183
+ (metharg, methsp) = ccall (:jl_type_intersection_with_env , Any, (Any, Any),
1184
+ atype, only_method. sig):: SimpleVector
1185
+ match = MethodMatch (metharg, methsp:: SimpleVector , only_method, true )
1186
+ else
1187
+ meth = meth:: MethodLookupResult
1188
+ @assert length (meth) == 1
1189
+ match = meth[1 ]
1196
1190
end
1191
+ item = analyze_method! (match, argtypes, flag, state)
1192
+ item === nothing && return
1193
+ push! (cases, InliningCase (match. spec_types, item))
1194
+ fully_covered = match. fully_covers
1197
1195
else
1198
- fully_covered = false
1196
+ fully_covered &= atype <: signature_union
1199
1197
end
1200
1198
1201
1199
# If we only have one case and that case is fully covered, we may either
@@ -1244,17 +1242,15 @@ function maybe_handle_const_call!(
1244
1242
1245
1243
# if the signature is fully covered and there is only one applicable method,
1246
1244
# we can try to inline it even if the signature is not a dispatch tuple
1247
- if atype <: signature_union
1248
- if length (cases) == 0 && length (results) == 1
1249
- (; mi) = item = InliningTodo (results[1 ]:: InferenceResult , argtypes)
1250
- state. mi_cache != = nothing && (item = resolve_todo (item, state, flag))
1251
- validate_sparams (mi. sparam_vals) || return true
1252
- item === nothing && return true
1253
- push! (cases, InliningCase (mi. specTypes, item))
1254
- fully_covered = true
1255
- end
1245
+ if length (cases) == 0 && length (results) == 1
1246
+ (; mi) = item = InliningTodo (results[1 ]:: InferenceResult , argtypes)
1247
+ state. mi_cache != = nothing && (item = resolve_todo (item, state, flag))
1248
+ validate_sparams (mi. sparam_vals) || return true
1249
+ item === nothing && return true
1250
+ push! (cases, InliningCase (mi. specTypes, item))
1251
+ fully_covered = atype <: mi.specTypes
1256
1252
else
1257
- fully_covered = false
1253
+ fully_covered &= atype <: signature_union
1258
1254
end
1259
1255
1260
1256
# If we only have one case and that case is fully covered, we may either
0 commit comments