mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 10:33:28 +00:00
[analyzer] add failing test case
Bug #50496 Change-Id: Iaa6007af1b9dbbf7bac3f2ad835dece3eb64b189 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/271520 Commit-Queue: Brian Wilkerson <brianwilkerson@google.com> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
parent
4b4b3645b8
commit
bea7045517
|
@ -3,7 +3,6 @@
|
|||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:collection';
|
||||
import 'dart:io' as io;
|
||||
import 'dart:math' show max;
|
||||
|
||||
|
@ -261,7 +260,7 @@ class LegacyAnalysisServer extends AnalysisServer {
|
|||
bool statusAnalyzing = false;
|
||||
|
||||
/// A set of the [ServerService]s to send notifications for.
|
||||
Set<ServerService> serverServices = HashSet<ServerService>();
|
||||
Set<ServerService> serverServices = {};
|
||||
|
||||
/// A table mapping request ids to cancellation tokens that allow cancelling
|
||||
/// the request.
|
||||
|
@ -271,13 +270,11 @@ class LegacyAnalysisServer extends AnalysisServer {
|
|||
Map<String, CancelableToken> cancellationTokens = {};
|
||||
|
||||
/// A set of the [GeneralAnalysisService]s to send notifications for.
|
||||
Set<GeneralAnalysisService> generalAnalysisServices =
|
||||
HashSet<GeneralAnalysisService>();
|
||||
Set<GeneralAnalysisService> generalAnalysisServices = {};
|
||||
|
||||
/// A table mapping [AnalysisService]s to the file paths for which these
|
||||
/// notifications should be sent.
|
||||
Map<AnalysisService, Set<String>> analysisServices =
|
||||
HashMap<AnalysisService, Set<String>>();
|
||||
Map<AnalysisService, Set<String>> analysisServices = {};
|
||||
|
||||
/// A table mapping [FlutterService]s to the file paths for which these
|
||||
/// notifications should be sent.
|
||||
|
|
|
@ -41,7 +41,7 @@ class AnalysisServerTest with ResourceProviderMixin {
|
|||
|
||||
/// Test that having multiple analysis contexts analyze the same file doesn't
|
||||
/// cause that file to receive duplicate notifications when it's modified.
|
||||
Future do_not_test_no_duplicate_notifications() async {
|
||||
Future<void> do_not_test_no_duplicate_notifications() async {
|
||||
// Subscribe to STATUS so we'll know when analysis is done.
|
||||
server.serverServices = {ServerService.STATUS};
|
||||
newFolder('/foo');
|
||||
|
@ -51,7 +51,7 @@ class AnalysisServerTest with ResourceProviderMixin {
|
|||
await server.setAnalysisRoots('0', ['/foo', '/bar'], []);
|
||||
var subscriptions = <AnalysisService, Set<String>>{};
|
||||
for (var service in AnalysisService.VALUES) {
|
||||
subscriptions[service] = <String>{bar.path};
|
||||
subscriptions[service] = {bar.path};
|
||||
}
|
||||
// The following line causes the isolate to continue running even though the
|
||||
// test completes.
|
||||
|
@ -105,11 +105,76 @@ class AnalysisServerTest with ResourceProviderMixin {
|
|||
InstrumentationService.NULL_SERVICE);
|
||||
}
|
||||
|
||||
@FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/50496')
|
||||
Future<void> test_cache() async {
|
||||
var lib = convertPath('/lib');
|
||||
newFolder(lib);
|
||||
var foo = newFile('/lib/foo.dart', '''
|
||||
abstract class A {
|
||||
set foo(_);
|
||||
}
|
||||
mixin M on A {
|
||||
void bar() {
|
||||
super.foo = 0;
|
||||
}
|
||||
}
|
||||
abstract class X extends A with M {}
|
||||
''');
|
||||
await server.setAnalysisRoots('0', [lib], []);
|
||||
await server.onAnalysisComplete;
|
||||
expect(server.statusAnalyzing, isFalse);
|
||||
channel.notificationsReceived.clear();
|
||||
|
||||
server.updateContent('0', {
|
||||
foo.path: AddContentOverlay('''
|
||||
abstract class A {
|
||||
set boo(_);
|
||||
}
|
||||
mixin M on A {
|
||||
void bar() {
|
||||
super.foo = 0;
|
||||
}
|
||||
}
|
||||
abstract class X extends A with M {}
|
||||
''')
|
||||
});
|
||||
await server.onAnalysisComplete;
|
||||
expect(server.statusAnalyzing, isFalse);
|
||||
channel.notificationsReceived.clear();
|
||||
|
||||
server.updateContent('0', {
|
||||
foo.path: AddContentOverlay('''
|
||||
abstract class A {
|
||||
set boo(_);
|
||||
}
|
||||
mixin M on A {
|
||||
void bar() {
|
||||
super.boo = 0;
|
||||
}
|
||||
}
|
||||
abstract class X extends A with M {}
|
||||
''')
|
||||
});
|
||||
await server.onAnalysisComplete;
|
||||
expect(server.statusAnalyzing, isFalse);
|
||||
var notifications = channel.notificationsReceived;
|
||||
expect(notifications, hasLength(1));
|
||||
var notification = notifications.first;
|
||||
expect(notification.event, 'analysis.errors');
|
||||
var params = notification.params;
|
||||
expect(params, isNotNull);
|
||||
var errors = params!['errors'] as List<Map<String, dynamic>>;
|
||||
expect(errors, hasLength(1));
|
||||
var error = errors.first;
|
||||
var message = error['message'];
|
||||
expect(message, contains("boo"));
|
||||
}
|
||||
|
||||
/// Test that modifying package_config again while a context rebuild is in
|
||||
/// progress does not get lost due to a gap between creating a file watcher
|
||||
/// and it raising events.
|
||||
/// https://github.com/Dart-Code/Dart-Code/issues/3438
|
||||
Future test_concurrentContextRebuilds() async {
|
||||
Future<void> test_concurrentContextRebuilds() async {
|
||||
// Subscribe to STATUS so we'll know when analysis is done.
|
||||
server.serverServices = {ServerService.STATUS};
|
||||
final projectRoot = convertPath('/foo');
|
||||
|
@ -172,7 +237,7 @@ class AnalysisServerTest with ResourceProviderMixin {
|
|||
expect(await getUriNotExistErrors(), hasLength(0));
|
||||
}
|
||||
|
||||
Future test_serverStatusNotifications_hasFile() async {
|
||||
Future<void> test_serverStatusNotifications_hasFile() async {
|
||||
server.serverServices.add(ServerService.STATUS);
|
||||
|
||||
newFile('/test/lib/a.dart', r'''
|
||||
|
@ -204,7 +269,7 @@ class A {}
|
|||
expect(params.analysis!.isAnalyzing, isFalse);
|
||||
}
|
||||
|
||||
Future test_serverStatusNotifications_noFiles() async {
|
||||
Future<void> test_serverStatusNotifications_noFiles() async {
|
||||
server.serverServices.add(ServerService.STATUS);
|
||||
|
||||
newFolder('/test');
|
||||
|
@ -276,7 +341,7 @@ analyzer:
|
|||
}), isTrue);
|
||||
}
|
||||
|
||||
Future test_shutdown() {
|
||||
Future<void> test_shutdown() {
|
||||
var request = Request('my28', SERVER_REQUEST_SHUTDOWN);
|
||||
return channel.sendRequest(request).then((Response response) {
|
||||
expect(response.id, equals('my28'));
|
||||
|
@ -284,7 +349,7 @@ analyzer:
|
|||
});
|
||||
}
|
||||
|
||||
Future test_unknownRequest() {
|
||||
Future<void> test_unknownRequest() {
|
||||
var request = Request('my22', 'randomRequest');
|
||||
return channel.sendRequest(request).then((Response response) {
|
||||
expect(response.id, equals('my22'));
|
||||
|
|
|
@ -250,7 +250,7 @@ class RecordingErrorListener implements AnalysisErrorListener {
|
|||
/// Return the errors collected by the listener.
|
||||
List<AnalysisError> get errors {
|
||||
if (_errors == null) {
|
||||
return const <AnalysisError>[];
|
||||
return const [];
|
||||
}
|
||||
return _errors!.toList();
|
||||
}
|
||||
|
@ -258,7 +258,7 @@ class RecordingErrorListener implements AnalysisErrorListener {
|
|||
/// Return the errors collected by the listener for the given [source].
|
||||
List<AnalysisError> getErrorsForSource(Source source) {
|
||||
if (_errors == null) {
|
||||
return const <AnalysisError>[];
|
||||
return const [];
|
||||
}
|
||||
return _errors!.where((error) => error.source == source).toList();
|
||||
}
|
||||
|
|
|
@ -674,9 +674,7 @@ class AnalysisDriver implements AnalysisDriverGeneric {
|
|||
}
|
||||
|
||||
var completer = Completer<SomeErrorsResult>();
|
||||
_errorsRequestedFiles
|
||||
.putIfAbsent(path, () => <Completer<SomeErrorsResult>>[])
|
||||
.add(completer);
|
||||
_errorsRequestedFiles.putIfAbsent(path, () => []).add(completer);
|
||||
_scheduler.notify(this);
|
||||
return completer.future;
|
||||
}
|
||||
|
@ -733,9 +731,7 @@ class AnalysisDriver implements AnalysisDriverGeneric {
|
|||
return Future.value();
|
||||
}
|
||||
var completer = Completer<AnalysisDriverUnitIndex?>();
|
||||
_indexRequestedFiles
|
||||
.putIfAbsent(path, () => <Completer<AnalysisDriverUnitIndex?>>[])
|
||||
.add(completer);
|
||||
_indexRequestedFiles.putIfAbsent(path, () => []).add(completer);
|
||||
_scheduler.notify(this);
|
||||
return completer.future;
|
||||
}
|
||||
|
@ -874,9 +870,7 @@ class AnalysisDriver implements AnalysisDriverGeneric {
|
|||
final kind = file.kind;
|
||||
if (kind is LibraryFileKind) {
|
||||
final completer = Completer<SomeResolvedLibraryResult>();
|
||||
_requestedLibraries
|
||||
.putIfAbsent(kind, () => <Completer<SomeResolvedLibraryResult>>[])
|
||||
.add(completer);
|
||||
_requestedLibraries.putIfAbsent(kind, () => []).add(completer);
|
||||
_scheduler.notify(this);
|
||||
return completer.future;
|
||||
} else if (kind is AugmentationFileKind) {
|
||||
|
@ -963,9 +957,7 @@ class AnalysisDriver implements AnalysisDriverGeneric {
|
|||
|
||||
// Schedule analysis.
|
||||
var completer = Completer<SomeResolvedUnitResult>();
|
||||
_requestedFiles
|
||||
.putIfAbsent(path, () => <Completer<SomeResolvedUnitResult>>[])
|
||||
.add(completer);
|
||||
_requestedFiles.putIfAbsent(path, () => []).add(completer);
|
||||
_scheduler.notify(this);
|
||||
return completer.future;
|
||||
}
|
||||
|
@ -992,9 +984,7 @@ class AnalysisDriver implements AnalysisDriverGeneric {
|
|||
}
|
||||
|
||||
var completer = Completer<SomeUnitElementResult>();
|
||||
_unitElementRequestedFiles
|
||||
.putIfAbsent(path, () => <Completer<SomeUnitElementResult>>[])
|
||||
.add(completer);
|
||||
_unitElementRequestedFiles.putIfAbsent(path, () => []).add(completer);
|
||||
_scheduler.notify(this);
|
||||
return completer.future;
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ class LibraryAnalyzer {
|
|||
// Return full results.
|
||||
var results = <UnitAnalysisResult>[];
|
||||
units.forEach((file, unit) {
|
||||
List<AnalysisError> errors = _getErrorListener(file).errors;
|
||||
var errors = _getErrorListener(file).errors;
|
||||
errors = _filterIgnoredErrors(file, errors);
|
||||
results.add(UnitAnalysisResult(file, unit, errors));
|
||||
});
|
||||
|
@ -269,8 +269,7 @@ class LibraryAnalyzer {
|
|||
usedImportedElements.add(visitor.usedElements);
|
||||
}
|
||||
}
|
||||
UsedLocalElements usedElements =
|
||||
UsedLocalElements.merge(usedLocalElements);
|
||||
var usedElements = UsedLocalElements.merge(usedLocalElements);
|
||||
units.forEach((file, unit) {
|
||||
_computeHints(
|
||||
file,
|
||||
|
@ -726,7 +725,7 @@ class LibraryAnalyzer {
|
|||
|
||||
void _resolveFile(FileState file, CompilationUnit unit) {
|
||||
var source = file.source;
|
||||
RecordingErrorListener errorListener = _getErrorListener(file);
|
||||
var errorListener = _getErrorListener(file);
|
||||
|
||||
var unitElement = unit.declaredElement as CompilationUnitElementImpl;
|
||||
|
||||
|
|
|
@ -16,54 +16,6 @@ main() {
|
|||
@reflectiveTest
|
||||
class MixinApplicationNoConcreteSuperInvokedMemberTest
|
||||
extends PubPackageResolutionTest {
|
||||
@FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/50496')
|
||||
test_cache() async {
|
||||
addTestFile('''
|
||||
abstract class A {
|
||||
set foo(_);
|
||||
}
|
||||
mixin M on A {
|
||||
void bar() {
|
||||
super.foo = 0;
|
||||
}
|
||||
}
|
||||
abstract class X extends A with M {}
|
||||
''');
|
||||
await resolveTestFile();
|
||||
|
||||
assertErrorsInResolvedUnit(result, [
|
||||
error(
|
||||
CompileTimeErrorCode
|
||||
.MIXIN_APPLICATION_NO_CONCRETE_SUPER_INVOKED_MEMBER,
|
||||
122,
|
||||
1,
|
||||
messageContains: ["foo"]),
|
||||
]);
|
||||
|
||||
modifyFile(testFile.path, '''
|
||||
abstract class A {
|
||||
set boo(_);
|
||||
}
|
||||
mixin M on A {
|
||||
void bar() {
|
||||
super.boo = 0;
|
||||
}
|
||||
}
|
||||
abstract class X extends A with M {}
|
||||
''');
|
||||
|
||||
await resolveTestFile();
|
||||
|
||||
assertErrorsInResolvedUnit(result, [
|
||||
error(
|
||||
CompileTimeErrorCode
|
||||
.MIXIN_APPLICATION_NO_CONCRETE_SUPER_INVOKED_MEMBER,
|
||||
122,
|
||||
1,
|
||||
messageContains: ["boo"]),
|
||||
]);
|
||||
}
|
||||
|
||||
test_class_getter() async {
|
||||
await assertErrorsInCode(r'''
|
||||
abstract class A {
|
||||
|
|
Loading…
Reference in a new issue