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

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

Issue 2837743002: Issue 29432. Instantiate the redirect constructor with the in-scope type arguments. (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
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 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analyzer/error/error.dart'; 9 import 'package:analyzer/error/error.dart';
10 import 'package:analyzer/src/error/codes.dart'; 10 import 'package:analyzer/src/error/codes.dart';
(...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 break; 882 break;
883 case 'abc': 883 case 'abc':
884 break; 884 break;
885 } 885 }
886 }'''); 886 }''');
887 await computeAnalysisResult(source); 887 await computeAnalysisResult(source);
888 assertNoErrors(source); 888 assertNoErrors(source);
889 verify([source]); 889 verify([source]);
890 } 890 }
891 891
892 test_constConstructor_redirect_generic() async {
893 Source source = addSource(r'''
894 class A<T> {
895 const A(T value) : this._(value);
896 const A._(T value) : value = value;
897 final T value;
898 }
899
900 void main(){
901 const A<int>(1);
902 }
903 ''');
904 await computeAnalysisResult(source);
905 assertNoErrors(source);
906 verify([source]);
907 }
908
892 test_constConstructorWithFieldInitializedByNonConst() async { 909 test_constConstructorWithFieldInitializedByNonConst() async {
893 Source source = addSource(r''' 910 Source source = addSource(r'''
894 class A { 911 class A {
895 final int i = f(); 912 final int i = f();
896 const A(); 913 const A();
897 } 914 }
898 int f() { 915 int f() {
899 return 3; 916 return 3;
900 }'''); 917 }''');
901 // TODO(paulberry): the error CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE is 918 // TODO(paulberry): the error CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE is
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
1253 verify([source]); 1270 verify([source]);
1254 } 1271 }
1255 1272
1256 test_constFormalParameter_simpleFormalParameter() async { 1273 test_constFormalParameter_simpleFormalParameter() async {
1257 Source source = addSource("f(const x) {}"); 1274 Source source = addSource("f(const x) {}");
1258 await computeAnalysisResult(source); 1275 await computeAnalysisResult(source);
1259 assertErrors(source, [CompileTimeErrorCode.CONST_FORMAL_PARAMETER]); 1276 assertErrors(source, [CompileTimeErrorCode.CONST_FORMAL_PARAMETER]);
1260 verify([source]); 1277 verify([source]);
1261 } 1278 }
1262 1279
1263 test_nonConstValueInInitializer_instanceCreation_inDifferentFile() async {
1264 resetWith(options: new AnalysisOptionsImpl()..strongMode = true);
1265 Source source = addNamedSource(
1266 '/a.dart',
1267 r'''
1268 import 'b.dart';
1269 const v = const MyClass();
1270 ''');
1271 addNamedSource(
1272 '/b.dart',
1273 r'''
1274 class MyClass {
1275 const MyClass([p = foo]);
1276 }
1277 ''');
1278 await computeAnalysisResult(source);
1279 assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION]);
1280 }
1281
1282 test_constInitializedWithNonConstValue() async { 1280 test_constInitializedWithNonConstValue() async {
1283 Source source = addSource(r''' 1281 Source source = addSource(r'''
1284 f(p) { 1282 f(p) {
1285 const C = p; 1283 const C = p;
1286 }'''); 1284 }''');
1287 await computeAnalysisResult(source); 1285 await computeAnalysisResult(source);
1288 assertErrors(source, 1286 assertErrors(source,
1289 [CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE]); 1287 [CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE]);
1290 verify([source]); 1288 verify([source]);
1291 } 1289 }
(...skipping 3504 matching lines...) Expand 10 before | Expand all | Expand 10 after
4796 // TODO(scheglov): the error CONST_EVAL_THROWS_EXCEPTION is redundant and 4794 // TODO(scheglov): the error CONST_EVAL_THROWS_EXCEPTION is redundant and
4797 // ought to be suppressed. Or not? 4795 // ought to be suppressed. Or not?
4798 await computeAnalysisResult(source); 4796 await computeAnalysisResult(source);
4799 assertErrors(source, [ 4797 assertErrors(source, [
4800 CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER, 4798 CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER,
4801 CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION 4799 CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION
4802 ]); 4800 ]);
4803 verify([source]); 4801 verify([source]);
4804 } 4802 }
4805 4803
4804 test_nonConstValueInInitializer_instanceCreation_inDifferentFile() async {
4805 resetWith(options: new AnalysisOptionsImpl()..strongMode = true);
4806 Source source = addNamedSource(
4807 '/a.dart',
4808 r'''
4809 import 'b.dart';
4810 const v = const MyClass();
4811 ''');
4812 addNamedSource(
4813 '/b.dart',
4814 r'''
4815 class MyClass {
4816 const MyClass([p = foo]);
4817 }
4818 ''');
4819 await computeAnalysisResult(source);
4820 assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION]);
4821 }
4822
4806 test_nonConstValueInInitializer_redirecting() async { 4823 test_nonConstValueInInitializer_redirecting() async {
4807 Source source = addSource(r''' 4824 Source source = addSource(r'''
4808 class A { 4825 class A {
4809 static var C; 4826 static var C;
4810 const A.named(p); 4827 const A.named(p);
4811 const A() : this.named(C); 4828 const A() : this.named(C);
4812 }'''); 4829 }''');
4813 await computeAnalysisResult(source); 4830 await computeAnalysisResult(source);
4814 assertErrors( 4831 assertErrors(
4815 source, [CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER]); 4832 source, [CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER]);
(...skipping 1823 matching lines...) Expand 10 before | Expand all | Expand 10 after
6639 source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR]); 6656 source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR]);
6640 verify([source]); 6657 verify([source]);
6641 reset(); 6658 reset();
6642 } 6659 }
6643 6660
6644 Future<Null> _check_wrongNumberOfParametersForOperator1(String name) async { 6661 Future<Null> _check_wrongNumberOfParametersForOperator1(String name) async {
6645 await _check_wrongNumberOfParametersForOperator(name, ""); 6662 await _check_wrongNumberOfParametersForOperator(name, "");
6646 await _check_wrongNumberOfParametersForOperator(name, "a, b"); 6663 await _check_wrongNumberOfParametersForOperator(name, "a, b");
6647 } 6664 }
6648 } 6665 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/dart/constant/evaluation.dart ('k') | pkg/analyzer/test/src/dart/constant/evaluation_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698