| Index: pkg/analyzer/test/generated/resolver_test.dart
|
| diff --git a/pkg/analyzer/test/generated/resolver_test.dart b/pkg/analyzer/test/generated/resolver_test.dart
|
| index bddddeadce0d671bce103e09613dc4be2ecc7802..57e263617b92d40d7dd1377bb3ef26cf1491bd98 100644
|
| --- a/pkg/analyzer/test/generated/resolver_test.dart
|
| +++ b/pkg/analyzer/test/generated/resolver_test.dart
|
| @@ -3589,6 +3589,36 @@ m(num i) {
|
| verify([source]);
|
| }
|
|
|
| + void test_unnecessaryNoSuchMethod_blockBody() {
|
| + Source source = addSource(r'''
|
| +class A {
|
| + noSuchMethod(x) => super.noSuchMethod(x);
|
| +}
|
| +class B extends A {
|
| + mmm();
|
| + noSuchMethod(y) {
|
| + return super.noSuchMethod(y);
|
| + }
|
| +}''');
|
| + computeLibrarySourceErrors(source);
|
| + assertErrors(source, [HintCode.UNNECESSARY_NO_SUCH_METHOD]);
|
| + verify([source]);
|
| + }
|
| +
|
| + void test_unnecessaryNoSuchMethod_expressionBody() {
|
| + Source source = addSource(r'''
|
| +class A {
|
| + noSuchMethod(x) => super.noSuchMethod(x);
|
| +}
|
| +class B extends A {
|
| + mmm();
|
| + noSuchMethod(y) => super.noSuchMethod(y);
|
| +}''');
|
| + computeLibrarySourceErrors(source);
|
| + assertErrors(source, [HintCode.UNNECESSARY_NO_SUCH_METHOD]);
|
| + verify([source]);
|
| + }
|
| +
|
| void test_unnecessaryTypeCheck_null_is_Null() {
|
| Source source = addSource("bool b = null is Null;");
|
| computeLibrarySourceErrors(source);
|
| @@ -7581,6 +7611,67 @@ m(v) {
|
| verify([source]);
|
| }
|
|
|
| + void test_unnecessaryNoSuchMethod_blockBody_notReturnStatement() {
|
| + Source source = addSource(r'''
|
| +class A {
|
| + noSuchMethod(x) => super.noSuchMethod(x);
|
| +}
|
| +class B extends A {
|
| + mmm();
|
| + noSuchMethod(y) {
|
| + print(y);
|
| + }
|
| +}''');
|
| + computeLibrarySourceErrors(source);
|
| + assertNoErrors(source);
|
| + verify([source]);
|
| + }
|
| +
|
| + void test_unnecessaryNoSuchMethod_blockBody_notSingleStatement() {
|
| + Source source = addSource(r'''
|
| +class A {
|
| + noSuchMethod(x) => super.noSuchMethod(x);
|
| +}
|
| +class B extends A {
|
| + mmm();
|
| + noSuchMethod(y) {
|
| + print(y);
|
| + return super.noSuchMethod(y);
|
| + }
|
| +}''');
|
| + computeLibrarySourceErrors(source);
|
| + assertNoErrors(source);
|
| + verify([source]);
|
| + }
|
| +
|
| + void test_unnecessaryNoSuchMethod_expressionBody_notNoSuchMethod() {
|
| + Source source = addSource(r'''
|
| +class A {
|
| + noSuchMethod(x) => super.noSuchMethod(x);
|
| +}
|
| +class B extends A {
|
| + mmm();
|
| + noSuchMethod(y) => super.hashCode;
|
| +}''');
|
| + computeLibrarySourceErrors(source);
|
| + assertNoErrors(source);
|
| + verify([source]);
|
| + }
|
| +
|
| + void test_unnecessaryNoSuchMethod_expressionBody_notSuper() {
|
| + Source source = addSource(r'''
|
| +class A {
|
| + noSuchMethod(x) => super.noSuchMethod(x);
|
| +}
|
| +class B extends A {
|
| + mmm();
|
| + noSuchMethod(y) => 42;
|
| +}''');
|
| + computeLibrarySourceErrors(source);
|
| + assertNoErrors(source);
|
| + verify([source]);
|
| + }
|
| +
|
| void test_unusedImport_annotationOnDirective() {
|
| Source source = addSource(r'''
|
| library L;
|
| @@ -13152,6 +13243,22 @@ main() {
|
| expect(declaration.initializer.propagatedType, isNull);
|
| }
|
|
|
| + void test_genericFunction() {
|
| + if (!AnalysisEngine.instance.useTaskModel) {
|
| + return;
|
| + }
|
| + _resolveTestUnit(r'/*=T*/ f/*<T>*/(/*=T*/ x) => null;');
|
| + SimpleIdentifier f = _findIdentifier('f');
|
| + FunctionElementImpl e = f.staticElement;
|
| + expect(e.typeParameters.toString(), '[T]');
|
| + expect(e.type.boundTypeParameters.toString(), '[T]');
|
| + expect(e.type.typeParameters.toString(), '[]');
|
| + expect(e.type.toString(), '<T>(T) → T');
|
| +
|
| + FunctionType ft = e.type.instantiate([typeProvider.stringType]);
|
| + expect(ft.toString(), '(String) → String');
|
| + }
|
| +
|
| void test_genericFunction_typedef() {
|
| String code = r'''
|
| typedef T F<T>(T x);
|
| @@ -13227,22 +13334,6 @@ class D<S> {
|
| }
|
| }
|
|
|
| - void test_genericFunction() {
|
| - if (!AnalysisEngine.instance.useTaskModel) {
|
| - return;
|
| - }
|
| - _resolveTestUnit(r'/*=T*/ f/*<T>*/(/*=T*/ x) => null;');
|
| - SimpleIdentifier f = _findIdentifier('f');
|
| - FunctionElementImpl e = f.staticElement;
|
| - expect(e.typeParameters.toString(), '[T]');
|
| - expect(e.type.boundTypeParameters.toString(), '[T]');
|
| - expect(e.type.typeParameters.toString(), '[]');
|
| - expect(e.type.toString(), '<T>(T) → T');
|
| -
|
| - FunctionType ft = e.type.instantiate([typeProvider.stringType]);
|
| - expect(ft.toString(), '(String) → String');
|
| - }
|
| -
|
| void test_genericMethod() {
|
| if (!AnalysisEngine.instance.useTaskModel) {
|
| return;
|
|
|