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

Should augmentations allow appending to the implements clause for extension types? #4136

Open
jakemac53 opened this issue Oct 22, 2024 · 8 comments

Comments

@jakemac53
Copy link
Contributor

jakemac53 commented Oct 22, 2024

We do not allow altering the representation type, and require the clause for that to be present, but we don't mention the implements clause.

cc @dart-lang/language-team

@lrhn lrhn changed the title Should augmentations allow appending to the with clause for extension types? Should augmentations allow appending to the with clause for extensions? Oct 22, 2024
@lrhn lrhn changed the title Should augmentations allow appending to the with clause for extensions? Should augmentations allow appending to the with clause for mixin types? Oct 22, 2024
@lrhn
Copy link
Member

lrhn commented Oct 22, 2024

I assume this means extension mixin types ... nope, I can't figure it out. Which declaration is this?

There is no declaration that has both an on clause and a with clause. The only declarations which have a with clause is class and enum declarations, which cannot have an on clause. The declarations with on clauses are extension and mixin, which cannot have a with clause.

The full grammars of the declarations are something like:

extension type const Name<X1, X2>.id(RepType id) implements I1, I2 { ... }
extension Name<X1, X2> on T { ... }
mixin Name<X1, X2> on T1, T2 implements I1, I2 { ... }
abstract base class Name<X1, X2> extends T with T1, T2 implements I1, I2 {}
abstract base class Name<X1, X2> = T with T1, T2 implements I1, I2 {}
abstract base mixin class Name<X1, X2> implements I1, I2 {}
enum Name<X1, X2> with T1, T2 implements I1, I2 {}

@lrhn lrhn changed the title Should augmentations allow appending to the with clause for mixin types? Should augmentations allow appending to the with clause for extension types? Oct 22, 2024
@jakemac53 jakemac53 changed the title Should augmentations allow appending to the with clause for extension types? Should augmentations allow appending to the implements clause for extension types? Oct 23, 2024
@jakemac53
Copy link
Contributor Author

I just wrote it wrong, I meant the implements clause :)

@eernstg
Copy link
Member

eernstg commented Oct 23, 2024

I think it should not be a problem to allow it. A longer implements clause would add to the available subtype relationships, but I don't think it will undo any existing assumptions for that declaration. Of course, there could be issues that correspond to the ones we can have with classes (like the non-existence of a combined member signature for a member, or a clash that can't be resolved like int get foo in one superinterface and int foo() in another).

@jakemac53
Copy link
Contributor Author

jakemac53 commented Oct 23, 2024

Yeah, I think it is mostly a philosophical question. We choose to for instance not allow filling in the on clause for extensions, or the representation type clause for extension types. Just because it is pretty weird to omit those.

But, we allow filling in implements on classes, so it seems a bit odd to not allow it on extension types.

@eernstg
Copy link
Member

eernstg commented Oct 23, 2024

Right, but adding an implements type to an extension type seems "no worse" than adding an implements type to a class, I'd think.

(haha, same edit ;-)

@jakemac53
Copy link
Contributor Author

Yeah I am inclined to allow it 👍

@lrhn
Copy link
Member

lrhn commented Oct 23, 2024

Agree. I'd prefer that implements behaves the same everywhere. It's stricty worse to be able to add interfaces to classes, mixins and enums, but not extension types.

@jakemac53
Copy link
Contributor Author

Ok, I will go ahead and add it into the builder APIs for macros (which is where I realized this omission).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

3 participants