@@ -432,6 +432,34 @@ function cycle_fix_limited(@nospecialize(typ), sv::InferenceState)
432432 return typ
433433end
434434
435+ function adjust_effects (ipo_effects:: Effects , def:: Method )
436+ # override the analyzed effects using manually annotated effect settings
437+ override = decode_effects_override (def. purity)
438+ if is_effect_overridden (override, :consistent )
439+ ipo_effects = Effects (ipo_effects; consistent= ALWAYS_TRUE)
440+ end
441+ if is_effect_overridden (override, :effect_free )
442+ ipo_effects = Effects (ipo_effects; effect_free= ALWAYS_TRUE)
443+ end
444+ if is_effect_overridden (override, :nothrow )
445+ ipo_effects = Effects (ipo_effects; nothrow= true )
446+ end
447+ if is_effect_overridden (override, :terminates_globally )
448+ ipo_effects = Effects (ipo_effects; terminates= true )
449+ end
450+ if is_effect_overridden (override, :notaskstate )
451+ ipo_effects = Effects (ipo_effects; notaskstate= true )
452+ end
453+ if is_effect_overridden (override, :inaccessiblememonly )
454+ ipo_effects = Effects (ipo_effects; inaccessiblememonly= ALWAYS_TRUE)
455+ end
456+ if is_effect_overridden (override, :noub )
457+ ipo_effects = Effects (ipo_effects; noub= ALWAYS_TRUE)
458+ end
459+ return ipo_effects
460+ end
461+
462+
435463function adjust_effects (sv:: InferenceState )
436464 ipo_effects = sv. ipo_effects
437465
@@ -478,28 +506,7 @@ function adjust_effects(sv::InferenceState)
478506 # override the analyzed effects using manually annotated effect settings
479507 def = sv. linfo. def
480508 if isa (def, Method)
481- override = decode_effects_override (def. purity)
482- if is_effect_overridden (override, :consistent )
483- ipo_effects = Effects (ipo_effects; consistent= ALWAYS_TRUE)
484- end
485- if is_effect_overridden (override, :effect_free )
486- ipo_effects = Effects (ipo_effects; effect_free= ALWAYS_TRUE)
487- end
488- if is_effect_overridden (override, :nothrow )
489- ipo_effects = Effects (ipo_effects; nothrow= true )
490- end
491- if is_effect_overridden (override, :terminates_globally )
492- ipo_effects = Effects (ipo_effects; terminates= true )
493- end
494- if is_effect_overridden (override, :notaskstate )
495- ipo_effects = Effects (ipo_effects; notaskstate= true )
496- end
497- if is_effect_overridden (override, :inaccessiblememonly )
498- ipo_effects = Effects (ipo_effects; inaccessiblememonly= ALWAYS_TRUE)
499- end
500- if is_effect_overridden (override, :noub )
501- ipo_effects = Effects (ipo_effects; noub= ALWAYS_TRUE)
502- end
509+ ipo_effects = adjust_effects (ipo_effects, def)
503510 end
504511
505512 return ipo_effects
@@ -850,16 +857,18 @@ function typeinf_edge(interp::AbstractInterpreter, method::Method, @nospecialize
850857 end
851858 typeinf (interp, frame)
852859 update_valid_age! (caller, frame. valid_worlds)
853- edge = is_inferred (frame) ? mi : nothing
854- return EdgeCallResult (frame. bestguess, edge, frame. ipo_effects) # effects are adjusted already within `finish`
860+ isinferred = is_inferred (frame)
861+ edge = isinferred ? mi : nothing
862+ effects = isinferred ? frame. ipo_effects : adjust_effects (Effects (), method) # effects are adjusted already within `finish` for ipo_effects
863+ return EdgeCallResult (frame. bestguess, edge, effects)
855864 elseif frame === true
856865 # unresolvable cycle
857866 return EdgeCallResult (Any, nothing , Effects ())
858867 end
859868 # return the current knowledge about this cycle
860869 frame = frame:: InferenceState
861870 update_valid_age! (caller, frame. valid_worlds)
862- return EdgeCallResult (frame. bestguess, nothing , adjust_effects (frame ))
871+ return EdgeCallResult (frame. bestguess, nothing , adjust_effects (Effects (), method ))
863872end
864873
865874function cached_return_type (code:: CodeInstance )
0 commit comments