Version 2.15.0-69.0.dev
Merge commit '097a511d9f43f753053a5ff1f57402d4787c6fee' into 'dev'
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index 6662d2e..99ccd1b 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -14,6 +14,7 @@
from typing import Callable
import scm
import subprocess
+import tempfile
import platform
USE_PYTHON3 = True
@@ -139,7 +140,23 @@
'--output=none',
'--summary=none',
]
- if contents:
+
+ # TODO(https://github.com/dart-lang/sdk/issues/46947): Remove this hack.
+ if windows and contents:
+ f = tempfile.NamedTemporaryFile(
+ encoding='utf-8',
+ delete=False,
+ mode='w',
+ suffix='.dart',
+ )
+ try:
+ f.write(contents)
+ f.close()
+ args.append(f.name)
+ process = subprocess.run(args)
+ finally:
+ os.unlink(f.name)
+ elif contents:
process = subprocess.run(args, input=contents, text=True)
else:
args.append(filename)
diff --git a/pkg/_fe_analyzer_shared/lib/src/parser/parser_impl.dart b/pkg/_fe_analyzer_shared/lib/src/parser/parser_impl.dart
index 9355d16..f35035f 100644
--- a/pkg/_fe_analyzer_shared/lib/src/parser/parser_impl.dart
+++ b/pkg/_fe_analyzer_shared/lib/src/parser/parser_impl.dart
@@ -4486,9 +4486,7 @@
begin = next = token.next!;
// Fall through to parse the block.
} else {
- token = ensureBlock(
- token,
- codes.templateExpectedFunctionBody,
+ token = ensureBlock(token, codes.templateExpectedFunctionBody,
/* missingBlockName = */ null);
listener.handleInvalidFunctionBody(token);
return token.endGroup!;
@@ -4951,6 +4949,19 @@
// Right associative, so we recurse at the same precedence
// level.
Token next = token.next!;
+ if (optional(">=", next.next!)) {
+ // Special case use of triple-shift in cases where it isn't
+ // enabled.
+ reportRecoverableErrorWithEnd(
+ next,
+ next.next!,
+ codes.templateExperimentNotEnabled
+ .withArguments("triple-shift", "2.14"));
+ assert(next == operator);
+ next = rewriter.replaceNextTokensWithSyntheticToken(
+ token, 2, TokenType.GT_GT_GT_EQ);
+ operator = next;
+ }
token = optional('throw', next.next!)
? parseThrowExpression(next, /* allowCascades = */ false)
: parsePrecedenceExpression(next, level, allowCascades);
@@ -5041,18 +5052,10 @@
next.next!,
codes.templateExperimentNotEnabled
.withArguments("triple-shift", "2.14"));
+ assert(next == operator);
next = rewriter.replaceNextTokensWithSyntheticToken(
token, 2, TokenType.GT_GT_GT);
- } else if (optional(">=", next.next!)) {
- // Special case use of triple-shift in cases where it isn't
- // enabled.
- reportRecoverableErrorWithEnd(
- next,
- next.next!,
- codes.templateExperimentNotEnabled
- .withArguments("triple-shift", "2.14"));
- next = rewriter.replaceNextTokensWithSyntheticToken(
- token, 2, TokenType.GT_GT_GT_EQ);
+ operator = next;
}
}
listener.beginBinaryExpression(next);
@@ -5201,6 +5204,14 @@
return SELECTOR_PRECEDENCE;
}
return POSTFIX_PRECEDENCE;
+ } else if (identical(type, TokenType.GT_GT)) {
+ // ">>" followed by ">=" (without space between tokens) should for
+ // recovery be seen as ">>>=".
+ TokenType nextType = token.next!.type;
+ if (identical(nextType, TokenType.GT_EQ) &&
+ token.charEnd == token.next!.offset) {
+ return TokenType.GT_GT_GT_EQ.precedence;
+ }
} else if (identical(type, TokenType.QUESTION) &&
optional('[', token.next!)) {
// "?[" can be a null-aware bracket or a conditional. If it's a
diff --git a/pkg/front_end/lib/src/fasta/command_line_reporting.dart b/pkg/front_end/lib/src/fasta/command_line_reporting.dart
index 528c601..9cb19b4 100644
--- a/pkg/front_end/lib/src/fasta/command_line_reporting.dart
+++ b/pkg/front_end/lib/src/fasta/command_line_reporting.dart
@@ -114,7 +114,7 @@
}
String formatErrorMessage(String? sourceLine, Location? location,
- int squigglyLength, String path, String messageText) {
+ int squigglyLength, String? path, String messageText) {
if (sourceLine == null || location == null) {
sourceLine = "";
} else if (sourceLine.isNotEmpty) {
diff --git a/pkg/front_end/lib/src/fasta/incremental_compiler.dart b/pkg/front_end/lib/src/fasta/incremental_compiler.dart
index 48bbed7..b1f362c 100644
--- a/pkg/front_end/lib/src/fasta/incremental_compiler.dart
+++ b/pkg/front_end/lib/src/fasta/incremental_compiler.dart
@@ -2065,7 +2065,7 @@
// Maps all non-platform LibraryBuilders from their import URI.
Map<Uri, LibraryBuilder> builders = <Uri, LibraryBuilder>{};
- Map<Uri?, LibraryBuilder> partUriToParent = <Uri, LibraryBuilder>{};
+ Map<Uri?, LibraryBuilder> partUriToParent = <Uri?, LibraryBuilder>{};
// Invalidated URIs translated back to their import URI (package:, dart:,
// etc.).
diff --git a/pkg/front_end/parser_testcases/no-triple-shift/define_triple_shift_method.dart.expect b/pkg/front_end/parser_testcases/no-triple-shift/define_triple_shift_method.dart.expect
index e6983f9..cc92f37 100644
--- a/pkg/front_end/parser_testcases/no-triple-shift/define_triple_shift_method.dart.expect
+++ b/pkg/front_end/parser_testcases/no-triple-shift/define_triple_shift_method.dart.expect
@@ -100,7 +100,7 @@
handleRecoverableError(Message[ExperimentNotEnabled, This requires the 'triple-shift' language feature to be enabled., Try updating your pubspec.yaml to set the minimum SDK constraint to 2.14 or higher, and running 'pub get'., {string: triple-shift, string2: 2.14}], >>, >)
beginBinaryExpression(>>>)
handleLiteralInt(42)
- endBinaryExpression(>>)
+ endBinaryExpression(>>>)
handleExpressionStatement(;)
handleIdentifier(print, expression)
handleNoTypeArguments(()
@@ -112,7 +112,7 @@
handleRecoverableError(Message[ExperimentNotEnabled, This requires the 'triple-shift' language feature to be enabled., Try updating your pubspec.yaml to set the minimum SDK constraint to 2.14 or higher, and running 'pub get'., {string: triple-shift, string2: 2.14}], >>, >)
beginBinaryExpression(>>>)
handleLiteralInt(42)
- endBinaryExpression(>>)
+ endBinaryExpression(>>>)
endArguments(1, (, ))
handleSend(print, ;)
handleExpressionStatement(;)
@@ -124,9 +124,8 @@
handleNoArguments(>>)
handleSend(foo, >>)
handleRecoverableError(Message[ExperimentNotEnabled, This requires the 'triple-shift' language feature to be enabled., Try updating your pubspec.yaml to set the minimum SDK constraint to 2.14 or higher, and running 'pub get'., {string: triple-shift, string2: 2.14}], >>, >=)
- beginBinaryExpression(>>>=)
- handleLiteralInt(42)
- endBinaryExpression(>>)
+ handleLiteralInt(42)
+ handleAssignmentExpression(>>>=)
endArguments(1, (, ))
handleSend(print, ;)
handleExpressionStatement(;)
@@ -136,9 +135,8 @@
handleNoArguments(>>)
handleSend(foo, >>)
handleRecoverableError(Message[ExperimentNotEnabled, This requires the 'triple-shift' language feature to be enabled., Try updating your pubspec.yaml to set the minimum SDK constraint to 2.14 or higher, and running 'pub get'., {string: triple-shift, string2: 2.14}], >>, >=)
- beginBinaryExpression(>>>=)
- handleLiteralInt(42)
- endBinaryExpression(>>)
+ handleLiteralInt(42)
+ handleAssignmentExpression(>>>=)
handleParenthesizedExpression(()
beginBinaryExpression(==)
handleIdentifier(foo, expression)
diff --git a/pkg/front_end/parser_testcases/no-triple-shift/define_triple_shift_method.dart.intertwined.expect b/pkg/front_end/parser_testcases/no-triple-shift/define_triple_shift_method.dart.intertwined.expect
index 012f061..c29f941 100644
--- a/pkg/front_end/parser_testcases/no-triple-shift/define_triple_shift_method.dart.intertwined.expect
+++ b/pkg/front_end/parser_testcases/no-triple-shift/define_triple_shift_method.dart.intertwined.expect
@@ -176,7 +176,7 @@
parsePrimary(>>>, expression)
parseLiteralInt(>>>)
listener: handleLiteralInt(42)
- listener: endBinaryExpression(>>)
+ listener: endBinaryExpression(>>>)
ensureSemicolon(42)
listener: handleExpressionStatement(;)
notEofOrValue(}, print)
@@ -222,7 +222,7 @@
parsePrimary(>>>, expression)
parseLiteralInt(>>>)
listener: handleLiteralInt(42)
- listener: endBinaryExpression(>>)
+ listener: endBinaryExpression(>>>)
listener: endArguments(1, (, ))
listener: handleSend(print, ;)
ensureSemicolon())
@@ -264,13 +264,12 @@
reportRecoverableErrorWithEnd(>>, >=, Message[ExperimentNotEnabled, This requires the 'triple-shift' language feature to be enabled., Try updating your pubspec.yaml to set the minimum SDK constraint to 2.14 or higher, and running 'pub get'., {string: triple-shift, string2: 2.14}])
listener: handleRecoverableError(Message[ExperimentNotEnabled, This requires the 'triple-shift' language feature to be enabled., Try updating your pubspec.yaml to set the minimum SDK constraint to 2.14 or higher, and running 'pub get'., {string: triple-shift, string2: 2.14}], >>, >=)
rewriter()
- listener: beginBinaryExpression(>>>=)
- parsePrecedenceExpression(>>>=, 13, true)
+ parsePrecedenceExpression(>>>=, 1, true)
parseUnaryExpression(>>>=, true)
parsePrimary(>>>=, expression)
parseLiteralInt(>>>=)
listener: handleLiteralInt(42)
- listener: endBinaryExpression(>>)
+ listener: handleAssignmentExpression(>>>=)
listener: endArguments(1, (, ))
listener: handleSend(print, ;)
ensureSemicolon())
@@ -306,13 +305,12 @@
reportRecoverableErrorWithEnd(>>, >=, Message[ExperimentNotEnabled, This requires the 'triple-shift' language feature to be enabled., Try updating your pubspec.yaml to set the minimum SDK constraint to 2.14 or higher, and running 'pub get'., {string: triple-shift, string2: 2.14}])
listener: handleRecoverableError(Message[ExperimentNotEnabled, This requires the 'triple-shift' language feature to be enabled., Try updating your pubspec.yaml to set the minimum SDK constraint to 2.14 or higher, and running 'pub get'., {string: triple-shift, string2: 2.14}], >>, >=)
rewriter()
- listener: beginBinaryExpression(>>>=)
- parsePrecedenceExpression(>>>=, 13, true)
+ parsePrecedenceExpression(>>>=, 1, true)
parseUnaryExpression(>>>=, true)
parsePrimary(>>>=, expression)
parseLiteralInt(>>>=)
listener: handleLiteralInt(42)
- listener: endBinaryExpression(>>)
+ listener: handleAssignmentExpression(>>>=)
ensureCloseParen(42, ()
listener: handleParenthesizedExpression(()
listener: beginBinaryExpression(==)
diff --git a/pkg/front_end/parser_testcases/no-triple-shift/define_triple_shift_method.equivalence_info b/pkg/front_end/parser_testcases/no-triple-shift/define_triple_shift_method.equivalence_info
new file mode 100644
index 0000000..ba86f89
--- /dev/null
+++ b/pkg/front_end/parser_testcases/no-triple-shift/define_triple_shift_method.equivalence_info
@@ -0,0 +1,7 @@
+files:
+ - define_triple_shift_method.dart
+ - define_triple_shift_method_prime.dart
+filters:
+ - ignoreListenerArguments
+ignored:
+ - handleRecoverableError
diff --git a/pkg/front_end/parser_testcases/no-triple-shift/define_triple_shift_method_prime.dart b/pkg/front_end/parser_testcases/no-triple-shift/define_triple_shift_method_prime.dart
new file mode 100644
index 0000000..c093e29
--- /dev/null
+++ b/pkg/front_end/parser_testcases/no-triple-shift/define_triple_shift_method_prime.dart
@@ -0,0 +1,13 @@
+class Foo {
+ Foo operator >>(_) => this;
+}
+
+main() {
+ Foo foo = new Foo();
+ foo >> 42;
+ print(foo >> 42);
+ print(foo >>= 42);
+ if ((foo >>= 42) == foo) {
+ print("same");
+ }
+}
diff --git a/pkg/front_end/parser_testcases/no-triple-shift/define_triple_shift_method_prime.dart.expect b/pkg/front_end/parser_testcases/no-triple-shift/define_triple_shift_method_prime.dart.expect
new file mode 100644
index 0000000..cd35af3
--- /dev/null
+++ b/pkg/front_end/parser_testcases/no-triple-shift/define_triple_shift_method_prime.dart.expect
@@ -0,0 +1,137 @@
+beginCompilationUnit(class)
+ beginMetadataStar(class)
+ endMetadataStar(0)
+ beginClassOrNamedMixinApplicationPrelude(class)
+ handleIdentifier(Foo, classOrMixinDeclaration)
+ handleNoTypeVariables({)
+ beginClassDeclaration(class, null, Foo)
+ handleNoType(Foo)
+ handleClassExtends(null, 1)
+ handleClassNoWithClause()
+ handleClassOrMixinImplements(null, 0)
+ handleClassHeader(class, class, null)
+ beginClassOrMixinBody(DeclarationKind.Class, {)
+ beginMetadataStar(Foo)
+ endMetadataStar(0)
+ beginMember()
+ beginMethod(null, null, null, null, null, operator)
+ handleIdentifier(Foo, typeReference)
+ handleNoTypeArguments(operator)
+ handleType(Foo, null)
+ handleOperatorName(operator, >>)
+ handleNoTypeVariables(()
+ beginFormalParameters((, MemberKind.NonStaticMethod)
+ beginMetadataStar(_)
+ endMetadataStar(0)
+ beginFormalParameter(_, MemberKind.NonStaticMethod, null, null, null)
+ handleNoType(()
+ handleIdentifier(_, formalParameterDeclaration)
+ handleFormalParameterWithoutValue())
+ endFormalParameter(null, null, _, null, null, FormalParameterKind.mandatory, MemberKind.NonStaticMethod)
+ endFormalParameters(1, (, ), MemberKind.NonStaticMethod)
+ handleNoInitializers()
+ handleAsyncModifier(null, null)
+ handleThisExpression(this, expression)
+ handleExpressionFunctionBody(=>, ;)
+ endClassMethod(null, Foo, (, null, ;)
+ endMember()
+ endClassOrMixinBody(DeclarationKind.Class, 1, {, })
+ endClassDeclaration(class, })
+ endTopLevelDeclaration(main)
+ beginMetadataStar(main)
+ endMetadataStar(0)
+ beginTopLevelMember(main)
+ beginTopLevelMethod(}, null)
+ handleNoType(})
+ handleIdentifier(main, topLevelFunctionDeclaration)
+ handleNoTypeVariables(()
+ beginFormalParameters((, MemberKind.TopLevelMethod)
+ endFormalParameters(0, (, ), MemberKind.TopLevelMethod)
+ handleAsyncModifier(null, null)
+ beginBlockFunctionBody({)
+ beginMetadataStar(Foo)
+ endMetadataStar(0)
+ handleIdentifier(Foo, typeReference)
+ handleNoTypeArguments(foo)
+ handleType(Foo, null)
+ beginVariablesDeclaration(foo, null, null)
+ handleIdentifier(foo, localVariableDeclaration)
+ beginInitializedIdentifier(foo)
+ beginVariableInitializer(=)
+ beginNewExpression(new)
+ handleIdentifier(Foo, constructorReference)
+ beginConstructorReference(Foo)
+ handleNoTypeArguments(()
+ handleNoConstructorReferenceContinuationAfterTypeArguments(()
+ endConstructorReference(Foo, null, (, ConstructorReferenceContext.New)
+ beginArguments(()
+ endArguments(0, (, ))
+ endNewExpression(new)
+ endVariableInitializer(=)
+ endInitializedIdentifier(foo)
+ endVariablesDeclaration(1, ;)
+ handleIdentifier(foo, expression)
+ handleNoTypeArguments(>>)
+ handleNoArguments(>>)
+ handleSend(foo, >>)
+ beginBinaryExpression(>>)
+ handleLiteralInt(42)
+ endBinaryExpression(>>)
+ handleExpressionStatement(;)
+ handleIdentifier(print, expression)
+ handleNoTypeArguments(()
+ beginArguments(()
+ handleIdentifier(foo, expression)
+ handleNoTypeArguments(>>)
+ handleNoArguments(>>)
+ handleSend(foo, >>)
+ beginBinaryExpression(>>)
+ handleLiteralInt(42)
+ endBinaryExpression(>>)
+ endArguments(1, (, ))
+ handleSend(print, ;)
+ handleExpressionStatement(;)
+ handleIdentifier(print, expression)
+ handleNoTypeArguments(()
+ beginArguments(()
+ handleIdentifier(foo, expression)
+ handleNoTypeArguments(>>=)
+ handleNoArguments(>>=)
+ handleSend(foo, >>=)
+ handleLiteralInt(42)
+ handleAssignmentExpression(>>=)
+ endArguments(1, (, ))
+ handleSend(print, ;)
+ handleExpressionStatement(;)
+ beginIfStatement(if)
+ handleIdentifier(foo, expression)
+ handleNoTypeArguments(>>=)
+ handleNoArguments(>>=)
+ handleSend(foo, >>=)
+ handleLiteralInt(42)
+ handleAssignmentExpression(>>=)
+ handleParenthesizedExpression(()
+ beginBinaryExpression(==)
+ handleIdentifier(foo, expression)
+ handleNoTypeArguments())
+ handleNoArguments())
+ handleSend(foo, ))
+ endBinaryExpression(==)
+ handleParenthesizedCondition(()
+ beginThenStatement({)
+ beginBlock({, BlockKind(statement))
+ handleIdentifier(print, expression)
+ handleNoTypeArguments(()
+ beginArguments(()
+ beginLiteralString("same")
+ endLiteralString(0, ))
+ endArguments(1, (, ))
+ handleSend(print, ;)
+ handleExpressionStatement(;)
+ endBlock(1, {, }, BlockKind(statement))
+ endThenStatement(})
+ endIfStatement(if, null)
+ endBlockFunctionBody(5, {, })
+ endTopLevelMethod(main, null, })
+ endTopLevelDeclaration()
+endCompilationUnit(2, )
diff --git a/pkg/front_end/parser_testcases/no-triple-shift/define_triple_shift_method_prime.dart.intertwined.expect b/pkg/front_end/parser_testcases/no-triple-shift/define_triple_shift_method_prime.dart.intertwined.expect
new file mode 100644
index 0000000..675e626
--- /dev/null
+++ b/pkg/front_end/parser_testcases/no-triple-shift/define_triple_shift_method_prime.dart.intertwined.expect
@@ -0,0 +1,365 @@
+parseUnit(class)
+ skipErrorTokens(class)
+ listener: beginCompilationUnit(class)
+ syntheticPreviousToken(class)
+ parseTopLevelDeclarationImpl(, Instance of 'DirectiveContext')
+ parseMetadataStar()
+ listener: beginMetadataStar(class)
+ listener: endMetadataStar(0)
+ parseTopLevelKeywordDeclaration(, class, Instance of 'DirectiveContext')
+ parseClassDeclarationModifiers(, class)
+ parseClassOrNamedMixinApplication(null, class)
+ listener: beginClassOrNamedMixinApplicationPrelude(class)
+ ensureIdentifier(class, classOrMixinDeclaration)
+ listener: handleIdentifier(Foo, classOrMixinDeclaration)
+ listener: handleNoTypeVariables({)
+ listener: beginClassDeclaration(class, null, Foo)
+ parseClass(Foo, class, class, Foo)
+ parseClassHeaderOpt(Foo, class, class)
+ parseClassExtendsOpt(Foo)
+ listener: handleNoType(Foo)
+ listener: handleClassExtends(null, 1)
+ parseWithClauseOpt(Foo)
+ listener: handleClassNoWithClause()
+ parseClassOrMixinImplementsOpt(Foo)
+ listener: handleClassOrMixinImplements(null, 0)
+ listener: handleClassHeader(class, class, null)
+ parseClassOrMixinOrExtensionBody(Foo, DeclarationKind.Class, Foo)
+ listener: beginClassOrMixinBody(DeclarationKind.Class, {)
+ notEofOrValue(}, Foo)
+ parseClassOrMixinOrExtensionMemberImpl({, DeclarationKind.Class, Foo)
+ parseMetadataStar({)
+ listener: beginMetadataStar(Foo)
+ listener: endMetadataStar(0)
+ listener: beginMember()
+ parseMethod({, null, null, null, null, null, null, {, Instance of 'SimpleType', null, operator, DeclarationKind.Class, Foo, false)
+ listener: beginMethod(null, null, null, null, null, operator)
+ listener: handleIdentifier(Foo, typeReference)
+ listener: handleNoTypeArguments(operator)
+ listener: handleType(Foo, null)
+ parseOperatorName(Foo)
+ listener: handleOperatorName(operator, >>)
+ parseMethodTypeVar(>>)
+ listener: handleNoTypeVariables(()
+ parseGetterOrFormalParameters(>>, operator, false, MemberKind.NonStaticMethod)
+ parseFormalParameters(>>, MemberKind.NonStaticMethod)
+ parseFormalParametersRest((, MemberKind.NonStaticMethod)
+ listener: beginFormalParameters((, MemberKind.NonStaticMethod)
+ parseFormalParameter((, FormalParameterKind.mandatory, MemberKind.NonStaticMethod)
+ parseMetadataStar(()
+ listener: beginMetadataStar(_)
+ listener: endMetadataStar(0)
+ listener: beginFormalParameter(_, MemberKind.NonStaticMethod, null, null, null)
+ listener: handleNoType(()
+ ensureIdentifier((, formalParameterDeclaration)
+ listener: handleIdentifier(_, formalParameterDeclaration)
+ listener: handleFormalParameterWithoutValue())
+ listener: endFormalParameter(null, null, _, null, null, FormalParameterKind.mandatory, MemberKind.NonStaticMethod)
+ listener: endFormalParameters(1, (, ), MemberKind.NonStaticMethod)
+ parseInitializersOpt())
+ listener: handleNoInitializers()
+ parseAsyncModifierOpt())
+ listener: handleAsyncModifier(null, null)
+ inPlainSync()
+ inPlainSync()
+ parseFunctionBody(), false, true)
+ parseExpressionFunctionBody(=>, false)
+ parseExpression(=>)
+ parsePrecedenceExpression(=>, 1, true)
+ parseUnaryExpression(=>, true)
+ parsePrimary(=>, expression)
+ parseThisExpression(=>, expression)
+ listener: handleThisExpression(this, expression)
+ ensureSemicolon(this)
+ listener: handleExpressionFunctionBody(=>, ;)
+ inGenerator()
+ listener: endClassMethod(null, Foo, (, null, ;)
+ listener: endMember()
+ notEofOrValue(}, })
+ listener: endClassOrMixinBody(DeclarationKind.Class, 1, {, })
+ listener: endClassDeclaration(class, })
+ listener: endTopLevelDeclaration(main)
+ parseTopLevelDeclarationImpl(}, Instance of 'DirectiveContext')
+ parseMetadataStar(})
+ listener: beginMetadataStar(main)
+ listener: endMetadataStar(0)
+ parseTopLevelMemberImpl(})
+ listener: beginTopLevelMember(main)
+ isReservedKeyword(()
+ parseTopLevelMethod(}, null, }, Instance of 'NoType', null, main, false)
+ listener: beginTopLevelMethod(}, null)
+ listener: handleNoType(})
+ ensureIdentifierPotentiallyRecovered(}, topLevelFunctionDeclaration, false)
+ listener: handleIdentifier(main, topLevelFunctionDeclaration)
+ parseMethodTypeVar(main)
+ listener: handleNoTypeVariables(()
+ parseGetterOrFormalParameters(main, main, false, MemberKind.TopLevelMethod)
+ parseFormalParameters(main, MemberKind.TopLevelMethod)
+ parseFormalParametersRest((, MemberKind.TopLevelMethod)
+ listener: beginFormalParameters((, MemberKind.TopLevelMethod)
+ listener: endFormalParameters(0, (, ), MemberKind.TopLevelMethod)
+ parseAsyncModifierOpt())
+ listener: handleAsyncModifier(null, null)
+ inPlainSync()
+ parseFunctionBody(), false, false)
+ listener: beginBlockFunctionBody({)
+ notEofOrValue(}, Foo)
+ parseStatement({)
+ parseStatementX({)
+ parseExpressionStatementOrDeclarationAfterModifiers({, {, null, null, null, false)
+ looksLikeLocalFunction(foo)
+ listener: beginMetadataStar(Foo)
+ listener: endMetadataStar(0)
+ listener: handleIdentifier(Foo, typeReference)
+ listener: handleNoTypeArguments(foo)
+ listener: handleType(Foo, null)
+ listener: beginVariablesDeclaration(foo, null, null)
+ parseVariablesDeclarationRest(Foo, true)
+ parseOptionallyInitializedIdentifier(Foo)
+ ensureIdentifier(Foo, localVariableDeclaration)
+ listener: handleIdentifier(foo, localVariableDeclaration)
+ listener: beginInitializedIdentifier(foo)
+ parseVariableInitializerOpt(foo)
+ listener: beginVariableInitializer(=)
+ parseExpression(=)
+ parsePrecedenceExpression(=, 1, true)
+ parseUnaryExpression(=, true)
+ parsePrimary(=, expression)
+ parseNewExpression(=)
+ isNextIdentifier(new)
+ listener: beginNewExpression(new)
+ parseConstructorReference(new, ConstructorReferenceContext.New, null)
+ ensureIdentifier(new, constructorReference)
+ listener: handleIdentifier(Foo, constructorReference)
+ listener: beginConstructorReference(Foo)
+ parseQualifiedRestOpt(Foo, constructorReferenceContinuation)
+ listener: handleNoTypeArguments(()
+ listener: handleNoConstructorReferenceContinuationAfterTypeArguments(()
+ listener: endConstructorReference(Foo, null, (, ConstructorReferenceContext.New)
+ parseConstructorInvocationArguments(Foo)
+ parseArgumentsRest(()
+ listener: beginArguments(()
+ listener: endArguments(0, (, ))
+ listener: endNewExpression(new)
+ listener: endVariableInitializer(=)
+ listener: endInitializedIdentifier(foo)
+ ensureSemicolon())
+ listener: endVariablesDeclaration(1, ;)
+ notEofOrValue(}, foo)
+ parseStatement(;)
+ parseStatementX(;)
+ parseExpressionStatementOrDeclarationAfterModifiers(;, ;, null, null, null, false)
+ looksLikeLocalFunction(foo)
+ parseExpressionStatement(;)
+ parseExpression(;)
+ parsePrecedenceExpression(;, 1, true)
+ parseUnaryExpression(;, true)
+ parsePrimary(;, expression)
+ parseSendOrFunctionLiteral(;, expression)
+ parseSend(;, expression)
+ isNextIdentifier(;)
+ ensureIdentifier(;, expression)
+ listener: handleIdentifier(foo, expression)
+ listener: handleNoTypeArguments(>>)
+ parseArgumentsOpt(foo)
+ listener: handleNoArguments(>>)
+ listener: handleSend(foo, >>)
+ listener: beginBinaryExpression(>>)
+ parsePrecedenceExpression(>>, 13, true)
+ parseUnaryExpression(>>, true)
+ parsePrimary(>>, expression)
+ parseLiteralInt(>>)
+ listener: handleLiteralInt(42)
+ listener: endBinaryExpression(>>)
+ ensureSemicolon(42)
+ listener: handleExpressionStatement(;)
+ notEofOrValue(}, print)
+ parseStatement(;)
+ parseStatementX(;)
+ parseExpressionStatementOrDeclarationAfterModifiers(;, ;, null, null, null, false)
+ looksLikeLocalFunction(print)
+ parseExpressionStatement(;)
+ parseExpression(;)
+ parsePrecedenceExpression(;, 1, true)
+ parseUnaryExpression(;, true)
+ parsePrimary(;, expression)
+ parseSendOrFunctionLiteral(;, expression)
+ looksLikeFunctionBody(;)
+ parseSend(;, expression)
+ isNextIdentifier(;)
+ ensureIdentifier(;, expression)
+ listener: handleIdentifier(print, expression)
+ listener: handleNoTypeArguments(()
+ parseArgumentsOpt(print)
+ parseArguments(print)
+ parseArgumentsRest(()
+ listener: beginArguments(()
+ parseExpression(()
+ parsePrecedenceExpression((, 1, true)
+ parseUnaryExpression((, true)
+ parsePrimary((, expression)
+ parseSendOrFunctionLiteral((, expression)
+ parseSend((, expression)
+ isNextIdentifier(()
+ ensureIdentifier((, expression)
+ listener: handleIdentifier(foo, expression)
+ listener: handleNoTypeArguments(>>)
+ parseArgumentsOpt(foo)
+ listener: handleNoArguments(>>)
+ listener: handleSend(foo, >>)
+ listener: beginBinaryExpression(>>)
+ parsePrecedenceExpression(>>, 13, true)
+ parseUnaryExpression(>>, true)
+ parsePrimary(>>, expression)
+ parseLiteralInt(>>)
+ listener: handleLiteralInt(42)
+ listener: endBinaryExpression(>>)
+ listener: endArguments(1, (, ))
+ listener: handleSend(print, ;)
+ ensureSemicolon())
+ listener: handleExpressionStatement(;)
+ notEofOrValue(}, print)
+ parseStatement(;)
+ parseStatementX(;)
+ parseExpressionStatementOrDeclarationAfterModifiers(;, ;, null, null, null, false)
+ looksLikeLocalFunction(print)
+ parseExpressionStatement(;)
+ parseExpression(;)
+ parsePrecedenceExpression(;, 1, true)
+ parseUnaryExpression(;, true)
+ parsePrimary(;, expression)
+ parseSendOrFunctionLiteral(;, expression)
+ looksLikeFunctionBody(;)
+ parseSend(;, expression)
+ isNextIdentifier(;)
+ ensureIdentifier(;, expression)
+ listener: handleIdentifier(print, expression)
+ listener: handleNoTypeArguments(()
+ parseArgumentsOpt(print)
+ parseArguments(print)
+ parseArgumentsRest(()
+ listener: beginArguments(()
+ parseExpression(()
+ parsePrecedenceExpression((, 1, true)
+ parseUnaryExpression((, true)
+ parsePrimary((, expression)
+ parseSendOrFunctionLiteral((, expression)
+ parseSend((, expression)
+ isNextIdentifier(()
+ ensureIdentifier((, expression)
+ listener: handleIdentifier(foo, expression)
+ listener: handleNoTypeArguments(>>=)
+ parseArgumentsOpt(foo)
+ listener: handleNoArguments(>>=)
+ listener: handleSend(foo, >>=)
+ parsePrecedenceExpression(>>=, 1, true)
+ parseUnaryExpression(>>=, true)
+ parsePrimary(>>=, expression)
+ parseLiteralInt(>>=)
+ listener: handleLiteralInt(42)
+ listener: handleAssignmentExpression(>>=)
+ listener: endArguments(1, (, ))
+ listener: handleSend(print, ;)
+ ensureSemicolon())
+ listener: handleExpressionStatement(;)
+ notEofOrValue(}, if)
+ parseStatement(;)
+ parseStatementX(;)
+ parseIfStatement(;)
+ listener: beginIfStatement(if)
+ ensureParenthesizedCondition(if)
+ parseExpressionInParenthesisRest(()
+ parseExpression(()
+ parsePrecedenceExpression((, 1, true)
+ parseUnaryExpression((, true)
+ parsePrimary((, expression)
+ parseParenthesizedExpressionOrFunctionLiteral(()
+ parseParenthesizedExpression(()
+ parseExpressionInParenthesis(()
+ parseExpressionInParenthesisRest(()
+ parseExpression(()
+ parsePrecedenceExpression((, 1, true)
+ parseUnaryExpression((, true)
+ parsePrimary((, expression)
+ parseSendOrFunctionLiteral((, expression)
+ parseSend((, expression)
+ isNextIdentifier(()
+ ensureIdentifier((, expression)
+ listener: handleIdentifier(foo, expression)
+ listener: handleNoTypeArguments(>>=)
+ parseArgumentsOpt(foo)
+ listener: handleNoArguments(>>=)
+ listener: handleSend(foo, >>=)
+ parsePrecedenceExpression(>>=, 1, true)
+ parseUnaryExpression(>>=, true)
+ parsePrimary(>>=, expression)
+ parseLiteralInt(>>=)
+ listener: handleLiteralInt(42)
+ listener: handleAssignmentExpression(>>=)
+ ensureCloseParen(42, ()
+ listener: handleParenthesizedExpression(()
+ listener: beginBinaryExpression(==)
+ parsePrecedenceExpression(==, 8, true)
+ parseUnaryExpression(==, true)
+ parsePrimary(==, expression)
+ parseSendOrFunctionLiteral(==, expression)
+ parseSend(==, expression)
+ isNextIdentifier(==)
+ ensureIdentifier(==, expression)
+ listener: handleIdentifier(foo, expression)
+ listener: handleNoTypeArguments())
+ parseArgumentsOpt(foo)
+ listener: handleNoArguments())
+ listener: handleSend(foo, ))
+ listener: endBinaryExpression(==)
+ ensureCloseParen(foo, ()
+ listener: handleParenthesizedCondition(()
+ listener: beginThenStatement({)
+ parseStatement())
+ parseStatementX())
+ parseBlock(), BlockKind(statement))
+ ensureBlock(), null, null)
+ listener: beginBlock({, BlockKind(statement))
+ notEofOrValue(}, print)
+ parseStatement({)
+ parseStatementX({)
+ parseExpressionStatementOrDeclarationAfterModifiers({, {, null, null, null, false)
+ looksLikeLocalFunction(print)
+ parseExpressionStatement({)
+ parseExpression({)
+ parsePrecedenceExpression({, 1, true)
+ parseUnaryExpression({, true)
+ parsePrimary({, expression)
+ parseSendOrFunctionLiteral({, expression)
+ looksLikeFunctionBody(;)
+ parseSend({, expression)
+ isNextIdentifier({)
+ ensureIdentifier({, expression)
+ listener: handleIdentifier(print, expression)
+ listener: handleNoTypeArguments(()
+ parseArgumentsOpt(print)
+ parseArguments(print)
+ parseArgumentsRest(()
+ listener: beginArguments(()
+ parseExpression(()
+ parsePrecedenceExpression((, 1, true)
+ parseUnaryExpression((, true)
+ parsePrimary((, expression)
+ parseLiteralString(()
+ parseSingleLiteralString(()
+ listener: beginLiteralString("same")
+ listener: endLiteralString(0, ))
+ listener: endArguments(1, (, ))
+ listener: handleSend(print, ;)
+ ensureSemicolon())
+ listener: handleExpressionStatement(;)
+ notEofOrValue(}, })
+ listener: endBlock(1, {, }, BlockKind(statement))
+ listener: endThenStatement(})
+ listener: endIfStatement(if, null)
+ notEofOrValue(}, })
+ listener: endBlockFunctionBody(5, {, })
+ listener: endTopLevelMethod(main, null, })
+ listener: endTopLevelDeclaration()
+ reportAllErrorTokens(class)
+ listener: endCompilationUnit(2, )
diff --git a/pkg/front_end/parser_testcases/no-triple-shift/define_triple_shift_method_prime.dart.parser.expect b/pkg/front_end/parser_testcases/no-triple-shift/define_triple_shift_method_prime.dart.parser.expect
new file mode 100644
index 0000000..4441541
--- /dev/null
+++ b/pkg/front_end/parser_testcases/no-triple-shift/define_triple_shift_method_prime.dart.parser.expect
@@ -0,0 +1,29 @@
+class Foo {
+Foo operator >>(_) => this;
+}
+
+main() {
+Foo foo = new Foo();
+foo >> 42;
+print(foo >> 42);
+print(foo >>= 42);
+if ((foo >>= 42) == foo) {
+print("same");
+}
+}
+
+
+class[KeywordToken] Foo[StringToken] {[BeginToken]
+Foo[StringToken] operator[KeywordToken] >>[SimpleToken]([BeginToken]_[StringToken])[SimpleToken] =>[SimpleToken] this[KeywordToken];[SimpleToken]
+}[SimpleToken]
+
+main[StringToken]([BeginToken])[SimpleToken] {[BeginToken]
+Foo[StringToken] foo[StringToken] =[SimpleToken] new[KeywordToken] Foo[StringToken]([BeginToken])[SimpleToken];[SimpleToken]
+foo[StringToken] >>[SimpleToken] 42[StringToken];[SimpleToken]
+print[StringToken]([BeginToken]foo[StringToken] >>[SimpleToken] 42[StringToken])[SimpleToken];[SimpleToken]
+print[StringToken]([BeginToken]foo[StringToken] >>=[SimpleToken] 42[StringToken])[SimpleToken];[SimpleToken]
+if[KeywordToken] ([BeginToken]([BeginToken]foo[StringToken] >>=[SimpleToken] 42[StringToken])[SimpleToken] ==[SimpleToken] foo[StringToken])[SimpleToken] {[BeginToken]
+print[StringToken]([BeginToken]"same"[StringToken])[SimpleToken];[SimpleToken]
+}[SimpleToken]
+}[SimpleToken]
+[SimpleToken]
diff --git a/pkg/front_end/parser_testcases/no-triple-shift/define_triple_shift_method_prime.dart.scanner.expect b/pkg/front_end/parser_testcases/no-triple-shift/define_triple_shift_method_prime.dart.scanner.expect
new file mode 100644
index 0000000..4441541
--- /dev/null
+++ b/pkg/front_end/parser_testcases/no-triple-shift/define_triple_shift_method_prime.dart.scanner.expect
@@ -0,0 +1,29 @@
+class Foo {
+Foo operator >>(_) => this;
+}
+
+main() {
+Foo foo = new Foo();
+foo >> 42;
+print(foo >> 42);
+print(foo >>= 42);
+if ((foo >>= 42) == foo) {
+print("same");
+}
+}
+
+
+class[KeywordToken] Foo[StringToken] {[BeginToken]
+Foo[StringToken] operator[KeywordToken] >>[SimpleToken]([BeginToken]_[StringToken])[SimpleToken] =>[SimpleToken] this[KeywordToken];[SimpleToken]
+}[SimpleToken]
+
+main[StringToken]([BeginToken])[SimpleToken] {[BeginToken]
+Foo[StringToken] foo[StringToken] =[SimpleToken] new[KeywordToken] Foo[StringToken]([BeginToken])[SimpleToken];[SimpleToken]
+foo[StringToken] >>[SimpleToken] 42[StringToken];[SimpleToken]
+print[StringToken]([BeginToken]foo[StringToken] >>[SimpleToken] 42[StringToken])[SimpleToken];[SimpleToken]
+print[StringToken]([BeginToken]foo[StringToken] >>=[SimpleToken] 42[StringToken])[SimpleToken];[SimpleToken]
+if[KeywordToken] ([BeginToken]([BeginToken]foo[StringToken] >>=[SimpleToken] 42[StringToken])[SimpleToken] ==[SimpleToken] foo[StringToken])[SimpleToken] {[BeginToken]
+print[StringToken]([BeginToken]"same"[StringToken])[SimpleToken];[SimpleToken]
+}[SimpleToken]
+}[SimpleToken]
+[SimpleToken]
diff --git a/pkg/front_end/parser_testcases/no-triple-shift/simple_attempted_usage_of_triple_shift.dart.expect b/pkg/front_end/parser_testcases/no-triple-shift/simple_attempted_usage_of_triple_shift.dart.expect
index a4925e8..c88d460 100644
--- a/pkg/front_end/parser_testcases/no-triple-shift/simple_attempted_usage_of_triple_shift.dart.expect
+++ b/pkg/front_end/parser_testcases/no-triple-shift/simple_attempted_usage_of_triple_shift.dart.expect
@@ -40,7 +40,7 @@
handleRecoverableError(Message[ExperimentNotEnabled, This requires the 'triple-shift' language feature to be enabled., Try updating your pubspec.yaml to set the minimum SDK constraint to 2.14 or higher, and running 'pub get'., {string: triple-shift, string2: 2.14}], >>, >)
beginBinaryExpression(>>>)
handleLiteralInt(2)
- endBinaryExpression(>>)
+ endBinaryExpression(>>>)
endVariableInitializer(=)
endInitializedIdentifier(x)
endVariablesDeclaration(1, ;)
diff --git a/pkg/front_end/parser_testcases/no-triple-shift/simple_attempted_usage_of_triple_shift.dart.intertwined.expect b/pkg/front_end/parser_testcases/no-triple-shift/simple_attempted_usage_of_triple_shift.dart.intertwined.expect
index 7cb2b5a..6db3700 100644
--- a/pkg/front_end/parser_testcases/no-triple-shift/simple_attempted_usage_of_triple_shift.dart.intertwined.expect
+++ b/pkg/front_end/parser_testcases/no-triple-shift/simple_attempted_usage_of_triple_shift.dart.intertwined.expect
@@ -72,7 +72,7 @@
parsePrimary(>>>, expression)
parseLiteralInt(>>>)
listener: handleLiteralInt(2)
- listener: endBinaryExpression(>>)
+ listener: endBinaryExpression(>>>)
listener: endVariableInitializer(=)
listener: endInitializedIdentifier(x)
ensureSemicolon(2)
diff --git a/pkg/front_end/test/ast_nodes_has_to_string_test.dart b/pkg/front_end/test/ast_nodes_has_to_string_test.dart
index 1750eab..9856c05 100644
--- a/pkg/front_end/test/ast_nodes_has_to_string_test.dart
+++ b/pkg/front_end/test/ast_nodes_has_to_string_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.md file.
-// @dart = 2.9
-
import 'dart:io' show File, Platform, stdin, exitCode;
import 'package:front_end/src/api_prototype/compiler_options.dart';
@@ -32,7 +30,7 @@
/*Uri initializeFrom*/ null,
/*bool outlineOnly*/ true);
c = await compiler.computeDelta();
- classHierarchy = compiler.getClassHierarchy();
+ classHierarchy = compiler.getClassHierarchy()!;
List<Library> libraries = c.libraries
.where((Library lib) =>
(lib.importUri.toString() == "package:kernel/ast.dart"))
@@ -63,13 +61,13 @@
if (toStringList.length > 1) throw "What?";
if (toStringList.length == 1) {
classMapWithOne[c.fileUri] ??= <Class>[];
- classMapWithOne[c.fileUri].add(c);
+ classMapWithOne[c.fileUri]!.add(c);
continue;
}
toGo++;
classMap[c.fileUri] ??= <Class>[];
- classMap[c.fileUri].add(c);
+ classMap[c.fileUri]!.add(c);
}
}
}
@@ -85,7 +83,7 @@
if (args.length == 1 && args.single == "--interactive") {
for (Uri uri in classMap.keys) {
- List<Class> classes = classMap[uri];
+ List<Class> classes = classMap[uri]!;
print("Would you like to update ${classes.length} classes in ${uri}?"
" (y/n)");
if (stdin.readLineSync() != "y") {
@@ -132,7 +130,7 @@
if (args.length == 1 && args.single == "--interactive") {
for (Uri uri in classMapWithOne.keys) {
- List<Class> classes = classMapWithOne[uri];
+ List<Class> classes = classMapWithOne[uri]!;
print("Would you like to update toString for ${classes.length} "
"classes in ${uri}? (y/n)");
if (stdin.readLineSync() != "y") {
diff --git a/pkg/front_end/test/binary_md_vm_tags_and_version_git_test.dart b/pkg/front_end/test/binary_md_vm_tags_and_version_git_test.dart
index 1f8b12d..61cac8f 100644
--- a/pkg/front_end/test/binary_md_vm_tags_and_version_git_test.dart
+++ b/pkg/front_end/test/binary_md_vm_tags_and_version_git_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 'dart:io' show File, Platform;
import 'package:_fe_analyzer_shared/src/messages/severity.dart' show Severity;
@@ -42,7 +40,7 @@
File vmTagFile = new File("$repoDir/runtime/vm/kernel_binary.h");
String vmTagContent = vmTagFile.readAsStringSync();
List<String> vmTagLines = vmTagContent.split("\n");
- int vmVersion;
+ int? vmVersion;
Map<int, String> vmTagToName = {};
Map<int, String> vmConstantTagToName = {};
for (int i = 0; i < vmTagLines.length; i++) {
@@ -54,15 +52,15 @@
.trim());
} else if (line.startsWith("#define KERNEL_TAG_LIST(V)")) {
while (true) {
- RegExpMatch match = tagParser.firstMatch(line);
+ RegExpMatch? match = tagParser.firstMatch(line);
if (match != null) {
- int value = int.parse(match.group(2));
+ int value = int.parse(match.group(2)!);
int end = value + 1;
- if (uses8Tags(match.group(1))) {
+ if (uses8Tags(match.group(1)!)) {
end = value + 8;
}
for (int j = value; j < end; j++) {
- vmTagToName[j] = match.group(1);
+ vmTagToName[j] = match.group(1)!;
}
}
if (!vmTagLines[i].trim().endsWith(r"\")) {
@@ -73,9 +71,9 @@
}
} else if (line.startsWith("enum ConstantTag {")) {
while (true) {
- RegExpMatch match = constantTagParser.firstMatch(line);
+ RegExpMatch? match = constantTagParser.firstMatch(line);
if (match != null) {
- vmConstantTagToName[int.parse(match.group(2))] = match.group(1);
+ vmConstantTagToName[int.parse(match.group(2)!)] = match.group(1)!;
}
if (vmTagLines[i].trim().startsWith("}")) {
break;
@@ -102,7 +100,7 @@
Class constantTagClass =
tagLibrary.classes.firstWhere((c) => c.name == "ConstantTag");
- int tagVersion;
+ int? tagVersion;
for (TagCompare compareMe in [
new TagCompare(binaryMdReader.tagToName, binaryMdReader.version,
vmTagToName, vmVersion, tagClass),
@@ -116,8 +114,8 @@
if (f.name.text.endsWith("HighBit")) continue;
if (f.name.text.endsWith("Bias")) continue;
if (f.name.text == "ComponentFile") continue;
- ConstantExpression value = f.initializer;
- IntConstant intConstant = value.constant;
+ ConstantExpression value = f.initializer as ConstantExpression;
+ IntConstant intConstant = value.constant as IntConstant;
int intValue = intConstant.value;
if (f.name.text == "BinaryFormatVersion") {
tagVersion = intValue;
@@ -150,14 +148,14 @@
// Kernels tag.dart vs binary.mds tags.
for (int key in tagToNameMd.keys) {
- String nameMd = tagToNameMd[key];
- String name = tagToName[key];
+ String nameMd = tagToNameMd[key]!;
+ String name = tagToName[key]!;
if (nameMd == name) continue;
throw "$key: $nameMd vs $name";
}
for (int key in tagToName.keys) {
- String nameMd = tagToNameMd[key];
- String name = tagToName[key];
+ String nameMd = tagToNameMd[key]!;
+ String name = tagToName[key]!;
if (nameMd == name) continue;
throw "$key: $nameMd vs $name";
}
@@ -169,8 +167,8 @@
// Kernels tag.dart vs the VMs tags.
// Here we only compare one way because the VM can have more (old) tags.
for (int key in tagToName.keys) {
- String nameVm = compareMe.vmTagToName[key];
- String name = tagToName[key];
+ String nameVm = compareMe.vmTagToName[key]!;
+ String name = tagToName[key]!;
if (nameVm == name) continue;
throw "$key: $nameVm vs $name";
}
@@ -195,9 +193,9 @@
class TagCompare {
final Map<int, String> mdTagToName;
- final int mdVersion;
+ final int? mdVersion;
final Map<int, String> vmTagToName;
- final int vmVersion;
+ final int? vmVersion;
final Class tagClass;
TagCompare(this.mdTagToName, this.mdVersion, this.vmTagToName, this.vmVersion,
diff --git a/pkg/front_end/test/class_hierarchy/class_hierarchy_test.dart b/pkg/front_end/test/class_hierarchy/class_hierarchy_test.dart
index 5fb09fd..c5629b1 100644
--- a/pkg/front_end/test/class_hierarchy/class_hierarchy_test.dart
+++ b/pkg/front_end/test/class_hierarchy/class_hierarchy_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 'dart:io' show Directory, Platform;
import 'package:_fe_analyzer_shared/src/testing/features.dart';
import 'package:_fe_analyzer_shared/src/testing/id.dart';
@@ -36,7 +34,7 @@
InternalCompilerResult compilerResult,
Library library,
Map<Id, ActualData<Features>> actualMap,
- {bool verbose}) {
+ {bool? verbose}) {
new InheritanceDataExtractor(compilerResult, actualMap)
.computeForLibrary(library);
}
@@ -47,7 +45,7 @@
InternalCompilerResult compilerResult,
Class cls,
Map<Id, ActualData<Features>> actualMap,
- {bool verbose}) {
+ {bool? verbose}) {
new InheritanceDataExtractor(compilerResult, actualMap)
.computeForClass(cls);
}
@@ -56,7 +54,7 @@
bool get supportsErrors => true;
@override
- Features computeErrorData(TestConfig config, InternalCompilerResult compiler,
+ Features? computeErrorData(TestConfig config, InternalCompilerResult compiler,
Id id, List<FormattedMessage> errors) {
return null; //errorsToText(errors, useCodes: true);
}
@@ -97,19 +95,19 @@
this._compilerResult, Map<Id, ActualData<Features>> actualMap)
: super(_compilerResult, actualMap);
- CoreTypes get _coreTypes => _compilerResult.coreTypes;
+ CoreTypes get _coreTypes => _compilerResult.coreTypes!;
ClassHierarchyBuilder get _classHierarchyBuilder =>
- _compilerResult.kernelTargetForTesting.loader.builderHierarchy;
+ _compilerResult.kernelTargetForTesting!.loader.builderHierarchy;
@override
void computeForClass(Class node) {
super.computeForClass(node);
ClassHierarchyNode classHierarchyNode =
_classHierarchyBuilder.getNodeFromClass(node);
- ClassHierarchyNodeDataForTesting data = classHierarchyNode.dataForTesting;
+ ClassHierarchyNodeDataForTesting data = classHierarchyNode.dataForTesting!;
void addMember(ClassMember classMember,
- {bool isSetter, bool isClassMember}) {
+ {required bool isSetter, required bool isClassMember}) {
Member member = classMember.getMember(_classHierarchyBuilder);
Member memberOrigin = member.memberSignatureOrigin ?? member;
if (memberOrigin.enclosingClass == _coreTypes.objectClass) {
@@ -123,9 +121,9 @@
TreeNode nodeWithOffset;
if (member.enclosingClass == node) {
- nodeWithOffset = computeTreeNodeWithOffset(member);
+ nodeWithOffset = computeTreeNodeWithOffset(member)!;
} else {
- nodeWithOffset = computeTreeNodeWithOffset(node);
+ nodeWithOffset = computeTreeNodeWithOffset(node)!;
}
if (classMember.isSourceDeclaration) {
features.add(Tag.isSourceDeclaration);
@@ -144,7 +142,7 @@
}
features[Tag.classBuilder] = classMember.classBuilder.name;
- Set<ClassMember> declaredOverrides =
+ Set<ClassMember>? declaredOverrides =
data.declaredOverrides[data.aliasMap[classMember] ?? classMember];
if (declaredOverrides != null) {
for (ClassMember override in declaredOverrides) {
@@ -153,7 +151,7 @@
}
}
- Set<ClassMember> mixinApplicationOverrides = data
+ Set<ClassMember>? mixinApplicationOverrides = data
.mixinApplicationOverrides[data.aliasMap[classMember] ?? classMember];
if (mixinApplicationOverrides != null) {
for (ClassMember override in mixinApplicationOverrides) {
@@ -162,7 +160,7 @@
}
}
- Set<ClassMember> inheritedImplements =
+ Set<ClassMember>? inheritedImplements =
data.inheritedImplements[data.aliasMap[classMember] ?? classMember];
if (inheritedImplements != null) {
for (ClassMember implement in inheritedImplements) {
@@ -187,7 +185,7 @@
features[Tag.type] = procedureType(member);
features[Tag.covariance] =
classMember.getCovariance(_classHierarchyBuilder).toString();
- features[Tag.stubTarget] = memberQualifiedName(member.stubTarget);
+ features[Tag.stubTarget] = memberQualifiedName(member.stubTarget!);
break;
case ProcedureStubKind.NoSuchMethodForwarder:
// TODO: Handle this case.
@@ -203,21 +201,21 @@
break;
case ProcedureStubKind.ConcreteMixinStub:
features.add(Tag.concreteMixinStub);
- features[Tag.stubTarget] = memberQualifiedName(member.stubTarget);
+ features[Tag.stubTarget] = memberQualifiedName(member.stubTarget!);
break;
}
}
- registerValue(nodeWithOffset?.location?.file, nodeWithOffset?.fileOffset,
+ registerValue(nodeWithOffset.location!.file, nodeWithOffset.fileOffset,
id, features, member);
}
classHierarchyNode.classMemberMap
- ?.forEach((Name name, ClassMember classMember) {
+ .forEach((Name name, ClassMember classMember) {
addMember(classMember, isSetter: false, isClassMember: true);
});
classHierarchyNode.classSetterMap
- ?.forEach((Name name, ClassMember classMember) {
+ .forEach((Name name, ClassMember classMember) {
addMember(classMember, isSetter: true, isClassMember: true);
});
classHierarchyNode.interfaceMemberMap
@@ -239,14 +237,14 @@
Features features = new Features();
ClassHierarchyNode classHierarchyNode =
_classHierarchyBuilder.getNodeFromClass(node);
- ClassHierarchyNodeDataForTesting data = classHierarchyNode.dataForTesting;
+ ClassHierarchyNodeDataForTesting data = classHierarchyNode.dataForTesting!;
classHierarchyNode.superclasses.forEach((Supertype supertype) {
features.addElement(Tag.superclasses, supertypeToText(supertype));
});
classHierarchyNode.interfaces.forEach((Supertype supertype) {
features.addElement(Tag.interfaces, supertypeToText(supertype));
});
- if (data.abstractMembers != null) {
+ if (data.abstractMembers.isNotEmpty) {
for (ClassMember abstractMember in data.abstractMembers) {
features.addElement(
Tag.abstractMembers, classMemberQualifiedName(abstractMember));
@@ -282,7 +280,7 @@
}
String memberQualifiedName(Member member) {
- return '${member.enclosingClass.name}.${memberName(member)}';
+ return '${member.enclosingClass!.name}.${memberName(member)}';
}
String procedureType(Procedure procedure) {
diff --git a/pkg/front_end/test/compile_benchmark_helper.dart b/pkg/front_end/test/compile_benchmark_helper.dart
index 1b187e8..fa1c9fe 100644
--- a/pkg/front_end/test/compile_benchmark_helper.dart
+++ b/pkg/front_end/test/compile_benchmark_helper.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 '../tool/_fasta/entry_points.dart' show compileEntryPoint;
main(List<String> arguments) async {
@@ -12,7 +10,7 @@
print("[");
bool printed = false;
for (int i = 0; i < numCalls.length; i++) {
- int value = numCalls[i];
+ int? value = numCalls[i];
if (value != null && value > 0) {
if (printed) print(",");
print("$i, $value");
@@ -24,11 +22,11 @@
print("[");
bool printed = false;
for (int i = 0; i < inCall.length; i++) {
- int value = inCall[i];
+ int? value = inCall[i];
if (value == null) continue;
if (value != 0) throw "$i has value $value";
if (printed) print(",");
- int time = callTimes[i];
+ int? time = callTimes[i];
print("$i, $time");
printed = true;
}
@@ -36,7 +34,7 @@
}
}
-List<int> numCalls = [];
+List<int?> numCalls = [];
void registerCall(int procedureNum) {
while (numCalls.length <= procedureNum) {
@@ -46,12 +44,12 @@
numCalls.length *= 2;
}
}
- numCalls[procedureNum] ??= 0;
- numCalls[procedureNum]++;
+ int numCallsCount = numCalls[procedureNum] ??= 0;
+ numCalls[procedureNum] = numCallsCount + 1;
}
-List<int> inCall = [];
-List<int> callTimes = [];
+List<int?> inCall = [];
+List<int?> callTimes = [];
Stopwatch stopwatch = new Stopwatch()..start();
void registerCallStart(int procedureNum) {
@@ -64,18 +62,22 @@
callTimes.length *= 2;
}
}
- inCall[procedureNum] ??= 0;
- callTimes[procedureNum] ??= 0;
- if (inCall[procedureNum]++ == 0) {
+ int inCallCount = inCall[procedureNum] ??= 0;
+ int callTimesCount = callTimes[procedureNum] ??= 0;
+ inCall[procedureNum] = inCallCount + 1;
+ if (inCallCount == 0) {
// First --- start a timer-ish.
- callTimes[procedureNum] -= stopwatch.elapsedMicroseconds;
+ callTimes[procedureNum] = callTimesCount - stopwatch.elapsedMicroseconds;
}
}
void registerCallEnd(int procedureNum) {
- if (inCall[procedureNum]-- == 1) {
+ int inCallCount = inCall[procedureNum]!;
+ inCall[procedureNum] = inCallCount - 1;
+ if (inCallCount == 1) {
// Last --- stop the timer-ish.
- callTimes[procedureNum] += stopwatch.elapsedMicroseconds;
+ callTimes[procedureNum] =
+ callTimes[procedureNum]! + stopwatch.elapsedMicroseconds;
}
}
diff --git a/pkg/front_end/test/compile_dart2js_with_no_sdk_test.dart b/pkg/front_end/test/compile_dart2js_with_no_sdk_test.dart
index 668ff0a..1ec6b5e 100644
--- a/pkg/front_end/test/compile_dart2js_with_no_sdk_test.dart
+++ b/pkg/front_end/test/compile_dart2js_with_no_sdk_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/api_prototype/compiler_options.dart';
import 'incremental_suite.dart' show TestIncrementalCompiler, getOptions;
@@ -11,7 +9,7 @@
main() async {
final Uri dart2jsUrl = Uri.base.resolve("pkg/compiler/bin/dart2js.dart");
CompilerOptions options = getOptions();
- options.sdkSummary = options.sdkSummary.resolve("nonexisting.dill");
+ options.sdkSummary = options.sdkSummary!.resolve("nonexisting.dill");
options.librariesSpecificationUri = null;
int diagnosticCount = 0;
options.onDiagnostic = (DiagnosticMessage message) {
diff --git a/pkg/front_end/test/compile_with_no_sdk_test.dart b/pkg/front_end/test/compile_with_no_sdk_test.dart
index 1cbbd98..5f776e7 100644
--- a/pkg/front_end/test/compile_with_no_sdk_test.dart
+++ b/pkg/front_end/test/compile_with_no_sdk_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/api_prototype/compiler_options.dart';
import 'package:front_end/src/api_prototype/memory_file_system.dart';
@@ -13,7 +11,7 @@
await compile("import 'foo.dart' if (dart.library.bar) 'baz.dart';");
}
-void compile(String data) async {
+Future<void> compile(String data) async {
Uri base = Uri.parse("org-dartlang-test:///");
Uri sdkSummary = base.resolve("nonexisting.dill");
Uri mainFile = base.resolve("main.dart");
diff --git a/pkg/front_end/test/constant_evaluator_benchmark.dart b/pkg/front_end/test/constant_evaluator_benchmark.dart
index ff7ee82..428f6d5 100644
--- a/pkg/front_end/test/constant_evaluator_benchmark.dart
+++ b/pkg/front_end/test/constant_evaluator_benchmark.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 'dart:io' show File;
import 'dart:typed_data' show Uint8List;
@@ -45,21 +43,21 @@
import 'package:front_end/src/fasta/kernel/utils.dart' show serializeComponent;
-bool tryWithNoEnvironment;
+bool? tryWithNoEnvironment;
bool verbose = false;
bool skipNonNullEnvironment = false;
bool skipNullEnvironment = false;
void benchmark(Component component, List<Library> libraries) {
if (tryWithNoEnvironment == null) throw "tryWithNoEnvironment not set";
- KernelTarget target = incrementalCompiler.userCode;
+ KernelTarget target = incrementalCompiler.userCode as KernelTarget;
constants.EvaluationMode evaluationMode =
target.getConstantEvaluationModeForTesting();
Uint8List serializedComponent = serializeComponent(component);
for (int k = 0; k < 3; k++) {
- Map<String, String> environmentDefines = null;
+ Map<String, String>? environmentDefines = null;
String environmentDefinesDescription = "null environment";
for (int j = 0; j < 2; j++) {
@@ -67,7 +65,7 @@
int iterations = 0;
int sum = 0;
for (int i = 0; i < 5; i++) {
- if (!tryWithNoEnvironment && environmentDefines == null) continue;
+ if (!tryWithNoEnvironment! && environmentDefines == null) continue;
if (skipNullEnvironment && environmentDefines == null) continue;
if (skipNonNullEnvironment && environmentDefines != null) continue;
stopwatch.reset();
@@ -125,20 +123,20 @@
class SilentErrorReporter implements constants.ErrorReporter {
@override
- void report(LocatedMessage message, [List<LocatedMessage> context]) {
+ void report(LocatedMessage message, [List<LocatedMessage>? context]) {
// ignore
}
}
-IncrementalCompiler incrementalCompiler;
+late IncrementalCompiler incrementalCompiler;
main(List<String> arguments) async {
- Uri platformUri;
+ Uri? platformUri;
Uri mainUri;
bool nnbd = false;
String targetString = "VM";
- String filename;
+ String? filename;
for (String arg in arguments) {
if (arg.startsWith("--")) {
if (arg == "--nnbd") {
@@ -242,8 +240,8 @@
CoreTypes coreTypes,
List<Library> libraries,
DiagnosticReporter diagnosticReporter,
- {void logger(String msg),
- ChangedStructureNotifier changedStructureNotifier}) {
+ {void Function(String msg)? logger,
+ ChangedStructureNotifier? changedStructureNotifier}) {
super.performPreConstantEvaluationTransformations(
component, coreTypes, libraries, diagnosticReporter,
logger: logger, changedStructureNotifier: changedStructureNotifier);
@@ -259,8 +257,8 @@
CoreTypes coreTypes,
List<Library> libraries,
DiagnosticReporter diagnosticReporter,
- {void logger(String msg),
- ChangedStructureNotifier changedStructureNotifier}) {
+ {void Function(String msg)? logger,
+ ChangedStructureNotifier? changedStructureNotifier}) {
super.performPreConstantEvaluationTransformations(
component, coreTypes, libraries, diagnosticReporter,
logger: logger, changedStructureNotifier: changedStructureNotifier);
@@ -276,8 +274,8 @@
CoreTypes coreTypes,
List<Library> libraries,
DiagnosticReporter diagnosticReporter,
- {void logger(String msg),
- ChangedStructureNotifier changedStructureNotifier}) {
+ {void Function(String msg)? logger,
+ ChangedStructureNotifier? changedStructureNotifier}) {
super.performPreConstantEvaluationTransformations(
component, coreTypes, libraries, diagnosticReporter,
logger: logger, changedStructureNotifier: changedStructureNotifier);
@@ -293,8 +291,8 @@
CoreTypes coreTypes,
List<Library> libraries,
DiagnosticReporter diagnosticReporter,
- {void logger(String msg),
- ChangedStructureNotifier changedStructureNotifier}) {
+ {void Function(String msg)? logger,
+ ChangedStructureNotifier? changedStructureNotifier}) {
super.performPreConstantEvaluationTransformations(
component, coreTypes, libraries, diagnosticReporter,
logger: logger, changedStructureNotifier: changedStructureNotifier);
diff --git a/pkg/front_end/test/crashing_test_case_minimizer_impl.dart b/pkg/front_end/test/crashing_test_case_minimizer_impl.dart
index 9c94019..72dd9f2 100644
--- a/pkg/front_end/test/crashing_test_case_minimizer_impl.dart
+++ b/pkg/front_end/test/crashing_test_case_minimizer_impl.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 'dart:async' show Future, StreamSubscription;
import 'dart:convert' show JsonEncoder, jsonDecode, utf8;
@@ -81,8 +79,8 @@
}
bool _useInitialFs = true;
- Uri mainUri;
- Uri platformUri;
+ Uri? mainUri;
+ Uri? platformUri;
bool noPlatform = false;
bool experimentalInvalidation = false;
bool serialize = false;
@@ -96,7 +94,7 @@
bool askAboutRedirectCrashTarget = false;
bool autoUncoverAllCrashes = false;
int stackTraceMatches = 1;
- String lookForErrorErrorOnReload;
+ String? lookForErrorErrorOnReload;
final Set<String> askedAboutRedirect = {};
final List<Map<String, dynamic>> fileSystems = [];
final Set<String> allAutoRedirects = {};
@@ -174,17 +172,17 @@
class TestMinimizer {
final TestMinimizerSettings _settings;
_FakeFileSystem get _fs => _settings._fs;
- Uri get _mainUri => _settings.mainUri;
- String _expectedCrashLine;
+ Uri get _mainUri => _settings.mainUri!;
+ String? _expectedCrashLine;
bool _quit = false;
bool _skip = false;
bool _check = false;
int _currentFsNum = -1;
bool _gotWantedError = false;
- Component _latestComponent;
- IncrementalCompiler _latestCrashingIncrementalCompiler;
- StreamSubscription<List<int>> _stdinSubscription;
+ Component? _latestComponent;
+ IncrementalCompiler? _latestCrashingIncrementalCompiler;
+ StreamSubscription<List<int>>? _stdinSubscription;
static const int _$LF = 10;
@@ -217,8 +215,8 @@
int totalFiles = 0;
int emptyFiles = 0;
int combinedSize = 0;
- for (Uri uri in _fs.data.keys) {
- final Uint8List originalBytes = _fs.data[uri];
+ for (Uri? uri in _fs.data.keys) {
+ final Uint8List? originalBytes = _fs.data[uri];
if (originalBytes == null) continue;
totalFiles++;
if (originalBytes.isEmpty) emptyFiles++;
@@ -265,13 +263,13 @@
_currentFsNum++;
}
- await _stdinSubscription.cancel();
+ await _stdinSubscription!.cancel();
}
Future _tryToMinimizeImpl() async {
// Set main to be basically empty up front.
_settings._useInitialFs = true;
- _fs.data[_mainUri] = utf8.encode("main() {}");
+ _fs.data[_mainUri] = utf8.encode("main() {}") as Uint8List;
Component initialComponent = await _getInitialComponent();
print("Compiled initially (without data)");
// Remove fake cache.
@@ -290,21 +288,21 @@
// For all dart files: Parse them as set their source as the parsed source
// to "get around" any encoding issues when printing later.
Map<Uri, Uint8List> copy = new Map.from(_fs.data);
- for (Uri uri in _fs.data.keys) {
+ for (Uri? uri in _fs.data.keys) {
if (await _shouldQuit()) break;
String uriString = uri.toString();
if (uriString.endsWith(".json") ||
uriString.endsWith(".packages") ||
uriString.endsWith(".dill") ||
_fs.data[uri] == null ||
- _fs.data[uri].isEmpty) {
+ _fs.data[uri]!.isEmpty) {
// skip
} else {
try {
- if (_knownByCompiler(uri)) {
+ if (_knownByCompiler(uri!)) {
String parsedString =
- _getFileAsStringContent(_fs.data[uri], _isUriNnbd(uri));
- _fs.data[uri] = utf8.encode(parsedString);
+ _getFileAsStringContent(_fs.data[uri]!, _isUriNnbd(uri));
+ _fs.data[uri] = utf8.encode(parsedString) as Uint8List;
}
} catch (e) {
// crash in scanner/parser --- keep original file. This crash might
@@ -331,10 +329,10 @@
for (int i = 0; i < uris.length; i++) {
if (await _shouldQuit()) break;
Uri uri = uris[i];
- if (_fs.data[uri] == null || _fs.data[uri].isEmpty) continue;
+ if (_fs.data[uri] == null || _fs.data[uri]!.isEmpty) continue;
print("About to work on file $i of ${uris.length}");
await _deleteContent(uris, i, false, initialComponent);
- if (_fs.data[uri] == null || _fs.data[uri].isEmpty) {
+ if (_fs.data[uri] == null || _fs.data[uri]!.isEmpty) {
changedSome = true;
}
}
@@ -349,7 +347,7 @@
for (int i = 0; i < uris.length; i++) {
if (await _shouldQuit()) break;
Uri uri = uris[i];
- if (_fs.data[uri] == null || _fs.data[uri].isNotEmpty) continue;
+ if (_fs.data[uri] == null || _fs.data[uri]!.isNotEmpty) continue;
print("About to work on file $i of ${uris.length}");
await _deleteContent(uris, i, false, initialComponent,
deleteFile: true);
@@ -363,18 +361,18 @@
int left = 0;
for (Uri uri in uris) {
- if (_fs.data[uri] == null || _fs.data[uri].isEmpty) continue;
+ if (_fs.data[uri] == null || _fs.data[uri]!.isEmpty) continue;
left++;
}
print("There's now $left files of ${_fs.data.length} files left");
// Operate on one file at a time.
- for (Uri uri in _fs.data.keys) {
- if (_fs.data[uri] == null || _fs.data[uri].isEmpty) continue;
+ for (Uri? uri in _fs.data.keys) {
+ if (_fs.data[uri] == null || _fs.data[uri]!.isEmpty) continue;
if (await _shouldQuit()) break;
if (await _tryRemoveIfNotKnownByCompiler(uri, initialComponent)) {
- if (_fs.data[uri] == null || _fs.data[uri].isEmpty) continue;
+ if (_fs.data[uri] == null || _fs.data[uri]!.isEmpty) continue;
if (await _shouldQuit()) break;
}
@@ -389,9 +387,9 @@
print("Now working on $uri");
- int prevLength = _fs.data[uri].length;
+ int prevLength = _fs.data[uri]!.length;
- await _deleteBlocks(uri, initialComponent);
+ await _deleteBlocks(uri!, initialComponent);
await _deleteEmptyLines(uri, initialComponent);
if (_settings.oldBlockDelete) {
@@ -404,44 +402,44 @@
await _deleteLines(uri, initialComponent);
}
- print("We're now at ${_fs.data[uri].length} bytes for $uri "
+ print("We're now at ${_fs.data[uri]!.length} bytes for $uri "
"(was $prevLength).");
- if (prevLength != _fs.data[uri].length) changedSome = true;
- if (_fs.data[uri].isEmpty) continue;
+ if (prevLength != _fs.data[uri]!.length) changedSome = true;
+ if (_fs.data[uri]!.isEmpty) continue;
if (_settings.byteDelete) {
// Now try to delete 'arbitrarily' (for any given start offset do an
// exponential binary search).
- int prevLength = _fs.data[uri].length;
+ int prevLength = _fs.data[uri]!.length;
while (true) {
if (await _shouldQuit()) break;
await _binarySearchDeleteData(uri, initialComponent);
- if (_fs.data[uri].length == prevLength) {
+ if (_fs.data[uri]!.length == prevLength) {
// No progress.
break;
} else {
- print("We're now at ${_fs.data[uri].length} bytes");
- prevLength = _fs.data[uri].length;
+ print("We're now at ${_fs.data[uri]!.length} bytes");
+ prevLength = _fs.data[uri]!.length;
changedSome = true;
}
}
}
}
- for (Uri uri in _fs.data.keys) {
- if (_fs.data[uri] == null || _fs.data[uri].isEmpty) continue;
+ for (Uri? uri in _fs.data.keys) {
+ if (_fs.data[uri] == null || _fs.data[uri]!.isEmpty) continue;
if (await _shouldQuit()) break;
if (await _tryRemoveIfNotKnownByCompiler(uri, initialComponent)) {
- if (_fs.data[uri] == null || _fs.data[uri].isEmpty) continue;
+ if (_fs.data[uri] == null || _fs.data[uri]!.isEmpty) continue;
if (await _shouldQuit()) break;
}
- if (await _attemptInline(uri, initialComponent)) {
+ if (await _attemptInline(uri!, initialComponent)) {
changedSome = true;
if (await _tryRemoveIfNotKnownByCompiler(uri, initialComponent)) {
- if (_fs.data[uri] == null || _fs.data[uri].isEmpty) continue;
+ if (_fs.data[uri] == null || _fs.data[uri]!.isEmpty) continue;
if (await _shouldQuit()) break;
}
}
@@ -471,11 +469,11 @@
print("\n\n\n");
for (Uri uri in uris) {
- if (_fs.data[uri] == null || _fs.data[uri].isEmpty) continue;
+ if (_fs.data[uri] == null || _fs.data[uri]!.isEmpty) continue;
print("Uri $uri has this content:");
try {
- String utfDecoded = utf8.decode(_fs.data[uri], allowMalformed: true);
+ String utfDecoded = utf8.decode(_fs.data[uri]!, allowMalformed: true);
print(utfDecoded);
} catch (e) {
print(_fs.data[uri]);
@@ -498,7 +496,7 @@
JsonEncoder jsonEncoder = new JsonEncoder.withIndent(" ");
String json = jsonEncoder.convert(_settings);
int i = 0;
- Uri jsonOut;
+ Uri? jsonOut;
while (jsonOut == null || new File.fromUri(jsonOut).existsSync()) {
jsonOut = Uri.base.resolve("crash_minimizer_result_$i");
i++;
@@ -515,7 +513,7 @@
// Don't attempt to inline the main uri --- that's our entry!
if (uri == _mainUri) return false;
- Uint8List inlineData = _fs.data[uri];
+ Uint8List inlineData = _fs.data[uri]!;
bool hasMultipleLines = false;
for (int i = 0; i < inlineData.length; i++) {
if (inlineData[i] == _$LF) {
@@ -533,16 +531,16 @@
int compileTry = 0;
bool changed = false;
- for (Uri uri in _fs.data.keys) {
+ for (Uri? uri in _fs.data.keys) {
if (!uri.toString().endsWith(".dart")) continue;
if (inlinableUri == uri) continue;
- final Uint8List originalBytes = _fs.data[uri];
+ final Uint8List? originalBytes = _fs.data[uri];
if (originalBytes == null || originalBytes.isEmpty) continue;
DirectParserASTContentCompilationUnitEnd ast = getAST(originalBytes,
includeBody: false,
includeComments: false,
enableExtensionMethods: true,
- enableNonNullable: _isUriNnbd(uri));
+ enableNonNullable: _isUriNnbd(uri!));
// Find all imports/exports of this file (if any).
// If finding any:
// * remove all of them, then
@@ -552,15 +550,15 @@
// try converting that to an import instead.
List<_Replacement> replacements = [];
for (DirectParserASTContentImportEnd import in ast.getImports()) {
- Token importUriToken = import.importKeyword.next;
+ Token importUriToken = import.importKeyword.next!;
Uri importUri = _getUri(importUriToken, uri);
if (inlinableUri == importUri) {
replacements.add(new _Replacement(
- import.importKeyword.offset - 1, import.semicolon.offset + 1));
+ import.importKeyword.offset - 1, import.semicolon!.offset + 1));
}
}
for (DirectParserASTContentExportEnd export in ast.getExports()) {
- Token exportUriToken = export.exportKeyword.next;
+ Token exportUriToken = export.exportKeyword.next!;
Uri exportUri = _getUri(exportUriToken, uri);
if (inlinableUri == exportUri) {
replacements.add(new _Replacement(
@@ -585,7 +583,7 @@
enableExtensionMethods: true,
enableNonNullable: _isUriNnbd(uri));
for (DirectParserASTContentImportEnd import in ast.getImports()) {
- offsetOfLast = max(offsetOfLast, import.semicolon.offset + 1);
+ offsetOfLast = max(offsetOfLast, import.semicolon!.offset + 1);
}
for (DirectParserASTContentExportEnd export in ast.getExports()) {
offsetOfLast = max(offsetOfLast, export.semicolon.offset + 1);
@@ -606,7 +604,8 @@
for (int i = offsetOfLast; i < withoutInlineableString.length; i++) {
builder.writeCharCode(withoutInlineableString.codeUnitAt(i));
}
- final Uint8List inlinedWithoutChange = utf8.encode(builder.toString());
+ final Uint8List inlinedWithoutChange =
+ utf8.encode(builder.toString()) as Uint8List;
if (!_parsesWithoutError(inlinedWithoutChange, _isUriNnbd(uri))) {
print("WARNING: Parser error after stuff at ${StackTrace.current}");
@@ -646,7 +645,8 @@
for (int i = offsetOfLast; i < withoutInlineableString.length; i++) {
builder.writeCharCode(withoutInlineableString.codeUnitAt(i));
}
- Uint8List inlinedWithChange = utf8.encode(builder.toString());
+ Uint8List inlinedWithChange =
+ utf8.encode(builder.toString()) as Uint8List;
if (!_parsesWithoutError(inlinedWithChange, _isUriNnbd(uri))) {
print("WARNING: Parser error after stuff at ${StackTrace.current}");
@@ -691,7 +691,7 @@
List<_Replacement> replacements = [];
for (DirectParserASTContentImportEnd import in ast.getImports()) {
_rewriteImportsExportsToUriInternal(
- import.importKeyword.next, oldUri, replacements, newUri);
+ import.importKeyword.next!, oldUri, replacements, newUri);
}
for (DirectParserASTContentExportEnd export in ast.getExports()) {
if (convertExportToImport) {
@@ -702,7 +702,7 @@
));
}
_rewriteImportsExportsToUriInternal(
- export.exportKeyword.next, oldUri, replacements, newUri);
+ export.exportKeyword.next!, oldUri, replacements, newUri);
}
if (replacements.isNotEmpty) {
Uint8List candidate = _replaceRange(replacements, oldData);
@@ -713,8 +713,8 @@
void _outputIncrementalCompilerYamlTest() {
int dartFiles = 0;
- for (MapEntry<Uri, Uint8List> entry in _fs.data.entries) {
- if (entry.key.pathSegments.last.endsWith(".dart")) {
+ for (MapEntry<Uri?, Uint8List?> entry in _fs.data.entries) {
+ if (entry.key!.pathSegments.last.endsWith(".dart")) {
if (entry.value != null) dartFiles++;
}
}
@@ -741,10 +741,10 @@
print(" experiments: alternative-invalidation-strategy");
}
print(" sources:");
- for (MapEntry<Uri, Uint8List> entry in _fs.data.entries) {
+ for (MapEntry<Uri?, Uint8List?> entry in _fs.data.entries) {
if (entry.value == null) continue;
print(" ${entry.key}: |");
- String string = utf8.decode(entry.value);
+ String string = utf8.decode(entry.value!);
List<String> lines = string.split("\n");
for (String line in lines) {
print(" $line");
@@ -801,8 +801,8 @@
uriString = uriString.substring(1, uriString.length - 1);
Uri uriTokenUri = uri.resolve(uriString);
if (resolvePackage && uriTokenUri.scheme == "package") {
- Package package = _latestCrashingIncrementalCompiler
- .currentPackagesMap[uriTokenUri.pathSegments.first];
+ Package package = _latestCrashingIncrementalCompiler!
+ .currentPackagesMap![uriTokenUri.pathSegments.first]!;
uriTokenUri = package.packageUriRoot
.resolve(uriTokenUri.pathSegments.skip(1).join("/"));
}
@@ -810,7 +810,7 @@
}
Uri _getImportUri(Uri uri) {
- return _latestCrashingIncrementalCompiler.userCode
+ return _latestCrashingIncrementalCompiler!.userCode!
.getEntryPointUri(uri, issueProblem: false);
}
@@ -820,8 +820,9 @@
return result;
}
- void _binarySearchDeleteData(Uri uri, Component initialComponent) async {
- Uint8List latestCrashData = _fs.data[uri];
+ Future<void> _binarySearchDeleteData(
+ Uri uri, Component initialComponent) async {
+ Uint8List latestCrashData = _fs.data[uri]!;
int offset = 0;
while (offset < latestCrashData.length) {
print("Working at offset $offset of ${latestCrashData.length}");
@@ -840,7 +841,7 @@
// Find how long we can go.
int crashingAt = 1;
- int noLongerCrashingAt;
+ int? noLongerCrashingAt;
while (true) {
int deleteChars = 2 * crashingAt;
if (offset + deleteChars > latestCrashData.length) {
@@ -867,7 +868,7 @@
}
// Binary search between [crashingAt] and [noLongerCrashingAt].
- while (crashingAt < noLongerCrashingAt) {
+ while (crashingAt < noLongerCrashingAt!) {
int mid = noLongerCrashingAt -
((noLongerCrashingAt - crashingAt) >>
1); // Get middle, rounding up.
@@ -901,20 +902,20 @@
_fs.data[uri] = latestCrashData;
}
- void _tryToRemoveUnreferencedFileContent(Component initialComponent,
+ Future<void> _tryToRemoveUnreferencedFileContent(Component initialComponent,
{bool deleteFile: false}) async {
// Check if there now are any unused files.
if (_latestComponent == null) return;
- Set<Uri> neededUris = _latestComponent.uriToSource.keys.toSet();
+ Set<Uri> neededUris = _latestComponent!.uriToSource.keys.toSet();
Map<Uri, Uint8List> copy = new Map.from(_fs.data);
bool removedSome = false;
if (await _shouldQuit()) return;
- for (MapEntry<Uri, Uint8List> entry in _fs.data.entries) {
+ for (MapEntry<Uri?, Uint8List?> entry in _fs.data.entries) {
if (entry.value == null) continue;
- if (!deleteFile && entry.value.isEmpty) continue;
+ if (!deleteFile && entry.value!.isEmpty) continue;
if (!entry.key.toString().endsWith(".dart")) continue;
if (!neededUris.contains(entry.key) &&
- (deleteFile || _fs.data[entry.key].length != 0)) {
+ (deleteFile || _fs.data[entry.key]!.length != 0)) {
if (deleteFile) {
_fs.data[entry.key] = null;
} else {
@@ -935,7 +936,7 @@
}
}
- void _deleteContent(
+ Future<void> _deleteContent(
List<Uri> uris, int uriIndex, bool limitTo1, Component initialComponent,
{bool deleteFile: false}) async {
String extraMessageText = "all content of ";
@@ -970,7 +971,7 @@
if (await _shouldQuit()) return;
Uri uri = uris[uriIndex];
- Uint8List data = _fs.data[uri];
+ Uint8List? data = _fs.data[uri];
if (deleteFile) {
_fs.data[uri] = null;
} else {
@@ -984,16 +985,16 @@
// For dart files we can't truncate completely try to "outline" them
// instead.
if (uri.toString().endsWith(".dart")) {
- String textualOutlined =
- textualOutline(data, _getScannerConfiguration(uri))
+ String? textualOutlined =
+ textualOutline(data!, _getScannerConfiguration(uri))
?.replaceAll(RegExp(r'\n+'), "\n");
bool outlined = false;
if (textualOutlined != null) {
- Uint8List candidate = utf8.encode(textualOutlined);
+ Uint8List candidate = utf8.encode(textualOutlined) as Uint8List;
// Because textual outline doesn't do the right thing for nnbd, only
// replace if it's syntactically valid.
- if (candidate.length != _fs.data[uri].length &&
+ if (candidate.length != _fs.data[uri]!.length &&
_parsesWithoutError(candidate, _isUriNnbd(uri))) {
if (await _shouldQuit()) return;
_fs.data[uri] = candidate;
@@ -1003,21 +1004,22 @@
} else {
outlined = true;
print("Can outline the file $uri "
- "(now ${_fs.data[uri].length} bytes)");
+ "(now ${_fs.data[uri]!.length} bytes)");
}
}
}
if (!outlined) {
// We can probably at least remove all comments then...
try {
- List<String> strings = utf8.decode(_fs.data[uri]).split("\n");
+ List<String> strings = utf8.decode(_fs.data[uri]!).split("\n");
List<String> stringsLeft = [];
for (String string in strings) {
if (!string.trim().startsWith("//")) stringsLeft.add(string);
}
- Uint8List candidate = utf8.encode(stringsLeft.join("\n"));
- if (candidate.length != _fs.data[uri].length) {
+ Uint8List candidate =
+ utf8.encode(stringsLeft.join("\n")) as Uint8List;
+ if (candidate.length != _fs.data[uri]!.length) {
if (await _shouldQuit()) return;
_fs.data[uri] = candidate;
if (!await _crashesOnCompile(initialComponent)) {
@@ -1040,7 +1042,7 @@
}
}
- void _deleteBlocksOld(Uri uri, Component initialComponent) async {
+ Future<void> _deleteBlocksOld(Uri uri, Component initialComponent) async {
if (uri.toString().endsWith(".json")) {
// Try to find annoying
//
@@ -1049,7 +1051,7 @@
// }
//
// part of json and remove it.
- Uint8List data = _fs.data[uri];
+ Uint8List data = _fs.data[uri]!;
String string = utf8.decode(data);
List<String> lines = string.split("\n");
for (int i = 0; i < lines.length - 2; i++) {
@@ -1062,7 +1064,7 @@
}
}
string = lines.join("\n");
- _fs.data[uri] = utf8.encode(string);
+ _fs.data[uri] = utf8.encode(string) as Uint8List;
if (!await _crashesOnCompile(initialComponent)) {
// For some reason that didn't work.
_fs.data[uri] = data;
@@ -1070,7 +1072,7 @@
}
if (!uri.toString().endsWith(".dart")) return;
- Uint8List data = _fs.data[uri];
+ Uint8List data = _fs.data[uri]!;
Uint8List latestCrashData = data;
List<int> lineStarts = [];
@@ -1080,13 +1082,14 @@
_isUriNnbd(uri) ? _scannerConfiguration : _scannerConfigurationNonNNBD,
lineStarts);
+ // ignore: unnecessary_null_comparison
if (firstToken == null) {
print("Got null token from scanner for $uri");
return;
}
int compileTry = 0;
- Token token = firstToken;
+ Token? token = firstToken;
while (token is ErrorToken) {
token = token.next;
}
@@ -1095,56 +1098,58 @@
bool tryCompile = false;
Token skipToToken = token;
// Skip very small blocks (e.g. "{}" or "{\n}");
- if (token.endGroup != null && token.offset + 3 < token.endGroup.offset) {
- replacements.add(new _Replacement(token.offset, token.endGroup.offset));
+ if (token.endGroup != null && token.offset + 3 < token.endGroup!.offset) {
+ replacements
+ .add(new _Replacement(token.offset, token.endGroup!.offset));
tryCompile = true;
- skipToToken = token.endGroup;
+ skipToToken = token.endGroup!;
} else if (token.lexeme == "@") {
- if (token.next.next.endGroup != null) {
- int end = token.next.next.endGroup.offset;
- skipToToken = token.next.next.endGroup;
+ if (token.next!.next!.endGroup != null) {
+ int end = token.next!.next!.endGroup!.offset;
+ skipToToken = token.next!.next!.endGroup!;
replacements.add(new _Replacement(token.offset - 1, end + 1));
tryCompile = true;
}
} else if (token.lexeme == "assert") {
- if (token.next.endGroup != null) {
- int end = token.next.endGroup.offset;
- skipToToken = token.next.endGroup;
- if (token.next.endGroup.next.lexeme == ",") {
- end = token.next.endGroup.next.offset;
- skipToToken = token.next.endGroup.next;
+ if (token.next!.endGroup != null) {
+ int end = token.next!.endGroup!.offset;
+ skipToToken = token.next!.endGroup!;
+ if (token.next!.endGroup!.next!.lexeme == ",") {
+ end = token.next!.endGroup!.next!.offset;
+ skipToToken = token.next!.endGroup!.next!;
}
// +/- 1 to not include the start and the end character.
replacements.add(new _Replacement(token.offset - 1, end + 1));
tryCompile = true;
}
- } else if ((token.lexeme == "abstract" && token.next.lexeme == "class") ||
+ } else if ((token.lexeme == "abstract" &&
+ token.next!.lexeme == "class") ||
token.lexeme == "class" ||
token.lexeme == "enum" ||
token.lexeme == "mixin" ||
token.lexeme == "static" ||
- token.next.lexeme == "get" ||
- token.next.lexeme == "set" ||
- token.next.next.lexeme == "(" ||
- (token.next.lexeme == "<" &&
- token.next.endGroup != null &&
- token.next.endGroup.next.next.lexeme == "(")) {
+ token.next!.lexeme == "get" ||
+ token.next!.lexeme == "set" ||
+ token.next!.next!.lexeme == "(" ||
+ (token.next!.lexeme == "<" &&
+ token.next!.endGroup != null &&
+ token.next!.endGroup!.next!.next!.lexeme == "(")) {
// Try to find and remove the entire class/enum/mixin/
// static procedure/getter/setter/simple procedure.
Token bracket = token;
for (int i = 0; i < 20; i++) {
// Find "{", but only go a maximum of 20 tokens to do that.
- bracket = bracket.next;
+ bracket = bracket.next!;
if (bracket.lexeme == "{" && bracket.endGroup != null) {
break;
} else if ((bracket.lexeme == "(" || bracket.lexeme == "<") &&
bracket.endGroup != null) {
- bracket = bracket.endGroup;
+ bracket = bracket.endGroup!;
}
}
if (bracket.lexeme == "{" && bracket.endGroup != null) {
- int end = bracket.endGroup.offset;
- skipToToken = bracket.endGroup;
+ int end = bracket.endGroup!.offset;
+ skipToToken = bracket.endGroup!;
// +/- 1 to not include the start and the end character.
replacements.add(new _Replacement(token.offset - 1, end + 1));
tryCompile = true;
@@ -1181,7 +1186,7 @@
_fs.data[uri] = latestCrashData;
}
- void _deleteBlocks(final Uri uri, Component initialComponent) async {
+ Future<void> _deleteBlocks(final Uri uri, Component initialComponent) async {
if (uri.toString().endsWith(".json")) {
// Try to find annoying
//
@@ -1190,7 +1195,7 @@
// }
//
// part of json and remove it.
- Uint8List data = _fs.data[uri];
+ Uint8List data = _fs.data[uri]!;
String string = utf8.decode(data);
List<String> lines = string.split("\n");
for (int i = 0; i < lines.length - 2; i++) {
@@ -1203,7 +1208,7 @@
}
}
string = lines.join("\n");
- Uint8List candidate = utf8.encode(string);
+ Uint8List candidate = utf8.encode(string) as Uint8List;
if (candidate.length != data.length) {
_fs.data[uri] = candidate;
if (!await _crashesOnCompile(initialComponent)) {
@@ -1225,8 +1230,8 @@
while (i < packagesModified.length) {
var oldEntry = packagesModified.removeAt(i);
String jsonString = jsonEncoder.convert(jsonModified);
- candidate = utf8.encode(jsonString);
- Uint8List previous = _fs.data[uri];
+ candidate = utf8.encode(jsonString) as Uint8List;
+ Uint8List? previous = _fs.data[uri];
_fs.data[uri] = candidate;
if (!await _crashesOnCompile(initialComponent)) {
// Couldn't remove that part.
@@ -1245,7 +1250,7 @@
}
if (!uri.toString().endsWith(".dart")) return;
- Uint8List data = _fs.data[uri];
+ Uint8List data = _fs.data[uri]!;
DirectParserASTContentCompilationUnitEnd ast = getAST(data,
includeBody: true,
includeComments: false,
@@ -1255,7 +1260,7 @@
_CompilationHelperClass helper = new _CompilationHelperClass(data);
// Try to remove top level things one at a time.
- for (DirectParserASTContent child in ast.children) {
+ for (DirectParserASTContent child in ast.children!) {
bool shouldCompile = false;
String what = "";
if (child.isClass()) {
@@ -1300,7 +1305,7 @@
} else if (child.isEnum()) {
DirectParserASTContentEnumEnd decl = child.asEnum();
helper.replacements.add(new _Replacement(
- decl.enumKeyword.offset - 1, decl.leftBrace.endGroup.offset + 1));
+ decl.enumKeyword.offset - 1, decl.leftBrace.endGroup!.offset + 1));
shouldCompile = true;
what = "enum";
} else if (child.isTypedef()) {
@@ -1323,7 +1328,7 @@
} else if (child.isImport()) {
DirectParserASTContentImportEnd decl = child.asImport();
helper.replacements.add(new _Replacement(
- decl.importKeyword.offset - 1, decl.semicolon.offset + 1));
+ decl.importKeyword.offset - 1, decl.semicolon!.offset + 1));
shouldCompile = true;
what = "import";
} else if (child.isExport()) {
@@ -1379,7 +1384,7 @@
if (!success) {
// Also try to remove members one at a time.
- for (DirectParserASTContent child in body.children) {
+ for (DirectParserASTContent child in body.children!) {
shouldCompile = false;
if (child is DirectParserASTContentMemberEnd) {
if (child.isClassConstructor()) {
@@ -1436,7 +1441,7 @@
helper, uri, initialComponent, what);
if (helper.shouldQuit) return;
if (!success) {
- DirectParserASTContentBlockFunctionBodyEnd decl;
+ DirectParserASTContentBlockFunctionBodyEnd? decl;
if (child is DirectParserASTContentMemberEnd) {
if (child.isClassMethod()) {
decl = child.getClassMethod().getBlockFunctionBody();
@@ -1466,7 +1471,7 @@
// we could try to remove "B, " or ", C" etc.
if (decl.getClassExtends().extendsKeyword != null) {
helper.replacements.add(new _Replacement(
- decl.getClassExtends().extendsKeyword.offset - 1,
+ decl.getClassExtends().extendsKeyword!.offset - 1,
body.beginToken.offset));
what = "class extends";
success = await _tryReplaceAndCompile(
@@ -1475,7 +1480,7 @@
}
if (decl.getClassImplements().implementsKeyword != null) {
helper.replacements.add(new _Replacement(
- decl.getClassImplements().implementsKeyword.offset - 1,
+ decl.getClassImplements().implementsKeyword!.offset - 1,
body.beginToken.offset));
what = "class implements";
success = await _tryReplaceAndCompile(
@@ -1484,7 +1489,7 @@
}
if (decl.getClassWithClause() != null) {
helper.replacements.add(new _Replacement(
- decl.getClassWithClause().withKeyword.offset - 1,
+ decl.getClassWithClause()!.withKeyword.offset - 1,
body.beginToken.offset));
what = "class with clause";
success = await _tryReplaceAndCompile(
@@ -1508,7 +1513,7 @@
if (!success) {
// Also try to remove members one at a time.
- for (DirectParserASTContent child in body.children) {
+ for (DirectParserASTContent child in body.children!) {
shouldCompile = false;
if (child is DirectParserASTContentMemberEnd) {
if (child.isMixinConstructor()) {
@@ -1565,7 +1570,7 @@
helper, uri, initialComponent, what);
if (helper.shouldQuit) return;
if (!success) {
- DirectParserASTContentBlockFunctionBodyEnd decl;
+ DirectParserASTContentBlockFunctionBodyEnd? decl;
if (child is DirectParserASTContentMemberEnd) {
if (child.isClassMethod()) {
decl = child.getClassMethod().getBlockFunctionBody();
@@ -1628,8 +1633,8 @@
}
}
- void _deleteEmptyLines(Uri uri, Component initialComponent) async {
- Uint8List data = _fs.data[uri];
+ Future<void> _deleteEmptyLines(Uri uri, Component initialComponent) async {
+ Uint8List data = _fs.data[uri]!;
List<Uint8List> lines = [];
int start = 0;
for (int i = 0; i < data.length; i++) {
@@ -1669,9 +1674,9 @@
}
}
- void _deleteLines(Uri uri, Component initialComponent) async {
+ Future<void> _deleteLines(Uri uri, Component initialComponent) async {
// Try to delete "lines".
- Uint8List data = _fs.data[uri];
+ Uint8List data = _fs.data[uri]!;
List<Uint8List> lines = [];
int start = 0;
for (int i = 0; i < data.length; i++) {
@@ -1743,15 +1748,16 @@
_fs.data[uri] = latestCrashData;
}
- Future<bool> _tryRemoveIfNotKnownByCompiler(Uri uri, initialComponent) async {
- if (_fs.data[uri] == null || _fs.data[uri].isEmpty) return false;
+ Future<bool> _tryRemoveIfNotKnownByCompiler(
+ Uri? uri, initialComponent) async {
+ if (_fs.data[uri] == null || _fs.data[uri]!.isEmpty) return false;
if (!uri.toString().endsWith(".dart")) return false;
- if (_knownByCompiler(uri)) return false;
+ if (_knownByCompiler(uri!)) return false;
// Compiler might not know this. Can we delete it?
await _deleteContent([uri], 0, true, initialComponent);
- if (_fs.data[uri] == null || _fs.data[uri].isEmpty) {
+ if (_fs.data[uri] == null || _fs.data[uri]!.isEmpty) {
await _deleteContent([uri], 0, true, initialComponent, deleteFile: true);
return true;
}
@@ -1760,8 +1766,8 @@
}
bool _knownByCompiler(Uri uri) {
- LibraryBuilder libraryBuilder = _latestCrashingIncrementalCompiler
- .userCode.loader.builders[_getImportUri(uri)];
+ LibraryBuilder? libraryBuilder = _latestCrashingIncrementalCompiler!
+ .userCode!.loader.builders[_getImportUri(uri)];
if (libraryBuilder != null) {
return true;
}
@@ -1778,14 +1784,14 @@
bool _isUriNnbd(Uri uri, {bool crashOnFail: true}) {
Uri asImportUri = _getImportUri(uri);
- LibraryBuilder libraryBuilder = _latestCrashingIncrementalCompiler
- .userCode.loader.builders[asImportUri];
+ LibraryBuilder? libraryBuilder = _latestCrashingIncrementalCompiler!
+ .userCode!.loader.builders[asImportUri];
if (libraryBuilder != null) {
return libraryBuilder.isNonNullableByDefault;
}
print("Couldn't lookup $uri");
- for (LibraryBuilder libraryBuilder
- in _latestCrashingIncrementalCompiler.userCode.loader.builders.values) {
+ for (LibraryBuilder libraryBuilder in _latestCrashingIncrementalCompiler!
+ .userCode!.loader.builders.values) {
if (libraryBuilder.importUri == uri) {
print("Found $uri as ${libraryBuilder.importUri} (!= ${asImportUri})");
return libraryBuilder.isNonNullableByDefault;
@@ -1824,7 +1830,7 @@
// serialization.
ByteSink sink = new ByteSink();
BinaryPrinter printer = new BinaryPrinter(sink);
- printer.writeComponentFile(_latestComponent);
+ printer.writeComponentFile(_latestComponent!);
}
if (_gotWantedError) didNotGetWantedErrorAfterFirstCompile = false;
@@ -1867,6 +1873,7 @@
}
}
}
+ // ignore: unnecessary_null_comparison
if (foundLine == null) throw "Unexpected crash without stacktrace: $e";
if (_expectedCrashLine == null) {
print("Got '$foundLine'");
@@ -1883,7 +1890,7 @@
print(" ==> Adding to auto redirects!");
// Add the current one too, so we don't rediscover that one once we
// try minimizing the new ones.
- _settings.allAutoRedirects.add(_expectedCrashLine);
+ _settings.allAutoRedirects.add(_expectedCrashLine!);
_settings.allAutoRedirects.add(foundLine);
_settings.fileSystems.add(_fs.toJson());
} else if (_settings.askAboutRedirectCrashTarget &&
@@ -1892,11 +1899,11 @@
while (true) {
// Add the current one too, so we don't rediscover that again
// and asks about going back to it.
- _settings.askedAboutRedirect.add(_expectedCrashLine);
+ _settings.askedAboutRedirect.add(_expectedCrashLine!);
_settings.askedAboutRedirect.add(foundLine);
print(eWithSt);
print("Should we redirect to searching for that? (y/n)");
- String answer = stdin.readLineSync();
+ String answer = stdin.readLineSync()!;
if (answer == "yes" || answer == "y") {
_expectedCrashLine = foundLine;
_latestCrashingIncrementalCompiler = incrementalCompiler;
@@ -1925,7 +1932,6 @@
CompilerOptions options = getOptions();
if (_settings.experimentalInvalidation) {
- options.explicitExperimentalFlags ??= {};
options.explicitExperimentalFlags[
ExperimentalFlag.alternativeInvalidationStrategy] = true;
}
@@ -1948,7 +1954,7 @@
target = new Dart2jsTarget("dart2js", targetFlags);
break;
default:
- throw "Unknown target '$target'";
+ throw "Unknown target '${_settings.targetString}'";
}
options.target = target;
options.fileSystem = _fs;
@@ -1960,7 +1966,7 @@
// Except if we're looking to trigger a specific error on reload.
if (_settings.lookForErrorErrorOnReload != null &&
message.ansiFormatted.first
- .contains(_settings.lookForErrorErrorOnReload)) {
+ .contains(_settings.lookForErrorErrorOnReload!)) {
_gotWantedError = true;
}
};
@@ -1981,6 +1987,7 @@
nnbd ? _scannerConfiguration : _scannerConfigurationNonNNBD,
lineStarts);
+ // ignore: unnecessary_null_comparison
if (firstToken == null) {
throw "Got null token from scanner";
}
@@ -1998,6 +2005,7 @@
Token firstToken = parser_suite.scanRawBytes(rawBytes,
nnbd ? _scannerConfiguration : _scannerConfigurationNonNNBD, null);
+ // ignore: unnecessary_null_comparison
if (firstToken == null) {
return false;
}
@@ -2019,8 +2027,9 @@
enableExtensionMethods: true,
enableNonNullable: false);
- List<int> _dataCache;
- String _dataCacheString;
+ List<int>? _dataCache;
+ String? _dataCacheString;
+
Uint8List _replaceRange(
List<_Replacement> unsortedReplacements, Uint8List rawData) {
// The offsets are character offsets, not byte offsets, so for non-ascii
@@ -2040,18 +2049,18 @@
for (int i = 0; i < sortedReplacements.length; i++) {
_Replacement replacement = sortedReplacements[i];
for (int j = prev; j <= replacement.from; j++) {
- builder.writeCharCode(_dataCacheString.codeUnitAt(j));
+ builder.writeCharCode(_dataCacheString!.codeUnitAt(j));
}
if (replacement.nullOrReplacement != null) {
builder.write(replacement.nullOrReplacement);
}
prev = replacement.to;
}
- for (int j = prev; j < _dataCacheString.length; j++) {
- builder.writeCharCode(_dataCacheString.codeUnitAt(j));
+ for (int j = prev; j < _dataCacheString!.length; j++) {
+ builder.writeCharCode(_dataCacheString!.codeUnitAt(j));
}
- Uint8List candidate = utf8.encode(builder.toString());
+ Uint8List candidate = utf8.encode(builder.toString()) as Uint8List;
return candidate;
}
}
@@ -2079,7 +2088,7 @@
class _Replacement implements Comparable<_Replacement> {
final int from;
final int to;
- final String nullOrReplacement;
+ final String? nullOrReplacement;
_Replacement(this.from, this.to, {this.nullOrReplacement});
@@ -2092,7 +2101,7 @@
class _FakeFileSystem extends FileSystem {
bool _redirectAndRecord = true;
bool _initialized = false;
- final Map<Uri, Uint8List> data = {};
+ final Map<Uri?, Uint8List?> data = {};
@override
FileSystemEntity entityForUri(Uri uri) {
@@ -2105,11 +2114,11 @@
data.clear();
List tmp = json['data'];
for (int i = 0; i < tmp.length; i += 2) {
- Uri key = tmp[i] == null ? null : Uri.parse(tmp[i]);
+ Uri? key = tmp[i] == null ? null : Uri.parse(tmp[i]);
if (tmp[i + 1] == null) {
data[key] = null;
} else if (tmp[i + 1] is String) {
- data[key] = utf8.encode(tmp[i + 1]);
+ data[key] = utf8.encode(tmp[i + 1]) as Uint8List;
} else {
data[key] = Uint8List.fromList(new List<int>.from(tmp[i + 1]));
}
@@ -2122,9 +2131,9 @@
if (entry.value == null) continue;
tmp.add(entry.key == null ? null : entry.key.toString());
dynamic out = entry.value;
- if (entry.value != null && entry.value.isNotEmpty) {
+ if (entry.value != null && entry.value!.isNotEmpty) {
try {
- String string = utf8.decode(entry.value);
+ String string = utf8.decode(entry.value!);
out = string;
} catch (e) {
// not a string...
@@ -2161,7 +2170,7 @@
@override
Future<bool> exists() {
_ensureCachedIfOk();
- Uint8List data = fs.data[uri];
+ Uint8List? data = fs.data[uri];
if (data == null) return Future.value(false);
return Future.value(true);
}
@@ -2172,7 +2181,7 @@
@override
Future<List<int>> readAsBytes() {
_ensureCachedIfOk();
- Uint8List data = fs.data[uri];
+ Uint8List? data = fs.data[uri];
if (data == null) throw new FileSystemException(uri, "File doesn't exist.");
return Future.value(data);
}
@@ -2183,7 +2192,7 @@
@override
Future<String> readAsString() {
_ensureCachedIfOk();
- Uint8List data = fs.data[uri];
+ Uint8List? data = fs.data[uri];
if (data == null) throw new FileSystemException(uri, "File doesn't exist.");
return Future.value(utf8.decode(data));
}
diff --git a/pkg/front_end/test/fasta/parser/parser_suite.dart b/pkg/front_end/test/fasta/parser/parser_suite.dart
index 76bcbd0..772922f 100644
--- a/pkg/front_end/test/fasta/parser/parser_suite.dart
+++ b/pkg/front_end/test/fasta/parser/parser_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:_fe_analyzer_shared/src/parser/parser.dart'
show ParserError, parse;
import 'package:front_end/src/fasta/source/diet_parser.dart';
diff --git a/pkg/front_end/test/fasta/testing/suite.dart b/pkg/front_end/test/fasta/testing/suite.dart
index c07935b..f849bf2 100644
--- a/pkg/front_end/test/fasta/testing/suite.dart
+++ b/pkg/front_end/test/fasta/testing/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
-
library fasta.testing.suite;
import 'dart:convert' show jsonDecode, utf8;
@@ -18,7 +16,7 @@
import 'package:_fe_analyzer_shared/src/util/colors.dart' as colors;
import 'package:_fe_analyzer_shared/src/util/options.dart';
import 'package:compiler/src/kernel/dart2js_target.dart';
-import 'package:dev_compiler/dev_compiler.dart';
+import 'package:dev_compiler/src/kernel/target.dart';
import 'package:front_end/src/api_prototype/compiler_options.dart'
show
@@ -269,10 +267,10 @@
final bool forceNoExplicitGetterCalls;
final int forceConstructorTearOffLowering;
final bool nnbdAgnosticMode;
- final Map<String, String> defines;
+ final Map<String, String>? defines;
final bool noVerify;
final String target;
- final String overwriteCurrentSdkVersion;
+ final String? overwriteCurrentSdkVersion;
FolderOptions(this._explicitExperimentalFlags,
{this.forceLateLowerings: LateLowering.none,
@@ -286,16 +284,23 @@
this.target: "vm",
// can be null
this.overwriteCurrentSdkVersion})
+ // ignore: unnecessary_null_comparison
: assert(forceLateLowerings != null),
+ // ignore: unnecessary_null_comparison
assert(forceLateLoweringSentinel != null),
+ // ignore: unnecessary_null_comparison
assert(forceStaticFieldLowering != null),
+ // ignore: unnecessary_null_comparison
assert(forceNoExplicitGetterCalls != null),
+ // ignore: unnecessary_null_comparison
assert(nnbdAgnosticMode != null),
assert(
// no this doesn't make any sense but left to underline
// that this is allowed to be null!
defines != null || defines == null),
+ // ignore: unnecessary_null_comparison
assert(noVerify != null),
+ // ignore: unnecessary_null_comparison
assert(target != null);
Map<ExperimentalFlag, bool> computeExplicitExperimentalFlags(
@@ -313,18 +318,19 @@
/// setting up custom experimental flag defaults for a single test.
class TestOptions {
final Set<Uri> linkDependencies;
- final NnbdMode nnbdMode;
- final AllowedExperimentalFlags allowedExperimentalFlags;
- final Map<ExperimentalFlag, Version> experimentEnabledVersion;
- final Map<ExperimentalFlag, Version> experimentReleasedVersion;
- Component component;
- List<Iterable<String>> errors;
+ final NnbdMode? nnbdMode;
+ final AllowedExperimentalFlags? allowedExperimentalFlags;
+ final Map<ExperimentalFlag, Version>? experimentEnabledVersion;
+ final Map<ExperimentalFlag, Version>? experimentReleasedVersion;
+ Component? component;
+ List<Iterable<String>>? errors;
TestOptions(this.linkDependencies,
- {this.nnbdMode,
- this.allowedExperimentalFlags,
- this.experimentEnabledVersion,
- this.experimentReleasedVersion})
+ {required this.nnbdMode,
+ required this.allowedExperimentalFlags,
+ required this.experimentEnabledVersion,
+ required this.experimentReleasedVersion})
+ // ignore: unnecessary_null_comparison
: assert(linkDependencies != null);
}
@@ -342,7 +348,7 @@
final Map<UriConfiguration, UriTranslator> _uriTranslators = {};
final Map<Uri, FolderOptions> _folderOptions = {};
final Map<Uri, TestOptions> _testOptions = {};
- final Map<Uri, Uri> _librariesJson = {};
+ final Map<Uri, Uri?> _librariesJson = {};
@override
final bool updateExpectations;
@@ -440,7 +446,7 @@
}
FolderOptions _computeFolderOptions(Directory directory) {
- FolderOptions folderOptions = _folderOptions[directory.uri];
+ FolderOptions? folderOptions = _folderOptions[directory.uri];
if (folderOptions == null) {
int forceLateLowering = LateLowering.none;
bool forceLateLoweringSentinel = false;
@@ -449,7 +455,7 @@
int forceConstructorTearOffLowering = ConstructorTearOffLowering.none;
bool nnbdAgnosticMode = false;
bool noVerify = false;
- Map<String, String> defines = {};
+ Map<String, String>? defines = {};
String target = "vm";
if (directory.uri == baseUri) {
folderOptions = new FolderOptions({},
@@ -531,7 +537,7 @@
Future<UriTranslator> computeUriTranslator(
TestDescription description) async {
UriConfiguration uriConfiguration = computeUriConfiguration(description);
- UriTranslator uriTranslator = _uriTranslators[uriConfiguration];
+ UriTranslator? uriTranslator = _uriTranslators[uriConfiguration];
if (uriTranslator == null) {
Uri sdk = Uri.base.resolve("sdk/");
Uri packages = Uri.base.resolve(".packages");
@@ -554,7 +560,7 @@
uriConfiguration.librariesSpecificationUri;
if (folderOptions.overwriteCurrentSdkVersion != null) {
compilerOptions.currentSdkVersion =
- folderOptions.overwriteCurrentSdkVersion;
+ folderOptions.overwriteCurrentSdkVersion!;
}
ProcessedOptions options = new ProcessedOptions(options: compilerOptions);
uriTranslator = await options.getUriTranslator();
@@ -566,15 +572,15 @@
/// Computes the test for [description].
TestOptions computeTestOptions(TestDescription description) {
Directory directory = new File.fromUri(description.uri).parent;
- TestOptions testOptions = _testOptions[directory.uri];
+ TestOptions? testOptions = _testOptions[directory.uri];
if (testOptions == null) {
File optionsFile =
new File.fromUri(directory.uri.resolve('test.options'));
Set<Uri> linkDependencies = new Set<Uri>();
- NnbdMode nnbdMode;
- AllowedExperimentalFlags allowedExperimentalFlags;
- Map<ExperimentalFlag, Version> experimentEnabledVersion;
- Map<ExperimentalFlag, Version> experimentReleasedVersion;
+ NnbdMode? nnbdMode;
+ AllowedExperimentalFlags? allowedExperimentalFlags;
+ Map<ExperimentalFlag, Version>? experimentEnabledVersion;
+ Map<ExperimentalFlag, Version>? experimentReleasedVersion;
if (optionsFile.existsSync()) {
List<String> arguments =
ParsedOptions.readOptionsFile(optionsFile.readAsStringSync());
@@ -639,12 +645,12 @@
}
/// Libraries json for [description].
- Uri computeLibrariesSpecificationUri(TestDescription description) {
+ Uri? computeLibrariesSpecificationUri(TestDescription description) {
Directory directory = new File.fromUri(description.uri).parent;
if (_librariesJson.containsKey(directory.uri)) {
return _librariesJson[directory.uri];
} else {
- Uri librariesJson;
+ Uri? librariesJson;
File jsonFile = new File.fromUri(directory.uri.resolve('libraries.json'));
if (jsonFile.existsSync()) {
librariesJson = jsonFile.uri;
@@ -654,16 +660,16 @@
}
/// Custom package config used for [description].
- Uri computePackageConfigUri(TestDescription description) {
+ Uri? computePackageConfigUri(TestDescription description) {
Uri packageConfig =
description.uri.resolve(".dart_tool/package_config.json");
return new File.fromUri(packageConfig).existsSync() ? packageConfig : null;
}
UriConfiguration computeUriConfiguration(TestDescription description) {
- Uri librariesSpecificationUri =
+ Uri? librariesSpecificationUri =
computeLibrariesSpecificationUri(description);
- Uri packageConfigUri = computePackageConfigUri(description);
+ Uri? packageConfigUri = computePackageConfigUri(description);
return new UriConfiguration(librariesSpecificationUri, packageConfigUri);
}
@@ -674,7 +680,7 @@
target,
nnbdMode,
() => throw new UnsupportedError(
- "No platform dill for target '${target.name}' with $nnbdMode."));
+ "No platform dill for target '${target.name}' with $nnbdMode."))!;
return platformBinaries.resolve(fileName);
}
@@ -708,7 +714,7 @@
Set<Expectation> outcomes, TestDescription description) {
// Remove outcomes related to phases not currently in effect.
- Set<Expectation> result;
+ Set<Expectation>? result;
// If skipping VM we can't get a runtime error.
if (skipVm && outcomes.contains(runtimeError)) {
@@ -782,7 +788,7 @@
bool verify = environment["verify"] != "false";
bool kernelTextSerialization =
environment.containsKey(KERNEL_TEXT_SERIALIZATION);
- String platformBinaries = environment["platformBinaries"];
+ String? platformBinaries = environment["platformBinaries"];
if (platformBinaries != null && !platformBinaries.endsWith('/')) {
platformBinaries = '$platformBinaries/';
}
@@ -825,7 +831,7 @@
if (context._platforms.isEmpty) {
throw "Executed `Run` step before initializing the context.";
}
- File generated = new File.fromUri(result.outputUri);
+ File generated = new File.fromUri(result.outputUri!);
StdioProcess process;
try {
var args = <String>[];
@@ -905,15 +911,15 @@
class StressConstantEvaluatorVisitor extends RecursiveResultVisitor<Node>
implements ErrorReporter {
- ConstantEvaluator constantEvaluator;
- ConstantEvaluator constantEvaluatorWithEmptyEnvironment;
+ late ConstantEvaluator constantEvaluator;
+ late ConstantEvaluator constantEvaluatorWithEmptyEnvironment;
int tries = 0;
int success = 0;
List<String> output = [];
StressConstantEvaluatorVisitor(
ConstantsBackend backend,
- Map<String, String> environmentDefines,
+ Map<String, String>? environmentDefines,
bool enableTripleShift,
TypeEnvironment typeEnvironment,
bool desugarSets,
@@ -931,7 +937,8 @@
evaluationMode: evaluationMode);
}
- Library currentLibrary;
+ Library? currentLibrary;
+
Library visitLibrary(Library node) {
currentLibrary = node;
node.visitChildren(this);
@@ -939,10 +946,10 @@
return node;
}
- Member currentMember;
+ Member? currentMember;
Node defaultMember(Member node) {
- Member prevCurrentMember = currentMember;
+ Member? prevCurrentMember = currentMember;
currentMember = node;
node.visitChildren(this);
currentMember = prevCurrentMember;
@@ -954,9 +961,9 @@
if (node is InvalidExpression) return node;
if (node is ConstantExpression) {
bool evaluate = false;
- if (node.constant is UnevaluatedConstant) {
- UnevaluatedConstant unevaluatedConstant = node.constant;
- if (unevaluatedConstant.expression is! InvalidExpression) {
+ Constant constant = node.constant;
+ if (constant is UnevaluatedConstant) {
+ if (constant.expression is! InvalidExpression) {
evaluate = true;
}
}
@@ -972,10 +979,10 @@
StaticTypeContext staticTypeContext;
if (currentMember == null) {
staticTypeContext = new StaticTypeContext.forAnnotations(
- currentLibrary, constantEvaluator.typeEnvironment);
+ currentLibrary!, constantEvaluator.typeEnvironment);
} else {
staticTypeContext = new StaticTypeContext(
- currentMember, constantEvaluator.typeEnvironment);
+ currentMember!, constantEvaluator.typeEnvironment);
}
Constant x = constantEvaluator.evaluate(staticTypeContext, node);
bool evaluatedWithEmptyEnvironment = false;
@@ -987,7 +994,7 @@
}
x = constantEvaluatorWithEmptyEnvironment.evaluate(
new StaticTypeContext(
- currentMember, constantEvaluator.typeEnvironment),
+ currentMember!, constantEvaluator.typeEnvironment),
new ConstantExpression(x));
evaluatedWithEmptyEnvironment = true;
}
@@ -1019,18 +1026,18 @@
try {
return node.location.toString();
} catch (e) {
- TreeNode n = node;
+ TreeNode? n = node;
while (n != null && n is! FileUriNode) {
n = n.parent;
}
if (n == null) return "(unknown location)";
- FileUriNode fileUriNode = n;
+ FileUriNode fileUriNode = n as FileUriNode;
return ("(unknown position in ${fileUriNode.fileUri})");
}
}
@override
- void report(LocatedMessage message, [List<LocatedMessage> context]) {
+ void report(LocatedMessage message, [List<LocatedMessage>? context]) {
// ignored.
}
}
@@ -1043,9 +1050,9 @@
final List<Iterable<String>> errors;
final CompilerOptions Function(
NnbdMode nnbdMode,
- AllowedExperimentalFlags allowedExperimentalFlags,
- Map<ExperimentalFlag, Version> experimentEnabledVersion,
- Map<ExperimentalFlag, Version> experimentReleasedVersion)
+ AllowedExperimentalFlags? allowedExperimentalFlags,
+ Map<ExperimentalFlag, Version>? experimentEnabledVersion,
+ Map<ExperimentalFlag, Version>? experimentReleasedVersion)
createCompilerOptions;
final ProcessedOptions Function(CompilerOptions compilerOptions)
@@ -1065,7 +1072,7 @@
TestDescription description, FastaContext context) {
List<Iterable<String>> errors = <Iterable<String>>[];
- Uri librariesSpecificationUri =
+ Uri? librariesSpecificationUri =
context.computeLibrariesSpecificationUri(description);
TestOptions testOptions = context.computeTestOptions(description);
FolderOptions folderOptions = context.computeFolderOptions(description);
@@ -1080,9 +1087,9 @@
CompilerOptions createCompilerOptions(
NnbdMode nnbdMode,
- AllowedExperimentalFlags allowedExperimentalFlags,
- Map<ExperimentalFlag, Version> experimentEnabledVersion,
- Map<ExperimentalFlag, Version> experimentReleasedVersion) {
+ AllowedExperimentalFlags? allowedExperimentalFlags,
+ Map<ExperimentalFlag, Version>? experimentEnabledVersion,
+ Map<ExperimentalFlag, Version>? experimentReleasedVersion) {
CompilerOptions compilerOptions = new CompilerOptions()
..onDiagnostic = (DiagnosticMessage message) {
errors.add(message.plainTextFormatted);
@@ -1098,7 +1105,7 @@
..target = createTarget(folderOptions, context);
if (folderOptions.overwriteCurrentSdkVersion != null) {
compilerOptions.currentSdkVersion =
- folderOptions.overwriteCurrentSdkVersion;
+ folderOptions.overwriteCurrentSdkVersion!;
}
return compilerOptions;
}
@@ -1131,7 +1138,7 @@
Future<Result<ComponentResult>> run(
ComponentResult result, FastaContext context) async {
- bool originalFlag = context.explicitExperimentalFlags[
+ bool? originalFlag = context.explicitExperimentalFlags[
ExperimentalFlag.alternativeInvalidationStrategy];
context.explicitExperimentalFlags[
ExperimentalFlag.alternativeInvalidationStrategy] = true;
@@ -1151,7 +1158,7 @@
Component platform = await context.loadPlatform(
backendTarget, compilationSetup.options.nnbdMode);
- Result<ComponentResult> passResult = await performFileInvalidation(
+ Result<ComponentResult>? passResult = await performFileInvalidation(
compilationSetup,
platform,
uriTranslator,
@@ -1171,13 +1178,13 @@
/// one at a time, and the code recompiled after each invalidation.
/// Verifies that either it's an error in all cases or in no cases.
/// Verifies that the same libraries comes out as a result.
- Future<Result<ComponentResult>> performFileInvalidation(
+ Future<Result<ComponentResult>?> performFileInvalidation(
CompilationSetup compilationSetup,
Component platform,
UriTranslator uriTranslator,
ComponentResult result,
FastaContext context,
- bool originalFlag) async {
+ bool? originalFlag) async {
compilationSetup.errors.clear();
IncrementalCompiler incrementalCompiler =
new IncrementalCompiler.fromComponent(
@@ -1253,8 +1260,13 @@
}
}
- context.explicitExperimentalFlags[
- ExperimentalFlag.alternativeInvalidationStrategy] = originalFlag;
+ if (originalFlag != null) {
+ context.explicitExperimentalFlags[
+ ExperimentalFlag.alternativeInvalidationStrategy] = originalFlag;
+ } else {
+ context.explicitExperimentalFlags
+ .remove(ExperimentalFlag.alternativeInvalidationStrategy);
+ }
return null;
}
@@ -1264,13 +1276,13 @@
/// etc are sorted).
/// Verifies that either it's an error in all cases or in no cases.
/// Verifies that the same libraries comes out as a result.
- Future<Result<ComponentResult>> performChunkReordering(
+ Future<Result<ComponentResult>?> performChunkReordering(
CompilationSetup compilationSetup,
Component platform,
UriTranslator uriTranslator,
ComponentResult result,
FastaContext context,
- bool originalFlag) async {
+ bool? originalFlag) async {
compilationSetup.errors.clear();
FileSystem orgFileSystem = compilationSetup.options.fileSystem;
@@ -1290,14 +1302,14 @@
// Create lookup-table from file uri to whatever.
Map<Uri, LibraryBuilder> builders = {};
for (LibraryBuilder builder
- in incrementalCompiler.userCode.loader.builders.values) {
+ in incrementalCompiler.userCode!.loader.builders.values) {
if (builder.importUri.scheme == "dart" && !builder.isSynthetic) continue;
builders[builder.fileUri] = builder;
for (LibraryPart part in builder.library.parts) {
Uri thisPartUri = builder.importUri.resolve(part.partUri);
if (thisPartUri.scheme == "package") {
- thisPartUri =
- incrementalCompiler.userCode.uriTranslator.translate(thisPartUri);
+ thisPartUri = incrementalCompiler.userCode!.uriTranslator
+ .translate(thisPartUri)!;
}
builders[thisPartUri] = builder;
}
@@ -1305,12 +1317,12 @@
for (Uri uri in fs.data.keys) {
print("Work on $uri");
- LibraryBuilder builder = builders[uri];
+ LibraryBuilder? builder = builders[uri];
if (builder == null) {
print("Skipping $uri -- couldn't find builder for it.");
continue;
}
- Uint8List orgData = fs.data[uri];
+ Uint8List orgData = fs.data[uri] as Uint8List;
FuzzAstVisitorSorter fuzzAstVisitorSorter;
try {
fuzzAstVisitorSorter =
@@ -1334,7 +1346,7 @@
for (FuzzAstVisitorSorterChunk chunk in fuzzAstVisitorSorter.chunks) {
sb.writeln(chunk.getSource());
}
- Uint8List sortedData = utf8.encode(sb.toString());
+ Uint8List sortedData = utf8.encode(sb.toString()) as Uint8List;
fs.data[uri] = sortedData;
incrementalCompiler = new IncrementalCompiler.fromComponent(
new CompilerContext(compilationSetup.options), platform);
@@ -1388,7 +1400,7 @@
class FuzzAstVisitorSorterChunk {
final String data;
- final String metadataAndComments;
+ final String? metadataAndComments;
final int layer;
FuzzAstVisitorSorterChunk(this.data, this.metadataAndComments, this.layer);
@@ -1421,7 +1433,7 @@
accept(ast);
if (metadataStart != null) {
String metadata = asString.substring(
- metadataStart.charOffset, metadataEndInclusive.charEnd);
+ metadataStart!.charOffset, metadataEndInclusive!.charEnd);
layer++;
chunks.add(new FuzzAstVisitorSorterChunk(
"",
@@ -1455,25 +1467,25 @@
}
List<FuzzAstVisitorSorterChunk> chunks = [];
- Token metadataStart;
- Token metadataEndInclusive;
+ Token? metadataStart;
+ Token? metadataEndInclusive;
int layer = 0;
- FuzzSorterState state = null;
+ FuzzSorterState? state = null;
/// If there's any LanguageVersionToken in the comment preceding the given
/// token add it as a separate chunk to keep it in place.
void _chunkOutLanguageVersionComment(Token fromToken) {
- Token comment = fromToken.precedingComments;
+ Token comment = fromToken.precedingComments!;
bool hasLanguageVersion = comment is LanguageVersionToken;
while (comment.next != null) {
- comment = comment.next;
+ comment = comment.next!;
hasLanguageVersion |= comment is LanguageVersionToken;
}
if (hasLanguageVersion) {
layer++;
chunks.add(new FuzzAstVisitorSorterChunk(
asString.substring(
- fromToken.precedingComments.charOffset, comment.charEnd),
+ fromToken.precedingComments!.charOffset, comment.charEnd),
null,
layer,
));
@@ -1498,19 +1510,19 @@
// anyway, so possibly allowing it to be sorted (and put in another place)
// won't make it more or less illegal.
if (metadataStart != null &&
- metadataStart.precedingComments != null &&
+ metadataStart!.precedingComments != null &&
chunks.isEmpty) {
- _chunkOutLanguageVersionComment(metadataStart);
+ _chunkOutLanguageVersionComment(metadataStart!);
} else if (metadataStart == null &&
startInclusive.precedingComments != null &&
chunks.isEmpty) {
_chunkOutLanguageVersionComment(startInclusive);
}
- String metadata;
+ String? metadata;
if (metadataStart != null || metadataEndInclusive != null) {
metadata = asString.substring(
- metadataStart.charOffset, metadataEndInclusive.charEnd);
+ metadataStart!.charOffset, metadataEndInclusive!.charEnd);
}
chunks.add(new FuzzAstVisitorSorterChunk(
asString.substring(startInclusive.charOffset, endInclusive.charEnd),
@@ -1530,9 +1542,9 @@
@override
void visitImport(DirectParserASTContentImportEnd node, Token startInclusive,
- Token endInclusive) {
+ Token? endInclusive) {
handleData(
- FuzzSorterState.importExportSortable, startInclusive, endInclusive);
+ FuzzSorterState.importExportSortable, startInclusive, endInclusive!);
}
@override
@@ -1619,7 +1631,7 @@
class _FakeFileSystem extends FileSystem {
bool redirectAndRecord = true;
- final Map<Uri, Uint8List> data = {};
+ final Map<Uri, Uint8List?> data = {};
final FileSystem fs;
_FakeFileSystem(this.fs);
@@ -1645,13 +1657,13 @@
fs.data[uri] = null;
return;
}
- fs.data[uri] = await f.readAsBytes();
+ fs.data[uri] = (await f.readAsBytes()) as Uint8List;
}
@override
Future<bool> exists() async {
await _ensureCachedIfOk();
- Uint8List data = fs.data[uri];
+ Uint8List? data = fs.data[uri];
if (data == null) return false;
return true;
}
@@ -1662,7 +1674,7 @@
@override
Future<List<int>> readAsBytes() async {
await _ensureCachedIfOk();
- Uint8List data = fs.data[uri];
+ Uint8List? data = fs.data[uri];
if (data == null) throw new FileSystemException(uri, "File doesn't exist.");
return data;
}
@@ -1673,7 +1685,7 @@
@override
Future<String> readAsString() async {
await _ensureCachedIfOk();
- Uint8List data = fs.data[uri];
+ Uint8List? data = fs.data[uri];
if (data == null) throw new FileSystemException(uri, "File doesn't exist.");
return utf8.decode(data);
}
@@ -1758,7 +1770,7 @@
if (compilationSetup.testOptions.nnbdMode != null) {
linkOptions = compilationSetup.createProcessedOptions(
compilationSetup.createCompilerOptions(
- compilationSetup.testOptions.nnbdMode,
+ compilationSetup.testOptions.nnbdMode!,
compilationSetup.testOptions.allowedExperimentalFlags,
compilationSetup.testOptions.experimentEnabledVersion,
compilationSetup.testOptions.experimentReleasedVersion));
@@ -1770,14 +1782,14 @@
linkOptions,
compilationSetup.testOptions.linkDependencies.toList());
if (compilationSetup.testOptions.errors != null) {
- compilationSetup.errors.addAll(compilationSetup.testOptions.errors);
+ compilationSetup.errors.addAll(compilationSetup.testOptions.errors!);
}
- Component p = await sourceTarget.buildOutlines();
+ Component p = (await sourceTarget.buildOutlines())!;
if (fullCompile) {
- p = await sourceTarget.buildComponent(
+ p = (await sourceTarget.buildComponent(
verify: compilationSetup.folderOptions.noVerify
? false
- : context.verify);
+ : context.verify))!;
}
// To avoid possible crash in mixin transformation in the transformation
@@ -1788,6 +1800,7 @@
backendTarget.performModularTransformations = true;
}
try {
+ // ignore: unnecessary_null_comparison
if (sourceTarget.loader.coreTypes != null) {
sourceTarget.runBuildTransformations();
}
@@ -1814,7 +1827,7 @@
return await CompilerContext.runWithOptions(compilationSetup.options,
(_) async {
- Component alsoAppend = compilationSetup.testOptions.component;
+ Component? alsoAppend = compilationSetup.testOptions.component;
if (description.uri.pathSegments.last.endsWith(".no_link.dart")) {
alsoAppend = null;
}
@@ -1825,14 +1838,14 @@
new ValidatingInstrumentation();
await instrumentation.loadExpectations(description.uri);
sourceTarget.loader.instrumentation = instrumentation;
- Component p = await sourceTarget.buildOutlines();
+ Component p = (await sourceTarget.buildOutlines())!;
Set<Uri> userLibraries =
createUserLibrariesImportUriSet(p, sourceTarget.uriTranslator);
if (fullCompile) {
- p = await sourceTarget.buildComponent(
+ p = (await sourceTarget.buildComponent(
verify: compilationSetup.folderOptions.noVerify
? false
- : context.verify);
+ : context.verify))!;
instrumentation.finish();
if (instrumentation.hasProblems) {
if (updateComments) {
@@ -1858,7 +1871,7 @@
TestDescription description,
ProcessedOptions options,
List<Uri> entryPoints,
- {Component alsoAppend}) async {
+ {Component? alsoAppend}) async {
Component platform =
await context.loadPlatform(options.target, options.nnbdMode);
Ticker ticker = new Ticker();
@@ -1897,6 +1910,7 @@
backendTarget.performModularTransformations = true;
}
try {
+ // ignore: unnecessary_null_comparison
if (sourceTarget.loader.coreTypes != null) {
sourceTarget.runBuildTransformations();
}
@@ -2008,11 +2022,11 @@
CoreTypes coreTypes,
ClassHierarchy hierarchy,
List<Library> libraries,
- Map<String, String> environmentDefines,
+ Map<String, String>? environmentDefines,
DiagnosticReporter diagnosticReporter,
- ReferenceFromIndex referenceFromIndex,
- {void logger(String msg),
- ChangedStructureNotifier changedStructureNotifier}) {
+ ReferenceFromIndex? referenceFromIndex,
+ {void Function(String msg)? logger,
+ ChangedStructureNotifier? changedStructureNotifier}) {
if (performModularTransformations) {
super.performModularTransformationsOnLibraries(
component,
@@ -2065,7 +2079,7 @@
ComponentResult result, FastaContext context) async {
Component component = result.component;
Uri uri =
- component.uriToSource.keys.firstWhere((uri) => uri?.scheme == "file");
+ component.uriToSource.keys.firstWhere((uri) => uri.scheme == "file");
KernelTarget target = result.sourceTarget;
ClassHierarchyBuilder hierarchy = target.loader.builderHierarchy;
StringBuffer sb = new StringBuffer();
@@ -2078,8 +2092,8 @@
}
class UriConfiguration {
- final Uri librariesSpecificationUri;
- final Uri packageConfigUri;
+ final Uri? librariesSpecificationUri;
+ final Uri? packageConfigUri;
UriConfiguration(this.librariesSpecificationUri, this.packageConfigUri);
@@ -2097,7 +2111,7 @@
}
class NoneConstantsBackendWithJs extends NoneConstantsBackend {
- const NoneConstantsBackendWithJs({bool supportsUnevaluatedConstants})
+ const NoneConstantsBackendWithJs({required bool supportsUnevaluatedConstants})
: super(supportsUnevaluatedConstants: supportsUnevaluatedConstants);
@override
diff --git a/pkg/front_end/test/incremental_suite.dart b/pkg/front_end/test/incremental_suite.dart
index f2a57ca..96dc4f3 100644
--- a/pkg/front_end/test/incremental_suite.dart
+++ b/pkg/front_end/test/incremental_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 file.
-// @dart = 2.9
-
import 'dart:developer' show debugger;
import 'dart:io' show Directory, File;
@@ -149,13 +147,15 @@
cleanupHelper?.outDir = null;
}
- TestData cleanupHelper;
+ TestData? cleanupHelper;
}
class TestData {
YamlMap map;
- Directory outDir;
+ Directory? outDir;
Uri loadedFrom;
+
+ TestData(this.map, this.outDir, this.loadedFrom);
}
class ReadTest extends Step<TestDescription, TestData, Context> {
@@ -167,11 +167,10 @@
TestDescription description, Context context) async {
Uri uri = description.uri;
String contents = await new File.fromUri(uri).readAsString();
- TestData data = new TestData();
- data.loadedFrom = uri;
- data.map = loadYamlNode(contents, sourceUrl: uri);
- data.outDir =
- Directory.systemTemp.createTempSync("incremental_load_from_dill_test");
+ TestData data = new TestData(
+ loadYamlNode(contents, sourceUrl: uri) as YamlMap,
+ Directory.systemTemp.createTempSync("incremental_load_from_dill_test"),
+ uri);
context.cleanupHelper = data;
return pass(data);
}
@@ -183,7 +182,7 @@
String get name => "run compilations";
Future<Result<TestData>> run(TestData data, Context context) async {
- Result<TestData> result;
+ Result<TestData>? result;
YamlMap map = data.map;
Set<String> keys = new Set<String>.from(map.keys.cast<String>());
keys.remove("type");
@@ -194,7 +193,7 @@
map["sources"],
map["entry"],
map["invalidate"],
- data.outDir,
+ data.outDir!,
);
break;
case "newworld":
@@ -231,12 +230,12 @@
}
Future<Null> basicTest(YamlMap sourceFiles, String entryPoint,
- YamlList invalidate, Directory outDir) async {
+ YamlList? invalidate, Directory outDir) async {
Uri entryPointUri = outDir.uri.resolve(entryPoint);
Set<String> invalidateFilenames =
invalidate == null ? new Set<String>() : new Set<String>.from(invalidate);
List<Uri> invalidateUris = <Uri>[];
- Uri packagesUri;
+ Uri? packagesUri;
for (String filename in sourceFiles.keys) {
Uri uri = outDir.uri.resolve(filename);
if (invalidateFilenames.contains(filename)) {
@@ -313,7 +312,7 @@
for (String moduleName in module.keys) {
List<Uri> moduleSources = <Uri>[];
- Uri packagesUri;
+ Uri? packagesUri;
for (String filename in module[moduleName].keys) {
Uri uri = base.resolve(filename);
if (uri.pathSegments.last == ".packages") {
@@ -361,15 +360,15 @@
class NewWorldTest {
// These are fields in a class to make it easier to track down memory leaks
// via the leak detector test.
- Component newestWholeComponent;
- Component sdk;
- Component component;
- Component component2;
- Component component3;
+ Component? newestWholeComponent;
+ Component? sdk;
+ Component? component;
+ Component? component2;
+ Component? component3;
String doStringReplacements(String input) {
Version enableNonNullableVersion =
- experimentEnabledVersion[ExperimentalFlag.nonNullable];
+ experimentEnabledVersion[ExperimentalFlag.nonNullable]!;
String output = input.replaceAll("%NNBD_VERSION_MARKER%",
"${enableNonNullableVersion.major}.${enableNonNullableVersion.minor}");
return output;
@@ -379,12 +378,12 @@
TestData data,
Context context,
List worlds,
- Map modules,
- bool omitPlatform,
- String targetName,
+ Map? modules,
+ bool? omitPlatform,
+ String? targetName,
bool forceLateLoweringForTesting,
bool trackWidgetCreation,
- bool incrementalSerialization,
+ bool? incrementalSerialization,
NnbdMode nnbdMode) async {
final Uri sdkRoot = computePlatformBinariesLocation(forceBuildDir: true);
@@ -411,7 +410,7 @@
target,
nnbdMode,
() => throw new UnsupportedError(
- "No platform dill for target '${targetName}' with $nnbdMode."));
+ "No platform dill for target '${targetName}' with $nnbdMode."))!;
final Uri base = Uri.parse("org-dartlang-test:///");
final Uri sdkSummaryUri = base.resolve(sdkSummary);
@@ -420,15 +419,15 @@
final List<int> sdkSummaryData =
await new File.fromUri(platformUri).readAsBytes();
- List<int> newestWholeComponentData;
- MemoryFileSystem fs;
- Map<String, String> sourceFiles;
- CompilerOptions options;
- TestIncrementalCompiler compiler;
- IncrementalSerializer incrementalSerializer;
+ List<int>? newestWholeComponentData;
+ MemoryFileSystem? fs;
+ Map<String, String?>? sourceFiles;
+ CompilerOptions? options;
+ TestIncrementalCompiler? compiler;
+ IncrementalSerializer? incrementalSerializer;
- Map<String, List<int>> moduleData;
- Map<String, Component> moduleComponents;
+ Map<String, List<int>>? moduleData;
+ Map<String, Component>? moduleComponents;
if (modules != null) {
moduleData =
@@ -436,7 +435,7 @@
sdk = newestWholeComponent = new Component();
new BinaryBuilder(sdkSummaryData,
filename: null, disableLazyReading: false)
- .readComponent(newestWholeComponent);
+ .readComponent(newestWholeComponent!);
}
int worldNum = 0;
@@ -447,27 +446,27 @@
print("----------------");
print("World #$worldNum");
print("----------------");
- List<Component> modulesToUse;
+ List<Component>? modulesToUse;
if (world["modules"] != null) {
moduleComponents ??= new Map<String, Component>();
- sdk.adoptChildren();
+ sdk!.adoptChildren();
for (Component c in moduleComponents.values) {
c.adoptChildren();
}
modulesToUse = <Component>[];
for (String moduleName in world["modules"]) {
- Component moduleComponent = moduleComponents[moduleName];
+ Component? moduleComponent = moduleComponents[moduleName];
if (moduleComponent != null) {
modulesToUse.add(moduleComponent);
}
}
for (String moduleName in world["modules"]) {
- Component moduleComponent = moduleComponents[moduleName];
+ Component? moduleComponent = moduleComponents[moduleName];
if (moduleComponent == null) {
- moduleComponent = new Component(nameRoot: sdk.root);
- new BinaryBuilder(moduleData[moduleName],
+ moduleComponent = new Component(nameRoot: sdk!.root);
+ new BinaryBuilder(moduleData![moduleName]!,
filename: null,
disableLazyReading: false,
alwaysCreateNewNamedNodes: true)
@@ -490,7 +489,7 @@
if (brandNewWorld) {
fs = new MemoryFileSystem(base);
}
- fs.entityForUri(sdkSummaryUri).writeAsBytesSync(sdkSummaryData);
+ fs!.entityForUri(sdkSummaryUri).writeAsBytesSync(sdkSummaryData);
bool expectInitializeFromDill = false;
if (newestWholeComponentData != null &&
newestWholeComponentData.isNotEmpty) {
@@ -503,12 +502,12 @@
expectInitializeFromDill = world["expectInitializeFromDill"];
}
if (brandNewWorld) {
- sourceFiles = new Map<String, String>.from(world["sources"]);
+ sourceFiles = new Map<String, String?>.from(world["sources"]);
} else {
- sourceFiles.addAll(new Map<String, String>.from(
- world["sources"] ?? <String, String>{}));
+ sourceFiles!.addAll(new Map<String, String?>.from(
+ world["sources"] ?? <String, String?>{}));
}
- Uri packagesUri;
+ Uri? packagesUri;
for (String filename in sourceFiles.keys) {
String data = sourceFiles[filename] ?? "";
Uri uri = base.resolve(filename);
@@ -563,7 +562,7 @@
}
}
if (packagesUri != null) {
- options.packagesFileUri = packagesUri;
+ options!.packagesFileUri = packagesUri;
}
bool gotError = false;
final Set<String> formattedErrors = Set<String>();
@@ -571,8 +570,8 @@
final Set<String> formattedWarnings = Set<String>();
final Set<String> seenDiagnosticCodes = Set<String>();
- options.onDiagnostic = (DiagnosticMessage message) {
- String code = getMessageCodeObject(message)?.name;
+ options!.onDiagnostic = (DiagnosticMessage message) {
+ String? code = getMessageCodeObject(message)?.name;
if (code != null) seenDiagnosticCodes.add(code);
String stringId = message.ansiFormatted.join("\n");
@@ -633,24 +632,24 @@
for (String filename in world["invalidate"]) {
Uri uri = base.resolve(filename);
invalidated.add(uri);
- compiler.invalidate(uri);
+ compiler!.invalidate(uri);
}
}
if (modulesToUse != null) {
- compiler.setModulesToLoadOnNextComputeDelta(modulesToUse);
+ compiler!.setModulesToLoadOnNextComputeDelta(modulesToUse);
compiler.invalidateAllSources();
compiler.trackNeededDillLibraries = true;
}
Stopwatch stopwatch = new Stopwatch()..start();
- component = await compiler.computeDelta(
+ component = await compiler!.computeDelta(
entryPoints: entries,
fullComponent:
brandNewWorld ? false : (noFullComponent ? false : true),
simulateTransformer: world["simulateTransformer"]);
if (outlineOnly && !skipOutlineBodyCheck) {
- for (Library lib in component.libraries) {
+ for (Library lib in component!.libraries) {
for (Class c in lib.classes) {
for (Procedure p in c.procedures) {
if (p.function.body != null &&
@@ -666,7 +665,7 @@
}
}
}
- Result<TestData> result = performErrorAndWarningCheck(world, data,
+ Result<TestData>? result = performErrorAndWarningCheck(world, data,
gotError, formattedErrors, gotWarning, formattedWarnings);
if (result != null) return result;
if (world["expectInitializationError"] != null) {
@@ -694,59 +693,59 @@
"${world["expectInitializationError"]}";
}
}
- util.throwOnEmptyMixinBodies(component);
- await util.throwOnInsufficientUriToSource(component,
+ util.throwOnEmptyMixinBodies(component!);
+ await util.throwOnInsufficientUriToSource(component!,
fileSystem: gotError ? null : fs);
print("Compile took ${stopwatch.elapsedMilliseconds} ms");
- Result contentResult = checkExpectedContent(world, component);
+ Result? contentResult = checkExpectedContent(world, component!);
if (contentResult != null) return contentResult.copyWithOutput(data);
result = checkNeededDillLibraries(
world, data, compiler.neededDillLibraries, base);
if (result != null) return result;
- Result nnbdCheck = checkNNBDSettings(component);
+ Result? nnbdCheck = checkNNBDSettings(component!);
if (nnbdCheck != null) return nnbdCheck.copyWithOutput(data);
if (!noFullComponent) {
Set<Library> allLibraries = new Set<Library>();
- for (Library lib in component.libraries) {
+ for (Library lib in component!.libraries) {
computeAllReachableLibrariesFor(lib, allLibraries);
}
- if (allLibraries.length != component.libraries.length) {
+ if (allLibraries.length != component!.libraries.length) {
return new Result<TestData>(
data,
ReachableLibrariesError,
"Expected for the reachable stuff to be equal to "
- "${component.libraries} but it was $allLibraries");
+ "${component!.libraries} but it was $allLibraries");
}
Set<Library> tooMany = allLibraries.toSet()
- ..removeAll(component.libraries);
+ ..removeAll(component!.libraries);
if (tooMany.isNotEmpty) {
return new Result<TestData>(
data,
ReachableLibrariesError,
"Expected for the reachable stuff to be equal to "
- "${component.libraries} but these were there too: $tooMany "
+ "${component!.libraries} but these were there too: $tooMany "
"(and others were missing)");
}
}
- newestWholeComponentData = util.postProcess(component);
+ newestWholeComponentData = util.postProcess(component!);
newestWholeComponent = component;
- String actualSerialized = componentToStringSdkFiltered(component);
+ String actualSerialized = componentToStringSdkFiltered(component!);
print("*****\n\ncomponent:\n"
"${actualSerialized}\n\n\n");
if (world["uriToSourcesDoesntInclude"] != null) {
for (String filename in world["uriToSourcesDoesntInclude"]) {
Uri uri = base.resolve(filename);
- if (component.uriToSource[uri] != null) {
+ if (component!.uriToSource[uri] != null) {
return new Result<TestData>(
data,
UriToSourceError,
"Expected no uriToSource for $uri but found "
- "${component.uriToSource[uri]}");
+ "${component!.uriToSource[uri]}");
}
}
}
@@ -756,16 +755,17 @@
Uri uri = base.resolve(filename);
allowed.add(uri);
}
- for (Uri uri in component.uriToSource.keys) {
+ for (Uri uri in component!.uriToSource.keys) {
// null is always there, so allow it implicitly.
// Dart scheme uris too.
+ // ignore: unnecessary_null_comparison
if (uri == null || uri.scheme == "org-dartlang-sdk") continue;
if (!allowed.contains(uri)) {
return new Result<TestData>(
data,
UriToSourceError,
"Expected no uriToSource for $uri but found "
- "${component.uriToSource[uri]}");
+ "${component!.uriToSource[uri]}");
}
}
}
@@ -774,14 +774,14 @@
if (result != null) return result;
if (world["skipClassHierarchyTest"] != true) {
result =
- checkClassHierarchy(compiler, component, data, worldNum, context);
+ checkClassHierarchy(compiler, component!, data, worldNum, context);
if (result != null) return result;
}
- int nonSyntheticLibraries = countNonSyntheticLibraries(component);
+ int nonSyntheticLibraries = countNonSyntheticLibraries(component!);
int nonSyntheticPlatformLibraries =
- countNonSyntheticPlatformLibraries(component);
- int syntheticLibraries = countSyntheticLibraries(component);
+ countNonSyntheticPlatformLibraries(component!);
+ int syntheticLibraries = countSyntheticLibraries(component!);
if (world["expectsPlatform"] == true) {
if (nonSyntheticPlatformLibraries < 5) {
return new Result<TestData>(
@@ -823,7 +823,7 @@
}
if (world["expectsRebuildBodiesOnly"] != null) {
- bool didRebuildBodiesOnly = compiler.rebuildBodiesCount > 0;
+ bool didRebuildBodiesOnly = compiler.rebuildBodiesCount! > 0;
if (world["expectsRebuildBodiesOnly"] != didRebuildBodiesOnly) {
return new Result<TestData>(
data,
@@ -836,7 +836,7 @@
if (!noFullComponent) {
if (world["checkEntries"] != false) {
- List<Library> entryLib = component.libraries
+ List<Library> entryLib = component!.libraries
.where((Library lib) =>
entries.contains(lib.importUri) ||
entries.contains(lib.fileUri))
@@ -867,27 +867,27 @@
}
if (world["checkInvalidatedFiles"] != false) {
- Set<Uri> filteredInvalidated =
+ Set<Uri>? filteredInvalidated =
compiler.getFilteredInvalidatedImportUrisForTesting(invalidated);
if (world["invalidate"] != null) {
Expect.equals(
world["invalidate"].length, filteredInvalidated?.length ?? 0);
- List expectedInvalidatedUri = world["expectedInvalidatedUri"];
+ List? expectedInvalidatedUri = world["expectedInvalidatedUri"];
if (expectedInvalidatedUri != null) {
Expect.setEquals(expectedInvalidatedUri.map((s) => base.resolve(s)),
- filteredInvalidated);
+ filteredInvalidated!);
}
} else {
Expect.isNull(filteredInvalidated);
Expect.isNull(world["expectedInvalidatedUri"]);
}
}
- Result<List<int>> serializationResult = checkIncrementalSerialization(
- incrementalSerialization, component, incrementalSerializer, world);
+ Result<List<int>?> serializationResult = checkIncrementalSerialization(
+ incrementalSerialization, component!, incrementalSerializer, world);
if (!serializationResult.isPass) {
return serializationResult.copyWithOutput(data);
}
- List<int> incrementalSerializationBytes = serializationResult.output;
+ List<int>? incrementalSerializationBytes = serializationResult.output;
worldErrors.add(formattedErrors.toSet());
assert(worldErrors.length == worldNum);
@@ -917,23 +917,26 @@
entryPoints: entries,
fullComponent: true,
simulateTransformer: world["simulateTransformer"]);
- Result<TestData> result = performErrorAndWarningCheck(world, data,
+ Result<TestData>? result = performErrorAndWarningCheck(world, data,
gotError, formattedErrors, gotWarning, formattedWarnings);
if (result != null) return result;
- List<int> thisWholeComponent = util.postProcess(component2);
+ List<int> thisWholeComponent = util.postProcess(component2!);
print("*****\n\ncomponent2:\n"
- "${componentToStringSdkFiltered(component2)}\n\n\n");
+ "${componentToStringSdkFiltered(component2!)}\n\n\n");
checkIsEqual(newestWholeComponentData, thisWholeComponent);
checkErrorsAndWarnings(prevFormattedErrors, formattedErrors,
prevFormattedWarnings, formattedWarnings);
newestWholeComponent = component2;
- Result<List<int>> serializationResult = checkIncrementalSerialization(
- incrementalSerialization, component2, incrementalSerializer, world);
+ Result<List<int>?> serializationResult = checkIncrementalSerialization(
+ incrementalSerialization,
+ component2!,
+ incrementalSerializer,
+ world);
if (!serializationResult.isPass) {
return serializationResult.copyWithOutput(data);
}
- List<int> incrementalSerializationBytes2 = serializationResult.output;
+ List<int>? incrementalSerializationBytes2 = serializationResult.output;
if ((incrementalSerializationBytes == null &&
incrementalSerializationBytes2 != null) ||
@@ -948,7 +951,7 @@
if (incrementalSerializationBytes != null) {
checkIsEqual(
- incrementalSerializationBytes, incrementalSerializationBytes2);
+ incrementalSerializationBytes, incrementalSerializationBytes2!);
}
}
@@ -967,8 +970,8 @@
bool expectWarnings = compilation["warnings"] ?? false;
Uri uri = base.resolve(compilation["uri"]);
String expression = compilation["expression"];
- Procedure procedure = await compiler.compileExpression(
- expression, {}, [], "debugExpr", uri);
+ Procedure procedure = (await compiler.compileExpression(
+ expression, {}, [], "debugExpr", uri))!;
if (gotError && !expectErrors) {
return new Result<TestData>(data, UnexpectedErrors,
"Got error(s) on expression compilation: ${formattedErrors}.");
@@ -986,7 +989,7 @@
return new Result<TestData>(
data, MissingWarnings, "Didn't get any warnings.");
}
- Result<TestData> result = checkExpectFile(
+ Result<TestData>? result = checkExpectFile(
data,
worldNum,
".expression.$expressionCompilationNum",
@@ -1001,9 +1004,9 @@
world["compareWithFromScratch"] == true)) {
// Do compile from scratch and compare.
clearPrevErrorsEtc();
- TestIncrementalCompiler compilerFromScratch;
+ TestIncrementalCompiler? compilerFromScratch;
- IncrementalSerializer incrementalSerializer2;
+ IncrementalSerializer? incrementalSerializer2;
if (incrementalSerialization == true) {
incrementalSerializer2 = new IncrementalSerializer();
}
@@ -1027,31 +1030,31 @@
entryPoints: entries,
simulateTransformer: world["simulateTransformer"]);
compilerFromScratch = null;
- Result<TestData> result = performErrorAndWarningCheck(world, data,
+ Result<TestData>? result = performErrorAndWarningCheck(world, data,
gotError, formattedErrors, gotWarning, formattedWarnings);
if (result != null) return result;
- util.throwOnEmptyMixinBodies(component3);
- await util.throwOnInsufficientUriToSource(component3);
+ util.throwOnEmptyMixinBodies(component3!);
+ await util.throwOnInsufficientUriToSource(component3!);
print("Compile took ${stopwatch.elapsedMilliseconds} ms");
- List<int> thisWholeComponent = util.postProcess(component3);
+ List<int> thisWholeComponent = util.postProcess(component3!);
print("*****\n\ncomponent3:\n"
- "${componentToStringSdkFiltered(component3)}\n\n\n");
+ "${componentToStringSdkFiltered(component3!)}\n\n\n");
if (world["compareWithFromScratch"] == true) {
checkIsEqual(newestWholeComponentData, thisWholeComponent);
}
checkErrorsAndWarnings(prevFormattedErrors, formattedErrors,
prevFormattedWarnings, formattedWarnings);
- Result<List<int>> serializationResult = checkIncrementalSerialization(
+ Result<List<int>?> serializationResult = checkIncrementalSerialization(
incrementalSerialization,
- component3,
+ component3!,
incrementalSerializer2,
world);
if (!serializationResult.isPass) {
return serializationResult.copyWithOutput(data);
}
- List<int> incrementalSerializationBytes3 = serializationResult.output;
+ List<int>? incrementalSerializationBytes3 = serializationResult.output;
if ((incrementalSerializationBytes == null &&
incrementalSerializationBytes3 != null) ||
@@ -1070,7 +1073,7 @@
// (e.g. when the old one contains more, and the new one doesn't).
} else {
checkIsEqual(
- incrementalSerializationBytes, incrementalSerializationBytes3);
+ incrementalSerializationBytes, incrementalSerializationBytes3!);
}
newestWholeComponentData = incrementalSerializationBytes;
}
@@ -1094,7 +1097,7 @@
}
}
-Result checkNNBDSettings(Component component) {
+Result? checkNNBDSettings(Component component) {
NonNullableByDefaultCompiledMode mode = component.mode;
if (mode == NonNullableByDefaultCompiledMode.Invalid) return null;
for (Library lib in component.libraries) {
@@ -1127,11 +1130,11 @@
return null;
}
-Result<TestData> checkExpectFile(TestData data, int worldNum,
+Result<TestData>? checkExpectFile(TestData data, int worldNum,
String extraUriString, Context context, String actualSerialized) {
Uri uri = data.loadedFrom.resolve(data.loadedFrom.pathSegments.last +
".world.$worldNum${extraUriString}.expect");
- String expected;
+ String? expected;
File file = new File.fromUri(uri);
if (file.existsSync()) {
expected = file.readAsStringSync();
@@ -1159,10 +1162,10 @@
///
/// This has the option to do expect files, but it's disabled by default
/// while we're trying to figure out if it's useful or not.
-Result<TestData> checkClassHierarchy(TestIncrementalCompiler compiler,
+Result<TestData>? checkClassHierarchy(TestIncrementalCompiler compiler,
Component component, TestData data, int worldNum, Context context,
{bool checkExpectFile: false}) {
- ClassHierarchy classHierarchy = compiler.getClassHierarchy();
+ ClassHierarchy? classHierarchy = compiler.getClassHierarchy();
if (classHierarchy is! ClosedWorldClassHierarchy) {
return new Result<TestData>(
data,
@@ -1171,7 +1174,7 @@
"but it wasn't. It was ${classHierarchy.runtimeType}");
}
List<ForTestingClassInfo> classHierarchyData =
- (classHierarchy as ClosedWorldClassHierarchy).getTestingClassInfo();
+ classHierarchy.getTestingClassInfo();
Map<Class, ForTestingClassInfo> classHierarchyMap =
new Map<Class, ForTestingClassInfo>();
for (ForTestingClassInfo info in classHierarchyData) {
@@ -1190,17 +1193,17 @@
sb.writeln(" - Class ${c.name}");
Set<Class> checkedSupertypes = <Class>{};
- Result<TestData> checkSupertype(Supertype supertype) {
+ Result<TestData>? checkSupertype(Supertype? supertype) {
if (supertype == null) return null;
Class superclass = supertype.classNode;
if (checkedSupertypes.add(superclass)) {
- Supertype asSuperClass =
+ Supertype? asSuperClass =
classHierarchy.getClassAsInstanceOf(c, superclass);
if (asSuperClass == null) {
return new Result<TestData>(data, ClassHierarchyError,
"${superclass} not found as a superclass of $c");
}
- Result<TestData> result = checkSupertype(superclass.supertype);
+ Result<TestData>? result = checkSupertype(superclass.supertype);
if (result != null) return result;
result = checkSupertype(superclass.mixedInType);
if (result != null) return result;
@@ -1212,10 +1215,10 @@
return null;
}
- Result<TestData> result = checkSupertype(c.asThisSupertype);
+ Result<TestData>? result = checkSupertype(c.asThisSupertype);
if (result != null) return result;
- ForTestingClassInfo info = classHierarchyMap[c];
+ ForTestingClassInfo? info = classHierarchyMap[c];
if (info == null) {
return new Result<TestData>(data, ClassHierarchyError,
"Didn't find any class hierarchy info for $c");
@@ -1223,12 +1226,12 @@
if (info.lazyDeclaredGettersAndCalls != null) {
sb.writeln(" - lazyDeclaredGettersAndCalls:");
- for (Member member in info.lazyDeclaredGettersAndCalls) {
+ for (Member member in info.lazyDeclaredGettersAndCalls!) {
sb.writeln(" - ${member.name.text}");
}
// Expect these to be the same as in the class.
- Set<Member> members = info.lazyDeclaredGettersAndCalls.toSet();
+ Set<Member> members = info.lazyDeclaredGettersAndCalls!.toSet();
for (Field f in c.fields) {
if (f.isStatic) continue;
if (!members.remove(f)) {
@@ -1260,12 +1263,12 @@
}
if (info.lazyDeclaredSetters != null) {
sb.writeln(" - lazyDeclaredSetters:");
- for (Member member in info.lazyDeclaredSetters) {
+ for (Member member in info.lazyDeclaredSetters!) {
sb.writeln(" - ${member.name.text}");
}
// Expect these to be the same as in the class.
- Set<Member> members = info.lazyDeclaredSetters.toSet();
+ Set<Member> members = info.lazyDeclaredSetters!.toSet();
for (Field f in c.fields) {
if (f.isStatic) continue;
if (!f.hasSetter) continue;
@@ -1292,25 +1295,25 @@
}
if (info.lazyImplementedGettersAndCalls != null) {
sb.writeln(" - lazyImplementedGettersAndCalls:");
- for (Member member in info.lazyImplementedGettersAndCalls) {
+ for (Member member in info.lazyImplementedGettersAndCalls!) {
sb.writeln(" - ${member.name.text}");
}
}
if (info.lazyImplementedSetters != null) {
sb.writeln(" - lazyImplementedSetters:");
- for (Member member in info.lazyImplementedSetters) {
+ for (Member member in info.lazyImplementedSetters!) {
sb.writeln(" - ${member.name.text}");
}
}
if (info.lazyInterfaceGettersAndCalls != null) {
sb.writeln(" - lazyInterfaceGettersAndCalls:");
- for (Member member in info.lazyInterfaceGettersAndCalls) {
+ for (Member member in info.lazyInterfaceGettersAndCalls!) {
sb.writeln(" - ${member.name.text}");
}
}
if (info.lazyInterfaceSetters != null) {
sb.writeln(" - lazyInterfaceSetters:");
- for (Member member in info.lazyInterfaceSetters) {
+ for (Member member in info.lazyInterfaceSetters!) {
sb.writeln(" - ${member.name.text}");
}
}
@@ -1320,7 +1323,7 @@
String actualClassHierarchy = sb.toString();
Uri uri = data.loadedFrom.resolve(data.loadedFrom.pathSegments.last +
".world.$worldNum.class_hierarchy.expect");
- String expected;
+ String? expected;
File file = new File.fromUri(uri);
if (file.existsSync()) {
expected = file.readAsStringSync();
@@ -1372,10 +1375,10 @@
}
}
-Result<List<int>> checkIncrementalSerialization(
- bool incrementalSerialization,
+Result<List<int>?> checkIncrementalSerialization(
+ bool? incrementalSerialization,
Component component,
- IncrementalSerializer incrementalSerializer,
+ IncrementalSerializer? incrementalSerializer,
YamlMap world) {
if (incrementalSerialization == true) {
Component c = new Component(nameRoot: component.root)
@@ -1385,7 +1388,7 @@
Map<String, Set<String>> originalContent = buildMapOfContent(c);
ByteSink sink = new ByteSink();
int librariesBefore = c.libraries.length;
- incrementalSerializer.writePackagesToSinkAndTrimComponent(c, sink);
+ incrementalSerializer!.writePackagesToSinkAndTrimComponent(c, sink);
int librariesAfter = c.libraries.length;
if (librariesAfter > librariesBefore) {
return new Result<List<int>>(null, IncrementalSerializationError,
@@ -1447,20 +1450,20 @@
for (String key in newKeys) {
afterContent.remove(key);
}
- Result result = checkExpectedContentData(afterContent, originalContent);
- if (result != null) return result.copyWithOutput<List<int>>(null);
+ Result? result = checkExpectedContentData(afterContent, originalContent);
+ if (result != null) return result.copyWithOutput<List<int>?>(null);
// Check that the result is self-contained.
result = checkSelfContained(loadedComponent);
- if (result != null) return result.copyWithOutput<List<int>>(null);
+ if (result != null) return result.copyWithOutput<List<int>?>(null);
return new Result<List<int>>.pass(bytes);
}
}
- return new Result<List<int>>.pass(null);
+ return new Result<List<int>?>.pass(null);
}
-Result checkSelfContained(Component component) {
+Result? checkSelfContained(Component component) {
Set<Library> got = new Set<Library>.from(component.libraries);
for (Library lib in component.libraries) {
for (LibraryDependency dependency in lib.dependencies) {
@@ -1500,7 +1503,7 @@
}
}
-Result checkExpectedContent(YamlMap world, Component component) {
+Result? checkExpectedContent(YamlMap world, Component component) {
if (world["expectedContent"] != null) {
Map<String, Set<String>> actualContent = buildMapOfContent(component);
Map expectedContent = world["expectedContent"];
@@ -1509,7 +1512,7 @@
return null;
}
-Result checkExpectedContentData(
+Result? checkExpectedContentData(
Map<String, Set<String>> actualContent, Map expectedContent) {
Result<TestData> createFailureResult() {
return new Result(
@@ -1530,7 +1533,7 @@
}
for (String key in expectedContent.keys) {
Set<String> expected = new Set<String>.from(expectedContent[key]);
- Set<String> actual = actualContent[key].toSet();
+ Set<String> actual = actualContent[key]!.toSet();
if (expected.length != actual.length) {
return createFailureResult();
}
@@ -1560,11 +1563,11 @@
return actualContent;
}
-Result<TestData> checkNeededDillLibraries(
- YamlMap world, TestData data, Set<Library> neededDillLibraries, Uri base) {
+Result<TestData>? checkNeededDillLibraries(
+ YamlMap world, TestData data, Set<Library>? neededDillLibraries, Uri base) {
if (world["neededDillLibraries"] != null) {
List<Uri> actualContent = <Uri>[];
- for (Library lib in neededDillLibraries) {
+ for (Library lib in neededDillLibraries!) {
if (lib.importUri.scheme == "dart") continue;
actualContent.add(lib.importUri);
}
@@ -1657,7 +1660,7 @@
return result;
}
-Result<TestData> performErrorAndWarningCheck(
+Result<TestData>? performErrorAndWarningCheck(
YamlMap world,
TestData data,
bool gotError,
@@ -1711,7 +1714,7 @@
Expect.equals(a.length, b.length);
}
-CompilerOptions getOptions({Target target, String sdkSummary}) {
+CompilerOptions getOptions({Target? target, String? sdkSummary}) {
target ??= new VmTarget(new TargetFlags());
sdkSummary ??= 'vm_platform_strong.dill';
final Uri sdkRoot = computePlatformBinariesLocation(forceBuildDir: true);
@@ -1733,7 +1736,7 @@
}
Future<bool> normalCompile(Uri input, Uri output,
- {CompilerOptions options}) async {
+ {CompilerOptions? options}) async {
options ??= getOptions();
TestIncrementalCompiler compiler =
new TestIncrementalCompiler(options, input);
@@ -1744,14 +1747,14 @@
}
Future<List<int>> normalCompileToBytes(Uri input,
- {CompilerOptions options, IncrementalCompiler compiler}) async {
+ {CompilerOptions? options, IncrementalCompiler? compiler}) async {
Component component = await normalCompileToComponent(input,
options: options, compiler: compiler);
return util.postProcess(component);
}
Future<Component> normalCompileToComponent(Uri input,
- {CompilerOptions options, IncrementalCompiler compiler}) async {
+ {CompilerOptions? options, IncrementalCompiler? compiler}) async {
Component component =
await normalCompilePlain(input, options: options, compiler: compiler);
util.throwOnEmptyMixinBodies(component);
@@ -1760,7 +1763,7 @@
}
Future<Component> normalCompilePlain(Uri input,
- {CompilerOptions options, IncrementalCompiler compiler}) async {
+ {CompilerOptions? options, IncrementalCompiler? compiler}) async {
options ??= getOptions();
compiler ??= new TestIncrementalCompiler(options, input);
return await compiler.computeDelta();
@@ -1768,7 +1771,7 @@
Future<bool> initializedCompile(
Uri input, Uri output, Uri initializeWith, List<Uri> invalidateUris,
- {CompilerOptions options}) async {
+ {CompilerOptions? options}) async {
options ??= getOptions();
TestIncrementalCompiler compiler =
new TestIncrementalCompiler(options, input, initializeWith);
@@ -1836,8 +1839,8 @@
}
class TestIncrementalCompiler extends IncrementalCompiler {
- Set<Uri> invalidatedImportUrisForTesting;
- int rebuildBodiesCount;
+ Set<Uri>? invalidatedImportUrisForTesting;
+ int? rebuildBodiesCount;
final Uri entryPoint;
/// Filter out the automatically added entryPoint, unless it's explicitly
@@ -1845,14 +1848,14 @@
/// Also filter out uris with "nonexisting.dart" in the name as synthetic
/// libraries are invalidated automatically too.
/// This is not perfect, but works for what it's currently used for.
- Set<Uri> getFilteredInvalidatedImportUrisForTesting(
+ Set<Uri>? getFilteredInvalidatedImportUrisForTesting(
List<Uri> invalidatedUris) {
if (invalidatedImportUrisForTesting == null) return null;
Set<String> invalidatedFilenames =
invalidatedUris.map((uri) => uri.pathSegments.last).toSet();
Set<Uri> result = new Set<Uri>();
- for (Uri uri in invalidatedImportUrisForTesting) {
+ for (Uri uri in invalidatedImportUrisForTesting!) {
if (uri.pathSegments.isNotEmpty &&
uri.pathSegments.last == "nonexisting.dart") {
continue;
@@ -1867,9 +1870,9 @@
}
TestIncrementalCompiler(CompilerOptions options, this.entryPoint,
- [Uri initializeFrom,
- bool outlineOnly,
- IncrementalSerializer incrementalSerializer])
+ [Uri? initializeFrom,
+ bool? outlineOnly,
+ IncrementalSerializer? incrementalSerializer])
: super(
new CompilerContext(
new ProcessedOptions(options: options, inputs: [entryPoint])),
@@ -1878,8 +1881,8 @@
incrementalSerializer);
TestIncrementalCompiler.fromComponent(CompilerOptions options,
- this.entryPoint, Component componentToInitializeFrom,
- [bool outlineOnly, IncrementalSerializer incrementalSerializer])
+ this.entryPoint, Component? componentToInitializeFrom,
+ [bool? outlineOnly, IncrementalSerializer? incrementalSerializer])
: super.fromComponent(
new CompilerContext(
new ProcessedOptions(options: options, inputs: [entryPoint])),
@@ -1910,14 +1913,14 @@
@override
Future<Component> computeDelta(
- {List<Uri> entryPoints,
+ {List<Uri>? entryPoints,
bool fullComponent = false,
- bool simulateTransformer}) async {
+ bool? simulateTransformer}) async {
Component result = await super
.computeDelta(entryPoints: entryPoints, fullComponent: fullComponent);
// We should at least have the SDK builders available. Slight smoke test.
- if (!dillLoadedData.loader.builders.keys
+ if (!dillLoadedData!.loader.builders.keys
.map((uri) => uri.toString())
.contains("dart:core")) {
throw "Loaders builder should contain the sdk, "
@@ -1947,7 +1950,7 @@
isFinal: true,
getterReference: lib.reference.canonicalName
?.getChildFromFieldWithName(fieldName)
- ?.reference,
+ .reference,
fileUri: lib.fileUri);
lib.addField(field);
for (Class c in lib.classes) {
@@ -1960,7 +1963,7 @@
isFinal: true,
getterReference: c.reference.canonicalName
?.getChildFromFieldWithName(fieldName)
- ?.reference,
+ .reference,
fileUri: c.fileUri);
c.addField(field);
}
diff --git a/pkg/front_end/test/incremental_utils.dart b/pkg/front_end/test/incremental_utils.dart
index 0d7251b..b226780 100644
--- a/pkg/front_end/test/incremental_utils.dart
+++ b/pkg/front_end/test/incremental_utils.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 'dart:convert' show utf8;
import "package:front_end/src/api_prototype/file_system.dart" show FileSystem;
@@ -64,7 +62,7 @@
}
Future<void> throwOnInsufficientUriToSource(Component component,
- {FileSystem fileSystem}) async {
+ {FileSystem? fileSystem}) async {
UriFinder uriFinder = new UriFinder();
component.accept(uriFinder);
Set<Uri> uris = uriFinder.seenUris.toSet();
@@ -77,13 +75,14 @@
if (fileSystem != null) {
uris = uriFinder.seenUris.toSet();
for (Uri uri in uris) {
+ // ignore: unnecessary_null_comparison
if (uri == null) continue;
if (uri.scheme != "org-dartlang-test") continue;
// The file system doesn't have the sources for any modules.
// For now assume that that is always what's going on.
if (!await fileSystem.entityForUri(uri).exists()) continue;
List<int> expected = await fileSystem.entityForUri(uri).readAsBytes();
- List<int> actual = component.uriToSource[uri].source;
+ List<int> actual = component.uriToSource[uri]!.source;
bool fail = false;
if (expected.length != actual.length) {
fail = true;
diff --git a/pkg/front_end/test/parser_suite.dart b/pkg/front_end/test/parser_suite.dart
index 1d51206..1216380 100644
--- a/pkg/front_end/test/parser_suite.dart
+++ b/pkg/front_end/test/parser_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 file.
-// @dart = 2.9
-
import 'dart:convert' show jsonDecode;
import 'dart:io' show File;
@@ -183,12 +181,13 @@
/// Scans the uri, parses it with the test listener and returns it.
///
/// Returns null if scanner doesn't return any Token.
- static ParserTestListenerWithMessageFormatting doListenerParsing(
+ static ParserTestListenerWithMessageFormatting? doListenerParsing(
Uri uri, String suiteName, String shortName,
{bool addTrace: false, bool annotateLines: false}) {
List<int> lineStarts = <int>[];
Token firstToken = scanUri(uri, shortName, lineStarts: lineStarts);
+ // ignore: unnecessary_null_comparison
if (firstToken == null) {
return null;
}
@@ -210,7 +209,7 @@
TestDescription description, Context context) {
Uri uri = description.uri;
- ParserTestListenerWithMessageFormatting parserTestListener =
+ ParserTestListenerWithMessageFormatting? parserTestListener =
doListenerParsing(
uri,
context.suiteName,
@@ -248,6 +247,7 @@
Token firstToken =
scanUri(description.uri, description.shortName, lineStarts: lineStarts);
+ // ignore: unnecessary_null_comparison
if (firstToken == null) {
return Future.value(crash(description, StackTrace.current));
}
@@ -284,6 +284,7 @@
Token firstToken =
scanUri(description.uri, description.shortName, lineStarts: lineStarts);
+ // ignore: unnecessary_null_comparison
if (firstToken == null) {
return Future.value(crash(description, StackTrace.current));
}
@@ -305,7 +306,7 @@
useImplicitCreationExpression: useImplicitCreationExpressionInCfe);
bool parserCrashed = false;
dynamic parserCrashedE;
- StackTrace parserCrashedSt;
+ StackTrace? parserCrashedSt;
try {
parser.parseUnit(firstToken);
} catch (e, st) {
@@ -330,7 +331,7 @@
description);
return result.then((result) {
if (parserCrashed) {
- return crash("Parser crashed: $parserCrashedE", parserCrashedSt);
+ return crash("Parser crashed: $parserCrashedE", parserCrashedSt!);
} else {
return result;
}
@@ -341,9 +342,9 @@
StringBuffer tokenStreamToString(Token firstToken, List<int> lineStarts,
{bool addTypes: false}) {
StringBuffer sb = new StringBuffer();
- Token token = firstToken;
+ Token? token = firstToken;
- Token process(Token token, bool errorTokens) {
+ Token? process(Token? token, bool errorTokens) {
bool printed = false;
int endOfLast = -1;
int lineStartsIteratorLine = 1;
@@ -389,13 +390,13 @@
endOfLast = token.end;
if (token == token.next) break;
token = token.next;
- if (!seenTokens.add(token)) {
+ if (!seenTokens.add(token!)) {
// Loop in tokens: Print error and break to avoid infinite loop.
sb.write("\n\nERROR: Loop in tokens: $token "
"(${token.runtimeType}, ${token.type}, ${token.offset})) "
"was seen before "
"(linking to ${token.next}, ${token.next.runtimeType}, "
- "${token.next.type}, ${token.next.offset})!\n\n");
+ "${token.next!.type}, ${token.next!.offset})!\n\n");
break;
}
}
@@ -411,7 +412,7 @@
return sb;
}
-Token scanUri(Uri uri, String shortName, {List<int> lineStarts}) {
+Token scanUri(Uri uri, String shortName, {List<int>? lineStarts}) {
ScannerConfiguration config;
String firstDir = shortName.split("/")[0];
@@ -430,7 +431,7 @@
}
Token scanRawBytes(
- List<int> rawBytes, ScannerConfiguration config, List<int> lineStarts) {
+ List<int> rawBytes, ScannerConfiguration config, List<int>? lineStarts) {
Uint8List bytes = new Uint8List(rawBytes.length + 1);
bytes.setRange(0, rawBytes.length, rawBytes);
@@ -445,10 +446,10 @@
class ParserTestListenerWithMessageFormatting extends ParserTestListener {
final bool annotateLines;
- final Source source;
- final String shortName;
+ final Source? source;
+ final String? shortName;
final List<String> errors = <String>[];
- Location latestSeenLocation;
+ Location? latestSeenLocation;
ParserTestListenerWithMessageFormatting(
bool trace, this.annotateLines, this.source, this.shortName)
@@ -472,16 +473,17 @@
}
}
- void seen(Token token) {
+ void seen(Token? token) {
if (!annotateLines) return;
if (token == null) return;
if (source == null) return;
if (offsetForToken(token) < 0) return;
Location location =
- source.getLocation(source.fileUri, offsetForToken(token));
- if (latestSeenLocation == null || location.line > latestSeenLocation.line) {
+ source!.getLocation(source!.fileUri!, offsetForToken(token));
+ if (latestSeenLocation == null ||
+ location.line > latestSeenLocation!.line) {
latestSeenLocation = location;
- String sourceLine = source.getTextLine(location.line);
+ String? sourceLine = source!.getTextLine(location.line);
doPrint("");
doPrint("// Line ${location.line}: $sourceLine");
}
@@ -499,11 +501,11 @@
Message message, Token startToken, Token endToken) {
if (source != null) {
Location location =
- source.getLocation(source.fileUri, offsetForToken(startToken));
+ source!.getLocation(source!.fileUri!, offsetForToken(startToken));
int length = lengthOfSpan(startToken, endToken);
if (length <= 0) length = 1;
errors.add(command_line_reporting.formatErrorMessage(
- source.getTextLine(location.line),
+ source!.getTextLine(location.line),
location,
length,
shortName,
@@ -518,7 +520,7 @@
class ParserTestListenerForIntertwined
extends ParserTestListenerWithMessageFormatting {
- TestParser parser;
+ late TestParser parser;
ParserTestListenerForIntertwined(
bool trace, bool annotateLines, Source source)
diff --git a/pkg/front_end/test/testing_utils.dart b/pkg/front_end/test/testing_utils.dart
index 502ac99..f4f88d1 100644
--- a/pkg/front_end/test/testing_utils.dart
+++ b/pkg/front_end/test/testing_utils.dart
@@ -2,20 +2,18 @@
// 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 'dart:io' show Directory, Process, ProcessResult;
import 'package:testing/testing.dart' show Chain, TestDescription;
Stream<TestDescription> filterList(
Chain suite, bool onlyInGit, Stream<TestDescription> base) async* {
- Set<Uri> gitFiles;
+ Set<Uri>? gitFiles;
if (onlyInGit) {
gitFiles = await getGitFiles(suite.uri);
}
await for (TestDescription description in base) {
- if (onlyInGit && !gitFiles.contains(description.uri)) {
+ if (onlyInGit && !gitFiles!.contains(description.uri)) {
continue;
}
yield description;
diff --git a/pkg/front_end/test/utils/kernel_chain.dart b/pkg/front_end/test/utils/kernel_chain.dart
index f3d539c..f106a1a 100644
--- a/pkg/front_end/test/utils/kernel_chain.dart
+++ b/pkg/front_end/test/utils/kernel_chain.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
-
library fasta.testing.kernel_chain;
import 'dart:io' show Directory, File, IOSink, Platform;
@@ -84,7 +82,7 @@
expectationSet["ExpectationFileMissing"];
Future<Result<O>> match<O>(String suffix, String actual, Uri uri, O output,
- {Expectation onMismatch, bool overwriteUpdateExpectationsWith}) async {
+ {Expectation? onMismatch, bool? overwriteUpdateExpectationsWith}) async {
bool updateExpectations =
overwriteUpdateExpectationsWith ?? this.updateExpectations;
actual = actual.trim();
@@ -203,7 +201,8 @@
/// be serialized, deserialized, and the textual representation of that is
/// compared. It is still the original component that is returned though.
const MatchExpectation(this.suffix,
- {this.serializeFirst: false, this.isLastMatchStep})
+ {this.serializeFirst: false, required this.isLastMatchStep})
+ // ignore: unnecessary_null_comparison
: assert(isLastMatchStep != null);
String get name => "match expectations";
@@ -225,7 +224,7 @@
writeMe.uriToSource.addAll(component.uriToSource);
if (component.problemsAsJson != null) {
writeMe.problemsAsJson =
- new List<String>.from(component.problemsAsJson);
+ new List<String>.from(component.problemsAsJson!);
}
BinaryPrinter binaryPrinter = new BinaryPrinter(sink);
binaryPrinter.writeComponentFile(writeMe);
@@ -251,7 +250,7 @@
reportedErrors.add(message.join('\n'));
}
Set<String> problemsAsJson = <String>{};
- void addProblemsAsJson(List<String> problems) {
+ void addProblemsAsJson(List<String>? problems) {
if (problems != null) {
for (String jsonString in problems) {
DiagnosticMessage message =
@@ -308,7 +307,7 @@
if (!result.isUserLibraryImportUri(source.importUri)) continue;
if (source.constantCoverageConstructors != null &&
- source.constantCoverageConstructors.isNotEmpty) {
+ source.constantCoverageConstructors!.isNotEmpty) {
if (!printedConstantCoverageHeader) {
buffer.writeln("");
buffer.writeln("");
@@ -316,9 +315,9 @@
printedConstantCoverageHeader = true;
}
buffer.writeln("${source.fileUri}:");
- for (Reference reference in source.constantCoverageConstructors) {
- buffer
- .writeln("- ${reference.node} (from ${reference.node.location})");
+ for (Reference reference in source.constantCoverageConstructors!) {
+ buffer.writeln(
+ "- ${reference.node} (from ${reference.node?.location})");
}
buffer.writeln("");
}
@@ -386,13 +385,13 @@
for (RoundTripStatus failure in failures) {
LocatedMessage message = templateUnspecified
.withArguments("\n${failure}")
- .withLocation(failure.uri, failure.offset, 1);
+ .withLocation(failure.uri!, failure.offset, 1);
options.report(message, message.code.severity);
}
if (writeRoundTripStatus) {
Uri uri = component.uriToSource.keys
- .firstWhere((uri) => uri?.scheme == "file");
+ .firstWhere((uri) => uri.scheme == "file");
String filename = "${uri.toFilePath()}${suffix}";
uri = new File(filename).uri;
StringBuffer buffer = new StringBuffer();
@@ -525,7 +524,7 @@
final TestDescription description;
final Component component;
final Set<Uri> userLibraries;
- final Uri outputUri;
+ final Uri? outputUri;
final CompilationSetup compilationSetup;
final KernelTarget sourceTarget;
final List<String> extraConstantStrings = [];
@@ -538,7 +537,7 @@
return isUserLibraryImportUri(library.importUri);
}
- bool isUserLibraryImportUri(Uri importUri) {
+ bool isUserLibraryImportUri(Uri? importUri) {
return userLibraries.contains(importUri);
}
diff --git a/pkg/front_end/test/utils/scanner_chain.dart b/pkg/front_end/test/utils/scanner_chain.dart
index 635ef6d..1bf5b45 100644
--- a/pkg/front_end/test/utils/scanner_chain.dart
+++ b/pkg/front_end/test/utils/scanner_chain.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
-
library fasta.testing.scanner_chain;
import 'package:_fe_analyzer_shared/src/scanner/scanner.dart'
diff --git a/pkg/front_end/test/utils/validating_instrumentation.dart b/pkg/front_end/test/utils/validating_instrumentation.dart
index 1c1af83..ed9b70b 100644
--- a/pkg/front_end/test/utils/validating_instrumentation.dart
+++ b/pkg/front_end/test/utils/validating_instrumentation.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 'dart:convert' show utf8;
import 'dart:io' show File;
@@ -101,7 +99,7 @@
/// pairs that were observed.
Future<Null> fixSource(Uri uri, bool offsetsCountCharacters) async {
uri = Uri.base.resolveUri(uri);
- List<_Fix> fixes = _fixes[uri];
+ List<_Fix>? fixes = _fixes[uri];
if (fixes == null) return;
File file = new File.fromUri(uri);
List<int> bytes = (await file.readAsBytes()).toList();
@@ -135,9 +133,9 @@
_testedFeaturesState.putIfAbsent(uri, () => {});
List<int> tokenOffsets = _tokenOffsets.putIfAbsent(uri, () => []);
ScannerResult result = scan(bytes, includeComments: true);
- for (Token token = result.tokens; !token.isEof; token = token.next) {
+ for (Token token = result.tokens; !token.isEof; token = token.next!) {
tokenOffsets.add(token.offset);
- for (analyzer.Token commentToken = token.precedingComments;
+ for (analyzer.Token? commentToken = token.precedingComments;
commentToken != null;
commentToken = commentToken.next) {
String lexeme = commentToken.lexeme;
@@ -153,7 +151,7 @@
property = expectation.substring(0, equals);
value = expectation
.substring(equals + 1)
- .replaceAllMapped(_ESCAPE_SEQUENCE, (m) => m.group(1));
+ .replaceAllMapped(_ESCAPE_SEQUENCE, (m) => m.group(1)!);
}
property = property.trim();
value = value.trim();
@@ -185,11 +183,11 @@
if (offset == -1) {
throw _formatProblem(uri, 0, 'No offset for $property=$value', null);
}
- Map<int, List<_Expectation>> expectationsForUri =
+ Map<int, List<_Expectation>>? expectationsForUri =
_unsatisfiedExpectations[uri];
if (expectationsForUri == null) return;
- offset = _normalizeOffset(offset, _tokenOffsets[uri]);
- List<_Expectation> expectationsAtOffset = expectationsForUri[offset];
+ offset = _normalizeOffset(offset, _tokenOffsets[uri]!);
+ List<_Expectation>? expectationsAtOffset = expectationsForUri[offset];
if (expectationsAtOffset != null) {
for (int i = 0; i < expectationsAtOffset.length; i++) {
_Expectation expectation = expectationsAtOffset[i];
@@ -227,7 +225,7 @@
}
String _formatProblem(
- Uri uri, int offset, String desc, StackTrace stackTrace) {
+ Uri uri, int offset, String desc, StackTrace? stackTrace) {
return CompilerContext.current
.format(
templateUnspecified
@@ -285,11 +283,12 @@
bool _shouldCheck(String property, Uri uri, int offset) {
bool state = false;
- Map<int, Set<String>> testedFeaturesStateForUri = _testedFeaturesState[uri];
+ Map<int, Set<String>>? testedFeaturesStateForUri =
+ _testedFeaturesState[uri];
if (testedFeaturesStateForUri == null) return false;
for (int i in testedFeaturesStateForUri.keys) {
if (i > offset) break;
- Set<String> testedFeaturesStateAtOffset = testedFeaturesStateForUri[i];
+ Set<String> testedFeaturesStateAtOffset = testedFeaturesStateForUri[i]!;
state = testedFeaturesStateAtOffset.contains(property);
}
return state;
diff --git a/pkg/front_end/testcases/general/issue_46886.dart b/pkg/front_end/testcases/general/issue_46886.dart
new file mode 100644
index 0000000..16425ef
--- /dev/null
+++ b/pkg/front_end/testcases/general/issue_46886.dart
@@ -0,0 +1,32 @@
+// Copyright (c) 2021, 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.13
+
+class Foo {
+ Foo operator >>>(_) => this;
+}
+
+extension on Symbol {
+ String operator >(_) => "Greater Than used";
+ String call(_) => "Called";
+}
+
+abstract class Bar implements List<List<List<String>>> {}
+
+main() {
+ Foo foo = new Foo();
+ foo >>> 42;
+ print(foo >>> 42);
+ print(foo >>>= 42);
+ if ((foo >>>= 42) == foo) {
+ print("same");
+ }
+
+ print(#>>>(2));
+ print(#>>>);
+
+ var x = 10 >>> 2;
+ print('x: $x');
+}
diff --git a/pkg/front_end/testcases/general/issue_46886.dart.textual_outline.expect b/pkg/front_end/testcases/general/issue_46886.dart.textual_outline.expect
new file mode 100644
index 0000000..8d133e3
--- /dev/null
+++ b/pkg/front_end/testcases/general/issue_46886.dart.textual_outline.expect
@@ -0,0 +1,13 @@
+// @dart = 2.13
+class Foo {
+ Foo operator >>>(_) => this;
+}
+
+extension on Symbol {
+ String operator >(_) => "Greater Than used";
+ String call(_) => "Called";
+}
+
+abstract class Bar implements List<List<List<String>>> {}
+
+main() {}
diff --git a/pkg/front_end/testcases/general/issue_46886.dart.textual_outline_modelled.expect b/pkg/front_end/testcases/general/issue_46886.dart.textual_outline_modelled.expect
new file mode 100644
index 0000000..dab65d1
--- /dev/null
+++ b/pkg/front_end/testcases/general/issue_46886.dart.textual_outline_modelled.expect
@@ -0,0 +1,13 @@
+// @dart = 2.13
+abstract class Bar implements List<List<List<String>>> {}
+
+class Foo {
+ Foo operator >>>(_) => this;
+}
+
+extension on Symbol {
+ String call(_) => "Called";
+ String operator >(_) => "Greater Than used";
+}
+
+main() {}
diff --git a/pkg/front_end/testcases/general/issue_46886.dart.weak.expect b/pkg/front_end/testcases/general/issue_46886.dart.weak.expect
new file mode 100644
index 0000000..e64cce5
--- /dev/null
+++ b/pkg/front_end/testcases/general/issue_46886.dart.weak.expect
@@ -0,0 +1,84 @@
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/general/issue_46886.dart:8:16: Error: This requires the 'triple-shift' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.14 or higher, and running 'pub get'.
+// Foo operator >>>(_) => this;
+// ^^^
+//
+// pkg/front_end/testcases/general/issue_46886.dart:20:7: Error: This requires the 'triple-shift' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.14 or higher, and running 'pub get'.
+// foo >>> 42;
+// ^^^
+//
+// pkg/front_end/testcases/general/issue_46886.dart:21:13: Error: This requires the 'triple-shift' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.14 or higher, and running 'pub get'.
+// print(foo >>> 42);
+// ^^^
+//
+// pkg/front_end/testcases/general/issue_46886.dart:22:13: Error: This requires the 'triple-shift' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.14 or higher, and running 'pub get'.
+// print(foo >>>= 42);
+// ^^^^
+//
+// pkg/front_end/testcases/general/issue_46886.dart:23:12: Error: This requires the 'triple-shift' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.14 or higher, and running 'pub get'.
+// if ((foo >>>= 42) == foo) {
+// ^^^^
+//
+// pkg/front_end/testcases/general/issue_46886.dart:28:13: Error: Expected an identifier, but got ')'.
+// Try inserting an identifier before ')'.
+// print(#>>>);
+// ^
+//
+// pkg/front_end/testcases/general/issue_46886.dart:30:14: Error: This requires the 'triple-shift' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.14 or higher, and running 'pub get'.
+// var x = 10 >>> 2;
+// ^^^
+//
+import self as self;
+import "dart:core" as core;
+
+class Foo extends core::Object {
+ synthetic constructor •() → self::Foo
+ : super core::Object::•()
+ ;
+ operator >>>(dynamic _) → self::Foo
+ return this;
+}
+abstract class Bar extends core::Object implements core::List<core::List<core::List<core::String>>> {
+ synthetic constructor •() → self::Bar
+ : super core::Object::•()
+ ;
+}
+extension _extension#0 on core::Symbol {
+ operator > = self::_extension#0|>;
+ method call = self::_extension#0|call;
+ tearoff call = self::_extension#0|get#call;
+}
+static method _extension#0|>(lowered final core::Symbol #this, dynamic _) → core::String
+ return "Greater Than used";
+static method _extension#0|call(lowered final core::Symbol #this, dynamic _) → core::String
+ return "Called";
+static method _extension#0|get#call(lowered final core::Symbol #this) → (dynamic) → core::String
+ return (dynamic _) → core::String => self::_extension#0|call(#this, _);
+static method main() → dynamic {
+ self::Foo foo = new self::Foo::•();
+ foo.{self::Foo::>>>}(42){(dynamic) → self::Foo};
+ core::print(foo.{self::Foo::>>>}(42){(dynamic) → self::Foo});
+ core::print(foo = foo.{self::Foo::>>>}(42){(dynamic) → self::Foo});
+ if((foo = foo.{self::Foo::>>>}(42){(dynamic) → self::Foo}) =={core::Object::==}{(core::Object) → core::bool} foo) {
+ core::print("same");
+ }
+ core::print(self::_extension#0|>(#C1, 2));
+ core::print(self::_extension#0|>(#C1, invalid-expression "pkg/front_end/testcases/general/issue_46886.dart:28:13: Error: This couldn't be parsed.
+ print(#>>>);
+ ^"));
+ core::int x = 10.{core::int::>>>}(2){(core::int) → core::int};
+ core::print("x: ${x}");
+}
+
+constants {
+ #C1 = #>>
+}
diff --git a/pkg/front_end/testcases/general/issue_46886.dart.weak.outline.expect b/pkg/front_end/testcases/general/issue_46886.dart.weak.outline.expect
new file mode 100644
index 0000000..73a7e48
--- /dev/null
+++ b/pkg/front_end/testcases/general/issue_46886.dart.weak.outline.expect
@@ -0,0 +1,35 @@
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/general/issue_46886.dart:8:16: Error: This requires the 'triple-shift' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.14 or higher, and running 'pub get'.
+// Foo operator >>>(_) => this;
+// ^^^
+//
+import self as self;
+import "dart:core" as core;
+
+class Foo extends core::Object {
+ synthetic constructor •() → self::Foo
+ ;
+ operator >>>(dynamic _) → self::Foo
+ ;
+}
+abstract class Bar extends core::Object implements core::List<core::List<core::List<core::String>>> {
+ synthetic constructor •() → self::Bar
+ ;
+}
+extension _extension#0 on core::Symbol {
+ operator > = self::_extension#0|>;
+ method call = self::_extension#0|call;
+ tearoff call = self::_extension#0|get#call;
+}
+static method _extension#0|>(lowered final core::Symbol #this, dynamic _) → core::String
+ ;
+static method _extension#0|call(lowered final core::Symbol #this, dynamic _) → core::String
+ ;
+static method _extension#0|get#call(lowered final core::Symbol #this) → (dynamic) → core::String
+ return (dynamic _) → core::String => self::_extension#0|call(#this, _);
+static method main() → dynamic
+ ;
diff --git a/pkg/front_end/testcases/general/issue_46886.dart.weak.transformed.expect b/pkg/front_end/testcases/general/issue_46886.dart.weak.transformed.expect
new file mode 100644
index 0000000..ab49a67
--- /dev/null
+++ b/pkg/front_end/testcases/general/issue_46886.dart.weak.transformed.expect
@@ -0,0 +1,88 @@
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/general/issue_46886.dart:8:16: Error: This requires the 'triple-shift' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.14 or higher, and running 'pub get'.
+// Foo operator >>>(_) => this;
+// ^^^
+//
+// pkg/front_end/testcases/general/issue_46886.dart:20:7: Error: This requires the 'triple-shift' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.14 or higher, and running 'pub get'.
+// foo >>> 42;
+// ^^^
+//
+// pkg/front_end/testcases/general/issue_46886.dart:21:13: Error: This requires the 'triple-shift' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.14 or higher, and running 'pub get'.
+// print(foo >>> 42);
+// ^^^
+//
+// pkg/front_end/testcases/general/issue_46886.dart:22:13: Error: This requires the 'triple-shift' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.14 or higher, and running 'pub get'.
+// print(foo >>>= 42);
+// ^^^^
+//
+// pkg/front_end/testcases/general/issue_46886.dart:23:12: Error: This requires the 'triple-shift' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.14 or higher, and running 'pub get'.
+// if ((foo >>>= 42) == foo) {
+// ^^^^
+//
+// pkg/front_end/testcases/general/issue_46886.dart:28:13: Error: Expected an identifier, but got ')'.
+// Try inserting an identifier before ')'.
+// print(#>>>);
+// ^
+//
+// pkg/front_end/testcases/general/issue_46886.dart:30:14: Error: This requires the 'triple-shift' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.14 or higher, and running 'pub get'.
+// var x = 10 >>> 2;
+// ^^^
+//
+import self as self;
+import "dart:core" as core;
+
+class Foo extends core::Object {
+ synthetic constructor •() → self::Foo
+ : super core::Object::•()
+ ;
+ operator >>>(dynamic _) → self::Foo
+ return this;
+}
+abstract class Bar extends core::Object implements core::List<core::List<core::List<core::String>>> {
+ synthetic constructor •() → self::Bar
+ : super core::Object::•()
+ ;
+}
+extension _extension#0 on core::Symbol {
+ operator > = self::_extension#0|>;
+ method call = self::_extension#0|call;
+ tearoff call = self::_extension#0|get#call;
+}
+static method _extension#0|>(lowered final core::Symbol #this, dynamic _) → core::String
+ return "Greater Than used";
+static method _extension#0|call(lowered final core::Symbol #this, dynamic _) → core::String
+ return "Called";
+static method _extension#0|get#call(lowered final core::Symbol #this) → (dynamic) → core::String
+ return (dynamic _) → core::String => self::_extension#0|call(#this, _);
+static method main() → dynamic {
+ self::Foo foo = new self::Foo::•();
+ foo.{self::Foo::>>>}(42){(dynamic) → self::Foo};
+ core::print(foo.{self::Foo::>>>}(42){(dynamic) → self::Foo});
+ core::print(foo = foo.{self::Foo::>>>}(42){(dynamic) → self::Foo});
+ if((foo = foo.{self::Foo::>>>}(42){(dynamic) → self::Foo}) =={core::Object::==}{(core::Object) → core::bool} foo) {
+ core::print("same");
+ }
+ core::print(self::_extension#0|>(#C1, 2));
+ core::print(self::_extension#0|>(#C1, invalid-expression "pkg/front_end/testcases/general/issue_46886.dart:28:13: Error: This couldn't be parsed.
+ print(#>>>);
+ ^"));
+ core::int x = 10.{core::int::>>>}(2){(core::int) → core::int};
+ core::print("x: ${x}");
+}
+
+constants {
+ #C1 = #>>
+}
+
+Extra constant evaluation status:
+Evaluated: InstanceInvocation @ org-dartlang-testcase:///issue_46886.dart:30:14 -> IntConstant(2)
+Extra constant evaluation: evaluated: 29, effectively constant: 1
diff --git a/pkg/front_end/testcases/text_serialization.status b/pkg/front_end/testcases/text_serialization.status
index dc74759..9093936 100644
--- a/pkg/front_end/testcases/text_serialization.status
+++ b/pkg/front_end/testcases/text_serialization.status
@@ -84,6 +84,7 @@
general/issue41210b/issue41210.no_link: TypeCheckError
general/issue41210b/issue41210: TypeCheckError
general/issue44733: TypeCheckError
+general/issue_46886: RuntimeError
general/micro: RuntimeError
general/mixin_application_override: TypeCheckError
general/mixin_constructors_with_default_values: RuntimeError
diff --git a/pkg/front_end/testcases/weak.status b/pkg/front_end/testcases/weak.status
index 7263971..15062a3 100644
--- a/pkg/front_end/testcases/weak.status
+++ b/pkg/front_end/testcases/weak.status
@@ -89,6 +89,7 @@
general/issue41210b/issue41210.no_link: TypeCheckError
general/issue41210b/issue41210: TypeCheckError
general/issue44733: TypeCheckError
+general/issue_46886: RuntimeError
general/micro: RuntimeError
general/mixin_application_override: ExpectationFileMismatch # Too many errors.
general/mixin_application_override: TypeCheckError
diff --git a/pkg/kernel/analysis_options.yaml b/pkg/kernel/analysis_options.yaml
index 68fdd50..d9d722e 100644
--- a/pkg/kernel/analysis_options.yaml
+++ b/pkg/kernel/analysis_options.yaml
@@ -16,4 +16,5 @@
- package_api_docs
- lines_longer_than_80_chars
- unrelated_type_equality_checks
+ - annotate_overrides
# - always_specify_types
diff --git a/pkg/kernel/bin/count_breakdown.dart b/pkg/kernel/bin/count_breakdown.dart
index 839ab42..b704879 100755
--- a/pkg/kernel/bin/count_breakdown.dart
+++ b/pkg/kernel/bin/count_breakdown.dart
@@ -28,6 +28,8 @@
class TypeCounter extends RecursiveVisitor {
Map<String, int> _typeCounts = <String, int>{};
+
+ @override
defaultNode(Node node) {
String key = node.runtimeType.toString();
_typeCounts[key] = (_typeCounts[key] ??= 0) + 1;
diff --git a/pkg/kernel/bin/size_breakdown.dart b/pkg/kernel/bin/size_breakdown.dart
index af98f8a..a5faac2 100755
--- a/pkg/kernel/bin/size_breakdown.dart
+++ b/pkg/kernel/bin/size_breakdown.dart
@@ -43,6 +43,7 @@
int constantTableSize = 0;
Map<Uri, int> librarySizes = {};
+ @override
int readOffset() {
offsetsSize -= byteOffset;
int result = super.readOffset();
@@ -50,18 +51,21 @@
return result;
}
+ @override
void readStringTable() {
stringTableSize -= byteOffset;
super.readStringTable();
stringTableSize += byteOffset;
}
+ @override
void readLinkTable(CanonicalName linkRoot) {
linkTableSize -= byteOffset;
super.readLinkTable(linkRoot);
linkTableSize += byteOffset;
}
+ @override
Map<Uri, Source> readUriToSource({required bool readCoverage}) {
uriToSourceSize -= byteOffset;
Map<Uri, Source> result = super.readUriToSource(readCoverage: readCoverage);
@@ -69,12 +73,14 @@
return result;
}
+ @override
void readConstantTable() {
constantTableSize -= byteOffset;
super.readConstantTable();
constantTableSize += byteOffset;
}
+ @override
Library readLibrary(Component component, int endOffset) {
int size = -byteOffset;
var result = super.readLibrary(component, endOffset);
diff --git a/pkg/kernel/lib/ast.dart b/pkg/kernel/lib/ast.dart
index 7edd205..99992d8 100644
--- a/pkg/kernel/lib/ast.dart
+++ b/pkg/kernel/lib/ast.dart
@@ -101,6 +101,7 @@
///
/// The data is generally bare-bones, but can easily be updated for your
/// specific debugging needs.
+ @override
String toString();
/// Returns the textual representation of this node for use in debugging.
@@ -138,6 +139,7 @@
/// This is anything other than [Name] and [DartType] nodes.
abstract class TreeNode extends Node {
static int _hashCounter = 0;
+ @override
final int hashCode = _hashCounter = (_hashCounter + 1) & 0x3fffffff;
static const int noOffset = -1;
@@ -149,8 +151,11 @@
/// not available (this is the default if none is specifically set).
int fileOffset = noOffset;
+ @override
R accept<R>(TreeVisitor<R> v);
+ @override
R accept1<R, A>(TreeVisitor1<R, A> v, A arg);
+ @override
void visitChildren(Visitor v);
void transformChildren(Transformer v);
void transformOrRemoveChildren(RemovingTransformer v);
@@ -608,10 +613,12 @@
printer.write(libraryNameToString(this));
}
+ @override
Location? _getLocationInEnclosingFile(int offset) {
return _getLocationInComponent(enclosingComponent, fileUri, offset);
}
+ @override
String leakingDebugToString() => astToText.debugLibraryToString(this);
}
@@ -1510,6 +1517,7 @@
String name;
/// The URI of the source file this class was loaded from.
+ @override
Uri fileUri;
/// Type parameters declared on the extension.
@@ -2262,6 +2270,7 @@
/// The `FunctionNode.body` is `null` or a synthesized [ConstructorInvocation]
/// of the [targetReference] constructor using the [typeArguments] and
/// [VariableGet] of the parameters.
+ @override
FunctionNode function;
RedirectingFactory(this.targetReference,
@@ -5051,6 +5060,7 @@
static const int FlagBoundsSafe = 1 << 1;
final InstanceAccessKind kind;
+ @override
Expression receiver;
@override
@@ -5224,6 +5234,7 @@
static const int FlagBoundsSafe = 1 << 1;
final InstanceAccessKind kind;
+ @override
Expression receiver;
@override
@@ -6820,6 +6831,7 @@
class FileUriExpression extends Expression implements FileUriNode {
/// The URI of the source file in which the subexpression is located.
/// Can be different from the file containing the [FileUriExpression].
+ @override
Uri fileUri;
Expression expression;
@@ -6905,6 +6917,7 @@
: (flags & ~FlagForNonNullableByDefault);
}
+ @override
DartType getStaticType(StaticTypeContext context) =>
getStaticTypeInternal(context);
@@ -7322,6 +7335,7 @@
@override
Object? get value => null;
+ @override
DartType getStaticType(StaticTypeContext context) =>
getStaticTypeInternal(context);
@@ -7434,6 +7448,7 @@
}
class ThisExpression extends Expression {
+ @override
DartType getStaticType(StaticTypeContext context) =>
getStaticTypeInternal(context);
@@ -7827,12 +7842,14 @@
return "MapEntry(${toStringInternal()})";
}
+ @override
String toText(AstTextStrategy strategy) {
AstPrinter printer = new AstPrinter(strategy);
toTextInternal(printer);
return printer.getText();
}
+ @override
void toTextInternal(AstPrinter printer) {
printer.writeExpression(key);
printer.write(': ');
@@ -10365,6 +10382,7 @@
@override
R accept<R>(DartTypeVisitor<R> v);
+ @override
R accept1<R, A>(DartTypeVisitor1<R, A> v, A arg);
@override
@@ -11020,6 +11038,7 @@
///
/// The underlying type can be extracted using [unalias].
class TypedefType extends DartType {
+ @override
final Nullability declaredNullability;
final Reference typedefReference;
final List<DartType> typeArguments;
@@ -11124,6 +11143,7 @@
class FutureOrType extends DartType {
final DartType typeArgument;
+ @override
final Nullability declaredNullability;
FutureOrType(this.typeArgument, this.declaredNullability);
@@ -11356,12 +11376,14 @@
return "NamedType(${toStringInternal()})";
}
+ @override
String toText(AstTextStrategy strategy) {
AstPrinter printer = new AstPrinter(strategy);
printer.writeNamedType(this);
return printer.getText();
}
+ @override
void toTextInternal(AstPrinter printer) {
if (isRequired) {
printer.write("required ");
@@ -12100,11 +12122,13 @@
Class get classNode => className.asClass;
+ @override
R accept<R>(Visitor<R> v) => v.visitSupertype(this);
@override
R accept1<R, A>(Visitor1<R, A> v, A arg) => v.visitSupertype(this, arg);
+ @override
visitChildren(Visitor v) {
classNode.acceptReference(v);
visitList(typeArguments, v);
@@ -12114,6 +12138,7 @@
return new InterfaceType(classNode, Nullability.legacy, typeArguments);
}
+ @override
bool operator ==(Object other) {
if (identical(this, other)) return true;
if (other is Supertype) {
@@ -12128,6 +12153,7 @@
}
}
+ @override
int get hashCode {
int hash = 0x3fffffff & className.hashCode;
for (int i = 0; i < typeArguments.length; ++i) {
@@ -12663,6 +12689,7 @@
Class get classNode => classReference.asClass;
+ @override
visitChildren(Visitor v) {
classReference.asClass.acceptReference(v);
visitList(typeArguments, v);
@@ -12674,6 +12701,7 @@
}
}
+ @override
R accept<R>(ConstantVisitor<R> v) => v.visitInstanceConstant(this);
@override
@@ -12894,13 +12922,16 @@
@override
String toString() => 'ConstructorTearOffConstant(${toStringInternal()})';
+ @override
int get hashCode => targetReference.hashCode;
+ @override
bool operator ==(Object other) {
return other is ConstructorTearOffConstant &&
other.targetReference == targetReference;
}
+ @override
FunctionType getType(StaticTypeContext context) {
return function.computeFunctionType(context.nonNullable);
}
@@ -12953,13 +12984,16 @@
String toString() =>
'RedirectingFactoryTearOffConstant(${toStringInternal()})';
+ @override
int get hashCode => targetReference.hashCode;
+ @override
bool operator ==(Object other) {
return other is RedirectingFactoryTearOffConstant &&
other.targetReference == targetReference;
}
+ @override
FunctionType getType(StaticTypeContext context) {
return function.computeFunctionType(context.nonNullable);
}
@@ -12970,6 +13004,7 @@
final TearOffConstant tearOffConstant;
final List<DartType> types;
+ @override
late final int hashCode = _computeHashCode();
TypedefTearOffConstant(this.parameters, this.tearOffConstant, this.types);
@@ -13006,6 +13041,7 @@
@override
String toString() => 'TypedefTearOffConstant(${toStringInternal()})';
+ @override
bool operator ==(Object other) {
if (other is! TypedefTearOffConstant) return false;
if (other.tearOffConstant != tearOffConstant) return false;
@@ -13044,6 +13080,7 @@
return hash;
}
+ @override
DartType getType(StaticTypeContext context) {
FunctionType type = tearOffConstant.getType(context) as FunctionType;
FreshTypeParameters freshTypeParameters =
@@ -13101,6 +13138,7 @@
return other is TypeLiteralConstant && other.type == type;
}
+ @override
DartType getType(StaticTypeContext context) =>
context.typeEnvironment.coreTypes.typeRawType(context.nonNullable);
}
@@ -13132,6 +13170,7 @@
R acceptReference1<R, A>(Visitor1<R, A> v, A arg) =>
v.visitUnevaluatedConstantReference(this, arg);
+ @override
DartType getType(StaticTypeContext context) =>
expression.getStaticType(context);
@@ -13339,6 +13378,7 @@
// TODO(johnniwinther): Implement this.
}
+ @override
String leakingDebugToString() => astToText.debugComponentToString(this);
}
@@ -13351,6 +13391,7 @@
Location(this.file, this.line, this.column);
+ @override
String toString() => '$file:$line:$column';
}
diff --git a/pkg/kernel/lib/binary/ast_from_binary.dart b/pkg/kernel/lib/binary/ast_from_binary.dart
index 5cc6168..87e536d 100644
--- a/pkg/kernel/lib/binary/ast_from_binary.dart
+++ b/pkg/kernel/lib/binary/ast_from_binary.dart
@@ -21,6 +21,7 @@
ParseError(this.message,
{required this.filename, required this.byteIndex, required this.path});
+ @override
String toString() => '$filename:$byteIndex: $message at $path';
}
@@ -30,6 +31,7 @@
InvalidKernelVersionError(this.filename, this.version);
+ @override
String toString() {
StringBuffer sb = new StringBuffer();
sb.write('Unexpected Kernel Format Version ${version} '
@@ -46,6 +48,7 @@
InvalidKernelSdkVersionError(this.version);
+ @override
String toString() {
return 'Unexpected Kernel SDK Version ${version} '
'(expected ${expectedSdkHash}).';
@@ -57,6 +60,7 @@
CompilationModeError(this.message);
+ @override
String toString() => "CompilationModeError[$message]";
}
diff --git a/pkg/kernel/lib/binary/ast_to_binary.dart b/pkg/kernel/lib/binary/ast_to_binary.dart
index 35857eb..c8df796 100644
--- a/pkg/kernel/lib/binary/ast_to_binary.dart
+++ b/pkg/kernel/lib/binary/ast_to_binary.dart
@@ -83,15 +83,18 @@
return index!;
}
+ @override
void writeByte(int byte) {
assert((byte & 0xFF) == byte);
_sink.addByte(byte);
}
+ @override
void writeBytes(List<int> bytes) {
_sink.addBytes(bytes);
}
+ @override
@pragma("vm:prefer-inline")
void writeUInt30(int value) {
assert(value >= 0 && value >> 30 == 0);
@@ -105,16 +108,19 @@
}
}
+ @override
void writeUInt32(int value) {
_sink.addByte4((value >> 24) & 0xFF, (value >> 16) & 0xFF,
(value >> 8) & 0xFF, value & 0xFF);
}
+ @override
void writeByteList(List<int> bytes) {
writeUInt30(bytes.length);
writeBytes(bytes);
}
+ @override
int getBufferOffset() {
return _sink.offset;
}
@@ -166,6 +172,7 @@
}
}
+ @override
void writeStringReference(String string) {
writeUInt30(stringIndexer.put(string));
}
@@ -174,6 +181,7 @@
writeList(strings, writeStringReference);
}
+ @override
void writeConstantReference(Constant constant) {
writeUInt30(_constantIndexer.put(constant));
}
@@ -296,6 +304,7 @@
_typeParameterIndexer = oldTypeParameterIndexer;
}
+ @override
void writeDartType(DartType type) {
type.accept(this);
}
@@ -413,6 +422,7 @@
}
}
+ @override
void writeNode(Node node) {
if (_metadataSubsections != null) {
_writeNodeMetadata(node);
@@ -951,6 +961,7 @@
_canonicalNameList.add(node);
}
+ @override
void writeNullAllowedCanonicalNameReference(CanonicalName? name) {
if (name == null) {
writeUInt30(0);
@@ -999,6 +1010,7 @@
writeNonNullCanonicalNameReference(getCanonicalNameOfClass(class_));
}
+ @override
void writeName(Name node) {
if (_metadataSubsections != null) {
_writeNodeMetadata(node);
@@ -1119,6 +1131,7 @@
writeNodeList(node.combinators);
}
+ @override
void visitCombinator(Combinator node) {
writeByte(node.isShow ? 1 : 0);
writeStringReferenceList(node.names);
@@ -1140,6 +1153,7 @@
writeStringReference(node.partUri);
}
+ @override
void visitTypedef(Typedef node) {
enterScope(memberScope: true);
writeNonNullCanonicalNameReference(getCanonicalNameOfTypedef(node));
@@ -2843,6 +2857,7 @@
return index[constant] = newIndex;
}
+ @override
defaultConstantReference(Constant node) {
put(node);
}
diff --git a/pkg/kernel/lib/canonical_name.dart b/pkg/kernel/lib/canonical_name.dart
index 6d7bd11..bd151c1 100644
--- a/pkg/kernel/lib/canonical_name.dart
+++ b/pkg/kernel/lib/canonical_name.dart
@@ -263,6 +263,7 @@
}
}
+ @override
String toString() => _parent == null ? 'root' : '$parent::$name';
String toStringInternal() {
if (isRoot) return "";
@@ -438,6 +439,7 @@
_node = node;
}
+ @override
String toString() {
return "Reference to ${toStringInternal()}";
}
@@ -597,12 +599,14 @@
CanonicalNameError(this.message);
+ @override
String toString() => 'CanonicalNameError: $message';
}
class CanonicalNameSdkError extends CanonicalNameError {
CanonicalNameSdkError(String message) : super(message);
+ @override
String toString() => 'CanonicalNameSdkError: $message';
}
diff --git a/pkg/kernel/lib/class_hierarchy.dart b/pkg/kernel/lib/class_hierarchy.dart
index f66182a..43368ec 100644
--- a/pkg/kernel/lib/class_hierarchy.dart
+++ b/pkg/kernel/lib/class_hierarchy.dart
@@ -454,11 +454,13 @@
/// Implementation of [ClassHierarchy] for closed world.
class ClosedWorldClassHierarchy implements ClassHierarchy {
+ @override
CoreTypes coreTypes;
late HandleAmbiguousSupertypes _onAmbiguousSupertypes;
late HandleAmbiguousSupertypes _onAmbiguousSupertypesNotWrapped;
MixinInferrer? mixinInferrer;
+ @override
void set onAmbiguousSupertypes(
HandleAmbiguousSupertypes onAmbiguousSupertypes) {
_onAmbiguousSupertypesNotWrapped = onAmbiguousSupertypes;
@@ -512,6 +514,7 @@
allBetsOff = false;
}
+ @override
final Set<Library> knownLibraries = new Set<Library>();
bool allBetsOff = false;
@@ -1702,6 +1705,7 @@
final Set<Class> _classes;
ClassSet(this._classes);
+ @override
bool contains(Object? class_) {
return _classes.contains(class_);
}
diff --git a/pkg/kernel/lib/clone.dart b/pkg/kernel/lib/clone.dart
index 4cc9711..257a3ed 100644
--- a/pkg/kernel/lib/clone.dart
+++ b/pkg/kernel/lib/clone.dart
@@ -57,30 +57,37 @@
return _variables[variable] = clone;
}
+ @override
TreeNode visitLibrary(Library node) {
throw 'Cloning of libraries is not implemented';
}
+ @override
TreeNode visitClass(Class node) {
throw 'Cloning of classes is not implemented';
}
+ @override
TreeNode visitExtension(Extension node) {
throw 'Cloning of extensions is not implemented';
}
+ @override
TreeNode visitConstructor(Constructor node) {
throw 'Cloning of constructors is not implemented here';
}
+ @override
TreeNode visitProcedure(Procedure node) {
throw 'Cloning of procedures is not implemented here';
}
+ @override
TreeNode visitField(Field node) {
throw 'Cloning of fields is not implemented here';
}
+ @override
TreeNode visitRedirectingFactory(RedirectingFactory node) {
throw 'Cloning of redirecting factory constructors is not implemented here';
}
@@ -151,92 +158,111 @@
return type == null ? null : substitute(type, typeSubstitution);
}
+ @override
visitInvalidExpression(InvalidExpression node) {
return new InvalidExpression(
node.message, node.expression != null ? clone(node.expression!) : null);
}
+ @override
visitVariableGet(VariableGet node) {
return new VariableGet(
getVariableClone(node.variable)!, visitOptionalType(node.promotedType));
}
+ @override
visitVariableSet(VariableSet node) {
return new VariableSet(getVariableClone(node.variable)!, clone(node.value));
}
+ @override
visitSuperPropertyGet(SuperPropertyGet node) {
return new SuperPropertyGet.byReference(
node.name, node.interfaceTargetReference);
}
+ @override
visitSuperPropertySet(SuperPropertySet node) {
return new SuperPropertySet.byReference(
node.name, clone(node.value), node.interfaceTargetReference);
}
+ @override
visitStaticGet(StaticGet node) {
return new StaticGet.byReference(node.targetReference);
}
+ @override
visitStaticSet(StaticSet node) {
return new StaticSet.byReference(node.targetReference, clone(node.value));
}
+ @override
visitSuperMethodInvocation(SuperMethodInvocation node) {
return new SuperMethodInvocation.byReference(
node.name, clone(node.arguments), node.interfaceTargetReference);
}
+ @override
visitStaticInvocation(StaticInvocation node) {
return new StaticInvocation.byReference(
node.targetReference, clone(node.arguments),
isConst: node.isConst);
}
+ @override
visitConstructorInvocation(ConstructorInvocation node) {
return new ConstructorInvocation.byReference(
node.targetReference, clone(node.arguments),
isConst: node.isConst);
}
+ @override
visitNot(Not node) {
return new Not(clone(node.operand));
}
+ @override
visitNullCheck(NullCheck node) {
return new NullCheck(clone(node.operand));
}
+ @override
visitLogicalExpression(LogicalExpression node) {
return new LogicalExpression(
clone(node.left), node.operatorEnum, clone(node.right));
}
+ @override
visitConditionalExpression(ConditionalExpression node) {
return new ConditionalExpression(clone(node.condition), clone(node.then),
clone(node.otherwise), visitType(node.staticType));
}
+ @override
visitStringConcatenation(StringConcatenation node) {
return new StringConcatenation(node.expressions.map(clone).toList());
}
+ @override
visitListConcatenation(ListConcatenation node) {
return new ListConcatenation(node.lists.map(clone).toList(),
typeArgument: visitType(node.typeArgument));
}
+ @override
visitSetConcatenation(SetConcatenation node) {
return new SetConcatenation(node.sets.map(clone).toList(),
typeArgument: visitType(node.typeArgument));
}
+ @override
visitMapConcatenation(MapConcatenation node) {
return new MapConcatenation(node.maps.map(clone).toList(),
keyType: visitType(node.keyType), valueType: visitType(node.valueType));
}
+ @override
visitInstanceCreation(InstanceCreation node) {
final Map<Reference, Expression> fieldValues = <Reference, Expression>{};
node.fieldValues.forEach((Reference fieldRef, Expression value) {
@@ -250,50 +276,61 @@
node.unusedArguments.map(clone).toList());
}
+ @override
visitFileUriExpression(FileUriExpression node) {
return new FileUriExpression(clone(node.expression), _activeFileUri!);
}
+ @override
visitIsExpression(IsExpression node) {
return new IsExpression(clone(node.operand), visitType(node.type))
..flags = node.flags;
}
+ @override
visitAsExpression(AsExpression node) {
return new AsExpression(clone(node.operand), visitType(node.type))
..flags = node.flags;
}
+ @override
visitSymbolLiteral(SymbolLiteral node) {
return new SymbolLiteral(node.value);
}
+ @override
visitTypeLiteral(TypeLiteral node) {
return new TypeLiteral(visitType(node.type));
}
+ @override
visitThisExpression(ThisExpression node) {
return new ThisExpression();
}
+ @override
visitRethrow(Rethrow node) {
return new Rethrow();
}
+ @override
visitThrow(Throw node) {
return new Throw(clone(node.expression));
}
+ @override
visitListLiteral(ListLiteral node) {
return new ListLiteral(node.expressions.map(clone).toList(),
typeArgument: visitType(node.typeArgument), isConst: node.isConst);
}
+ @override
visitSetLiteral(SetLiteral node) {
return new SetLiteral(node.expressions.map(clone).toList(),
typeArgument: visitType(node.typeArgument), isConst: node.isConst);
}
+ @override
visitMapLiteral(MapLiteral node) {
return new MapLiteral(node.entries.map(clone).toList(),
keyType: visitType(node.keyType),
@@ -301,69 +338,85 @@
isConst: node.isConst);
}
+ @override
visitMapLiteralEntry(MapLiteralEntry node) {
return new MapLiteralEntry(clone(node.key), clone(node.value));
}
+ @override
visitAwaitExpression(AwaitExpression node) {
return new AwaitExpression(clone(node.operand));
}
+ @override
visitFunctionExpression(FunctionExpression node) {
return new FunctionExpression(clone(node.function));
}
+ @override
visitConstantExpression(ConstantExpression node) {
return new ConstantExpression(
visitConstant(node.constant), visitType(node.type));
}
+ @override
visitStringLiteral(StringLiteral node) {
return new StringLiteral(node.value);
}
+ @override
visitIntLiteral(IntLiteral node) {
return new IntLiteral(node.value);
}
+ @override
visitDoubleLiteral(DoubleLiteral node) {
return new DoubleLiteral(node.value);
}
+ @override
visitBoolLiteral(BoolLiteral node) {
return new BoolLiteral(node.value);
}
+ @override
visitNullLiteral(NullLiteral node) {
return new NullLiteral();
}
+ @override
visitLet(Let node) {
VariableDeclaration newVariable = clone(node.variable);
return new Let(newVariable, clone(node.body));
}
+ @override
visitBlockExpression(BlockExpression node) {
return new BlockExpression(clone(node.body), clone(node.value));
}
+ @override
visitExpressionStatement(ExpressionStatement node) {
return new ExpressionStatement(clone(node.expression));
}
+ @override
visitBlock(Block node) {
return new Block(node.statements.map(clone).toList())
..fileEndOffset = _cloneFileOffset(node.fileEndOffset);
}
+ @override
visitAssertBlock(AssertBlock node) {
return new AssertBlock(node.statements.map(clone).toList());
}
+ @override
visitEmptyStatement(EmptyStatement node) {
return new EmptyStatement();
}
+ @override
visitAssertStatement(AssertStatement node) {
return new AssertStatement(clone(node.condition),
conditionStartOffset: node.conditionStartOffset,
@@ -371,6 +424,7 @@
message: cloneOptional(node.message));
}
+ @override
visitLabeledStatement(LabeledStatement node) {
LabeledStatement newNode = new LabeledStatement(null);
labels[node] = newNode;
@@ -378,24 +432,29 @@
return newNode;
}
+ @override
visitBreakStatement(BreakStatement node) {
return new BreakStatement(labels[node.target]!);
}
+ @override
visitWhileStatement(WhileStatement node) {
return new WhileStatement(clone(node.condition), clone(node.body));
}
+ @override
visitDoStatement(DoStatement node) {
return new DoStatement(clone(node.body), clone(node.condition));
}
+ @override
visitForStatement(ForStatement node) {
List<VariableDeclaration> variables = node.variables.map(clone).toList();
return new ForStatement(variables, cloneOptional(node.condition),
node.updates.map(clone).toList(), clone(node.body));
}
+ @override
visitForInStatement(ForInStatement node) {
VariableDeclaration newVariable = clone(node.variable);
return new ForInStatement(
@@ -404,6 +463,7 @@
..bodyOffset = node.bodyOffset;
}
+ @override
visitSwitchStatement(SwitchStatement node) {
for (SwitchCase switchCase in node.cases) {
switchCases[switchCase] = new SwitchCase(
@@ -416,30 +476,36 @@
clone(node.expression), node.cases.map(clone).toList());
}
+ @override
visitSwitchCase(SwitchCase node) {
SwitchCase switchCase = switchCases[node]!;
switchCase.body = clone(node.body)..parent = switchCase;
return switchCase;
}
+ @override
visitContinueSwitchStatement(ContinueSwitchStatement node) {
return new ContinueSwitchStatement(switchCases[node.target]!);
}
+ @override
visitIfStatement(IfStatement node) {
return new IfStatement(
clone(node.condition), clone(node.then), cloneOptional(node.otherwise));
}
+ @override
visitReturnStatement(ReturnStatement node) {
return new ReturnStatement(cloneOptional(node.expression));
}
+ @override
visitTryCatch(TryCatch node) {
return new TryCatch(clone(node.body), node.catches.map(clone).toList(),
isSynthetic: node.isSynthetic);
}
+ @override
visitCatch(Catch node) {
VariableDeclaration? newException = cloneOptional(node.exception);
VariableDeclaration? newStackTrace = cloneOptional(node.stackTrace);
@@ -447,14 +513,17 @@
stackTrace: newStackTrace, guard: visitType(node.guard));
}
+ @override
visitTryFinally(TryFinally node) {
return new TryFinally(clone(node.body), clone(node.finalizer));
}
+ @override
visitYieldStatement(YieldStatement node) {
return new YieldStatement(clone(node.expression))..flags = node.flags;
}
+ @override
visitVariableDeclaration(VariableDeclaration node) {
return setVariableClone(
node,
@@ -468,6 +537,7 @@
..fileEqualsOffset = _cloneFileOffset(node.fileEqualsOffset));
}
+ @override
visitFunctionDeclaration(FunctionDeclaration node) {
VariableDeclaration newVariable = clone(node.variable);
// Create the declaration before cloning the body to support recursive
@@ -491,6 +561,7 @@
}
}
+ @override
TypeParameter visitTypeParameter(TypeParameter node) {
TypeParameter newNode = typeParams[node]!;
newNode.bound = visitType(node.bound);
@@ -515,6 +586,7 @@
}
}
+ @override
visitFunctionNode(FunctionNode node) {
prepareTypeParameters(node.typeParameters);
List<TypeParameter> typeParameters =
@@ -533,97 +605,119 @@
..fileEndOffset = _cloneFileOffset(node.fileEndOffset);
}
+ @override
visitArguments(Arguments node) {
return new Arguments(node.positional.map(clone).toList(),
types: node.types.map(visitType).toList(),
named: node.named.map(clone).toList());
}
+ @override
visitNamedExpression(NamedExpression node) {
return new NamedExpression(node.name, clone(node.value));
}
+ @override
defaultBasicLiteral(BasicLiteral node) {
return defaultExpression(node);
}
+ @override
defaultExpression(Expression node) {
throw 'Unimplemented clone for Kernel expression: $node';
}
+ @override
defaultInitializer(Initializer node) {
throw 'Unimplemented clone for Kernel initializer: $node';
}
+ @override
defaultMember(Member node) {
throw 'Unimplemented clone for Kernel member: $node';
}
+ @override
defaultStatement(Statement node) {
throw 'Unimplemented clone for Kernel statement: $node';
}
+ @override
defaultTreeNode(TreeNode node) {
throw 'Cloning Kernel non-members is not supported. '
'Tried cloning $node';
}
+ @override
visitAssertInitializer(AssertInitializer node) {
return new AssertInitializer(clone(node.statement));
}
+ @override
visitCheckLibraryIsLoaded(CheckLibraryIsLoaded node) {
return new CheckLibraryIsLoaded(node.import);
}
+ @override
visitCombinator(Combinator node) {
return defaultTreeNode(node);
}
+ @override
visitFieldInitializer(FieldInitializer node) {
return new FieldInitializer.byReference(
node.fieldReference, clone(node.value));
}
+ @override
visitInstantiation(Instantiation node) {
return new Instantiation(
clone(node.expression), node.typeArguments.map(visitType).toList());
}
+ @override
visitInvalidInitializer(InvalidInitializer node) {
return new InvalidInitializer();
}
+ @override
visitLibraryDependency(LibraryDependency node) {
return defaultTreeNode(node);
}
+ @override
visitLibraryPart(LibraryPart node) {
return defaultTreeNode(node);
}
+ @override
visitLoadLibrary(LoadLibrary node) {
return new LoadLibrary(node.import);
}
+ @override
visitLocalInitializer(LocalInitializer node) {
return new LocalInitializer(clone(node.variable));
}
+ @override
visitComponent(Component node) {
return defaultTreeNode(node);
}
+ @override
visitRedirectingInitializer(RedirectingInitializer node) {
return new RedirectingInitializer.byReference(
node.targetReference, clone(node.arguments));
}
+ @override
visitSuperInitializer(SuperInitializer node) {
return new SuperInitializer.byReference(
node.targetReference, clone(node.arguments));
}
+ @override
visitTypedef(Typedef node) {
return defaultTreeNode(node);
}
@@ -756,6 +850,7 @@
typeParams: typeParams,
cloneAnnotations: cloneAnnotations);
+ @override
@Deprecated("When cloning with members one should use the specific cloneX")
T clone<T extends TreeNode>(T node) {
return super.clone(node);
diff --git a/pkg/kernel/lib/import_table.dart b/pkg/kernel/lib/import_table.dart
index bf9f7d5..deffa5d 100644
--- a/pkg/kernel/lib/import_table.dart
+++ b/pkg/kernel/lib/import_table.dart
@@ -19,6 +19,7 @@
}
}
+ @override
int getImportIndex(Library library) => _libraryIndex[library] ?? -1;
}
@@ -51,6 +52,7 @@
}
/// Returns the index of the given import, or -1 if not found.
+ @override
int getImportIndex(Library library) {
return _libraryIndex[library] ?? -1;
}
@@ -103,10 +105,12 @@
}
}
+ @override
visitClassReference(Class node) {
addLibraryImport(node.enclosingLibrary);
}
+ @override
visitLibrary(Library node) {
super.visitLibrary(node);
for (Reference exportedReference in node.additionalExports) {
@@ -114,10 +118,12 @@
}
}
+ @override
defaultMemberReference(Member node) {
addLibraryImport(node.enclosingLibrary);
}
+ @override
visitName(Name name) {
if (name.library != null) {
addLibraryImport(name.library);
diff --git a/pkg/kernel/lib/reference_from_index.dart b/pkg/kernel/lib/reference_from_index.dart
index 0e83da3..1c93f7c 100644
--- a/pkg/kernel/lib/reference_from_index.dart
+++ b/pkg/kernel/lib/reference_from_index.dart
@@ -79,6 +79,7 @@
final Map<String, IndexedClass> _indexedClasses =
new Map<String, IndexedClass>();
final Map<String, Extension> _extensions = new Map<String, Extension>();
+ @override
final Library library;
IndexedLibrary(this.library) {
@@ -112,6 +113,7 @@
class IndexedClass extends IndexedContainer {
final Class cls;
final Map<Name, Member> _constructors = new Map<Name, Member>();
+ @override
final Library library;
IndexedClass._(this.cls, this.library) {
diff --git a/pkg/kernel/lib/src/bounds_checks.dart b/pkg/kernel/lib/src/bounds_checks.dart
index 68ad9bb..31bdf1c 100644
--- a/pkg/kernel/lib/src/bounds_checks.dart
+++ b/pkg/kernel/lib/src/bounds_checks.dart
@@ -15,6 +15,7 @@
import 'legacy_erasure.dart';
class TypeVariableGraph extends Graph<int> {
+ @override
late List<int> vertices;
List<TypeParameter> typeParameters;
List<DartType> bounds;
@@ -50,6 +51,7 @@
}
}
+ @override
Iterable<int> neighborsOf(int index) {
return edges[index];
}
@@ -67,22 +69,28 @@
node.type.accept(this);
}
+ @override
void visitInvalidType(InvalidType node);
+ @override
void visitDynamicType(DynamicType node);
+ @override
void visitVoidType(VoidType node);
+ @override
void visitInterfaceType(InterfaceType node) {
for (DartType argument in node.typeArguments) {
argument.accept(this);
}
}
+ @override
void visitTypedefType(TypedefType node) {
for (DartType argument in node.typeArguments) {
argument.accept(this);
}
}
+ @override
void visitFunctionType(FunctionType node) {
for (TypeParameter typeParameter in node.typeParameters) {
typeParameter.bound.accept(this);
@@ -97,6 +105,7 @@
node.returnType.accept(this);
}
+ @override
void visitTypeParameterType(TypeParameterType node) {
if (typeParameters.contains(node.parameter)) {
occurred.add(node.parameter);
@@ -249,6 +258,7 @@
this.index, this.argument, this.typeParameter, this.enclosingType,
{this.invertedType, this.isGenericTypeAsArgumentIssue = false});
+ @override
int get hashCode {
int hash = 0x3fffffff & index;
hash = 0x3fffffff & (hash * 31 + (hash ^ argument.hashCode));
@@ -257,6 +267,7 @@
return hash;
}
+ @override
bool operator ==(Object other) {
assert(other is TypeArgumentIssue);
return other is TypeArgumentIssue &&
@@ -266,6 +277,7 @@
enclosingType == other.enclosingType;
}
+ @override
String toString() {
return "TypeArgumentIssue(index=${index}, argument=${argument}, "
"typeParameter=${typeParameter}, enclosingType=${enclosingType}";
diff --git a/pkg/kernel/lib/src/equivalence_helpers.dart b/pkg/kernel/lib/src/equivalence_helpers.dart
index 29f6e00..a36ee07 100644
--- a/pkg/kernel/lib/src/equivalence_helpers.dart
+++ b/pkg/kernel/lib/src/equivalence_helpers.dart
@@ -13,6 +13,7 @@
/// State for visiting two AST nodes in [EquivalenceVisitor].
class NodeState extends State {
+ @override
final State? parent;
final Node a;
final Node b;
@@ -22,6 +23,7 @@
/// State for visiting an AST property in [EquivalenceVisitor]
class PropertyState extends State {
+ @override
final State? parent;
final String name;
diff --git a/pkg/kernel/lib/src/hierarchy_based_type_environment.dart b/pkg/kernel/lib/src/hierarchy_based_type_environment.dart
index 58186dd..65894ac 100644
--- a/pkg/kernel/lib/src/hierarchy_based_type_environment.dart
+++ b/pkg/kernel/lib/src/hierarchy_based_type_environment.dart
@@ -13,6 +13,7 @@
import '../type_environment.dart' show TypeEnvironment;
class HierarchyBasedTypeEnvironment extends TypeEnvironment {
+ @override
final ClassHierarchyBase hierarchy;
HierarchyBasedTypeEnvironment(CoreTypes coreTypes, this.hierarchy)
diff --git a/pkg/kernel/lib/src/legacy_erasure.dart b/pkg/kernel/lib/src/legacy_erasure.dart
index 316a701..a17f78b 100644
--- a/pkg/kernel/lib/src/legacy_erasure.dart
+++ b/pkg/kernel/lib/src/legacy_erasure.dart
@@ -51,6 +51,7 @@
class _LegacyErasure extends ReplacementVisitor {
const _LegacyErasure();
+ @override
Nullability? visitNullability(DartType node) {
if (node.declaredNullability != Nullability.legacy) {
return Nullability.legacy;
diff --git a/pkg/kernel/lib/src/tool/find_referenced_libraries.dart b/pkg/kernel/lib/src/tool/find_referenced_libraries.dart
index 9846b9b..dca5f78 100644
--- a/pkg/kernel/lib/src/tool/find_referenced_libraries.dart
+++ b/pkg/kernel/lib/src/tool/find_referenced_libraries.dart
@@ -23,6 +23,7 @@
class _LibraryCollector extends RecursiveVisitor {
Set<Library> allSeenLibraries = {};
+ @override
void defaultNode(Node node) {
if (node is NamedNode) {
// Named nodes can be linked to.
@@ -35,6 +36,7 @@
super.defaultNode(node);
}
+ @override
void defaultMemberReference(Member node) {
seen(node);
super.defaultMemberReference(node);
diff --git a/pkg/kernel/lib/src/types.dart b/pkg/kernel/lib/src/types.dart
index abb2a35..b78578c 100644
--- a/pkg/kernel/lib/src/types.dart
+++ b/pkg/kernel/lib/src/types.dart
@@ -24,6 +24,7 @@
@override
CoreTypes get coreTypes => hierarchy.coreTypes;
+ @override
bool areMutualSubtypes(DartType s, DartType t, SubtypeCheckMode mode) {
IsSubtypeOf result = performNullabilityAwareMutualSubtypesCheck(s, t);
switch (mode) {
diff --git a/pkg/kernel/lib/target/targets.dart b/pkg/kernel/lib/target/targets.dart
index 55a69cd..c4062b0 100644
--- a/pkg/kernel/lib/target/targets.dart
+++ b/pkg/kernel/lib/target/targets.dart
@@ -31,6 +31,7 @@
ConstructorTearOffLowering.none,
this.enableNullSafety = false});
+ @override
bool operator ==(other) {
if (identical(this, other)) return true;
return other is TargetFlags &&
@@ -45,6 +46,7 @@
enableNullSafety == other.enableNullSafety;
}
+ @override
int get hashCode {
int hash = 485786;
hash = 0x3fffffff & (hash * 31 + (hash ^ trackWidgetCreation.hashCode));
@@ -451,6 +453,7 @@
// Configure environment defines in a target-specific way.
Map<String, String> updateEnvironmentDefines(Map<String, String> map) => map;
+ @override
String toString() => 'Target($name)';
Class? concreteListLiteralClass(CoreTypes coreTypes) => null;
@@ -474,6 +477,7 @@
}
class NoneTarget extends Target {
+ @override
final TargetFlags flags;
NoneTarget(this.flags);
diff --git a/pkg/kernel/lib/testing/type_parser.dart b/pkg/kernel/lib/testing/type_parser.dart
index f2522d3..f5d38ee 100644
--- a/pkg/kernel/lib/testing/type_parser.dart
+++ b/pkg/kernel/lib/testing/type_parser.dart
@@ -51,6 +51,7 @@
ParsedInterfaceType(this.name, this.arguments, this.parsedNullability);
+ @override
String toString() {
StringBuffer sb = new StringBuffer();
sb.write(name);
@@ -63,6 +64,7 @@
return "$sb";
}
+ @override
R accept<R, A>(Visitor<R, A> visitor, A a) {
return visitor.visitInterfaceType(this, a);
}
@@ -85,6 +87,7 @@
this.interfaces, this.callableType)
: super(name);
+ @override
String toString() {
StringBuffer sb = new StringBuffer();
sb.write("class ");
@@ -112,6 +115,7 @@
return "$sb";
}
+ @override
R accept<R, A>(Visitor<R, A> visitor, A a) {
return visitor.visitClass(this, a);
}
@@ -123,6 +127,7 @@
ParsedExtension(String name, this.typeVariables, this.onType) : super(name);
+ @override
String toString() {
StringBuffer sb = new StringBuffer();
sb.write("extension ");
@@ -138,6 +143,7 @@
return "$sb";
}
+ @override
R accept<R, A>(Visitor<R, A> visitor, A a) {
return visitor.visitExtension(this, a);
}
@@ -150,6 +156,7 @@
ParsedTypedef(String name, this.typeVariables, this.type) : super(name);
+ @override
String toString() {
StringBuffer sb = new StringBuffer();
sb.write("typedef ");
@@ -164,6 +171,7 @@
return "$sb;";
}
+ @override
R accept<R, A>(Visitor<R, A> visitor, A a) {
return visitor.visitTypedef(this, a);
}
@@ -181,6 +189,7 @@
ParsedFunctionType(this.typeVariables, this.returnType, this.arguments,
this.parsedNullability);
+ @override
String toString() {
StringBuffer sb = new StringBuffer();
if (typeVariables.isNotEmpty) {
@@ -196,14 +205,17 @@
return "$sb";
}
+ @override
R accept<R, A>(Visitor<R, A> visitor, A a) {
return visitor.visitFunctionType(this, a);
}
}
class ParsedVoidType extends ParsedType {
+ @override
String toString() => "void";
+ @override
R accept<R, A>(Visitor<R, A> visitor, A a) {
return visitor.visitVoidType(this, a);
}
@@ -216,6 +228,7 @@
ParsedTypeVariable(this.name, this.bound);
+ @override
String toString() {
if (bound == null) return name;
StringBuffer sb = new StringBuffer();
@@ -225,6 +238,7 @@
return "$sb";
}
+ @override
R accept<R, A>(Visitor<R, A> visitor, A a) {
return visitor.visitTypeVariable(this, a);
}
@@ -237,6 +251,7 @@
ParsedIntersectionType(this.a, this.b);
+ @override
String toString() {
StringBuffer sb = new StringBuffer();
sb.write(a);
@@ -245,6 +260,7 @@
return "$sb";
}
+ @override
R accept<R, A>(Visitor<R, A> visitor, A a) {
return visitor.visitIntersectionType(this, a);
}
@@ -258,6 +274,7 @@
ParsedArguments(this.required, this.positional, this.named)
: assert(positional.isEmpty || named.isEmpty);
+ @override
String toString() {
StringBuffer sb = new StringBuffer();
sb.write("(");
@@ -291,6 +308,7 @@
ParsedNamedArgument(this.isRequired, this.type, this.name);
+ @override
String toString() {
StringBuffer sb = new StringBuffer();
if (isRequired) {
diff --git a/pkg/kernel/lib/testing/type_parser_environment.dart b/pkg/kernel/lib/testing/type_parser_environment.dart
index c9c0b12..6beaa67 100644
--- a/pkg/kernel/lib/testing/type_parser_environment.dart
+++ b/pkg/kernel/lib/testing/type_parser_environment.dart
@@ -243,6 +243,7 @@
as InterfaceType?;
}
+ @override
DartType visitInterfaceType(
ParsedInterfaceType node, TypeParserEnvironment environment) {
String name = node.name;
@@ -338,6 +339,7 @@
}
}
+ @override
Class visitClass(ParsedClass node, TypeParserEnvironment environment) {
String name = node.name;
Class cls = environment.lookupDeclaration(name) as Class;
@@ -373,6 +375,7 @@
return cls;
}
+ @override
Extension visitExtension(
ParsedExtension node, TypeParserEnvironment environment) {
String name = node.name;
@@ -393,6 +396,7 @@
return ext;
}
+ @override
Typedef visitTypedef(ParsedTypedef node, TypeParserEnvironment environment) {
String name = node.name;
Typedef def = environment._registerDeclaration(
@@ -423,6 +427,7 @@
return def..type = type;
}
+ @override
FunctionType visitFunctionType(
ParsedFunctionType node, TypeParserEnvironment environment) {
ParameterEnvironment parameterEnvironment =
@@ -453,16 +458,19 @@
typeParameters: parameterEnvironment.parameters);
}
+ @override
VoidType visitVoidType(
ParsedVoidType node, TypeParserEnvironment environment) {
return const VoidType();
}
+ @override
TypeParameter visitTypeVariable(
ParsedTypeVariable node, TypeParserEnvironment environment) {
throw "not implemented: $node";
}
+ @override
TypeParameterType visitIntersectionType(
ParsedIntersectionType node, TypeParserEnvironment environment) {
TypeParameterType type =
diff --git a/pkg/kernel/lib/text/ast_to_text.dart b/pkg/kernel/lib/text/ast_to_text.dart
index e2012c2..dc98fc7 100644
--- a/pkg/kernel/lib/text/ast_to_text.dart
+++ b/pkg/kernel/lib/text/ast_to_text.dart
@@ -21,16 +21,19 @@
}
class NormalNamer<T> extends Namer<T> {
+ @override
final String prefix;
NormalNamer(this.prefix);
}
class ConstantNamer extends RecursiveResultVisitor<Null> with Namer<Constant> {
+ @override
final String prefix;
ConstantNamer(this.prefix);
+ @override
String getName(Constant constant) {
if (!map.containsKey(constant)) {
// When printing a non-fully linked kernel AST (i.e. some [Reference]s
@@ -61,10 +64,12 @@
return super.getName(constant);
}
+ @override
defaultConstantReference(Constant constant) {
getName(constant);
}
+ @override
defaultDartType(DartType type) {
// No need to recurse into dart types, we only care about naming the
// constants themselves.
@@ -702,6 +707,7 @@
}
}
+ @override
visitSupertype(Supertype type) {
// ignore: unnecessary_null_comparison
if (type == null) {
@@ -716,6 +722,7 @@
}
}
+ @override
visitTypedefType(TypedefType type) {
writeTypedefReference(type.typedefNode);
if (type.typeArguments.isNotEmpty) {
@@ -1107,8 +1114,10 @@
}
}
+ @override
visitLibrary(Library node) {}
+ @override
visitField(Field node) {
writeAnnotationList(node.annotations);
writeIndentation();
@@ -1153,6 +1162,7 @@
endLine(';');
}
+ @override
visitProcedure(Procedure node) {
writeAnnotationList(node.annotations);
writeIndentation();
@@ -1220,6 +1230,7 @@
}
}
+ @override
visitConstructor(Constructor node) {
writeAnnotationList(node.annotations);
writeIndentation();
@@ -1243,6 +1254,7 @@
name: node.name, initializers: node.initializers);
}
+ @override
visitRedirectingFactory(RedirectingFactory node) {
writeAnnotationList(node.annotations);
writeIndentation();
@@ -1272,6 +1284,7 @@
endLine(';');
}
+ @override
visitClass(Class node) {
writeAnnotationList(node.annotations);
writeIndentation();
@@ -1326,6 +1339,7 @@
endLine('}');
}
+ @override
visitExtension(Extension node) {
writeAnnotationList(node.annotations);
writeIndentation();
@@ -1384,6 +1398,7 @@
endLine('}');
}
+ @override
visitTypedef(Typedef node) {
writeAnnotationList(node.annotations);
writeIndentation();
@@ -1402,6 +1417,7 @@
endLine(';');
}
+ @override
visitInvalidExpression(InvalidExpression node) {
writeWord('invalid-expression');
if (node.message != null) {
@@ -1430,6 +1446,7 @@
}
}
+ @override
visitDynamicInvocation(DynamicInvocation node) {
writeExpression(node.receiver, Precedence.PRIMARY);
_writeDynamicAccessKind(node.kind);
@@ -1453,6 +1470,7 @@
}
}
+ @override
visitFunctionInvocation(FunctionInvocation node) {
writeExpression(node.receiver, Precedence.PRIMARY);
_writeFunctionAccessKind(node.kind);
@@ -1487,6 +1505,7 @@
}
}
+ @override
visitInstanceInvocation(InstanceInvocation node) {
writeExpression(node.receiver, Precedence.PRIMARY);
writeSymbol('.');
@@ -1508,6 +1527,7 @@
writeSymbol('}');
}
+ @override
visitInstanceGetterInvocation(InstanceGetterInvocation node) {
writeExpression(node.receiver, Precedence.PRIMARY);
writeSymbol('.');
@@ -1521,6 +1541,7 @@
}
}
+ @override
visitEqualsCall(EqualsCall node) {
int precedence = Precedence.EQUALITY;
writeExpression(node.left, precedence);
@@ -1534,6 +1555,7 @@
writeExpression(node.right, precedence + 1);
}
+ @override
visitEqualsNull(EqualsNull node) {
writeExpression(node.expression, Precedence.EQUALITY);
writeSpace();
@@ -1542,6 +1564,7 @@
writeSymbol('null');
}
+ @override
visitSuperMethodInvocation(SuperMethodInvocation node) {
writeWord('super');
writeSymbol('.');
@@ -1549,28 +1572,33 @@
writeNode(node.arguments);
}
+ @override
visitStaticInvocation(StaticInvocation node) {
writeModifier(node.isConst, 'const');
writeMemberReferenceFromReference(node.targetReference);
writeNode(node.arguments);
}
+ @override
visitConstructorInvocation(ConstructorInvocation node) {
writeWord(node.isConst ? 'const' : 'new');
writeMemberReferenceFromReference(node.targetReference);
writeNode(node.arguments);
}
+ @override
visitNot(Not node) {
writeSymbol('!');
writeExpression(node.operand, Precedence.PREFIX);
}
+ @override
visitNullCheck(NullCheck node) {
writeExpression(node.operand, Precedence.POSTFIX);
writeSymbol('!');
}
+ @override
visitLogicalExpression(LogicalExpression node) {
int precedence = Precedence.binaryPrecedence[
logicalExpressionOperatorToString(node.operatorEnum)]!;
@@ -1579,6 +1607,7 @@
writeExpression(node.right, precedence + 1);
}
+ @override
visitConditionalExpression(ConditionalExpression node) {
writeExpression(node.condition, Precedence.LOGICAL_OR);
ensureSpace();
@@ -1590,6 +1619,7 @@
writeExpression(node.otherwise);
}
+ @override
visitStringConcatenation(StringConcatenation node) {
if (state == WORD) {
writeSpace();
@@ -1608,6 +1638,7 @@
state = WORD;
}
+ @override
visitListConcatenation(ListConcatenation node) {
bool first = true;
for (Expression part in node.lists) {
@@ -1617,6 +1648,7 @@
}
}
+ @override
visitSetConcatenation(SetConcatenation node) {
bool first = true;
for (Expression part in node.sets) {
@@ -1626,6 +1658,7 @@
}
}
+ @override
visitMapConcatenation(MapConcatenation node) {
bool first = true;
for (Expression part in node.maps) {
@@ -1635,6 +1668,7 @@
}
}
+ @override
visitInstanceCreation(InstanceCreation node) {
writeClassReferenceFromReference(node.classReference);
if (node.typeArguments.isNotEmpty) {
@@ -1677,10 +1711,12 @@
writeSymbol('}');
}
+ @override
visitFileUriExpression(FileUriExpression node) {
writeExpression(node.expression);
}
+ @override
visitIsExpression(IsExpression node) {
writeExpression(node.operand, Precedence.BITWISE_OR);
writeSpaced(
@@ -1688,6 +1724,7 @@
writeType(node.type);
}
+ @override
visitAsExpression(AsExpression node) {
writeExpression(node.operand, Precedence.BITWISE_OR);
List<String> flags = <String>[];
@@ -1707,29 +1744,35 @@
writeType(node.type);
}
+ @override
visitSymbolLiteral(SymbolLiteral node) {
writeSymbol('#');
writeWord(node.value);
}
+ @override
visitTypeLiteral(TypeLiteral node) {
writeType(node.type);
}
+ @override
visitThisExpression(ThisExpression node) {
writeWord('this');
}
+ @override
visitRethrow(Rethrow node) {
writeWord('rethrow');
}
+ @override
visitThrow(Throw node) {
writeWord('throw');
writeSpace();
writeExpression(node.expression);
}
+ @override
visitListLiteral(ListLiteral node) {
if (node.isConst) {
writeWord('const');
@@ -1746,6 +1789,7 @@
writeSymbol(']');
}
+ @override
visitSetLiteral(SetLiteral node) {
if (node.isConst) {
writeWord('const');
@@ -1762,6 +1806,7 @@
writeSymbol('}');
}
+ @override
visitMapLiteral(MapLiteral node) {
if (node.isConst) {
writeWord('const');
@@ -1778,41 +1823,50 @@
writeSymbol('}');
}
+ @override
visitMapLiteralEntry(MapLiteralEntry node) {
writeExpression(node.key);
writeComma(':');
writeExpression(node.value);
}
+ @override
visitAwaitExpression(AwaitExpression node) {
writeWord('await');
writeExpression(node.operand);
}
+ @override
visitFunctionExpression(FunctionExpression node) {
writeFunction(node.function, terminateLine: false);
}
+ @override
visitStringLiteral(StringLiteral node) {
writeWord('"${escapeString(node.value)}"');
}
+ @override
visitIntLiteral(IntLiteral node) {
writeWord('${node.value}');
}
+ @override
visitDoubleLiteral(DoubleLiteral node) {
writeWord('${node.value}');
}
+ @override
visitBoolLiteral(BoolLiteral node) {
writeWord('${node.value}');
}
+ @override
visitNullLiteral(NullLiteral node) {
writeWord('null');
}
+ @override
visitLet(Let node) {
writeWord('let');
writeVariableDeclaration(node.variable);
@@ -1820,6 +1874,7 @@
writeExpression(node.body);
}
+ @override
visitBlockExpression(BlockExpression node) {
writeSpaced('block');
writeBlockBody(node.body.statements, asExpression: true);
@@ -1827,6 +1882,7 @@
writeExpression(node.value);
}
+ @override
visitInstantiation(Instantiation node) {
writeExpression(node.expression);
writeSymbol('<');
@@ -1834,6 +1890,7 @@
writeSymbol('>');
}
+ @override
visitLoadLibrary(LoadLibrary node) {
writeWord('LoadLibrary');
writeSymbol('(');
@@ -1842,6 +1899,7 @@
state = WORD;
}
+ @override
visitCheckLibraryIsLoaded(CheckLibraryIsLoaded node) {
writeWord('CheckLibraryIsLoaded');
writeSymbol('(');
@@ -1850,6 +1908,7 @@
state = WORD;
}
+ @override
visitLibraryPart(LibraryPart node) {
writeAnnotationList(node.annotations);
writeIndentation();
@@ -1858,6 +1917,7 @@
endLine(";");
}
+ @override
visitLibraryDependency(LibraryDependency node) {
writeIndentation();
writeWord(node.isImport ? 'import' : 'export');
@@ -1900,10 +1960,12 @@
endLine(';');
}
+ @override
defaultExpression(Expression node) {
writeWord('${node.runtimeType}');
}
+ @override
visitVariableGet(VariableGet node) {
writeVariableReference(node.variable);
DartType? promotedType = node.promotedType;
@@ -1915,6 +1977,7 @@
}
}
+ @override
visitVariableSet(VariableSet node) {
writeVariableReference(node.variable);
writeSpaced('=');
@@ -1940,18 +2003,21 @@
}
}
+ @override
visitDynamicGet(DynamicGet node) {
writeExpression(node.receiver, Precedence.PRIMARY);
_writeDynamicAccessKind(node.kind);
writeName(node.name);
}
+ @override
visitFunctionTearOff(FunctionTearOff node) {
writeExpression(node.receiver, Precedence.PRIMARY);
writeSymbol('.');
writeSymbol('call');
}
+ @override
visitInstanceGet(InstanceGet node) {
writeExpression(node.receiver, Precedence.PRIMARY);
writeSymbol('.');
@@ -1962,6 +2028,7 @@
writeSymbol('}');
}
+ @override
visitInstanceTearOff(InstanceTearOff node) {
writeExpression(node.receiver, Precedence.PRIMARY);
writeSymbol('.');
@@ -1972,6 +2039,7 @@
writeSymbol('}');
}
+ @override
visitDynamicSet(DynamicSet node) {
writeExpression(node.receiver, Precedence.PRIMARY);
_writeDynamicAccessKind(node.kind);
@@ -1980,6 +2048,7 @@
writeExpression(node.value);
}
+ @override
visitInstanceSet(InstanceSet node) {
writeExpression(node.receiver, Precedence.PRIMARY);
writeSymbol('.');
@@ -1989,12 +2058,14 @@
writeExpression(node.value);
}
+ @override
visitSuperPropertyGet(SuperPropertyGet node) {
writeWord('super');
writeSymbol('.');
writeInterfaceTarget(node.name, node.interfaceTargetReference);
}
+ @override
visitSuperPropertySet(SuperPropertySet node) {
writeWord('super');
writeSymbol('.');
@@ -2003,28 +2074,34 @@
writeExpression(node.value);
}
+ @override
visitStaticTearOff(StaticTearOff node) {
writeMemberReferenceFromReference(node.targetReference);
}
+ @override
visitStaticGet(StaticGet node) {
writeMemberReferenceFromReference(node.targetReference);
}
+ @override
visitStaticSet(StaticSet node) {
writeMemberReferenceFromReference(node.targetReference);
writeSpaced('=');
writeExpression(node.value);
}
+ @override
visitConstructorTearOff(ConstructorTearOff node) {
writeMemberReferenceFromReference(node.targetReference);
}
+ @override
visitRedirectingFactoryTearOff(RedirectingFactoryTearOff node) {
writeMemberReferenceFromReference(node.targetReference);
}
+ @override
visitTypedefTearOff(TypedefTearOff node) {
writeTypeParameterList(node.typeParameters);
state = SYMBOL;
@@ -2039,6 +2116,7 @@
state = WORD;
}
+ @override
visitExpressionStatement(ExpressionStatement node) {
writeIndentation();
writeExpression(node.expression);
@@ -2058,22 +2136,26 @@
asExpression ? writeSymbol('}') : endLine('}');
}
+ @override
visitBlock(Block node) {
writeIndentation();
writeBlockBody(node.statements);
}
+ @override
visitAssertBlock(AssertBlock node) {
writeIndentation();
writeSpaced('assert');
writeBlockBody(node.statements);
}
+ @override
visitEmptyStatement(EmptyStatement node) {
writeIndentation();
endLine(';');
}
+ @override
visitAssertStatement(AssertStatement node, {bool asExpression = false}) {
if (!asExpression) {
writeIndentation();
@@ -2093,6 +2175,7 @@
}
}
+ @override
visitLabeledStatement(LabeledStatement node) {
writeIndentation();
writeWord(syntheticNames.nameLabeledStatement(node));
@@ -2100,6 +2183,7 @@
writeNode(node.body);
}
+ @override
visitBreakStatement(BreakStatement node) {
writeIndentation();
writeWord('break');
@@ -2107,6 +2191,7 @@
endLine(';');
}
+ @override
visitWhileStatement(WhileStatement node) {
writeIndentation();
writeSpaced('while');
@@ -2116,6 +2201,7 @@
writeBody(node.body);
}
+ @override
visitDoStatement(DoStatement node) {
writeIndentation();
writeWord('do');
@@ -2127,6 +2213,7 @@
endLine(')');
}
+ @override
visitForStatement(ForStatement node) {
writeIndentation();
writeSpaced('for');
@@ -2143,6 +2230,7 @@
writeBody(node.body);
}
+ @override
visitForInStatement(ForInStatement node) {
writeIndentation();
if (node.isAsync) {
@@ -2157,6 +2245,7 @@
writeBody(node.body);
}
+ @override
visitSwitchStatement(SwitchStatement node) {
writeIndentation();
writeWord('switch');
@@ -2170,6 +2259,7 @@
endLine('}');
}
+ @override
visitSwitchCase(SwitchCase node) {
String label = syntheticNames.nameSwitchCase(node);
writeIndentation();
@@ -2191,6 +2281,7 @@
--indentation;
}
+ @override
visitContinueSwitchStatement(ContinueSwitchStatement node) {
writeIndentation();
writeWord('continue');
@@ -2198,6 +2289,7 @@
endLine(';');
}
+ @override
visitIfStatement(IfStatement node) {
writeIndentation();
writeWord('if');
@@ -2213,6 +2305,7 @@
}
}
+ @override
visitReturnStatement(ReturnStatement node) {
writeIndentation();
writeWord('return');
@@ -2224,6 +2317,7 @@
endLine(';');
}
+ @override
visitTryCatch(TryCatch node) {
writeIndentation();
writeWord('try');
@@ -2231,6 +2325,7 @@
node.catches.forEach(writeNode);
}
+ @override
visitCatch(Catch node) {
writeIndentation();
// ignore: unnecessary_null_comparison
@@ -2256,6 +2351,7 @@
writeBody(node.body);
}
+ @override
visitTryFinally(TryFinally node) {
writeIndentation();
writeWord('try');
@@ -2265,6 +2361,7 @@
writeBody(node.finalizer);
}
+ @override
visitYieldStatement(YieldStatement node) {
writeIndentation();
if (node.isYieldStar) {
@@ -2278,12 +2375,14 @@
endLine(';');
}
+ @override
visitVariableDeclaration(VariableDeclaration node) {
writeIndentation();
writeVariableDeclaration(node, useVarKeyword: true);
endLine(';');
}
+ @override
visitFunctionDeclaration(FunctionDeclaration node) {
writeAnnotationList(node.variable.annotations);
writeIndentation();
@@ -2325,6 +2424,7 @@
}
}
+ @override
visitArguments(Arguments node) {
if (node.types.isNotEmpty) {
writeSymbol('<');
@@ -2338,47 +2438,56 @@
writeSymbol(')');
}
+ @override
visitNamedExpression(NamedExpression node) {
writeWord(node.name);
writeComma(':');
writeExpression(node.value);
}
+ @override
defaultStatement(Statement node) {
writeIndentation();
endLine('${node.runtimeType}');
}
+ @override
visitInvalidInitializer(InvalidInitializer node) {
writeWord('invalid-initializer');
}
+ @override
visitFieldInitializer(FieldInitializer node) {
writeMemberReferenceFromReference(node.fieldReference);
writeSpaced('=');
writeExpression(node.value);
}
+ @override
visitSuperInitializer(SuperInitializer node) {
writeWord('super');
writeMemberReferenceFromReference(node.targetReference);
writeNode(node.arguments);
}
+ @override
visitRedirectingInitializer(RedirectingInitializer node) {
writeWord('this');
writeMemberReferenceFromReference(node.targetReference);
writeNode(node.arguments);
}
+ @override
visitLocalInitializer(LocalInitializer node) {
writeVariableDeclaration(node.variable);
}
+ @override
visitAssertInitializer(AssertInitializer node) {
visitAssertStatement(node.statement, asExpression: true);
}
+ @override
defaultInitializer(Initializer node) {
writeIndentation();
endLine(': ${node.runtimeType}');
@@ -2420,27 +2529,33 @@
}
}
+ @override
visitInvalidType(InvalidType node) {
writeWord('invalid-type');
}
+ @override
visitDynamicType(DynamicType node) {
writeWord('dynamic');
}
+ @override
visitVoidType(VoidType node) {
writeWord('void');
}
+ @override
visitNeverType(NeverType node) {
writeWord('Never');
writeNullability(node.nullability);
}
+ @override
visitNullType(NullType node) {
writeWord('Null');
}
+ @override
visitInterfaceType(InterfaceType node) {
writeClassReferenceFromReference(node.className);
if (node.typeArguments.isNotEmpty) {
@@ -2452,6 +2567,7 @@
writeNullability(node.nullability);
}
+ @override
visitExtensionType(ExtensionType node) {
writeExtensionReferenceFromReference(node.extensionReference);
if (node.typeArguments.isNotEmpty) {
@@ -2463,6 +2579,7 @@
writeNullability(node.declaredNullability);
}
+ @override
visitFutureOrType(FutureOrType node) {
writeWord('FutureOr');
writeSymbol('<');
@@ -2471,10 +2588,12 @@
writeNullability(node.declaredNullability);
}
+ @override
visitFunctionType(FunctionType node) {
writeFunctionType(node);
}
+ @override
visitNamedType(NamedType node) {
writeModifier(node.isRequired, 'required');
writeWord(node.name);
@@ -2483,6 +2602,7 @@
writeType(node.type);
}
+ @override
visitTypeParameterType(TypeParameterType node) {
writeTypeParameterReference(node.parameter);
writeNullability(node.declaredNullability);
@@ -2501,6 +2621,7 @@
}
}
+ @override
visitTypeParameter(TypeParameter node) {
writeModifier(node.isGenericCovariantImpl, 'generic-covariant-impl');
writeAnnotationList(node.annotations, separateLines: false);
@@ -2526,10 +2647,12 @@
writeWord(syntheticNames.nameConstant(node));
}
+ @override
visitConstantExpression(ConstantExpression node) {
writeConstantReference(node.constant);
}
+ @override
defaultConstant(Constant node) {
writeIndentation();
writeConstantReference(node);
@@ -2537,6 +2660,7 @@
endLine('${node.runtimeType}');
}
+ @override
visitNullConstant(NullConstant node) {
writeIndentation();
writeConstantReference(node);
@@ -2544,6 +2668,7 @@
endLine('${node.value}');
}
+ @override
visitBoolConstant(BoolConstant node) {
writeIndentation();
writeConstantReference(node);
@@ -2551,6 +2676,7 @@
endLine('${node.value}');
}
+ @override
visitIntConstant(IntConstant node) {
writeIndentation();
writeConstantReference(node);
@@ -2558,6 +2684,7 @@
endLine('${node.value}');
}
+ @override
visitDoubleConstant(DoubleConstant node) {
writeIndentation();
writeConstantReference(node);
@@ -2565,6 +2692,7 @@
endLine('${node.value}');
}
+ @override
visitSymbolConstant(SymbolConstant node) {
writeIndentation();
writeConstantReference(node);
@@ -2576,6 +2704,7 @@
endLine('${text}');
}
+ @override
visitListConstant(ListConstant node) {
writeIndentation();
writeConstantReference(node);
@@ -2587,6 +2716,7 @@
endLine(']');
}
+ @override
visitSetConstant(SetConstant node) {
writeIndentation();
writeConstantReference(node);
@@ -2598,6 +2728,7 @@
endLine('}');
}
+ @override
visitMapConstant(MapConstant node) {
writeIndentation();
writeConstantReference(node);
@@ -2613,6 +2744,7 @@
endLine(')');
}
+ @override
visitTypeLiteralConstant(TypeLiteralConstant node) {
writeIndentation();
writeConstantReference(node);
@@ -2623,6 +2755,7 @@
endLine(')');
}
+ @override
visitInstanceConstant(InstanceConstant node) {
writeIndentation();
writeConstantReference(node);
@@ -2647,6 +2780,7 @@
endLine('}');
}
+ @override
visitInstantiationConstant(InstantiationConstant node) {
writeIndentation();
writeConstantReference(node);
@@ -2666,6 +2800,7 @@
endLine();
}
+ @override
visitStringConstant(StringConstant node) {
writeIndentation();
writeConstantReference(node);
@@ -2673,6 +2808,7 @@
endLine('"${escapeString(node.value)}"');
}
+ @override
visitStaticTearOffConstant(StaticTearOffConstant node) {
writeIndentation();
writeConstantReference(node);
@@ -2683,6 +2819,7 @@
endLine();
}
+ @override
visitTypedefTearOffConstant(TypedefTearOffConstant node) {
writeIndentation();
writeConstantReference(node);
@@ -2703,6 +2840,7 @@
endLine();
}
+ @override
visitUnevaluatedConstant(UnevaluatedConstant node) {
writeIndentation();
writeConstantReference(node);
@@ -2713,6 +2851,7 @@
endLine();
}
+ @override
visitConstructorTearOffConstant(ConstructorTearOffConstant node) {
writeIndentation();
writeConstantReference(node);
@@ -2723,6 +2862,7 @@
endLine();
}
+ @override
visitRedirectingFactoryTearOffConstant(
RedirectingFactoryTearOffConstant node) {
writeIndentation();
@@ -2734,6 +2874,7 @@
endLine();
}
+ @override
defaultNode(Node node) {
write('<${node.runtimeType}>');
}
diff --git a/pkg/kernel/lib/text/serializer_combinators.dart b/pkg/kernel/lib/text/serializer_combinators.dart
index aae9ea2..b187beb 100644
--- a/pkg/kernel/lib/text/serializer_combinators.dart
+++ b/pkg/kernel/lib/text/serializer_combinators.dart
@@ -136,16 +136,20 @@
class Nothing extends TextSerializer<void> {
const Nothing();
+ @override
void readFrom(Iterator<Object?> stream, DeserializationState? _) {}
+ @override
void writeTo(StringBuffer buffer, void ignored, SerializationState? _) {}
+ @override
bool get isEmpty => true;
}
class DartString extends TextSerializer<String> {
const DartString();
+ @override
String readFrom(Iterator<Object?> stream, DeserializationState? _) {
Object? current = stream.current;
if (current is! String) {
@@ -156,6 +160,7 @@
return result;
}
+ @override
void writeTo(StringBuffer buffer, String object, SerializationState? _) {
buffer.write(json.encode(object));
}
@@ -164,6 +169,7 @@
class DartInt extends TextSerializer<int> {
const DartInt();
+ @override
int readFrom(Iterator<Object?> stream, DeserializationState? _) {
Object? current = stream.current;
if (current is! String) {
@@ -174,6 +180,7 @@
return result;
}
+ @override
void writeTo(StringBuffer buffer, int object, SerializationState? _) {
buffer.write(object);
}
@@ -182,6 +189,7 @@
class DartDouble extends TextSerializer<double> {
const DartDouble();
+ @override
double readFrom(Iterator<Object?> stream, DeserializationState? _) {
Object? current = stream.current;
if (current is! String) {
@@ -192,6 +200,7 @@
return result;
}
+ @override
void writeTo(StringBuffer buffer, double object, SerializationState? _) {
buffer.write(object);
}
@@ -200,6 +209,7 @@
class DartBool extends TextSerializer<bool> {
const DartBool();
+ @override
bool readFrom(Iterator<Object?> stream, DeserializationState? _) {
Object? current = stream.current;
if (current is! String) {
@@ -217,6 +227,7 @@
return result;
}
+ @override
void writeTo(StringBuffer buffer, bool object, SerializationState? _) {
buffer.write(object ? 'true' : 'false');
}
@@ -225,11 +236,13 @@
class UriSerializer extends TextSerializer<Uri> {
const UriSerializer();
+ @override
Uri readFrom(Iterator<Object?> stream, DeserializationState? state) {
String uriAsString = const DartString().readFrom(stream, state);
return Uri.parse(uriAsString);
}
+ @override
void writeTo(StringBuffer buffer, Uri object, SerializationState? state) {
const DartString().writeTo(buffer, object.toString(), state);
}
@@ -258,6 +271,7 @@
_serializers.addAll(tagsAndSerializers.values);
}
+ @override
T readFrom(Iterator<Object?> stream, DeserializationState? state) {
Object? iterator = stream.current;
if (iterator is! Iterator<Object?>) {
@@ -284,6 +298,7 @@
throw StateError("Unrecognized tag '${tag}'.");
}
+ @override
void writeTo(StringBuffer buffer, T object, SerializationState? state) {
String tag = tagger.tag(object);
for (int i = 0; i < _tags.length; ++i) {
@@ -310,14 +325,17 @@
const Wrapped(this.unwrap, this.wrap, this.contents);
+ @override
K readFrom(Iterator<Object?> stream, DeserializationState? state) {
return wrap(contents.readFrom(stream, state));
}
+ @override
void writeTo(StringBuffer buffer, K object, SerializationState? state) {
contents.writeTo(buffer, unwrap(object), state);
}
+ @override
bool get isEmpty => contents.isEmpty;
}
@@ -326,6 +344,7 @@
const ScopedUse();
+ @override
T readFrom(Iterator<Object?> stream, DeserializationState? state) {
if (state == null) {
throw StateError(
@@ -335,6 +354,7 @@
as T;
}
+ @override
void writeTo(StringBuffer buffer, T object, SerializationState? state) {
if (state == null) {
throw StateError(
@@ -351,12 +371,14 @@
const Tuple2Serializer(this.first, this.second);
+ @override
Tuple2<T1, T2> readFrom(
Iterator<Object?> stream, DeserializationState? state) {
return new Tuple2(
first.readFrom(stream, state), second.readFrom(stream, state));
}
+ @override
void writeTo(
StringBuffer buffer, Tuple2<T1, T2> object, SerializationState? state) {
first.writeTo(buffer, object.first, state);
@@ -379,12 +401,14 @@
const Tuple3Serializer(this.first, this.second, this.third);
+ @override
Tuple3<T1, T2, T3> readFrom(
Iterator<Object?> stream, DeserializationState? state) {
return new Tuple3(first.readFrom(stream, state),
second.readFrom(stream, state), third.readFrom(stream, state));
}
+ @override
void writeTo(StringBuffer buffer, Tuple3<T1, T2, T3> object,
SerializationState? state) {
first.writeTo(buffer, object.first, state);
@@ -412,6 +436,7 @@
const Tuple4Serializer(this.first, this.second, this.third, this.fourth);
+ @override
Tuple4<T1, T2, T3, T4> readFrom(
Iterator<Object?> stream, DeserializationState? state) {
return new Tuple4(
@@ -421,6 +446,7 @@
fourth.readFrom(stream, state));
}
+ @override
void writeTo(StringBuffer buffer, Tuple4<T1, T2, T3, T4> object,
SerializationState? state) {
first.writeTo(buffer, object.first, state);
@@ -453,6 +479,7 @@
const Tuple5Serializer(
this.first, this.second, this.third, this.fourth, this.fifth);
+ @override
Tuple5<T1, T2, T3, T4, T5> readFrom(
Iterator<Object?> stream, DeserializationState? state) {
return new Tuple5(
@@ -463,6 +490,7 @@
fifth.readFrom(stream, state));
}
+ @override
void writeTo(StringBuffer buffer, Tuple5<T1, T2, T3, T4, T5> object,
SerializationState? state) {
first.writeTo(buffer, object.first, state);
@@ -499,6 +527,7 @@
const Tuple6Serializer(
this.first, this.second, this.third, this.fourth, this.fifth, this.sixth);
+ @override
Tuple6<T1, T2, T3, T4, T5, T6> readFrom(
Iterator<Object?> stream, DeserializationState? state) {
return new Tuple6(
@@ -510,6 +539,7 @@
sixth.readFrom(stream, state));
}
+ @override
void writeTo(StringBuffer buffer, Tuple6<T1, T2, T3, T4, T5, T6> object,
SerializationState? state) {
first.writeTo(buffer, object.first, state);
@@ -551,6 +581,7 @@
const Tuple7Serializer(this.first, this.second, this.third, this.fourth,
this.fifth, this.sixth, this.seventh);
+ @override
Tuple7<T1, T2, T3, T4, T5, T6, T7> readFrom(
Iterator<Object?> stream, DeserializationState? state) {
return new Tuple7(
@@ -563,6 +594,7 @@
seventh.readFrom(stream, state));
}
+ @override
void writeTo(StringBuffer buffer, Tuple7<T1, T2, T3, T4, T5, T6, T7> object,
SerializationState? state) {
first.writeTo(buffer, object.first, state);
@@ -608,6 +640,7 @@
const Tuple8Serializer(this.first, this.second, this.third, this.fourth,
this.fifth, this.sixth, this.seventh, this.eighth);
+ @override
Tuple8<T1, T2, T3, T4, T5, T6, T7, T8> readFrom(
Iterator<Object?> stream, DeserializationState? state) {
return new Tuple8(
@@ -621,6 +654,7 @@
eighth.readFrom(stream, state));
}
+ @override
void writeTo(
StringBuffer buffer,
Tuple8<T1, T2, T3, T4, T5, T6, T7, T8> object,
@@ -663,6 +697,7 @@
const ListSerializer(this.elements);
+ @override
List<T> readFrom(Iterator<Object?> stream, DeserializationState? state) {
Object? iterator = stream.current;
if (iterator is! Iterator<Object?>) {
@@ -677,6 +712,7 @@
return result;
}
+ @override
void writeTo(StringBuffer buffer, List<T> object, SerializationState? state) {
buffer.write('(');
for (int i = 0; i < object.length; ++i) {
@@ -692,6 +728,7 @@
const Optional(this.contents);
+ @override
T? readFrom(Iterator<Object?> stream, DeserializationState? state) {
if (stream.current == '_') {
stream.moveNext();
@@ -700,6 +737,7 @@
return contents.readFrom(stream, state);
}
+ @override
void writeTo(StringBuffer buffer, T? object, SerializationState? state) {
if (object == null) {
buffer.write('_');
@@ -720,6 +758,7 @@
Binder(TextSerializer<T> contents)
: namedContents = new Tuple2Serializer(const DartString(), contents);
+ @override
Tuple2<String, T> readFrom(
Iterator<Object?> stream, DeserializationState? state) {
if (state == null) {
@@ -733,6 +772,7 @@
return new Tuple2(name, object);
}
+ @override
void writeTo(StringBuffer buffer, Tuple2<String?, T> namedObject,
SerializationState? state) {
if (state == null) {
@@ -758,6 +798,7 @@
const Bind(this.pattern, this.term);
+ @override
Tuple2<P, T> readFrom(Iterator<Object?> stream, DeserializationState? state) {
if (state == null) {
throw StateError(
@@ -771,6 +812,7 @@
return new Tuple2(first, second);
}
+ @override
void writeTo(
StringBuffer buffer, Tuple2<P, T> tuple, SerializationState? state) {
if (state == null) {
@@ -797,6 +839,7 @@
const Rebind(this.pattern1, this.pattern2);
+ @override
Tuple2<P, T> readFrom(Iterator<Object?> stream, DeserializationState? state) {
if (state == null) {
throw StateError(
@@ -813,6 +856,7 @@
return new Tuple2(first, second);
}
+ @override
void writeTo(
StringBuffer buffer, Tuple2<P, T> tuple, SerializationState? state) {
if (state == null) {
@@ -837,6 +881,7 @@
const Zip(this.lists, this.zip, this.unzip);
+ @override
List<T> readFrom(Iterator<Object?> stream, DeserializationState? state) {
Tuple2<List<T1>, List<T2>> toZip = lists.readFrom(stream, state);
List<T1> firsts = toZip.first;
@@ -854,6 +899,7 @@
return zipped;
}
+ @override
void writeTo(StringBuffer buffer, List<T> zipped, SerializationState? state) {
List<T1> firsts;
List<T2> seconds;
diff --git a/pkg/kernel/lib/text/text_serialization_verifier.dart b/pkg/kernel/lib/text/text_serialization_verifier.dart
index dab2bc7..a8a0283 100644
--- a/pkg/kernel/lib/text/text_serialization_verifier.dart
+++ b/pkg/kernel/lib/text/text_serialization_verifier.dart
@@ -39,6 +39,7 @@
String get nameForDebugging;
+ @override
int compareTo(RoundTripStatus other) {
Node thisNode = this.node;
Node otherNode = other.node;
@@ -111,6 +112,7 @@
}
}
+ @override
String toString() {
StringBuffer sb = new StringBuffer();
printOn(sb);
diff --git a/pkg/kernel/lib/text/text_serializer.dart b/pkg/kernel/lib/text/text_serializer.dart
index 0a49543..0f6e9f5 100644
--- a/pkg/kernel/lib/text/text_serializer.dart
+++ b/pkg/kernel/lib/text/text_serializer.dart
@@ -15,6 +15,7 @@
class NameTagger implements Tagger<Name> {
const NameTagger();
+ @override
String tag(Name name) => name.isPrivate ? "private" : "public";
}
@@ -33,92 +34,153 @@
implements Tagger<Expression> {
const ExpressionTagger();
+ @override
String tag(Expression expression) => expression.accept(this);
+ @override
String visitStringLiteral(StringLiteral _) => "string";
+ @override
String visitIntLiteral(IntLiteral _) => "int";
+ @override
String visitDoubleLiteral(DoubleLiteral _) => "double";
+ @override
String visitBoolLiteral(BoolLiteral _) => "bool";
+ @override
String visitNullLiteral(NullLiteral _) => "null";
+ @override
String visitInvalidExpression(InvalidExpression _) => "invalid";
+ @override
String visitNot(Not _) => "not";
+ @override
String visitLogicalExpression(LogicalExpression expression) {
return logicalExpressionOperatorToString(expression.operatorEnum);
}
+ @override
String visitStringConcatenation(StringConcatenation _) => "concat";
+ @override
String visitSymbolLiteral(SymbolLiteral _) => "symbol";
+ @override
String visitThisExpression(ThisExpression _) => "this";
+ @override
String visitRethrow(Rethrow _) => "rethrow";
+ @override
String visitThrow(Throw _) => "throw";
+ @override
String visitAwaitExpression(AwaitExpression _) => "await";
+ @override
String visitConditionalExpression(ConditionalExpression _) => "cond";
+ @override
String visitIsExpression(IsExpression _) => "is";
+ @override
String visitAsExpression(AsExpression _) => "as";
+ @override
String visitTypeLiteral(TypeLiteral _) => "type";
+ @override
String visitListLiteral(ListLiteral expression) {
return expression.isConst ? "const-list" : "list";
}
+ @override
String visitSetLiteral(SetLiteral expression) {
return expression.isConst ? "const-set" : "set";
}
+ @override
String visitMapLiteral(MapLiteral expression) {
return expression.isConst ? "const-map" : "map";
}
+ @override
String visitLet(Let _) => "let";
+ @override
String visitInstanceGet(InstanceGet _) => "get-instance";
+ @override
String visitInstanceSet(InstanceSet _) => "set-instance";
+ @override
String visitDynamicGet(DynamicGet _) => "get-dynamic";
+ @override
String visitDynamicSet(DynamicSet _) => "set-dynamic";
+ @override
String visitInstanceTearOff(InstanceTearOff _) => "tearoff-instance";
+ @override
String visitFunctionTearOff(FunctionTearOff _) => "tearoff-function";
+ @override
String visitSuperPropertyGet(SuperPropertyGet _) => "get-super";
+ @override
String visitSuperPropertySet(SuperPropertySet _) => "set-super";
+ @override
String visitInstanceInvocation(InstanceInvocation _) => "invoke-instance";
+ @override
String visitInstanceGetterInvocation(InstanceGetterInvocation _) =>
"invoke-instance-getter";
+ @override
String visitDynamicInvocation(DynamicInvocation _) => "invoke-dynamic";
+ @override
String visitFunctionInvocation(FunctionInvocation _) => "invoke-function";
+ @override
String visitLocalFunctionInvocation(LocalFunctionInvocation _) =>
"invoke-local-function";
+ @override
String visitEqualsNull(EqualsNull _) => "equals-null";
+ @override
String visitEqualsCall(EqualsCall _) => "equals-call";
+ @override
String visitSuperMethodInvocation(SuperMethodInvocation _) => "invoke-super";
+ @override
String visitVariableGet(VariableGet _) => "get-var";
+ @override
String visitVariableSet(VariableSet _) => "set-var";
+ @override
String visitStaticGet(StaticGet _) => "get-static";
+ @override
String visitStaticSet(StaticSet _) => "set-static";
+ @override
String visitStaticTearOff(StaticTearOff _) => "tearoff-static";
+ @override
String visitConstructorTearOff(ConstructorTearOff _) => "tearoff-constructor";
+ @override
String visitRedirectingFactoryTearOff(RedirectingFactoryTearOff _) =>
"tearoff-redirecting-factory";
+ @override
String visitTypedefTearOff(TypedefTearOff _) => "tearoff-typedef";
+ @override
String visitStaticInvocation(StaticInvocation expression) {
return expression.isConst ? "invoke-const-static" : "invoke-static";
}
+ @override
String visitConstructorInvocation(ConstructorInvocation expression) {
return expression.isConst
? "invoke-const-constructor"
: "invoke-constructor";
}
+ @override
String visitFunctionExpression(FunctionExpression _) => "fun";
+ @override
String visitListConcatenation(ListConcatenation _) => "lists";
+ @override
String visitSetConcatenation(SetConcatenation _) => "sets";
+ @override
String visitMapConcatenation(MapConcatenation _) => "maps";
+ @override
String visitBlockExpression(BlockExpression _) => "let-block";
+ @override
String visitInstantiation(Instantiation _) => "apply";
+ @override
String visitNullCheck(NullCheck _) => "not-null";
+ @override
String visitFileUriExpression(FileUriExpression _) => "with-uri";
+ @override
String visitCheckLibraryIsLoaded(CheckLibraryIsLoaded _) => "is-loaded";
+ @override
String visitLoadLibrary(LoadLibrary _) => "load";
+ @override
String visitConstantExpression(ConstantExpression _) => "const";
+ @override
String visitInstanceCreation(InstanceCreation _) => "object";
@override
@@ -574,6 +636,7 @@
class InstanceAccessKindTagger implements Tagger<InstanceAccessKind> {
const InstanceAccessKindTagger();
+ @override
String tag(InstanceAccessKind kind) {
return instanceAccessKindToName[kind] ??
(throw StateError("Unknown InstanceAccessKind flag value: ${kind}."));
@@ -665,6 +728,7 @@
class DynamicAccessKindTagger implements Tagger<DynamicAccessKind> {
const DynamicAccessKindTagger();
+ @override
String tag(DynamicAccessKind kind) {
return dynamicAccessKindToName[kind] ??
(throw StateError("Unknown DynamicAccessKind flag value: ${kind}."));
@@ -704,6 +768,7 @@
class FunctionAccessKindTagger implements Tagger<FunctionAccessKind> {
const FunctionAccessKindTagger();
+ @override
String tag(FunctionAccessKind kind) {
return functionAccessKindToName[kind] ??
(throw StateError("Unknown FunctionAccessKind flag value: ${kind}."));
@@ -849,6 +914,7 @@
}
}
+ @override
CanonicalName readFrom(
Iterator<Object?> stream, DeserializationState? state) {
if (state == null) {
@@ -863,6 +929,7 @@
return name;
}
+ @override
void writeTo(
StringBuffer buffer, CanonicalName name, SerializationState? state) {
StringBuffer sb = new StringBuffer();
@@ -1153,6 +1220,7 @@
};
class VariableDeclarationFlagTagger implements Tagger<int> {
+ @override
String tag(int flag) {
return variableDeclarationFlagToName[flag] ??
(throw StateError("Unknown VariableDeclaration flag value: ${flag}."));
@@ -1226,17 +1294,28 @@
implements Tagger<DartType> {
const DartTypeTagger();
+ @override
String tag(DartType type) => type.accept(this);
+ @override
String visitInvalidType(InvalidType _) => "invalid";
+ @override
String visitDynamicType(DynamicType _) => "dynamic";
+ @override
String visitVoidType(VoidType _) => "void";
+ @override
String visitFunctionType(FunctionType _) => "->";
+ @override
String visitTypeParameterType(TypeParameterType _) => "par";
+ @override
String visitInterfaceType(InterfaceType _) => "interface";
+ @override
String visitNeverType(NeverType _) => "never";
+ @override
String visitTypedefType(TypedefType _) => "typedef";
+ @override
String visitFutureOrType(FutureOrType _) => "futureor";
+ @override
String visitNullType(NullType _) => "null-type";
@override
@@ -1390,37 +1469,58 @@
implements Tagger<Statement> {
const StatementTagger();
+ @override
String tag(Statement statement) => statement.accept(this);
+ @override
String visitExpressionStatement(ExpressionStatement _) => "expr";
+ @override
String visitReturnStatement(ReturnStatement node) {
return node.expression == null ? "ret-void" : "ret";
}
+ @override
String visitYieldStatement(YieldStatement _) => "yield";
+ @override
String visitBlock(Block _) => "block";
+ @override
String visitVariableDeclaration(VariableDeclaration _) => "local";
+ @override
String visitIfStatement(IfStatement node) {
return node.otherwise == null ? "if" : "if-else";
}
+ @override
String visitEmptyStatement(EmptyStatement node) => "skip";
+ @override
String visitWhileStatement(WhileStatement node) => "while";
+ @override
String visitDoStatement(DoStatement node) => "do-while";
+ @override
String visitForStatement(ForStatement node) => "for";
+ @override
String visitForInStatement(ForInStatement node) {
return node.isAsync ? "await-for-in" : "for-in";
}
+ @override
String visitAssertStatement(AssertStatement node) => "assert";
+ @override
String visitAssertBlock(AssertBlock node) => "assert-block";
+ @override
String visitLabeledStatement(LabeledStatement node) => "label";
+ @override
String visitBreakStatement(BreakStatement node) => "break";
+ @override
String visitTryFinally(TryFinally node) => "try-finally";
+ @override
String visitTryCatch(TryCatch node) => "try-catch";
+ @override
String visitSwitchStatement(SwitchStatement node) => "switch";
+ @override
String visitContinueSwitchStatement(ContinueSwitchStatement node) =>
"continue";
+ @override
String visitFunctionDeclaration(FunctionDeclaration node) => "local-fun";
@override
@@ -1509,6 +1609,7 @@
extends TextSerializer<Tuple2<List<Statement>, Expression?>> {
const BlockSerializer();
+ @override
Tuple2<List<Statement>, Expression?> readFrom(
Iterator<Object?> stream, DeserializationState? state) {
if (state == null) {
@@ -1535,6 +1636,7 @@
return new Tuple2(statements, expression);
}
+ @override
void writeTo(StringBuffer buffer, Tuple2<List<Statement>, Expression?> tuple,
SerializationState? state) {
if (state == null) {
@@ -1727,6 +1829,7 @@
(SwitchCase z) => Tuple2(z, z.body))));
class SwitchCaseTagger implements Tagger<SwitchCase> {
+ @override
String tag(SwitchCase node) {
return node.isDefault ? "default" : "case";
}
@@ -1777,6 +1880,7 @@
class AsyncMarkerTagger implements Tagger<AsyncMarker> {
const AsyncMarkerTagger();
+ @override
String tag(AsyncMarker node) {
return asyncMarkerToName[node] ?? (throw new UnsupportedError("${node}"));
}
@@ -1791,8 +1895,10 @@
functionNodeWithInitializersSerializer = Wrapped<
Tuple2<
AsyncMarker,
- Tuple2< /**/
- Tuple2< /**/
+ Tuple2<
+ /**/
+ Tuple2<
+ /**/
List<TypeParameter>,
Tuple3<
List<VariableDeclaration>,
@@ -1856,6 +1962,7 @@
class ProcedureFlagTagger implements Tagger<int> {
const ProcedureFlagTagger();
+ @override
String tag(int flag) {
return procedureFlagToName[flag] ??
(throw StateError("Unknown Procedure flag value: ${flag}."));
@@ -1883,6 +1990,7 @@
class FieldFlagTagger implements Tagger<int> {
const FieldFlagTagger();
+ @override
String tag(int flag) {
return fieldFlagToName[flag] ??
(throw StateError("Unknown Field flag value: ${flag}."));
@@ -1904,6 +2012,7 @@
class ConstructorFlagTagger implements Tagger<int> {
const ConstructorFlagTagger();
+ @override
String tag(int flag) {
return constructorFlagToName[flag] ??
(throw StateError("Unknown Constructor flag value: ${flag}."));
@@ -1925,6 +2034,7 @@
class RedirectingFactoryFlagTagger implements Tagger<int> {
const RedirectingFactoryFlagTagger();
+ @override
String tag(int flag) {
return redirectingFactoryFlagToName[flag] ??
(throw StateError("Unknown RedirectingFactory flag value: ${flag}."));
@@ -1943,6 +2053,7 @@
class MemberTagger implements Tagger<Member> {
const MemberTagger();
+ @override
String tag(Member node) {
if (node is Field) {
return node.hasSetter ? "mutable-field" : "immutable-field";
@@ -2025,13 +2136,14 @@
Tuple4Serializer(nameSerializer, procedureFlagsSerializer,
functionNodeSerializer, UriSerializer()));
-TextSerializer<Procedure> factorySerializer = Wrapped<
- Tuple4<Name, int, FunctionNode, Uri>, Procedure>(
- (w) => Tuple4(w.name, w.flags, w.function, w.fileUri),
- (u) => Procedure(u.first, ProcedureKind.Factory, u.third, fileUri: u.fourth)
- ..flags = u.second,
- Tuple4Serializer(nameSerializer, procedureFlagsSerializer,
- functionNodeSerializer, UriSerializer()));
+TextSerializer<Procedure> factorySerializer =
+ Wrapped<Tuple4<Name, int, FunctionNode, Uri>, Procedure>(
+ (w) => Tuple4(w.name, w.flags, w.function, w.fileUri),
+ (u) => Procedure(u.first, ProcedureKind.Factory, u.third,
+ fileUri: u.fourth)
+ ..flags = u.second,
+ Tuple4Serializer(nameSerializer, procedureFlagsSerializer,
+ functionNodeSerializer, UriSerializer()));
TextSerializer<Constructor> constructorSerializer = Wrapped<
Tuple4<Name, int, Tuple2<FunctionNode, List<Initializer>?>, Uri>,
@@ -2076,6 +2188,7 @@
class LibraryTagger implements Tagger<Library> {
const LibraryTagger();
+ @override
String tag(Library node) {
return node.isNonNullableByDefault ? "null-safe" : "legacy";
}
@@ -2091,6 +2204,7 @@
class LibraryFlagTagger implements Tagger<int> {
const LibraryFlagTagger();
+ @override
String tag(int flag) {
return libraryFlagToName[flag] ??
(throw StateError("Unknown Library flag value: ${flag}."));
@@ -2137,6 +2251,7 @@
ListSerializer(librarySerializer));
class ShowHideTagger implements Tagger<Combinator> {
+ @override
String tag(Combinator node) => node.isShow ? "show" : "hide";
}
@@ -2171,30 +2286,48 @@
implements Tagger<Constant> {
const ConstantTagger();
+ @override
String tag(Constant node) => node.accept(this);
+ @override
String visitBoolConstant(BoolConstant node) => "const-bool";
+ @override
String visitDoubleConstant(DoubleConstant node) => "const-double";
+ @override
String visitInstanceConstant(InstanceConstant node) => "const-object";
+ @override
String visitIntConstant(IntConstant node) => "const-int";
+ @override
String visitListConstant(ListConstant node) => "const-list";
+ @override
String visitMapConstant(MapConstant node) => "const-map";
+ @override
String visitNullConstant(NullConstant node) => "const-null";
+ @override
String visitInstantiationConstant(InstantiationConstant node) =>
"const-apply";
+ @override
String visitSetConstant(SetConstant node) => "const-set";
+ @override
String visitStringConstant(StringConstant node) => "const-string";
+ @override
String visitSymbolConstant(SymbolConstant node) => "const-symbol";
+ @override
String visitStaticTearOffConstant(StaticTearOffConstant node) =>
"const-tearoff-static";
+ @override
String visitConstructorTearOffConstant(ConstructorTearOffConstant node) =>
"const-tearoff-constructor";
+ @override
String visitRedirectingFactoryTearOffConstant(
RedirectingFactoryTearOffConstant node) =>
"const-tearoff-redirecting-factory";
+ @override
String visitTypedefTearOffConstant(TypedefTearOffConstant node) =>
"const-tearoff-typedef";
+ @override
String visitTypeLiteralConstant(TypeLiteralConstant node) => "const-type";
+ @override
String visitUnevaluatedConstant(UnevaluatedConstant node) => "const-expr";
@override
@@ -2335,6 +2468,7 @@
class InitializerTagger implements Tagger<Initializer> {
const InitializerTagger();
+ @override
String tag(Initializer node) {
if (node is AssertInitializer) {
return "assert";
@@ -2406,6 +2540,7 @@
class ClassFlagTagger implements Tagger<int> {
const ClassFlagTagger();
+ @override
String tag(int flag) {
return classFlagToName[flag] ??
(throw StateError("Unknown Class flag value: ${flag}."));
@@ -2482,6 +2617,7 @@
class ExtensionMemberDescriptorFlagTagger implements Tagger<int> {
const ExtensionMemberDescriptorFlagTagger();
+ @override
String tag(int flag) {
return extensionMemberDescriptorFlagToName[flag] ??
(throw StateError(
@@ -2510,6 +2646,7 @@
class ExtensionMemberKindTagger implements Tagger<ExtensionMemberKind> {
const ExtensionMemberKindTagger();
+ @override
String tag(ExtensionMemberKind kind) {
return extensionMemberKindToName[kind] ??
(throw StateError("Unknown ExtensionMemberKind flag value: ${kind}."));
diff --git a/pkg/kernel/lib/transformations/async.dart b/pkg/kernel/lib/transformations/async.dart
index 848a1ce..2866e54 100644
--- a/pkg/kernel/lib/transformations/async.dart
+++ b/pkg/kernel/lib/transformations/async.dart
@@ -157,13 +157,21 @@
// Simple literals. These are pure expressions so they can be evaluated after
// an await to their right.
+ @override
TreeNode visitSymbolLiteral(SymbolLiteral expr) => expr;
+ @override
TreeNode visitTypeLiteral(TypeLiteral expr) => expr;
+ @override
TreeNode visitThisExpression(ThisExpression expr) => expr;
+ @override
TreeNode visitStringLiteral(StringLiteral expr) => expr;
+ @override
TreeNode visitIntLiteral(IntLiteral expr) => expr;
+ @override
TreeNode visitDoubleLiteral(DoubleLiteral expr) => expr;
+ @override
TreeNode visitBoolLiteral(BoolLiteral expr) => expr;
+ @override
TreeNode visitNullLiteral(NullLiteral expr) => expr;
// Nullary expressions with effects.
@@ -175,13 +183,18 @@
return expr;
}
+ @override
TreeNode visitSuperPropertyGet(SuperPropertyGet expr) => nullary(expr);
+ @override
TreeNode visitStaticGet(StaticGet expr) => nullary(expr);
+ @override
TreeNode visitStaticTearOff(StaticTearOff expr) => nullary(expr);
+ @override
TreeNode visitRethrow(Rethrow expr) => nullary(expr);
// Getting a final or const variable is not an effect so it can be evaluated
// after an await to its right.
+ @override
TreeNode visitVariableGet(VariableGet expr) {
Expression result = expr;
if (seenAwait && !expr.variable.isFinal && !expr.variable.isConst) {
@@ -271,6 +284,7 @@
});
}
+ @override
TreeNode visitArguments(Arguments args) {
for (var named in args.named.reversed) {
named.value = transform(named.value)..parent = named;
@@ -326,24 +340,28 @@
});
}
+ @override
TreeNode visitSuperMethodInvocation(SuperMethodInvocation expr) {
return transformTreeNode(expr, () {
visitArguments(expr.arguments);
});
}
+ @override
TreeNode visitStaticInvocation(StaticInvocation expr) {
return transformTreeNode(expr, () {
visitArguments(expr.arguments);
});
}
+ @override
TreeNode visitConstructorInvocation(ConstructorInvocation expr) {
return transformTreeNode(expr, () {
visitArguments(expr.arguments);
});
}
+ @override
TreeNode visitStringConcatenation(StringConcatenation expr) {
return transformTreeNode(expr, () {
var expressions = expr.expressions;
@@ -353,6 +371,7 @@
});
}
+ @override
TreeNode visitListLiteral(ListLiteral expr) {
return transformTreeNode(expr, () {
var expressions = expr.expressions;
@@ -362,6 +381,7 @@
});
}
+ @override
TreeNode visitMapLiteral(MapLiteral expr) {
return transformTreeNode(expr, () {
for (var entry in expr.entries.reversed) {
@@ -372,6 +392,7 @@
}
// Control flow.
+ @override
TreeNode visitLogicalExpression(LogicalExpression expr) {
var shouldName = seenAwait;
@@ -437,6 +458,7 @@
return unsafeCastVariableGet(result, type);
}
+ @override
TreeNode visitConditionalExpression(ConditionalExpression expr) {
// Then and otherwise are delimited because they are conditionally
// evaluated.
@@ -502,6 +524,7 @@
}
// Others.
+ @override
TreeNode visitAwaitExpression(AwaitExpression expr) {
final R = continuationRewriter;
var shouldName = seenAwait;
@@ -558,11 +581,13 @@
return result;
}
+ @override
TreeNode visitFunctionExpression(FunctionExpression expr) {
expr.transformChildren(this);
return expr;
}
+ @override
TreeNode visitLet(Let expr) {
var body = transform(expr.body);
@@ -604,12 +629,14 @@
}
}
+ @override
visitFunctionNode(FunctionNode node) {
var nestedRewriter = new RecursiveContinuationRewriter(
continuationRewriter.helper, _staticTypeContext);
return nestedRewriter.transform(node);
}
+ @override
TreeNode visitBlockExpression(BlockExpression expr) {
return transformTreeNode(expr, () {
expr.value = transform(expr.value)..parent = expr;
@@ -648,6 +675,7 @@
return null;
}
+ @override
TreeNode defaultStatement(Statement stmt) {
throw new UnsupportedError(
"Use _rewriteStatement to transform statement: ${stmt}");
diff --git a/pkg/kernel/lib/transformations/continuation.dart b/pkg/kernel/lib/transformations/continuation.dart
index fd8476f..3baab93 100644
--- a/pkg/kernel/lib/transformations/continuation.dart
+++ b/pkg/kernel/lib/transformations/continuation.dart
@@ -99,6 +99,7 @@
return transform(node);
}
+ @override
visitField(Field node, TreeNode? removalSentinel) {
staticTypeContext.enterMember(node);
final result = super.visitField(node, removalSentinel);
@@ -106,6 +107,7 @@
return result;
}
+ @override
visitConstructor(Constructor node, TreeNode? removalSentinel) {
staticTypeContext.enterMember(node);
final result = super.visitConstructor(node, removalSentinel);
@@ -283,6 +285,7 @@
return new YieldStatement(value, isNative: true);
}
+ @override
TreeNode visitTryCatch(TryCatch node, TreeNode? removalSentinel) {
// ignore: unnecessary_null_comparison
if (node.body != null) {
@@ -298,6 +301,7 @@
return node;
}
+ @override
TreeNode visitTryFinally(TryFinally node, TreeNode? removalSentinel) {
// ignore: unnecessary_null_comparison
if (node.body != null) {
@@ -492,6 +496,7 @@
]);
}
+ @override
visitYieldStatement(YieldStatement node, TreeNode? removalSentinel) {
Expression transformedExpression = transform(node.expression);
@@ -517,6 +522,7 @@
return new Block(statements);
}
+ @override
TreeNode visitReturnStatement(
ReturnStatement node, TreeNode? removalSentinel) {
// sync* functions cannot return a value.
@@ -655,6 +661,7 @@
List<Statement> statements = <Statement>[];
+ @override
TreeNode visitExpressionStatement(
ExpressionStatement stmt, TreeNode? removalSentinel) {
stmt.expression = expressionRewriter!.rewrite(stmt.expression, statements)
@@ -663,6 +670,7 @@
return removalSentinel ?? EmptyStatement();
}
+ @override
TreeNode visitBlock(Block stmt, TreeNode? removalSentinel) {
var saved = statements;
statements = <Statement>[];
@@ -674,11 +682,13 @@
return removalSentinel ?? EmptyStatement();
}
+ @override
TreeNode visitEmptyStatement(EmptyStatement stmt, TreeNode? removalSentinel) {
statements.add(stmt);
return removalSentinel ?? EmptyStatement();
}
+ @override
TreeNode visitAssertBlock(AssertBlock stmt, TreeNode? removalSentinel) {
var saved = statements;
statements = <Statement>[];
@@ -690,6 +700,7 @@
return removalSentinel ?? EmptyStatement();
}
+ @override
TreeNode visitAssertStatement(
AssertStatement stmt, TreeNode? removalSentinel) {
var condEffects = <Statement>[];
@@ -760,6 +771,7 @@
return result;
}
+ @override
TreeNode visitLabeledStatement(
LabeledStatement stmt, TreeNode? removalSentinel) {
stmt.body = visitDelimited(stmt.body)..parent = stmt;
@@ -767,11 +779,13 @@
return removalSentinel ?? EmptyStatement();
}
+ @override
TreeNode visitBreakStatement(BreakStatement stmt, TreeNode? removalSentinel) {
statements.add(stmt);
return removalSentinel ?? EmptyStatement();
}
+ @override
TreeNode visitWhileStatement(WhileStatement stmt, TreeNode? removalSentinel) {
Statement body = visitDelimited(stmt.body);
List<Statement> effects = <Statement>[];
@@ -801,6 +815,7 @@
return removalSentinel ?? EmptyStatement();
}
+ @override
TreeNode visitDoStatement(DoStatement stmt, TreeNode? removalSentinel) {
Statement body = visitDelimited(stmt.body);
List<Statement> effects = <Statement>[];
@@ -820,6 +835,7 @@
return removalSentinel ?? EmptyStatement();
}
+ @override
TreeNode visitForStatement(ForStatement stmt, TreeNode? removalSentinel) {
// Because of for-loop scoping and variable capture, it is tricky to deal
// with await in the loop's variable initializers or update expressions.
@@ -832,7 +848,7 @@
if (decl.initializer != null) {
decl.initializer = expressionRewriter!
.rewrite(decl.initializer!, statements)
- ..parent = decl;
+ ..parent = decl;
}
isSimple = isSimple && statements.isEmpty;
return statements;
@@ -963,6 +979,7 @@
return removalSentinel ?? EmptyStatement();
}
+ @override
TreeNode visitForInStatement(ForInStatement stmt, TreeNode? removalSentinel) {
if (stmt.isAsync) {
// Transform
@@ -1088,6 +1105,7 @@
}
}
+ @override
TreeNode visitSwitchStatement(
SwitchStatement stmt, TreeNode? removalSentinel) {
stmt.expression = expressionRewriter!.rewrite(stmt.expression, statements)
@@ -1101,12 +1119,14 @@
return removalSentinel ?? EmptyStatement();
}
+ @override
TreeNode visitContinueSwitchStatement(
ContinueSwitchStatement stmt, TreeNode? removalSentinel) {
statements.add(stmt);
return removalSentinel ?? EmptyStatement();
}
+ @override
TreeNode visitIfStatement(IfStatement stmt, TreeNode? removalSentinel) {
stmt.condition = expressionRewriter!.rewrite(stmt.condition, statements)
..parent = stmt;
@@ -1118,6 +1138,7 @@
return removalSentinel ?? EmptyStatement();
}
+ @override
TreeNode visitTryCatch(TryCatch stmt, TreeNode? removalSentinel) {
++currentTryDepth;
stmt.body = visitDelimited(stmt.body)..parent = stmt;
@@ -1132,6 +1153,7 @@
return removalSentinel ?? EmptyStatement();
}
+ @override
TreeNode visitTryFinally(TryFinally stmt, TreeNode? removalSentinel) {
++currentTryDepth;
stmt.body = visitDelimited(stmt.body)..parent = stmt;
@@ -1143,6 +1165,7 @@
return removalSentinel ?? EmptyStatement();
}
+ @override
TreeNode visitYieldStatement(YieldStatement stmt, TreeNode? removalSentinel) {
stmt.expression = expressionRewriter!.rewrite(stmt.expression, statements)
..parent = stmt;
@@ -1150,17 +1173,19 @@
return removalSentinel ?? EmptyStatement();
}
+ @override
TreeNode visitVariableDeclaration(
VariableDeclaration stmt, TreeNode? removalSentinel) {
if (stmt.initializer != null) {
stmt.initializer = expressionRewriter!
.rewrite(stmt.initializer!, statements)
- ..parent = stmt;
+ ..parent = stmt;
}
statements.add(stmt);
return removalSentinel ?? EmptyStatement();
}
+ @override
TreeNode visitFunctionDeclaration(
FunctionDeclaration stmt, TreeNode? removalSentinel) {
stmt.function = transform(stmt.function)..parent = stmt;
@@ -1168,6 +1193,7 @@
return removalSentinel ?? EmptyStatement();
}
+ @override
defaultExpression(TreeNode node, TreeNode? removalSentinel) =>
throw 'unreachable $node';
}
@@ -1231,6 +1257,7 @@
return enclosingFunction;
}
+ @override
Statement buildWrappedBody() {
++currentTryDepth;
Statement body = super.buildWrappedBody();
@@ -1249,6 +1276,7 @@
return tryFinally;
}
+ @override
Statement buildCatchBody(VariableDeclaration exceptionVariable,
VariableDeclaration stackTraceVariable) {
return new ExpressionStatement(new InstanceInvocation(
@@ -1264,6 +1292,7 @@
as FunctionType));
}
+ @override
Statement buildReturn(Statement body) {
// Async* functions cannot return a value. The returns from the function
// have been translated into breaks from the labeled body.
@@ -1273,6 +1302,7 @@
]);
}
+ @override
TreeNode visitYieldStatement(YieldStatement stmt, TreeNode? removalSentinel) {
Expression expr = expressionRewriter!.rewrite(stmt.expression, statements);
@@ -1298,6 +1328,7 @@
return removalSentinel ?? EmptyStatement();
}
+ @override
TreeNode visitReturnStatement(
ReturnStatement node, TreeNode? removalSentinel) {
// Async* functions cannot return a value.
@@ -1380,6 +1411,7 @@
}
// :async_op's try-catch catch body:
+ @override
Statement buildCatchBody(exceptionVariable, stackTraceVariable) {
// _completeOnAsyncError(_future, e, st, :is_sync)
return ExpressionStatement(StaticInvocation(
@@ -1393,6 +1425,7 @@
}
// :async_op's try-catch try body:
+ @override
Statement buildReturn(Statement body) {
// Returns from the body have all been translated into assignments to the
// return value variable followed by a break from the labeled body.
@@ -1413,6 +1446,7 @@
]);
}
+ @override
visitReturnStatement(ReturnStatement node, TreeNode? removalSentinel) {
var expr = node.expression == null
? new NullLiteral()
diff --git a/pkg/kernel/lib/transformations/scanner.dart b/pkg/kernel/lib/transformations/scanner.dart
index 18c7814..ec75cbd 100644
--- a/pkg/kernel/lib/transformations/scanner.dart
+++ b/pkg/kernel/lib/transformations/scanner.dart
@@ -18,18 +18,22 @@
Map<X, ScanResult<Y, TreeNode?>?> targets = new Map();
Map<X, ScanError>? errors;
+ @override
String toString() => 'ScanResult<$X,$Y>';
}
class ScanError {}
abstract class ClassScanner<Y extends TreeNode?> implements Scanner<Class, Y> {
+ @override
final Scanner<Y, TreeNode?>? next;
ClassScanner(this.next);
+ @override
bool predicate(Class node);
+ @override
ScanResult<Class, Y> scan(TreeNode node) {
ScanResult<Class, Y> result = new ScanResult<Class, Y>();
@@ -64,12 +68,15 @@
}
abstract class FieldScanner<Y extends TreeNode> implements Scanner<Field, Y> {
+ @override
final Scanner<Y, TreeNode>? next;
FieldScanner(this.next);
+ @override
bool predicate(Field node);
+ @override
ScanResult<Field, Y> scan(TreeNode node) {
ScanResult<Field, Y> result = new ScanResult<Field, Y>();
@@ -115,12 +122,15 @@
}
abstract class MemberScanner<Y extends TreeNode> implements Scanner<Member, Y> {
+ @override
final Scanner<Y, TreeNode?>? next;
MemberScanner(this.next);
+ @override
bool predicate(Member node);
+ @override
ScanResult<Member, Y> scan(TreeNode node) {
ScanResult<Member, Y> result = new ScanResult<Member, Y>();
@@ -167,12 +177,15 @@
abstract class ProcedureScanner<Y extends TreeNode?>
implements Scanner<Procedure, Y> {
+ @override
final Scanner<Y, TreeNode>? next;
ProcedureScanner(this.next);
+ @override
bool predicate(Procedure node);
+ @override
ScanResult<Procedure, Y> scan(TreeNode node) {
ScanResult<Procedure, Y> result = new ScanResult<Procedure, Y>();
@@ -219,13 +232,16 @@
abstract class ExpressionScanner<Y extends TreeNode>
extends RecursiveResultVisitor<void> implements Scanner<Expression, Y> {
+ @override
final Scanner<Y, TreeNode>? next;
ScanResult<Expression, Y>? _result;
ExpressionScanner(this.next);
+ @override
bool predicate(Expression node);
+ @override
ScanResult<Expression, Y> scan(TreeNode node) {
ScanResult<Expression, Y> result =
_result = new ScanResult<Expression, Y>();
@@ -245,13 +261,16 @@
abstract class MethodInvocationScanner<Y extends TreeNode?>
extends RecursiveVisitor
implements Scanner<InstanceInvocationExpression, Y> {
+ @override
final Scanner<Y, TreeNode>? next;
ScanResult<InstanceInvocationExpression, Y>? _result;
MethodInvocationScanner(this.next);
+ @override
bool predicate(InstanceInvocationExpression node);
+ @override
ScanResult<InstanceInvocationExpression, Y> scan(TreeNode node) {
ScanResult<InstanceInvocationExpression, Y> result =
_result = new ScanResult<InstanceInvocationExpression, Y>();
@@ -260,6 +279,7 @@
return result;
}
+ @override
void visitInstanceInvocation(InstanceInvocation node) {
if (predicate(node)) {
_result!.targets[node] = next?.scan(node);
diff --git a/pkg/kernel/lib/transformations/value_class.dart b/pkg/kernel/lib/transformations/value_class.dart
index 61481e5..cbb27dc 100644
--- a/pkg/kernel/lib/transformations/value_class.dart
+++ b/pkg/kernel/lib/transformations/value_class.dart
@@ -15,12 +15,14 @@
class ValueClassScanner extends ClassScanner<Null> {
ValueClassScanner() : super(null);
+ @override
bool predicate(Class node) => isValueClass(node);
}
class JenkinsClassScanner extends ClassScanner<Procedure> {
JenkinsClassScanner(Scanner<Procedure, TreeNode?> next) : super(next);
+ @override
bool predicate(Class node) {
return node.name == "JenkinsSmiHash";
}
@@ -29,6 +31,7 @@
class HashCombineMethodsScanner extends ProcedureScanner<Null> {
HashCombineMethodsScanner() : super(null);
+ @override
bool predicate(Procedure node) {
return node.name.text == "combine" || node.name.text == "finish";
}
@@ -38,6 +41,7 @@
AllMemberScanner(Scanner<InstanceInvocationExpression, TreeNode?> next)
: super(next);
+ @override
bool predicate(Member member) => true;
}
@@ -50,6 +54,7 @@
// @valueClass V {}
// V v;
// (v as dynamic).copyWith() as V
+ @override
bool predicate(InstanceInvocationExpression node) {
return node.name.text == "copyWith" &&
_isValueClassAsConstruct(node.receiver);
@@ -346,8 +351,8 @@
.map<VariableDeclaration>(
(f) => VariableDeclaration(f.name, type: f.type))
.toList()
- ..addAll(cls.fields.map<VariableDeclaration>(
- (f) => VariableDeclaration(f.name.text, type: f.type)));
+ ..addAll(cls.fields.map<VariableDeclaration>(
+ (f) => VariableDeclaration(f.name.text, type: f.type)));
}
void removeValueClassAnnotation(Class cls) {
diff --git a/pkg/kernel/lib/type_algebra.dart b/pkg/kernel/lib/type_algebra.dart
index 9581107..f836d1e 100644
--- a/pkg/kernel/lib/type_algebra.dart
+++ b/pkg/kernel/lib/type_algebra.dart
@@ -298,6 +298,7 @@
const _NullSubstitution();
+ @override
DartType getSubstitute(TypeParameter parameter, bool upperBound) {
return new TypeParameterType.forAlphaRenaming(parameter, parameter);
}
@@ -318,6 +319,7 @@
_MapSubstitution(this.upper, this.lower);
+ @override
DartType? getSubstitute(TypeParameter parameter, bool upperBound) {
return upperBound ? upper[parameter] : lower[parameter];
}
@@ -335,10 +337,12 @@
}
}
+ @override
DartType? lookup(TypeParameter parameter, bool upperBound) {
return substitution.getSubstitute(parameter, upperBound);
}
+ @override
TypeParameter freshTypeParameter(TypeParameter node) {
throw 'Create a fresh environment first';
}
@@ -349,6 +353,7 @@
_ClassBottomSubstitution(this.class_);
+ @override
DartType? getSubstitute(TypeParameter parameter, bool upperBound) {
if (parameter.parent == class_) {
return upperBound ? const NeverType.nonNullable() : const DynamicType();
@@ -362,6 +367,7 @@
_CombinedSubstitution(this.first, this.second);
+ @override
DartType? getSubstitute(TypeParameter parameter, bool upperBound) {
return first.getSubstitute(parameter, upperBound) ??
second.getSubstitute(parameter, upperBound);
@@ -376,6 +382,7 @@
_FilteredSubstitution(this.base, this.filterFn);
+ @override
DartType? getSubstitute(TypeParameter parameter, bool upperBound) {
return filterFn(parameter)
? base.getSubstitute(parameter, upperBound)
@@ -388,10 +395,12 @@
_InnerTypeSubstitutor(_TypeSubstitutor? outer) : super(outer);
+ @override
DartType? lookup(TypeParameter parameter, bool upperBound) {
return substitution[parameter];
}
+ @override
TypeParameter freshTypeParameter(TypeParameter node) {
TypeParameter fresh = new TypeParameter(node.name)..flags = node.flags;
TypeParameterType typeParameterType = substitution[node] =
@@ -578,13 +587,20 @@
DartType visit(DartType node) => node.accept(this);
+ @override
DartType defaultDartType(DartType node) => node;
+ @override
DartType visitInvalidType(InvalidType node) => node;
+ @override
DartType visitDynamicType(DynamicType node) => node;
+ @override
DartType visitVoidType(VoidType node) => node;
+ @override
DartType visitNeverType(NeverType node) => node;
+ @override
DartType visitNullType(NullType node) => node;
+ @override
DartType visitInterfaceType(InterfaceType node) {
if (node.typeArguments.isEmpty) return node;
int before = useCounter;
@@ -593,6 +609,7 @@
return new InterfaceType(node.classNode, node.nullability, typeArguments);
}
+ @override
DartType visitFutureOrType(FutureOrType node) {
int before = useCounter;
DartType typeArgument = node.typeArgument.accept(this);
@@ -600,6 +617,7 @@
return new FutureOrType(typeArgument, node.declaredNullability);
}
+ @override
DartType visitTypedefType(TypedefType node) {
if (node.typeArguments.isEmpty) return node;
int before = useCounter;
@@ -615,6 +633,7 @@
TypeParameter freshTypeParameter(TypeParameter node);
+ @override
DartType visitFunctionType(FunctionType node) {
// This is a bit tricky because we have to generate fresh type parameters
// in order to change the bounds. At the same time, if the function type
@@ -682,6 +701,7 @@
return null;
}
+ @override
DartType visitTypeParameterType(TypeParameterType node) {
DartType? replacement = getSubstitute(node.parameter);
if (replacement is InvalidType) return replacement;
@@ -749,6 +769,7 @@
return visit(node.type);
}
+ @override
bool defaultDartType(DartType node) {
if (unhandledTypeHandler == null) {
throw new UnsupportedError("Unsupported type '${node.runtimeType}'.");
@@ -757,28 +778,38 @@
}
}
+ @override
bool visitNeverType(NeverType node) => false;
+ @override
bool visitNullType(NullType node) => false;
+ @override
bool visitInvalidType(InvalidType node) => false;
+ @override
bool visitDynamicType(DynamicType node) => false;
+ @override
bool visitVoidType(VoidType node) => false;
+ @override
bool visitInterfaceType(InterfaceType node) {
return node.typeArguments.any(visit);
}
+ @override
bool visitExtensionType(ExtensionType node) {
return node.typeArguments.any(visit);
}
+ @override
bool visitFutureOrType(FutureOrType node) {
return visit(node.typeArgument);
}
+ @override
bool visitTypedefType(TypedefType node) {
return node.typeArguments.any(visit);
}
+ @override
bool visitFunctionType(FunctionType node) {
return node.typeParameters.any(handleTypeParameter) ||
node.positionalParameters.any(visit) ||
@@ -786,6 +817,7 @@
visit(node.returnType);
}
+ @override
bool visitTypeParameterType(TypeParameterType node) {
return variables.contains(node.parameter);
}
@@ -806,6 +838,7 @@
bool visit(DartType node) => node.accept(this);
+ @override
bool defaultDartType(DartType node) {
throw new UnsupportedError("Unsupported type $node (${node.runtimeType}.");
}
@@ -814,28 +847,38 @@
return visit(node.type);
}
+ @override
bool visitNeverType(NeverType node) => false;
+ @override
bool visitNullType(NullType node) => false;
+ @override
bool visitInvalidType(InvalidType node) => false;
+ @override
bool visitDynamicType(DynamicType node) => false;
+ @override
bool visitVoidType(VoidType node) => false;
+ @override
bool visitInterfaceType(InterfaceType node) {
return node.typeArguments.any(visit);
}
+ @override
bool visitExtensionType(ExtensionType node) {
return node.typeArguments.any(visit);
}
+ @override
bool visitFutureOrType(FutureOrType node) {
return visit(node.typeArgument);
}
+ @override
bool visitTypedefType(TypedefType node) {
return node.typeArguments.any(visit);
}
+ @override
bool visitFunctionType(FunctionType node) {
variables.addAll(node.typeParameters);
bool result = node.typeParameters.any(handleTypeParameter) ||
@@ -846,6 +889,7 @@
return result;
}
+ @override
bool visitTypeParameterType(TypeParameterType node) {
return node.parameter.parent == null && !variables.contains(node.parameter);
}
@@ -866,6 +910,7 @@
bool visit(DartType node) => node.accept(this);
+ @override
bool defaultDartType(DartType node) {
throw new UnsupportedError("Unsupported type $node (${node.runtimeType}.");
}
@@ -874,28 +919,38 @@
return visit(node.type);
}
+ @override
bool visitNeverType(NeverType node) => false;
+ @override
bool visitNullType(NullType node) => false;
+ @override
bool visitInvalidType(InvalidType node) => false;
+ @override
bool visitDynamicType(DynamicType node) => false;
+ @override
bool visitVoidType(VoidType node) => false;
+ @override
bool visitInterfaceType(InterfaceType node) {
return node.typeArguments.any(visit);
}
+ @override
bool visitExtensionType(ExtensionType node) {
return node.typeArguments.any(visit);
}
+ @override
bool visitFutureOrType(FutureOrType node) {
return visit(node.typeArgument);
}
+ @override
bool visitTypedefType(TypedefType node) {
return node.typeArguments.any(visit);
}
+ @override
bool visitFunctionType(FunctionType node) {
variables.addAll(node.typeParameters);
bool result = node.typeParameters.any(handleTypeParameter) ||
@@ -906,6 +961,7 @@
return result;
}
+ @override
bool visitTypeParameterType(TypeParameterType node) {
return !variables.contains(node.parameter);
}
diff --git a/pkg/kernel/lib/type_checker.dart b/pkg/kernel/lib/type_checker.dart
index 8d9cacc..b321095 100644
--- a/pkg/kernel/lib/type_checker.dart
+++ b/pkg/kernel/lib/type_checker.dart
@@ -170,24 +170,30 @@
node.accept(this);
}
+ @override
defaultMember(Member node) => throw 'Unused';
+ @override
DartType defaultBasicLiteral(BasicLiteral node) {
return defaultExpression(node);
}
+ @override
DartType defaultExpression(Expression node) {
throw 'Unexpected expression ${node.runtimeType}';
}
+ @override
defaultStatement(Statement node) {
throw 'Unexpected statement ${node.runtimeType}';
}
+ @override
defaultInitializer(Initializer node) {
throw 'Unexpected initializer ${node.runtimeType}';
}
+ @override
visitField(Field node) {
if (node.initializer != null) {
node.initializer =
@@ -195,6 +201,7 @@
}
}
+ @override
visitConstructor(Constructor node) {
currentReturnType = null;
currentYieldType = null;
@@ -202,12 +209,14 @@
handleFunctionNode(node.function);
}
+ @override
visitProcedure(Procedure node) {
currentReturnType = _getInternalReturnType(node.function);
currentYieldType = _getYieldType(node.function);
handleFunctionNode(node.function);
}
+ @override
visitRedirectingFactory(RedirectingFactory node) {
currentReturnType = null;
currentYieldType = null;
diff --git a/pkg/kernel/lib/type_environment.dart b/pkg/kernel/lib/type_environment.dart
index f0b4795..6b22016 100644
--- a/pkg/kernel/lib/type_environment.dart
+++ b/pkg/kernel/lib/type_environment.dart
@@ -16,6 +16,7 @@
typedef void ErrorHandler(TreeNode node, String message);
abstract class TypeEnvironment extends Types {
+ @override
final CoreTypes coreTypes;
TypeEnvironment.fromSubclass(this.coreTypes, ClassHierarchyBase base)
@@ -509,6 +510,7 @@
return _value == _valueAlways;
}
+ @override
String toString() {
switch (_value) {
case _valueAlways:
@@ -540,15 +542,18 @@
late Map<ForInStatement, DartType> _forInIteratorTypes = {};
late Map<ForInStatement, DartType> _forInElementTypes = {};
+ @override
DartType getExpressionType(Expression node, StaticTypeContext context) {
return _expressionTypes[node] ??= node.getStaticTypeInternal(context);
}
+ @override
DartType getForInIteratorType(
ForInStatement node, StaticTypeContext context) {
return _forInIteratorTypes[node] ??= node.getIteratorTypeInternal(context);
}
+ @override
DartType getForInElementType(ForInStatement node, StaticTypeContext context) {
return _forInElementTypes[node] ??= node.getElementTypeInternal(context);
}
@@ -610,6 +615,7 @@
/// The [TypeEnvironment] used for the static type computation.
///
/// This provides access to the core types and the class hierarchy.
+ @override
final TypeEnvironment typeEnvironment;
/// The library in which the static type is computed.
@@ -619,6 +625,7 @@
final Library _library;
/// The static type of a `this` expression.
+ @override
final InterfaceType? thisType;
final StaticTypeCache? _cache;
@@ -642,21 +649,26 @@
/// The [Nullability] used for non-nullable types.
///
/// For opt out libraries this is [Nullability.legacy].
+ @override
Nullability get nonNullable => _library.nonNullable;
/// The [Nullability] used for nullable types.
///
/// For opt out libraries this is [Nullability.legacy].
+ @override
Nullability get nullable => _library.nullable;
/// Return `true` if the current library is opted in to non-nullable by
/// default.
+ @override
bool get isNonNullableByDefault => _library.isNonNullableByDefault;
/// Returns the mode under which the current library was compiled.
+ @override
NonNullableByDefaultCompiledMode get nonNullableByDefaultCompiledMode =>
_library.nonNullableByDefaultCompiledMode;
+ @override
DartType getExpressionType(Expression node) {
if (_cache != null) {
return _cache!.getExpressionType(node, this);
@@ -665,6 +677,7 @@
}
}
+ @override
DartType getForInIteratorType(ForInStatement node) {
if (_cache != null) {
return _cache!.getForInIteratorType(node, this);
@@ -673,6 +686,7 @@
}
}
+ @override
DartType getForInElementType(ForInStatement node) {
if (_cache != null) {
return _cache!.getForInElementType(node, this);
diff --git a/pkg/kernel/lib/verifier.dart b/pkg/kernel/lib/verifier.dart
index 9ef4115..7581e08 100644
--- a/pkg/kernel/lib/verifier.dart
+++ b/pkg/kernel/lib/verifier.dart
@@ -22,6 +22,7 @@
VerificationError(this.context, this.node, this.details);
+ @override
toString() {
Location? location;
try {
@@ -209,6 +210,7 @@
}
}
+ @override
visitComponent(Component component) {
try {
for (Library library in component.libraries) {
@@ -239,12 +241,14 @@
}
}
+ @override
void visitLibrary(Library node) {
currentLibrary = node;
super.visitLibrary(node);
currentLibrary = null;
}
+ @override
visitExtension(Extension node) {
currentExtension = node;
declareTypeParameters(node.typeParameters);
@@ -276,12 +280,14 @@
typedefState[node] = TypedefState.Done;
}
+ @override
visitTypedef(Typedef node) {
checkTypedef(node);
// Enter and exit the node to check the parent pointer on the typedef node.
exitParent(enterParent(node));
}
+ @override
visitField(Field node) {
currentMember = node;
TreeNode? oldParent = enterParent(node);
@@ -324,6 +330,7 @@
currentMember = null;
}
+ @override
visitProcedure(Procedure node) {
currentMember = node;
TreeNode? oldParent = enterParent(node);
@@ -374,6 +381,7 @@
currentMember = null;
}
+ @override
visitConstructor(Constructor node) {
currentMember = node;
classTypeParametersAreInScope = true;
@@ -394,6 +402,7 @@
currentMember = null;
}
+ @override
visitClass(Class node) {
currentClass = node;
declareTypeParameters(node.typeParameters);
@@ -410,6 +419,7 @@
currentClass = null;
}
+ @override
visitFunctionNode(FunctionNode node) {
declareTypeParameters(node.typeParameters);
bool savedInCatchBlock = inCatchBlock;
@@ -429,6 +439,7 @@
undeclareTypeParameters(node.typeParameters);
}
+ @override
visitFunctionType(FunctionType node) {
for (int i = 1; i < node.namedParameters.length; ++i) {
if (node.namedParameters[i - 1].compareTo(node.namedParameters[i]) >= 0) {
@@ -450,18 +461,22 @@
undeclareTypeParameters(node.typeParameters);
}
+ @override
visitBlock(Block node) {
visitWithLocalScope(node);
}
+ @override
visitForStatement(ForStatement node) {
visitWithLocalScope(node);
}
+ @override
visitForInStatement(ForInStatement node) {
visitWithLocalScope(node);
}
+ @override
visitLet(Let node) {
if (_isCompileTimeErrorEncoding(node)) return;
visitWithLocalScope(node);
@@ -472,6 +487,7 @@
return;
}
+ @override
visitBlockExpression(BlockExpression node) {
int stackHeight = enterLocalScope();
// Do not visit the block directly because the value expression needs to
@@ -487,6 +503,7 @@
exitLocalScope(stackHeight);
}
+ @override
visitCatch(Catch node) {
bool savedInCatchBlock = inCatchBlock;
inCatchBlock = true;
@@ -539,6 +556,7 @@
}
}
+ @override
visitVariableDeclaration(VariableDeclaration node) {
TreeNode? parent = node.parent;
if (parent is! Block &&
@@ -567,6 +585,7 @@
}
}
+ @override
visitVariableGet(VariableGet node) {
checkVariableInScope(node.variable, node);
visitChildren(node);
@@ -575,6 +594,7 @@
}
}
+ @override
visitVariableSet(VariableSet node) {
checkVariableInScope(node.variable, node);
visitChildren(node);
@@ -999,6 +1019,7 @@
CheckParentPointers([this.parent]);
+ @override
defaultTreeNode(TreeNode node) {
if (node.parent != parent) {
throw new VerificationError(
diff --git a/pkg/kernel/lib/visitor.dart b/pkg/kernel/lib/visitor.dart
index 5e5c959..cbd116e 100644
--- a/pkg/kernel/lib/visitor.dart
+++ b/pkg/kernel/lib/visitor.dart
@@ -186,109 +186,197 @@
R defaultTreeNode(TreeNode node);
// Expressions
+ @override
R defaultExpression(Expression node) => defaultTreeNode(node);
+ @override
R defaultBasicLiteral(BasicLiteral node) => defaultExpression(node);
+ @override
R visitInvalidExpression(InvalidExpression node) => defaultExpression(node);
+ @override
R visitVariableGet(VariableGet node) => defaultExpression(node);
+ @override
R visitVariableSet(VariableSet node) => defaultExpression(node);
+ @override
R visitDynamicGet(DynamicGet node) => defaultExpression(node);
+ @override
R visitDynamicSet(DynamicSet node) => defaultExpression(node);
+ @override
R visitFunctionTearOff(FunctionTearOff node) => defaultExpression(node);
+ @override
R visitInstanceGet(InstanceGet node) => defaultExpression(node);
+ @override
R visitInstanceSet(InstanceSet node) => defaultExpression(node);
+ @override
R visitInstanceTearOff(InstanceTearOff node) => defaultExpression(node);
+ @override
R visitSuperPropertyGet(SuperPropertyGet node) => defaultExpression(node);
+ @override
R visitSuperPropertySet(SuperPropertySet node) => defaultExpression(node);
+ @override
R visitStaticGet(StaticGet node) => defaultExpression(node);
+ @override
R visitStaticSet(StaticSet node) => defaultExpression(node);
+ @override
R visitStaticTearOff(StaticTearOff node) => defaultExpression(node);
+ @override
R visitLocalFunctionInvocation(LocalFunctionInvocation node) =>
defaultExpression(node);
+ @override
R visitDynamicInvocation(DynamicInvocation node) => defaultExpression(node);
+ @override
R visitFunctionInvocation(FunctionInvocation node) => defaultExpression(node);
+ @override
R visitInstanceInvocation(InstanceInvocation node) => defaultExpression(node);
+ @override
R visitInstanceGetterInvocation(InstanceGetterInvocation node) =>
defaultExpression(node);
+ @override
R visitEqualsNull(EqualsNull node) => defaultExpression(node);
+ @override
R visitEqualsCall(EqualsCall node) => defaultExpression(node);
+ @override
R visitSuperMethodInvocation(SuperMethodInvocation node) =>
defaultExpression(node);
+ @override
R visitStaticInvocation(StaticInvocation node) => defaultExpression(node);
+ @override
R visitConstructorInvocation(ConstructorInvocation node) =>
defaultExpression(node);
+ @override
R visitNot(Not node) => defaultExpression(node);
+ @override
R visitNullCheck(NullCheck node) => defaultExpression(node);
+ @override
R visitLogicalExpression(LogicalExpression node) => defaultExpression(node);
+ @override
R visitConditionalExpression(ConditionalExpression node) =>
defaultExpression(node);
+ @override
R visitStringConcatenation(StringConcatenation node) =>
defaultExpression(node);
+ @override
R visitListConcatenation(ListConcatenation node) => defaultExpression(node);
+ @override
R visitSetConcatenation(SetConcatenation node) => defaultExpression(node);
+ @override
R visitMapConcatenation(MapConcatenation node) => defaultExpression(node);
+ @override
R visitInstanceCreation(InstanceCreation node) => defaultExpression(node);
+ @override
R visitFileUriExpression(FileUriExpression node) => defaultExpression(node);
+ @override
R visitIsExpression(IsExpression node) => defaultExpression(node);
+ @override
R visitAsExpression(AsExpression node) => defaultExpression(node);
+ @override
R visitSymbolLiteral(SymbolLiteral node) => defaultExpression(node);
+ @override
R visitTypeLiteral(TypeLiteral node) => defaultExpression(node);
+ @override
R visitThisExpression(ThisExpression node) => defaultExpression(node);
+ @override
R visitRethrow(Rethrow node) => defaultExpression(node);
+ @override
R visitThrow(Throw node) => defaultExpression(node);
+ @override
R visitListLiteral(ListLiteral node) => defaultExpression(node);
+ @override
R visitSetLiteral(SetLiteral node) => defaultExpression(node);
+ @override
R visitMapLiteral(MapLiteral node) => defaultExpression(node);
+ @override
R visitAwaitExpression(AwaitExpression node) => defaultExpression(node);
+ @override
R visitFunctionExpression(FunctionExpression node) => defaultExpression(node);
+ @override
R visitConstantExpression(ConstantExpression node) => defaultExpression(node);
+ @override
R visitStringLiteral(StringLiteral node) => defaultBasicLiteral(node);
+ @override
R visitIntLiteral(IntLiteral node) => defaultBasicLiteral(node);
+ @override
R visitDoubleLiteral(DoubleLiteral node) => defaultBasicLiteral(node);
+ @override
R visitBoolLiteral(BoolLiteral node) => defaultBasicLiteral(node);
+ @override
R visitNullLiteral(NullLiteral node) => defaultBasicLiteral(node);
+ @override
R visitLet(Let node) => defaultExpression(node);
+ @override
R visitBlockExpression(BlockExpression node) => defaultExpression(node);
+ @override
R visitInstantiation(Instantiation node) => defaultExpression(node);
+ @override
R visitLoadLibrary(LoadLibrary node) => defaultExpression(node);
+ @override
R visitCheckLibraryIsLoaded(CheckLibraryIsLoaded node) =>
defaultExpression(node);
+ @override
R visitConstructorTearOff(ConstructorTearOff node) => defaultExpression(node);
+ @override
R visitRedirectingFactoryTearOff(RedirectingFactoryTearOff node) =>
defaultExpression(node);
+ @override
R visitTypedefTearOff(TypedefTearOff node) => defaultExpression(node);
// Statements
+ @override
R defaultStatement(Statement node) => defaultTreeNode(node);
+ @override
R visitExpressionStatement(ExpressionStatement node) =>
defaultStatement(node);
+ @override
R visitBlock(Block node) => defaultStatement(node);
+ @override
R visitAssertBlock(AssertBlock node) => defaultStatement(node);
+ @override
R visitEmptyStatement(EmptyStatement node) => defaultStatement(node);
+ @override
R visitAssertStatement(AssertStatement node) => defaultStatement(node);
+ @override
R visitLabeledStatement(LabeledStatement node) => defaultStatement(node);
+ @override
R visitBreakStatement(BreakStatement node) => defaultStatement(node);
+ @override
R visitWhileStatement(WhileStatement node) => defaultStatement(node);
+ @override
R visitDoStatement(DoStatement node) => defaultStatement(node);
+ @override
R visitForStatement(ForStatement node) => defaultStatement(node);
+ @override
R visitForInStatement(ForInStatement node) => defaultStatement(node);
+ @override
R visitSwitchStatement(SwitchStatement node) => defaultStatement(node);
+ @override
R visitContinueSwitchStatement(ContinueSwitchStatement node) =>
defaultStatement(node);
+ @override
R visitIfStatement(IfStatement node) => defaultStatement(node);
+ @override
R visitReturnStatement(ReturnStatement node) => defaultStatement(node);
+ @override
R visitTryCatch(TryCatch node) => defaultStatement(node);
+ @override
R visitTryFinally(TryFinally node) => defaultStatement(node);
+ @override
R visitYieldStatement(YieldStatement node) => defaultStatement(node);
+ @override
R visitVariableDeclaration(VariableDeclaration node) =>
defaultStatement(node);
+ @override
R visitFunctionDeclaration(FunctionDeclaration node) =>
defaultStatement(node);
// Members
+ @override
R defaultMember(Member node) => defaultTreeNode(node);
+ @override
R visitConstructor(Constructor node) => defaultMember(node);
+ @override
R visitProcedure(Procedure node) => defaultMember(node);
+ @override
R visitField(Field node) => defaultMember(node);
+ @override
R visitRedirectingFactory(RedirectingFactory node) {
return defaultMember(node);
}
@@ -298,14 +386,21 @@
R visitExtension(Extension node) => defaultTreeNode(node);
// Initializers
+ @override
R defaultInitializer(Initializer node) => defaultTreeNode(node);
+ @override
R visitInvalidInitializer(InvalidInitializer node) =>
defaultInitializer(node);
+ @override
R visitFieldInitializer(FieldInitializer node) => defaultInitializer(node);
+ @override
R visitSuperInitializer(SuperInitializer node) => defaultInitializer(node);
+ @override
R visitRedirectingInitializer(RedirectingInitializer node) =>
defaultInitializer(node);
+ @override
R visitLocalInitializer(LocalInitializer node) => defaultInitializer(node);
+ @override
R visitAssertInitializer(AssertInitializer node) => defaultInitializer(node);
// Other tree nodes
@@ -335,146 +430,234 @@
R defaultTreeNode(TreeNode node, A arg);
// Expressions
+ @override
R defaultExpression(Expression node, A arg) => defaultTreeNode(node, arg);
+ @override
R defaultBasicLiteral(BasicLiteral node, A arg) =>
defaultExpression(node, arg);
+ @override
R visitInvalidExpression(InvalidExpression node, A arg) =>
defaultExpression(node, arg);
+ @override
R visitVariableGet(VariableGet node, A arg) => defaultExpression(node, arg);
+ @override
R visitVariableSet(VariableSet node, A arg) => defaultExpression(node, arg);
+ @override
R visitDynamicGet(DynamicGet node, A arg) => defaultExpression(node, arg);
+ @override
R visitDynamicSet(DynamicSet node, A arg) => defaultExpression(node, arg);
+ @override
R visitFunctionTearOff(FunctionTearOff node, A arg) =>
defaultExpression(node, arg);
+ @override
R visitInstanceGet(InstanceGet node, A arg) => defaultExpression(node, arg);
+ @override
R visitInstanceSet(InstanceSet node, A arg) => defaultExpression(node, arg);
+ @override
R visitInstanceTearOff(InstanceTearOff node, A arg) =>
defaultExpression(node, arg);
+ @override
R visitSuperPropertyGet(SuperPropertyGet node, A arg) =>
defaultExpression(node, arg);
+ @override
R visitSuperPropertySet(SuperPropertySet node, A arg) =>
defaultExpression(node, arg);
+ @override
R visitStaticGet(StaticGet node, A arg) => defaultExpression(node, arg);
+ @override
R visitStaticSet(StaticSet node, A arg) => defaultExpression(node, arg);
+ @override
R visitStaticTearOff(StaticTearOff node, A arg) =>
defaultExpression(node, arg);
+ @override
R visitLocalFunctionInvocation(LocalFunctionInvocation node, A arg) =>
defaultExpression(node, arg);
+ @override
R visitDynamicInvocation(DynamicInvocation node, A arg) =>
defaultExpression(node, arg);
+ @override
R visitFunctionInvocation(FunctionInvocation node, A arg) =>
defaultExpression(node, arg);
+ @override
R visitInstanceInvocation(InstanceInvocation node, A arg) =>
defaultExpression(node, arg);
+ @override
R visitInstanceGetterInvocation(InstanceGetterInvocation node, A arg) =>
defaultExpression(node, arg);
+ @override
R visitEqualsNull(EqualsNull node, A arg) => defaultExpression(node, arg);
+ @override
R visitEqualsCall(EqualsCall node, A arg) => defaultExpression(node, arg);
+ @override
R visitSuperMethodInvocation(SuperMethodInvocation node, A arg) =>
defaultExpression(node, arg);
+ @override
R visitStaticInvocation(StaticInvocation node, A arg) =>
defaultExpression(node, arg);
+ @override
R visitConstructorInvocation(ConstructorInvocation node, A arg) =>
defaultExpression(node, arg);
+ @override
R visitNot(Not node, A arg) => defaultExpression(node, arg);
+ @override
R visitNullCheck(NullCheck node, A arg) => defaultExpression(node, arg);
+ @override
R visitLogicalExpression(LogicalExpression node, A arg) =>
defaultExpression(node, arg);
+ @override
R visitConditionalExpression(ConditionalExpression node, A arg) =>
defaultExpression(node, arg);
+ @override
R visitStringConcatenation(StringConcatenation node, A arg) =>
defaultExpression(node, arg);
+ @override
R visitListConcatenation(ListConcatenation node, A arg) =>
defaultExpression(node, arg);
+ @override
R visitSetConcatenation(SetConcatenation node, A arg) =>
defaultExpression(node, arg);
+ @override
R visitMapConcatenation(MapConcatenation node, A arg) =>
defaultExpression(node, arg);
+ @override
R visitInstanceCreation(InstanceCreation node, A arg) =>
defaultExpression(node, arg);
+ @override
R visitFileUriExpression(FileUriExpression node, A arg) =>
defaultExpression(node, arg);
+ @override
R visitIsExpression(IsExpression node, A arg) => defaultExpression(node, arg);
+ @override
R visitAsExpression(AsExpression node, A arg) => defaultExpression(node, arg);
+ @override
R visitSymbolLiteral(SymbolLiteral node, A arg) =>
defaultExpression(node, arg);
+ @override
R visitTypeLiteral(TypeLiteral node, A arg) => defaultExpression(node, arg);
+ @override
R visitThisExpression(ThisExpression node, A arg) =>
defaultExpression(node, arg);
+ @override
R visitRethrow(Rethrow node, A arg) => defaultExpression(node, arg);
+ @override
R visitThrow(Throw node, A arg) => defaultExpression(node, arg);
+ @override
R visitListLiteral(ListLiteral node, A arg) => defaultExpression(node, arg);
+ @override
R visitSetLiteral(SetLiteral node, A arg) => defaultExpression(node, arg);
+ @override
R visitMapLiteral(MapLiteral node, A arg) => defaultExpression(node, arg);
+ @override
R visitAwaitExpression(AwaitExpression node, A arg) =>
defaultExpression(node, arg);
+ @override
R visitFunctionExpression(FunctionExpression node, A arg) =>
defaultExpression(node, arg);
+ @override
R visitConstantExpression(ConstantExpression node, A arg) =>
defaultExpression(node, arg);
+ @override
R visitStringLiteral(StringLiteral node, A arg) =>
defaultBasicLiteral(node, arg);
+ @override
R visitIntLiteral(IntLiteral node, A arg) => defaultBasicLiteral(node, arg);
+ @override
R visitDoubleLiteral(DoubleLiteral node, A arg) =>
defaultBasicLiteral(node, arg);
+ @override
R visitBoolLiteral(BoolLiteral node, A arg) => defaultBasicLiteral(node, arg);
+ @override
R visitNullLiteral(NullLiteral node, A arg) => defaultBasicLiteral(node, arg);
+ @override
R visitLet(Let node, A arg) => defaultExpression(node, arg);
+ @override
R visitBlockExpression(BlockExpression node, A arg) =>
defaultExpression(node, arg);
+ @override
R visitInstantiation(Instantiation node, A arg) =>
defaultExpression(node, arg);
+ @override
R visitLoadLibrary(LoadLibrary node, A arg) => defaultExpression(node, arg);
+ @override
R visitCheckLibraryIsLoaded(CheckLibraryIsLoaded node, A arg) =>
defaultExpression(node, arg);
+ @override
R visitConstructorTearOff(ConstructorTearOff node, A arg) =>
defaultExpression(node, arg);
+ @override
R visitRedirectingFactoryTearOff(RedirectingFactoryTearOff node, A arg) =>
defaultExpression(node, arg);
+ @override
R visitTypedefTearOff(TypedefTearOff node, A arg) =>
defaultExpression(node, arg);
// Statements
+ @override
R defaultStatement(Statement node, A arg) => defaultTreeNode(node, arg);
+ @override
R visitExpressionStatement(ExpressionStatement node, A arg) =>
defaultStatement(node, arg);
+ @override
R visitBlock(Block node, A arg) => defaultStatement(node, arg);
+ @override
R visitAssertBlock(AssertBlock node, A arg) => defaultStatement(node, arg);
+ @override
R visitEmptyStatement(EmptyStatement node, A arg) =>
defaultStatement(node, arg);
+ @override
R visitAssertStatement(AssertStatement node, A arg) =>
defaultStatement(node, arg);
+ @override
R visitLabeledStatement(LabeledStatement node, A arg) =>
defaultStatement(node, arg);
+ @override
R visitBreakStatement(BreakStatement node, A arg) =>
defaultStatement(node, arg);
+ @override
R visitWhileStatement(WhileStatement node, A arg) =>
defaultStatement(node, arg);
+ @override
R visitDoStatement(DoStatement node, A arg) => defaultStatement(node, arg);
+ @override
R visitForStatement(ForStatement node, A arg) => defaultStatement(node, arg);
+ @override
R visitForInStatement(ForInStatement node, A arg) =>
defaultStatement(node, arg);
+ @override
R visitSwitchStatement(SwitchStatement node, A arg) =>
defaultStatement(node, arg);
+ @override
R visitContinueSwitchStatement(ContinueSwitchStatement node, A arg) =>
defaultStatement(node, arg);
+ @override
R visitIfStatement(IfStatement node, A arg) => defaultStatement(node, arg);
+ @override
R visitReturnStatement(ReturnStatement node, A arg) =>
defaultStatement(node, arg);
+ @override
R visitTryCatch(TryCatch node, A arg) => defaultStatement(node, arg);
+ @override
R visitTryFinally(TryFinally node, A arg) => defaultStatement(node, arg);
+ @override
R visitYieldStatement(YieldStatement node, A arg) =>
defaultStatement(node, arg);
+ @override
R visitVariableDeclaration(VariableDeclaration node, A arg) =>
defaultStatement(node, arg);
+ @override
R visitFunctionDeclaration(FunctionDeclaration node, A arg) =>
defaultStatement(node, arg);
// Members
+ @override
R defaultMember(Member node, A arg) => defaultTreeNode(node, arg);
+ @override
R visitConstructor(Constructor node, A arg) => defaultMember(node, arg);
+ @override
R visitProcedure(Procedure node, A arg) => defaultMember(node, arg);
+ @override
R visitField(Field node, A arg) => defaultMember(node, arg);
+ @override
R visitRedirectingFactory(RedirectingFactory node, A arg) {
return defaultMember(node, arg);
}
@@ -484,17 +667,24 @@
R visitExtension(Extension node, A arg) => defaultTreeNode(node, arg);
// Initializers
+ @override
R defaultInitializer(Initializer node, A arg) => defaultTreeNode(node, arg);
+ @override
R visitInvalidInitializer(InvalidInitializer node, A arg) =>
defaultInitializer(node, arg);
+ @override
R visitFieldInitializer(FieldInitializer node, A arg) =>
defaultInitializer(node, arg);
+ @override
R visitSuperInitializer(SuperInitializer node, A arg) =>
defaultInitializer(node, arg);
+ @override
R visitRedirectingInitializer(RedirectingInitializer node, A arg) =>
defaultInitializer(node, arg);
+ @override
R visitLocalInitializer(LocalInitializer node, A arg) =>
defaultInitializer(node, arg);
+ @override
R visitAssertInitializer(AssertInitializer node, A arg) =>
defaultInitializer(node, arg);
@@ -750,30 +940,48 @@
return value;
}
+ @override
R defaultConstant(Constant node);
+ @override
R visitNullConstant(NullConstant node) => defaultConstant(node);
+ @override
R visitBoolConstant(BoolConstant node) => defaultConstant(node);
+ @override
R visitIntConstant(IntConstant node) => defaultConstant(node);
+ @override
R visitDoubleConstant(DoubleConstant node) => defaultConstant(node);
+ @override
R visitStringConstant(StringConstant node) => defaultConstant(node);
+ @override
R visitSymbolConstant(SymbolConstant node) => defaultConstant(node);
+ @override
R visitMapConstant(MapConstant node) => defaultConstant(node);
+ @override
R visitListConstant(ListConstant node) => defaultConstant(node);
+ @override
R visitSetConstant(SetConstant node) => defaultConstant(node);
+ @override
R visitInstanceConstant(InstanceConstant node) => defaultConstant(node);
+ @override
R visitInstantiationConstant(InstantiationConstant node) =>
defaultConstant(node);
+ @override
R visitTypedefTearOffConstant(TypedefTearOffConstant node) =>
defaultConstant(node);
+ @override
R visitStaticTearOffConstant(StaticTearOffConstant node) =>
defaultConstant(node);
+ @override
R visitConstructorTearOffConstant(ConstructorTearOffConstant node) =>
defaultConstant(node);
+ @override
R visitRedirectingFactoryTearOffConstant(
RedirectingFactoryTearOffConstant node) =>
defaultConstant(node);
+ @override
R visitTypeLiteralConstant(TypeLiteralConstant node) => defaultConstant(node);
+ @override
R visitUnevaluatedConstant(UnevaluatedConstant node) => defaultConstant(node);
}
@@ -799,29 +1007,46 @@
}
}
+ @override
void defaultConstant(Constant node);
+ @override
void visitNullConstant(NullConstant node) => defaultConstant(node);
+ @override
void visitBoolConstant(BoolConstant node) => defaultConstant(node);
+ @override
void visitIntConstant(IntConstant node) => defaultConstant(node);
+ @override
void visitDoubleConstant(DoubleConstant node) => defaultConstant(node);
+ @override
void visitStringConstant(StringConstant node) => defaultConstant(node);
+ @override
void visitSymbolConstant(SymbolConstant node) => defaultConstant(node);
+ @override
void visitMapConstant(MapConstant node) => defaultConstant(node);
+ @override
void visitListConstant(ListConstant node) => defaultConstant(node);
+ @override
void visitSetConstant(SetConstant node) => defaultConstant(node);
+ @override
void visitInstanceConstant(InstanceConstant node) => defaultConstant(node);
+ @override
void visitInstantiationConstant(InstantiationConstant node) =>
defaultConstant(node);
+ @override
void visitStaticTearOffConstant(StaticTearOffConstant node) =>
defaultConstant(node);
+ @override
void visitConstructorTearOffConstant(ConstructorTearOffConstant node) =>
defaultConstant(node);
+ @override
void visitRedirectingFactoryTearOffConstant(
RedirectingFactoryTearOffConstant node) =>
defaultConstant(node);
+ @override
void visitTypeLiteralConstant(TypeLiteralConstant node) =>
defaultConstant(node);
+ @override
void visitUnevaluatedConstant(UnevaluatedConstant node) =>
defaultConstant(node);
}
@@ -863,46 +1088,77 @@
/// The catch-all case, except for references.
R defaultNode(Node node);
+ @override
R defaultTreeNode(TreeNode node) => defaultNode(node);
// DartTypes
+ @override
R defaultDartType(DartType node) => defaultNode(node);
+ @override
R visitInvalidType(InvalidType node) => defaultDartType(node);
+ @override
R visitDynamicType(DynamicType node) => defaultDartType(node);
+ @override
R visitVoidType(VoidType node) => defaultDartType(node);
+ @override
R visitInterfaceType(InterfaceType node) => defaultDartType(node);
+ @override
R visitFutureOrType(FutureOrType node) => defaultDartType(node);
+ @override
R visitFunctionType(FunctionType node) => defaultDartType(node);
+ @override
R visitTypeParameterType(TypeParameterType node) => defaultDartType(node);
+ @override
R visitTypedefType(TypedefType node) => defaultDartType(node);
+ @override
R visitNeverType(NeverType node) => defaultDartType(node);
+ @override
R visitNullType(NullType node) => defaultDartType(node);
+ @override
R visitExtensionType(ExtensionType node) => defaultDartType(node);
// Constants
+ @override
R defaultConstant(Constant node) => defaultNode(node);
+ @override
R visitNullConstant(NullConstant node) => defaultConstant(node);
+ @override
R visitBoolConstant(BoolConstant node) => defaultConstant(node);
+ @override
R visitIntConstant(IntConstant node) => defaultConstant(node);
+ @override
R visitDoubleConstant(DoubleConstant node) => defaultConstant(node);
+ @override
R visitStringConstant(StringConstant node) => defaultConstant(node);
+ @override
R visitSymbolConstant(SymbolConstant node) => defaultConstant(node);
+ @override
R visitMapConstant(MapConstant node) => defaultConstant(node);
+ @override
R visitListConstant(ListConstant node) => defaultConstant(node);
+ @override
R visitSetConstant(SetConstant node) => defaultConstant(node);
+ @override
R visitInstanceConstant(InstanceConstant node) => defaultConstant(node);
+ @override
R visitInstantiationConstant(InstantiationConstant node) =>
defaultConstant(node);
+ @override
R visitTypedefTearOffConstant(TypedefTearOffConstant node) =>
defaultConstant(node);
+ @override
R visitStaticTearOffConstant(StaticTearOffConstant node) =>
defaultConstant(node);
+ @override
R visitConstructorTearOffConstant(ConstructorTearOffConstant node) =>
defaultConstant(node);
+ @override
R visitRedirectingFactoryTearOffConstant(
RedirectingFactoryTearOffConstant node) =>
defaultConstant(node);
+ @override
R visitTypeLiteralConstant(TypeLiteralConstant node) => defaultConstant(node);
+ @override
R visitUnevaluatedConstant(UnevaluatedConstant node) => defaultConstant(node);
// Class references
@@ -952,11 +1208,16 @@
defaultConstantReference(node);
// Member references
+ @override
R defaultMemberReference(Member node);
+ @override
R visitFieldReference(Field node) => defaultMemberReference(node);
+ @override
R visitConstructorReference(Constructor node) => defaultMemberReference(node);
+ @override
R visitProcedureReference(Procedure node) => defaultMemberReference(node);
+ @override
R visitRedirectingFactoryReference(RedirectingFactory node) {
return defaultMemberReference(node);
}
@@ -975,43 +1236,70 @@
/// The catch-all case, except for references.
R defaultNode(Node node, A arg);
+ @override
R defaultTreeNode(TreeNode node, A arg) => defaultNode(node, arg);
// DartTypes
+ @override
R defaultDartType(DartType node, A arg) => defaultNode(node, arg);
+ @override
R visitInvalidType(InvalidType node, A arg) => defaultDartType(node, arg);
+ @override
R visitDynamicType(DynamicType node, A arg) => defaultDartType(node, arg);
+ @override
R visitVoidType(VoidType node, A arg) => defaultDartType(node, arg);
+ @override
R visitInterfaceType(InterfaceType node, A arg) => defaultDartType(node, arg);
+ @override
R visitFutureOrType(FutureOrType node, A arg) => defaultDartType(node, arg);
+ @override
R visitFunctionType(FunctionType node, A arg) => defaultDartType(node, arg);
+ @override
R visitTypeParameterType(TypeParameterType node, A arg) =>
defaultDartType(node, arg);
+ @override
R visitTypedefType(TypedefType node, A arg) => defaultDartType(node, arg);
+ @override
R visitNeverType(NeverType node, A arg) => defaultDartType(node, arg);
+ @override
R visitNullType(NullType node, A arg) => defaultDartType(node, arg);
+ @override
R visitExtensionType(ExtensionType node, A arg) => defaultDartType(node, arg);
// Constants
+ @override
R defaultConstant(Constant node, A arg) => defaultNode(node, arg);
+ @override
R visitNullConstant(NullConstant node, A arg) => defaultConstant(node, arg);
+ @override
R visitBoolConstant(BoolConstant node, A arg) => defaultConstant(node, arg);
+ @override
R visitIntConstant(IntConstant node, A arg) => defaultConstant(node, arg);
+ @override
R visitDoubleConstant(DoubleConstant node, A arg) =>
defaultConstant(node, arg);
+ @override
R visitStringConstant(StringConstant node, A arg) =>
defaultConstant(node, arg);
+ @override
R visitSymbolConstant(SymbolConstant node, A arg) =>
defaultConstant(node, arg);
+ @override
R visitMapConstant(MapConstant node, A arg) => defaultConstant(node, arg);
+ @override
R visitListConstant(ListConstant node, A arg) => defaultConstant(node, arg);
+ @override
R visitSetConstant(SetConstant node, A arg) => defaultConstant(node, arg);
+ @override
R visitInstanceConstant(InstanceConstant node, A arg) =>
defaultConstant(node, arg);
+ @override
R visitInstantiationConstant(InstantiationConstant node, A arg) =>
defaultConstant(node, arg);
+ @override
R visitTypeLiteralConstant(TypeLiteralConstant node, A arg) =>
defaultConstant(node, arg);
+ @override
R visitUnevaluatedConstant(UnevaluatedConstant node, A arg) =>
defaultConstant(node, arg);
@@ -1063,13 +1351,18 @@
defaultConstantReference(node, arg);
// Member references
+ @override
R defaultMemberReference(Member node, A arg);
+ @override
R visitFieldReference(Field node, A arg) => defaultMemberReference(node, arg);
+ @override
R visitConstructorReference(Constructor node, A arg) =>
defaultMemberReference(node, arg);
+ @override
R visitProcedureReference(Procedure node, A arg) =>
defaultMemberReference(node, arg);
+ @override
R visitRedirectingFactoryReference(RedirectingFactory node, A arg) =>
defaultMemberReference(node, arg);
@@ -1194,6 +1487,7 @@
class RecursiveVisitor<T> extends Visitor<void> with VisitorVoidMixin {
const RecursiveVisitor();
+ @override
void defaultNode(Node node) {
node.visitChildren(this);
}
@@ -1204,6 +1498,7 @@
class RecursiveResultVisitor<R> extends Visitor<R?> with VisitorNullMixin<R> {
const RecursiveResultVisitor();
+ @override
R? defaultNode(Node node) {
node.visitChildren(this);
return null;
@@ -1295,6 +1590,7 @@
Supertype visitSupertype(Supertype node) => node;
+ @override
TreeNode defaultTreeNode(TreeNode node) {
node.transformChildren(this);
return node;
@@ -1653,6 +1949,7 @@
Supertype visitSupertype(Supertype node, Supertype? removalSentinel) => node;
+ @override
TreeNode defaultTreeNode(TreeNode node, TreeNode? removalSentinel) {
node.transformOrRemoveChildren(this);
return node;
@@ -1806,38 +2103,59 @@
implements StatementVisitor1<R, T> {
const BodyVisitor1();
+ @override
R defaultStatement(Statement node, T arg);
+ @override
R visitExpressionStatement(ExpressionStatement node, T arg) =>
defaultStatement(node, arg);
+ @override
R visitBlock(Block node, T arg) => defaultStatement(node, arg);
+ @override
R visitAssertBlock(AssertBlock node, T arg) => defaultStatement(node, arg);
+ @override
R visitEmptyStatement(EmptyStatement node, T arg) =>
defaultStatement(node, arg);
+ @override
R visitAssertStatement(AssertStatement node, T arg) =>
defaultStatement(node, arg);
+ @override
R visitLabeledStatement(LabeledStatement node, T arg) =>
defaultStatement(node, arg);
+ @override
R visitBreakStatement(BreakStatement node, T arg) =>
defaultStatement(node, arg);
+ @override
R visitWhileStatement(WhileStatement node, T arg) =>
defaultStatement(node, arg);
+ @override
R visitDoStatement(DoStatement node, T arg) => defaultStatement(node, arg);
+ @override
R visitForStatement(ForStatement node, T arg) => defaultStatement(node, arg);
+ @override
R visitForInStatement(ForInStatement node, T arg) =>
defaultStatement(node, arg);
+ @override
R visitSwitchStatement(SwitchStatement node, T arg) =>
defaultStatement(node, arg);
+ @override
R visitContinueSwitchStatement(ContinueSwitchStatement node, T arg) =>
defaultStatement(node, arg);
+ @override
R visitIfStatement(IfStatement node, T arg) => defaultStatement(node, arg);
+ @override
R visitReturnStatement(ReturnStatement node, T arg) =>
defaultStatement(node, arg);
+ @override
R visitTryCatch(TryCatch node, T arg) => defaultStatement(node, arg);
+ @override
R visitTryFinally(TryFinally node, T arg) => defaultStatement(node, arg);
+ @override
R visitYieldStatement(YieldStatement node, T arg) =>
defaultStatement(node, arg);
+ @override
R visitVariableDeclaration(VariableDeclaration node, T arg) =>
defaultStatement(node, arg);
+ @override
R visitFunctionDeclaration(FunctionDeclaration node, T arg) =>
defaultStatement(node, arg);
}
diff --git a/pkg/kernel/test/binary/utils.dart b/pkg/kernel/test/binary/utils.dart
index 1005909..b5faa20 100644
--- a/pkg/kernel/test/binary/utils.dart
+++ b/pkg/kernel/test/binary/utils.dart
@@ -32,9 +32,11 @@
class ByteSink implements Sink<List<int>> {
final BytesBuilder builder = new BytesBuilder();
+ @override
void add(List<int> data) {
builder.add(data);
}
+ @override
void close() {}
}
diff --git a/pkg/kernel/test/class_hierarchy_basic.dart b/pkg/kernel/test/class_hierarchy_basic.dart
index 78ca0c5..259fd47 100644
--- a/pkg/kernel/test/class_hierarchy_basic.dart
+++ b/pkg/kernel/test/class_hierarchy_basic.dart
@@ -11,6 +11,7 @@
/// A simple implementation of the class hierarchy interface using
/// hash tables for everything.
class BasicClassHierarchy implements ClassHierarchy {
+ @override
final Set<Library> knownLibraries;
final Map<Class, Set<Class>> superclasses = <Class, Set<Class>>{};
final Map<Class, Set<Class>> superMixtures = <Class, Set<Class>>{};
@@ -39,6 +40,7 @@
}
}
+ @override
void forEachOverridePair(
Class class_, callback(Member member, Member superMember, bool setter)) {
void report(Member member, Member superMember, bool setter) {
@@ -199,6 +201,7 @@
}
}
+ @override
bool isSubclassOf(Class subtype, Class supertype) {
return superclasses[subtype]!.contains(supertype);
}
@@ -207,18 +210,22 @@
return superMixtures[subtype]!.contains(supertype);
}
+ @override
bool isSubtypeOf(Class subtype, Class supertype) {
return supertypes[subtype]!.contains(supertype);
}
+ @override
Supertype? getClassAsInstanceOf(Class type, Class supertype) {
return supertypeInstantiations[type]![supertype];
}
+ @override
Member? getDispatchTarget(Class class_, Name name, {bool setter: false}) {
return setter ? setters[class_]![name] : gettersAndCalls[class_]![name];
}
+ @override
List<Member> getDispatchTargets(Class class_, {bool setters: false}) {
return setters
? this.setters[class_]!.values.toList()
@@ -229,6 +236,7 @@
return (members == null || members.isEmpty) ? null : members.first;
}
+ @override
Member? getInterfaceMember(Class class_, Name name, {bool setter: false}) {
return tryFirst(getInterfaceMembersByName(class_, name, setter: setter));
}
@@ -241,6 +249,7 @@
return iterable == null ? const <Member>[] : iterable;
}
+ @override
List<Member> getInterfaceMembers(Class class_, {bool setters: false}) {
return setters
? interfaceSetters[class_]!.values.expand((x) => x).toList()
@@ -255,5 +264,6 @@
double getCompressionRatio() => 0.0;
int getSuperTypeHashTableSize() => 0;
+ @override
noSuchMethod(inv) => super.noSuchMethod(inv);
}
diff --git a/pkg/kernel/test/graph_test.dart b/pkg/kernel/test/graph_test.dart
index 1dc79f9..e6d87db 100644
--- a/pkg/kernel/test/graph_test.dart
+++ b/pkg/kernel/test/graph_test.dart
@@ -13,8 +13,10 @@
TestGraph(this.graph);
+ @override
Iterable<String> get vertices => graph.keys;
+ @override
Iterable<String> neighborsOf(String vertex) => graph[vertex]!;
}
diff --git a/pkg/kernel/test/heap_test.dart b/pkg/kernel/test/heap_test.dart
index 32b294e..139fe54 100644
--- a/pkg/kernel/test/heap_test.dart
+++ b/pkg/kernel/test/heap_test.dart
@@ -34,5 +34,6 @@
}
class _intHeap extends Heap<int> {
+ @override
bool sortsBefore(int a, int b) => a < b;
}
diff --git a/pkg/kernel/test/metadata_test.dart b/pkg/kernel/test/metadata_test.dart
index 16418c6..fbdc952 100644
--- a/pkg/kernel/test/metadata_test.dart
+++ b/pkg/kernel/test/metadata_test.dart
@@ -56,10 +56,13 @@
class TestMetadataRepository extends MetadataRepository<Metadata> {
static const kTag = 'kernel.metadata.test';
+ @override
final String tag = kTag;
+ @override
final Map<TreeNode, Metadata> mapping = <TreeNode, Metadata>{};
+ @override
void writeToBinary(Metadata metadata, Node node, BinarySink sink) {
expect(metadata, equals(mapping[node]));
sink.writeByteList(utf8.encode(metadata.string));
@@ -69,6 +72,7 @@
sink.writeDartType(metadata.type);
}
+ @override
Metadata readFromBinary(Node node, BinarySource source) {
final string1 = utf8.decode(source.readByteList());
final string2 = source.readStringReference();
@@ -101,6 +105,7 @@
Visitor(this.predicate, this.handle);
+ @override
defaultTreeNode(TreeNode node) {
super.defaultTreeNode(node);
if (MetadataRepository.isSupported(node) && predicate(node)) {
diff --git a/pkg/kernel/test/type_hashcode_test.dart b/pkg/kernel/test/type_hashcode_test.dart
index 8d13fe6..c232443 100644
--- a/pkg/kernel/test/type_hashcode_test.dart
+++ b/pkg/kernel/test/type_hashcode_test.dart
@@ -65,6 +65,7 @@
bool get shouldSucceed => expectedSubstitution != null;
+ @override
String toString() => '∃ ${quantifiedVariables.join(',')}. $type1 = $type2';
}
diff --git a/pkg/kernel/test/type_substitute_bounds_test.dart b/pkg/kernel/test/type_substitute_bounds_test.dart
index ca16ac0..19436dc 100644
--- a/pkg/kernel/test/type_substitute_bounds_test.dart
+++ b/pkg/kernel/test/type_substitute_bounds_test.dart
@@ -41,6 +41,7 @@
TestCase(this.type, this.bounds, this.expected);
+ @override
String toString() {
var substitution = bounds.keys.map((key) {
var bound = bounds[key]!;
diff --git a/tools/VERSION b/tools/VERSION
index ef5f560..6d69f90 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 15
PATCH 0
-PRERELEASE 68
+PRERELEASE 69
PRERELEASE_PATCH 0
\ No newline at end of file