-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge 07d2288 into dev
- Loading branch information
Showing
15 changed files
with
157 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
tests/language/wildcard_variables/unnamed_optional/unnamed_optional_error_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// Copyright (c) 2024, 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. | ||
|
||
// Tests that we still need default values for `this._` and `super._` and that | ||
// we can't add default values to a `_` named parameter where you can't add | ||
// default values. | ||
|
||
// SharedOptions=--enable-experiment=wildcard-variables | ||
|
||
class SuperClass { | ||
SuperClass([int _]); | ||
// ^ | ||
// [analyzer] COMPILE_TIME_ERROR.MISSING_DEFAULT_VALUE_FOR_PARAMETER | ||
// [cfe] The parameter '_' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'. | ||
SuperClass.nullable([int? _]); | ||
} | ||
class SubClass extends SuperClass { | ||
final int _; | ||
SubClass([ | ||
this._, | ||
// ^ | ||
// [analyzer] COMPILE_TIME_ERROR.MISSING_DEFAULT_VALUE_FOR_PARAMETER | ||
// [cfe] The parameter '_' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'. | ||
super._, | ||
// ^ | ||
// [analyzer] COMPILE_TIME_ERROR.DUPLICATE_DEFINITION | ||
// [analyzer] COMPILE_TIME_ERROR.MISSING_DEFAULT_VALUE_FOR_PARAMETER | ||
// [cfe] Duplicated parameter name '_'. | ||
// [cfe] The parameter '_' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'. | ||
// [cfe] Type 'int' of the optional super-initializer parameter '_' doesn't allow 'null', but the parameter doesn't have a default value, and the default value can't be copied from the corresponding parameter of the super constructor. | ||
]); | ||
} | ||
class TypedSubClass extends SuperClass { | ||
final int? _; | ||
TypedSubClass([ | ||
int this._, | ||
// ^ | ||
// [analyzer] COMPILE_TIME_ERROR.MISSING_DEFAULT_VALUE_FOR_PARAMETER | ||
// [cfe] The parameter '_' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'. | ||
int super._, | ||
// ^ | ||
// [analyzer] COMPILE_TIME_ERROR.DUPLICATE_DEFINITION | ||
// [analyzer] COMPILE_TIME_ERROR.MISSING_DEFAULT_VALUE_FOR_PARAMETER | ||
// [cfe] Duplicated parameter name '_'. | ||
// [cfe] The parameter '_' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'. | ||
// [cfe] Type 'int' of the optional super-initializer parameter '_' doesn't allow 'null', but the parameter doesn't have a default value, and the default value can't be copied from the corresponding parameter of the super constructor. | ||
]) : super.nullable(); | ||
} | ||
|
||
// Function type parameters cannot have default values. | ||
typedef F = void Function([int _ = 1]); | ||
// ^ | ||
// [analyzer] SYNTACTIC_ERROR.DEFAULT_VALUE_IN_FUNCTION_TYPE | ||
// [cfe] Can't have a default value in a function type. | ||
|
||
// Redirecting factory constructors cannot have default values. | ||
class ReClass { | ||
ReClass([int x = 0]); | ||
factory ReClass.redir([int _ = 0]) = ReClass; | ||
// ^ | ||
// [analyzer] COMPILE_TIME_ERROR.DEFAULT_VALUE_IN_REDIRECTING_FACTORY_CONSTRUCTOR | ||
// ^ | ||
// [cfe] Can't have a default value here because any default values of 'ReClass' would be used instead. | ||
} |
61 changes: 61 additions & 0 deletions
61
tests/language/wildcard_variables/unnamed_optional/unnamed_optional_no_default_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Copyright (c) 2024, 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. | ||
|
||
// Unnamed optional parameters, which are not initializing or super parameters, | ||
// that have no default values, have no errors. | ||
|
||
// SharedOptions=--enable-experiment=wildcard-variables | ||
|
||
import 'package:expect/expect.dart'; | ||
|
||
class C { | ||
C([int _]) {} | ||
C.otherParams([int _, bool x = false, bool _ = true]) {} | ||
C.otherParams2([int _ = 1, bool x = false, bool _]) {} | ||
|
||
int foo([int _]) => 1; | ||
int foo2([bool x = false, bool _, int _]) => 1; | ||
int foo3([bool? x, bool _ = false, int _]) => 1; | ||
int foo4([int _, bool? x, bool _ = false]) => 1; | ||
|
||
static int fn([int _]) => 1; | ||
static int fn2([bool x = false, bool _, int _]) => 1; | ||
static int fn3([bool? x, bool _ = false, int _]) => 1; | ||
static int fn4([int _, bool? x, bool _ = false]) => 1; | ||
} | ||
|
||
int _([bool _]) => 1; | ||
int topFoo2([bool x = false, bool _, int _]) => 1; | ||
int topFoo3([bool? x, bool _ = false, int _]) => 1; | ||
int topFoo4([int _, bool? x, bool _ = false]) => 1; | ||
|
||
void main() { | ||
Expect.equals(1, _()); | ||
Expect.equals(1, topFoo2()); | ||
Expect.equals(1, topFoo3()); | ||
Expect.equals(1, topFoo4()); | ||
|
||
int foo([int _]) => 1; | ||
int foo2([bool x = false, bool _, int _]) => 1; | ||
int foo3([bool? x, bool _ = false, int _]) => 1; | ||
int foo4([int _, bool? x, bool _ = false]) => 1; | ||
Expect.equals(1, foo()); | ||
Expect.equals(1, foo2()); | ||
Expect.equals(1, foo3()); | ||
Expect.equals(1, foo4()); | ||
|
||
var c = C(); | ||
Expect.equals(1, c.foo()); | ||
Expect.equals(1, c.foo2()); | ||
Expect.equals(1, c.foo3()); | ||
Expect.equals(1, c.foo4()); | ||
|
||
Expect.equals(1, C.otherParams().foo()); | ||
Expect.equals(1, C.otherParams2().foo()); | ||
|
||
Expect.equals(1, C.fn()); | ||
Expect.equals(1, C.fn2()); | ||
Expect.equals(1, C.fn3()); | ||
Expect.equals(1, C.fn4()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,4 +16,5 @@ dev_dependencies: | |
args: any | ||
collection: any | ||
http: any | ||
lints: any | ||
path: any |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,17 @@ | ||
name: language_server_protocol | ||
version: 0.0.0 | ||
description: >- | ||
A Dart implementation of the language server protocol. | ||
repository: https://github.com/dart-lang/sdk/tree/main/third_party/pkg/language_server_protocol | ||
|
||
publish_to: none | ||
|
||
environment: | ||
sdk: '>=3.0.0 <4.0.0' | ||
|
||
# Use 'any' constraints here; we get our versions from the DEPS file. | ||
dependencies: | ||
collection: 'any' | ||
collection: any | ||
|
||
dependency_overrides: | ||
collection: | ||
path: ../collection | ||
# Use 'any' constraints here; we get our versions from the DEPS file. | ||
dev_dependencies: | ||
lints: any |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,5 +27,5 @@ CHANNEL dev | |
MAJOR 3 | ||
MINOR 5 | ||
PATCH 0 | ||
PRERELEASE 238 | ||
PRERELEASE 239 | ||
PRERELEASE_PATCH 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters