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

Commit19d5e37

Browse files
authored
Merge pull requestdotnet#4976 from Microsoft/merges/master-to-dev15.8
Merge master to dev15.8
2 parents582df28 +02ced05 commit19d5e37

File tree

3 files changed

+34
-25
lines changed

3 files changed

+34
-25
lines changed

‎src/fsharp/MethodOverrides.fs‎

Lines changed: 24 additions & 21 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
@@ -273,19 +273,20 @@ module DispatchSlotChecking =
273273
sink|> ignore
274274
()
275275
|[]->
276-
ifnot isOptional&&
276+
ifnot isOptional&&
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
|_->
@@ -475,7 +478,7 @@ module DispatchSlotChecking =
475478
// So here we get and yield all of those.
476479
for minfoin reqdTy|> GetIntrinsicMethInfosOfType infoReader(None,AccessibleFromSomewhere,AllowMultiIntfInstantiations.Yes) IgnoreOverrides reqdTyRangedo
477480
if minfo.IsDispatchSlotthen
478-
yield RequiredSlot(minfo,(*isOptional=*)false)]
481+
yield RequiredSlot(minfo,(*isOptional=*)not minfo.IsAbstract)]
479482

480483

481484
// Compute the methods that are available to implement abstract slots from the base class

‎src/fsharp/SignatureConformance.fs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,8 @@ type Checker(g, amap, denv, remapInfo: SignatureRepackageInfo, checkingSig) =
183183
letunimpl= ListSet.subtract(fun fity aity-> typeAEquiv g aenv aity fity) fintfs aintfs
184184
(unimpl|> List.forall(fun ity-> errorR(Error(FSComp.SR.DefinitionsInSigAndImplNotCompatibleMissingInterface(implTycon.TypeOrMeasureKind.ToString(),implTycon.DisplayName, NicePrint.minimalStringOfType denv ity),m));false))&&
185185
lethidden= ListSet.subtract(typeAEquiv g aenv) aintfsUser fintfs
186-
hidden|> List.iter(fun ity->(if implTycon.IsFSharpInterfaceTyconthen errorelse warning)(InterfaceNotRevealed(denv,ity,implTycon.Range)))
186+
letwarningOrError=if implTycon.IsFSharpInterfaceTyconthen errorelse warning
187+
hidden|> List.iter(fun ity-> warningOrError(InterfaceNotRevealed(denv,ity,implTycon.Range)))
187188

188189
letaNull= IsUnionTypeWithNullAsTrueValue g implTycon
189190
letfNull= IsUnionTypeWithNullAsTrueValue g sigTycon

‎src/fsharp/TypeChecker.fs‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10847,7 +10847,12 @@ and ApplyAbstractSlotInference (cenv:cenv) (envinner:TcEnv) (bindingTy, m, synTy
1084710847
if memberFlags.IsOverrideOrExplicitImpl then
1084810848

1084910849
// for error detection, we want to compare finality when testing for equivalence
10850-
let makeUniqueBySig meths = meths |> ListSet.setify (MethInfosEquivByNameAndSig EraseNone false cenv.g cenv.amap m)
10850+
let methInfosEquivByNameAndSig meths =
10851+
match meths with
10852+
| [] -> false
10853+
| head :: tail ->
10854+
tail |> List.forall (MethInfosEquivByNameAndSig EraseNone false cenv.g cenv.amap m head)
10855+
1085110856
match memberFlags.MemberKind with
1085210857
| MemberKind.Member ->
1085310858
let dispatchSlots, dispatchSlotsArityMatch =
@@ -10861,11 +10866,11 @@ and ApplyAbstractSlotInference (cenv:cenv) (envinner:TcEnv) (bindingTy, m, synTy
1086110866

1086210867
| slots ->
1086310868
match dispatchSlotsArityMatch with
10864-
| meths whenmeths |> makeUniqueBySig |> isSingleton -> meths
10869+
| meths whenmethInfosEquivByNameAndSig meths -> meths
1086510870
| [] ->
1086610871
let details =
1086710872
slots
10868-
|>List.map (NicePrint.stringOfMethInfo cenv.amap m envinner.DisplayEnv)
10873+
|>Seq.map (NicePrint.stringOfMethInfo cenv.amap m envinner.DisplayEnv)
1086910874
|> Seq.map (sprintf "%s %s" System.Environment.NewLine)
1087010875
|> String.concat ""
1087110876

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp