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

Analyzer checks overriding between superclass and superinterface incorrectly. #36432

Closed
iarkh opened this issue Apr 2, 2019 · 6 comments
Closed
Labels
needs-info We need additional information from the issue author (auto-closed after 14 days if no response)

Comments

@iarkh
Copy link
Contributor

iarkh commented Apr 2, 2019

DART version: 2.2.1-dev-1.1
OS: Windows 10 64 bit

This bug is similar with #34392 which was fixed some time ago.

Here is a source code example:

abstract class I { foo(a) {} }

abstract class A { foo() {} }
abstract class B { another() {} }

abstract class C extends A implements I {}    // compile error here
abstract class D extends B implements I {}    // no error here

main() {}

Analyzer throws a compile error for the line #6 and passes with the line #7:

Analyzing test.dart...
error - Superinterfaces don't have a valid override for 'foo': I.foo ((dynamic) → dynamic), A.foo (() → dynamic) at test.dart:6:16 - inconsistent_inheritance
1 error found.

Seems like it should pass in both cases.

Please note that #34392 source example passes with the recent dart versions.

If I run my test with dart, it passes as well.

@eernstg
Copy link
Member

eernstg commented Apr 2, 2019

This is working as intended.

You need to say foo([a]) in I in order to make that signature more specific than A.foo. Otherwise you just have two incomparable signatures for foo in the superinterfaces of C, and that makes the declaration of C an error.

Alternatively, if you add the declaration foo([a]); to the body of C then that declaration is a correct override of both A.foo and I.foo, and there is no error.

But it sounds like the front end is too forgiving ... testing ... no: I get an error for line 6 from dart (version 2.1.1-dev.3.2 plus a fresh one from 28e6588):

n002.dart:6:16: Error: The method 'C.foo' has more required arguments than those of overridden method 'A.foo'.
abstract class C extends A implements I {}    // compile error here
               ^

@iarkh
Copy link
Contributor Author

iarkh commented Apr 2, 2019

I tested this with 2.2.1-dev-1.1 and dart passed for me.
So, seems like it's fixed in the next release.

@eernstg
Copy link
Member

eernstg commented Apr 2, 2019

I get the same response (error on line 6) from dart version 2.2.1-dev.1.1 as I did for the other versions (older and newer than that), which is also the response we should get, and also the response that we get from dartanalyzer.

But I'm not quite sure what you mean by 'it passed for me'. Do you mean that you have a version of dart that does not report an error for line 6? That would be a bug, but I can't recreate that behavior.

@iarkh
Copy link
Contributor Author

iarkh commented Apr 3, 2019

Sorry for inaccuracy! Dart report compile error on the line 6 too, so if it's expected this bug can be closed.

@eernstg
Copy link
Member

eernstg commented Apr 3, 2019

Yep, that error is expected. Thanks!

@kevmoo
Copy link
Member

kevmoo commented Apr 3, 2019

@eernstg – is there a bug here? For whom? Otherwise, please close! 😄

@kevmoo kevmoo added the needs-info We need additional information from the issue author (auto-closed after 14 days if no response) label Apr 3, 2019
@eernstg eernstg closed this as completed Apr 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-info We need additional information from the issue author (auto-closed after 14 days if no response)
Projects
None yet
Development

No branches or pull requests

3 participants