Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Compiler/Checking/AugmentWithHashCompare.fs
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,7 @@ let slotImplMethod (final, c, slotsig) : ValMemberInfo =
IsDispatchSlot=false
IsFinal=final
IsOverrideOrExplicitImpl=true
GetterOrSetterIsCompilerGenerated=false
MemberKind=SynMemberKind.Member
Trivia=SynMemberFlagsTrivia.Zero}
IsImplemented=false
Expand All @@ -866,6 +867,7 @@ let nonVirtualMethod c : ValMemberInfo =
IsDispatchSlot=false
IsFinal=false
IsOverrideOrExplicitImpl=false
GetterOrSetterIsCompilerGenerated=false
MemberKind=SynMemberKind.Member
Trivia=SynMemberFlagsTrivia.Zero}
IsImplemented=false
Expand Down
5 changes: 3 additions & 2 deletions src/Compiler/Checking/CheckDeclarations.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4032,6 +4032,7 @@ module TcDeclarations =
let fldId = ident (CompilerGeneratedName id.idText, mMemberPortion)
let headPatIds = if isStatic then [id] else [ident ("__", mMemberPortion);id]
let headPat = SynPat.LongIdent (SynLongIdent(headPatIds, [], List.replicate headPatIds.Length None), None, Some noInferredTypars, SynArgPats.Pats [], None, mMemberPortion)
let memberFlags kind = Some { memberFlags kind with GetterOrSetterIsCompilerGenerated = true }

match propKind, mGetSetOpt with
| SynMemberKind.PropertySet, Some m -> errorR(Error(FSComp.SR.parsMutableOnAutoPropertyShouldBeGetSetNotJustSet(), m))
Expand All @@ -4046,7 +4047,7 @@ module TcDeclarations =
let rhsExpr = SynExpr.Ident fldId
let retInfo = match tyOpt with None -> None | Some ty -> Some (SynReturnInfo((ty, SynInfo.unnamedRetVal), ty.Range))
let attribs = mkAttributeList attribs mMemberPortion
let binding = mkSynBinding (xmlDoc, headPat) (access, false, false, mMemberPortion, DebugPointAtBinding.NoneAtInvisible, retInfo, rhsExpr, rhsExpr.Range, [], attribs, Some (memberFlags SynMemberKind.Member), SynBindingTrivia.Zero)
let binding = mkSynBinding (xmlDoc, headPat) (access, false, false, mMemberPortion, DebugPointAtBinding.NoneAtInvisible, retInfo, rhsExpr, rhsExpr.Range, [], attribs, memberFlags SynMemberKind.Member, SynBindingTrivia.Zero)
SynMemberDefn.Member (binding, mMemberPortion)
yield getter
| _ -> ()
Expand All @@ -4059,7 +4060,7 @@ module TcDeclarations =
let headPat = SynPat.LongIdent (SynLongIdent(headPatIds, [], List.replicate headPatIds.Length None), None, Some noInferredTypars, SynArgPats.Pats [mkSynPatVar None vId], None, mMemberPortion)
let rhsExpr = mkSynAssign (SynExpr.Ident fldId) (SynExpr.Ident vId)
//let retInfo = match tyOpt with None -> None | Some ty -> Some (SynReturnInfo((ty, SynInfo.unnamedRetVal), ty.Range))
let binding = mkSynBinding (xmlDoc, headPat) (access, false, false, mMemberPortion, DebugPointAtBinding.NoneAtInvisible, None, rhsExpr, rhsExpr.Range, [], [], Some (memberFlags SynMemberKind.PropertySet), SynBindingTrivia.Zero)
let binding = mkSynBinding (xmlDoc, headPat) (access, false, false, mMemberPortion, DebugPointAtBinding.NoneAtInvisible, None, rhsExpr, rhsExpr.Range, [], [], memberFlags SynMemberKind.PropertySet, SynBindingTrivia.Zero)
SynMemberDefn.Member (binding, mMemberPortion)
yield setter
| _ -> ()]
Expand Down
11 changes: 8 additions & 3 deletions src/Compiler/CodeGen/IlxGen.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2107,7 +2107,9 @@ type AssemblyBuilder(cenv: cenv, anonTypeTable: AnonTypeGenerationTable) as mgbu
[
for propName, fldName, fldTy in flds ->
let attrs = if isStruct then [ GenReadOnlyAttribute g ] else []

mkLdfldMethodDef ("get_" + propName, ILMemberAccess.Public, false, ilTy, fldName, fldTy, attrs)
|> g.AddMethodGeneratedAttributes
yield! genToStringMethod ilTy
]

Expand Down Expand Up @@ -8996,8 +8998,8 @@ and GenMethodForBinding

// Do not push the attributes to the method for events and properties
let ilAttrsCompilerGenerated =
if v.IsCompilerGenerated then
[ g.CompilerGeneratedAttribute ]
if v.IsCompilerGenerated || v.GetterOrSetterIsCompilerGenerated then
[ g.CompilerGeneratedAttribute; g.DebuggerNonUserCodeAttribute ]
else
[]

Expand Down Expand Up @@ -10760,7 +10762,9 @@ and GenTypeDef cenv mgbuf lazyInitInfo eenv m (tycon: Tycon) =
else
[]

yield mkLdfldMethodDef (ilMethName, access, isStatic, ilThisTy, ilFieldName, ilPropType, attrs)
yield
mkLdfldMethodDef (ilMethName, access, isStatic, ilThisTy, ilFieldName, ilPropType, attrs)
|> g.AddMethodGeneratedAttributes

// Generate property setter methods for the mutable fields
for useGenuineField, ilFieldName, isFSharpMutable, isStatic, _, ilPropType, isPropHidden, fspec in fieldSummaries do
Expand Down Expand Up @@ -10799,6 +10803,7 @@ and GenTypeDef cenv mgbuf lazyInitInfo eenv m (tycon: Tycon) =
)

mkILNonGenericInstanceMethod (ilMethName, iLAccess, ilParams, ilReturn, ilMethodBody)
|> g.AddMethodGeneratedAttributes

yield ilMethodDef.WithSpecialName

Expand Down
5 changes: 5 additions & 0 deletions src/Compiler/SyntaxTree/SyntaxTree.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1047,6 +1047,9 @@ type SynMemberFlags =

IsFinal: bool

// This is not persisted in pickling
GetterOrSetterIsCompilerGenerated: bool

MemberKind: SynMemberKind

Trivia: SynMemberFlagsTrivia
Expand All @@ -1059,6 +1062,7 @@ type SynMemberFlags =
&& this.IsDispatchSlot = other.IsDispatchSlot
&& this.IsOverrideOrExplicitImpl = other.IsOverrideOrExplicitImpl
&& this.IsFinal = other.IsFinal
&& this.GetterOrSetterIsCompilerGenerated = other.GetterOrSetterIsCompilerGenerated
&& this.MemberKind = other.MemberKind
| _ -> false

Expand All @@ -1067,6 +1071,7 @@ type SynMemberFlags =
+ hash this.IsDispatchSlot
+ hash this.IsOverrideOrExplicitImpl
+ hash this.IsFinal
+ hash this.GetterOrSetterIsCompilerGenerated
+ hash this.MemberKind

[<StructuralEquality; NoComparison; RequireQualifiedAccess>]
Expand Down
3 changes: 3 additions & 0 deletions src/Compiler/SyntaxTree/SyntaxTree.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -1203,6 +1203,9 @@ type SynMemberFlags =
/// The member is 'final'
IsFinal: bool

/// The member was generated by the compiler
GetterOrSetterIsCompilerGenerated: bool

/// The kind of the member
MemberKind: SynMemberKind

Expand Down
6 changes: 6 additions & 0 deletions src/Compiler/SyntaxTree/SyntaxTreeOps.fs
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,7 @@ let NonVirtualMemberFlags trivia k : SynMemberFlags =
IsDispatchSlot = false
IsOverrideOrExplicitImpl = false
IsFinal = false
GetterOrSetterIsCompilerGenerated = false
Trivia = trivia
}

Expand All @@ -707,6 +708,7 @@ let CtorMemberFlags trivia : SynMemberFlags =
IsDispatchSlot = false
IsOverrideOrExplicitImpl = false
IsFinal = false
GetterOrSetterIsCompilerGenerated = false
Trivia = trivia
}

Expand All @@ -717,6 +719,7 @@ let ClassCtorMemberFlags trivia : SynMemberFlags =
IsDispatchSlot = false
IsOverrideOrExplicitImpl = false
IsFinal = false
GetterOrSetterIsCompilerGenerated = false
Trivia = trivia
}

Expand All @@ -727,6 +730,7 @@ let OverrideMemberFlags trivia k : SynMemberFlags =
IsDispatchSlot = false
IsOverrideOrExplicitImpl = true
IsFinal = false
GetterOrSetterIsCompilerGenerated = false
Trivia = trivia
}

Expand All @@ -737,6 +741,7 @@ let AbstractMemberFlags trivia k : SynMemberFlags =
IsDispatchSlot = true
IsOverrideOrExplicitImpl = false
IsFinal = false
GetterOrSetterIsCompilerGenerated = false
Trivia = trivia
}

Expand All @@ -747,6 +752,7 @@ let StaticMemberFlags trivia k : SynMemberFlags =
IsDispatchSlot = false
IsOverrideOrExplicitImpl = false
IsFinal = false
GetterOrSetterIsCompilerGenerated = false
Trivia = trivia
}

Expand Down
2 changes: 2 additions & 0 deletions src/Compiler/TypedTree/TcGlobals.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1758,6 +1758,8 @@ type TcGlobals(

member _.CompilerGeneratedAttribute = mkCompilerGeneratedAttribute ()

member _.DebuggerNonUserCodeAttribute = mkDebuggerNonUserCodeAttribute ()

member _.MakeInternalsVisibleToAttribute(simpleAssemName) =
mkILCustomAttribute (tref_InternalsVisibleToAttribute, [ilg.typ_String], [ILAttribElem.String (Some simpleAssemName)], [])

Expand Down
5 changes: 4 additions & 1 deletion src/Compiler/TypedTree/TypedTree.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2783,6 +2783,10 @@ type Val =
///
/// Note: this is true for the overrides generated by hash/compare augmentations
member x.IsCompilerGenerated = x.val_flags.IsCompilerGenerated

/// Indicates that this value's getter or setter are generated by the compiler
member x.GetterOrSetterIsCompilerGenerated =
x.MemberInfo |> Option.exists (fun m -> m.MemberFlags.GetterOrSetterIsCompilerGenerated = true)

/// Get the declared attributes for the value
member x.Attribs =
Expand Down Expand Up @@ -5955,4 +5959,3 @@ type Construct() =
let pos = Position.mkPos line (max 0 (column - 1))
mkRange filePath pos pos |> Some
#endif

3 changes: 3 additions & 0 deletions src/Compiler/TypedTree/TypedTree.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -2001,6 +2001,9 @@ type Val =
/// Note: this is true for the overrides generated by hash/compare augmentations
member IsCompilerGenerated: bool

/// Indicates that this value's getter or setter are generated by the compiler
member GetterOrSetterIsCompilerGenerated: bool

/// Indicates if this is an F#-defined 'new' constructor member
member IsConstructor: bool

Expand Down
1 change: 1 addition & 0 deletions src/Compiler/TypedTree/TypedTreePickle.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1499,6 +1499,7 @@ let u_MemberFlags st : SynMemberFlags=
IsDispatchSlot=x4
IsOverrideOrExplicitImpl=x5
IsFinal=x6
GetterOrSetterIsCompilerGenerated=false
MemberKind=x7
Trivia = SynMemberFlagsTrivia.Zero }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@
.method public strict virtual instance string
ToString() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
// Code size 22 (0x16)
.maxstack 8
IL_0000: ldstr "%+A"
Expand All @@ -224,7 +224,8 @@
.method public hidebysig virtual final
instance int32 CompareTo(class CCtorDUWithMember01a/C obj) cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [mscorlib]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 )
// Code size 39 (0x27)
.maxstack 4
.locals init (int32 V_0,
Expand Down Expand Up @@ -269,7 +270,8 @@
.method public hidebysig virtual final
instance int32 CompareTo(object obj) cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [mscorlib]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 )
// Code size 13 (0xd)
.maxstack 8
IL_0000: ldarg.0
Expand All @@ -283,7 +285,8 @@
instance int32 CompareTo(object obj,
class [mscorlib]System.Collections.IComparer comp) cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [mscorlib]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 )
// Code size 56 (0x38)
.maxstack 4
.locals init (class CCtorDUWithMember01a/C V_0,
Expand Down Expand Up @@ -334,7 +337,8 @@
.method public hidebysig virtual final
instance int32 GetHashCode(class [mscorlib]System.Collections.IEqualityComparer comp) cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [mscorlib]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 )
// Code size 14 (0xe)
.maxstack 3
.locals init (int32 V_0)
Expand All @@ -354,7 +358,8 @@
.method public hidebysig virtual final
instance int32 GetHashCode() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [mscorlib]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 )
// Code size 12 (0xc)
.maxstack 8
IL_0000: ldarg.0
Expand All @@ -367,7 +372,8 @@
instance bool Equals(object obj,
class [mscorlib]System.Collections.IEqualityComparer comp) cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [mscorlib]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 )
// Code size 44 (0x2c)
.maxstack 4
.locals init (class CCtorDUWithMember01a/C V_0,
Expand Down Expand Up @@ -422,7 +428,8 @@
.method public hidebysig virtual final
instance bool Equals(class CCtorDUWithMember01a/C obj) cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [mscorlib]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 )
// Code size 35 (0x23)
.maxstack 4
.locals init (int32 V_0,
Expand Down Expand Up @@ -458,7 +465,8 @@
.method public hidebysig virtual final
instance bool Equals(object obj) cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [mscorlib]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 )
// Code size 20 (0x14)
.maxstack 4
.locals init (class CCtorDUWithMember01a/C V_0)
Expand Down
Loading