OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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.static_warning_code_test; | 5 library analyzer.test.generated.static_warning_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/source_io.dart'; | 10 import 'package:analyzer/src/generated/source_io.dart'; |
(...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
789 Source source = addSource(r''' | 789 Source source = addSource(r''' |
790 f() { | 790 f() { |
791 final x = 0; | 791 final x = 0; |
792 x += 1; | 792 x += 1; |
793 }'''); | 793 }'''); |
794 await computeAnalysisResult(source); | 794 await computeAnalysisResult(source); |
795 assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]); | 795 assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]); |
796 verify([source]); | 796 verify([source]); |
797 } | 797 } |
798 | 798 |
| 799 test_assignmentToFinal_parameter() async { |
| 800 Source source = addSource(r''' |
| 801 f(final x) { |
| 802 x = 1; |
| 803 }'''); |
| 804 await computeAnalysisResult(source); |
| 805 assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]); |
| 806 verify([source]); |
| 807 } |
| 808 |
799 test_assignmentToFinal_postfixMinusMinus() async { | 809 test_assignmentToFinal_postfixMinusMinus() async { |
800 Source source = addSource(r''' | 810 Source source = addSource(r''' |
801 f() { | 811 f() { |
802 final x = 0; | 812 final x = 0; |
803 x--; | 813 x--; |
804 }'''); | 814 }'''); |
805 await computeAnalysisResult(source); | 815 await computeAnalysisResult(source); |
806 assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]); | 816 assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]); |
807 verify([source]); | 817 verify([source]); |
808 } | 818 } |
(...skipping 2898 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3707 | 3717 |
3708 test_voidReturnForGetter() async { | 3718 test_voidReturnForGetter() async { |
3709 Source source = addSource(r''' | 3719 Source source = addSource(r''' |
3710 class S { | 3720 class S { |
3711 void get value {} | 3721 void get value {} |
3712 }'''); | 3722 }'''); |
3713 await computeAnalysisResult(source); | 3723 await computeAnalysisResult(source); |
3714 assertErrors(source, [StaticWarningCode.VOID_RETURN_FOR_GETTER]); | 3724 assertErrors(source, [StaticWarningCode.VOID_RETURN_FOR_GETTER]); |
3715 } | 3725 } |
3716 } | 3726 } |
OLD | NEW |