Files
sdk/pkg/analysis_server/test/integration/analysis/error_test.dart
T
Kevin Millikin be30b62e3d Remove the Kernel type inference listener
We have decided to move to a different API for Fasta/Analyzer
integration, one that doesn't involve compiling to Kernel or observing
type inference.  The listener API will become broken, so let's just
remove it before that happens.

We lose the ability to trace type inference so let's restore that
ability next.  The analyzer's resolution storer is not used, but that
code has been left.  The resolution applier will no longer work
without the resolution storer, so those tests have been disabled.

Change-Id: If9ac5aba2d5de7788d8a65f7fa8410599e636d21
Reviewed-on: https://dart-review.googlesource.com/42400
Commit-Queue: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Peter von der Ahé <ahe@google.com>
2018-02-21 16:28:07 +00:00

123 lines
4.1 KiB
Dart

// Copyright (c) 2014, 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.
import 'package:analysis_server/protocol/protocol_generated.dart';
import 'package:analyzer_plugin/protocol/protocol_common.dart';
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
import '../support/integration_tests.dart';
main() {
defineReflectiveSuite(() {
defineReflectiveTests(AnalysisErrorIntegrationTest);
// TODO(scheglov): Restore similar test coverage when the front-end API
// allows it. See https://github.com/dart-lang/sdk/issues/32258.
// defineReflectiveTests(AnalysisErrorIntegrationTest_UseCFE);
});
}
@reflectiveTest
class AnalysisErrorIntegrationTest
extends AbstractAnalysisServerIntegrationTest {
test_detect_simple_error() {
String pathname = sourcePath('test.dart');
writeFile(pathname, '''
main() {
print(null) // parse error: missing ';'
}''');
standardAnalysisSetup();
return analysisFinished.then((_) {
expect(currentAnalysisErrors[pathname], isList);
List<AnalysisError> errors = currentAnalysisErrors[pathname];
expect(errors, hasLength(1));
expect(errors[0].location.file, equals(pathname));
});
}
test_super_mixins_disabled() async {
String pathname = sourcePath('test.dart');
writeFile(pathname, '''
class Test extends Object with C {
void foo() {}
}
abstract class B {
void foo() {}
}
abstract class C extends B {
void bar() {
super.foo();
}
}
''');
standardAnalysisSetup();
await analysisFinished;
expect(currentAnalysisErrors[pathname], isList);
List<AnalysisError> errors = currentAnalysisErrors[pathname];
expect(errors, hasLength(2));
Set<String> allErrorMessages =
errors.map((AnalysisError e) => e.message).toSet();
expect(
allErrorMessages,
contains(
"The class 'C' can't be used as a mixin because it extends a class other than Object."));
expect(
allErrorMessages,
contains(
"The class 'C' can't be used as a mixin because it references 'super'."));
}
@failingTest
test_super_mixins_enabled() async {
// We see errors here with the new driver (#28870).
// Expected: empty
// Actual: [
// AnalysisError:{"severity":"ERROR","type":"COMPILE_TIME_ERROR","location":{"file":"/var/folders/00/0w95r000h01000cxqpysvccm003j4q/T/analysisServerfbuOQb/test.dart","offset":31,"length":1,"startLine":1,"startColumn":32},"message":"The class 'C' can't be used as a mixin because it extends a class other than Object.","correction":"","code":"mixin_inherits_from_not_object","hasFix":false},
// AnalysisError:{"severity":"ERROR","type":"COMPILE_TIME_ERROR","location":{"file":"/var/folders/00/0w95r000h01000cxqpysvccm003j4q/T/analysisServerfbuOQb/test.dart","offset":31,"length":1,"startLine":1,"startColumn":32},"message":"The class 'C' can't be used as a mixin because it references 'super'.","correction":"","code":"mixin_references_super","hasFix":false}
// ]
String pathname = sourcePath('test.dart');
writeFile(pathname, '''
class Test extends Object with C {
void foo() {}
}
abstract class B {
void foo() {}
}
abstract class C extends B {
void bar() {
super.foo();
}
}
''');
// ignore: deprecated_member_use
await sendAnalysisUpdateOptions(
new AnalysisOptions()..enableSuperMixins = true);
standardAnalysisSetup();
await analysisFinished;
expect(currentAnalysisErrors[pathname], isList);
List<AnalysisError> errors = currentAnalysisErrors[pathname];
expect(errors, isEmpty);
}
}
@reflectiveTest
class AnalysisErrorIntegrationTest_UseCFE extends AnalysisErrorIntegrationTest {
@override
bool get useCFE => true;
@override
@failingTest
test_super_mixins_disabled() {
// Disabling super mixins is not supported in the new FE.
return super.test_super_mixins_disabled();
}
@override
test_super_mixins_enabled() {
// This does pass with the new FE.
return super.test_super_mixins_enabled();
}
}