From 6da1083953e8956faed0bb8619bc8728055b1725 Mon Sep 17 00:00:00 2001 From: Regis Crelier Date: Wed, 7 Dec 2016 07:34:09 -0800 Subject: [PATCH] Disallow deprecated typedef syntax for mixin apps in the VM (fixes #14410). Update status files (will reassign issue #14410 to dart2js, since it still accepts the syntax). R=floitsch@google.com, scheglov@google.com Review URL: https://codereview.chromium.org/2556433004 . --- runtime/vm/parser.cc | 26 ------------------- runtime/vm/parser.h | 1 - tests/language/language_analyzer2.status | 4 --- tests/language/language_dart2js.status | 1 + tests/language/language_kernel.status | 2 -- tests/language/mixin_illegal_syntax_test.dart | 11 ++++---- 6 files changed, 7 insertions(+), 38 deletions(-) diff --git a/runtime/vm/parser.cc b/runtime/vm/parser.cc index 1a91fcb71023..d3b62f69fb59 100644 --- a/runtime/vm/parser.cc +++ b/runtime/vm/parser.cc @@ -44,7 +44,6 @@ namespace dart { DEFINE_FLAG(bool, enable_debug_break, false, "Allow use of break \"message\"."); DEFINE_FLAG(bool, trace_parser, false, "Trace parser operations."); -DEFINE_FLAG(bool, warn_mixin_typedef, true, "Warning on legacy mixin typedef."); DEFINE_FLAG(bool, warn_new_tearoff_syntax, true, "Warning on new tear off."); // TODO(floitsch): remove the conditional-directive flag, once we publicly // committed to the current version. @@ -5073,23 +5072,6 @@ bool Parser::IsFunctionTypeAliasName() { } -// Look ahead to detect if we are seeing ident [ TypeParameters ] "=". -// Token position remains unchanged. -bool Parser::IsMixinAppAlias() { - if (IsIdentifier() && (LookaheadToken(1) == Token::kASSIGN)) { - return true; - } - const TokenPosScope saved_pos(this); - if (IsIdentifier() && (LookaheadToken(1) == Token::kLT)) { - ConsumeToken(); - if (TryParseTypeParameters() && (CurrentToken() == Token::kASSIGN)) { - return true; - } - } - return false; -} - - void Parser::ParseTypedef(const GrowableObjectArray& pending_classes, const Object& tl_owner, TokenPosition metadata_pos) { @@ -5098,14 +5080,6 @@ void Parser::ParseTypedef(const GrowableObjectArray& pending_classes, metadata_pos.IsReal() ? metadata_pos : TokenPos(); ExpectToken(Token::kTYPEDEF); - if (IsMixinAppAlias()) { - if (FLAG_warn_mixin_typedef) { - ReportWarning(TokenPos(), "deprecated mixin application typedef"); - } - ParseMixinAppAlias(pending_classes, tl_owner, metadata_pos); - return; - } - // Parse the result type of the function type. AbstractType& result_type = Type::Handle(Z, Type::DynamicType()); if (CurrentToken() == Token::kVOID) { diff --git a/runtime/vm/parser.h b/runtime/vm/parser.h index 004913e9ae43..54a6027a6ae3 100644 --- a/runtime/vm/parser.h +++ b/runtime/vm/parser.h @@ -750,7 +750,6 @@ class Parser : public ValueObject { bool IsSymbol(const String& symbol); bool IsSimpleLiteral(const AbstractType& type, Instance* value); bool IsFunctionTypeAliasName(); - bool IsMixinAppAlias(); bool TryParseQualIdent(); bool TryParseTypeParameters(); bool TryParseTypeArguments(); diff --git a/tests/language/language_analyzer2.status b/tests/language/language_analyzer2.status index 72203db61851..d13f27ac19cd 100644 --- a/tests/language/language_analyzer2.status +++ b/tests/language/language_analyzer2.status @@ -156,9 +156,6 @@ regress_22438_test: fail # test issue 14079, it is not error, but warning to use # test issue 14228 black_listed_test/none: fail # test issue 14228, warnings are required but not expected -# test issue 14410, "typedef C = " is now really illegal syntax -mixin_illegal_syntax_test/none: fail - # test issue 14736, It is a static warning if a class C declares an instance method named n and has a setter named n=. setter4_test: StaticWarning @@ -292,7 +289,6 @@ method_override5_test: StaticWarning method_override6_test: StaticWarning method_override_test: StaticWarning mixin_illegal_static_access_test: StaticWarning -mixin_illegal_syntax_test/13: CompileTimeError mixin_type_parameters_mixin_extends_test: StaticWarning mixin_type_parameters_mixin_test: StaticWarning mixin_type_parameters_super_extends_test: StaticWarning diff --git a/tests/language/language_dart2js.status b/tests/language/language_dart2js.status index 4d5379c424a7..8c73613ce932 100644 --- a/tests/language/language_dart2js.status +++ b/tests/language/language_dart2js.status @@ -24,6 +24,7 @@ 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 diff --git a/tests/language/language_kernel.status b/tests/language/language_kernel.status index 98ae1fdb5aad..f2569e9d1382 100644 --- a/tests/language/language_kernel.status +++ b/tests/language/language_kernel.status @@ -75,8 +75,6 @@ mixin_illegal_superclass_test/27: DartkMissingCompileTimeError mixin_illegal_superclass_test/28: DartkMissingCompileTimeError mixin_illegal_superclass_test/29: DartkMissingCompileTimeError mixin_illegal_superclass_test/30: DartkMissingCompileTimeError -mixin_illegal_syntax_test/13: DartkCompileTimeError -mixin_illegal_syntax_test/none: DartkCompileTimeError multiline_newline_test/01: DartkCompileTimeError multiline_newline_test/02: DartkCompileTimeError multiline_newline_test/03: DartkCompileTimeError diff --git a/tests/language/mixin_illegal_syntax_test.dart b/tests/language/mixin_illegal_syntax_test.dart index c9bb06946301..167304ddb438 100644 --- a/tests/language/mixin_illegal_syntax_test.dart +++ b/tests/language/mixin_illegal_syntax_test.dart @@ -6,8 +6,9 @@ class S { } class G { } class M { } -typedef T0 = abstract S with M; -abstract class T0A = S with M; +class T = S with M; +typedef T0 = S with M; /// 00: compile-time error +abstract class TA = S with M; class T1 = final S with M; /// 01: compile-time error class T2 = var S with M; /// 02: compile-time error class T3 = const S with M; /// 03: compile-time error @@ -29,13 +30,13 @@ class D0 extends S with M implements M /// 12: compile-time error implements M { } -class D1 extends T0 { } +class D1 extends T { } class X = S; /// 14: compile-time error main() { - new T0(); /// 13: static type warning, runtime error - new T0A(); /// 13: static type warning, runtime error + new T(); + new TA(); /// 13: static type warning, runtime error new T1(); /// 01: continued new T2(); /// 02: continued new T3(); /// 03: continued