Why doesn't `@nospecialize` work in this example?

It’s all expected. Again, the caller is allowed to specialize wrt to inference, and in cases like this where the return type is Const that’s the end of the story. But in normal cases there will be only one LLVM implementation generated for all those “specializations.” MethodInstance ≠ LLVM code—@nospecialize does not directly affect caller inference, only codegen.

1 Like