Closed iarkh closed 5 years ago
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 28e658814fc9d3d17631597b385f7ca0cb1f7fb9):
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
^
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.
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.
Sorry for inaccuracy! Dart report compile error on the line 6 too, so if it's expected this bug can be closed.
Yep, that error is expected. Thanks!
@eernstg – is there a bug here? For whom? Otherwise, please close! 😄
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:
Analyzer throws a compile error for the line #6 and passes with the line #7:
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.