Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit02ced05

Browse files
forkiKevinRansom
authored andcommitted
Don't get CompileSig over and over again (#4970)
* compileSig* compileSig* compileSig* compileSig* compileSig* compileSig
1 parent941d05c commit02ced05

File tree

1 file changed

+22
-19
lines changed

1 file changed

+22
-19
lines changed

‎src/fsharp/MethodOverrides.fs‎

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -157,23 +157,22 @@ module DispatchSlotChecking =
157157
letIsImplMatch g(dispatchSlot:MethInfo)(overrideBy:OverrideInfo)=
158158
// If the override is listed as only relevant to one type, and we're matching it against an abstract slot of an interface type,
159159
// then check that interface type is the right type.
160-
(match overrideBy.CanImplementwith
161-
| CanImplementNoSlots->false
162-
| CanImplementAnySlot->true
163-
| CanImplementAnyClassHierarchySlot->not(isInterfaceTy g dispatchSlot.ApparentEnclosingType)
164-
| CanImplementAnyInterfaceSlot-> isInterfaceTy g dispatchSlot.ApparentEnclosingType)
160+
match overrideBy.CanImplementwith
161+
| CanImplementNoSlots->false
162+
| CanImplementAnySlot->true
163+
| CanImplementAnyClassHierarchySlot->not(isInterfaceTy g dispatchSlot.ApparentEnclosingType)
164+
| CanImplementAnyInterfaceSlot-> isInterfaceTy g dispatchSlot.ApparentEnclosingType
165165

166166
/// Check if the kinds of type parameters match between a dispatch slot and an override.
167-
letIsTyparKindMatch g amap m(dispatchSlot:MethInfo)(Override(_,_,_,(mtps,_),_,_,_,_))=
168-
let(CompiledSig(_,_,fvmtps,_))= CompiledSigOfMeth g amap m dispatchSlot
167+
letIsTyparKindMatch(CompiledSig(_,_,fvmtps,_))(Override(_,_,_,(mtps,_),_,_,_,_))=
169168
List.lengthsEqAndForall2(fun(tp1:Typar)(tp2:Typar)-> tp1.Kind= tp2.Kind) mtps fvmtps
170169

171170
/// Check if an override is a partial match for the requirements for a dispatch slot
172-
letIsPartialMatch gamap m(dispatchSlot:MethInfo)(Override(_,_,_,(mtps,_),argTys,_retTy,_,_)as overrideBy)=
171+
letIsPartialMatch g(dispatchSlot:MethInfo)compiledSig(Override(_,_,_,(mtps,_),argTys,_retTy,_,_)as overrideBy)=
173172
IsNameMatch dispatchSlot overrideBy&&
174-
let(CompiledSig(vargtys,_,fvmtps,_))=CompiledSigOfMeth g amap m dispatchSlot
173+
let(CompiledSig(vargtys,_,fvmtps,_))=compiledSig
175174
mtps.Length= fvmtps.Length&&
176-
IsTyparKindMatchg amap m dispatchSlot overrideBy&&
175+
IsTyparKindMatchcompiledSig overrideBy&&
177176
argTys.Length= vargtys.Length&&
178177
IsImplMatch g dispatchSlot overrideBy
179178

@@ -187,8 +186,9 @@ module DispatchSlotChecking =
187186

188187
/// Check if an override exactly matches the requirements for a dispatch slot
189188
letIsExactMatch g amap m dispatchSlot(Override(_,_,_,(mtps,mtpinst),argTys,retTy,_,_)as overrideBy)=
190-
IsPartialMatch g amap m dispatchSlot overrideBy&&
191-
let(CompiledSig(vargtys,vrty,fvmtps,ttpinst))= CompiledSigOfMeth g amap m dispatchSlot
189+
letcompiledSig= CompiledSigOfMeth g amap m dispatchSlot
190+
IsPartialMatch g dispatchSlot compiledSig overrideBy&&
191+
let(CompiledSig(vargtys,vrty,fvmtps,ttpinst))= compiledSig
192192

193193
// Compare the types. CompiledSigOfMeth, GetObjectExprOverrideInfo and GetTypeMemberOverrideInfo have already
194194
// applied all relevant substitutions except the renamings from fvtmps <-> mtps
@@ -277,15 +277,16 @@ module DispatchSlotChecking =
277277
// Check that no available prior override implements this dispatch slot
278278
not(DispatchSlotIsAlreadyImplemented g amap m availPriorOverridesKeyed dispatchSlot)
279279
then
280-
// error reporting path
281-
let(CompiledSig(vargtys,_vrty,fvmtps,_))= CompiledSigOfMeth g amap m dispatchSlot
280+
// error reporting path
281+
letcompiledSig= CompiledSigOfMeth g amap m dispatchSlot
282+
282283
letnoimpl()=
283284
if isReqdTyInterfacethen
284285
fail(Error(FSComp.SR.typrelNoImplementationGivenWithSuggestion(NicePrint.stringOfMethInfo amap m denv dispatchSlot), m))
285286
else
286287
fail(Error(FSComp.SR.typrelNoImplementationGiven(NicePrint.stringOfMethInfo amap m denv dispatchSlot), m))
287-
288-
match overrides|> List.filter(IsPartialMatch gamap mdispatchSlot)with
288+
289+
match overrides|> List.filter(IsPartialMatch g dispatchSlot compiledSig)with
289290
|[]->
290291
letpossibleOverrides=
291292
overrides
@@ -300,7 +301,9 @@ module DispatchSlotChecking =
300301
|> List.filter(fun(RequiredSlot(dispatchSlot,_))-> IsNameMatch dispatchSlot overrideBy&& IsImplMatch g dispatchSlot overrideBy)
301302
|> isNilOrSingleton
302303
|>not
303-
304+
305+
let(CompiledSig(vargtys,_,fvmtps,_))= compiledSig
306+
304307
if moreThanOnePossibleDispatchSlotthen
305308
// Error will be reported below in CheckOverridesAreAllUsedOnce
306309
()
@@ -309,7 +312,7 @@ module DispatchSlotChecking =
309312
fail(Error(FSComp.SR.typrelMemberDoesNotHaveCorrectNumberOfArguments(FormatOverride denv overrideBy, FormatMethInfoSig g amap m denv dispatchSlot), overrideBy.Range))
310313
elif mtps.Length<> fvmtps.Lengththen
311314
fail(Error(FSComp.SR.typrelMemberDoesNotHaveCorrectNumberOfTypeParameters(FormatOverride denv overrideBy, FormatMethInfoSig g amap m denv dispatchSlot), overrideBy.Range))
312-
elifnot(IsTyparKindMatchg amap m dispatchSlot overrideBy)then
315+
elifnot(IsTyparKindMatchcompiledSig overrideBy)then
313316
fail(Error(FSComp.SR.typrelMemberDoesNotHaveCorrectKindsOfGenericParameters(FormatOverride denv overrideBy, FormatMethInfoSig g amap m denv dispatchSlot), overrideBy.Range))
314317
else
315318
fail(Error(FSComp.SR.typrelMemberCannotImplement(FormatOverride denv overrideBy, NicePrint.stringOfMethInfo amap m denv dispatchSlot, FormatMethInfoSig g amap m denv dispatchSlot), overrideBy.Range))
@@ -343,7 +346,7 @@ module DispatchSlotChecking =
343346
match relevantVirts|> List.filter(fun dispatchSlot-> OverrideImplementsDispatchSlot g amap m dispatchSlot overrideBy)with
344347
|[]->
345348
// This is all error reporting
346-
match relevantVirts|> List.filter(fun dispatchSlot-> IsPartialMatch g amap m dispatchSlot overrideBy)with
349+
match relevantVirts|> List.filter(fun dispatchSlot-> IsPartialMatch gdispatchSlot(CompiledSigOfMeth gamap m dispatchSlot) overrideBy)with
347350
|[dispatchSlot]->
348351
errorR(OverrideDoesntOverride(denv,overrideBy,Some dispatchSlot,g,amap,m))
349352
|_->

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp