mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 16:37:43 +00:00
Recover from default values in function types
Fixes https://github.com/dart-lang/sdk/issues/35035 Change-Id: I29fe0d792998c43f49877d97b61b3afc16c43cef Reviewed-on: https://dart-review.googlesource.com/c/82984 Commit-Queue: Aske Simon Christensen <askesc@google.com> Reviewed-by: Aske Simon Christensen <askesc@google.com> Auto-Submit: Peter von der Ahé <ahe@google.com>
This commit is contained in:
parent
0fd14324c5
commit
0fd4a51e2c
|
@ -2686,8 +2686,12 @@ abstract class BodyBuilder extends ScopeListener<JumpTarget>
|
|||
void handleValuedFormalParameter(Token equals, Token token) {
|
||||
debugEvent("ValuedFormalParameter");
|
||||
Expression initializer = popForValue();
|
||||
Identifier name = pop();
|
||||
push(new InitializedIdentifier(name, initializer));
|
||||
Object name = pop();
|
||||
if (name is ParserRecovery) {
|
||||
push(name);
|
||||
} else {
|
||||
push(new InitializedIdentifier(name, initializer));
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
@ -494,5 +494,5 @@ class ParserRecovery {
|
|||
final int charOffset;
|
||||
ParserRecovery(this.charOffset);
|
||||
|
||||
String toString() => "ParserRecovery(charOffset)";
|
||||
String toString() => "ParserRecovery(@$charOffset)";
|
||||
}
|
||||
|
|
7
pkg/front_end/testcases/function_type_default_value.dart
Normal file
7
pkg/front_end/testcases/function_type_default_value.dart
Normal file
|
@ -0,0 +1,7 @@
|
|||
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
void Function({obj: Object}) x;
|
||||
|
||||
main() {}
|
|
@ -0,0 +1,29 @@
|
|||
// Formatted problems:
|
||||
//
|
||||
// pkg/front_end/testcases/function_type_default_value.dart:5:19: Error: Expected an identifier, but got ':'.
|
||||
// void Function({obj: Object}) x;
|
||||
// ^
|
||||
//
|
||||
// pkg/front_end/testcases/function_type_default_value.dart:5:19: Error: Can't have a default value in a function type.
|
||||
// void Function({obj: Object}) x;
|
||||
// ^
|
||||
//
|
||||
// pkg/front_end/testcases/function_type_default_value.dart:5:16: Warning: 'obj' isn't a type.
|
||||
// void Function({obj: Object}) x;
|
||||
// ^^^
|
||||
|
||||
// Unhandled errors:
|
||||
//
|
||||
// pkg/front_end/testcases/function_type_default_value.dart:5:19: Error: Expected an identifier, but got ':'.
|
||||
// void Function({obj: Object}) x;
|
||||
// ^
|
||||
//
|
||||
// pkg/front_end/testcases/function_type_default_value.dart:5:19: Error: Can't have a default value in a function type.
|
||||
// void Function({obj: Object}) x;
|
||||
// ^
|
||||
|
||||
library;
|
||||
import self as self;
|
||||
|
||||
static field () → void x;
|
||||
static method main() → dynamic {}
|
|
@ -0,0 +1,15 @@
|
|||
// Unhandled errors:
|
||||
//
|
||||
// pkg/front_end/testcases/function_type_default_value.dart:5:19: Error: Expected an identifier, but got ':'.
|
||||
// void Function({obj: Object}) x;
|
||||
// ^
|
||||
//
|
||||
// pkg/front_end/testcases/function_type_default_value.dart:5:19: Error: Can't have a default value in a function type.
|
||||
// void Function({obj: Object}) x;
|
||||
// ^
|
||||
|
||||
library;
|
||||
import self as self;
|
||||
|
||||
static field () → void x;
|
||||
static method main() → dynamic {}
|
|
@ -0,0 +1,16 @@
|
|||
// Formatted problems:
|
||||
//
|
||||
// pkg/front_end/testcases/function_type_default_value.dart:5:19: Error: Expected an identifier, but got ':'.
|
||||
// void Function({obj: Object}) x;
|
||||
// ^
|
||||
//
|
||||
// pkg/front_end/testcases/function_type_default_value.dart:5:19: Error: Can't have a default value in a function type.
|
||||
// void Function({obj: Object}) x;
|
||||
// ^
|
||||
|
||||
library;
|
||||
import self as self;
|
||||
|
||||
static field () → void x;
|
||||
static method main() → dynamic
|
||||
;
|
|
@ -0,0 +1,33 @@
|
|||
// Formatted problems:
|
||||
//
|
||||
// pkg/front_end/testcases/function_type_default_value.dart:5:19: Error: Expected an identifier, but got ':'.
|
||||
// void Function({obj: Object}) x;
|
||||
// ^
|
||||
//
|
||||
// pkg/front_end/testcases/function_type_default_value.dart:5:19: Error: Can't have a default value in a function type.
|
||||
// void Function({obj: Object}) x;
|
||||
// ^
|
||||
//
|
||||
// pkg/front_end/testcases/function_type_default_value.dart:5:16: Error: 'obj' isn't a type.
|
||||
// void Function({obj: Object}) x;
|
||||
// ^^^
|
||||
|
||||
// Unhandled errors:
|
||||
//
|
||||
// pkg/front_end/testcases/function_type_default_value.dart:5:19: Error: Expected an identifier, but got ':'.
|
||||
// void Function({obj: Object}) x;
|
||||
// ^
|
||||
//
|
||||
// pkg/front_end/testcases/function_type_default_value.dart:5:19: Error: Can't have a default value in a function type.
|
||||
// void Function({obj: Object}) x;
|
||||
// ^
|
||||
//
|
||||
// pkg/front_end/testcases/function_type_default_value.dart:5:16: Error: 'obj' isn't a type.
|
||||
// void Function({obj: Object}) x;
|
||||
// ^^^
|
||||
|
||||
library;
|
||||
import self as self;
|
||||
|
||||
static field () → void x;
|
||||
static method main() → dynamic {}
|
|
@ -0,0 +1,19 @@
|
|||
// Unhandled errors:
|
||||
//
|
||||
// pkg/front_end/testcases/function_type_default_value.dart:5:19: Error: Expected an identifier, but got ':'.
|
||||
// void Function({obj: Object}) x;
|
||||
// ^
|
||||
//
|
||||
// pkg/front_end/testcases/function_type_default_value.dart:5:19: Error: Can't have a default value in a function type.
|
||||
// void Function({obj: Object}) x;
|
||||
// ^
|
||||
//
|
||||
// pkg/front_end/testcases/function_type_default_value.dart:5:16: Error: 'obj' isn't a type.
|
||||
// void Function({obj: Object}) x;
|
||||
// ^^^
|
||||
|
||||
library;
|
||||
import self as self;
|
||||
|
||||
static field () → void x;
|
||||
static method main() → dynamic {}
|
Loading…
Reference in a new issue