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

Commit5a54ebd

Browse files
realvictorprmKevinRansom
authored andcommitted
*Fixdotnet#5531This is a working fix for the example ofdotnet#5531.However there are still some points open before I think it's a good idea to merge this:- Discuss the change of this proposal, is it OK to prefer overrides of methods and so ignore base implementations?- Extend the check to the complete inheritance graph instead of a single "look-back"- Only ignore a methinfo if the signature of both match (so respect different overloads)@dsyme It would be great if you could have a look whether this check is allowed at this location or should appear earlier.* Fix left points.Signed-off-by: realvictorprm <mueller.vpr@gmail.com>* another approach to fix* remove old approach* Remove approach again and apply different approach.Signed-off-by: realvictorprm <mueller.vpr@gmail.com>* Adjusting predicate to reflect correct behaviour.* Revert to old List.merge strategy.* Apply review and add testsSigned-off-by: realvictorprm <mueller.vpr@gmail.com>* Try fixing weird CI failureSigned-off-by: realvictorprm <mueller.vpr@gmail.com>* Fix test.Signed-off-by: realvictorprm <mueller.vpr@gmail.com>
1 parent4a9cc93 commit5a54ebd

File tree

7 files changed

+78
-0
lines changed

7 files changed

+78
-0
lines changed

‎src/fsharp/ConstraintSolver.fs‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1491,7 +1491,14 @@ and GetRelevantMethodsForTrait (csenv:ConstraintSolverEnv) permitWeakResolution
14911491
/// to a generic instantiation for an operator based on the right hand type.
14921492
14931493
letminfos= List.reduce(ListSet.unionFavourLeft MethInfo.MethInfosUseIdenticalDefinitions) minfos
1494+
1495+
/// Check that the available members aren't hiding a member from the parent (depth 1 only)
1496+
letrelevantMinfos= minfos|> List.filter(fun minfo->not minfo.IsDispatchSlot&&not minfo.IsVirtual&& minfo.IsInstance)
14941497
minfos
1498+
|> List.filter(fun minfo1->
1499+
not(minfo1.IsDispatchSlot&&
1500+
relevantMinfos
1501+
|> List.exists(fun minfo2-> MethInfosEquivByNameAndSig EraseAlltrue csenv.g csenv.amap m minfo2 minfo1)))
14951502
else
14961503
[]
14971504
// The trait name "op_Explicit" also covers "op_Implicit", so look for that one too.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
test.fs(7,17): warning FS0864: Thisnew member hides the abstract member 'abstract member Base.Foo : unit-> unit'. Rename the memberor use 'override' instead.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
test.fs(7,17): warning FS0864: This new member hides the abstract member 'abstract member Base.Foo : unit -> unit'. Rename the member or use 'override' instead.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Base
2+
Base
3+
Derived
4+
Base
5+
Base
6+
Base
7+
Derived
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Base
2+
Base
3+
Derived
4+
Base
5+
Base
6+
Base
7+
Derived
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
typeBase()=
2+
abstractmemberFoo :unit->unit
3+
defaultthis.Foo()= printfn"Base"
4+
5+
typeDerived()=
6+
inherit Base()
7+
memberthis.Foo()= printfn"Derived"
8+
9+
let inlinecallFoo<^Twhen^T:(member Foo:unit->unit)>(t:^T)=
10+
(^T:(memberFoo: unit-> unit)(t))
11+
12+
letb= Base()
13+
letd= Derived()
14+
letbd= d:> Base
15+
16+
b.Foo()
17+
bd.Foo()
18+
d.Foo()
19+
20+
callFoo<Base> b
21+
callFoo<Base> bd
22+
callFoo<Base> d
23+
callFoo<Derived> d

‎tests/fsharp/tests.fs‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1755,6 +1755,36 @@ module RegressionTests =
17551755
//// [<Test >]
17561756
//// let ``struct-tuple-bug-1-FSI_BASIC`` () = singleTestBuildAndRun "regression/struct-tuple-bug-1" FSI_BASIC
17571757

1758+
#if!FSHARP_SUITE_DRIVES_CORECLR_TESTS
1759+
[<Test>]
1760+
let``SRTP doesn't handle calling member hiding hinherited members``()=
1761+
letcfg= testConfig"regression/5531"
1762+
1763+
letoutFile="compilation.output.test.txt"
1764+
letexpectedFile="compilation.output.test.bsl"
1765+
1766+
fscBothToOut cfg outFile"%s --nologo -O" cfg.fsc_flags["test.fs"]
1767+
1768+
letdiff= fsdiff cfg outFile expectedFile
1769+
1770+
match diffwith
1771+
|""->()
1772+
|_->
1773+
Assert.Fail(sprintf"'%s' and '%s' differ;%A"(getfullpath cfg outFile)(getfullpath cfg expectedFile) diff)
1774+
1775+
letoutFile2="output.test.txt"
1776+
letexpectedFile2="output.test.bsl"
1777+
1778+
execBothToOut cfg(cfg.Directory) outFile2(cfg.Directory++"test.exe")""
1779+
1780+
letdiff2= fsdiff cfg outFile2 expectedFile2
1781+
1782+
match diff2with
1783+
|""->()
1784+
|_->
1785+
Assert.Fail(sprintf"'%s' and '%s' differ;%A"(getfullpath cfg outFile2)(getfullpath cfg expectedFile2) diff2)
1786+
#endif
1787+
17581788
#if!FSHARP_SUITE_DRIVES_CORECLR_TESTS
17591789
// This test is disabled in coreclr builds dependent on fixing : https://github.com/Microsoft/visualfsharp/issues/2600
17601790
[<Test>]

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp