Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2599)

Unified Diff: pkg/analyzer/test/generated/resolver_test.dart

Issue 1506903005: Issue 24648. Report HintCode.UNNECESSARY_NO_SUCH_METHOD. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/generated/resolver.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « pkg/analyzer/lib/src/generated/resolver.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698