1
0
mirror of https://github.com/dart-lang/sdk synced 2024-07-03 00:08:46 +00:00

Remove support for mixin typedefs in dart2js.

Fixes #14410.
BUG= http://dartbug.com/14410
R=johnniwinther@google.com, sigmund@google.com

Review-Url: https://codereview.chromium.org/2567943003 .
This commit is contained in:
Florian Loitsch 2016-12-13 14:04:06 +01:00
parent 36c5cea288
commit 7374ec71bd
7 changed files with 17 additions and 56 deletions

View File

@ -21,6 +21,11 @@
pubspec can't be parsed will now be ignored by `pub get --offline` and
deleted by `pub cache repair`.
* Dart2Js
* Remove support for (long-time deprecated) mixin typedefs.
## 1.21.0 - 2016-12-07
### Language

View File

@ -162,7 +162,6 @@ enum MessageKind {
DEFERRED_LIBRARY_WITHOUT_PREFIX,
DEFERRED_OLD_SYNTAX,
DEFERRED_TYPE_ANNOTATION,
DEPRECATED_TYPEDEF_MIXIN_SYNTAX,
DIRECTLY_THROWING_NSM,
DISALLOWED_LIBRARY_IMPORT,
DUPLICATE_DEFINITION,
@ -1633,7 +1632,7 @@ class C extends Object with String {}
main() => new C();
""",
"""
typedef C = Object with String;
class C = Object with String;
main() => new C();
"""
@ -2481,19 +2480,6 @@ main() => A.A = 1;
"main() => +2; // No longer a valid way to write '2'"
]),
MessageKind.DEPRECATED_TYPEDEF_MIXIN_SYNTAX: const MessageTemplate(
MessageKind.DEPRECATED_TYPEDEF_MIXIN_SYNTAX,
"'typedef' not allowed here. ",
howToFix: "Try replacing 'typedef' with 'class'.",
examples: const [
"""
class B { }
class M1 { }
typedef C = B with M1; // Need to replace 'typedef' with 'class'.
main() { new C(); }
"""
]),
MessageKind.MIRRORS_EXPECTED_STRING: const MessageTemplate(
MessageKind.MIRRORS_EXPECTED_STRING,
"Can't use '#{name}' here because it's an instance of '#{type}' "

View File

@ -273,9 +273,9 @@ class ElementListener extends Listener {
Token classKeyword, Token implementsKeyword, Token endToken) {
NodeList interfaces = (implementsKeyword != null) ? popNode() : null;
MixinApplication mixinApplication = popNode();
Modifiers modifiers = popNode();
NodeList typeParameters = popNode();
Identifier name = popNode();
Modifiers modifiers = popNode();
NamedMixinApplication namedMixinApplication = new NamedMixinApplication(
name,
typeParameters,

View File

@ -128,9 +128,9 @@ class NodeListener extends ElementListener {
Token classKeyword, Token implementsKeyword, Token endToken) {
NodeList interfaces = (implementsKeyword != null) ? popNode() : null;
Node mixinApplication = popNode();
Modifiers modifiers = popNode();
NodeList typeParameters = popNode();
Identifier name = popNode();
Modifiers modifiers = popNode();
pushNode(new NamedMixinApplication(name, typeParameters, modifiers,
mixinApplication, interfaces, classKeyword, endToken));
}

View File

@ -362,30 +362,12 @@ class Parser {
Token parseTypedef(Token token) {
Token typedefKeyword = token;
if (optional('=', peekAfterType(token.next))) {
// TODO(aprelev@gmail.com): Remove deprecated 'typedef' mixin application,
// remove corresponding diagnostic from members.dart.
listener.beginNamedMixinApplication(token);
token = parseIdentifier(token.next);
token = parseTypeVariablesOpt(token);
token = expect('=', token);
token = parseModifiers(token);
token = parseMixinApplication(token);
Token implementsKeyword = null;
if (optional('implements', token)) {
implementsKeyword = token;
token = parseTypeList(token.next);
}
listener.endNamedMixinApplication(
typedefKeyword, implementsKeyword, token);
} else {
listener.beginFunctionTypeAlias(token);
token = parseReturnTypeOpt(token.next);
token = parseIdentifier(token);
token = parseTypeVariablesOpt(token);
token = parseFormalParameters(token);
listener.endFunctionTypeAlias(typedefKeyword, token);
}
listener.beginFunctionTypeAlias(token);
token = parseReturnTypeOpt(token.next);
token = parseIdentifier(token);
token = parseTypeVariablesOpt(token);
token = parseFormalParameters(token);
listener.endFunctionTypeAlias(typedefKeyword, token);
return expect(';', token);
}
@ -682,17 +664,10 @@ class Parser {
var isMixinApplication = optional('=', peekAfterType(token.next));
if (isMixinApplication) {
listener.beginNamedMixinApplication(begin);
token = parseIdentifier(token.next);
token = parseTypeVariablesOpt(token);
token = expect('=', token);
} else {
listener.beginClassDeclaration(begin);
}
// TODO(aprelev@gmail.com): Once 'typedef' named mixin application is
// removed, move modifiers for named mixin application to the bottom of
// listener stack. This is so stacks for class declaration and named
// mixin application look similar.
int modifierCount = 0;
if (abstractKeyword != null) {
parseModifier(abstractKeyword);
@ -701,6 +676,9 @@ class Parser {
listener.handleModifiers(modifierCount);
if (isMixinApplication) {
token = parseIdentifier(token.next);
token = parseTypeVariablesOpt(token);
token = expect('=', token);
return parseNamedMixinApplication(token, classKeyword);
} else {
return parseClass(begin, classKeyword);

View File

@ -276,13 +276,6 @@ class ClassResolverVisitor extends TypeDefinitionVisitor {
element, 'cyclic resolution of class $element');
}
if (identical(node.classKeyword.stringValue, 'typedef')) {
// TODO(aprelev@gmail.com): Remove this deprecation diagnostic
// together with corresponding TODO in parser.dart.
reporter.reportWarningMessage(
node.classKeyword, MessageKind.DEPRECATED_TYPEDEF_MIXIN_SYNTAX);
}
element.computeType(resolution);
scope = new TypeDeclarationScope(scope, element);
resolveTypeVariableBounds(node.typeParameters);

View File

@ -24,7 +24,6 @@ mixin_supertype_subclass2_test: CompileTimeError # Issue 23773
mixin_supertype_subclass3_test: CompileTimeError # Issue 23773
mixin_supertype_subclass4_test: CompileTimeError # Issue 23773
mixin_of_mixin_test: CompileTimeError # Issue 23773
mixin_illegal_syntax_test/00: MissingCompileTimeError # Issue 14410
# The following tests are supposed to fail.
# In testing-mode, dart2js supports all dart:X libraries (because it