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

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

Issue 1923593002: provide MISSING_RETURN on factory constructors (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Addressing feedback Created 4 years, 7 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) 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.compile_time_error_code_test; 5 library analyzer.test.generated.compile_time_error_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' show ParserErrorCode; 9 import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode;
10 import 'package:analyzer/src/generated/source_io.dart'; 10 import 'package:analyzer/src/generated/source_io.dart';
(...skipping 2191 matching lines...) Expand 10 before | Expand all | Expand 10 after
2202 computeLibrarySourceErrors(source); 2202 computeLibrarySourceErrors(source);
2203 assertErrors(source, 2203 assertErrors(source,
2204 [CompileTimeErrorCode.FIELD_INITIALIZED_IN_PARAMETER_AND_INITIALIZER]); 2204 [CompileTimeErrorCode.FIELD_INITIALIZED_IN_PARAMETER_AND_INITIALIZER]);
2205 verify([source]); 2205 verify([source]);
2206 } 2206 }
2207 2207
2208 void test_fieldInitializerFactoryConstructor() { 2208 void test_fieldInitializerFactoryConstructor() {
2209 Source source = addSource(r''' 2209 Source source = addSource(r'''
2210 class A { 2210 class A {
2211 int x; 2211 int x;
2212 factory A(this.x) {} 2212 factory A(this.x) => null;
2213 }'''); 2213 }''');
2214 computeLibrarySourceErrors(source); 2214 computeLibrarySourceErrors(source);
2215 assertErrors( 2215 assertErrors(
2216 source, [CompileTimeErrorCode.FIELD_INITIALIZER_FACTORY_CONSTRUCTOR]); 2216 source, [CompileTimeErrorCode.FIELD_INITIALIZER_FACTORY_CONSTRUCTOR]);
2217 verify([source]); 2217 verify([source]);
2218 } 2218 }
2219 2219
2220 void test_fieldInitializerOutsideConstructor() { 2220 void test_fieldInitializerOutsideConstructor() {
2221 // TODO(brianwilkerson) Fix the duplicate error messages. 2221 // TODO(brianwilkerson) Fix the duplicate error messages.
2222 Source source = addSource(r''' 2222 Source source = addSource(r'''
(...skipping 971 matching lines...) Expand 10 before | Expand all | Expand 10 after
3194 }'''); 3194 }''');
3195 computeLibrarySourceErrors(source); 3195 computeLibrarySourceErrors(source);
3196 assertErrors(source, [CompileTimeErrorCode.INVALID_CONSTRUCTOR_NAME]); 3196 assertErrors(source, [CompileTimeErrorCode.INVALID_CONSTRUCTOR_NAME]);
3197 // no verify() call, "B" is not resolved 3197 // no verify() call, "B" is not resolved
3198 } 3198 }
3199 3199
3200 void test_invalidFactoryNameNotAClass_notClassName() { 3200 void test_invalidFactoryNameNotAClass_notClassName() {
3201 Source source = addSource(r''' 3201 Source source = addSource(r'''
3202 int B; 3202 int B;
3203 class A { 3203 class A {
3204 factory B() {} 3204 factory B() => null;
3205 }'''); 3205 }''');
3206 computeLibrarySourceErrors(source); 3206 computeLibrarySourceErrors(source);
3207 assertErrors( 3207 assertErrors(
3208 source, [CompileTimeErrorCode.INVALID_FACTORY_NAME_NOT_A_CLASS]); 3208 source, [CompileTimeErrorCode.INVALID_FACTORY_NAME_NOT_A_CLASS]);
3209 verify([source]); 3209 verify([source]);
3210 } 3210 }
3211 3211
3212 void test_invalidFactoryNameNotAClass_notEnclosingClassName() { 3212 void test_invalidFactoryNameNotAClass_notEnclosingClassName() {
3213 Source source = addSource(r''' 3213 Source source = addSource(r'''
3214 class A { 3214 class A {
3215 factory B() {} 3215 factory B() => null;
3216 }'''); 3216 }''');
3217 computeLibrarySourceErrors(source); 3217 computeLibrarySourceErrors(source);
3218 assertErrors( 3218 assertErrors(
3219 source, [CompileTimeErrorCode.INVALID_FACTORY_NAME_NOT_A_CLASS]); 3219 source, [CompileTimeErrorCode.INVALID_FACTORY_NAME_NOT_A_CLASS]);
3220 // no verify() call, "B" is not resolved 3220 // no verify() call, "B" is not resolved
3221 } 3221 }
3222 3222
3223 void test_invalidModifierOnConstructor_async() { 3223 void test_invalidModifierOnConstructor_async() {
3224 Source source = addSource(r''' 3224 Source source = addSource(r'''
3225 class A { 3225 class A {
(...skipping 1503 matching lines...) Expand 10 before | Expand all | Expand 10 after
4729 }''' 4729 }'''
4730 ], <ErrorCode>[ 4730 ], <ErrorCode>[
4731 CompileTimeErrorCode 4731 CompileTimeErrorCode
4732 .NON_CONSTANT_VALUE_IN_INITIALIZER_FROM_DEFERRED_LIBRARY 4732 .NON_CONSTANT_VALUE_IN_INITIALIZER_FROM_DEFERRED_LIBRARY
4733 ]); 4733 ]);
4734 } 4734 }
4735 4735
4736 void test_nonGenerativeConstructor_explicit() { 4736 void test_nonGenerativeConstructor_explicit() {
4737 Source source = addSource(r''' 4737 Source source = addSource(r'''
4738 class A { 4738 class A {
4739 factory A.named() {} 4739 factory A.named() => null;
4740 } 4740 }
4741 class B extends A { 4741 class B extends A {
4742 B() : super.named(); 4742 B() : super.named();
4743 }'''); 4743 }''');
4744 computeLibrarySourceErrors(source); 4744 computeLibrarySourceErrors(source);
4745 assertErrors(source, [CompileTimeErrorCode.NON_GENERATIVE_CONSTRUCTOR]); 4745 assertErrors(source, [CompileTimeErrorCode.NON_GENERATIVE_CONSTRUCTOR]);
4746 verify([source]); 4746 verify([source]);
4747 } 4747 }
4748 4748
4749 void test_nonGenerativeConstructor_implicit() { 4749 void test_nonGenerativeConstructor_implicit() {
4750 Source source = addSource(r''' 4750 Source source = addSource(r'''
4751 class A { 4751 class A {
4752 factory A() {} 4752 factory A() => null;
4753 } 4753 }
4754 class B extends A { 4754 class B extends A {
4755 B(); 4755 B();
4756 }'''); 4756 }''');
4757 computeLibrarySourceErrors(source); 4757 computeLibrarySourceErrors(source);
4758 assertErrors(source, [CompileTimeErrorCode.NON_GENERATIVE_CONSTRUCTOR]); 4758 assertErrors(source, [CompileTimeErrorCode.NON_GENERATIVE_CONSTRUCTOR]);
4759 verify([source]); 4759 verify([source]);
4760 } 4760 }
4761 4761
4762 void test_nonGenerativeConstructor_implicit2() { 4762 void test_nonGenerativeConstructor_implicit2() {
4763 Source source = addSource(r''' 4763 Source source = addSource(r'''
4764 class A { 4764 class A {
4765 factory A() {} 4765 factory A() => null;
4766 } 4766 }
4767 class B extends A { 4767 class B extends A {
4768 }'''); 4768 }''');
4769 computeLibrarySourceErrors(source); 4769 computeLibrarySourceErrors(source);
4770 assertErrors(source, [CompileTimeErrorCode.NON_GENERATIVE_CONSTRUCTOR]); 4770 assertErrors(source, [CompileTimeErrorCode.NON_GENERATIVE_CONSTRUCTOR]);
4771 verify([source]); 4771 verify([source]);
4772 } 4772 }
4773 4773
4774 void test_notEnoughRequiredArguments_const() { 4774 void test_notEnoughRequiredArguments_const() {
4775 Source source = addSource(r''' 4775 Source source = addSource(r'''
(...skipping 977 matching lines...) Expand 10 before | Expand all | Expand 10 after
5753 } 5753 }
5754 5754
5755 void test_superInInvalidContext_factoryConstructor() { 5755 void test_superInInvalidContext_factoryConstructor() {
5756 Source source = addSource(r''' 5756 Source source = addSource(r'''
5757 class A { 5757 class A {
5758 m() {} 5758 m() {}
5759 } 5759 }
5760 class B extends A { 5760 class B extends A {
5761 factory B() { 5761 factory B() {
5762 super.m(); 5762 super.m();
5763 return null;
5763 } 5764 }
5764 }'''); 5765 }''');
5765 computeLibrarySourceErrors(source); 5766 computeLibrarySourceErrors(source);
5766 assertErrors(source, [CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]); 5767 assertErrors(source, [CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]);
5767 // no verify(), 'super.m' is not resolved 5768 // no verify(), 'super.m' is not resolved
5768 } 5769 }
5769 5770
5770 void test_superInInvalidContext_instanceVariableInitializer() { 5771 void test_superInInvalidContext_instanceVariableInitializer() {
5771 Source source = addSource(r''' 5772 Source source = addSource(r'''
5772 class A { 5773 class A {
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after
6337 source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR]); 6338 source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR]);
6338 verify([source]); 6339 verify([source]);
6339 reset(); 6340 reset();
6340 } 6341 }
6341 6342
6342 void _check_wrongNumberOfParametersForOperator1(String name) { 6343 void _check_wrongNumberOfParametersForOperator1(String name) {
6343 _check_wrongNumberOfParametersForOperator(name, ""); 6344 _check_wrongNumberOfParametersForOperator(name, "");
6344 _check_wrongNumberOfParametersForOperator(name, "a, b"); 6345 _check_wrongNumberOfParametersForOperator(name, "a, b");
6345 } 6346 }
6346 } 6347 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/resolver.dart ('k') | pkg/analyzer/test/generated/hint_code_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698