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

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

Issue 2805443002: Restrict `@immutable` checks to instance fields (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « pkg/analyzer/lib/src/generated/resolver.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/error/error.dart'; 7 import 'package:analyzer/error/error.dart';
8 import 'package:analyzer/src/error/codes.dart'; 8 import 'package:analyzer/src/error/codes.dart';
9 import 'package:analyzer/src/generated/engine.dart'; 9 import 'package:analyzer/src/generated/engine.dart';
10 import 'package:analyzer/src/generated/parser.dart'; 10 import 'package:analyzer/src/generated/parser.dart';
(...skipping 1989 matching lines...) Expand 10 before | Expand all | Expand 10 after
2000 @immutable 2000 @immutable
2001 class A { 2001 class A {
2002 int x; 2002 int x;
2003 } 2003 }
2004 '''); 2004 ''');
2005 await computeAnalysisResult(source); 2005 await computeAnalysisResult(source);
2006 assertErrors(source, [HintCode.MUST_BE_IMMUTABLE]); 2006 assertErrors(source, [HintCode.MUST_BE_IMMUTABLE]);
2007 verify([source]); 2007 verify([source]);
2008 } 2008 }
2009 2009
2010 test_mustBeImmutable_instance() async {
2011 Source source = addSource(r'''
2012 import 'package:meta/meta.dart';
2013 @immutable
2014 class A {
2015 static int x;
2016 }
2017 ''');
2018 await computeAnalysisResult(source);
2019 assertErrors(source, []);
2020 verify([source]);
2021 }
2022
2010 test_mustBeImmutable_extends() async { 2023 test_mustBeImmutable_extends() async {
2011 Source source = addSource(r''' 2024 Source source = addSource(r'''
2012 import 'package:meta/meta.dart'; 2025 import 'package:meta/meta.dart';
2013 @immutable 2026 @immutable
2014 class A {} 2027 class A {}
2015 class B extends A { 2028 class B extends A {
2016 int x; 2029 int x;
2017 } 2030 }
2018 '''); 2031 ''');
2019 await computeAnalysisResult(source); 2032 await computeAnalysisResult(source);
(...skipping 2202 matching lines...) Expand 10 before | Expand all | Expand 10 after
4222 n() { 4235 n() {
4223 var a = m(), b = m(); 4236 var a = m(), b = m();
4224 } 4237 }
4225 }'''); 4238 }''');
4226 await computeAnalysisResult(source); 4239 await computeAnalysisResult(source);
4227 assertErrors( 4240 assertErrors(
4228 source, [HintCode.USE_OF_VOID_RESULT, HintCode.USE_OF_VOID_RESULT]); 4241 source, [HintCode.USE_OF_VOID_RESULT, HintCode.USE_OF_VOID_RESULT]);
4229 verify([source]); 4242 verify([source]);
4230 } 4243 }
4231 } 4244 }
OLDNEW
« 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