Skip to content

optimizer: @nospecialize annotation doesn't work when applied to unnamed argument #44428

@aviatesk

Description

@aviatesk
julia> @noinline valid(@nospecialize x::Any) = Base.inferencebarrier(0)
valid (generic function with 1 method)

julia> @noinline invalid1(@nospecialize ::Any) = Base.inferencebarrier(0)
invalid1 (generic function with 1 method)

julia> @noinline invalid2(@nospecialize ::Any) = Base.inferencebarrier(0)
invalid2 (generic function with 1 method)

julia> code_typed((Any,)) do x
           valid(x), invalid1(x), invalid2(x)
       end
1-element Vector{Any}:
 CodeInfo(
1%1 = invoke Main.valid(x::Any)::Any%2 = Main.invalid1(x)::Any%3 = Main.invalid2(x)::Any%4 = Core.tuple(%1, %2, %3)::Tuple{Any, Any, Any}
└──      return %4
) => Tuple{Any, Any, Any}

Here calls to invalid1 and invalid2 should be resolved statically (i.e. resolved to :invoke expressions) since their ::Any-argument is explicitly declared as @nospecialize.

Metadata

Metadata

Assignees

No one assigned

    Labels

    compiler:loweringSyntax lowering (compiler front end, 2nd stage)macros@macrostypes and dispatchTypes, subtyping and method dispatch

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions