Skip to content

Commit c9bed79

Browse files
authored
Revert ILTypeDef custom attributes changes (#17503)
1 parent 5e035e2 commit c9bed79

File tree

9 files changed

+88
-26
lines changed

9 files changed

+88
-26
lines changed

src/Compiler/AbstractIL/il.fs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2686,7 +2686,7 @@ type ILTypeDef
26862686
properties,
26872687
additionalFlags,
26882688
storeILSecurityDecls securityDecls,
2689-
storeILCustomAttrs customAttrs,
2689+
customAttrs,
26902690
NoMetadataIdx
26912691
)
26922692

@@ -2762,7 +2762,7 @@ type ILTypeDef
27622762
events = defaultArg events x.Events,
27632763
properties = defaultArg properties x.Properties,
27642764
additionalFlags = defaultArg newAdditionalFlags additionalFlags,
2765-
customAttrs = defaultArg customAttrs (x.CustomAttrs)
2765+
customAttrs = defaultArg customAttrs (x.CustomAttrsStored)
27662766
)
27672767

27682768
member x.CustomAttrs: ILAttributes =
@@ -4259,7 +4259,7 @@ let mkILGenericClass (nm, access, genparams, extends, impl, methods, fields, nes
42594259
methods = methods,
42604260
fields = fields,
42614261
nestedTypes = nestedTypes,
4262-
customAttrs = attrs,
4262+
customAttrs = storeILCustomAttrs attrs,
42634263
methodImpls = emptyILMethodImpls,
42644264
properties = props,
42654265
events = events,
@@ -4284,7 +4284,7 @@ let mkRawDataValueTypeDef (iltyp_ValueType: ILType) (nm, size, pack) =
42844284
methods = emptyILMethods,
42854285
fields = emptyILFields,
42864286
nestedTypes = emptyILTypeDefs,
4287-
customAttrs = emptyILCustomAttrs,
4287+
customAttrs = emptyILCustomAttrsStored,
42884288
methodImpls = emptyILMethodImpls,
42894289
properties = emptyILProperties,
42904290
events = emptyILEvents,

src/Compiler/AbstractIL/il.fsi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1548,7 +1548,7 @@ type ILTypeDef =
15481548
properties: ILPropertyDefs *
15491549
additionalFlags: ILTypeDefAdditionalFlags *
15501550
securityDecls: ILSecurityDecls *
1551-
customAttrs: ILAttributes ->
1551+
customAttrs: ILAttributesStored ->
15521552
ILTypeDef
15531553

15541554
member Name: string
@@ -1616,7 +1616,7 @@ type ILTypeDef =
16161616
?events: ILEventDefs *
16171617
?properties: ILPropertyDefs *
16181618
?newAdditionalFlags: ILTypeDefAdditionalFlags *
1619-
?customAttrs: ILAttributes *
1619+
?customAttrs: ILAttributesStored *
16201620
?securityDecls: ILSecurityDecls *
16211621
?implementsCustomAttrs: (ILAttributesStored * int) list option ->
16221622
ILTypeDef

src/Compiler/AbstractIL/ilmorph.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ let rec tdef_ty2ty_ilmbody2ilmbody_mdefs2mdefs isInKnownSet enc fs (tdef: ILType
378378
methodImpls = mimpls_ty2ty fTyInCtxtR tdef.MethodImpls,
379379
events = edefs_ty2ty fTyInCtxtR tdef.Events,
380380
properties = pdefs_ty2ty fTyInCtxtR tdef.Properties,
381-
customAttrs = cattrs_ty2ty fTyInCtxtR tdef.CustomAttrs
381+
customAttrs = storeILCustomAttrs (cattrs_ty2ty fTyInCtxtR tdef.CustomAttrs)
382382
)
383383

384384
and tdefs_ty2ty_ilmbody2ilmbody_mdefs2mdefs isInKnownSet enc fs tdefs =

src/Compiler/CodeGen/EraseClosures.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ let rec convIlxClosureDef cenv encl (td: ILTypeDef) clo =
579579
extends = Some cenv.mkILTyFuncTy,
580580
methods = mkILMethods (ctorMethodDef :: nowApplyMethDef :: nowMethods),
581581
fields = mkILFields (mkILCloFldDefs cenv nowFields @ td.Fields.AsList()),
582-
customAttrs = emptyILCustomAttrs,
582+
customAttrs = emptyILCustomAttrsStored,
583583
methodImpls = emptyILMethodImpls,
584584
properties = emptyILProperties,
585585
events = emptyILEvents,
@@ -714,7 +714,7 @@ let rec convIlxClosureDef cenv encl (td: ILTypeDef) clo =
714714
extends = Some nowEnvParentClass,
715715
methods = mkILMethods (ctorMethodDef :: nowApplyMethDef :: nowMethods),
716716
fields = mkILFields (mkILCloFldDefs cenv nowFields @ td.Fields.AsList()),
717-
customAttrs = emptyILCustomAttrs,
717+
customAttrs = emptyILCustomAttrsStored,
718718
methodImpls = emptyILMethodImpls,
719719
properties = emptyILProperties,
720720
events = emptyILEvents,

src/Compiler/CodeGen/EraseUnions.fs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1574,7 +1574,7 @@ let mkClassUnionDef
15741574
events = emptyILEvents,
15751575
properties = emptyILProperties,
15761576
additionalFlags = ILTypeDefAdditionalFlags.None,
1577-
customAttrs = emptyILCustomAttrs
1577+
customAttrs = emptyILCustomAttrsStored
15781578
)
15791579
.WithNestedAccess(cud.UnionCasesAccessibility)
15801580
.WithAbstract(true)
@@ -1621,8 +1621,9 @@ let mkClassUnionDef
16211621
td.CustomAttrs.AsArray()
16221622
|> Array.append [| GetNullableAttribute g [ FSharp.Compiler.TypedTree.NullnessInfo.WithNull ] |]
16231623
|> mkILCustomAttrsFromArray
1624+
|> storeILCustomAttrs
16241625
else
1625-
td.CustomAttrs
1626+
td.CustomAttrsStored
16261627
)
16271628
// The .cctor goes on the Cases type since that's where the constant fields for nullary constructors live
16281629
|> addConstFieldInit

src/Compiler/CodeGen/IlxGen.fs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1924,7 +1924,7 @@ type TypeDefBuilder(tdef: ILTypeDef, tdefDiscards) =
19241924
properties = mkILProperties (tdef.Properties.AsList() @ HashRangeSorted gproperties),
19251925
events = mkILEvents (ResizeArray.toList gevents),
19261926
nestedTypes = mkILTypeDefs (tdef.NestedTypes.AsList() @ gnested.Close(g)),
1927-
customAttrs = attrs
1927+
customAttrs = storeILCustomAttrs attrs
19281928
)
19291929

19301930
member _.AddEventDef edef = gevents.Add edef
@@ -6237,6 +6237,7 @@ and GenStructStateMachine cenv cgbuf eenvouter (res: LoweredStateMachine) sequel
62376237
mkCompilationMappingAttr g (int SourceConstructFlags.Closure)
62386238
]
62396239
|> mkILCustomAttrs
6240+
|> storeILCustomAttrs
62406241

62416242
let cloTypeDef =
62426243
ILTypeDef(
@@ -6670,6 +6671,7 @@ and GenClosureTypeDefs
66706671
let customAttrs =
66716672
attrs @ [ mkCompilationMappingAttr g (int SourceConstructFlags.Closure) ]
66726673
|> mkILCustomAttrs
6674+
|> storeILCustomAttrs
66736675

66746676
let tdef =
66756677
ILTypeDef(
@@ -11370,7 +11372,7 @@ and GenTypeDef cenv mgbuf lazyInitInfo eenv m (tycon: Tycon) : ILTypeRef option
1137011372
| TILObjectRepr _ ->
1137111373
let tdef = tycon.ILTyconRawMetadata.WithAccess tyconAccess
1137211374

11373-
let customAttrs = ilCustomAttrs |> mkILCustomAttrs
11375+
let customAttrs = ilCustomAttrs |> mkILCustomAttrs |> storeILCustomAttrs
1137411376

1137511377
let tdef = tdef.With(customAttrs = customAttrs, genericParams = ilGenParams)
1137611378

@@ -11594,6 +11596,7 @@ and GenTypeDef cenv mgbuf lazyInitInfo eenv m (tycon: Tycon) : ILTypeRef option
1159411596
))
1159511597
]
1159611598
|> mkILCustomAttrs
11599+
|> storeILCustomAttrs
1159711600

1159811601
let tdef =
1159911602
ILTypeDef(

0 commit comments

Comments
 (0)