Version 2.16.0-45.0.dev
Merge commit '71a551d5127097e6c6ac166a390d861385044046' into 'dev'
diff --git a/pkg/front_end/test/fasta/parser/type_info_test.dart b/pkg/front_end/test/fasta/parser/type_info_test.dart
index 26fb78f..8402482 100644
--- a/pkg/front_end/test/fasta/parser/type_info_test.dart
+++ b/pkg/front_end/test/fasta/parser/type_info_test.dart
@@ -2,8 +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.
-// @dart = 2.9
-
import 'package:_fe_analyzer_shared/src/parser/parser.dart';
import 'package:_fe_analyzer_shared/src/parser/type_info.dart';
import 'package:_fe_analyzer_shared/src/parser/type_info_impl.dart';
@@ -298,12 +296,12 @@
void test_prefixedTypeInfo() {
final Token start = scanString('before C.a ;').tokens;
- final Token expectedEnd = start.next.next.next;
+ final Token expectedEnd = start.next!.next!.next!;
expect(prefixedType.skipType(start), expectedEnd);
expect(prefixedType.couldBeExpression, isTrue);
- TypeInfoListener listener;
+ late TypeInfoListener listener;
void assertResult(Token actualEnd) {
expect(actualEnd, expectedEnd);
expect(listener.calls, [
@@ -374,12 +372,12 @@
void test_simpleNullableType() {
final Token start = scanString('before C? ;').tokens;
- final Token expectedEnd = start.next.next;
+ final Token expectedEnd = start.next!.next!;
expect(simpleNullableType.skipType(start), expectedEnd);
expect(simpleNullableType.couldBeExpression, isTrue);
- TypeInfoListener listener;
+ late TypeInfoListener listener;
void assertResult(Token actualEnd) {
expect(actualEnd, expectedEnd);
expect(listener.calls, [
@@ -424,13 +422,13 @@
void test_gt_questionMark() {
final Token start = scanString('before C<T>? ;').tokens;
- final Token expectedEnd = start.next.next.next.next.next;
+ final Token expectedEnd = start.next!.next!.next!.next!.next!;
expect(expectedEnd.lexeme, '?');
expect(simpleNullableTypeWith1Argument.skipType(start), expectedEnd);
expect(simpleNullableTypeWith1Argument.couldBeExpression, isFalse);
- TypeInfoListener listener;
+ late TypeInfoListener listener;
void assertResult(Token actualEnd) {
expect(actualEnd, expectedEnd);
expect(listener.calls, [
@@ -495,12 +493,12 @@
void test_simpleType() {
final Token start = scanString('before C ;').tokens;
- final Token expectedEnd = start.next;
+ final Token expectedEnd = start.next!;
expect(simpleType.skipType(start), expectedEnd);
expect(simpleType.couldBeExpression, isTrue);
- TypeInfoListener listener;
+ late TypeInfoListener listener;
void assertResult(Token actualEnd) {
expect(actualEnd, expectedEnd);
expect(listener.calls, [
@@ -568,13 +566,13 @@
void test_gt() {
final Token start = scanString('before C<T> ;').tokens;
- final Token expectedEnd = start.next.next.next.next;
+ final Token expectedEnd = start.next!.next!.next!.next!;
expect(expectedEnd.lexeme, '>');
expect(simpleTypeWith1Argument.skipType(start), expectedEnd);
expect(simpleTypeWith1Argument.couldBeExpression, isFalse);
- TypeInfoListener listener;
+ late TypeInfoListener listener;
void assertResult(Token actualEnd) {
expect(actualEnd, expectedEnd);
expect(listener.calls, [
@@ -608,21 +606,21 @@
void test_gt_eq() {
final Token start = scanString('before C<T>= ;').tokens;
- final Token t = start.next.next.next;
- final Token semicolon = t.next.next;
+ final Token t = start.next!.next!.next!;
+ final Token semicolon = t.next!.next!;
expect(semicolon.lexeme, ';');
Token skip = simpleTypeWith1ArgumentGtEq.skipType(start);
expect(skip.lexeme, '>');
- expect(skip.next.lexeme, '=');
- expect(skip.next.next, semicolon);
+ expect(skip.next!.lexeme, '=');
+ expect(skip.next!.next, semicolon);
expect(simpleTypeWith1ArgumentGtEq.couldBeExpression, isFalse);
- TypeInfoListener listener;
+ late TypeInfoListener listener;
void assertResult(Token actualEnd) {
expect(actualEnd.lexeme, '>');
- expect(actualEnd.next.lexeme, '=');
- expect(actualEnd.next.next, semicolon);
+ expect(actualEnd.next!.lexeme, '=');
+ expect(actualEnd.next!.next, semicolon);
expect(listener.calls, [
'handleIdentifier C typeReference',
'beginTypeArguments <',
@@ -654,20 +652,20 @@
void test_gt_gt() {
final Token start = scanString('before C<T>> ;').tokens;
- final Token semicolon = start.next.next.next.next.next;
+ final Token semicolon = start.next!.next!.next!.next!.next!;
expect(semicolon.lexeme, ';');
Token skip = simpleTypeWith1ArgumentGtGt.skipType(start);
expect(skip.lexeme, '>');
- expect(skip.next.lexeme, '>');
- expect(skip.next.next, semicolon);
+ expect(skip.next!.lexeme, '>');
+ expect(skip.next!.next, semicolon);
expect(simpleTypeWith1ArgumentGtGt.couldBeExpression, isFalse);
- TypeInfoListener listener;
+ late TypeInfoListener listener;
void assertResult(Token actualEnd) {
expect(actualEnd.lexeme, '>');
- expect(actualEnd.next.lexeme, '>');
- expect(actualEnd.next.next, semicolon);
+ expect(actualEnd.next!.lexeme, '>');
+ expect(actualEnd.next!.next, semicolon);
expect(listener.calls, [
'handleIdentifier C typeReference',
'beginTypeArguments <',
@@ -1592,7 +1590,7 @@
expect(simpleTypeArgument1.typeInfo, simpleTypeWith1Argument);
final Token start = scanString('before <T> after').tokens;
- final Token gt = start.next.next.next;
+ final Token gt = start.next!.next!.next!;
expect(gt.lexeme, '>');
Token skip = simpleTypeArgument1.skip(start);
@@ -1606,14 +1604,14 @@
expect(simpleTypeArgument1GtEq.typeInfo, simpleTypeWith1ArgumentGtEq);
final Token start = scanString('before <T>= after').tokens;
- Token t = start.next.next;
- expect(t.next.lexeme, '>=');
+ Token t = start.next!.next!;
+ expect(t.next!.lexeme, '>=');
Token skip = simpleTypeArgument1GtEq.skip(start);
validateTokens(start);
expect(skip.lexeme, '>');
- expect(skip.next.lexeme, '=');
- expect(skip.next.next, t.next.next);
+ expect(skip.next!.lexeme, '=');
+ expect(skip.next!.next, t.next!.next);
}
void test_basic_gt_gt() {
@@ -1621,17 +1619,17 @@
expect(simpleTypeArgument1GtGt.typeArgumentCount, 1);
expect(simpleTypeArgument1GtGt.typeInfo, simpleTypeWith1ArgumentGtGt);
- final Token start = scanString('before <S<T>> after').tokens.next.next;
- var gtgt = start.next.next.next;
+ final Token start = scanString('before <S<T>> after').tokens.next!.next!;
+ var gtgt = start.next!.next!.next!;
expect(gtgt.lexeme, '>>');
- Token after = gtgt.next;
+ Token after = gtgt.next!;
expect(after.lexeme, 'after');
Token skip = simpleTypeArgument1GtGt.skip(start);
validateTokens(start);
expect(skip.lexeme, '>');
- expect(skip.next.lexeme, '>');
- expect(skip.next.next, after);
+ expect(skip.next!.lexeme, '>');
+ expect(skip.next!.next, after);
}
void test_compute_gt() {
@@ -1644,9 +1642,9 @@
void test_compute_gt_gt() {
String source = '<C<T>>';
- Token start = scan(source).next.next;
+ Token start = scan(source).next!.next!;
expect(start.lexeme, 'C');
- Token gtgt = start.next.next.next;
+ Token gtgt = start.next!.next!.next!;
expect(gtgt.lexeme, '>>');
expect(computeTypeParamOrArg(start, false), simpleTypeArgument1GtGt);
@@ -1654,9 +1652,9 @@
}
void testParseArguments(TypeParamOrArgInfo typeArg, String source,
- [String next]) {
+ [String? next]) {
final Token start = scanString('before $source after').tokens;
- final Token after = start.next.next.next.next;
+ final Token after = start.next!.next!.next!.next!;
expect(after.lexeme, 'after');
final TypeInfoListener listener = new TypeInfoListener();
@@ -1666,10 +1664,10 @@
useImplicitCreationExpression: useImplicitCreationExpressionInCfe));
validateTokens(start);
expect(token.lexeme, '>');
- token = token.next;
+ token = token.next!;
if (next != null) {
expect(token.lexeme, next);
- token = token.next;
+ token = token.next!;
}
expect(token, after);
expect(listener.calls, [
@@ -1695,9 +1693,9 @@
}
void testParseVariables(TypeParamOrArgInfo typeParam, String source,
- [String next]) {
+ [String? next]) {
final Token start = scanString('before $source after').tokens;
- final Token after = start.next.next.next.next;
+ final Token after = start.next!.next!.next!.next!;
expect(after.lexeme, 'after');
final TypeInfoListener listener = new TypeInfoListener();
@@ -1707,10 +1705,10 @@
useImplicitCreationExpression: useImplicitCreationExpressionInCfe));
validateTokens(start);
expect(token.lexeme, '>');
- token = token.next;
+ token = token.next!;
if (next != null) {
expect(token.lexeme, next);
- token = token.next;
+ token = token.next!;
}
expect(token, after);
expect(listener.calls, [
@@ -2588,7 +2586,7 @@
}
}
-void expectInfo(expectedInfo, String source, {bool required}) {
+void expectInfo(expectedInfo, String source, {bool? required}) {
if (required == null) {
compute(expectedInfo, source, scan(source), true);
compute(expectedInfo, source, scan(source), false);
@@ -2600,12 +2598,12 @@
/// Note that if [required] is null it is run both with required [true] and
/// [false] and expect the same in both situations.
void expectComplexInfo(String source,
- {bool required,
+ {bool? required,
bool inDeclaration = false,
bool couldBeExpression = false,
- String expectedAfter,
- List<String> expectedCalls,
- List<ExpectedError> expectedErrors}) {
+ String? expectedAfter,
+ List<String>? expectedCalls,
+ List<ExpectedError>? expectedErrors}) {
if (required == null) {
computeComplex(source, scan(source), true, inDeclaration, couldBeExpression,
expectedAfter, expectedCalls, expectedErrors);
@@ -2619,7 +2617,7 @@
void expectNestedInfo(expectedInfo, String source) {
expect(source.startsWith('<'), isTrue);
- Token start = scan(source).next;
+ Token start = scan(source).next!;
compute(expectedInfo, source, start, true);
}
@@ -2643,13 +2641,13 @@
bool required,
bool inDeclaration,
bool couldBeExpression,
- String expectedAfter,
- List<String> expectedCalls,
- List<ExpectedError> expectedErrors) {
+ String? expectedAfter,
+ List<String>? expectedCalls,
+ List<ExpectedError>? expectedErrors) {
int expectedGtGtAndNullEndCount = countGtGtAndNullEnd(start);
ComplexTypeInfo typeInfo = compute(
const TypeMatcher<ComplexTypeInfo>(), source, start, required,
- inDeclaration: inDeclaration);
+ inDeclaration: inDeclaration) as ComplexTypeInfo;
expect(typeInfo.start, start.next, reason: source);
expect(typeInfo.couldBeExpression, couldBeExpression);
expectEnd(expectedAfter, typeInfo.skipType(start));
@@ -2673,16 +2671,16 @@
void expectComplexTypeArg(String source,
{bool inDeclaration = false,
int typeArgumentCount = -1,
- String expectedAfter,
- List<String> expectedCalls,
- List<ExpectedError> expectedErrors}) {
+ String? expectedAfter,
+ List<String>? expectedCalls,
+ List<ExpectedError>? expectedErrors}) {
Token start = scan(source);
int expectedGtGtAndNullEndCount = countGtGtAndNullEnd(start);
ComplexTypeParamOrArgInfo typeVarInfo = computeVar(
const TypeMatcher<ComplexTypeParamOrArgInfo>(),
source,
start,
- inDeclaration);
+ inDeclaration) as ComplexTypeParamOrArgInfo;
expect(typeVarInfo.start, start.next, reason: source);
expectEnd(expectedAfter, typeVarInfo.skip(start));
@@ -2708,16 +2706,16 @@
void expectComplexTypeParam(String source,
{bool inDeclaration = false,
int typeArgumentCount = -1,
- String expectedAfter,
- List<String> expectedCalls,
- List<ExpectedError> expectedErrors}) {
+ String? expectedAfter,
+ List<String>? expectedCalls,
+ List<ExpectedError>? expectedErrors}) {
Token start = scan(source);
int expectedGtGtAndNullEndCount = countGtGtAndNullEnd(start);
ComplexTypeParamOrArgInfo typeVarInfo = computeVar(
const TypeMatcher<ComplexTypeParamOrArgInfo>(),
source,
start,
- inDeclaration);
+ inDeclaration) as ComplexTypeParamOrArgInfo;
expect(typeVarInfo.start, start.next, reason: source);
expectEnd(expectedAfter, typeVarInfo.skip(start));
@@ -2743,9 +2741,9 @@
void expectTypeParamOrArg(expectedInfo, String source,
{bool inDeclaration = false,
- String expectedAfter,
- List<String> expectedCalls,
- List<ExpectedError> expectedErrors}) {
+ String? expectedAfter,
+ List<String>? expectedCalls,
+ List<ExpectedError>? expectedErrors}) {
Token start = scan(source);
computeVar(expectedInfo, source, start, inDeclaration);
}
@@ -2761,21 +2759,21 @@
return typeVarInfo;
}
-void expectEnd(String tokenAfter, Token end) {
+void expectEnd(String? tokenAfter, Token end) {
if (tokenAfter == null) {
expect(end.isEof, isFalse);
- if (!end.next.isEof) {
+ if (!end.next!.isEof) {
fail('Expected EOF after $end but found ${end.next}');
}
} else {
- expect(end.next.lexeme, tokenAfter);
+ expect(end.next!.lexeme, tokenAfter);
}
}
Token scan(String source) {
Token start = scanString(source).tokens;
while (start is ErrorToken) {
- start = start.next;
+ start = start.next!;
}
return new SyntheticToken(TokenType.EOF, -1)..setNext(start);
}
@@ -2787,18 +2785,18 @@
optional('>>', token)) {
++count;
}
- token = token.next;
+ token = token.next!;
}
return count;
}
void validateTokens(Token token) {
int count = 0;
- if (token.isEof && !token.next.isEof) {
- token = token.next;
+ if (token.isEof && !token.next!.isEof) {
+ token = token.next!;
}
while (!token.isEof) {
- Token next = token.next;
+ Token next = token.next!;
expect(token.charOffset, lessThanOrEqualTo(next.charOffset));
expect(next.previous, token, reason: next.type.toString());
if (next is SyntheticToken) {
@@ -2813,12 +2811,12 @@
class TypeInfoListener implements Listener {
final bool metadataAllowed;
List<String> calls = <String>[];
- List<ExpectedError> errors;
- Token firstToken;
+ List<ExpectedError>? errors;
+ Token? firstToken;
TypeInfoListener({this.firstToken, this.metadataAllowed: false}) {
- if (firstToken != null && firstToken.isEof) {
- firstToken = firstToken.next;
+ if (firstToken != null && firstToken!.isEof) {
+ firstToken = firstToken!.next;
}
}
@@ -2832,8 +2830,8 @@
}
@override
- void beginFormalParameter(Token token, MemberKind kind, Token requiredToken,
- Token covariantToken, Token varFinalOrConst) {
+ void beginFormalParameter(Token token, MemberKind kind, Token? requiredToken,
+ Token? covariantToken, Token? varFinalOrConst) {
// TODO(danrubel): Update tests to include required and covariant
calls.add('beginFormalParameter $token $kind');
}
@@ -2894,12 +2892,12 @@
@override
void endFormalParameter(
- Token thisKeyword,
- Token superKeyword,
- Token periodAfterThisOrSuper,
+ Token? thisKeyword,
+ Token? superKeyword,
+ Token? periodAfterThisOrSuper,
Token nameToken,
- Token initializerStart,
- Token initializerEnd,
+ Token? initializerStart,
+ Token? initializerEnd,
FormalParameterKind kind,
MemberKind memberKind) {
calls.add('endFormalParameter $thisKeyword $periodAfterThisOrSuper '
@@ -2907,12 +2905,12 @@
}
@override
- void endFunctionType(Token functionToken, Token questionMark) {
+ void endFunctionType(Token functionToken, Token? questionMark) {
calls.add('endFunctionType $functionToken $questionMark');
}
@override
- void endMetadata(Token beginToken, Token periodBeforeName, Token endToken) {
+ void endMetadata(Token beginToken, Token? periodBeforeName, Token endToken) {
if (metadataAllowed) {
calls.add('endMetadata $beginToken $periodBeforeName $endToken');
} else {
@@ -2934,7 +2932,7 @@
@override
void endTypeVariable(
- Token token, int index, Token extendsOrSuper, Token variance) {
+ Token token, int index, Token? extendsOrSuper, Token? variance) {
calls.add('endTypeVariable $token $index $extendsOrSuper $variance');
assertTokenInStream(token);
assertTokenInStream(extendsOrSuper);
@@ -2989,9 +2987,9 @@
@override
void handleRecoverableError(
Message message, Token startToken, Token endToken) {
- errors ??= <ExpectedError>[];
int offset = startToken.charOffset;
- errors.add(error(message.code, offset, endToken.charEnd - offset));
+ (errors ??= <ExpectedError>[])
+ .add(error(message.code, offset, endToken.charEnd - offset));
}
@override
@@ -3000,7 +2998,7 @@
}
@override
- void handleType(Token beginToken, Token questionMark) {
+ void handleType(Token beginToken, Token? questionMark) {
calls.add('handleType $beginToken $questionMark');
}
@@ -3024,20 +3022,20 @@
throw '${invocation.memberName} should not be called.';
}
- void assertTokenInStream(Token match) {
+ void assertTokenInStream(Token? match) {
if (firstToken != null && match != null && !match.isEof) {
- Token token = firstToken;
+ Token token = firstToken!;
while (!token.isEof) {
if (identical(token, match)) {
return;
}
- token = token.next;
+ token = token.next!;
}
final msg = new StringBuffer();
msg.writeln('Expected $match in token stream, but found');
while (!token.isEof) {
msg.write(' $token');
- token = token.next;
+ token = token.next!;
}
fail(msg.toString());
}
diff --git a/pkg/front_end/test/fasta/scanner/scanner_suite.dart b/pkg/front_end/test/fasta/scanner/scanner_suite.dart
index f9822e8..69ea079 100644
--- a/pkg/front_end/test/fasta/scanner/scanner_suite.dart
+++ b/pkg/front_end/test/fasta/scanner/scanner_suite.dart
@@ -2,8 +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.md file.
-// @dart = 2.9
-
import 'package:testing/testing.dart' show Chain, ChainContext, Step, runMe;
import '../../utils/scanner_chain.dart' show Read, Scan;
diff --git a/pkg/front_end/test/fasta/type_inference/factor_type_test.dart b/pkg/front_end/test/fasta/type_inference/factor_type_test.dart
index a365e93..a743918 100644
--- a/pkg/front_end/test/fasta/type_inference/factor_type_test.dart
+++ b/pkg/front_end/test/fasta/type_inference/factor_type_test.dart
@@ -2,8 +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.
-// @dart = 2.9
-
import 'package:_fe_analyzer_shared/src/flow_analysis/factory_type_test_helper.dart';
import 'package:expect/expect.dart';
import 'package:front_end/src/api_prototype/compiler_options.dart';
@@ -106,8 +104,10 @@
CompilerOptions options = new CompilerOptions()
..explicitExperimentalFlags[ExperimentalFlag.nonNullable] = true;
InternalCompilerResult result = await compileScript('',
- options: options, requireMain: false, retainDataForTesting: true);
+ options: options,
+ requireMain: false,
+ retainDataForTesting: true) as InternalCompilerResult;
new FactorTypeTest(
- new TypeEnvironment(result.coreTypes, result.classHierarchy))
+ new TypeEnvironment(result.coreTypes!, result.classHierarchy!))
.run();
}
diff --git a/pkg/front_end/test/fasta/type_inference/type_constraint_gatherer_nnbd_test.dart b/pkg/front_end/test/fasta/type_inference/type_constraint_gatherer_nnbd_test.dart
index 7bf3df7..f037ae5 100644
--- a/pkg/front_end/test/fasta/type_inference/type_constraint_gatherer_nnbd_test.dart
+++ b/pkg/front_end/test/fasta/type_inference/type_constraint_gatherer_nnbd_test.dart
@@ -2,8 +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.
-// @dart = 2.9
-
import 'package:front_end/src/fasta/type_inference/type_constraint_gatherer.dart';
import 'package:front_end/src/fasta/type_inference/type_schema.dart';
import 'package:front_end/src/fasta/type_inference/type_schema_environment.dart';
@@ -22,15 +20,15 @@
@reflectiveTest
class TypeConstraintGathererTest {
- Env env;
+ late Env env;
final Map<String, DartType Function()> additionalTypes = {
'UNKNOWN': () => new UnknownType()
};
- Library _coreLibrary;
+ late Library _coreLibrary;
- Library _testLibrary;
+ late Library _testLibrary;
TypeConstraintGathererTest();
@@ -308,7 +306,7 @@
}
void checkConstraintsLower(String type, String bound, List<String> expected,
- {String typeParameters, String typeParametersToConstrain}) {
+ {String? typeParameters, String? typeParametersToConstrain}) {
env.withTypeParameters(typeParameters ?? '',
(List<TypeParameter> typeParameterNodes) {
List<TypeParameter> typeParameterNodesToConstrain;
@@ -345,8 +343,8 @@
typeParameterNodesToConstrain);
}
- void checkConstraintsUpper(String type, String bound, List<String> expected,
- {String typeParameters, String typeParametersToConstrain}) {
+ void checkConstraintsUpper(String type, String bound, List<String>? expected,
+ {String? typeParameters, String? typeParametersToConstrain}) {
env.withTypeParameters(typeParameters ?? '',
(List<TypeParameter> typeParameterNodes) {
List<TypeParameter> typeParameterNodesToConstrain;
@@ -372,7 +370,7 @@
DartType type,
DartType bound,
Library clientLibrary,
- List<String> expectedConstraints,
+ List<String>? expectedConstraints,
List<TypeParameter> typeParameterNodesToConstrain) {
_checkConstraintsHelper(
type,
@@ -387,7 +385,7 @@
DartType a,
DartType b,
Library clientLibrary,
- List<String> expectedConstraints,
+ List<String>? expectedConstraints,
bool Function(TypeConstraintGatherer, DartType, DartType) tryConstrain,
List<TypeParameter> typeParameterNodesToConstrain) {
var typeSchemaEnvironment = new TypeSchemaEnvironment(
@@ -403,7 +401,7 @@
}
expect(constraints, isNotNull);
var constraintStrings = <String>[];
- constraints.forEach((t, constraint) {
+ constraints!.forEach((t, constraint) {
if (constraint.lower is! UnknownType ||
constraint.upper is! UnknownType) {
var s = t.name;
@@ -413,7 +411,7 @@
if (constraint.upper is! UnknownType) {
s = '$s <: ${typeSchemaToString(constraint.upper)}';
}
- constraintStrings.add(s);
+ constraintStrings.add(s as String);
}
});
expect(constraintStrings, unorderedEquals(expectedConstraints));
diff --git a/pkg/front_end/test/fasta/type_inference/type_constraint_gatherer_test.dart b/pkg/front_end/test/fasta/type_inference/type_constraint_gatherer_test.dart
index 16df20d..e42fc10 100644
--- a/pkg/front_end/test/fasta/type_inference/type_constraint_gatherer_test.dart
+++ b/pkg/front_end/test/fasta/type_inference/type_constraint_gatherer_test.dart
@@ -2,8 +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.
-// @dart = 2.9
-
import 'package:front_end/src/fasta/type_inference/type_constraint_gatherer.dart';
import 'package:front_end/src/fasta/type_inference/type_schema.dart';
import 'package:front_end/src/fasta/type_inference/type_schema_environment.dart';
@@ -22,15 +20,15 @@
@reflectiveTest
class TypeConstraintGathererTest {
- Env env;
+ late Env env;
final Map<String, DartType Function()> additionalTypes = {
'UNKNOWN': () => UnknownType()
};
- Library _coreLibrary;
+ late Library _coreLibrary;
- Library _testLibrary;
+ late Library _testLibrary;
TypeConstraintGathererTest();
@@ -215,8 +213,8 @@
typeParameters: 'T1 extends Object*');
}
- void checkConstraintsLower(String type, String bound, List<String> expected,
- {String typeParameters, String typeParametersToConstrain}) {
+ void checkConstraintsLower(String type, String bound, List<String>? expected,
+ {String? typeParameters, String? typeParametersToConstrain}) {
env.withTypeParameters(typeParameters ?? '',
(List<TypeParameter> typeParameterNodes) {
List<TypeParameter> typeParameterNodesToConstrain;
@@ -242,7 +240,7 @@
DartType type,
DartType bound,
Library clientLibrary,
- List<String> expectedConstraints,
+ List<String>? expectedConstraints,
List<TypeParameter> typeParameterNodesToConstrain) {
_checkConstraintsHelper(
type,
@@ -253,8 +251,8 @@
typeParameterNodesToConstrain);
}
- void checkConstraintsUpper(String type, String bound, List<String> expected,
- {String typeParameters, String typeParametersToConstrain}) {
+ void checkConstraintsUpper(String type, String bound, List<String>? expected,
+ {String? typeParameters, String? typeParametersToConstrain}) {
env.withTypeParameters(typeParameters ?? '',
(List<TypeParameter> typeParameterNodes) {
List<TypeParameter> typeParameterNodesToConstrain;
@@ -280,7 +278,7 @@
DartType type,
DartType bound,
Library clientLibrary,
- List<String> expectedConstraints,
+ List<String>? expectedConstraints,
List<TypeParameter> typeParameterNodesToConstrain) {
_checkConstraintsHelper(
type,
@@ -295,7 +293,7 @@
DartType a,
DartType b,
Library clientLibrary,
- List<String> expectedConstraints,
+ List<String>? expectedConstraints,
bool Function(TypeConstraintGatherer, DartType, DartType) tryConstrain,
List<TypeParameter> typeParameterNodesToConstrain) {
var typeSchemaEnvironment = new TypeSchemaEnvironment(
@@ -311,7 +309,7 @@
}
expect(constraints, isNotNull);
var constraintStrings = <String>[];
- constraints.forEach((t, constraint) {
+ constraints!.forEach((t, constraint) {
if (constraint.lower is! UnknownType ||
constraint.upper is! UnknownType) {
var s = t.name;
@@ -321,7 +319,7 @@
if (constraint.upper is! UnknownType) {
s = '$s <: ${typeSchemaToString(constraint.upper)}';
}
- constraintStrings.add(s);
+ constraintStrings.add(s as String);
}
});
expect(constraintStrings, unorderedEquals(expectedConstraints));
diff --git a/pkg/front_end/test/fasta/type_inference/type_inference_engine_test.dart b/pkg/front_end/test/fasta/type_inference/type_inference_engine_test.dart
index 0588e94..0221278 100644
--- a/pkg/front_end/test/fasta/type_inference/type_inference_engine_test.dart
+++ b/pkg/front_end/test/fasta/type_inference/type_inference_engine_test.dart
@@ -2,8 +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.
-// @dart = 2.9
-
import 'package:front_end/src/fasta/type_inference/type_inference_engine.dart';
import 'package:kernel/ast.dart';
import 'package:test/test.dart';
@@ -226,7 +224,7 @@
isFalse);
}
- TypeParameterType tpt(TypeParameter param, {int variance = null}) {
+ TypeParameterType tpt(TypeParameter param, {int? variance = null}) {
return new TypeParameterType(param, Nullability.legacy)
..parameter.variance = variance;
}
diff --git a/pkg/front_end/test/fasta/type_inference/type_schema_elimination_nnbd_test.dart b/pkg/front_end/test/fasta/type_inference/type_schema_elimination_nnbd_test.dart
index dc5b7cb..7abe586 100644
--- a/pkg/front_end/test/fasta/type_inference/type_schema_elimination_nnbd_test.dart
+++ b/pkg/front_end/test/fasta/type_inference/type_schema_elimination_nnbd_test.dart
@@ -2,8 +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.
-// @dart = 2.9
-
import 'package:front_end/src/fasta/type_inference/type_schema.dart';
import 'package:front_end/src/fasta/type_inference/type_schema_elimination.dart'
as typeSchemaElimination;
diff --git a/pkg/front_end/test/fasta/type_inference/type_schema_elimination_test.dart b/pkg/front_end/test/fasta/type_inference/type_schema_elimination_test.dart
index 36f0c1a..49f3b77 100644
--- a/pkg/front_end/test/fasta/type_inference/type_schema_elimination_test.dart
+++ b/pkg/front_end/test/fasta/type_inference/type_schema_elimination_test.dart
@@ -2,8 +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.
-// @dart = 2.9
-
import 'package:front_end/src/fasta/type_inference/type_schema.dart';
import 'package:front_end/src/fasta/type_inference/type_schema_elimination.dart'
as typeSchemaElimination;
diff --git a/pkg/front_end/test/fasta/type_inference/type_schema_environment_nnbd_test.dart b/pkg/front_end/test/fasta/type_inference/type_schema_environment_nnbd_test.dart
index 20d575a..182d44b 100644
--- a/pkg/front_end/test/fasta/type_inference/type_schema_environment_nnbd_test.dart
+++ b/pkg/front_end/test/fasta/type_inference/type_schema_environment_nnbd_test.dart
@@ -2,8 +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.
-// @dart = 2.9
-
import 'package:front_end/src/fasta/type_inference/type_schema.dart';
import 'package:front_end/src/fasta/type_inference/type_schema_environment.dart';
import 'package:kernel/ast.dart';
@@ -21,15 +19,15 @@
@reflectiveTest
class TypeSchemaEnvironmentTest {
- Env typeParserEnvironment;
- TypeSchemaEnvironment typeSchemaEnvironment;
+ late Env typeParserEnvironment;
+ late TypeSchemaEnvironment typeSchemaEnvironment;
final Map<String, DartType Function()> additionalTypes = {
"UNKNOWN": () => new UnknownType(),
};
- Library _coreLibrary;
- Library _testLibrary;
+ late Library _coreLibrary;
+ late Library _testLibrary;
Library get coreLibrary => _coreLibrary;
Library get testLibrary => _testLibrary;
@@ -111,7 +109,7 @@
/// There's an infinite amount of such types, and the list contains some
/// practical base cases. For the definition of TOP see the following:
/// https://github.com/dart-lang/language/blob/master/resources/type-system/upper-lower-bounds.md#helper-predicates
- static const Map<String, String> topPredicateEnumeration = <String, String>{
+ static const Map<String, String?> topPredicateEnumeration = {
// dynamic and void.
"dynamic": null,
"void": null,
@@ -210,7 +208,7 @@
/// There's an infinite amount of such types, and the list contains some
/// practical base cases. For the definition of OBJECT see the following:
/// https://github.com/dart-lang/language/blob/master/resources/type-system/upper-lower-bounds.md#helper-predicates
- static const Map<String, String> objectPredicateEnumeration = {
+ static const Map<String, String?> objectPredicateEnumeration = {
"Object": null,
"FutureOr<Object>": null,
"FutureOr<FutureOr<Object>>": null,
@@ -224,7 +222,7 @@
///
/// The names of the variables here and in [nullPredicateEnumeration] should
/// be distinct to avoid collisions.
- static const Map<String, String> bottomPredicateEnumeration = {
+ static const Map<String, String?> bottomPredicateEnumeration = {
"Never": null,
"Xb & Never": "Xb extends Object?",
"Yb & Zb & Never": "Yb extends Object?, Zb extends Object?",
@@ -241,7 +239,7 @@
///
/// The names of the variables here and in [bottomPredicateEnumeration] should
/// be distinct to avoid collisions.
- static const Map<String, String> nullPredicateEnumeration = {
+ static const Map<String, String?> nullPredicateEnumeration = {
// T? where BOTTOM(T).
"Never?": null,
"Xn?": "Xn extends Never",
@@ -256,8 +254,8 @@
"Null": null,
};
- static String joinTypeParameters(
- String typeParameters1, String typeParameters2) {
+ static String? joinTypeParameters(
+ String? typeParameters1, String? typeParameters2) {
if (typeParameters1 == null) return typeParameters2;
if (typeParameters2 == null) return typeParameters1;
if (typeParameters1 == typeParameters2) return typeParameters1;
@@ -277,7 +275,7 @@
// T2 otherwise
for (String t1 in bottomPredicateEnumeration.keys) {
for (String t2 in bottomPredicateEnumeration.keys) {
- String typeParameters = joinTypeParameters(
+ String? typeParameters = joinTypeParameters(
bottomPredicateEnumeration[t1], bottomPredicateEnumeration[t2]);
typeParserEnvironment.withTypeParameters(typeParameters, (_) {
String expected =
@@ -320,7 +318,7 @@
// T2 otherwise
for (String t1 in nullPredicateEnumeration.keys) {
for (String t2 in nullPredicateEnumeration.keys) {
- String typeParameters = joinTypeParameters(
+ String? typeParameters = joinTypeParameters(
nullPredicateEnumeration[t1], nullPredicateEnumeration[t2]);
typeParserEnvironment.withTypeParameters(typeParameters, (_) {
String expected =
@@ -600,7 +598,7 @@
// T2 otherwise
for (String t1 in topPredicateEnumeration.keys) {
for (String t2 in topPredicateEnumeration.keys) {
- String typeParameters = joinTypeParameters(
+ String? typeParameters = joinTypeParameters(
topPredicateEnumeration[t1], topPredicateEnumeration[t2]);
typeParserEnvironment.withTypeParameters(typeParameters, (_) {
String expected =
@@ -1100,7 +1098,7 @@
// T2 otherwise
for (String t1 in topPredicateEnumeration.keys) {
for (String t2 in topPredicateEnumeration.keys) {
- String typeParameters = joinTypeParameters(
+ String? typeParameters = joinTypeParameters(
topPredicateEnumeration[t1], topPredicateEnumeration[t2]);
typeParserEnvironment.withTypeParameters(typeParameters, (_) {
String expected =
@@ -1143,7 +1141,7 @@
// T2 otherwise
for (String t1 in objectPredicateEnumeration.keys) {
for (String t2 in objectPredicateEnumeration.keys) {
- String typeParameters = joinTypeParameters(
+ String? typeParameters = joinTypeParameters(
objectPredicateEnumeration[t1], objectPredicateEnumeration[t2]);
typeParserEnvironment.withTypeParameters(typeParameters, (_) {
String expected =
@@ -1194,7 +1192,7 @@
// T1 otherwise
for (String t1 in bottomPredicateEnumeration.keys) {
for (String t2 in bottomPredicateEnumeration.keys) {
- String typeParameters = joinTypeParameters(
+ String? typeParameters = joinTypeParameters(
bottomPredicateEnumeration[t1], bottomPredicateEnumeration[t2]);
typeParserEnvironment.withTypeParameters(typeParameters, (_) {
String expected =
@@ -1237,7 +1235,7 @@
// T1 otherwise
for (String t1 in nullPredicateEnumeration.keys) {
for (String t2 in nullPredicateEnumeration.keys) {
- String typeParameters = joinTypeParameters(
+ String? typeParameters = joinTypeParameters(
nullPredicateEnumeration[t1], nullPredicateEnumeration[t2]);
typeParserEnvironment.withTypeParameters(typeParameters, (_) {
String expected =
@@ -1505,8 +1503,7 @@
}
void checkConstraintSolving(String constraint, String expected,
- {bool grounded}) {
- assert(grounded != null);
+ {required bool grounded}) {
expect(
typeSchemaEnvironment.solveTypeConstraint(
parseConstraint(constraint),
@@ -1516,17 +1513,13 @@
parseType(expected));
}
- void checkConstraintUpperBound({String constraint, String bound}) {
- assert(constraint != null);
- assert(bound != null);
-
+ void checkConstraintUpperBound(
+ {required String constraint, required String bound}) {
expect(parseConstraint(constraint).upper, parseType(bound));
}
- void checkConstraintLowerBound({String constraint, String bound}) {
- assert(constraint != null);
- assert(bound != null);
-
+ void checkConstraintLowerBound(
+ {required String constraint, required String bound}) {
expect(parseConstraint(constraint).lower, parseType(bound));
}
@@ -1572,16 +1565,12 @@
}
void checkUpperBound(
- {String type1,
- String type2,
- String upperBound,
- String typeParameters,
+ {required String type1,
+ required String type2,
+ required String upperBound,
+ String? typeParameters,
bool nonNull1: false,
bool nonNull2: false}) {
- assert(type1 != null);
- assert(type2 != null);
- assert(upperBound != null);
-
typeParserEnvironment.withTypeParameters(typeParameters,
(List<TypeParameter> typeParameterNodes) {
DartType dartType1 = parseType(type1);
@@ -1600,11 +1589,10 @@
}
void checkLowerBound(
- {String type1, String type2, String lowerBound, String typeParameters}) {
- assert(type1 != null);
- assert(type2 != null);
- assert(lowerBound != null);
-
+ {required String type1,
+ required String type2,
+ required String lowerBound,
+ String? typeParameters}) {
typeParserEnvironment.withTypeParameters(typeParameters,
(List<TypeParameter> typeParameterNodes) {
expect(
@@ -1615,28 +1603,23 @@
}
void checkInference(
- {String typeParametersToInfer,
- String functionType,
- String actualParameterTypes,
- String returnContextType,
- String inferredTypesFromDownwardPhase,
- String expectedTypes}) {
- assert(typeParametersToInfer != null);
- assert(functionType != null);
- assert(expectedTypes != null);
-
+ {required String typeParametersToInfer,
+ required String functionType,
+ String? actualParameterTypes,
+ String? returnContextType,
+ String? inferredTypesFromDownwardPhase,
+ required String expectedTypes}) {
typeParserEnvironment.withTypeParameters(typeParametersToInfer,
(List<TypeParameter> typeParameterNodesToInfer) {
- FunctionType functionTypeNode = parseType(functionType);
- DartType returnContextTypeNode =
+ FunctionType functionTypeNode = parseType(functionType) as FunctionType;
+ DartType? returnContextTypeNode =
returnContextType == null ? null : parseType(returnContextType);
- List<DartType> actualTypeNodes = actualParameterTypes == null
+ List<DartType>? actualTypeNodes = actualParameterTypes == null
? null
: parseTypes(actualParameterTypes);
- List<DartType> expectedTypeNodes =
- expectedTypes == null ? null : parseTypes(expectedTypes);
+ List<DartType> expectedTypeNodes = parseTypes(expectedTypes);
DartType declaredReturnTypeNode = functionTypeNode.returnType;
- List<DartType> formalTypeNodes = actualParameterTypes == null
+ List<DartType>? formalTypeNodes = actualParameterTypes == null
? null
: functionTypeNode.positionalParameters;
@@ -1668,14 +1651,11 @@
}
void checkInferenceFromConstraints(
- {String typeParameter,
- String constraints,
- String inferredTypeFromDownwardPhase,
- bool downwardsInferPhase,
- String expected}) {
- assert(typeParameter != null);
- assert(expected != null);
- assert(downwardsInferPhase != null);
+ {required String typeParameter,
+ required String constraints,
+ String? inferredTypeFromDownwardPhase,
+ required bool downwardsInferPhase,
+ required String expected}) {
assert(inferredTypeFromDownwardPhase == null || !downwardsInferPhase);
typeParserEnvironment.withTypeParameters(typeParameter,
diff --git a/pkg/front_end/test/fasta/type_inference/type_schema_environment_test.dart b/pkg/front_end/test/fasta/type_inference/type_schema_environment_test.dart
index 6945778..526e061 100644
--- a/pkg/front_end/test/fasta/type_inference/type_schema_environment_test.dart
+++ b/pkg/front_end/test/fasta/type_inference/type_schema_environment_test.dart
@@ -2,8 +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.
-// @dart = 2.9
-
import 'package:front_end/src/fasta/type_inference/type_schema.dart';
import 'package:front_end/src/fasta/type_inference/type_schema_environment.dart';
import 'package:kernel/ast.dart';
@@ -21,15 +19,15 @@
@reflectiveTest
class TypeSchemaEnvironmentTest {
- Env typeParserEnvironment;
- TypeSchemaEnvironment typeSchemaEnvironment;
+ late Env typeParserEnvironment;
+ late TypeSchemaEnvironment typeSchemaEnvironment;
final Map<String, DartType Function()> additionalTypes = {
"UNKNOWN": () => new UnknownType(),
};
- Library _coreLibrary;
- Library _testLibrary;
+ late Library _coreLibrary;
+ late Library _testLibrary;
Library get coreLibrary => _coreLibrary;
Library get testLibrary => _testLibrary;
@@ -587,8 +585,7 @@
}
void checkConstraintSolving(String constraint, String expected,
- {bool grounded}) {
- assert(grounded != null);
+ {required bool grounded}) {
expect(
typeSchemaEnvironment.solveTypeConstraint(
parseConstraint(constraint), new DynamicType(), new NullType(),
@@ -596,17 +593,13 @@
parseType(expected));
}
- void checkConstraintUpperBound({String constraint, String bound}) {
- assert(constraint != null);
- assert(bound != null);
-
+ void checkConstraintUpperBound(
+ {required String constraint, required String bound}) {
expect(parseConstraint(constraint).upper, parseType(bound));
}
- void checkConstraintLowerBound({String constraint, String bound}) {
- assert(constraint != null);
- assert(bound != null);
-
+ void checkConstraintLowerBound(
+ {required String constraint, required String bound}) {
expect(parseConstraint(constraint).lower, parseType(bound));
}
@@ -652,11 +645,10 @@
}
void checkUpperBound(
- {String type1, String type2, String upperBound, String typeParameters}) {
- assert(type1 != null);
- assert(type2 != null);
- assert(upperBound != null);
-
+ {required String type1,
+ required String type2,
+ required String upperBound,
+ String? typeParameters}) {
typeParserEnvironment.withTypeParameters(typeParameters,
(List<TypeParameter> typeParameterNodes) {
expect(
@@ -667,11 +659,10 @@
}
void checkLowerBound(
- {String type1, String type2, String lowerBound, String typeParameters}) {
- assert(type1 != null);
- assert(type2 != null);
- assert(lowerBound != null);
-
+ {required String type1,
+ required String type2,
+ required String lowerBound,
+ String? typeParameters}) {
typeParserEnvironment.withTypeParameters(typeParameters,
(List<TypeParameter> typeParameterNodes) {
expect(
@@ -682,28 +673,23 @@
}
void checkInference(
- {String typeParametersToInfer,
- String functionType,
- String actualParameterTypes,
- String returnContextType,
- String inferredTypesFromDownwardPhase,
- String expectedTypes}) {
- assert(typeParametersToInfer != null);
- assert(functionType != null);
- assert(expectedTypes != null);
-
+ {required String typeParametersToInfer,
+ required String functionType,
+ String? actualParameterTypes,
+ String? returnContextType,
+ String? inferredTypesFromDownwardPhase,
+ required String expectedTypes}) {
typeParserEnvironment.withTypeParameters(typeParametersToInfer,
(List<TypeParameter> typeParameterNodesToInfer) {
- FunctionType functionTypeNode = parseType(functionType);
- DartType returnContextTypeNode =
+ FunctionType functionTypeNode = parseType(functionType) as FunctionType;
+ DartType? returnContextTypeNode =
returnContextType == null ? null : parseType(returnContextType);
- List<DartType> actualTypeNodes = actualParameterTypes == null
+ List<DartType>? actualTypeNodes = actualParameterTypes == null
? null
: parseTypes(actualParameterTypes);
- List<DartType> expectedTypeNodes =
- expectedTypes == null ? null : parseTypes(expectedTypes);
+ List<DartType> expectedTypeNodes = parseTypes(expectedTypes);
DartType declaredReturnTypeNode = functionTypeNode.returnType;
- List<DartType> formalTypeNodes = actualParameterTypes == null
+ List<DartType>? formalTypeNodes = actualParameterTypes == null
? null
: functionTypeNode.positionalParameters;
@@ -735,14 +721,11 @@
}
void checkInferenceFromConstraints(
- {String typeParameter,
- String constraints,
- String inferredTypeFromDownwardPhase,
- bool downwardsInferPhase,
- String expected}) {
- assert(typeParameter != null);
- assert(expected != null);
- assert(downwardsInferPhase != null);
+ {required String typeParameter,
+ required String constraints,
+ String? inferredTypeFromDownwardPhase,
+ required bool downwardsInferPhase,
+ required String expected}) {
assert(inferredTypeFromDownwardPhase == null || !downwardsInferPhase);
typeParserEnvironment.withTypeParameters(typeParameter,
diff --git a/pkg/front_end/test/fasta/type_inference/type_schema_test.dart b/pkg/front_end/test/fasta/type_inference/type_schema_test.dart
index eff2502..eb34789 100644
--- a/pkg/front_end/test/fasta/type_inference/type_schema_test.dart
+++ b/pkg/front_end/test/fasta/type_inference/type_schema_test.dart
@@ -2,8 +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.
-// @dart = 2.9
-
import 'package:front_end/src/fasta/type_inference/type_schema.dart';
import 'package:kernel/ast.dart';
import 'package:test/test.dart';
@@ -112,38 +110,38 @@
}
}
-class _OrdinaryVisitor<R> extends Visitor<R> with VisitorNullMixin<R> {
- final _UnaryFunction<DartType, R> _defaultDartType;
+class _OrdinaryVisitor<R> extends Visitor<R?> with VisitorNullMixin<R> {
+ final _UnaryFunction<DartType, R>? _defaultDartType;
- _OrdinaryVisitor({_UnaryFunction<DartType, R> defaultDartType})
+ _OrdinaryVisitor({_UnaryFunction<DartType, R>? defaultDartType})
: _defaultDartType = defaultDartType;
@override
- R defaultDartType(DartType node) {
+ R? defaultDartType(DartType node) {
if (_defaultDartType != null) {
- return _defaultDartType(node);
+ return _defaultDartType!(node);
} else {
return super.defaultDartType(node);
}
}
}
-class _TypeSchemaVisitor<R> extends Visitor<R> with VisitorNullMixin<R> {
- final _UnaryFunction<DartType, R> _defaultDartType;
- final _UnaryFunction<UnknownType, R> _visitUnknownType;
+class _TypeSchemaVisitor<R> extends Visitor<R?> with VisitorNullMixin<R> {
+ final _UnaryFunction<DartType, R>? _defaultDartType;
+ final _UnaryFunction<UnknownType, R>? _visitUnknownType;
_TypeSchemaVisitor(
- {_UnaryFunction<DartType, R> defaultDartType,
- _UnaryFunction<UnknownType, R> visitUnknownType})
+ {_UnaryFunction<DartType, R>? defaultDartType,
+ _UnaryFunction<UnknownType, R>? visitUnknownType})
: _defaultDartType = defaultDartType,
_visitUnknownType = visitUnknownType;
@override
- R defaultDartType(DartType node) {
+ R? defaultDartType(DartType node) {
if (node is UnknownType && _visitUnknownType != null) {
- return _visitUnknownType(node);
+ return _visitUnknownType!(node);
} else if (_defaultDartType != null) {
- return _defaultDartType(node);
+ return _defaultDartType!(node);
} else {
return super.defaultDartType(node);
}
diff --git a/tools/VERSION b/tools/VERSION
index 594094a..cd2b3ae 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 16
PATCH 0
-PRERELEASE 44
+PRERELEASE 45
PRERELEASE_PATCH 0
\ No newline at end of file