Skip to content

Commit

Permalink
Disallow deprecated typedef syntax for mixin apps in the VM (fixes #1…
Browse files Browse the repository at this point in the history
…4410).

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 .
  • Loading branch information
crelier committed Dec 7, 2016
1 parent 1a172e9 commit 6da1083
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 38 deletions.
26 changes: 0 additions & 26 deletions runtime/vm/parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion runtime/vm/parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 0 additions & 4 deletions tests/language/language_analyzer2.status
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions tests/language/language_dart2js.status
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions tests/language/language_kernel.status
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 6 additions & 5 deletions tests/language/mixin_illegal_syntax_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ class S { }
class G<T> { }
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
Expand All @@ -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
Expand Down

0 comments on commit 6da1083

Please sign in to comment.