-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Erroneous fatal error about interfaces duplicated in the supertype graph #3803
Comments
This comment was originally written by zundel@google.com I don't know the history of this message, it might be being accidentally triggered for another important case, but if this is valid, it makes me ask, are there rules about this situation in general as far as warnings are concerned that we should follow? A slight variation: interface Interface<T> { C instanceC = new C(); This creates a way around two unassignable types with no warnings. Looking at the spec for guidance, I see we should generate warnings if we tried to use overrides on individual members. If its not supposed to be in the spec, maybe the analyzer could do a 'value add' warning. Removed the owner. |
The implicit interface of C has as superinterfaces: The implicit interface of A C has method m() whose name is "m". The superinterfaces Interface<int> and Interface<String> both declare methods with name "m", and so the interface of C overrides them (per 8.5.1). The override is a compile-time erro per 8.1 because the number of required parameters differs. Perhaps you meant to write interface Interface<T> { In this case, C's m overrides Interface<int>'s m correctly, but a warning will be issued for the attempt to override Interface<String>. Now, consider interface Interface<T> { this one is interesting. The overrides are both legal. But of course now there is no contradiction. |
Marked this as blocking #2136. |
This comment was originally written by zundel@google.com
I don't think it is sufficient to say to look at the override rules to determine how to warn for this issue. First of all, is this a case of a problem in a method override? The class C clearly states it is implementing Interface<int>, and int m() matches the signature of that method exactly, so that doesn't sound like an override. Flagging this on m() will be very confusing, especially considering that every method define in Interface that references the type parameter would trigger this warning. What's more, changing the method signature to: String m(); wouldn't fix it either, would it? I see this issue is blocking progress, I'll take the compile error and do something better. Set owner to zundel@google.com. |
This comment was originally written by zundel@google.com Issue #2495 has been merged into this issue. |
This comment was originally written by zundel@google.com https://chromiumcodereview.appspot.com/10627017 In the code originally in the bug report, the analyzer is now silent. but in this variant, it emits warnings: interface Interface<T> { file:/tmp/t.dart:8: cannot override m of Interface because () -> int is not a subtype of () -> String The latter message is at the 'info' level and shouldn't trigger any unit tests. Added Started label. |
This comment was originally written by zundel@google.com r9035 Added Fixed label. |
Consider the following code:
interface Interface<T> {
T m();
}
abstract class A implements Interface {
}
class C extends A implements Interface<int> {
int m() => 0;
}
The analyzer fails with the following error
file:/usr/local/google/home/cshapiro/dart-all/dart/darta.dart:8: Interface<int> and Interface<<dynamic>> are duplicated in the supertype graph
7:
8: class C extends A implements Interface<int> {
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Compilation failed with 1 problem.
We believe no such prohibition exists and this should not be an error.
The text was updated successfully, but these errors were encountered: