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][Extension types] No error when extension type has a member conflict #53920

Closed
Tracked by #49732
sgrekhov opened this issue Nov 1, 2023 · 5 comments
Closed
Tracked by #49732
Assignees
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. feature-extension-types Implementation of the extension type feature P2 A bug or feature request we're likely to work on

Comments

@sgrekhov
Copy link
Contributor

sgrekhov commented Nov 1, 2023

Test https://github.com/dart-lang/co19/blob/master/LanguageFeatures/Extension-types/superinterfaces_of_extension_type_A05_t08.dart works in CFE but fails in analyzer. The code is

// SharedOptions=--enable-experiment=inline-class

extension type V(int id) {
  external int id2;
}

extension type ET(int id) implements V {
  int id2() => id; // No expected error in analyzer
//    ^^^
// [analyzer] unspecified
// [cfe] unspecified
}

main() {
  print(ET);
}

Tested on Dart SDK version: 3.3.0-edge.e2aa60ddf362967e17e06ec08871d634a32832c1 (be) (Wed Nov 1 04:17:41 2023 +0000) on "macos_x64"

@sgrekhov sgrekhov added area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. feature-extension-types Implementation of the extension type feature labels Nov 1, 2023
@pq pq added the P2 A bug or feature request we're likely to work on label Nov 1, 2023
@scheglov scheglov self-assigned this Nov 6, 2023
@scheglov
Copy link
Contributor

scheglov commented Nov 6, 2023

Ah, I opened dart-lang/co19#2354
I don't understand why this is a compile-time error.
@eernstg

@eernstg
Copy link
Member

eernstg commented Nov 6, 2023

Actually, I also can't see any conflicts: ET has a declaration that induces a getter int get id and a method int id2(), and it inherits nothing (because V has a member named id and a member named id2, and they are both redeclared by ET).

The failure I can see (but I haven't looked into running the test on many configurations) is that the DartPad compiler reports an error on external int id;. But that's simply because this is an external getter which is not associated with any implementation (I think it's enough for the representation type to be JSAny or a subtype thereof, but the compiler needs something in order to know how to bind that getter to an actual external implementation), and hence it is rejected by the compiler.

@sgrekhov, what would be conflict be?

@sgrekhov
Copy link
Contributor Author

sgrekhov commented Nov 7, 2023

Please see #53901 (comment)
As far as I understand the key point here is that external int id2; is not final here and therefore introduces a setter as well. According to dart spec

It is a compile-time error if the interface of C has an instance method named n and an instance setter with basename n.

@eernstg
Copy link
Member

eernstg commented Nov 7, 2023

Ah, of course, external int id2 does introduce a setter named id2=, and we can't have that in the interface of ET together with a method named id2. Thanks!

@scheglov
Copy link
Contributor

scheglov commented Nov 7, 2023

copybara-service bot pushed a commit that referenced this issue Nov 7, 2023
…ven when there is getter.

Bug: #53920
Change-Id: Ib2d7715a45b4696ce56c200cbbadc60ee8ab3b81
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/334640
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
@scheglov scheglov closed this as completed Nov 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. feature-extension-types Implementation of the extension type feature P2 A bug or feature request we're likely to work on
Projects
None yet
Development

No branches or pull requests

4 participants