Skip to content
Merged
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
20 changes: 12 additions & 8 deletions src/fsharp/AugmentWithHashCompare.fs
Original file line number Diff line number Diff line change
Expand Up @@ -883,11 +883,15 @@ let nonVirtualMethod c : ValMemberInfo =
let unitArg = ValReprInfo.unitArgData
let unaryArg = [ ValReprInfo.unnamedTopArg ]
let tupArg = [ [ ValReprInfo.unnamedTopArg1; ValReprInfo.unnamedTopArg1 ] ]
let mkValSpec g (tcref: TyconRef) tmty vis slotsig methn ty argData =
let mkValSpec g (tcref: TyconRef) tmty vis slotsig methn ty argData =
let m = tcref.Range
let tps = tcref.Typars m
let final = isUnionTy g tmty || isRecdTy g tmty || isStructTy g tmty
let membInfo = match slotsig with None -> nonVirtualMethod tcref | Some slotsig -> slotImplMethod(final, tcref, slotsig)
let membInfo =
match slotsig with
| None -> nonVirtualMethod tcref
| Some slotsig ->
let final = isUnionTy g tmty || isRecdTy g tmty || isStructTy g tmty
slotImplMethod(final, tcref, slotsig)
let inl = ValInline.Optional
let args = ValReprInfo.unnamedTopArg :: argData
let topValInfo = Some (ValReprInfo (ValReprInfo.InferTyparInfo tps, args, ValReprInfo.unnamedRetVal))
Expand All @@ -899,8 +903,8 @@ let MakeValsForCompareAugmentation g (tcref: TyconRef) =
let tps = tcref.Typars m
let vis = tcref.TypeReprAccessibility

mkValSpec g tcref tmty vis (Some(mkIComparableCompareToSlotSig g)) "CompareTo" (tps +-> (mkCompareObjTy g tmty)) unaryArg,
mkValSpec g tcref tmty vis (Some(mkGenericIComparableCompareToSlotSig g tmty)) "CompareTo" (tps +-> (mkCompareTy g tmty)) unaryArg
mkValSpec g tcref tmty vis (Some(mkIComparableCompareToSlotSig g)) "CompareTo" (tps +-> (mkCompareObjTy g tmty)) unaryArg,
mkValSpec g tcref tmty vis (Some(mkGenericIComparableCompareToSlotSig g tmty)) "CompareTo" (tps +-> (mkCompareTy g tmty)) unaryArg

let MakeValsForCompareWithComparerAugmentation g (tcref: TyconRef) =
let m = tcref.Range
Expand All @@ -915,15 +919,15 @@ let MakeValsForEqualsAugmentation g (tcref: TyconRef) =
let vis = tcref.TypeReprAccessibility
let tps = tcref.Typars m

let objEqualsVal = mkValSpec g tcref tmty vis (Some(mkEqualsSlotSig g)) "Equals" (tps +-> (mkEqualsObjTy g tmty)) unaryArg
let nocEqualsVal = mkValSpec g tcref tmty vis (if tcref.Deref.IsExceptionDecl then None else Some(mkGenericIEquatableEqualsSlotSig g tmty)) "Equals" (tps +-> (mkEqualsTy g tmty)) unaryArg
let objEqualsVal = mkValSpec g tcref tmty vis (Some(mkEqualsSlotSig g)) "Equals" (tps +-> (mkEqualsObjTy g tmty)) unaryArg
let nocEqualsVal = mkValSpec g tcref tmty vis (if tcref.Deref.IsExceptionDecl then None else Some(mkGenericIEquatableEqualsSlotSig g tmty)) "Equals" (tps +-> (mkEqualsTy g tmty)) unaryArg
objEqualsVal, nocEqualsVal

let MakeValsForEqualityWithComparerAugmentation g (tcref: TyconRef) =
let _, tmty = mkMinimalTy g tcref
let vis = tcref.TypeReprAccessibility
let tps = tcref.Typars tcref.Range
let objGetHashCodeVal = mkValSpec g tcref tmty vis (Some(mkGetHashCodeSlotSig g)) "GetHashCode" (tps +-> (mkHashTy g tmty)) unitArg
let objGetHashCodeVal = mkValSpec g tcref tmty vis (Some(mkGetHashCodeSlotSig g)) "GetHashCode" (tps +-> (mkHashTy g tmty)) unitArg
let withcGetHashCodeVal = mkValSpec g tcref tmty vis (Some(mkIStructuralEquatableGetHashCodeSlotSig g)) "GetHashCode" (tps +-> (mkHashWithComparerTy g tmty)) unaryArg
let withcEqualsVal = mkValSpec g tcref tmty vis (Some(mkIStructuralEquatableEqualsSlotSig g)) "Equals" (tps +-> (mkEqualsWithComparerTy g tmty)) tupArg
objGetHashCodeVal, withcGetHashCodeVal, withcEqualsVal
Expand Down