fix: @[nospecialize] is never template-like (#12663)

This PR avoids false-positive error messages on specialization
restrictions under the module system when the declaration is explicitly
marked as not specializable. It could also provide some minor public
size and rebuild savings.
This commit is contained in:
Sebastian Ullrich
2026-02-23 21:00:36 +01:00
committed by GitHub
parent 65e5053008
commit d0f8eb7bd6

View File

@@ -1017,7 +1017,7 @@ Return `true` if `decl` is supposed to be inlined/specialized.
-/
def Decl.isTemplateLike (decl : Decl pu) : CoreM Bool := do
let env getEnv
if hasLocalInst decl.type then
if !hasNospecializeAttribute env decl.name && ( hasLocalInst decl.type) then
return true -- `decl` applications will be specialized
else if ( isImplicitReducible decl.name) then
return true -- `decl` is "fuel" for code specialization