Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use lazy evaluation for useMethodImpl #5728

Merged
merged 1 commit into from
Oct 11, 2018
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
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