-
Notifications
You must be signed in to change notification settings - Fork 789
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
Fix #5531 #5778
Fix #5531 #5778
Conversation
This is a working fix for the example of dotnet#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.
Signed-off-by: realvictorprm <mueller.vpr@gmail.com>
OK as soon as the CI passes this is ready for a review. |
Ok this is ready! :) |
I looked at the change and to be honest I don't really know what rule it's implementing. Also, there are no tests added so it's hard to assess what's being changed and whether we are correctly testing it's impact. |
I think you want to be making appropriate use of It could be we are missing a call to this during SRTP resolution. |
OK, I'll add more comments to the code. The tests would have been the next step as soon as the change itself is the right approach. The changes filter out any members which are base implementations (parent) of the given member implementation from the derived class (child). |
@dsyme thanks for the pointer. Exactly such is what I expected to find in the compiler somewhere but didn't :) |
I'll find out where this call can be added to apply the same effect as my current code + add tests for the change. |
OK I tried your tip but it looks like the method isn't filtering out the methods correctly. Could it be that the method implementation is wrong? |
No, I'm fairly certain it's not wrong, you can test it in normal code (x.Method resolution not SRTP resolution), and the repro in the bug actually tests it that way I believe Just go through and work out why the filtering is not being applied? |
@dsyme OK I found out that the big problem here is that in the example:
the members overriding a base implementation should definitely be written with "override" instead. |
@dsyme the problem is that the non explicit override isn't saved anywhere neither it's possible at that location to check for such. As we're displaying warnings that an implementation isn't specified with |
I've applied the new approach with which the bug is resolved + it's saved back that a member non explicitly overrides a member. |
Unfortunately I discovered, that the current approach isn't working. I guess something with my test setup yesterday went wrong. |
Signed-off-by: realvictorprm <mueller.vpr@gmail.com>
So this "new" approach is simply using the filter predicate from the warning that a member implementation is hidden by another implementation. In my understanding the |
@dotnet-bot test this please |
OK this fix is working too however if I try this example: type Base() =
abstract member Foo : unit -> unit
default this.Foo() = printfn "Base"
type Derived() =
inherit Base()
member this.Foo() = printfn "Derived"
type DerivedDerived() =
inherit Derived()
member this.Foo() = printfn "DerivedDerived"
let inline callFoo< ^T when ^T : (member Foo: unit -> unit) > (t: ^T) =
(^T : (member Foo: unit -> unit) (t))
let b = Base()
let d = Derived()
let dd = DerivedDerived()
let bd = d :> Base
callFoo<Derived> d
callFoo<DerivedDerived> dd The last line has conflict again, is this OK or shouldn't this be covered too? (Also there isn't any warning that the method of DerivedDerived is hidding the method of Derived). cc @dsyme PS: Tests come as soon as we've decided on which fix is OK. |
Signed-off-by: realvictorprm <mueller.vpr@gmail.com>
Signed-off-by: realvictorprm <mueller.vpr@gmail.com>
Can someone help me identifying what the problem with my new test case is? The error the CI gives is confusing |
The ci_build3 fails with this: |
This is an internal error in the typechecker, likely because you've caused it to hit an illegal state. There is a warning in CI that may be a hint:
|
@realvictorprm so the test is failing to build with the coreclr. It is not a problem with the fix, it's just that the test case isn't correct for coreclr. To build and run tests on coreclr and desktop use SingleTestBuildAndRun. That doesn't really support the diffing, so probably the best thing to do is to add the test within a #if !FSHARP_SUITE_DRIVES_CORECLR_TESTS block and hope we rewrite these test sensibly. Kevin |
Thank you very much! |
OK done, CI passes. This is ready again @KevinRansom :) |
Thank you for this contribution Kevin |
This is a working fix for the example of #5531.
However there are still some points open before I think it's a good idea to merge this:
@dsyme It would be great if you could have a look whether this check is allowed at this location or should appear earlier.