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

breaking change: remove support for old super-mixins from CFE and VM #48167

Closed
mraleph opened this issue Jan 19, 2022 · 16 comments
Closed

breaking change: remove support for old super-mixins from CFE and VM #48167

mraleph opened this issue Jan 19, 2022 · 16 comments
Assignees
Labels
breaking-change-approved legacy-area-front-end Legacy: Use area-dart-model instead.

Comments

@mraleph
Copy link
Member

mraleph commented Jan 19, 2022

Background

Currently CFE allows certain targets (e.g. Flutter, Dart CLI) to use old super mixin feature - which permitted to classes to be used as mixins even when they extended something that was not an Object.

Meaning that CFE would compile (and VM would run) the following code:

class Base {}

class Mixin extends Base {
}

class C extends Base with Mixin {
}

Analyzer rejects this code with mixin_inherits_from_not_object error:

  error • test.dart:5:27 • The class 'Mixin' can't be used as a mixin because it extends a class other than 'Object'. • mixin_inherits_from_not_object

Though this error can be suppressed via // ignore:mixin_inherits_from_not_object.

The analyser used to support this feature (hidden under a flag) but this support has been removed.

Proposed change

We propose to remove support for this feature from CFE.

Migration

Users should migrate their class Mixin extends Base declarations to use mixin Mixin on Base declarations instead.

class Base {}

mixin Mixin on Base {
}

class C extends Base with Mixin {
}

Impact

Given that the analyzer issues an error by default we consider the risk to be minimal.

As far as we can neither Flutter no internally Google code base does not contain any suppressions for mixin_inherits_from_not_object which means it does not contain any uses of these feature.

Only users that explicitly suppressed analysis error will be affected and will be required to migrate.

@mraleph mraleph added breaking-change-request This tracks requests for feedback on breaking changes legacy-area-front-end Legacy: Use area-dart-model instead. labels Jan 19, 2022
@mraleph
Copy link
Member Author

mraleph commented Jan 19, 2022

/cc @devoncarew @johnniwinther

@mraleph
Copy link
Member Author

mraleph commented Jan 19, 2022

Announced on announce@dartlang.org. @devoncarew please kick of the process.

@devoncarew
Copy link
Member

To paraphrase from above:

  • we'd like to remove support for old super-mixins from CFE and VM
  • the analyzer no longer supports this syntax (it emits an mixin_inherits_from_not_object error)
  • we haven't found places (in flutter or in google3) where this error is ignored - assumed no remaining uses of the older syntax
  • and, we've sent the notification + migration email

@vsm - can you review and sign off for Dart? @Hixie - can you do the same for Flutter? And @grouma for Angular? Thanks!

@Hixie
Copy link
Contributor

Hixie commented Jan 21, 2022

I didn't realise we still supported this. Sure, this is fine by me.

@Hixie
Copy link
Contributor

Hixie commented Jan 21, 2022

Does removing support leave an error message in place that explains how to migrate easily?

@devoncarew
Copy link
Member

Does removing support leave an error message in place that explains how to migrate easily?

I assume it would leave the existing error message in place (The class 'Mixin' can't be used as a mixin because it extends a class other than 'Object'). @bwilkerson - perhaps this message could be modified to suggest the use of the mixin ... on syntax?

@devoncarew
Copy link
Member

ping @vsm, @grouma

@grouma
Copy link
Member

grouma commented Jan 29, 2022

As far as I can tell this will not impact Angular.

@vsmenon
Copy link
Member

vsmenon commented Jan 31, 2022

lgtm

@devoncarew
Copy link
Member

@mraleph - this breaking change request is approved; feel free to move to the next steps (https://github.com/dart-lang/sdk/blob/main/docs/process/breaking-changes.md#step-3-execution).

@mraleph mraleph assigned johnniwinther and unassigned mraleph Feb 1, 2022
@mraleph
Copy link
Member Author

mraleph commented Feb 1, 2022

We are ready to go @johnniwinther

@itsjustkevin
Copy link
Contributor

@johnniwinther Is this something we are still moving forward with?

@johnniwinther
Copy link
Member

It is. I'm currently looking into making some preparations in the CFE.

@itsjustkevin itsjustkevin removed the breaking-change-request This tracks requests for feedback on breaking changes label May 31, 2022
copybara-service bot pushed a commit that referenced this issue Jun 13, 2022
This CL remove the support for mixing in classes that don't extend
Object. An error has been report by the analyzer for some time and
now also by the CFE.

This puts the breaking change #48167 into effect.

TEST=pkg/front_end/testcases/general/issue48167.dart

Change-Id: Ia7715a27dc1aa18a7c85b24ed86d19a91b6924d5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247551
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
@johnniwinther
Copy link
Member

This has landed.

@MaryaBelanger
Copy link
Contributor

MaryaBelanger commented Aug 23, 2022

@johnniwinther can you confirm this section in the docs on mixins reflects the change?

Edit: also this section

Thanks!

@eernstg
Copy link
Member

eernstg commented Aug 23, 2022

The section 'Mixins' is up to date. The section 'Adding features to a class: mixins', too.

The latter does contain the sentence

To implement a mixin, create a class that extends Object and declares no constructors.

It would have been better if it said 'To implement a mixin, write a mixin declaration. For backward compatibility, it is also possible to use a class as a mixin if it extends Object (that is, it has the clause extends Object or it does not have an extends clause), and it does not have any constructors', but the current wording isn't actually wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change-approved legacy-area-front-end Legacy: Use area-dart-model instead.
Projects
None yet
Development

No branches or pull requests

9 participants