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

Side by Side Diff: pkg/analyzer/test/generated/hint_code_test.dart

Issue 2228233003: Remove false positive from override hint (issue 27046) (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 4 months 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library analyzer.test.generated.hint_code_test; 5 library analyzer.test.generated.hint_code_test;
6 6
7 import 'package:analyzer/src/generated/engine.dart'; 7 import 'package:analyzer/src/generated/engine.dart';
8 import 'package:analyzer/src/generated/error.dart'; 8 import 'package:analyzer/src/generated/error.dart';
9 import 'package:analyzer/src/generated/parser.dart'; 9 import 'package:analyzer/src/generated/parser.dart';
10 import 'package:analyzer/src/generated/source_io.dart'; 10 import 'package:analyzer/src/generated/source_io.dart';
(...skipping 13 matching lines...) Expand all
24 class HintCodeTest extends ResolverTestCase { 24 class HintCodeTest extends ResolverTestCase {
25 @override 25 @override
26 void reset() { 26 void reset() {
27 analysisContext2 = AnalysisContextFactory.contextWithCoreAndPackages({ 27 analysisContext2 = AnalysisContextFactory.contextWithCoreAndPackages({
28 'package:meta/meta.dart': r''' 28 'package:meta/meta.dart': r'''
29 library meta; 29 library meta;
30 30
31 const _Factory factory = const _Factory(); 31 const _Factory factory = const _Factory();
32 const _Literal literal = const _Literal(); 32 const _Literal literal = const _Literal();
33 const _MustCallSuper mustCallSuper = const _MustCallSuper(); 33 const _MustCallSuper mustCallSuper = const _MustCallSuper();
34 const _Override override = const _Override();
35 const _Protected protected = const _Protected(); 34 const _Protected protected = const _Protected();
36 const Required required = const Required(); 35 const Required required = const Required();
37 class Required { 36 class Required {
38 final String reason; 37 final String reason;
39 const Required([this.reason]); 38 const Required([this.reason]);
40 } 39 }
41 40
42 class _Factory { 41 class _Factory {
43 const _Factory(); 42 const _Factory();
44 } 43 }
45 class _Literal { 44 class _Literal {
46 const _Literal(); 45 const _Literal();
47 } 46 }
48 class _MustCallSuper { 47 class _MustCallSuper {
49 const _MustCallSuper(); 48 const _MustCallSuper();
50 } 49 }
51 class _Override {
52 const _Override();
53 }
54 class _Protected { 50 class _Protected {
55 const _Protected(); 51 const _Protected();
56 } 52 }
57 class _Required { 53 class _Required {
58 final String reason; 54 final String reason;
59 const _Required([this.reason])); 55 const _Required([this.reason]));
60 } 56 }
61 ''', 57 ''',
62 'package:js/js.dart': r''' 58 'package:js/js.dart': r'''
63 library js; 59 library js;
(...skipping 1984 matching lines...) Expand 10 before | Expand all | Expand 10 after
2048 class A { 2044 class A {
2049 bool operator ==(x) {} 2045 bool operator ==(x) {}
2050 }'''); 2046 }''');
2051 computeLibrarySourceErrors(source); 2047 computeLibrarySourceErrors(source);
2052 assertErrors(source, [HintCode.OVERRIDE_EQUALS_BUT_NOT_HASH_CODE]); 2048 assertErrors(source, [HintCode.OVERRIDE_EQUALS_BUT_NOT_HASH_CODE]);
2053 verify([source]); 2049 verify([source]);
2054 } 2050 }
2055 2051
2056 void test_overrideOnNonOverridingField_invalid() { 2052 void test_overrideOnNonOverridingField_invalid() {
2057 Source source = addSource(r''' 2053 Source source = addSource(r'''
2058 library dart.core;
2059 const override = null;
2060 class A { 2054 class A {
2061 } 2055 }
2062 class B extends A { 2056 class B extends A {
2063 @override 2057 @override
2064 final int m = 1; 2058 final int m = 1;
2065 }'''); 2059 }''');
2066 computeLibrarySourceErrors(source); 2060 computeLibrarySourceErrors(source);
2067 assertErrors(source, [HintCode.OVERRIDE_ON_NON_OVERRIDING_FIELD]); 2061 assertErrors(source, [HintCode.OVERRIDE_ON_NON_OVERRIDING_FIELD]);
2068 verify([source]); 2062 verify([source]);
2069 } 2063 }
2070 2064
2071 void test_overrideOnNonOverridingGetter_invalid() { 2065 void test_overrideOnNonOverridingGetter_invalid() {
2072 Source source = addSource(r''' 2066 Source source = addSource(r'''
2073 library dart.core;
2074 const override = null;
2075 class A { 2067 class A {
2076 } 2068 }
2077 class B extends A { 2069 class B extends A {
2078 @override 2070 @override
2079 int get m => 1; 2071 int get m => 1;
2080 }'''); 2072 }''');
2081 computeLibrarySourceErrors(source); 2073 computeLibrarySourceErrors(source);
2082 assertErrors(source, [HintCode.OVERRIDE_ON_NON_OVERRIDING_GETTER]); 2074 assertErrors(source, [HintCode.OVERRIDE_ON_NON_OVERRIDING_GETTER]);
2083 verify([source]); 2075 verify([source]);
2084 } 2076 }
2085 2077
2086 void test_overrideOnNonOverridingMethod_invalid() { 2078 void test_overrideOnNonOverridingMethod_invalid() {
2087 Source source = addSource(r''' 2079 Source source = addSource(r'''
2088 library dart.core;
2089 const override = null;
2090 class A { 2080 class A {
2091 } 2081 }
2092 class B extends A { 2082 class B extends A {
2093 @override 2083 @override
2094 int m() => 1; 2084 int m() => 1;
2095 }'''); 2085 }''');
2096 computeLibrarySourceErrors(source); 2086 computeLibrarySourceErrors(source);
2097 assertErrors(source, [HintCode.OVERRIDE_ON_NON_OVERRIDING_METHOD]); 2087 assertErrors(source, [HintCode.OVERRIDE_ON_NON_OVERRIDING_METHOD]);
2098 verify([source]); 2088 verify([source]);
2099 } 2089 }
2100 2090
2101 void test_overrideOnNonOverridingSetter_invalid() { 2091 void test_overrideOnNonOverridingSetter_invalid() {
2102 Source source = addSource(r''' 2092 Source source = addSource(r'''
2103 library dart.core;
2104 const override = null;
2105 class A { 2093 class A {
2106 } 2094 }
2107 class B extends A { 2095 class B extends A {
2108 @override 2096 @override
2109 set m(int x) {} 2097 set m(int x) {}
2110 }'''); 2098 }''');
2111 computeLibrarySourceErrors(source); 2099 computeLibrarySourceErrors(source);
2112 assertErrors(source, [HintCode.OVERRIDE_ON_NON_OVERRIDING_SETTER]); 2100 assertErrors(source, [HintCode.OVERRIDE_ON_NON_OVERRIDING_SETTER]);
2113 verify([source]); 2101 verify([source]);
2114 } 2102 }
(...skipping 1810 matching lines...) Expand 10 before | Expand all | Expand 10 after
3925 n() { 3913 n() {
3926 var a = m(), b = m(); 3914 var a = m(), b = m();
3927 } 3915 }
3928 }'''); 3916 }''');
3929 computeLibrarySourceErrors(source); 3917 computeLibrarySourceErrors(source);
3930 assertErrors( 3918 assertErrors(
3931 source, [HintCode.USE_OF_VOID_RESULT, HintCode.USE_OF_VOID_RESULT]); 3919 source, [HintCode.USE_OF_VOID_RESULT, HintCode.USE_OF_VOID_RESULT]);
3932 verify([source]); 3920 verify([source]);
3933 } 3921 }
3934 } 3922 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698