diff --git a/src/internals.jl b/src/internals.jl index 6b5a43d..242385d 100644 --- a/src/internals.jl +++ b/src/internals.jl @@ -2,18 +2,14 @@ module Internals import StableTasks: @spawn, @spawnat, @fetch, @fetchfrom, StableTask, AtomicRef -if ( - (@isdefined Core) && - (Core isa Module) && - isdefined(Core, :Compiler) && - (Core.Compiler isa Module) && - isdefined(Core.Compiler, :return_type) && - applicable(Core.Compiler.return_type, identity, Tuple{}) +const infer_return_type = if ( + isdefined(Base, :promote_op) && + applicable(Base.promote_op, rand) ) - infer_return_type(@nospecialize f::Any) = Core.Compiler.return_type(f, Tuple{}) + Base.promote_op else # safe conservative fallback to `Any`, which is subtyped by each type - infer_return_type(@nospecialize f::Any) = Any + Returns(Any) end Base.getindex(r::AtomicRef) = @atomic r.x