feat: make computed_fields respect inline (#12580)
This PR makes `computed_field` respect the inline attributes on the function for computing the field. This means we can inline the accessor for the field, allowing quicker access.
This commit is contained in:
parent
14c973db4e
commit
88ecacea4e
2 changed files with 7 additions and 2 deletions
|
|
@ -186,8 +186,9 @@ def overrideComputedFields : M Unit := do
|
|||
← getComputedFieldValue cfn (mkAppN (mkConst ctor lparams) (params ++ fields))
|
||||
else
|
||||
mkLambdaFVars (compFieldVars ++ fields) cf
|
||||
let cfnOverride := cfn ++ `_override
|
||||
addDecl <| .defnDecl {
|
||||
name := cfn ++ `_override
|
||||
name := cfnOverride
|
||||
levelParams
|
||||
type := ← mkForallFVars (params ++ indices ++ #[val]) (← inferType cf)
|
||||
value := ← mkLambdaFVars (params ++ indices ++ #[val]) <|
|
||||
|
|
@ -197,7 +198,9 @@ def overrideComputedFields : M Unit := do
|
|||
safety := .unsafe
|
||||
hints := .opaque
|
||||
}
|
||||
setImplementedBy cfn (cfn ++ `_override)
|
||||
if let some inlineAttr := Compiler.getInlineAttribute? (← getEnv) cfn then
|
||||
setInlineAttribute cfnOverride inlineAttr
|
||||
setImplementedBy cfn cfnOverride
|
||||
|
||||
def mkComputedFieldOverrides (declName : Name) (compFields : Array Name) : MetaM Unit := do
|
||||
let ind ← getConstInfoInduct declName
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
#include "util/options.h"
|
||||
|
||||
// update thy
|
||||
|
||||
namespace lean {
|
||||
options get_default_options() {
|
||||
options opts;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue