[cfe] Report error on : for default values

Closes #51576

TEST=pkg/front_end/testcases/general/colon_default_value

Change-Id: Ia8ccdf697d876dbefcbf2c5ed98d01634c075e74
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/286183
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
This commit is contained in:
Johnni Winther
2023-03-06 19:04:55 +00:00
committed by Commit Queue
parent a899b17908
commit bd02ce7a7f
60 changed files with 1327 additions and 923 deletions
@@ -10138,6 +10138,17 @@ const Code<Null> codeObjectMixesIn = messageObjectMixesIn;
const MessageCode messageObjectMixesIn = const MessageCode("ObjectMixesIn",
problemMessage: r"""The class 'Object' can't use mixins.""");
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<Null> codeObsoleteColonForDefaultValue =
messageObsoleteColonForDefaultValue;
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const MessageCode messageObsoleteColonForDefaultValue = const MessageCode(
"ObsoleteColonForDefaultValue",
problemMessage:
r"""Using a colon as a separator before a default value is no longer supported.""",
correctionMessage: r"""Try replacing the colon with an equal sign.""");
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<Null> codeOnlyTry = messageOnlyTry;
@@ -2050,8 +2050,9 @@ class ForwardingListener implements Listener {
}
@override
void handleValuedFormalParameter(Token equals, Token token) {
listener?.handleValuedFormalParameter(equals, token);
void handleValuedFormalParameter(
Token equals, Token token, FormalParameterKind kind) {
listener?.handleValuedFormalParameter(equals, token, kind);
}
@override
@@ -2073,7 +2073,8 @@ class Listener implements UnescapeErrorListener {
logEvent("FormalParameterDefaultValueExpression");
}
void handleValuedFormalParameter(Token equals, Token token) {
void handleValuedFormalParameter(
Token equals, Token token, FormalParameterKind kind) {
logEvent("ValuedFormalParameter");
}
@@ -2097,7 +2097,7 @@ class Parser {
listener.endFormalParameterDefaultValueExpression();
// TODO(danrubel): Consider removing the last parameter from the
// handleValuedFormalParameter event... it appears to be unused.
listener.handleValuedFormalParameter(equal, next);
listener.handleValuedFormalParameter(equal, next, parameterKind);
if (parameterKind.isRequiredPositional) {
reportRecoverableError(
equal, codes.messageRequiredParameterWithDefault);
+2 -1
View File
@@ -5484,7 +5484,8 @@ class AstBuilder extends StackListener {
}
@override
void handleValuedFormalParameter(Token equals, Token token) {
void handleValuedFormalParameter(
Token equals, Token token, FormalParameterKind kind) {
assert(optional('=', equals) || optional(':', equals));
debugEvent("ValuedFormalParameter");
@@ -703,7 +703,7 @@ void runAgnosticSharedTests(SetupCompilerOptions setup, TestDriver driver) {
group('Expression compiler tests in static function:', () {
var source = '''
int foo(int x, {int y: 0}) {
int foo(int x, {int y = 0}) {
int z = 3;
// Breakpoint: bp
return x + y + z;
@@ -5448,7 +5448,8 @@ class BodyBuilder extends StackListenerImpl
}
@override
void handleValuedFormalParameter(Token equals, Token token) {
void handleValuedFormalParameter(
Token equals, Token token, FormalParameterKind kind) {
debugEvent("ValuedFormalParameter");
Expression initializer = popForValue();
Object? name = pop();
@@ -5457,6 +5458,13 @@ class BodyBuilder extends StackListenerImpl
} else {
push(new InitializedIdentifier(name as Identifier, initializer));
}
if ((kind == FormalParameterKind.optionalNamed ||
kind == FormalParameterKind.requiredNamed) &&
equals.lexeme == ':' &&
libraryBuilder.languageVersion.version.major >= 3) {
addProblem(fasta.messageObsoleteColonForDefaultValue, equals.charOffset,
equals.charCount);
}
}
@override
@@ -2256,7 +2256,8 @@ class _MacroListener implements Listener {
}
@override
void handleValuedFormalParameter(Token equals, Token token) {
void handleValuedFormalParameter(
Token equals, Token token, FormalParameterKind kind) {
_unsupported();
}
@@ -2549,7 +2549,8 @@ class OutlineBuilder extends StackListenerImpl {
}
@override
void handleValuedFormalParameter(Token equals, Token token) {
void handleValuedFormalParameter(
Token equals, Token token, FormalParameterKind kind) {
debugEvent("ValuedFormalParameter");
// Ignored for now.
}
@@ -2841,11 +2841,13 @@ abstract class AbstractParserAstListener implements Listener {
}
@override
void handleValuedFormalParameter(Token equals, Token token) {
void handleValuedFormalParameter(
Token equals, Token token, FormalParameterKind kind) {
ValuedFormalParameterHandle data = new ValuedFormalParameterHandle(
ParserAstType.HANDLE,
equals: equals,
token: token);
token: token,
kind: kind);
seen(data);
}
@@ -8042,15 +8044,17 @@ class FormalParameterDefaultValueExpressionEnd extends ParserAstNode {
class ValuedFormalParameterHandle extends ParserAstNode {
final Token equals;
final Token token;
final FormalParameterKind kind;
ValuedFormalParameterHandle(ParserAstType type,
{required this.equals, required this.token})
{required this.equals, required this.token, required this.kind})
: super("ValuedFormalParameter", type);
@override
Map<String, Object?> get deprecatedArguments => {
"equals": equals,
"token": token,
"kind": kind,
};
}
+1
View File
@@ -791,6 +791,7 @@ NullableTearoffWarning/analyzerCode: Fail
NullableTearoffWarning/example: Fail
ObjectMemberNameUsedForRecordField/analyzerCode: Fail
ObjectMemberNameUsedForRecordField/example: Fail
ObsoleteColonForDefaultValue/analyzerCode: Fail
OperatorMinusParameterMismatch/example: Fail
OperatorParameterMismatch0/analyzerCode: Fail
OperatorParameterMismatch0/example: Fail
+6
View File
@@ -6513,3 +6513,9 @@ WeakReferenceTargetNotStaticTearoff:
WeakReferenceTargetHasParameters:
problemMessage: "The target of weak reference should not take parameters."
ObsoleteColonForDefaultValue:
problemMessage: "Using a colon as a separator before a default value is no longer supported."
correctionMessage: "Try replacing the colon with an equal sign."
script: |
method({int x: 3}) {}
@@ -147,7 +147,7 @@ beginCompilationUnit(void)
handleLiteralInt(42)
endRecordLiteral((, 2, null)
endFormalParameterDefaultValueExpression()
handleValuedFormalParameter(=, ,)
handleValuedFormalParameter(=, ,, FormalParameterKind.optionalNamed)
endFormalParameter(null, null, null, record1, (, ), FormalParameterKind.optionalNamed, MemberKind.TopLevelMethod)
beginMetadataStar(dynamic)
endMetadataStar(0)
@@ -164,7 +164,7 @@ beginCompilationUnit(void)
endRecordLiteral((, 2, const)
endConstLiteral(})
endFormalParameterDefaultValueExpression()
handleValuedFormalParameter(=, })
handleValuedFormalParameter(=, }, FormalParameterKind.optionalNamed)
endFormalParameter(null, null, null, record2, const, ), FormalParameterKind.optionalNamed, MemberKind.TopLevelMethod)
endOptionalFormalParameters(2, {, })
endFormalParameters(1, (, ), MemberKind.TopLevelMethod)
@@ -350,7 +350,7 @@ parseUnit(void)
ensureCloseParen(42, ()
listener: endRecordLiteral((, 2, null)
listener: endFormalParameterDefaultValueExpression()
listener: handleValuedFormalParameter(=, ,)
listener: handleValuedFormalParameter(=, ,, FormalParameterKind.optionalNamed)
listener: endFormalParameter(null, null, null, record1, (, ), FormalParameterKind.optionalNamed, MemberKind.TopLevelMethod)
parseFormalParameter(,, FormalParameterKind.optionalNamed, MemberKind.TopLevelMethod)
parseMetadataStar(,)
@@ -387,7 +387,7 @@ parseUnit(void)
listener: endRecordLiteral((, 2, const)
listener: endConstLiteral(})
listener: endFormalParameterDefaultValueExpression()
listener: handleValuedFormalParameter(=, })
listener: handleValuedFormalParameter(=, }, FormalParameterKind.optionalNamed)
listener: endFormalParameter(null, null, null, record2, const, ), FormalParameterKind.optionalNamed, MemberKind.TopLevelMethod)
listener: endOptionalFormalParameters(2, {, })
ensureCloseParen(}, ()
@@ -100,7 +100,7 @@ beginCompilationUnit(void)
handleLiteralInt(42)
endRecordLiteral((, 2, null)
endFormalParameterDefaultValueExpression()
handleValuedFormalParameter(:, ,)
handleValuedFormalParameter(:, ,, FormalParameterKind.optionalNamed)
endFormalParameter(null, null, null, foo1, (, ), FormalParameterKind.optionalNamed, MemberKind.TopLevelMethod)
beginMetadataStar(()
endMetadataStar(0)
@@ -130,7 +130,7 @@ beginCompilationUnit(void)
handleLiteralInt(42)
endRecordLiteral((, 2, null)
endFormalParameterDefaultValueExpression()
handleValuedFormalParameter(:, })
handleValuedFormalParameter(:, }, FormalParameterKind.optionalNamed)
endFormalParameter(null, null, null, foo2, (, ), FormalParameterKind.optionalNamed, MemberKind.TopLevelMethod)
endOptionalFormalParameters(2, {, })
endFormalParameters(1, (, ), MemberKind.TopLevelMethod)
@@ -176,7 +176,7 @@ beginCompilationUnit(void)
handleLiteralInt(42)
endRecordLiteral((, 2, null)
endFormalParameterDefaultValueExpression()
handleValuedFormalParameter(=, ,)
handleValuedFormalParameter(=, ,, FormalParameterKind.optionalNamed)
endFormalParameter(null, null, null, foo1, (, ), FormalParameterKind.optionalNamed, MemberKind.TopLevelMethod)
beginMetadataStar(()
endMetadataStar(0)
@@ -206,7 +206,7 @@ beginCompilationUnit(void)
handleLiteralInt(42)
endRecordLiteral((, 2, null)
endFormalParameterDefaultValueExpression()
handleValuedFormalParameter(=, })
handleValuedFormalParameter(=, }, FormalParameterKind.optionalNamed)
endFormalParameter(null, null, null, foo2, (, ), FormalParameterKind.optionalNamed, MemberKind.TopLevelMethod)
endOptionalFormalParameters(2, {, })
endFormalParameters(1, (, ), MemberKind.TopLevelMethod)
@@ -169,7 +169,7 @@ parseUnit(void)
ensureCloseParen(42, ()
listener: endRecordLiteral((, 2, null)
listener: endFormalParameterDefaultValueExpression()
listener: handleValuedFormalParameter(:, ,)
listener: handleValuedFormalParameter(:, ,, FormalParameterKind.optionalNamed)
listener: endFormalParameter(null, null, null, foo1, (, ), FormalParameterKind.optionalNamed, MemberKind.TopLevelMethod)
parseFormalParameter(,, FormalParameterKind.optionalNamed, MemberKind.TopLevelMethod)
parseMetadataStar(,)
@@ -224,7 +224,7 @@ parseUnit(void)
ensureCloseParen(42, ()
listener: endRecordLiteral((, 2, null)
listener: endFormalParameterDefaultValueExpression()
listener: handleValuedFormalParameter(:, })
listener: handleValuedFormalParameter(:, }, FormalParameterKind.optionalNamed)
listener: endFormalParameter(null, null, null, foo2, (, ), FormalParameterKind.optionalNamed, MemberKind.TopLevelMethod)
listener: endOptionalFormalParameters(2, {, })
ensureCloseParen(}, ()
@@ -310,7 +310,7 @@ parseUnit(void)
ensureCloseParen(42, ()
listener: endRecordLiteral((, 2, null)
listener: endFormalParameterDefaultValueExpression()
listener: handleValuedFormalParameter(=, ,)
listener: handleValuedFormalParameter(=, ,, FormalParameterKind.optionalNamed)
listener: endFormalParameter(null, null, null, foo1, (, ), FormalParameterKind.optionalNamed, MemberKind.TopLevelMethod)
parseFormalParameter(,, FormalParameterKind.optionalNamed, MemberKind.TopLevelMethod)
parseMetadataStar(,)
@@ -365,7 +365,7 @@ parseUnit(void)
ensureCloseParen(42, ()
listener: endRecordLiteral((, 2, null)
listener: endFormalParameterDefaultValueExpression()
listener: handleValuedFormalParameter(=, })
listener: handleValuedFormalParameter(=, }, FormalParameterKind.optionalNamed)
listener: endFormalParameter(null, null, null, foo2, (, ), FormalParameterKind.optionalNamed, MemberKind.TopLevelMethod)
listener: endOptionalFormalParameters(2, {, })
ensureCloseParen(}, ()
@@ -100,7 +100,7 @@ beginCompilationUnit(void)
handleLiteralInt(42)
endRecordLiteral((, 2, null)
endFormalParameterDefaultValueExpression()
handleValuedFormalParameter(=, ,)
handleValuedFormalParameter(=, ,, FormalParameterKind.optionalPositional)
endFormalParameter(null, null, null, foo1, (, ), FormalParameterKind.optionalPositional, MemberKind.TopLevelMethod)
beginMetadataStar(()
endMetadataStar(0)
@@ -130,7 +130,7 @@ beginCompilationUnit(void)
handleLiteralInt(42)
endRecordLiteral((, 2, null)
endFormalParameterDefaultValueExpression()
handleValuedFormalParameter(=, ])
handleValuedFormalParameter(=, ], FormalParameterKind.optionalPositional)
endFormalParameter(null, null, null, foo2, (, ), FormalParameterKind.optionalPositional, MemberKind.TopLevelMethod)
endOptionalFormalParameters(2, [, ])
endFormalParameters(1, (, ), MemberKind.TopLevelMethod)
@@ -169,7 +169,7 @@ parseUnit(void)
ensureCloseParen(42, ()
listener: endRecordLiteral((, 2, null)
listener: endFormalParameterDefaultValueExpression()
listener: handleValuedFormalParameter(=, ,)
listener: handleValuedFormalParameter(=, ,, FormalParameterKind.optionalPositional)
listener: endFormalParameter(null, null, null, foo1, (, ), FormalParameterKind.optionalPositional, MemberKind.TopLevelMethod)
parseFormalParameter(,, FormalParameterKind.optionalPositional, MemberKind.TopLevelMethod)
parseMetadataStar(,)
@@ -224,7 +224,7 @@ parseUnit(void)
ensureCloseParen(42, ()
listener: endRecordLiteral((, 2, null)
listener: endFormalParameterDefaultValueExpression()
listener: handleValuedFormalParameter(=, ])
listener: handleValuedFormalParameter(=, ], FormalParameterKind.optionalPositional)
listener: endFormalParameter(null, null, null, foo2, (, ), FormalParameterKind.optionalPositional, MemberKind.TopLevelMethod)
listener: endOptionalFormalParameters(2, [, ])
ensureCloseParen(], ()
+3 -2
View File
@@ -2987,10 +2987,11 @@ class ParserTestListener implements Listener {
}
@override
void handleValuedFormalParameter(Token equals, Token token) {
void handleValuedFormalParameter(
Token equals, Token token, FormalParameterKind kind) {
seen(equals);
seen(token);
doPrint('handleValuedFormalParameter(' '$equals, ' '$token)');
doPrint('handleValuedFormalParameter(' '$equals, ' '$token, ' '$kind)');
}
@override
@@ -975,6 +975,7 @@ obj
obligated
observatory
observe
obsolete
obstruct
obtaining
occasionally
@@ -6,7 +6,7 @@ main.dart.patch: |
// Test that an instance tear-off with named parameters can be called
class C {
foo({a, named: 'v1', x}) {
foo({a, named = 'v1', x}) {
print(named);
}
}
@@ -6,7 +6,7 @@ main.dart.patch: |
// Test that named arguments can be called
class C {
foo({a, named: 'v1', x}) {
foo({a, named = 'v1', x}) {
print(named);
}
}
@@ -6,7 +6,7 @@ main.dart.patch: |
// Test that named arguments can be called
class C {
foo({a, named: 'v2', x}) {
foo({a, named = 'v2', x}) {
print(named);
}
}
@@ -8,7 +8,7 @@ main.dart.patch: |
// the same class.
class C {
foo({a: 'v2'}) {
foo({a = 'v2'}) {
print(a);
}
@@ -7,7 +7,7 @@ main.dart.patch: |
// when updated
class C {
m({a: 'a'}) {
m({a = 'a'}) {
<<<< ["closure is null","v1"]
print('v1');
==== "v2"
@@ -0,0 +1,12 @@
// Copyright (c) 2023, 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.
topLevel({int x: 3}) {}
class Class {
method({int x: 3}) {
local({int x: 3}) {}
({int x: 3}) {};
}
}
@@ -0,0 +1,41 @@
library /*isNonNullableByDefault*/;
//
// Problems in library:
//
// pkg/front_end/testcases/general/colon_default_value.dart:5:16: Error: Using a colon as a separator before a default value is no longer supported.
// Try replacing the colon with an equal sign.
// topLevel({int x: 3}) {}
// ^
//
// pkg/front_end/testcases/general/colon_default_value.dart:8:16: Error: Using a colon as a separator before a default value is no longer supported.
// Try replacing the colon with an equal sign.
// method({int x: 3}) {
// ^
//
// pkg/front_end/testcases/general/colon_default_value.dart:9:17: Error: Using a colon as a separator before a default value is no longer supported.
// Try replacing the colon with an equal sign.
// local({int x: 3}) {}
// ^
//
// pkg/front_end/testcases/general/colon_default_value.dart:10:12: Error: Using a colon as a separator before a default value is no longer supported.
// Try replacing the colon with an equal sign.
// ({int x: 3}) {};
// ^
//
import self as self;
import "dart:core" as core;
class Class extends core::Object {
synthetic constructor •() → self::Class
: super core::Object::•()
;
method method({core::int x = #C1}) → dynamic {
function local({core::int x = #C1}) → Null {}
({core::int x = #C1}) → Null {};
}
}
static method topLevel({core::int x = #C1}) → dynamic {}
constants {
#C1 = 3
}
@@ -0,0 +1,41 @@
library /*isNonNullableByDefault*/;
//
// Problems in library:
//
// pkg/front_end/testcases/general/colon_default_value.dart:5:16: Error: Using a colon as a separator before a default value is no longer supported.
// Try replacing the colon with an equal sign.
// topLevel({int x: 3}) {}
// ^
//
// pkg/front_end/testcases/general/colon_default_value.dart:8:16: Error: Using a colon as a separator before a default value is no longer supported.
// Try replacing the colon with an equal sign.
// method({int x: 3}) {
// ^
//
// pkg/front_end/testcases/general/colon_default_value.dart:9:17: Error: Using a colon as a separator before a default value is no longer supported.
// Try replacing the colon with an equal sign.
// local({int x: 3}) {}
// ^
//
// pkg/front_end/testcases/general/colon_default_value.dart:10:12: Error: Using a colon as a separator before a default value is no longer supported.
// Try replacing the colon with an equal sign.
// ({int x: 3}) {};
// ^
//
import self as self;
import "dart:core" as core;
class Class extends core::Object {
synthetic constructor •() → self::Class
: super core::Object::•()
;
method method({core::int x = #C1}) → dynamic {
function local({core::int x = #C1}) → Null {}
({core::int x = #C1}) → Null {};
}
}
static method topLevel({core::int x = #C1}) → dynamic {}
constants {
#C1 = 3
}
@@ -0,0 +1,5 @@
topLevel({int x: 3}) {}
class Class {
method({int x: 3}) {}
}
@@ -0,0 +1,5 @@
class Class {
method({int x: 3}) {}
}
topLevel({int x: 3}) {}
@@ -0,0 +1,41 @@
library /*isNonNullableByDefault*/;
//
// Problems in library:
//
// pkg/front_end/testcases/general/colon_default_value.dart:5:16: Error: Using a colon as a separator before a default value is no longer supported.
// Try replacing the colon with an equal sign.
// topLevel({int x: 3}) {}
// ^
//
// pkg/front_end/testcases/general/colon_default_value.dart:8:16: Error: Using a colon as a separator before a default value is no longer supported.
// Try replacing the colon with an equal sign.
// method({int x: 3}) {
// ^
//
// pkg/front_end/testcases/general/colon_default_value.dart:9:17: Error: Using a colon as a separator before a default value is no longer supported.
// Try replacing the colon with an equal sign.
// local({int x: 3}) {}
// ^
//
// pkg/front_end/testcases/general/colon_default_value.dart:10:12: Error: Using a colon as a separator before a default value is no longer supported.
// Try replacing the colon with an equal sign.
// ({int x: 3}) {};
// ^
//
import self as self;
import "dart:core" as core;
class Class extends core::Object {
synthetic constructor •() → self::Class
: super core::Object::•()
;
method method({core::int x = #C1}) → dynamic {
function local({core::int x = #C1}) → Null {}
({core::int x = #C1}) → Null {};
}
}
static method topLevel({core::int x = #C1}) → dynamic {}
constants {
#C1 = 3
}
@@ -0,0 +1,41 @@
library /*isNonNullableByDefault*/;
//
// Problems in library:
//
// pkg/front_end/testcases/general/colon_default_value.dart:5:16: Error: Using a colon as a separator before a default value is no longer supported.
// Try replacing the colon with an equal sign.
// topLevel({int x: 3}) {}
// ^
//
// pkg/front_end/testcases/general/colon_default_value.dart:8:16: Error: Using a colon as a separator before a default value is no longer supported.
// Try replacing the colon with an equal sign.
// method({int x: 3}) {
// ^
//
// pkg/front_end/testcases/general/colon_default_value.dart:9:17: Error: Using a colon as a separator before a default value is no longer supported.
// Try replacing the colon with an equal sign.
// local({int x: 3}) {}
// ^
//
// pkg/front_end/testcases/general/colon_default_value.dart:10:12: Error: Using a colon as a separator before a default value is no longer supported.
// Try replacing the colon with an equal sign.
// ({int x: 3}) {};
// ^
//
import self as self;
import "dart:core" as core;
class Class extends core::Object {
synthetic constructor •() → self::Class
: super core::Object::•()
;
method method({core::int x = #C1}) → dynamic {
function local({core::int x = #C1}) → Null {}
({core::int x = #C1}) → Null {};
}
}
static method topLevel({core::int x = #C1}) → dynamic {}
constants {
#C1 = 3
}
@@ -0,0 +1,12 @@
library /*isNonNullableByDefault*/;
import self as self;
import "dart:core" as core;
class Class extends core::Object {
synthetic constructor •() → self::Class
;
method method({core::int x = 3}) → dynamic
;
}
static method topLevel({has-declared-initializer core::int x}) → dynamic
;
@@ -0,0 +1,41 @@
library /*isNonNullableByDefault*/;
//
// Problems in library:
//
// pkg/front_end/testcases/general/colon_default_value.dart:5:16: Error: Using a colon as a separator before a default value is no longer supported.
// Try replacing the colon with an equal sign.
// topLevel({int x: 3}) {}
// ^
//
// pkg/front_end/testcases/general/colon_default_value.dart:8:16: Error: Using a colon as a separator before a default value is no longer supported.
// Try replacing the colon with an equal sign.
// method({int x: 3}) {
// ^
//
// pkg/front_end/testcases/general/colon_default_value.dart:9:17: Error: Using a colon as a separator before a default value is no longer supported.
// Try replacing the colon with an equal sign.
// local({int x: 3}) {}
// ^
//
// pkg/front_end/testcases/general/colon_default_value.dart:10:12: Error: Using a colon as a separator before a default value is no longer supported.
// Try replacing the colon with an equal sign.
// ({int x: 3}) {};
// ^
//
import self as self;
import "dart:core" as core;
class Class extends core::Object {
synthetic constructor •() → self::Class
: super core::Object::•()
;
method method({core::int x = #C1}) → dynamic {
function local({core::int x = #C1}) → Null {}
({core::int x = #C1}) → Null {};
}
}
static method topLevel({core::int x = #C1}) → dynamic {}
constants {
#C1 = 3
}
@@ -0,0 +1,14 @@
// Copyright (c) 2023, 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.
// @dart=2.19
topLevel({int x: 3}) {}
class Class {
method({int x: 3}) {
local({int x: 3}) {}
({int x: 3}) {};
}
}
@@ -0,0 +1,18 @@
library /*isNonNullableByDefault*/;
import self as self;
import "dart:core" as core;
class Class extends core::Object {
synthetic constructor •() → self::Class
: super core::Object::•()
;
method method({core::int x = #C1}) → dynamic {
function local({core::int x = #C1}) → Null {}
({core::int x = #C1}) → Null {};
}
}
static method topLevel({core::int x = #C1}) → dynamic {}
constants {
#C1 = 3
}
@@ -0,0 +1,18 @@
library /*isNonNullableByDefault*/;
import self as self;
import "dart:core" as core;
class Class extends core::Object {
synthetic constructor •() → self::Class
: super core::Object::•()
;
method method({core::int x = #C1}) → dynamic {
function local({core::int x = #C1}) → Null {}
({core::int x = #C1}) → Null {};
}
}
static method topLevel({core::int x = #C1}) → dynamic {}
constants {
#C1 = 3
}
@@ -0,0 +1,6 @@
// @dart = 2.19
topLevel({int x: 3}) {}
class Class {
method({int x: 3}) {}
}
@@ -0,0 +1,6 @@
// @dart = 2.19
class Class {
method({int x: 3}) {}
}
topLevel({int x: 3}) {}
@@ -0,0 +1,18 @@
library /*isNonNullableByDefault*/;
import self as self;
import "dart:core" as core;
class Class extends core::Object {
synthetic constructor •() → self::Class
: super core::Object::•()
;
method method({core::int x = #C1}) → dynamic {
function local({core::int x = #C1}) → Null {}
({core::int x = #C1}) → Null {};
}
}
static method topLevel({core::int x = #C1}) → dynamic {}
constants {
#C1 = 3
}
@@ -0,0 +1,18 @@
library /*isNonNullableByDefault*/;
import self as self;
import "dart:core" as core;
class Class extends core::Object {
synthetic constructor •() → self::Class
: super core::Object::•()
;
method method({core::int x = #C1}) → dynamic {
function local({core::int x = #C1}) → Null {}
({core::int x = #C1}) → Null {};
}
}
static method topLevel({core::int x = #C1}) → dynamic {}
constants {
#C1 = 3
}
@@ -0,0 +1,12 @@
library /*isNonNullableByDefault*/;
import self as self;
import "dart:core" as core;
class Class extends core::Object {
synthetic constructor •() → self::Class
;
method method({core::int x = 3}) → dynamic
;
}
static method topLevel({has-declared-initializer core::int x}) → dynamic
;
@@ -0,0 +1,18 @@
library /*isNonNullableByDefault*/;
import self as self;
import "dart:core" as core;
class Class extends core::Object {
synthetic constructor •() → self::Class
: super core::Object::•()
;
method method({core::int x = #C1}) → dynamic {
function local({core::int x = #C1}) → Null {}
({core::int x = #C1}) → Null {};
}
}
static method topLevel({core::int x = #C1}) → dynamic {}
constants {
#C1 = 3
}
@@ -2,6 +2,6 @@
// 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;
void Function({obj = Object})? x;
main() {}
@@ -2,21 +2,21 @@ library /*isNonNullableByDefault*/;
//
// Problems in library:
//
// pkg/front_end/testcases/general/function_type_default_value.dart:5:19: Error: Expected an identifier, but got ':'.
// Try inserting an identifier before ':'.
// void Function({obj: Object})? x;
// ^
// pkg/front_end/testcases/general/function_type_default_value.dart:5:20: Error: Expected an identifier, but got '='.
// Try inserting an identifier before '='.
// void Function({obj = Object})? x;
// ^
//
// pkg/front_end/testcases/general/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/general/function_type_default_value.dart:5:20: Error: Can't have a default value in a function type.
// void Function({obj = Object})? x;
// ^
//
// pkg/front_end/testcases/general/function_type_default_value.dart:5:16: Error: Type 'obj' not found.
// void Function({obj: Object})? x;
// void Function({obj = Object})? x;
// ^^^
//
// pkg/front_end/testcases/general/function_type_default_value.dart:5:16: Error: 'obj' isn't a type.
// void Function({obj: Object})? x;
// void Function({obj = Object})? x;
// ^^^
//
import self as self;
@@ -2,21 +2,21 @@ library /*isNonNullableByDefault*/;
//
// Problems in library:
//
// pkg/front_end/testcases/general/function_type_default_value.dart:5:19: Error: Expected an identifier, but got ':'.
// Try inserting an identifier before ':'.
// void Function({obj: Object})? x;
// ^
// pkg/front_end/testcases/general/function_type_default_value.dart:5:20: Error: Expected an identifier, but got '='.
// Try inserting an identifier before '='.
// void Function({obj = Object})? x;
// ^
//
// pkg/front_end/testcases/general/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/general/function_type_default_value.dart:5:20: Error: Can't have a default value in a function type.
// void Function({obj = Object})? x;
// ^
//
// pkg/front_end/testcases/general/function_type_default_value.dart:5:16: Error: Type 'obj' not found.
// void Function({obj: Object})? x;
// void Function({obj = Object})? x;
// ^^^
//
// pkg/front_end/testcases/general/function_type_default_value.dart:5:16: Error: 'obj' isn't a type.
// void Function({obj: Object})? x;
// void Function({obj = Object})? x;
// ^^^
//
import self as self;
@@ -1,2 +1,2 @@
void Function({obj: Object})? x;
void Function({obj = Object})? x;
main() {}
@@ -2,21 +2,21 @@ library /*isNonNullableByDefault*/;
//
// Problems in library:
//
// pkg/front_end/testcases/general/function_type_default_value.dart:5:19: Error: Expected an identifier, but got ':'.
// Try inserting an identifier before ':'.
// void Function({obj: Object})? x;
// ^
// pkg/front_end/testcases/general/function_type_default_value.dart:5:20: Error: Expected an identifier, but got '='.
// Try inserting an identifier before '='.
// void Function({obj = Object})? x;
// ^
//
// pkg/front_end/testcases/general/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/general/function_type_default_value.dart:5:20: Error: Can't have a default value in a function type.
// void Function({obj = Object})? x;
// ^
//
// pkg/front_end/testcases/general/function_type_default_value.dart:5:16: Error: Type 'obj' not found.
// void Function({obj: Object})? x;
// void Function({obj = Object})? x;
// ^^^
//
// pkg/front_end/testcases/general/function_type_default_value.dart:5:16: Error: 'obj' isn't a type.
// void Function({obj: Object})? x;
// void Function({obj = Object})? x;
// ^^^
//
import self as self;
@@ -2,21 +2,21 @@ library /*isNonNullableByDefault*/;
//
// Problems in library:
//
// pkg/front_end/testcases/general/function_type_default_value.dart:5:19: Error: Expected an identifier, but got ':'.
// Try inserting an identifier before ':'.
// void Function({obj: Object})? x;
// ^
// pkg/front_end/testcases/general/function_type_default_value.dart:5:20: Error: Expected an identifier, but got '='.
// Try inserting an identifier before '='.
// void Function({obj = Object})? x;
// ^
//
// pkg/front_end/testcases/general/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/general/function_type_default_value.dart:5:20: Error: Can't have a default value in a function type.
// void Function({obj = Object})? x;
// ^
//
// pkg/front_end/testcases/general/function_type_default_value.dart:5:16: Error: Type 'obj' not found.
// void Function({obj: Object})? x;
// void Function({obj = Object})? x;
// ^^^
//
// pkg/front_end/testcases/general/function_type_default_value.dart:5:16: Error: 'obj' isn't a type.
// void Function({obj: Object})? x;
// void Function({obj = Object})? x;
// ^^^
//
import self as self;
@@ -2,17 +2,17 @@ library /*isNonNullableByDefault*/;
//
// Problems in library:
//
// pkg/front_end/testcases/general/function_type_default_value.dart:5:19: Error: Expected an identifier, but got ':'.
// Try inserting an identifier before ':'.
// void Function({obj: Object})? x;
// ^
// pkg/front_end/testcases/general/function_type_default_value.dart:5:20: Error: Expected an identifier, but got '='.
// Try inserting an identifier before '='.
// void Function({obj = Object})? x;
// ^
//
// pkg/front_end/testcases/general/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/general/function_type_default_value.dart:5:20: Error: Can't have a default value in a function type.
// void Function({obj = Object})? x;
// ^
//
// pkg/front_end/testcases/general/function_type_default_value.dart:5:16: Error: Type 'obj' not found.
// void Function({obj: Object})? x;
// void Function({obj = Object})? x;
// ^^^
//
import self as self;
@@ -2,21 +2,21 @@ library /*isNonNullableByDefault*/;
//
// Problems in library:
//
// pkg/front_end/testcases/general/function_type_default_value.dart:5:19: Error: Expected an identifier, but got ':'.
// Try inserting an identifier before ':'.
// void Function({obj: Object})? x;
// ^
// pkg/front_end/testcases/general/function_type_default_value.dart:5:20: Error: Expected an identifier, but got '='.
// Try inserting an identifier before '='.
// void Function({obj = Object})? x;
// ^
//
// pkg/front_end/testcases/general/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/general/function_type_default_value.dart:5:20: Error: Can't have a default value in a function type.
// void Function({obj = Object})? x;
// ^
//
// pkg/front_end/testcases/general/function_type_default_value.dart:5:16: Error: Type 'obj' not found.
// void Function({obj: Object})? x;
// void Function({obj = Object})? x;
// ^^^
//
// pkg/front_end/testcases/general/function_type_default_value.dart:5:16: Error: 'obj' isn't a type.
// void Function({obj: Object})? x;
// void Function({obj = Object})? x;
// ^^^
//
import self as self;
@@ -18,7 +18,7 @@ worlds:
lib.dart: |
abstract class Interface {
int method5c([int a = 0, int? b]);
int method7b({int a: 0, int? b});
int method7b({int a = 0, int? b});
}
class Class {
int method5c([int a = 0, int? b]) => 0;
+1 -1
View File
@@ -52,7 +52,7 @@ class C$i {
""");
if (i == (n - 1)) {
sb.write("""
test({bool rareCase: false}) {
test({bool rareCase = false}) {
final v = this.f;
if (rareCase) {
return v.f;
+1 -1
View File
@@ -54,7 +54,7 @@ class C$i {
""");
if (i == (n - 1)) {
sb.write("""
test({bool rareCase: false}) {
test({bool rareCase = false}) {
final v = this.f;
if (rareCase) {
return v.f;
+1 -1
View File
@@ -1705,7 +1705,7 @@ TEST_CASE(IsolateReload_TearOff_Remove) {
const char* kScript =
"import 'file:///test:isolate_reload_helper';\n"
"class C {\n"
" static foo({String bar: 'bar'}) => 'old';\n"
" static foo({String bar = 'bar'}) => 'old';\n"
"}\n"
"main() {\n"
" var f1 = C.foo;\n"
+1 -1
View File
@@ -1860,7 +1860,7 @@ ISOLATE_UNIT_TEST_CASE(TTS_Function) {
createF() => (){};
createG() => () => 3;
createH() => (int x, String y, {int z : 0}) => x + z;
createH() => (int x, String y, {int z = 0}) => x + z;
createAInt() => A<int>();
createAFunction() => A<Function>();