mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 08:44:27 +00:00
[VM parser] Complete support for generalized void (fixes #30516).
'void' is now allowed as type annotation for locals, fields, and formal parameters, in addition to being previously allowed as type argument. Update status files. Change-Id: I6459f56824dc0a695615d8dc87c9a8a1f9be29ef Reviewed-on: https://dart-review.googlesource.com/37651 Reviewed-by: Siva Annamalai <asiva@google.com> Commit-Queue: Régis Crelier <regis@google.com>
This commit is contained in:
parent
ddafb88794
commit
ed1d8bd475
6 changed files with 20 additions and 25 deletions
|
@ -2012,7 +2012,7 @@ void Parser::ParseParameterType(ParamList* params) {
|
|||
// It is too early to resolve the type here, since it can be a result type
|
||||
// referring to a not yet declared function type parameter.
|
||||
parameter.type = &AbstractType::ZoneHandle(
|
||||
Z, ParseTypeOrFunctionType(false, ClassFinalizer::kDoNotResolve));
|
||||
Z, ParseTypeOrFunctionType(true, ClassFinalizer::kDoNotResolve));
|
||||
|
||||
// At this point, we must see an identifier for the parameter name, unless
|
||||
// we are using the function type syntax (in which case the name is optional,
|
||||
|
@ -2060,10 +2060,6 @@ void Parser::ParseParameterType(ParamList* params) {
|
|||
ASSERT(params->num_optional_parameters == 0);
|
||||
}
|
||||
}
|
||||
if (parameter.type->IsVoidType()) {
|
||||
ReportError("parameter '%s' may not be 'void'",
|
||||
parameter.name->ToCString());
|
||||
}
|
||||
if (params->implicitly_final) {
|
||||
parameter.is_final = true;
|
||||
}
|
||||
|
@ -2287,10 +2283,6 @@ void Parser::ParseFormalParameter(bool allow_explicit_default_value,
|
|||
ASSERT(params->num_optional_parameters == 0);
|
||||
}
|
||||
}
|
||||
if (parameter.type->IsVoidType()) {
|
||||
ReportError("parameter '%s' may not be 'void'",
|
||||
parameter.name->ToCString());
|
||||
}
|
||||
if (params->implicitly_final) {
|
||||
parameter.is_final = true;
|
||||
}
|
||||
|
@ -4756,8 +4748,6 @@ void Parser::ParseClassMemberDefinition(ClassDesc* members,
|
|||
"missing 'var', 'final', 'const' or type"
|
||||
" in field declaration");
|
||||
}
|
||||
} else if (member.type->IsVoidType()) {
|
||||
ReportError(member.name_pos, "field may not be 'void'");
|
||||
}
|
||||
if (!member.type->IsResolved()) {
|
||||
AbstractType& type = AbstractType::ZoneHandle(Z, member.type->raw());
|
||||
|
@ -8003,7 +7993,7 @@ RawAbstractType* Parser::ParseConstFinalVarOrType(
|
|||
type_is_optional = true;
|
||||
}
|
||||
if ((CurrentToken() == Token::kVOID) || IsFunctionTypeSymbol()) {
|
||||
return ParseFunctionType(AbstractType::Handle(Z), finalization);
|
||||
return ParseTypeOrFunctionType(true, finalization);
|
||||
}
|
||||
if (CurrentToken() != Token::kIDENT) {
|
||||
if (type_is_optional) {
|
||||
|
@ -8023,7 +8013,7 @@ RawAbstractType* Parser::ParseConstFinalVarOrType(
|
|||
return Type::DynamicType();
|
||||
}
|
||||
}
|
||||
return ParseTypeOrFunctionType(false, finalization);
|
||||
return ParseTypeOrFunctionType(false, finalization); // void handled above.
|
||||
}
|
||||
|
||||
// Returns ast nodes of the variable initialization. Variables without an
|
||||
|
@ -8480,6 +8470,8 @@ bool Parser::TryParseQualIdent() {
|
|||
// Allow 'void' as type if 'allow_void' is true.
|
||||
// Note that 'void Function()' is always allowed, since it is a function type
|
||||
// and not the void type.
|
||||
// TODO(regis): Consider removing allow_void argument, since this call is only
|
||||
// used where void is allowed. Wait for Dart 2 spec to stabilize.
|
||||
bool Parser::TryParseType(bool allow_void) {
|
||||
bool found = false;
|
||||
if (CurrentToken() == Token::kVOID) {
|
||||
|
@ -8536,8 +8528,7 @@ bool Parser::IsVariableDeclaration() {
|
|||
}
|
||||
if ((CurrentToken() != Token::kIDENT) && (CurrentToken() != Token::kVOID) &&
|
||||
(CurrentToken() != Token::kCONST)) {
|
||||
// Not a legal type identifier or void (result type of function type)
|
||||
// or const keyword or metadata.
|
||||
// Not a legal type identifier or void or const keyword or metadata.
|
||||
return false;
|
||||
}
|
||||
const TokenPosition saved_pos = TokenPos();
|
||||
|
@ -8548,7 +8539,7 @@ bool Parser::IsVariableDeclaration() {
|
|||
have_type = true; // Type is dynamic if 'const' is not followed by a type.
|
||||
}
|
||||
if ((CurrentToken() == Token::kVOID) || IsFunctionTypeSymbol()) {
|
||||
if (TryParseType(false)) {
|
||||
if (TryParseType(true)) {
|
||||
have_type = true;
|
||||
}
|
||||
} else if (IsIdentifier()) { // Type or variable name.
|
||||
|
@ -8558,7 +8549,7 @@ bool Parser::IsVariableDeclaration() {
|
|||
Token::IsIdentifier(follower)) { // Variable name following a type.
|
||||
// We see the beginning of something that could be a type.
|
||||
const TokenPosition type_pos = TokenPos();
|
||||
if (TryParseType(false)) {
|
||||
if (TryParseType(false)) { // void handled above.
|
||||
have_type = true;
|
||||
} else {
|
||||
SetPosition(type_pos);
|
||||
|
@ -8685,10 +8676,12 @@ bool Parser::IsForInStatement() {
|
|||
CurrentToken() == Token::kCONST) {
|
||||
ConsumeToken();
|
||||
}
|
||||
if (IsIdentifier()) {
|
||||
if (LookaheadToken(1) == Token::kIN) {
|
||||
// void as the loop variable type does not make much sense, but it is not
|
||||
// disallowed by the spec.
|
||||
if (IsIdentifier() || (CurrentToken() == Token::kVOID)) {
|
||||
if ((CurrentToken() != Token::kVOID) && (LookaheadToken(1) == Token::kIN)) {
|
||||
return true;
|
||||
} else if (TryParseType(false)) {
|
||||
} else if (TryParseType(true)) {
|
||||
if (IsIdentifier()) {
|
||||
ConsumeToken();
|
||||
}
|
||||
|
|
|
@ -300,6 +300,9 @@ Language/Statements/Yield_and_Yield_Each/Yield_Each/execution_async_t09: Runtime
|
|||
Language/Statements/Yield_and_Yield_Each/Yield_Each/execution_async_t10: RuntimeError # Issue 25748
|
||||
Language/Statements/Yield_and_Yield_Each/Yield_Each/execution_sync_t05: RuntimeError # Issue 25662,25634
|
||||
Language/Types/Type_Void/syntax_t01: MissingCompileTimeError # Issue co19/30264
|
||||
Language/Types/Type_Void/syntax_t02: MissingCompileTimeError # Issue co19/30264
|
||||
Language/Types/Type_Void/syntax_t04: MissingCompileTimeError # Issue co19/30264
|
||||
Language/Types/Type_Void/syntax_t09: MissingCompileTimeError # Issue co19/30264
|
||||
LayoutTests/fast/*: SkipByDesign # DOM not supported on VM.
|
||||
LibTest/collection/ListBase/ListBase_class_A01_t01: RuntimeError # Large integers
|
||||
LibTest/collection/ListMixin/ListMixin_class_A01_t01: RuntimeError # Large integers
|
||||
|
|
|
@ -424,7 +424,6 @@ duplicate_export_negative_test: Fail # Issue 6134
|
|||
example_constructor_test: Fail, OK # Failures related to super call in ctor initializer list
|
||||
field_initialization_order_test: Fail, OK # Failures related to super call in ctor initializer list
|
||||
final_field_initialization_order_test: Fail, OK # Failures related to super call in ctor initializer list
|
||||
generalized_void_syntax_test: CompileTimeError
|
||||
generic_methods_type_expression_test: RuntimeError # Issue 25869 / 27460
|
||||
least_upper_bound_expansive_test/*: Fail, OK # Non-contractive types are not supported in the vm.
|
||||
main_not_a_function_test/01: Skip # Skipped temporaril until Issue 29895 is fixed.
|
||||
|
|
|
@ -85,7 +85,6 @@ factory6_test/00: CompileTimeError
|
|||
field_increment_bailout_test: CompileTimeError
|
||||
field_override_test/01: CompileTimeError
|
||||
function_malformed_result_type_test: CompileTimeError
|
||||
generalized_void_syntax_test: CompileTimeError # Issue #30176
|
||||
generic_function_typedef2_test/04: CompileTimeError
|
||||
instance_creation_in_function_annotation_test: CompileTimeError
|
||||
internal_library_test/01: CompileTimeError
|
||||
|
|
|
@ -376,7 +376,6 @@ function_type_call_getter2_test/04: MissingCompileTimeError
|
|||
function_type_call_getter2_test/05: MissingCompileTimeError
|
||||
fuzzy_arrows_test/01: MissingCompileTimeError
|
||||
fuzzy_arrows_test/03: RuntimeError
|
||||
generalized_void_syntax_test: CompileTimeError # Issue #30176
|
||||
generic_closure_test: RuntimeError
|
||||
generic_constructor_mixin2_test/01: MissingCompileTimeError
|
||||
generic_constructor_mixin3_test/01: MissingCompileTimeError
|
||||
|
@ -884,6 +883,8 @@ switch_fallthru_test/01: MissingCompileTimeError
|
|||
symbol_literal_test/01: MissingCompileTimeError
|
||||
sync_generator1_test/01: MissingCompileTimeError
|
||||
syntax_test/59: MissingCompileTimeError, OK # Issue 30516.
|
||||
syntax_test/60: MissingCompileTimeError, OK # Issue 30516.
|
||||
syntax_test/61: MissingCompileTimeError, OK # Issue 30516.
|
||||
top_level_getter_no_setter1_test: MissingCompileTimeError
|
||||
top_level_getter_no_setter2_test: MissingCompileTimeError
|
||||
transitive_private_library_access_test: MissingCompileTimeError
|
||||
|
|
|
@ -56,7 +56,6 @@ dynamic_prefix_core_test/01: RuntimeError # Issue 12478
|
|||
example_constructor_test: Fail, OK
|
||||
export_ambiguous_main_negative_test: Fail # Issue 14763
|
||||
field_initialization_order_test: Fail, OK
|
||||
generalized_void_syntax_test: CompileTimeError # Issue #30176
|
||||
hello_dart_test: Skip # Incompatible flag: --compile_all
|
||||
language_2/least_upper_bound_expansive_test/none: CompileTimeError
|
||||
library_env_test/has_html_support: RuntimeError, OK
|
||||
|
@ -856,6 +855,8 @@ switch_fallthru_test/01: MissingCompileTimeError
|
|||
symbol_literal_test/01: MissingCompileTimeError
|
||||
sync_generator1_test/01: MissingCompileTimeError
|
||||
syntax_test/59: MissingCompileTimeError, OK # Issue 30516.
|
||||
syntax_test/60: MissingCompileTimeError, OK # Issue 30516.
|
||||
syntax_test/61: MissingCompileTimeError, OK # Issue 30516.
|
||||
top_level_getter_no_setter1_test: MissingCompileTimeError
|
||||
top_level_getter_no_setter2_test: MissingCompileTimeError
|
||||
transitive_private_library_access_test: MissingCompileTimeError
|
||||
|
@ -1222,7 +1223,6 @@ dynamic_prefix_core_test/01: RuntimeError # Issue 12478
|
|||
example_constructor_test: Fail, OK
|
||||
export_ambiguous_main_negative_test: Fail # Issue 14763
|
||||
field_initialization_order_test: Fail, OK
|
||||
generalized_void_syntax_test: CompileTimeError # Issue #30176
|
||||
generic_methods_bounds_test/02: MissingRuntimeError
|
||||
library_env_test/has_html_support: RuntimeError, OK
|
||||
library_env_test/has_no_io_support: RuntimeError, OK
|
||||
|
|
Loading…
Reference in a new issue