Version 2.17.0-34.0.dev
Merge commit '0c2079561b794822b507fd2494417824f84f032c' into 'dev'
diff --git a/pkg/analyzer/lib/src/diagnostic/diagnostic_factory.dart b/pkg/analyzer/lib/src/diagnostic/diagnostic_factory.dart
index 11ad6a2..6681a49 100644
--- a/pkg/analyzer/lib/src/diagnostic/diagnostic_factory.dart
+++ b/pkg/analyzer/lib/src/diagnostic/diagnostic_factory.dart
@@ -69,6 +69,41 @@
]);
}
+ /// Return a diagnostic indicating that [member] is not a correct override of
+ /// [superMember].
+ AnalysisError invalidOverride(
+ Source source,
+ ErrorCode? errorCode,
+ AstNode errorNode,
+ ExecutableElement member,
+ ExecutableElement superMember) {
+ errorCode ??= CompileTimeErrorCode.INVALID_OVERRIDE;
+ // Elements enclosing members that can participate in overrides are always
+ // named, so we can safely assume `_thisMember.enclosingElement.name` and
+ // `superMember.enclosingElement.name` are non-`null`.
+ return AnalysisError(
+ source, errorNode.offset, errorNode.length, errorCode, [
+ member.name,
+ member.enclosingElement.name!,
+ member.type,
+ superMember.enclosingElement.name!,
+ superMember.type,
+ ], [
+ // Only include the context location for INVALID_OVERRIDE because for
+ // some other types this location is not ideal (for example
+ // INVALID_IMPLEMENTATION_OVERRIDE may provide the subclass as superMember
+ // if the subclass has an abstract member and the superclass has the
+ // concrete).
+ if (errorCode == CompileTimeErrorCode.INVALID_OVERRIDE)
+ DiagnosticMessageImpl(
+ filePath: superMember.source.fullName,
+ message: "The member being overridden.",
+ offset: superMember.nonSynthetic.nameOffset,
+ length: superMember.nonSynthetic.nameLength,
+ url: null)
+ ]);
+ }
+
/// Return a diagnostic indicating that the given [identifier] was referenced
/// before it was declared.
AnalysisError referencedBeforeDeclaration(
diff --git a/pkg/analyzer/lib/src/error/correct_override.dart b/pkg/analyzer/lib/src/error/correct_override.dart
index 1066a3c..2169256 100644
--- a/pkg/analyzer/lib/src/error/correct_override.dart
+++ b/pkg/analyzer/lib/src/error/correct_override.dart
@@ -14,6 +14,7 @@
import 'package:analyzer/src/dart/element/type.dart';
import 'package:analyzer/src/dart/element/type_algebra.dart';
import 'package:analyzer/src/dart/element/type_system.dart';
+import 'package:analyzer/src/diagnostic/diagnostic_factory.dart';
import 'package:analyzer/src/error/codes.dart';
class CorrectOverrideHelper {
@@ -23,6 +24,8 @@
final ExecutableElement _thisMember;
FunctionType? _thisTypeForSubtype;
+ final DiagnosticFactory _diagnosticFactory = DiagnosticFactory();
+
CorrectOverrideHelper({
required LibraryElementImpl library,
required ExecutableElement thisMember,
@@ -52,20 +55,12 @@
}) {
var isCorrect = isCorrectOverrideOf(superMember: superMember);
if (!isCorrect) {
- // Elements enclosing members that can participate in overrides are always
- // named, so we can safely assume `_thisMember.enclosingElement.name` and
- // `superMember.enclosingElement.name` are non-`null`.
- errorReporter.reportErrorForNode(
- errorCode ?? CompileTimeErrorCode.INVALID_OVERRIDE,
- errorNode,
- [
- _thisMember.name,
- _thisMember.enclosingElement.name!,
- _thisMember.type,
- superMember.enclosingElement.name!,
- superMember.type,
- ],
- );
+ errorReporter.reportError(_diagnosticFactory.invalidOverride(
+ errorReporter.source,
+ errorCode,
+ errorNode,
+ _thisMember,
+ superMember));
}
}
diff --git a/pkg/analyzer/lib/src/lint/linter_visitor.dart b/pkg/analyzer/lib/src/lint/linter_visitor.dart
index 692f0c7..b08cc00 100644
--- a/pkg/analyzer/lib/src/lint/linter_visitor.dart
+++ b/pkg/analyzer/lib/src/lint/linter_visitor.dart
@@ -653,6 +653,12 @@
}
@override
+ void visitSuperFormalParameter(SuperFormalParameter node) {
+ _runSubscriptions(node, registry._forSuperFormalParameter);
+ super.visitSuperFormalParameter(node);
+ }
+
+ @override
void visitSwitchCase(SwitchCase node) {
_runSubscriptions(node, registry._forSwitchCase);
super.visitSwitchCase(node);
@@ -897,6 +903,7 @@
final List<_Subscription<SuperConstructorInvocation>>
_forSuperConstructorInvocation = [];
final List<_Subscription<SuperExpression>> _forSuperExpression = [];
+ final List<_Subscription<SuperFormalParameter>> _forSuperFormalParameter = [];
final List<_Subscription<SwitchCase>> _forSwitchCase = [];
final List<_Subscription<SwitchDefault>> _forSwitchDefault = [];
final List<_Subscription<SwitchStatement>> _forSwitchStatement = [];
@@ -1386,6 +1393,11 @@
_forSuperExpression.add(_Subscription(linter, visitor, _getTimer(linter)));
}
+ void addSuperFormalParameter(LintRule linter, AstVisitor visitor) {
+ _forSuperFormalParameter
+ .add(_Subscription(linter, visitor, _getTimer(linter)));
+ }
+
void addSwitchCase(LintRule linter, AstVisitor visitor) {
_forSwitchCase.add(_Subscription(linter, visitor, _getTimer(linter)));
}
diff --git a/pkg/analyzer/test/generated/strong_mode_test.dart b/pkg/analyzer/test/generated/strong_mode_test.dart
index e23271d..4cde594 100644
--- a/pkg/analyzer/test/generated/strong_mode_test.dart
+++ b/pkg/analyzer/test/generated/strong_mode_test.dart
@@ -3269,7 +3269,8 @@
class D extends C {
T f<T extends B>(T x) => null;
}''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 101, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 101, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 46, 1)]),
]);
}
@@ -3283,7 +3284,8 @@
class D extends C {
T f<T extends A>(T x) => null;
}''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 101, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 101, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 46, 1)]),
]);
}
@@ -3295,7 +3297,8 @@
class D extends C {
String f<S>(S x) => null;
}''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 74, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 74, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 24, 1)]),
]);
}
@@ -3307,7 +3310,8 @@
class D extends C {
S f<T, S>(T x) => null;
}''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 59, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 59, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 14, 1)]),
]);
}
diff --git a/pkg/analyzer/test/src/diagnostics/invalid_implementation_override_test.dart b/pkg/analyzer/test/src/diagnostics/invalid_implementation_override_test.dart
index a4d4a40..5985dde 100644
--- a/pkg/analyzer/test/src/diagnostics/invalid_implementation_override_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/invalid_implementation_override_test.dart
@@ -51,7 +51,8 @@
}
''', [
error(CompileTimeErrorCode.INVALID_IMPLEMENTATION_OVERRIDE, 52, 1),
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 72, 3),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 72, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 16, 3)]),
]);
}
@@ -102,7 +103,8 @@
}
''', [
error(CompileTimeErrorCode.INVALID_IMPLEMENTATION_OVERRIDE, 52, 1),
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 69, 3),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 69, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 16, 3)]),
]);
}
@@ -117,7 +119,8 @@
class B extends A with M {}
''', [
error(CompileTimeErrorCode.INVALID_IMPLEMENTATION_OVERRIDE, 77, 1),
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 94, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 94, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 16, 3)]),
]);
}
diff --git a/pkg/analyzer/test/src/diagnostics/invalid_override_test.dart b/pkg/analyzer/test/src/diagnostics/invalid_override_test.dart
index 7d7ecd5..2b5c527 100644
--- a/pkg/analyzer/test/src/diagnostics/invalid_override_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/invalid_override_test.dart
@@ -26,7 +26,8 @@
String get g { return 'a'; }
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 71, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 71, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 20, 1)]),
]);
}
@@ -39,8 +40,10 @@
int f;
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 50, 1),
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 50, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 50, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 19, 1)]),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 50, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 19, 1)]),
]);
}
@@ -58,7 +61,8 @@
String get getter => null;
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 163, 6),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 163, 6,
+ contextMessages: [message('/home/test/lib/test.dart', 29, 6)]),
]);
}
@@ -74,8 +78,10 @@
double get g => null;
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 138, 1),
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 138, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 138, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 73, 1)]),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 138, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 30, 1)]),
]);
}
@@ -89,7 +95,8 @@
}
''', [
error(CompileTimeErrorCode.INVALID_IMPLEMENTATION_OVERRIDE, 52, 1),
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 72, 3),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 72, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 16, 3)]),
]);
}
@@ -103,7 +110,8 @@
}
''', [
error(CompileTimeErrorCode.INVALID_IMPLEMENTATION_OVERRIDE, 52, 1),
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 69, 3),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 69, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 16, 3)]),
]);
}
@@ -118,7 +126,8 @@
class B extends A with M {}
''', [
error(CompileTimeErrorCode.INVALID_IMPLEMENTATION_OVERRIDE, 77, 1),
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 94, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 94, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 16, 3)]),
]);
}
@@ -177,7 +186,8 @@
m({a}) {}
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 49, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 49, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 12, 1)]),
]);
}
@@ -190,7 +200,8 @@
m({a, c}) {}
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 49, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 49, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 12, 1)]),
]);
}
@@ -203,7 +214,8 @@
m({String a}) {}
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 53, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 53, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 12, 1)]),
]);
}
@@ -216,7 +228,8 @@
m(String a) {}
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 51, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 51, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 12, 1)]),
]);
}
@@ -229,7 +242,8 @@
m(String a) {}
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 48, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 48, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 12, 1)]),
]);
}
@@ -245,8 +259,10 @@
void m(double d) {}
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 147, 1),
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 147, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 147, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 76, 1)]),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 147, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 29, 1)]),
]);
}
@@ -263,7 +279,8 @@
m(String n) {}
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 124, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 124, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 54, 1)]),
]);
}
@@ -280,8 +297,10 @@
void m(double d) {}
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 140, 1),
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 140, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 140, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 29, 1)]),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 140, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 76, 1)]),
]);
}
@@ -294,7 +313,8 @@
m([String a]) {}
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 53, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 53, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 12, 1)]),
]);
}
@@ -311,7 +331,8 @@
m([String n]) {}
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 128, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 128, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 56, 1)]),
]);
}
@@ -324,7 +345,8 @@
m([a]) {}
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 49, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 49, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 12, 1)]),
]);
}
@@ -337,7 +359,8 @@
m(a, b, [c]) {}
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 55, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 55, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 12, 1)]),
]);
}
@@ -350,7 +373,8 @@
m(a, [c, d]) {}
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 55, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 55, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 12, 1)]),
]);
}
@@ -363,7 +387,8 @@
m(a, b) {}
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 44, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 44, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 12, 1)]),
]);
}
@@ -376,7 +401,8 @@
String m() { return 'a'; }
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 68, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 68, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 16, 1)]),
]);
}
@@ -391,7 +417,8 @@
String m() { return 'a'; }
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 98, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 98, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 25, 1)]),
]);
}
@@ -404,7 +431,8 @@
String m() { return 'a'; }
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 77, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 77, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 16, 1)]),
]);
}
@@ -417,7 +445,8 @@
String m() { return 'a'; }
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 65, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 65, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 16, 1)]),
]);
}
@@ -432,7 +461,8 @@
String m() { return 'a'; }
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 87, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 87, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 16, 1)]),
]);
}
@@ -449,7 +479,8 @@
String m() => '';
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 129, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 129, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 25, 1)]),
]);
}
@@ -462,7 +493,8 @@
void m() {}
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 63, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 63, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 16, 1)]),
]);
}
@@ -476,8 +508,10 @@
int foo = 0;
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 53, 3),
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 53, 3),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 53, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 19, 3)]),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 53, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 19, 3)]),
]);
}
@@ -491,7 +525,8 @@
int get foo => 0;
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 62, 3),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 62, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 23, 3)]),
]);
}
@@ -505,7 +540,8 @@
int foo() => 0;
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 56, 3),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 56, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 19, 3)]),
]);
}
@@ -519,7 +555,8 @@
set foo(int _) {}
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 57, 3),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 57, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 16, 3)]),
]);
}
@@ -532,7 +569,8 @@
void set s(String v) {}
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 66, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 66, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 21, 1)]),
]);
}
@@ -549,7 +587,8 @@
set setter14(String _) => null;
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 173, 8),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 173, 8,
+ contextMessages: [message('/home/test/lib/test.dart', 77, 8)]),
]);
}
@@ -567,7 +606,8 @@
set setter14(String _) => null;
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 166, 8),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 166, 8,
+ contextMessages: [message('/home/test/lib/test.dart', 77, 8)]),
]);
}
@@ -583,8 +623,10 @@
set s(double d) {}
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 125, 1),
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 125, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 125, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 28, 1)]),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 125, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 68, 1)]),
]);
}
}
@@ -631,7 +673,8 @@
void set x(num value);
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 91, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 91, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 44, 1)]),
]);
}
@@ -656,7 +699,8 @@
void set x(num value);
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 87, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 87, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 40, 1)]),
]);
}
@@ -681,7 +725,8 @@
void set x(num value);
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 81, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 81, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 34, 1)]),
]);
}
@@ -706,7 +751,8 @@
void set x(num value);
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 82, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 82, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 35, 1)]),
]);
}
@@ -731,7 +777,8 @@
void set x(num value);
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 78, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 78, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 31, 1)]),
]);
}
@@ -756,7 +803,8 @@
void set x(num value);
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 72, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 72, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 25, 1)]),
]);
}
@@ -906,7 +954,8 @@
void set x(int value);
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 95, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 95, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 34, 1)]),
]);
}
@@ -955,7 +1004,8 @@
void set x(int value);
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 86, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 86, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 25, 1)]),
]);
}
diff --git a/pkg/analyzer/test/src/diagnostics/override_on_non_overriding_field_test.dart b/pkg/analyzer/test/src/diagnostics/override_on_non_overriding_field_test.dart
index 2bae72c..21454e6 100644
--- a/pkg/analyzer/test/src/diagnostics/override_on_non_overriding_field_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/override_on_non_overriding_field_test.dart
@@ -30,7 +30,8 @@
@override
int c = 0;
}''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 134, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 134, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 39, 1)]),
]);
}
@@ -49,7 +50,8 @@
@override
int c = 0;
}''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 131, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 131, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 39, 1)]),
]);
}
diff --git a/pkg/analyzer/test/src/summary/top_level_inference_test.dart b/pkg/analyzer/test/src/summary/top_level_inference_test.dart
index f152265..f2133b0 100644
--- a/pkg/analyzer/test/src/summary/top_level_inference_test.dart
+++ b/pkg/analyzer/test/src/summary/top_level_inference_test.dart
@@ -318,8 +318,10 @@
var aaa;
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 109, 3),
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 109, 3),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 109, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 64, 3)]),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 109, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 25, 3)]),
]);
}
diff --git a/pkg/analyzer/test/src/task/strong/checker_test.dart b/pkg/analyzer/test/src/task/strong/checker_test.dart
index 5a33bcb..0b8f745 100644
--- a/pkg/analyzer/test/src/task/strong/checker_test.dart
+++ b/pkg/analyzer/test/src/task/strong/checker_test.dart
@@ -1639,7 +1639,8 @@
S foo() => null;
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 130, 3),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 130, 3,
+ contextMessages: [message('/home/test/lib/test.dart', 63, 3)]),
]);
}
@@ -1725,8 +1726,10 @@
dynamic get f4 => null;
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 162, 2),
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 226, 2),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 162, 2,
+ contextMessages: [message('/home/test/lib/test.dart', 84, 2)]),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 226, 2,
+ contextMessages: [message('/home/test/lib/test.dart', 120, 2)]),
]);
}
@@ -1749,8 +1752,10 @@
ToVoid<dynamic> get g => null;
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 143, 1),
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 231, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 143, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 62, 1)]),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 231, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 62, 1)]),
]);
}
@@ -2014,7 +2019,8 @@
int x;
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 95, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 95, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 46, 1)]),
]);
}
@@ -2036,8 +2042,10 @@
String x;
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 112, 1),
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 197, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 112, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 25, 1)]),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 197, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 25, 1)]),
]);
}
@@ -2079,10 +2087,12 @@
num x;
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 124, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 124, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 28, 1)]),
error(CompileTimeErrorCode.CONFLICTING_GENERIC_INTERFACES, 184, 1),
error(CompileTimeErrorCode.CONFLICTING_GENERIC_INTERFACES, 184, 1),
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 216, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 216, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 28, 1)]),
error(CompileTimeErrorCode.CONFLICTING_GENERIC_INTERFACES, 228, 1),
error(CompileTimeErrorCode.CONFLICTING_GENERIC_INTERFACES, 228, 1),
]);
@@ -2130,34 +2140,44 @@
}
''', [
error(CompileTimeErrorCode.GETTER_NOT_ASSIGNABLE_SETTER_TYPES, 80, 1),
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 80, 1),
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 124, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 80, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 42, 1)]),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 124, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 42, 1)]),
error(CompileTimeErrorCode.GETTER_NOT_ASSIGNABLE_SETTER_TYPES, 124, 1),
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 177, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 177, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 42, 1)]),
error(CompileTimeErrorCode.GETTER_NOT_ASSIGNABLE_SETTER_TYPES, 177, 1),
error(CompileTimeErrorCode.FINAL_NOT_INITIALIZED, 177, 1),
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 259, 1),
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 259, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 259, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 42, 1)]),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 259, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 42, 1)]),
error(
CompileTimeErrorCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE,
271,
2),
error(CompileTimeErrorCode.GETTER_NOT_ASSIGNABLE_SETTER_TYPES, 300, 1),
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 300, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 300, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 42, 1)]),
error(
CompileTimeErrorCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE,
320,
2),
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 347, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 347, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 42, 1)]),
error(CompileTimeErrorCode.GETTER_NOT_ASSIGNABLE_SETTER_TYPES, 347, 1),
error(
CompileTimeErrorCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE,
372,
2),
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 403, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 403, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 42, 1)]),
error(CompileTimeErrorCode.GETTER_NOT_ASSIGNABLE_SETTER_TYPES, 403, 1),
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 495, 1),
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 495, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 495, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 42, 1)]),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 495, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 42, 1)]),
]);
}
@@ -2174,7 +2194,8 @@
m(B a) {}
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 79, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 79, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 38, 1)]),
]);
}
@@ -2191,7 +2212,22 @@
m(B a) {}
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 81, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 81, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 44, 1)]),
+ ]);
+ }
+
+ test_invalidOverrides_contextMessage() async {
+ await assertErrorsInCode('''
+class A {
+ void method() {}
+}
+class B extends A {
+ void method(String a) {}
+}
+''', [
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 58, 6,
+ contextMessages: [message('/home/test/lib/test.dart', 17, 6)]),
]);
}
@@ -2213,7 +2249,8 @@
m(B a) {}
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 162, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 162, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 95, 1)]),
]);
}
@@ -2234,7 +2271,8 @@
m(B a) {}
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 95, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 95, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 45, 1)]),
]);
}
@@ -2256,7 +2294,8 @@
int x;
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 135, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 135, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 45, 1)]),
]);
}
@@ -2286,12 +2325,18 @@
class U2 = Base with M1, M2;
class U3 = Base with M2, M1;
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 144, 2),
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 177, 2),
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 218, 2),
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 246, 2),
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 271, 2),
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 304, 2),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 144, 2,
+ contextMessages: [message('/home/test/lib/test.dart', 40, 1)]),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 177, 2,
+ contextMessages: [message('/home/test/lib/test.dart', 40, 1)]),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 218, 2,
+ contextMessages: [message('/home/test/lib/test.dart', 40, 1)]),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 246, 2,
+ contextMessages: [message('/home/test/lib/test.dart', 40, 1)]),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 271, 2,
+ contextMessages: [message('/home/test/lib/test.dart', 40, 1)]),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 304, 2,
+ contextMessages: [message('/home/test/lib/test.dart', 40, 1)]),
]);
}
@@ -2317,8 +2362,10 @@
class U1 = Base with M1, M2;
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 148, 2),
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 180, 2),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 148, 2,
+ contextMessages: [message('/home/test/lib/test.dart', 54, 1)]),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 180, 2,
+ contextMessages: [message('/home/test/lib/test.dart', 54, 1)]),
]);
}
@@ -2492,10 +2539,14 @@
dynamic m6(dynamic value) => null;
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 227, 2),
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 252, 2),
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 277, 2),
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 354, 2),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 227, 2,
+ contextMessages: [message('/home/test/lib/test.dart', 71, 2)]),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 252, 2,
+ contextMessages: [message('/home/test/lib/test.dart', 92, 2)]),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 277, 2,
+ contextMessages: [message('/home/test/lib/test.dart', 113, 2)]),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 354, 2,
+ contextMessages: [message('/home/test/lib/test.dart', 176, 2)]),
]);
}
@@ -2522,8 +2573,10 @@
void g(dynamic x) {}
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 156, 1),
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 224, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 156, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 99, 1)]),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 224, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 99, 1)]),
]);
}
@@ -2576,8 +2629,10 @@
class U1 = Base with M;
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 146, 1),
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 173, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 146, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 45, 1)]),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 173, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 45, 1)]),
]);
}
@@ -2604,8 +2659,10 @@
CompileTimeErrorCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE,
62,
4),
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 137, 1),
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 164, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 137, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 45, 1)]),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 164, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 45, 1)]),
]);
}
@@ -2628,7 +2685,8 @@
m(B a) {}
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 145, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 145, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 92, 1)]),
]);
}
@@ -2690,7 +2748,8 @@
void n(A a);
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 121, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 121, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 59, 1)]),
]);
}
@@ -2720,7 +2779,8 @@
class E extends B implements A { }
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 78, 4),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 78, 4,
+ contextMessages: [message('/home/test/lib/test.dart', 24, 4)]),
error(CompileTimeErrorCode.INVALID_IMPLEMENTATION_OVERRIDE, 159, 1),
error(CompileTimeErrorCode.INVALID_IMPLEMENTATION_OVERRIDE, 189, 1),
]);
@@ -2933,10 +2993,14 @@
void set i(dynamic x) {}
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 220, 1),
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 255, 1),
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 362, 1),
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 397, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 220, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 85, 1)]),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 255, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 116, 1)]),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 362, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 85, 1)]),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 397, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 116, 1)]),
]);
}
@@ -2987,7 +3051,8 @@
set f5(B value) {}
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 263, 2),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 263, 2,
+ contextMessages: [message('/home/test/lib/test.dart', 111, 2)]),
]);
}
@@ -3048,7 +3113,8 @@
m(B a) {}
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 96, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 96, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 47, 1)]),
]);
}
@@ -3069,7 +3135,8 @@
m(B a) {}
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 85, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 85, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 45, 1)]),
]);
}
@@ -3430,7 +3497,8 @@
T method<T>(T x) => x;
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 227, 6),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 227, 6,
+ contextMessages: [message('/home/test/lib/test.dart', 176, 6)]),
]);
}
diff --git a/pkg/analyzer/test/src/task/strong/inferred_type_test.dart b/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
index 4840db6..279763f 100644
--- a/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
+++ b/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
@@ -423,8 +423,10 @@
get a => null;
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 246, 1),
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 246, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 246, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 150, 1)]),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 246, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 116, 1)]),
]);
}
@@ -709,7 +711,8 @@
int z = new B().x;
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 69, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 69, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 22, 1)]),
error(HintCode.UNUSED_LOCAL_VARIABLE, 97, 1),
error(HintCode.UNUSED_LOCAL_VARIABLE, 118, 1),
]);
@@ -2141,7 +2144,8 @@
print(y);
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 50, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 50, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 12, 1)]),
error(CompileTimeErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS_METHOD, 91, 5),
]);
}
@@ -2199,8 +2203,10 @@
print(y);
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 74, 1),
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 94, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 74, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 12, 1)]),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 94, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 33, 1)]),
error(HintCode.UNNECESSARY_CAST, 132, 12),
]);
}
@@ -3679,7 +3685,8 @@
int z = new B().x;
}
''', [
- error(CompileTimeErrorCode.INVALID_OVERRIDE, 78, 1),
+ error(CompileTimeErrorCode.INVALID_OVERRIDE, 78, 1,
+ contextMessages: [message('/home/test/lib/test.dart', 23, 1)]),
error(HintCode.UNUSED_LOCAL_VARIABLE, 106, 1),
error(HintCode.UNUSED_LOCAL_VARIABLE, 127, 1),
]);
diff --git a/pkg/dartdev/lib/src/commands/run.dart b/pkg/dartdev/lib/src/commands/run.dart
index 457f673..2ce7fbc 100644
--- a/pkg/dartdev/lib/src/commands/run.dart
+++ b/pkg/dartdev/lib/src/commands/run.dart
@@ -333,11 +333,16 @@
stderrSub.cancel();
completer.complete();
} else {
+ stderrSub.cancel();
final error = result['error'] ?? event;
final stacktrace = result['stacktrace'] ?? '';
- stderrSub.cancel();
- completer.completeError(
- 'Could not start Observatory HTTP server:\n$error\n$stacktrace\n');
+ String message = 'Could not start the VM service: ';
+ if (error.contains('Failed to create server socket')) {
+ message += '$host:$port is already in use.\n';
+ } else {
+ message += '$error\n$stacktrace\n';
+ }
+ completer.completeError(message);
}
});
try {
diff --git a/pkg/dartdev/test/smoke/smoke_test.dart b/pkg/dartdev/test/smoke/smoke_test.dart
index 7b1c688..38dd049 100644
--- a/pkg/dartdev/test/smoke/smoke_test.dart
+++ b/pkg/dartdev/test/smoke/smoke_test.dart
@@ -51,6 +51,24 @@
}
});
+ test('dart run --enable-vm-service smoke.dart with used port', () async {
+ final server = await HttpServer.bind(InternetAddress.anyIPv4, 0);
+ final result = await Process.run(
+ Platform.executable,
+ [
+ 'run',
+ '--enable-vm-service=${server.port}',
+ script,
+ ],
+ );
+ expect(
+ result.stderr,
+ 'Could not start Observatory HTTP server: localhost:${server.port} is already in use.\n',
+ );
+ expect(result.stdout, isEmpty);
+ server.close();
+ });
+
// This test verifies that an error isn't thrown when a valid experiment
// is passed.
// Experiments are lists here:
diff --git a/pkg/dds/lib/src/dap/utils.dart b/pkg/dds/lib/src/dap/utils.dart
index 8dcfbae..c455837 100644
--- a/pkg/dds/lib/src/dap/utils.dart
+++ b/pkg/dds/lib/src/dap/utils.dart
@@ -21,7 +21,7 @@
/// was necessarily a stack frame or that calling `toString` will return the
/// original input text.
stack.Frame? parseStackFrame(String line) {
- // Because we split on \r, on Windows there may be trailing \r which prevents
+ // Because we split on \n, on Windows there may be trailing \r which prevents
// package:stack_trace from parsing correctly.
line = line.trim();
diff --git a/pkg/dds/lib/src/dds_impl.dart b/pkg/dds/lib/src/dds_impl.dart
index 1d76900..000a15b 100644
--- a/pkg/dds/lib/src/dds_impl.dart
+++ b/pkg/dds/lib/src/dds_impl.dart
@@ -152,14 +152,30 @@
// Start the DDS server. Run in an error Zone to ensure that asynchronous
// exceptions encountered during request handling are handled, as exceptions
// thrown during request handling shouldn't take down the entire service.
- _server = await runZonedGuarded(
- () async => await io.serve(handler, host, port),
+ late String errorMessage;
+ final tmpServer = await runZonedGuarded(
+ () async {
+ try {
+ return await io.serve(handler, host, port);
+ } on SocketException catch (e) {
+ errorMessage = e.message;
+ if (e.osError != null) {
+ errorMessage += ' (${e.osError!.message})';
+ }
+ errorMessage += ': ${e.address?.host}:${e.port}';
+ return null;
+ }
+ },
(error, stack) {
if (shouldLogRequests) {
print('Asynchronous error: $error\n$stack');
}
},
- )!;
+ );
+ if (tmpServer == null) {
+ throw DartDevelopmentServiceException.connectionIssue(errorMessage);
+ }
+ _server = tmpServer;
final tmpUri = Uri(
scheme: 'http',
diff --git a/runtime/tests/vm/dart/finalizer/weak_reference_run_gc_test.dart b/runtime/tests/vm/dart/finalizer/weak_reference_run_gc_test.dart
new file mode 100644
index 0000000..74e128e
--- /dev/null
+++ b/runtime/tests/vm/dart/finalizer/weak_reference_run_gc_test.dart
@@ -0,0 +1,68 @@
+// Copyright (c) 2022, 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.
+//
+// SharedObjects=ffi_test_functions
+
+import 'dart:async';
+import 'dart:ffi';
+import 'dart:io';
+
+import 'package:expect/expect.dart';
+
+void main() {
+ testWeakReference();
+}
+
+class Nonce {
+ final int value;
+
+ Nonce(this.value);
+
+ String toString() => 'Nonce($value)';
+}
+
+void testWeakReference() async {
+ final weakRef = () {
+ final object = Nonce(23);
+ final weakRef = WeakReference(object);
+ // Left to right argument evaluation: evaluate weakRef.target first.
+ Expect.equals(weakRef.target, object);
+ return weakRef;
+ }();
+
+ print('do gc');
+ triggerGc();
+ await Future.delayed(Duration(milliseconds: 1));
+ triggerGc();
+ await Future.delayed(Duration(milliseconds: 1));
+ triggerGc();
+ await Future.delayed(Duration(milliseconds: 1));
+ triggerGc();
+
+ // The weak reference should not target anything anymore.
+ Expect.isNull(weakRef.target);
+
+ print('End of test, shutting down.');
+}
+
+final void Function() triggerGc = () {
+ String _platformPath(String name, {String? path}) {
+ if (path == null) path = "";
+ if (Platform.isLinux || Platform.isAndroid || Platform.isFuchsia)
+ return path + "lib" + name + ".so";
+ if (Platform.isMacOS) return path + "lib" + name + ".dylib";
+ if (Platform.isWindows) return path + name + ".dll";
+ throw Exception("Platform not implemented");
+ }
+
+ DynamicLibrary dlopenPlatformSpecific(String name, {String? path}) {
+ String fullPath = _platformPath(name, path: path);
+ return DynamicLibrary.open(fullPath);
+ }
+
+ final ffiTestFunctions = dlopenPlatformSpecific("ffi_test_functions");
+
+ return ffiTestFunctions
+ .lookupFunction<Void Function(), void Function()>("TriggerGC");
+}();
diff --git a/sdk/lib/_internal/vm/lib/expando_patch.dart b/sdk/lib/_internal/vm/lib/expando_patch.dart
index be89c3e..a8a4be4 100644
--- a/sdk/lib/_internal/vm/lib/expando_patch.dart
+++ b/sdk/lib/_internal/vm/lib/expando_patch.dart
@@ -171,10 +171,21 @@
class WeakReference<T extends Object> {
@patch
factory WeakReference(T object) {
- throw UnimplementedError("WeakReference");
+ final weakProperty = _WeakProperty()..key = object;
+ return _WeakReferenceImpl<T>(weakProperty);
}
}
+class _WeakReferenceImpl<T extends Object> implements WeakReference<T> {
+ // TODO(http://dartbug.com/48162): Implement _WeakReference in the VM
+ // instead of reusing WeakProperty.
+ final _WeakProperty _weakProperty;
+
+ _WeakReferenceImpl(this._weakProperty);
+
+ T? get target => _weakProperty.key as T?;
+}
+
@patch
class Finalizer<T> {
@patch
diff --git a/sdk/lib/core/weak.dart b/sdk/lib/core/weak.dart
index 17f5d31..01ef31c 100644
--- a/sdk/lib/core/weak.dart
+++ b/sdk/lib/core/weak.dart
@@ -58,7 +58,7 @@
///
/// A _weak_ reference to the [target] object which may be cleared
/// (set to reference `null` instead) at any time
-/// when there is no other ways for the program to access the target object.
+/// when there is no other way for the program to access the target object.
///
/// _Being the target of a weak reference does not keep an object
/// from being garbage collected._
diff --git a/tools/VERSION b/tools/VERSION
index e29da8b..9b534e9 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 17
PATCH 0
-PRERELEASE 33
+PRERELEASE 34
PRERELEASE_PATCH 0
\ No newline at end of file