Version 3.0.0-104.0.dev
Merge 28a3c47c4c2330187074466874711d0b0f8ed23f into dev
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9d5e8f8..d0438d8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -130,6 +130,12 @@
- update `use_build_context_synchronously` to check context properties.
- fix a false positive for `avoid_private_typedef_functions` with generalized type aliases.
+#### Migration tool removal
+
+The null safety migration tool (`dart migrate`) has been removed. If you still
+have code which needs to be migrated to null safety, please run `dart migrate`
+using Dart version 2.19, before upgrading to Dart version 3.0.
+
## 2.19.0
### Language
diff --git a/pkg/_fe_analyzer_shared/lib/src/flow_analysis/flow_analysis.dart b/pkg/_fe_analyzer_shared/lib/src/flow_analysis/flow_analysis.dart
index 8435b32..5f5f6c1 100644
--- a/pkg/_fe_analyzer_shared/lib/src/flow_analysis/flow_analysis.dart
+++ b/pkg/_fe_analyzer_shared/lib/src/flow_analysis/flow_analysis.dart
@@ -477,6 +477,9 @@
/// Call this method just after visiting the initializer of a late variable.
void lateInitializer_end();
+ /// Call this method just before visiting the subpatterns of a list pattern.
+ void listPattern_begin();
+
/// Call this method before visiting the LHS of a logical binary operation
/// ("||" or "&&").
void logicalBinaryOp_begin();
@@ -1260,6 +1263,11 @@
}
@override
+ void listPattern_begin() {
+ _wrap('listPattern_begin()', () => _wrapped.listPattern_begin());
+ }
+
+ @override
void logicalBinaryOp_begin() {
_wrap('logicalBinaryOp_begin()', () => _wrapped.logicalBinaryOp_begin());
}
@@ -3556,7 +3564,7 @@
// If there's a scrutinee, and its value is known to be the same as that of
// the synthetic cache variable, promote it too.
if (scrutineeReference != null &&
- _current.infoFor(matchedValueReference.promotionKey).ssaNode ==
+ _current.infoFor(scrutineeReference.promotionKey).ssaNode ==
_scrutineeSsaNode) {
ifTrue = ifTrue
.tryPromoteForTypeCheck(this, scrutineeReference, staticType)
@@ -3983,6 +3991,14 @@
}
@override
+ void listPattern_begin() {
+ // As a temporary measure, just assume the pattern might or might not match.
+ // This avoids some bogus "unreachable code" warnings in analyzer tests.
+ // TODO(paulberry): replace this with a full implementation.
+ _unmatched = _join(_unmatched!, _current);
+ }
+
+ @override
void logicalBinaryOp_begin() {
_current = _current.split();
}
@@ -4181,7 +4197,9 @@
@override
void switchStatement_beginAlternative() {
- assert(_stack.last is _SwitchAlternativesContext<Type>);
+ _SwitchAlternativesContext<Type> context =
+ _stack.last as _SwitchAlternativesContext<Type>;
+ _current = context._switchStatementContext._unmatched;
_pushPattern();
}
@@ -4189,8 +4207,7 @@
void switchStatement_beginAlternatives() {
_SwitchStatementContext<Type> context =
_stack.last as _SwitchStatementContext<Type>;
- _current = context._previous.split();
- _stack.add(new _SwitchAlternativesContext<Type>(_current));
+ _stack.add(new _SwitchAlternativesContext<Type>(context));
}
@override
@@ -4219,13 +4236,14 @@
@override
void switchStatement_endAlternative(Expression? guard) {
- // TODO(paulberry): make use of `unmatched`
- // ignore: unused_local_variable
FlowModel<Type> unmatched = _popPattern(guard);
_SwitchAlternativesContext<Type> context =
_stack.last as _SwitchAlternativesContext<Type>;
+ // Future alternatives will be analyzed under the assumption that this
+ // alternative didn't match. This models the fact that a switch statement
+ // behaves like a chain of if/else tests.
+ context._switchStatementContext._unmatched = unmatched;
context._combinedModel = _join(context._combinedModel, _current);
- _current = context._previous;
}
@override
@@ -4233,16 +4251,14 @@
{required bool hasLabels}) {
_SwitchAlternativesContext<Type> alternativesContext =
_stack.removeLast() as _SwitchAlternativesContext<Type>;
- _SimpleStatementContext<Type> switchContext =
- _stack.last as _SimpleStatementContext<Type>;
+ _SwitchStatementContext<Type> switchContext =
+ _stack.last as _SwitchStatementContext<Type>;
if (hasLabels) {
AssignedVariablesNodeInfo info = _assignedVariables.getInfoForNode(node!);
_current = switchContext._previous
.conservativeJoin(this, info.written, info.captured);
} else {
- _current =
- (alternativesContext._combinedModel ?? alternativesContext._previous)
- .unsplit();
+ _current = alternativesContext._combinedModel ?? switchContext._unmatched;
}
// TODO(paulberry): consider doing a split here if unreachable, and a join
// later, so that one case matching everything won't prevent promotion in
@@ -4438,13 +4454,35 @@
@override
void _dumpState() {
print(' current: $_current');
- print(' expressionWithInfo: $_expressionWithInfo');
- print(' expressionInfo: $_expressionInfo');
- print(' expressionWithReference: $_expressionWithReference');
- print(' expressionReference: $_expressionReference');
- print(' stack:');
- for (_FlowContext stackEntry in _stack.reversed) {
- print(' $stackEntry');
+ if (_unmatched != null) {
+ print(' unmatched: $_unmatched');
+ }
+ if (_scrutineeReference != null) {
+ print(' scrutineeReference: $_scrutineeReference');
+ }
+ if (_scrutineeSsaNode != null) {
+ print(' scrutineeSsaNode: $_scrutineeSsaNode');
+ }
+ if (_scrutineeType != null) {
+ print(' scrutineeType: $_scrutineeType');
+ }
+ if (_expressionWithInfo != null) {
+ print(' expressionWithInfo: $_expressionWithInfo');
+ }
+ if (_expressionInfo != null) {
+ print(' expressionInfo: $_expressionInfo');
+ }
+ if (_expressionWithReference != null) {
+ print(' expressionWithReference: $_expressionWithReference');
+ }
+ if (_expressionReference != null) {
+ print(' expressionReference: $_expressionReference');
+ }
+ if (_stack.isNotEmpty) {
+ print(' stack:');
+ for (_FlowContext stackEntry in _stack.reversed) {
+ print(' $stackEntry');
+ }
}
}
@@ -5053,6 +5091,9 @@
void lateInitializer_end() {}
@override
+ void listPattern_begin() {}
+
+ @override
void logicalBinaryOp_begin() {
_writeStackForAnd.add({});
}
@@ -5561,16 +5602,16 @@
}
class _SwitchAlternativesContext<Type extends Object> extends _FlowContext {
- final FlowModel<Type> _previous;
+ /// The enclosing [_SwitchStatementContext].
+ final _SwitchStatementContext<Type> _switchStatementContext;
FlowModel<Type>? _combinedModel;
- _SwitchAlternativesContext(this._previous);
+ _SwitchAlternativesContext(this._switchStatementContext);
@override
- Map<String, Object?> get _debugFields => super._debugFields
- ..['previous'] = _previous
- ..['combinedModel'] = _combinedModel;
+ Map<String, Object?> get _debugFields =>
+ super._debugFields..['combinedModel'] = _combinedModel;
@override
String get _debugType => '_SwitchAlternativesContext';
@@ -5582,12 +5623,19 @@
/// The static type of the value being matched.
final Type _scrutineeType;
+ /// Flow state for the code path where no switch cases have matched yet. If
+ /// we think of a switch statement as syntactic sugar for a chain of if-else
+ /// statements, this is the flow state on entry to the next `if`.
+ FlowModel<Type> _unmatched;
+
_SwitchStatementContext(
- super.checkpoint, super._previous, this._scrutineeType);
+ super.checkpoint, super._previous, this._scrutineeType)
+ : _unmatched = _previous;
@override
- Map<String, Object?> get _debugFields =>
- super._debugFields..['scrutineeType'] = _scrutineeType;
+ Map<String, Object?> get _debugFields => super._debugFields
+ ..['scrutineeType'] = _scrutineeType
+ ..['unmatched'] = _unmatched;
@override
String get _debugType => '_SwitchStatementContext';
diff --git a/pkg/_fe_analyzer_shared/lib/src/type_inference/type_analyzer.dart b/pkg/_fe_analyzer_shared/lib/src/type_inference/type_analyzer.dart
index 055f711..79dd651 100644
--- a/pkg/_fe_analyzer_shared/lib/src/type_inference/type_analyzer.dart
+++ b/pkg/_fe_analyzer_shared/lib/src/type_inference/type_analyzer.dart
@@ -615,6 +615,7 @@
}
}
// Stack: ()
+ flow.listPattern_begin();
Node? previousRestPattern;
for (Node element in elements) {
if (isRestPatternElement(element)) {
@@ -1574,8 +1575,8 @@
SwitchStatementMemberInfo<Node, Statement, Expression, Variable>
getSwitchStatementMemberInfo(Statement node, int caseIndex);
- /// Returns the type of [node].
- Type getVariableType(Variable node);
+ /// Returns the type of [variable].
+ Type getVariableType(Variable variable);
/// Called after visiting the pattern in `if-case` statement.
/// [variables] are variables declared in the pattern.
diff --git a/pkg/_fe_analyzer_shared/test/flow_analysis/flow_analysis_test.dart b/pkg/_fe_analyzer_shared/test/flow_analysis/flow_analysis_test.dart
index 624f785..731ea5d 100644
--- a/pkg/_fe_analyzer_shared/test/flow_analysis/flow_analysis_test.dart
+++ b/pkg/_fe_analyzer_shared/test/flow_analysis/flow_analysis_test.dart
@@ -6620,6 +6620,19 @@
});
});
+ group('List pattern:', () {
+ test('Not guaranteed to match', () {
+ h.run([
+ switch_(expr('Object'), [
+ listPattern([]).then([break_()]),
+ default_.then([
+ checkReachable(true),
+ ]),
+ ]),
+ ]);
+ });
+ });
+
group('Switch expression:', () {
test('guarded', () {
var x = Var('x');
@@ -6638,7 +6651,42 @@
]);
});
- test('promotes', () {
+ group('guard promotes later cases:', () {
+ test('when pattern fully covers the scrutinee type', () {
+ // `case _ when x == null:` promotes `x` to non-null in later cases,
+ // because the implicit type of `_` fully covers the scrutinee type.
+ var x = Var('x');
+ h.run([
+ declare(x, type: 'int?'),
+ switchExpr(expr('Object?'), [
+ wildcard().when(x.expr.eq(nullLiteral)).thenExpr(intLiteral(0)),
+ wildcard().thenExpr(block([
+ checkPromoted(x, 'int'),
+ ]).thenExpr(intLiteral(1))),
+ ]).stmt,
+ ]);
+ });
+
+ test('when pattern does not fully cover the scrutinee type', () {
+ // `case String _ when x == null:` does not promote `y` to non-null in
+ // later cases, because the type `String` does not fully cover the
+ // scrutinee type.
+ var x = Var('x');
+ h.run([
+ declare(x, type: 'int?'),
+ switchExpr(expr('Object?'), [
+ wildcard(type: 'String')
+ .when(x.expr.eq(nullLiteral))
+ .thenExpr(intLiteral(0)),
+ wildcard().thenExpr(block([
+ checkNotPromoted(x),
+ ]).thenExpr(intLiteral(1))),
+ ]).stmt,
+ ]);
+ });
+ });
+
+ test('promotes scrutinee', () {
var x = Var('x');
var y = Var('y');
h.run([
@@ -6655,6 +6703,55 @@
]).stmt,
]);
});
+
+ test('reassigned scrutinee var no longer promotes', () {
+ var x = Var('x');
+ // Note that the second `wildcard(type: 'int')` doesn't promote `x`
+ // because it's been reassigned. But it does still promote the
+ // scrutinee in the RHS of the `&&`.
+ h.run([
+ declare(x, initializer: expr('Object')),
+ switchExpr(x.expr, [
+ wildcard(type: 'int')
+ .and(wildcard(expectInferredType: 'int'))
+ .thenExpr(block([
+ checkPromoted(x, 'int'),
+ ]).thenExpr(intLiteral(0))),
+ wildcard()
+ .when(x.write(expr('Object')).stmt.thenExpr(expr('bool')))
+ .thenExpr(intLiteral(1)),
+ wildcard(type: 'int')
+ .and(wildcard(expectInferredType: 'int'))
+ .thenExpr(block([
+ checkNotPromoted(x),
+ ]).thenExpr(intLiteral(2))),
+ wildcard().thenExpr(intLiteral(3)),
+ ]).stmt,
+ ]);
+ });
+
+ test(
+ 'cached scrutinee retains promoted type even if scrutinee var '
+ 'reassigned', () {
+ var x = Var('x');
+ var y = Var('y');
+ // `x` is promoted at the time the scrutinee is cached. Therefore, even
+ // though `case _ where f(x = ...)` de-promotes `x`, the promoted type
+ // is still used for type inference in the later `case var y`.
+ h.run([
+ declare(x, initializer: expr('Object')),
+ x.expr.as_('int').stmt,
+ checkPromoted(x, 'int'),
+ switchExpr(x.expr, [
+ wildcard()
+ .when(x.write(expr('Object')).stmt.thenExpr(expr('bool')))
+ .thenExpr(intLiteral(0)),
+ y.pattern(expectInferredType: 'int').thenExpr(block([
+ checkNotPromoted(x),
+ ]).thenExpr(intLiteral(1))),
+ ]).stmt,
+ ]);
+ });
});
group('Switch statement:', () {
@@ -6679,7 +6776,42 @@
]);
});
- test('promotes', () {
+ group('guard promotes later cases:', () {
+ test('when pattern fully covers the scrutinee type', () {
+ // `case _ when x == null:` promotes `x` to non-null in later cases,
+ // because the implicit type of `_` fully covers the scrutinee type.
+ var x = Var('x');
+ h.run([
+ declare(x, type: 'int?'),
+ switch_(expr('Object?'), [
+ wildcard().when(x.expr.eq(nullLiteral)).then([break_()]),
+ wildcard().then([
+ checkPromoted(x, 'int'),
+ ]),
+ ]),
+ ]);
+ });
+
+ test('when pattern does not fully cover the scrutinee type', () {
+ // `case String _ when x == null:` does not promote `x` to non-null in
+ // later cases, because the type `String` does not fully cover the
+ // scrutinee type.
+ var x = Var('x');
+ h.run([
+ declare(x, type: 'int?'),
+ switch_(expr('Object?'), [
+ wildcard(type: 'String')
+ .when(x.expr.eq(nullLiteral))
+ .then([break_()]),
+ wildcard().then([
+ checkNotPromoted(x),
+ ]),
+ ]),
+ ]);
+ });
+ });
+
+ test('promotes scrutinee', () {
var x = Var('x');
var y = Var('y');
h.run([
@@ -6849,6 +6981,56 @@
]);
});
});
+
+ test('reassigned scrutinee var no longer promotes', () {
+ var x = Var('x');
+ // Note that the second `wildcard(type: 'int')` doesn't promote `x`
+ // because it's been reassigned. But it does still promote the
+ // scrutinee in the RHS of the `&&`.
+ h.run([
+ declare(x, initializer: expr('Object')),
+ switch_(x.expr, [
+ wildcard(type: 'int')
+ .and(wildcard(expectInferredType: 'int'))
+ .then([
+ checkPromoted(x, 'int'),
+ ]),
+ wildcard()
+ .when(x.write(expr('Object')).stmt.thenExpr(expr('bool')))
+ .then([
+ break_(),
+ ]),
+ wildcard(type: 'int')
+ .and(wildcard(expectInferredType: 'int'))
+ .then([
+ checkNotPromoted(x),
+ ])
+ ]),
+ ]);
+ });
+
+ test(
+ 'cached scrutinee retains promoted type even if scrutinee var '
+ 'reassigned', () {
+ var x = Var('x');
+ var y = Var('y');
+ // `x` is promoted at the time the scrutinee is cached. Therefore, even
+ // though `case _ where f(x = ...)` de-promotes `x`, the promoted type
+ // is still used for type inference in the later `case var y`.
+ h.run([
+ declare(x, initializer: expr('Object')),
+ x.expr.as_('int').stmt,
+ checkPromoted(x, 'int'),
+ switch_(x.expr, [
+ wildcard()
+ .when(x.write(expr('Object')).stmt.thenExpr(expr('bool')))
+ .then([break_()]),
+ y.pattern(expectInferredType: 'int').then([
+ checkNotPromoted(x),
+ ]),
+ ]),
+ ]);
+ });
});
group('Variable pattern:', () {
diff --git a/pkg/_fe_analyzer_shared/test/mini_ast.dart b/pkg/_fe_analyzer_shared/test/mini_ast.dart
index 74c1578..2d19b86 100644
--- a/pkg/_fe_analyzer_shared/test/mini_ast.dart
+++ b/pkg/_fe_analyzer_shared/test/mini_ast.dart
@@ -825,6 +825,7 @@
'Never': false,
'num': false,
'Object': false,
+ 'Object?': false,
'String': false,
};
@@ -939,6 +940,7 @@
'Object? <: int': false,
'Object? <: int?': false,
'Object? <: Null': false,
+ 'Object? <: String': false,
'String <: int': false,
'String <: int?': false,
'String <: List<num>': false,
@@ -3628,8 +3630,8 @@
}
@override
- Type getVariableType(Var node) {
- return node.type;
+ Type getVariableType(Var variable) {
+ return variable.type;
}
@override
diff --git a/pkg/_js_interop_checks/lib/src/transformations/static_interop_mock_validator.dart b/pkg/_js_interop_checks/lib/src/transformations/static_interop_mock_validator.dart
index c7f1770..3496a86 100644
--- a/pkg/_js_interop_checks/lib/src/transformations/static_interop_mock_validator.dart
+++ b/pkg/_js_interop_checks/lib/src/transformations/static_interop_mock_validator.dart
@@ -230,7 +230,7 @@
/// an error. Considering this API should primarily be used in tests, such a
/// compilation will be unlikely, but we should revisit this.
Map<Reference, Set<Extension>> _computeStaticInteropExtensionMap() {
- // Process the stored libaries, and create a mapping between @staticInterop
+ // Process the stored libraries, and create a mapping between @staticInterop
// classes and their extensions.
var staticInteropClassesWithExtensions = <Reference, Set<Extension>>{};
for (var library in ExportChecker.libraryExtensionMap.keys) {
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/add_type_annotation.dart b/pkg/analysis_server/lib/src/services/correction/dart/add_type_annotation.dart
index 9c09c87..0ee19fc8 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/add_type_annotation.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/add_type_annotation.dart
@@ -82,11 +82,11 @@
if (builder.canWriteType(type)) {
if (keyword != null && keyword.keyword == Keyword.VAR) {
builder.addReplacement(range.token(keyword), (builder) {
- builder.writeType(type, includeDefaultValuesInFunctionTypes: false);
+ builder.writeType(type);
});
} else {
builder.addInsertion(offset, (builder) {
- builder.writeType(type, includeDefaultValuesInFunctionTypes: false);
+ builder.writeType(type);
builder.write(' ');
});
}
diff --git a/pkg/analysis_server/lib/src/services/refactoring/move_top_level_to_file.dart b/pkg/analysis_server/lib/src/services/refactoring/move_top_level_to_file.dart
index 61d31bf..5f4c784 100644
--- a/pkg/analysis_server/lib/src/services/refactoring/move_top_level_to_file.dart
+++ b/pkg/analysis_server/lib/src/services/refactoring/move_top_level_to_file.dart
@@ -5,6 +5,7 @@
import 'package:analysis_server/lsp_protocol/protocol_custom_generated.dart'
show CommandParameter, SaveUriCommandParameter;
import 'package:analysis_server/src/services/refactoring/framework/refactoring_producer.dart';
+import 'package:analysis_server/src/utilities/extensions/ast.dart';
import 'package:analysis_server/src/utilities/import_analyzer.dart';
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/ast/token.dart';
@@ -66,24 +67,17 @@
if (destinationImportUri == null) {
return;
}
- // TODO(brianwilkerson) If we attempt to copy the file header, then the
- // imports are inserted before the file header, which is wrong. To solve
- // this, I think we need to teach `DartFileEditBuilder` about header
- // comments so that it can insert the comment before the imports. When
- // that's happened, uncomment the code below and replace the code inside
- // `addInsertion` to set the file header rather than to include it in the
- // insertion.
- // var destinationExists =
- // unitResult.session.resourceProvider.getFile(destinationFilePath).exists;
- // String? fileHeader;
- // if (!destinationExists) {
- // var headerTokens = unitResult.unit.fileHeader;
- // if (headerTokens.isNotEmpty) {
- // var offset = headerTokens.first.offset;
- // var end = headerTokens.last.end;
- // fileHeader = utils.getText(offset, end - offset);
- // }
- // }
+ var destinationExists =
+ unitResult.session.resourceProvider.getFile(destinationFilePath).exists;
+ String? fileHeader;
+ if (!destinationExists) {
+ var headerTokens = unitResult.unit.fileHeader;
+ if (headerTokens.isNotEmpty) {
+ var offset = headerTokens.first.offset;
+ var end = headerTokens.last.end;
+ fileHeader = utils.getText(offset, end - offset);
+ }
+ }
var lineInfo = unitResult.lineInfo;
var ranges = members.groups
@@ -95,8 +89,10 @@
await builder.addDartFileEdit(destinationFilePath, (builder) {
// TODO(dantup): Ensure the range inserted and deleted match (allowing for
// whitespace), including handling of leading/trailing comments etc.
+ if (fileHeader != null) {
+ builder.fileHeader = fileHeader + utils.endOfLine;
+ }
builder.addInsertion(0, (builder) {
- // TODO(brianwilkerson) Set the file header.
for (var i = 0; i < members.groups.length; i++) {
var group = members.groups[i];
var sourceRange =
diff --git a/pkg/analysis_server/test/src/services/refactoring/move_top_level_to_file_test.dart b/pkg/analysis_server/test/src/services/refactoring/move_top_level_to_file_test.dart
index c28a131..edd0e22 100644
--- a/pkg/analysis_server/test/src/services/refactoring/move_top_level_to_file_test.dart
+++ b/pkg/analysis_server/test/src/services/refactoring/move_top_level_to_file_test.dart
@@ -36,7 +36,6 @@
arguments[0] = newFileUri.toString();
}
- @failingTest
Future<void> test_copyFileHeader() async {
var originalSource = '''
// File header.
diff --git a/pkg/analyzer/test/src/diagnostics/missing_variable_pattern_test.dart b/pkg/analyzer/test/src/diagnostics/missing_variable_pattern_test.dart
index a8c6693..72f54f1 100644
--- a/pkg/analyzer/test/src/diagnostics/missing_variable_pattern_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/missing_variable_pattern_test.dart
@@ -551,9 +551,9 @@
test_switchStatement_case2_left() async {
await assertNoErrorsInCode(r'''
-void f(int x) {
+void f(num x) {
switch (x) {
- case final a:
+ case final double a:
case 2:
return;
}
@@ -590,9 +590,9 @@
test_switchStatement_differentCases_sibling() async {
await assertNoErrorsInCode(r'''
-void f(int x) {
+void f(num x) {
switch (x) {
- case final a:
+ case final double a:
return;
case 2:
return;
diff --git a/pkg/analyzer_plugin/lib/src/utilities/change_builder/change_builder_dart.dart b/pkg/analyzer_plugin/lib/src/utilities/change_builder/change_builder_dart.dart
index 821d5c5..8dbe801 100644
--- a/pkg/analyzer_plugin/lib/src/utilities/change_builder/change_builder_dart.dart
+++ b/pkg/analyzer_plugin/lib/src/utilities/change_builder/change_builder_dart.dart
@@ -524,7 +524,6 @@
{bool isCovariant = false,
bool isRequiredNamed = false,
ExecutableElement? methodBeingCopied,
- bool includeDefaultValuesInFunctionTypes = true,
String? nameGroupName,
DartType? type,
String? typeGroupName,
@@ -534,18 +533,12 @@
late bool hasType;
addLinkedEdit(typeGroupName, (DartLinkedEditBuilder builder) {
hasType = _writeType(type,
- methodBeingCopied: methodBeingCopied,
- includeDefaultValuesInFunctionTypes:
- includeDefaultValuesInFunctionTypes,
- required: isRequiredType);
+ methodBeingCopied: methodBeingCopied, required: isRequiredType);
builder.addSuperTypesAsSuggestions(type);
});
return hasType;
}
- return _writeType(type,
- methodBeingCopied: methodBeingCopied,
- includeDefaultValuesInFunctionTypes:
- includeDefaultValuesInFunctionTypes);
+ return _writeType(type, methodBeingCopied: methodBeingCopied);
}
void writeName() {
@@ -621,7 +614,7 @@
@override
void writeParameters(Iterable<ParameterElement> parameters,
{ExecutableElement? methodBeingCopied,
- bool includeDefaultValuesInFunctionTypes = true,
+ bool includeDefaultValues = true,
bool requiredTypes = false}) {
var parameterNames = <String>{};
for (var i = 0; i < parameters.length; i++) {
@@ -663,14 +656,12 @@
isCovariant: parameter.isCovariant,
isRequiredNamed: parameter.isRequiredNamed,
methodBeingCopied: methodBeingCopied,
- includeDefaultValuesInFunctionTypes:
- includeDefaultValuesInFunctionTypes,
nameGroupName: parameter.isNamed ? null : '${groupPrefix}PARAM$i',
type: parameter.type,
typeGroupName: '${groupPrefix}TYPE$i',
isRequiredType: requiredTypes);
// default value
- if (includeDefaultValuesInFunctionTypes) {
+ if (includeDefaultValues) {
var defaultCode = parameter.defaultValueCode;
if (defaultCode != null) {
write(' = ');
@@ -759,7 +750,6 @@
{bool addSupertypeProposals = false,
String? groupName,
ExecutableElement? methodBeingCopied,
- bool includeDefaultValuesInFunctionTypes = true,
bool required = false}) {
var wroteType = false;
if (type != null && !type.isDynamic) {
@@ -771,12 +761,7 @@
}
});
} else {
- wroteType = _writeType(
- type,
- methodBeingCopied: methodBeingCopied,
- includeDefaultValuesInFunctionTypes:
- includeDefaultValuesInFunctionTypes,
- );
+ wroteType = _writeType(type, methodBeingCopied: methodBeingCopied);
}
}
if (!wroteType && required) {
@@ -1234,9 +1219,7 @@
/// Causes any libraries whose elements are used by the generated code, to be
/// imported.
bool _writeType(DartType? type,
- {ExecutableElement? methodBeingCopied,
- bool includeDefaultValuesInFunctionTypes = true,
- bool required = false}) {
+ {ExecutableElement? methodBeingCopied, bool required = false}) {
type = _getVisibleType(type, methodBeingCopied: methodBeingCopied);
// If not a useful type, don't write it.
@@ -1279,8 +1262,7 @@
writeParameters(
type.parameters,
methodBeingCopied: methodBeingCopied,
- includeDefaultValuesInFunctionTypes:
- includeDefaultValuesInFunctionTypes,
+ includeDefaultValues: false,
requiredTypes: true,
);
if (type.nullabilitySuffix == NullabilitySuffix.question) {
@@ -1419,6 +1401,9 @@
/// or `null` if the receiver is the builder for the library.
final DartFileEditBuilderImpl? libraryChangeBuilder;
+ @override
+ String? fileHeader;
+
/// Whether to create edits that add imports for any written types that are
/// not already imported.
final bool createEditsForImports;
@@ -1446,7 +1431,8 @@
resolvedUnit.session.analysisContext.analysisOptions.codeStyleOptions;
@override
- bool get hasEdits => super.hasEdits || librariesToImport.isNotEmpty;
+ bool get hasEdits =>
+ super.hasEdits || librariesToImport.isNotEmpty || fileHeader != null;
@override
List<Uri> get requiredImports => librariesToImport.keys.toList();
@@ -1517,6 +1503,12 @@
if (createEditsForImports && librariesToImport.isNotEmpty) {
_addLibraryImports(librariesToImport.values);
}
+ var header = fileHeader;
+ if (header != null) {
+ addInsertion(0, insertBeforeExisting: true, (builder) {
+ builder.writeln(header);
+ });
+ }
}
@override
diff --git a/pkg/analyzer_plugin/lib/utilities/change_builder/change_builder_dart.dart b/pkg/analyzer_plugin/lib/utilities/change_builder/change_builder_dart.dart
index 339beeb..3d5694d 100644
--- a/pkg/analyzer_plugin/lib/utilities/change_builder/change_builder_dart.dart
+++ b/pkg/analyzer_plugin/lib/utilities/change_builder/change_builder_dart.dart
@@ -221,7 +221,7 @@
Expression argument, int index, Set<String> usedNames);
/// Write the code for a list of [parameters], including the surrounding
- /// parentheses.
+ /// parentheses and default values (unless [includeDefaultValues] is `false`).
///
/// If a [methodBeingCopied] is provided, then type parameters defined by that
/// method are assumed to be part of what is being written and hence valid
@@ -229,7 +229,9 @@
///
/// If [requiredTypes] is `true`, then the types are always written.
void writeParameters(Iterable<ParameterElement> parameters,
- {ExecutableElement? methodBeingCopied, bool requiredTypes});
+ {ExecutableElement? methodBeingCopied,
+ bool includeDefaultValues = true,
+ bool requiredTypes});
/// Write the code for a list of parameters that would match the given list of
/// [arguments]. The surrounding parentheses are *not* written.
@@ -267,9 +269,6 @@
/// [addSupertypeProposals] is `true`, then all of the supertypes of the
/// [type] will be added as suggestions for alternatives to the type name.
///
- /// If [includeDefaultValuesInFunctionTypes] is `true`, function types will be
- /// written including their default values.
- ///
/// If a [methodBeingCopied] is provided, then type parameters defined by that
/// method are assumed to be part of what is being written and hence valid
/// types.
@@ -279,7 +278,6 @@
{bool addSupertypeProposals = false,
String? groupName,
ExecutableElement? methodBeingCopied,
- bool includeDefaultValuesInFunctionTypes = true,
bool required = false});
/// Write the code to declare the given [typeParameter]. The enclosing angle
@@ -310,6 +308,10 @@
///
/// Clients may not extend, implement or mix-in this class.
abstract class DartFileEditBuilder implements FileEditBuilder {
+ /// Set the file header to be added before any generated imports. A blank line
+ /// will automatically be added after the file header.
+ set fileHeader(String fileHeader);
+
/// A list of new URIs that must be imported for the types being referenced in
/// edits.
List<Uri> get requiredImports;
diff --git a/pkg/analyzer_plugin/test/src/utilities/change_builder/change_builder_dart_test.dart b/pkg/analyzer_plugin/test/src/utilities/change_builder/change_builder_dart_test.dart
index 62be8bb..31cf004 100644
--- a/pkg/analyzer_plugin/test/src/utilities/change_builder/change_builder_dart_test.dart
+++ b/pkg/analyzer_plugin/test/src/utilities/change_builder/change_builder_dart_test.dart
@@ -1119,6 +1119,27 @@
equalsIgnoringWhitespace('(int a, {bool b = false, String c})'));
}
+ Future<void> test_writeParameters_noDefaults() async {
+ var path = convertPath('/home/test/lib/test.dart');
+ var content = 'f(int a, {bool b = false, String c = ""}) {}';
+ addSource(path, content);
+
+ var unit = (await resolveFile(path)).unit;
+ var f = unit.declarations[0] as FunctionDeclaration;
+ var parameters = f.functionExpression.parameters;
+ var elements = parameters?.parameters.map((p) => p.declaredElement!);
+
+ var builder = await newBuilder();
+ await builder.addDartFileEdit(path, (builder) {
+ builder.addInsertion(content.length - 1, (builder) {
+ builder.writeParameters(elements!, includeDefaultValues: false);
+ });
+ });
+ var edit = getEdit(builder);
+ expect(edit.replacement,
+ equalsIgnoringWhitespace('(int a, {bool b, String c})'));
+ }
+
Future<void> test_writeParameters_positional() async {
var path = convertPath('/home/test/lib/test.dart');
var content = 'f(int a, [bool b = false, String c]) {}';
@@ -1846,6 +1867,76 @@
expect(edits[1].replacement, equalsIgnoringWhitespace('Future<String>'));
}
+ Future<void> test_fileHeader_emptyFile() async {
+ var initialCode = '''
+''';
+ var path = convertPath('/home/test/lib/test.dart');
+ newFile(path, initialCode);
+
+ var builder = await newBuilder();
+ await builder.addDartFileEdit(path, (builder) {
+ builder.fileHeader = '''
+// File header
+''';
+ });
+
+ var edits = getEdits(builder);
+ var resultCode = SourceEdit.applySequence(initialCode, edits);
+ expect(resultCode, r'''
+// File header
+
+''');
+ }
+
+ Future<void> test_fileHeader_withImports() async {
+ var initialCode = '''
+class C {}
+''';
+ var path = convertPath('/home/test/lib/test.dart');
+ newFile(path, initialCode);
+
+ var builder = await newBuilder();
+ await builder.addDartFileEdit(path, (builder) {
+ builder.fileHeader = '''
+// File header
+''';
+ builder.importLibrary(Uri.parse('package:p/p.dart'));
+ });
+
+ var edits = getEdits(builder);
+ var resultCode = SourceEdit.applySequence(initialCode, edits);
+ expect(resultCode, r'''
+// File header
+
+import 'package:p/p.dart';
+
+class C {}
+''');
+ }
+
+ Future<void> test_fileHeader_withoutImports() async {
+ var initialCode = '''
+class C {}
+''';
+ var path = convertPath('/home/test/lib/test.dart');
+ newFile(path, initialCode);
+
+ var builder = await newBuilder();
+ await builder.addDartFileEdit(path, (builder) {
+ builder.fileHeader = '''
+// File header
+''';
+ });
+
+ var edits = getEdits(builder);
+ var resultCode = SourceEdit.applySequence(initialCode, edits);
+ expect(resultCode, r'''
+// File header
+
+class C {}
+''');
+ }
+
Future<void> test_format_hasEdits() async {
var initialCode = r'''
void functionBefore() {
diff --git a/pkg/front_end/lib/src/fasta/source/source_field_builder.dart b/pkg/front_end/lib/src/fasta/source/source_field_builder.dart
index 3b503c8..03e1866 100644
--- a/pkg/front_end/lib/src/fasta/source/source_field_builder.dart
+++ b/pkg/front_end/lib/src/fasta/source/source_field_builder.dart
@@ -38,7 +38,6 @@
show IncludesTypeParametersNonCovariantly;
import '../util/helpers.dart' show DelayedActionPerformer;
import 'source_class_builder.dart';
-import 'source_inline_class_builder.dart';
import 'source_member_builder.dart';
class SourceFieldBuilder extends SourceMemberBuilderImpl
@@ -1567,7 +1566,6 @@
final bool isAbstract;
final bool isExternal;
final bool _isExtensionInstanceMember;
- final bool _isInlineClassInstanceMember;
late Procedure _getter;
Procedure? _setter;
@@ -1599,11 +1597,8 @@
assert(isNonNullableByDefault != null),
_isExtensionInstanceMember = isExternal &&
nameScheme.isExtensionMember &&
- nameScheme.isInstanceMember,
- _isInlineClassInstanceMember = isExternal &&
- nameScheme.isInlineClassMember &&
nameScheme.isInstanceMember {
- if (_isExtensionInstanceMember || _isInlineClassInstanceMember) {
+ if (_isExtensionInstanceMember) {
_getter = new Procedure(
dummyName,
ProcedureKind.Method,
@@ -1695,26 +1690,17 @@
"Type has already been computed for field ${_fieldBuilder.name}.");
_type = value;
if (value is! InferredType) {
- if (_isExtensionInstanceMember || _isInlineClassInstanceMember) {
- DartType thisParameterType;
- List<TypeParameter> typeParameters;
- if (_isExtensionInstanceMember) {
- SourceExtensionBuilder extensionBuilder =
- _fieldBuilder.parent as SourceExtensionBuilder;
- thisParameterType = extensionBuilder.extension.onType;
- typeParameters = extensionBuilder.extension.typeParameters;
- } else {
- SourceInlineClassBuilder inlineClassBuilder =
- _fieldBuilder.parent as SourceInlineClassBuilder;
- thisParameterType =
- inlineClassBuilder.inlineClass.declaredRepresentationType;
- typeParameters = inlineClassBuilder.inlineClass.typeParameters;
- }
+ if (_isExtensionInstanceMember) {
+ SourceExtensionBuilder extensionBuilder =
+ _fieldBuilder.parent as SourceExtensionBuilder;
+ DartType onType = extensionBuilder.extension.onType;
+ List<TypeParameter> typeParameters =
+ extensionBuilder.extension.typeParameters;
if (typeParameters.isNotEmpty) {
FreshTypeParameters getterTypeParameters =
getFreshTypeParameters(typeParameters);
_getter.function.positionalParameters.first.type =
- getterTypeParameters.substitute(thisParameterType);
+ getterTypeParameters.substitute(onType);
_getter.function.returnType = getterTypeParameters.substitute(value);
_getter.function.typeParameters =
getterTypeParameters.freshTypeParameters;
@@ -1726,7 +1712,7 @@
FreshTypeParameters setterTypeParameters =
getFreshTypeParameters(typeParameters);
setter.function.positionalParameters.first.type =
- setterTypeParameters.substitute(thisParameterType);
+ setterTypeParameters.substitute(onType);
setter.function.positionalParameters[1].type =
setterTypeParameters.substitute(value);
setter.function.typeParameters =
@@ -1737,8 +1723,8 @@
} else {
_getter.function.returnType = value;
_setter?.function.positionalParameters[1].type = value;
- _getter.function.positionalParameters.first.type = thisParameterType;
- _setter?.function.positionalParameters.first.type = thisParameterType;
+ _getter.function.positionalParameters.first.type = onType;
+ _setter?.function.positionalParameters.first.type = onType;
}
} else {
_getter.function.returnType = value;
@@ -1769,16 +1755,13 @@
void build(
SourceLibraryBuilder libraryBuilder, SourceFieldBuilder fieldBuilder) {
bool isExtensionMember = fieldBuilder.isExtensionMember;
- bool isInlineClassMember = fieldBuilder.isInlineClassMember;
- bool isInstanceMember = !isExtensionMember &&
- !isInlineClassMember &&
+ bool isInstanceMember = !fieldBuilder.isExtensionMember &&
!fieldBuilder.isStatic &&
!fieldBuilder.isTopLevel;
_getter..isConst = fieldBuilder.isConst;
_getter
..isStatic = !isInstanceMember
..isExtensionMember = isExtensionMember
- ..isInlineClassMember = isInlineClassMember
..isAbstract = isAbstract && !isExternal
..isExternal = isExternal;
@@ -1786,7 +1769,6 @@
_setter!
..isStatic = !isInstanceMember
..isExtensionMember = isExtensionMember
- ..isInlineClassMember = isInlineClassMember
..isAbstract = isAbstract && !isExternal
..isExternal = isExternal;
}
@@ -1797,25 +1779,17 @@
SourceLibraryBuilder library,
SourceFieldBuilder fieldBuilder,
void Function(Member, BuiltMemberKind) f) {
- BuiltMemberKind getterMemberKind;
- if (fieldBuilder.isExtensionMember) {
- getterMemberKind = BuiltMemberKind.ExtensionGetter;
- } else if (fieldBuilder.isInlineClassMember) {
- getterMemberKind = BuiltMemberKind.InlineClassGetter;
- } else {
- getterMemberKind = BuiltMemberKind.Method;
- }
- f(_getter, getterMemberKind);
+ f(
+ _getter,
+ fieldBuilder.isExtensionMember
+ ? BuiltMemberKind.ExtensionGetter
+ : BuiltMemberKind.Method);
if (_setter != null) {
- BuiltMemberKind setterMemberKind;
- if (fieldBuilder.isExtensionMember) {
- setterMemberKind = BuiltMemberKind.ExtensionSetter;
- } else if (fieldBuilder.isInlineClassMember) {
- setterMemberKind = BuiltMemberKind.InlineClassSetter;
- } else {
- setterMemberKind = BuiltMemberKind.Method;
- }
- f(_setter!, setterMemberKind);
+ f(
+ _setter!,
+ fieldBuilder.isExtensionMember
+ ? BuiltMemberKind.ExtensionSetter
+ : BuiltMemberKind.Method);
}
}
diff --git a/pkg/front_end/lib/src/fasta/type_inference/inference_visitor.dart b/pkg/front_end/lib/src/fasta/type_inference/inference_visitor.dart
index 8c6af1a..89c7805 100644
--- a/pkg/front_end/lib/src/fasta/type_inference/inference_visitor.dart
+++ b/pkg/front_end/lib/src/fasta/type_inference/inference_visitor.dart
@@ -9888,8 +9888,8 @@
}
@override
- DartType getVariableType(VariableDeclaration node) {
- return node.type;
+ DartType getVariableType(VariableDeclaration variable) {
+ return variable.type;
}
@override
diff --git a/pkg/front_end/test/spell_checking_list_code.txt b/pkg/front_end/test/spell_checking_list_code.txt
index 92db463..f9f296f 100644
--- a/pkg/front_end/test/spell_checking_list_code.txt
+++ b/pkg/front_end/test/spell_checking_list_code.txt
@@ -27,6 +27,7 @@
adequate
adi
adjusts
+adoption
advantage
affecting
affords
diff --git a/pkg/front_end/testcases/inline_class/external.dart b/pkg/front_end/testcases/inline_class/external.dart
index 36452cc..6593037 100644
--- a/pkg/front_end/testcases/inline_class/external.dart
+++ b/pkg/front_end/testcases/inline_class/external.dart
@@ -11,8 +11,6 @@
external B.named(int i);
- external A field;
-
external A method();
external T genericMethod<T>(T t);
@@ -21,36 +19,29 @@
external void set setter(B b);
- external static A staticField;
+ // TODO(johnniwinther): Support static fields.
+ //static external A staticField;
- external static A staticMethod();
+ static external A staticMethod();
- external static T staticGenericMethod<T>(T t);
+ static external T staticGenericMethod<T>(T t);
- external static B get staticGetter;
+ static external B get staticGetter;
- external static void set staticSetter(B b);
+ static external void set staticGetter(B b);
}
void method(A a) {
B b1 = new B(a);
B b2 = new B.named(0);
- a = b1.field;
- b1.field = a;
a = b1.method();
- var f1 = b1.method;
b2 = b2.genericMethod(b2);
- var f2 = b2.genericMethod;
- int Function(int) f3 = b2.genericMethod;
b1 = b2.getter;
b1.setter = b2;
- a = B.staticField;
- B.staticField = a;
- a = B.staticMethod();
- var f4 = B.staticMethod;
+ //a = B.staticField;
+ //B.staticField = a;
+ a = B.staticMethod;
b2 = B.staticGenericMethod(b2);
- var f5 = B.staticGenericMethod;
- String Function(String) f6 = B.staticGenericMethod;
b1 = B.staticGetter;
B.staticSetter = b2;
}
\ No newline at end of file
diff --git a/pkg/front_end/testcases/inline_class/external.dart.strong.expect b/pkg/front_end/testcases/inline_class/external.dart.strong.expect
index a3b0f4e..b9a3ac2 100644
--- a/pkg/front_end/testcases/inline_class/external.dart.strong.expect
+++ b/pkg/front_end/testcases/inline_class/external.dart.strong.expect
@@ -1,4 +1,36 @@
library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/inline_class/external.dart:25:10: Error: The modifier 'external' should be before the modifier 'static'.
+// Try re-ordering the modifiers.
+// static external A staticMethod();
+// ^^^^^^^^
+//
+// pkg/front_end/testcases/inline_class/external.dart:27:10: Error: The modifier 'external' should be before the modifier 'static'.
+// Try re-ordering the modifiers.
+// static external T staticGenericMethod<T>(T t);
+// ^^^^^^^^
+//
+// pkg/front_end/testcases/inline_class/external.dart:29:10: Error: The modifier 'external' should be before the modifier 'static'.
+// Try re-ordering the modifiers.
+// static external B get staticGetter;
+// ^^^^^^^^
+//
+// pkg/front_end/testcases/inline_class/external.dart:31:10: Error: The modifier 'external' should be before the modifier 'static'.
+// Try re-ordering the modifiers.
+// static external void set staticGetter(B b);
+// ^^^^^^^^
+//
+// pkg/front_end/testcases/inline_class/external.dart:46:5: Error: Setter not found: 'staticSetter'.
+// B.staticSetter = b2;
+// ^^^^^^^^^^^^
+//
+// pkg/front_end/testcases/inline_class/external.dart:43:9: Error: A value of type 'A Function()' can't be assigned to a variable of type 'A'.
+// - 'A' is from 'pkg/front_end/testcases/inline_class/external.dart'.
+// a = B.staticMethod;
+// ^
+//
import self as self;
import "dart:core" as core;
@@ -8,27 +40,21 @@
;
}
inline class B /* declaredRepresentationType = self::A */ {
- get field = self::B|get#field;
- set field = self::B|set#field;
method method = self::B|method;
tearoff method = self::B|get#method;
method genericMethod = self::B|genericMethod;
tearoff genericMethod = self::B|get#genericMethod;
get getter = self::B|get#getter;
- static get staticField = get self::B|staticField;
- static set staticField = set self::B|staticField;
static method staticMethod = self::B|staticMethod;
static method staticGenericMethod = self::B|staticGenericMethod;
static get staticGetter = get self::B|staticGetter;
set setter = self::B|set#setter;
- static set staticSetter = set self::B|staticSetter;
+ static set staticGetter = set self::B|staticGetter;
constructor • = self::B|;
constructor named = self::B|named;
}
external static method B|(self::A a) → self::B;
external static method B|named(core::int i) → self::B;
-external static method B|get#field(self::A #this) → self::A;
-external static method B|set#field(self::A #this, self::A #externalFieldValue) → void;
external static method B|method(lowered final self::B #this) → self::A;
static method B|get#method(lowered final self::B #this) → () → self::A
return () → self::A => self::B|method(#this);
@@ -37,37 +63,28 @@
return <T extends core::Object? = dynamic>(T% t) → T% => self::B|genericMethod<T%>(#this, t);
external static method B|get#getter(lowered final self::B #this) → self::B;
external static method B|set#setter(lowered final self::B #this, self::B b) → void;
-external static get B|staticField() → self::A;
-external static set B|staticField(self::A #externalFieldValue) → void;
external static method B|staticMethod() → self::A;
external static method B|staticGenericMethod<T extends core::Object? = dynamic>(self::B|staticGenericMethod::T% t) → self::B|staticGenericMethod::T%;
external static get B|staticGetter() → self::B;
-external static set B|staticSetter(self::B b) → void;
+external static set B|staticGetter(self::B b) → void;
static method method(self::A a) → void {
self::B b1 = self::B|(a);
self::B b2 = self::B|named(0);
- a = self::B|get#field(b1);
- self::B|set#field(b1, a);
a = self::B|method(b1);
- () → self::A f1 = self::B|get#method(b1);
b2 = self::B|genericMethod<self::B>(b2, b2);
- <T extends core::Object? = dynamic>(T%) → T% f2 = self::B|get#genericMethod(b2);
- (core::int) → core::int f3 = self::B|get#genericMethod(b2)<core::int>;
b1 = self::B|get#getter(b2);
self::B|set#setter(b1, b2);
- a = self::B|staticField;
- self::B|staticField = a;
- a = self::B|staticMethod();
- () → self::A f4 = #C1;
+ a = invalid-expression "pkg/front_end/testcases/inline_class/external.dart:43:9: Error: A value of type 'A Function()' can't be assigned to a variable of type 'A'.
+ - 'A' is from 'pkg/front_end/testcases/inline_class/external.dart'.
+ a = B.staticMethod;
+ ^" in #C1 as{TypeError,ForNonNullableByDefault} self::A;
b2 = self::B|staticGenericMethod<self::B>(b2);
- <T extends core::Object? = dynamic>(T%) → T% f5 = #C2;
- (core::String) → core::String f6 = #C3;
b1 = self::B|staticGetter;
- self::B|staticSetter = b2;
+ invalid-expression "pkg/front_end/testcases/inline_class/external.dart:46:5: Error: Setter not found: 'staticSetter'.
+ B.staticSetter = b2;
+ ^^^^^^^^^^^^";
}
constants {
#C1 = static-tearoff self::B|staticMethod
- #C2 = static-tearoff self::B|staticGenericMethod
- #C3 = instantiation #C2 <core::String>
}
diff --git a/pkg/front_end/testcases/inline_class/external.dart.strong.transformed.expect b/pkg/front_end/testcases/inline_class/external.dart.strong.transformed.expect
index a3b0f4e..b9a3ac2 100644
--- a/pkg/front_end/testcases/inline_class/external.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/inline_class/external.dart.strong.transformed.expect
@@ -1,4 +1,36 @@
library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/inline_class/external.dart:25:10: Error: The modifier 'external' should be before the modifier 'static'.
+// Try re-ordering the modifiers.
+// static external A staticMethod();
+// ^^^^^^^^
+//
+// pkg/front_end/testcases/inline_class/external.dart:27:10: Error: The modifier 'external' should be before the modifier 'static'.
+// Try re-ordering the modifiers.
+// static external T staticGenericMethod<T>(T t);
+// ^^^^^^^^
+//
+// pkg/front_end/testcases/inline_class/external.dart:29:10: Error: The modifier 'external' should be before the modifier 'static'.
+// Try re-ordering the modifiers.
+// static external B get staticGetter;
+// ^^^^^^^^
+//
+// pkg/front_end/testcases/inline_class/external.dart:31:10: Error: The modifier 'external' should be before the modifier 'static'.
+// Try re-ordering the modifiers.
+// static external void set staticGetter(B b);
+// ^^^^^^^^
+//
+// pkg/front_end/testcases/inline_class/external.dart:46:5: Error: Setter not found: 'staticSetter'.
+// B.staticSetter = b2;
+// ^^^^^^^^^^^^
+//
+// pkg/front_end/testcases/inline_class/external.dart:43:9: Error: A value of type 'A Function()' can't be assigned to a variable of type 'A'.
+// - 'A' is from 'pkg/front_end/testcases/inline_class/external.dart'.
+// a = B.staticMethod;
+// ^
+//
import self as self;
import "dart:core" as core;
@@ -8,27 +40,21 @@
;
}
inline class B /* declaredRepresentationType = self::A */ {
- get field = self::B|get#field;
- set field = self::B|set#field;
method method = self::B|method;
tearoff method = self::B|get#method;
method genericMethod = self::B|genericMethod;
tearoff genericMethod = self::B|get#genericMethod;
get getter = self::B|get#getter;
- static get staticField = get self::B|staticField;
- static set staticField = set self::B|staticField;
static method staticMethod = self::B|staticMethod;
static method staticGenericMethod = self::B|staticGenericMethod;
static get staticGetter = get self::B|staticGetter;
set setter = self::B|set#setter;
- static set staticSetter = set self::B|staticSetter;
+ static set staticGetter = set self::B|staticGetter;
constructor • = self::B|;
constructor named = self::B|named;
}
external static method B|(self::A a) → self::B;
external static method B|named(core::int i) → self::B;
-external static method B|get#field(self::A #this) → self::A;
-external static method B|set#field(self::A #this, self::A #externalFieldValue) → void;
external static method B|method(lowered final self::B #this) → self::A;
static method B|get#method(lowered final self::B #this) → () → self::A
return () → self::A => self::B|method(#this);
@@ -37,37 +63,28 @@
return <T extends core::Object? = dynamic>(T% t) → T% => self::B|genericMethod<T%>(#this, t);
external static method B|get#getter(lowered final self::B #this) → self::B;
external static method B|set#setter(lowered final self::B #this, self::B b) → void;
-external static get B|staticField() → self::A;
-external static set B|staticField(self::A #externalFieldValue) → void;
external static method B|staticMethod() → self::A;
external static method B|staticGenericMethod<T extends core::Object? = dynamic>(self::B|staticGenericMethod::T% t) → self::B|staticGenericMethod::T%;
external static get B|staticGetter() → self::B;
-external static set B|staticSetter(self::B b) → void;
+external static set B|staticGetter(self::B b) → void;
static method method(self::A a) → void {
self::B b1 = self::B|(a);
self::B b2 = self::B|named(0);
- a = self::B|get#field(b1);
- self::B|set#field(b1, a);
a = self::B|method(b1);
- () → self::A f1 = self::B|get#method(b1);
b2 = self::B|genericMethod<self::B>(b2, b2);
- <T extends core::Object? = dynamic>(T%) → T% f2 = self::B|get#genericMethod(b2);
- (core::int) → core::int f3 = self::B|get#genericMethod(b2)<core::int>;
b1 = self::B|get#getter(b2);
self::B|set#setter(b1, b2);
- a = self::B|staticField;
- self::B|staticField = a;
- a = self::B|staticMethod();
- () → self::A f4 = #C1;
+ a = invalid-expression "pkg/front_end/testcases/inline_class/external.dart:43:9: Error: A value of type 'A Function()' can't be assigned to a variable of type 'A'.
+ - 'A' is from 'pkg/front_end/testcases/inline_class/external.dart'.
+ a = B.staticMethod;
+ ^" in #C1 as{TypeError,ForNonNullableByDefault} self::A;
b2 = self::B|staticGenericMethod<self::B>(b2);
- <T extends core::Object? = dynamic>(T%) → T% f5 = #C2;
- (core::String) → core::String f6 = #C3;
b1 = self::B|staticGetter;
- self::B|staticSetter = b2;
+ invalid-expression "pkg/front_end/testcases/inline_class/external.dart:46:5: Error: Setter not found: 'staticSetter'.
+ B.staticSetter = b2;
+ ^^^^^^^^^^^^";
}
constants {
#C1 = static-tearoff self::B|staticMethod
- #C2 = static-tearoff self::B|staticGenericMethod
- #C3 = instantiation #C2 <core::String>
}
diff --git a/pkg/front_end/testcases/inline_class/external.dart.textual_outline.expect b/pkg/front_end/testcases/inline_class/external.dart.textual_outline.expect
index ede85d1..e59d363 100644
--- a/pkg/front_end/testcases/inline_class/external.dart.textual_outline.expect
+++ b/pkg/front_end/testcases/inline_class/external.dart.textual_outline.expect
@@ -4,15 +4,13 @@
final A a;
external B(A a);
external B.named(int i);
- external A field;
external A method();
external T genericMethod<T>(T t);
external B get getter;
external void set setter(B b);
- external static A staticField;
- external static A staticMethod();
- external static T staticGenericMethod<T>(T t);
- external static B get staticGetter;
- external static void set staticSetter(B b);
+ static external A staticMethod();
+ static external T staticGenericMethod<T>(T t);
+ static external B get staticGetter;
+ static external void set staticGetter(B b);
}
void method(A a) {}
diff --git a/pkg/front_end/testcases/inline_class/external.dart.weak.expect b/pkg/front_end/testcases/inline_class/external.dart.weak.expect
index 467c226..b9a3ac2 100644
--- a/pkg/front_end/testcases/inline_class/external.dart.weak.expect
+++ b/pkg/front_end/testcases/inline_class/external.dart.weak.expect
@@ -1,4 +1,36 @@
library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/inline_class/external.dart:25:10: Error: The modifier 'external' should be before the modifier 'static'.
+// Try re-ordering the modifiers.
+// static external A staticMethod();
+// ^^^^^^^^
+//
+// pkg/front_end/testcases/inline_class/external.dart:27:10: Error: The modifier 'external' should be before the modifier 'static'.
+// Try re-ordering the modifiers.
+// static external T staticGenericMethod<T>(T t);
+// ^^^^^^^^
+//
+// pkg/front_end/testcases/inline_class/external.dart:29:10: Error: The modifier 'external' should be before the modifier 'static'.
+// Try re-ordering the modifiers.
+// static external B get staticGetter;
+// ^^^^^^^^
+//
+// pkg/front_end/testcases/inline_class/external.dart:31:10: Error: The modifier 'external' should be before the modifier 'static'.
+// Try re-ordering the modifiers.
+// static external void set staticGetter(B b);
+// ^^^^^^^^
+//
+// pkg/front_end/testcases/inline_class/external.dart:46:5: Error: Setter not found: 'staticSetter'.
+// B.staticSetter = b2;
+// ^^^^^^^^^^^^
+//
+// pkg/front_end/testcases/inline_class/external.dart:43:9: Error: A value of type 'A Function()' can't be assigned to a variable of type 'A'.
+// - 'A' is from 'pkg/front_end/testcases/inline_class/external.dart'.
+// a = B.staticMethod;
+// ^
+//
import self as self;
import "dart:core" as core;
@@ -8,27 +40,21 @@
;
}
inline class B /* declaredRepresentationType = self::A */ {
- get field = self::B|get#field;
- set field = self::B|set#field;
method method = self::B|method;
tearoff method = self::B|get#method;
method genericMethod = self::B|genericMethod;
tearoff genericMethod = self::B|get#genericMethod;
get getter = self::B|get#getter;
- static get staticField = get self::B|staticField;
- static set staticField = set self::B|staticField;
static method staticMethod = self::B|staticMethod;
static method staticGenericMethod = self::B|staticGenericMethod;
static get staticGetter = get self::B|staticGetter;
set setter = self::B|set#setter;
- static set staticSetter = set self::B|staticSetter;
+ static set staticGetter = set self::B|staticGetter;
constructor • = self::B|;
constructor named = self::B|named;
}
external static method B|(self::A a) → self::B;
external static method B|named(core::int i) → self::B;
-external static method B|get#field(self::A #this) → self::A;
-external static method B|set#field(self::A #this, self::A #externalFieldValue) → void;
external static method B|method(lowered final self::B #this) → self::A;
static method B|get#method(lowered final self::B #this) → () → self::A
return () → self::A => self::B|method(#this);
@@ -37,37 +63,28 @@
return <T extends core::Object? = dynamic>(T% t) → T% => self::B|genericMethod<T%>(#this, t);
external static method B|get#getter(lowered final self::B #this) → self::B;
external static method B|set#setter(lowered final self::B #this, self::B b) → void;
-external static get B|staticField() → self::A;
-external static set B|staticField(self::A #externalFieldValue) → void;
external static method B|staticMethod() → self::A;
external static method B|staticGenericMethod<T extends core::Object? = dynamic>(self::B|staticGenericMethod::T% t) → self::B|staticGenericMethod::T%;
external static get B|staticGetter() → self::B;
-external static set B|staticSetter(self::B b) → void;
+external static set B|staticGetter(self::B b) → void;
static method method(self::A a) → void {
self::B b1 = self::B|(a);
self::B b2 = self::B|named(0);
- a = self::B|get#field(b1);
- self::B|set#field(b1, a);
a = self::B|method(b1);
- () → self::A f1 = self::B|get#method(b1);
b2 = self::B|genericMethod<self::B>(b2, b2);
- <T extends core::Object? = dynamic>(T%) → T% f2 = self::B|get#genericMethod(b2);
- (core::int) → core::int f3 = self::B|get#genericMethod(b2)<core::int>;
b1 = self::B|get#getter(b2);
self::B|set#setter(b1, b2);
- a = self::B|staticField;
- self::B|staticField = a;
- a = self::B|staticMethod();
- () → self::A f4 = #C1;
+ a = invalid-expression "pkg/front_end/testcases/inline_class/external.dart:43:9: Error: A value of type 'A Function()' can't be assigned to a variable of type 'A'.
+ - 'A' is from 'pkg/front_end/testcases/inline_class/external.dart'.
+ a = B.staticMethod;
+ ^" in #C1 as{TypeError,ForNonNullableByDefault} self::A;
b2 = self::B|staticGenericMethod<self::B>(b2);
- <T extends core::Object? = dynamic>(T%) → T% f5 = #C2;
- (core::String) → core::String f6 = #C3;
b1 = self::B|staticGetter;
- self::B|staticSetter = b2;
+ invalid-expression "pkg/front_end/testcases/inline_class/external.dart:46:5: Error: Setter not found: 'staticSetter'.
+ B.staticSetter = b2;
+ ^^^^^^^^^^^^";
}
constants {
#C1 = static-tearoff self::B|staticMethod
- #C2 = static-tearoff self::B|staticGenericMethod
- #C3 = instantiation #C2 <core::String*>
}
diff --git a/pkg/front_end/testcases/inline_class/external.dart.weak.modular.expect b/pkg/front_end/testcases/inline_class/external.dart.weak.modular.expect
index 467c226..b9a3ac2 100644
--- a/pkg/front_end/testcases/inline_class/external.dart.weak.modular.expect
+++ b/pkg/front_end/testcases/inline_class/external.dart.weak.modular.expect
@@ -1,4 +1,36 @@
library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/inline_class/external.dart:25:10: Error: The modifier 'external' should be before the modifier 'static'.
+// Try re-ordering the modifiers.
+// static external A staticMethod();
+// ^^^^^^^^
+//
+// pkg/front_end/testcases/inline_class/external.dart:27:10: Error: The modifier 'external' should be before the modifier 'static'.
+// Try re-ordering the modifiers.
+// static external T staticGenericMethod<T>(T t);
+// ^^^^^^^^
+//
+// pkg/front_end/testcases/inline_class/external.dart:29:10: Error: The modifier 'external' should be before the modifier 'static'.
+// Try re-ordering the modifiers.
+// static external B get staticGetter;
+// ^^^^^^^^
+//
+// pkg/front_end/testcases/inline_class/external.dart:31:10: Error: The modifier 'external' should be before the modifier 'static'.
+// Try re-ordering the modifiers.
+// static external void set staticGetter(B b);
+// ^^^^^^^^
+//
+// pkg/front_end/testcases/inline_class/external.dart:46:5: Error: Setter not found: 'staticSetter'.
+// B.staticSetter = b2;
+// ^^^^^^^^^^^^
+//
+// pkg/front_end/testcases/inline_class/external.dart:43:9: Error: A value of type 'A Function()' can't be assigned to a variable of type 'A'.
+// - 'A' is from 'pkg/front_end/testcases/inline_class/external.dart'.
+// a = B.staticMethod;
+// ^
+//
import self as self;
import "dart:core" as core;
@@ -8,27 +40,21 @@
;
}
inline class B /* declaredRepresentationType = self::A */ {
- get field = self::B|get#field;
- set field = self::B|set#field;
method method = self::B|method;
tearoff method = self::B|get#method;
method genericMethod = self::B|genericMethod;
tearoff genericMethod = self::B|get#genericMethod;
get getter = self::B|get#getter;
- static get staticField = get self::B|staticField;
- static set staticField = set self::B|staticField;
static method staticMethod = self::B|staticMethod;
static method staticGenericMethod = self::B|staticGenericMethod;
static get staticGetter = get self::B|staticGetter;
set setter = self::B|set#setter;
- static set staticSetter = set self::B|staticSetter;
+ static set staticGetter = set self::B|staticGetter;
constructor • = self::B|;
constructor named = self::B|named;
}
external static method B|(self::A a) → self::B;
external static method B|named(core::int i) → self::B;
-external static method B|get#field(self::A #this) → self::A;
-external static method B|set#field(self::A #this, self::A #externalFieldValue) → void;
external static method B|method(lowered final self::B #this) → self::A;
static method B|get#method(lowered final self::B #this) → () → self::A
return () → self::A => self::B|method(#this);
@@ -37,37 +63,28 @@
return <T extends core::Object? = dynamic>(T% t) → T% => self::B|genericMethod<T%>(#this, t);
external static method B|get#getter(lowered final self::B #this) → self::B;
external static method B|set#setter(lowered final self::B #this, self::B b) → void;
-external static get B|staticField() → self::A;
-external static set B|staticField(self::A #externalFieldValue) → void;
external static method B|staticMethod() → self::A;
external static method B|staticGenericMethod<T extends core::Object? = dynamic>(self::B|staticGenericMethod::T% t) → self::B|staticGenericMethod::T%;
external static get B|staticGetter() → self::B;
-external static set B|staticSetter(self::B b) → void;
+external static set B|staticGetter(self::B b) → void;
static method method(self::A a) → void {
self::B b1 = self::B|(a);
self::B b2 = self::B|named(0);
- a = self::B|get#field(b1);
- self::B|set#field(b1, a);
a = self::B|method(b1);
- () → self::A f1 = self::B|get#method(b1);
b2 = self::B|genericMethod<self::B>(b2, b2);
- <T extends core::Object? = dynamic>(T%) → T% f2 = self::B|get#genericMethod(b2);
- (core::int) → core::int f3 = self::B|get#genericMethod(b2)<core::int>;
b1 = self::B|get#getter(b2);
self::B|set#setter(b1, b2);
- a = self::B|staticField;
- self::B|staticField = a;
- a = self::B|staticMethod();
- () → self::A f4 = #C1;
+ a = invalid-expression "pkg/front_end/testcases/inline_class/external.dart:43:9: Error: A value of type 'A Function()' can't be assigned to a variable of type 'A'.
+ - 'A' is from 'pkg/front_end/testcases/inline_class/external.dart'.
+ a = B.staticMethod;
+ ^" in #C1 as{TypeError,ForNonNullableByDefault} self::A;
b2 = self::B|staticGenericMethod<self::B>(b2);
- <T extends core::Object? = dynamic>(T%) → T% f5 = #C2;
- (core::String) → core::String f6 = #C3;
b1 = self::B|staticGetter;
- self::B|staticSetter = b2;
+ invalid-expression "pkg/front_end/testcases/inline_class/external.dart:46:5: Error: Setter not found: 'staticSetter'.
+ B.staticSetter = b2;
+ ^^^^^^^^^^^^";
}
constants {
#C1 = static-tearoff self::B|staticMethod
- #C2 = static-tearoff self::B|staticGenericMethod
- #C3 = instantiation #C2 <core::String*>
}
diff --git a/pkg/front_end/testcases/inline_class/external.dart.weak.outline.expect b/pkg/front_end/testcases/inline_class/external.dart.weak.outline.expect
index 933ed07..e3657ca 100644
--- a/pkg/front_end/testcases/inline_class/external.dart.weak.outline.expect
+++ b/pkg/front_end/testcases/inline_class/external.dart.weak.outline.expect
@@ -1,4 +1,27 @@
library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/inline_class/external.dart:25:10: Error: The modifier 'external' should be before the modifier 'static'.
+// Try re-ordering the modifiers.
+// static external A staticMethod();
+// ^^^^^^^^
+//
+// pkg/front_end/testcases/inline_class/external.dart:27:10: Error: The modifier 'external' should be before the modifier 'static'.
+// Try re-ordering the modifiers.
+// static external T staticGenericMethod<T>(T t);
+// ^^^^^^^^
+//
+// pkg/front_end/testcases/inline_class/external.dart:29:10: Error: The modifier 'external' should be before the modifier 'static'.
+// Try re-ordering the modifiers.
+// static external B get staticGetter;
+// ^^^^^^^^
+//
+// pkg/front_end/testcases/inline_class/external.dart:31:10: Error: The modifier 'external' should be before the modifier 'static'.
+// Try re-ordering the modifiers.
+// static external void set staticGetter(B b);
+// ^^^^^^^^
+//
import self as self;
import "dart:core" as core;
@@ -7,27 +30,21 @@
;
}
inline class B /* declaredRepresentationType = self::A */ {
- get field = self::B|get#field;
- set field = self::B|set#field;
method method = self::B|method;
tearoff method = self::B|get#method;
method genericMethod = self::B|genericMethod;
tearoff genericMethod = self::B|get#genericMethod;
get getter = self::B|get#getter;
- static get staticField = get self::B|staticField;
- static set staticField = set self::B|staticField;
static method staticMethod = self::B|staticMethod;
static method staticGenericMethod = self::B|staticGenericMethod;
static get staticGetter = get self::B|staticGetter;
set setter = self::B|set#setter;
- static set staticSetter = set self::B|staticSetter;
+ static set staticGetter = set self::B|staticGetter;
constructor • = self::B|;
constructor named = self::B|named;
}
external static method B|(self::A a) → self::B;
external static method B|named(core::int i) → self::B;
-external static method B|get#field(self::A #this) → self::A;
-external static method B|set#field(self::A #this, self::A #externalFieldValue) → void;
external static method B|method(lowered final self::B #this) → self::A;
static method B|get#method(lowered final self::B #this) → () → self::A
return () → self::A => self::B|method(#this);
@@ -36,11 +53,9 @@
return <T extends core::Object? = dynamic>(T% t) → T% => self::B|genericMethod<T%>(#this, t);
external static method B|get#getter(lowered final self::B #this) → self::B;
external static method B|set#setter(lowered final self::B #this, self::B b) → void;
-external static get B|staticField() → self::A;
-external static set B|staticField(self::A #externalFieldValue) → void;
external static method B|staticMethod() → self::A;
external static method B|staticGenericMethod<T extends core::Object? = dynamic>(self::B|staticGenericMethod::T% t) → self::B|staticGenericMethod::T%;
external static get B|staticGetter() → self::B;
-external static set B|staticSetter(self::B b) → void;
+external static set B|staticGetter(self::B b) → void;
static method method(self::A a) → void
;
diff --git a/pkg/front_end/testcases/inline_class/external.dart.weak.transformed.expect b/pkg/front_end/testcases/inline_class/external.dart.weak.transformed.expect
index 467c226..b9a3ac2 100644
--- a/pkg/front_end/testcases/inline_class/external.dart.weak.transformed.expect
+++ b/pkg/front_end/testcases/inline_class/external.dart.weak.transformed.expect
@@ -1,4 +1,36 @@
library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/inline_class/external.dart:25:10: Error: The modifier 'external' should be before the modifier 'static'.
+// Try re-ordering the modifiers.
+// static external A staticMethod();
+// ^^^^^^^^
+//
+// pkg/front_end/testcases/inline_class/external.dart:27:10: Error: The modifier 'external' should be before the modifier 'static'.
+// Try re-ordering the modifiers.
+// static external T staticGenericMethod<T>(T t);
+// ^^^^^^^^
+//
+// pkg/front_end/testcases/inline_class/external.dart:29:10: Error: The modifier 'external' should be before the modifier 'static'.
+// Try re-ordering the modifiers.
+// static external B get staticGetter;
+// ^^^^^^^^
+//
+// pkg/front_end/testcases/inline_class/external.dart:31:10: Error: The modifier 'external' should be before the modifier 'static'.
+// Try re-ordering the modifiers.
+// static external void set staticGetter(B b);
+// ^^^^^^^^
+//
+// pkg/front_end/testcases/inline_class/external.dart:46:5: Error: Setter not found: 'staticSetter'.
+// B.staticSetter = b2;
+// ^^^^^^^^^^^^
+//
+// pkg/front_end/testcases/inline_class/external.dart:43:9: Error: A value of type 'A Function()' can't be assigned to a variable of type 'A'.
+// - 'A' is from 'pkg/front_end/testcases/inline_class/external.dart'.
+// a = B.staticMethod;
+// ^
+//
import self as self;
import "dart:core" as core;
@@ -8,27 +40,21 @@
;
}
inline class B /* declaredRepresentationType = self::A */ {
- get field = self::B|get#field;
- set field = self::B|set#field;
method method = self::B|method;
tearoff method = self::B|get#method;
method genericMethod = self::B|genericMethod;
tearoff genericMethod = self::B|get#genericMethod;
get getter = self::B|get#getter;
- static get staticField = get self::B|staticField;
- static set staticField = set self::B|staticField;
static method staticMethod = self::B|staticMethod;
static method staticGenericMethod = self::B|staticGenericMethod;
static get staticGetter = get self::B|staticGetter;
set setter = self::B|set#setter;
- static set staticSetter = set self::B|staticSetter;
+ static set staticGetter = set self::B|staticGetter;
constructor • = self::B|;
constructor named = self::B|named;
}
external static method B|(self::A a) → self::B;
external static method B|named(core::int i) → self::B;
-external static method B|get#field(self::A #this) → self::A;
-external static method B|set#field(self::A #this, self::A #externalFieldValue) → void;
external static method B|method(lowered final self::B #this) → self::A;
static method B|get#method(lowered final self::B #this) → () → self::A
return () → self::A => self::B|method(#this);
@@ -37,37 +63,28 @@
return <T extends core::Object? = dynamic>(T% t) → T% => self::B|genericMethod<T%>(#this, t);
external static method B|get#getter(lowered final self::B #this) → self::B;
external static method B|set#setter(lowered final self::B #this, self::B b) → void;
-external static get B|staticField() → self::A;
-external static set B|staticField(self::A #externalFieldValue) → void;
external static method B|staticMethod() → self::A;
external static method B|staticGenericMethod<T extends core::Object? = dynamic>(self::B|staticGenericMethod::T% t) → self::B|staticGenericMethod::T%;
external static get B|staticGetter() → self::B;
-external static set B|staticSetter(self::B b) → void;
+external static set B|staticGetter(self::B b) → void;
static method method(self::A a) → void {
self::B b1 = self::B|(a);
self::B b2 = self::B|named(0);
- a = self::B|get#field(b1);
- self::B|set#field(b1, a);
a = self::B|method(b1);
- () → self::A f1 = self::B|get#method(b1);
b2 = self::B|genericMethod<self::B>(b2, b2);
- <T extends core::Object? = dynamic>(T%) → T% f2 = self::B|get#genericMethod(b2);
- (core::int) → core::int f3 = self::B|get#genericMethod(b2)<core::int>;
b1 = self::B|get#getter(b2);
self::B|set#setter(b1, b2);
- a = self::B|staticField;
- self::B|staticField = a;
- a = self::B|staticMethod();
- () → self::A f4 = #C1;
+ a = invalid-expression "pkg/front_end/testcases/inline_class/external.dart:43:9: Error: A value of type 'A Function()' can't be assigned to a variable of type 'A'.
+ - 'A' is from 'pkg/front_end/testcases/inline_class/external.dart'.
+ a = B.staticMethod;
+ ^" in #C1 as{TypeError,ForNonNullableByDefault} self::A;
b2 = self::B|staticGenericMethod<self::B>(b2);
- <T extends core::Object? = dynamic>(T%) → T% f5 = #C2;
- (core::String) → core::String f6 = #C3;
b1 = self::B|staticGetter;
- self::B|staticSetter = b2;
+ invalid-expression "pkg/front_end/testcases/inline_class/external.dart:46:5: Error: Setter not found: 'staticSetter'.
+ B.staticSetter = b2;
+ ^^^^^^^^^^^^";
}
constants {
#C1 = static-tearoff self::B|staticMethod
- #C2 = static-tearoff self::B|staticGenericMethod
- #C3 = instantiation #C2 <core::String*>
}
diff --git a/pkg/kernel/binary.md b/pkg/kernel/binary.md
index 8385e50..5a67d53 100644
--- a/pkg/kernel/binary.md
+++ b/pkg/kernel/binary.md
@@ -174,7 +174,7 @@
// Component index with all fixed-size-32-bit integers.
// This gives "semi-random-access" to certain parts of the binary.
-// By reading the last 4 bytes one knows the number of libaries,
+// By reading the last 4 bytes one knows the number of libraries,
// which allows to skip to any other field in this component index,
// which again allows to skip to what it points to.
type ComponentIndex {
diff --git a/pkg/vm/lib/transformations/ffi/finalizable.dart b/pkg/vm/lib/transformations/ffi/finalizable.dart
index b59786b..4304d58 100644
--- a/pkg/vm/lib/transformations/ffi/finalizable.dart
+++ b/pkg/vm/lib/transformations/ffi/finalizable.dart
@@ -15,7 +15,7 @@
/// [Statement]s can be replaced by other [Expression]s and [Statement]s
/// respectively. This means one cannot do `visitX() { super.visitX() as X }`.
///
-/// This transform must be run on the standard libaries as well. For example
+/// This transform must be run on the standard libraries as well. For example
/// `NativeFinalizer`s `attach` implementation depends on it.
mixin FinalizableTransformer on Transformer {
TypeEnvironment get env;
diff --git a/runtime/observatory/lib/src/cli/command.dart b/runtime/observatory/lib/src/cli/command.dart
index 7beb26f..d368908 100644
--- a/runtime/observatory/lib/src/cli/command.dart
+++ b/runtime/observatory/lib/src/cli/command.dart
@@ -158,7 +158,7 @@
var completions =
commands.map((command) => '${prefix}${command.name} ').toList();
if (matchLen == args.length) {
- // If we are showing all possiblities, also include local
+ // If we are showing all possibilities, also include local
// completions for the parent command.
return commands[0]
._parent!
diff --git a/runtime/observatory_2/lib/src/cli/command.dart b/runtime/observatory_2/lib/src/cli/command.dart
index 0a0fc42..cd08eeb 100644
--- a/runtime/observatory_2/lib/src/cli/command.dart
+++ b/runtime/observatory_2/lib/src/cli/command.dart
@@ -158,7 +158,7 @@
var completions =
commands.map((command) => '${prefix}${command.name} ').toList();
if (matchLen == args.length) {
- // If we are showing all possiblities, also include local
+ // If we are showing all possibilities, also include local
// completions for the parent command.
return commands[0]
._parent
diff --git a/runtime/vm/compiler/aot/precompiler.cc b/runtime/vm/compiler/aot/precompiler.cc
index e870e56..386a03a 100644
--- a/runtime/vm/compiler/aot/precompiler.cc
+++ b/runtime/vm/compiler/aot/precompiler.cc
@@ -3544,7 +3544,7 @@
// too big). If we were adding objects into the global pool directly
// these recompilations would leave dead entries behind.
// Instead we add objects into an intermediary pool which gets
- // commited into the global object pool at the end of the compilation.
+ // committed into the global object pool at the end of the compilation.
// This makes an assumption that global object pool itself does not
// grow during code generation - unfortunately this is not the case
// becase we might have nested code generation (i.e. we might generate
diff --git a/runtime/vm/compiler/stub_code_compiler.cc b/runtime/vm/compiler/stub_code_compiler.cc
index 9a99940..4df6db1 100644
--- a/runtime/vm/compiler/stub_code_compiler.cc
+++ b/runtime/vm/compiler/stub_code_compiler.cc
@@ -2477,7 +2477,7 @@
// Check if suspend_state is initialized. Otherwise
// exception was thrown from the prologue code and
- // should be synchronuously propagated.
+ // should be synchronously propagated.
__ CompareObject(kSuspendState, NullObject());
__ BranchIf(EQUAL, &rethrow_exception);
diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc
index 46a9ebe..e4559c6 100644
--- a/runtime/vm/dart_api_impl.cc
+++ b/runtime/vm/dart_api_impl.cc
@@ -5898,7 +5898,7 @@
I->debugger()->NotifyDoneLoading();
#endif
- // After having loaded all the code, we can let the GC set reaonsable limits
+ // After having loaded all the code, we can let the GC set reasonable limits
// for the heap growth.
// If this is an auxiliary isolate inside a larger isolate group, we will not
// re-initialize the growth policy.
diff --git a/runtime/vm/dart_api_impl_test.cc b/runtime/vm/dart_api_impl_test.cc
index eddde3a..9f6e13d 100644
--- a/runtime/vm/dart_api_impl_test.cc
+++ b/runtime/vm/dart_api_impl_test.cc
@@ -3287,7 +3287,7 @@
(*count)++;
}
-TEST_CASE(DartAPI_SlowWeakPersistenhandle) {
+TEST_CASE(DartAPI_SlowWeakPersistentHandle) {
Dart_WeakPersistentHandle handles[20];
intptr_t count = 0;
diff --git a/runtime/vm/isolate_reload.cc b/runtime/vm/isolate_reload.cc
index 0c6025b..977027d 100644
--- a/runtime/vm/isolate_reload.cc
+++ b/runtime/vm/isolate_reload.cc
@@ -1361,7 +1361,7 @@
// Before this operation class table which is used for heap scanning and
// the class table used for program loading are the same. After this step
- // they will become different until reload is commited (or rolled back).
+ // they will become different until reload is committed (or rolled back).
//
// Note that because GC is always reading from heap_walk_class_table and
// we are not changing that, there is no reason to wait for sweeping
diff --git a/runtime/vm/service.cc b/runtime/vm/service.cc
index 3270228..a235586 100644
--- a/runtime/vm/service.cc
+++ b/runtime/vm/service.cc
@@ -4006,7 +4006,7 @@
ObjectIdRing::LookupResult lookup_result;
Isolate* isolate = thread->isolate();
Breakpoint* bpt = LookupBreakpoint(isolate, bpt_id, &lookup_result);
- // TODO(turnidge): Should we return a different error for bpts whic
+ // TODO(turnidge): Should we return a different error for bpts which
// have been already removed?
if (bpt == NULL) {
PrintInvalidParamError(js, "breakpointId");
diff --git a/runtime/vm/thread_pool.h b/runtime/vm/thread_pool.h
index 2533051..f3256ea 100644
--- a/runtime/vm/thread_pool.h
+++ b/runtime/vm/thread_pool.h
@@ -46,7 +46,7 @@
return RunImpl(std::unique_ptr<Task>(new T(std::forward<Args>(args)...)));
}
- // Returns `true` if the current thread is runing on the [this] thread pool.
+ // Returns `true` if the current thread is running on the [this] thread pool.
bool CurrentThreadIsWorker();
// Mark the current thread as being blocked (e.g. in native code). This might
diff --git a/samples/ffi/sample_ffi_bitfield.dart b/samples/ffi/sample_ffi_bitfield.dart
index 4508bed..094ab07 100644
--- a/samples/ffi/sample_ffi_bitfield.dart
+++ b/samples/ffi/sample_ffi_bitfield.dart
@@ -72,7 +72,7 @@
/// Extension to use a 64-bit integer as bit field.
extension IntBitField on int {
- static int _bitMask(int offset, int lenght) => ((1 << lenght) - 1) << offset;
+ static int _bitMask(int offset, int length) => ((1 << length) - 1) << offset;
/// Read `length` bits at `offset`.
///
diff --git a/samples/ffi/sample_ffi_functions_callbacks_closures.dart b/samples/ffi/sample_ffi_functions_callbacks_closures.dart
index 5fb0b7a..5cccf91 100644
--- a/samples/ffi/sample_ffi_functions_callbacks_closures.dart
+++ b/samples/ffi/sample_ffi_functions_callbacks_closures.dart
@@ -18,7 +18,7 @@
counter++;
}
- // C holds on to this closure through a `Dart_PersistenHandle`.
+ // C holds on to this closure through a `Dart_PersistentHandle`.
registerClosureCallback(closure);
// Some time later this closure can be invoked.
diff --git a/samples/ffi/sqlite/docs/sqlite-tutorial.md b/samples/ffi/sqlite/docs/sqlite-tutorial.md
index 14d77b1..60d6729 100644
--- a/samples/ffi/sqlite/docs/sqlite-tutorial.md
+++ b/samples/ffi/sqlite/docs/sqlite-tutorial.md
@@ -208,7 +208,7 @@
In this minitutorial we used these `dart:ffi` features:
-* Loading dynamic libararies and looking up C functions in these dynamic libraries.
+* Loading dynamic libraries and looking up C functions in these dynamic libraries.
* Calling C functions, with `dart:ffi` automatically marshalling arguments and return value.
* Manipulating C memory through `Pointer`s with `allocate`, `free`, `load`, `store`, and `elementAt`.
diff --git a/samples/ffi/sqlite/lib/src/database.dart b/samples/ffi/sqlite/lib/src/database.dart
index fa6a8d5..23b1739 100644
--- a/samples/ffi/sqlite/lib/src/database.dart
+++ b/samples/ffi/sqlite/lib/src/database.dart
@@ -19,7 +19,7 @@
///
/// All functions against a database may throw [SQLiteError].
///
-/// This database interacts with SQLite synchonously.
+/// This database interacts with SQLite synchronously.
class Database {
late DatabaseResource _database;
bool _open = false;
diff --git a/sdk/lib/_internal/js_dev_runtime/private/foreign_helper.dart b/sdk/lib/_internal/js_dev_runtime/private/foreign_helper.dart
index 9315837..3baadcb 100644
--- a/sdk/lib/_internal/js_dev_runtime/private/foreign_helper.dart
+++ b/sdk/lib/_internal/js_dev_runtime/private/foreign_helper.dart
@@ -57,7 +57,7 @@
*
* + Do not use any parameter, local, method or field names in the
* [codeTemplate]. These names are all subject to arbitrary renaming by the
- * compiler. Pass the values in via `#` substition, and test with the
+ * compiler. Pass the values in via `#` substitution, and test with the
* `--minify` dart2js command-line option.
*
* + The substituted expressions are values, not locations.
diff --git a/sdk/lib/_internal/js_runtime/lib/foreign_helper.dart b/sdk/lib/_internal/js_runtime/lib/foreign_helper.dart
index 66b06a7..428e0b8 100644
--- a/sdk/lib/_internal/js_runtime/lib/foreign_helper.dart
+++ b/sdk/lib/_internal/js_runtime/lib/foreign_helper.dart
@@ -86,7 +86,7 @@
///
/// + Do not use any parameter, local, method or field names in the
/// [codeTemplate]. These names are all subject to arbitrary renaming by the
-/// compiler. Pass the values in via `#` substition, and test with the
+/// compiler. Pass the values in via `#` substitution, and test with the
/// `--minify` dart2js command-line option.
///
/// + The substituted expressions are values, not locations.
diff --git a/sdk/lib/indexed_db/dart2js/indexed_db_dart2js.dart b/sdk/lib/indexed_db/dart2js/indexed_db_dart2js.dart
index 1df1cc9..2328da9 100644
--- a/sdk/lib/indexed_db/dart2js/indexed_db_dart2js.dart
+++ b/sdk/lib/indexed_db/dart2js/indexed_db_dart2js.dart
@@ -1164,7 +1164,7 @@
* Provides a Future which will be completed once the transaction has
* completed.
*
- * The future will error if an error occurrs on the transaction or if the
+ * The future will error if an error occurs on the transaction or if the
* transaction is aborted.
*/
Future<Database> get completed {
diff --git a/sdk/lib/web_audio/dart2js/web_audio_dart2js.dart b/sdk/lib/web_audio/dart2js/web_audio_dart2js.dart
index 37e538b..128dc1c 100644
--- a/sdk/lib/web_audio/dart2js/web_audio_dart2js.dart
+++ b/sdk/lib/web_audio/dart2js/web_audio_dart2js.dart
@@ -1303,7 +1303,7 @@
* Get a Stream that fires events when AudioProcessingEvents occur.
* This particular stream is special in that it only allows one listener to a
* given stream. Converting the returned [Stream.asBroadcastStream] will
- * likely ruin the soft-real-time properties which which these events are
+ * likely ruin the soft-real-time properties which these events are
* fired and can be processed.
*/
Stream<AudioProcessingEvent> get onAudioProcess =>
diff --git a/tests/ffi/function_callbacks_structs_by_value_test.dart b/tests/ffi/function_callbacks_structs_by_value_test.dart
index a33cadc..01cc17a 100644
--- a/tests/ffi/function_callbacks_structs_by_value_test.dart
+++ b/tests/ffi/function_callbacks_structs_by_value_test.dart
@@ -45,7 +45,7 @@
Struct20BytesHomogeneousInt32 dartPassStructRecursive(
int recursionCounter, Struct20BytesHomogeneousInt32 struct) {
- print("callbackPassStructRecurisive($recursionCounter, $struct)");
+ print("callbackPassStructRecursive($recursionCounter, $struct)");
struct.a0++;
final structA0Saved = struct.a0;
if (recursionCounter <= 0) {
diff --git a/tests/ffi/generator/utils.dart b/tests/ffi/generator/utils.dart
index 735e769..7f1e769 100644
--- a/tests/ffi/generator/utils.dart
+++ b/tests/ffi/generator/utils.dart
@@ -11,9 +11,9 @@
String makeDartDocComment() => "/// " + split("\n").join("\n/// ");
- String limitTo(int lenght) {
- if (this.length > lenght) {
- return substring(0, lenght);
+ String limitTo(int length) {
+ if (this.length > length) {
+ return substring(0, length);
}
return this;
}
diff --git a/tests/ffi_2/function_callbacks_structs_by_value_test.dart b/tests/ffi_2/function_callbacks_structs_by_value_test.dart
index fad090e..0392513 100644
--- a/tests/ffi_2/function_callbacks_structs_by_value_test.dart
+++ b/tests/ffi_2/function_callbacks_structs_by_value_test.dart
@@ -47,7 +47,7 @@
Struct20BytesHomogeneousInt32 dartPassStructRecursive(
int recursionCounter, Struct20BytesHomogeneousInt32 struct) {
- print("callbackPassStructRecurisive($recursionCounter, $struct)");
+ print("callbackPassStructRecursive($recursionCounter, $struct)");
struct.a0++;
final structA0Saved = struct.a0;
if (recursionCounter <= 0) {
diff --git a/tests/language/nnbd/boolean_conversion/boolean_conversion_lib1.dart b/tests/language/nnbd/boolean_conversion/boolean_conversion_lib1.dart
index 4811a87..9116dbb 100644
--- a/tests/language/nnbd/boolean_conversion/boolean_conversion_lib1.dart
+++ b/tests/language/nnbd/boolean_conversion/boolean_conversion_lib1.dart
@@ -4,7 +4,7 @@
// This library defines a set of test functions 'xxxAsBoolean" and a check
// combinator called `check` which test the runtime behavior of conversions
-// of values in boolean condional positions (e.g. the condition of a conditional
+// of values in boolean conditional positions (e.g. the condition of a conditional
// statement).
//
// For example: calling `check(dynamicAsBoolean, value, expectation)` tests that
diff --git a/tools/VERSION b/tools/VERSION
index e8af3d2..9fe2919 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 3
MINOR 0
PATCH 0
-PRERELEASE 103
+PRERELEASE 104
PRERELEASE_PATCH 0
diff --git a/tools/copy_tree.py b/tools/copy_tree.py
index 8c63308..a3ef4c2 100755
--- a/tools/copy_tree.py
+++ b/tools/copy_tree.py
@@ -61,7 +61,7 @@
def CopyTree(src, dst, ignore=None):
- # Recusive helper method to collect errors but keep processing.
+ # Recursive helper method to collect errors but keep processing.
def copy_tree(src, dst, ignore, errors):
names = os.listdir(src)
if ignore is not None:
diff --git a/tools/diff_results.dart b/tools/diff_results.dart
index 3c2331a..764e366 100644
--- a/tools/diff_results.dart
+++ b/tools/diff_results.dart
@@ -352,12 +352,12 @@
List<String> extractBuilderPattern(List<String> builders) {
final all = Set<String>.from(builders);
- String reduce(String builder, List<String> posibilities) {
- for (final pos in posibilities) {
+ String reduce(String builder, List<String> possibilities) {
+ for (final pos in possibilities) {
if (builder.contains(pos)) {
final existing = <String>[];
final available = <String>[];
- for (final pos2 in posibilities) {
+ for (final pos2 in possibilities) {
final builder2 = builder.replaceFirst(pos, pos2);
if (all.contains(builder2)) {
existing.add(builder2);
diff --git a/tools/dom/docs.json b/tools/dom/docs.json
index e7730fc..d5602a6 100644
--- a/tools/dom/docs.json
+++ b/tools/dom/docs.json
@@ -5187,7 +5187,7 @@
" * Get a Stream that fires events when AudioProcessingEvents occur.",
" * This particular stream is special in that it only allows one listener to a",
" * given stream. Converting the returned [Stream.asBroadcastStream] will",
- " * likely ruin the soft-real-time properties which which these events are",
+ " * likely ruin the soft-real-time properties which these events are",
" * fired and can be processed.",
" */"
]
diff --git a/tools/dom/scripts/css_code_generator.py b/tools/dom/scripts/css_code_generator.py
index 16cf73b..3726fe5 100644
--- a/tools/dom/scripts/css_code_generator.py
+++ b/tools/dom/scripts/css_code_generator.py
@@ -272,7 +272,7 @@
// Important note: CssStyleDeclarationSet does NOT implement every method
// available in CssStyleDeclaration. Some of the methods don't make so much
- // sense in terms of having a resonable value to return when you're
+ // sense in terms of having a reasonable value to return when you're
// considering a list of Elements. You will need to manually add any of the
// items in the MEMBERS set if you want that functionality.
}
diff --git a/tools/dom/scripts/emitter.py b/tools/dom/scripts/emitter.py
index 55e3313..06b5eaf 100755
--- a/tools/dom/scripts/emitter.py
+++ b/tools/dom/scripts/emitter.py
@@ -26,7 +26,7 @@
self._bindings = bindings or Emitter.Frame({}, None)
def EmitRaw(self, item):
- """Emits literal string with no substitition."""
+ """Emits literal string with no substitution."""
self._items.append(item)
def Emit(self, template_source, **parameters):
@@ -250,7 +250,7 @@
"""A lookup operation that is deferred until final string generation."""
# TODO(sra): A deferred lookup will be useful when we add expansions that
- # have behaviour condtional on the contents, e.g. adding separators between
+ # have behaviour conditional on the contents, e.g. adding separators between
# a list of items.
def __init__(self, lookup, environment):
self._lookup = lookup
diff --git a/tools/dom/templates/html/impl/impl_CSSStyleDeclaration.darttemplate b/tools/dom/templates/html/impl/impl_CSSStyleDeclaration.darttemplate
index 10ea0fc..1c1266c 100644
--- a/tools/dom/templates/html/impl/impl_CSSStyleDeclaration.darttemplate
+++ b/tools/dom/templates/html/impl/impl_CSSStyleDeclaration.darttemplate
@@ -1850,7 +1850,7 @@
// Important note: CssStyleDeclarationSet does NOT implement every method
// available in CssStyleDeclaration. Some of the methods don't make so much
- // sense in terms of having a resonable value to return when you're
+ // sense in terms of having a reasonable value to return when you're
// considering a list of Elements. You will need to manually add any of the
// items in the MEMBERS set if you want that functionality.
}
diff --git a/tools/dom/templates/html/impl/impl_IDBTransaction.darttemplate b/tools/dom/templates/html/impl/impl_IDBTransaction.darttemplate
index 4eb6bec..67fcc25 100644
--- a/tools/dom/templates/html/impl/impl_IDBTransaction.darttemplate
+++ b/tools/dom/templates/html/impl/impl_IDBTransaction.darttemplate
@@ -10,7 +10,7 @@
* Provides a Future which will be completed once the transaction has
* completed.
*
- * The future will error if an error occurrs on the transaction or if the
+ * The future will error if an error occurs on the transaction or if the
* transaction is aborted.
*/
Future<Database> get completed {
diff --git a/tools/patches/flutter-engine/create.sh b/tools/patches/flutter-engine/create.sh
index 15dad92..1197f63 100755
--- a/tools/patches/flutter-engine/create.sh
+++ b/tools/patches/flutter-engine/create.sh
@@ -8,7 +8,7 @@
# changes in the current engine checkout. It is named after the Dart SDK
# revision the engine is currently pinned to. It's meant to be consumed by the
# apply.sh script next to this script. Any existing patches are removed, as they
-# are assumed to not be relevant anymore. If there are no uncommited changes in
+# are assumed to not be relevant anymore. If there are no uncommitted changes in
# the local engine checkout, then no patch is produced.
#
# Usage: src/third_party/dart/tools/patches/flutter-engine/create.sh
diff --git a/tools/promote.py b/tools/promote.py
index 4d32d19..6dce07c 100755
--- a/tools/promote.py
+++ b/tools/promote.py
@@ -185,7 +185,7 @@
gsutilTool = join(DART_PATH, 'third_party', 'gsutil', 'gsutil')
command = [sys.executable, gsutilTool] + cmd
if DRY_RUN:
- print('DRY runnning: %s' % command)
+ print('DRY running: %s' % command)
return (None, None, 0)
return bot_utils.run(command, throw_on_error=throw_on_error)