Dart 2 Breaking Change: mixin and interface are built-in identifiers

135 views
Skip to first unread message

Leaf Petersen

unread,
May 17, 2018, 6:25:07 PM5/17/18
to Dart Misc
TLDR: If your code uses mixin or interface as a prefix, class, type parameter or typedef name, then your code will soon break.  Otherwise you can stop reading.

What's changing?

We are adding mixin and interface to the list of built-in identifiers in Dart.  This means that those names will no longer be allowed to be used as a prefix, class name, type parameter name or typedef name.

What will break?

Using the mixin or interface identifiers as a prefix:

import "dart:core" as mixin;

as a typedef name:

typedef mixin(x);

as a class name:

class mixin {}

or as a type parameter name:

class Foo<mixin> {}

will become a compile time error.

With the exception of prefixes, none of these uses are consistent with Dart naming conventions and so we expect breakage to be rare. 

How do I know if this has broken me?

If you see an error that looks something like the following:

  error • The built-in identifier 'mixin' can't be used as a prefix name at /Users/leafp/tmp/ddctest.dart:1:23 • built_in_identifier_as_prefix_name


then you are probably running into this.

How do I fix this?

If you are using these identifiers as prefixes (the most likely case) or a type parameter name you can simply choose a new name without affecting your API.  If you are using these identifiers as class names or typedef names (why!?) then you may need to make a breaking change to your API.

Why is this change being made?

We plan on adding explicit syntax for mixins to support the super-mixin feature as part of Dart 2 in the next update release.  We anticipate the possibility of doing something similar with interfaces in the future.  To support both of these use cases, we are making mixin and interface built-in identifiers now to avoid breakage in the future.

This change is being tracked on this issue: https://github.com/dart-lang/sdk/issues/33113 .  Feel free to reach out here or on the issue with comments or with questions about how to resolve breakage from this change.

thanks,
-leaf

Joel Trottier-Hébert

unread,
May 18, 2018, 7:54:30 AM5/18/18
to General Dart Discussion
Welcome back Mr. interface :P

--
For more ways to connect visit https://www.dartlang.org/community
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.
To view this discussion on the web visit https://groups.google.com/a/dartlang.org/d/msgid/misc/7efa441c-dc34-4ba6-be75-7fb60ae7d5ca%40dartlang.org.
Reply all
Reply to author
Forward
0 new messages