Skip to content

Commit

Permalink
Use lazy evaluation for useMethodImpl (#5728)
Browse files Browse the repository at this point in the history
  • Loading branch information
forki authored and KevinRansom committed Oct 11, 2018
1 parent 2e4e60f commit e42cea2
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions src/fsharp/IlxGen.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5121,25 +5121,32 @@ and ComputeFlagFixupsForMemberBinding cenv (v:Val,memberInfo:ValMemberInfo) =
let otcref = tcrefOfAppTy cenv.g oty
let tcref = v.MemberApparentEntity

let useMethodImpl =
// REVIEW: it would be good to get rid of this special casing of Compare and GetHashCode during code generation
let isCompare =
(Option.isSome tcref.GeneratedCompareToValues && typeEquiv cenv.g oty cenv.g.mk_IComparable_ty) ||
(Option.isSome tcref.GeneratedCompareToValues && tyconRefEq cenv.g cenv.g.system_GenericIComparable_tcref otcref)

let isGenericEquals =
(Option.isSome tcref.GeneratedHashAndEqualsWithComparerValues && tyconRefEq cenv.g cenv.g.system_GenericIEquatable_tcref otcref)

let isStructural =
(Option.isSome tcref.GeneratedCompareToWithComparerValues && typeEquiv cenv.g oty cenv.g.mk_IStructuralComparable_ty) ||
(Option.isSome tcref.GeneratedHashAndEqualsWithComparerValues && typeEquiv cenv.g oty cenv.g.mk_IStructuralEquatable_ty)
isInterfaceTy cenv.g oty && not isCompare && not isStructural && not isGenericEquals
let useMethodImpl =
// REVIEW: it would be good to get rid of this special casing of Compare and GetHashCode during code generation
isInterfaceTy cenv.g oty &&
(let isCompare =
Option.isSome tcref.GeneratedCompareToValues &&
(typeEquiv cenv.g oty cenv.g.mk_IComparable_ty ||
tyconRefEq cenv.g cenv.g.system_GenericIComparable_tcref otcref)

not isCompare) &&

(let isGenericEquals =
Option.isSome tcref.GeneratedHashAndEqualsWithComparerValues && tyconRefEq cenv.g cenv.g.system_GenericIEquatable_tcref otcref

not isGenericEquals) &&
(let isStructural =
(Option.isSome tcref.GeneratedCompareToWithComparerValues && typeEquiv cenv.g oty cenv.g.mk_IStructuralComparable_ty) ||
(Option.isSome tcref.GeneratedHashAndEqualsWithComparerValues && typeEquiv cenv.g oty cenv.g.mk_IStructuralEquatable_ty)

not isStructural)

let nameOfOverridingMethod = GenNameOfOverridingMethod cenv (useMethodImpl,slotsig)

(if useMethodImpl then fixupMethodImplFlags >> renameMethodDef nameOfOverridingMethod
else fixupVirtualSlotFlags >> renameMethodDef nameOfOverridingMethod))
if useMethodImpl then
fixupMethodImplFlags >> renameMethodDef nameOfOverridingMethod
else
fixupVirtualSlotFlags >> renameMethodDef nameOfOverridingMethod)

and ComputeMethodImplAttribs cenv (_v:Val) attrs =
let implflags =
Expand Down

0 comments on commit e42cea2

Please sign in to comment.