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

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

Issue 2769703002: Revert "Issue 28580. Relax instantiate to bounds." (Closed)
Patch Set: Created 3 years, 9 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.strong_mode_test; 5 library analyzer.test.generated.strong_mode_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; 10 import 'package:analyzer/dart/ast/standard_resolution_map.dart';
(...skipping 3312 matching lines...) Expand 10 before | Expand all | Expand 10 after
3323 void main() { 3323 void main() {
3324 m(); 3324 m();
3325 } 3325 }
3326 } 3326 }
3327 '''; 3327 ''';
3328 await resolveTestUnit(code); 3328 await resolveTestUnit(code);
3329 assertNoErrors(testSource); 3329 assertNoErrors(testSource);
3330 expectStaticInvokeType('m();', '() → T'); 3330 expectStaticInvokeType('m();', '() → T');
3331 } 3331 }
3332 3332
3333 test_notInstantiatedBound_error_class_argument() async { 3333 test_notInstantiatedBound_direct_class_class() async {
3334 String code = r''' 3334 String code = r'''
3335 class A<K, V extends List<K>> {} 3335 class A<T extends int> {}
3336 class C<T extends A> {} 3336 class C<T extends A> {}
3337 '''; 3337 ''';
3338 await resolveTestUnit(code, noErrors: false); 3338 await resolveTestUnit(code, noErrors: false);
3339 assertErrors(testSource, [StrongModeCode.NOT_INSTANTIATED_BOUND]); 3339 assertErrors(testSource, [StrongModeCode.NOT_INSTANTIATED_BOUND]);
3340 } 3340 }
3341 3341
3342 test_notInstantiatedBound_error_class_argument2() async { 3342 test_notInstantiatedBound_direct_class_typedef() async {
3343 // Check that if the bound of a class is an uninstantiated typedef
3344 // we emit an error
3343 String code = r''' 3345 String code = r'''
3344 class A<K, V extends List<List<K>>> {} 3346 typedef void F<T extends int>();
3345 class C<T extends A> {} 3347 class C<T extends F> {}
3346 '''; 3348 ''';
3347 await resolveTestUnit(code, noErrors: false); 3349 await resolveTestUnit(code, noErrors: false);
3348 assertErrors(testSource, [StrongModeCode.NOT_INSTANTIATED_BOUND]); 3350 assertErrors(testSource, [StrongModeCode.NOT_INSTANTIATED_BOUND]);
3349 } 3351 }
3350 3352
3351 test_notInstantiatedBound_error_class_direct() async { 3353 test_notInstantiatedBound_direct_typedef_class() async {
3354 // Check that if the bound of a typeded is an uninstantiated class
3355 // we emit an error
3352 String code = r''' 3356 String code = r'''
3353 class A<K, V extends K> {} 3357 class C<T extends int> {}
3354 class C<T extends A> {} 3358 typedef void F<T extends C>();
3355 '''; 3359 ''';
3356 await resolveTestUnit(code, noErrors: false); 3360 await resolveTestUnit(code, noErrors: false);
3357 assertErrors(testSource, [StrongModeCode.NOT_INSTANTIATED_BOUND]); 3361 assertErrors(testSource, [StrongModeCode.NOT_INSTANTIATED_BOUND]);
3358 } 3362 }
3359 3363
3360 test_notInstantiatedBound_error_class_indirect() async { 3364 test_notInstantiatedBound_indirect_class_class() async {
3361 String code = r''' 3365 String code = r'''
3362 class A<K, V extends K> {} 3366 class A<T> {}
3363 class C<T extends List<A>> {} 3367 class B<T extends int> {}
3368 class C<T extends A<B>> {}
3364 '''; 3369 ''';
3365 await resolveTestUnit(code, noErrors: false); 3370 await resolveTestUnit(code, noErrors: false);
3366 assertErrors(testSource, [StrongModeCode.NOT_INSTANTIATED_BOUND]); 3371 assertErrors(testSource, [StrongModeCode.NOT_INSTANTIATED_BOUND]);
3367 } 3372 }
3368 3373
3369 test_notInstantiatedBound_error_typedef_argument() async { 3374 test_notInstantiatedBound_indirect_class_class2() async {
3370 String code = r'''
3371 class A<K, V extends List<K>> {}
3372 typedef void F<T extends A>();
3373 ''';
3374 await resolveTestUnit(code, noErrors: false);
3375 assertErrors(testSource, [StrongModeCode.NOT_INSTANTIATED_BOUND]);
3376 }
3377
3378 test_notInstantiatedBound_error_typedef_argument2() async {
3379 String code = r'''
3380 class A<K, V extends List<List<K>>> {}
3381 typedef void F<T extends A>();
3382 ''';
3383 await resolveTestUnit(code, noErrors: false);
3384 assertErrors(testSource, [StrongModeCode.NOT_INSTANTIATED_BOUND]);
3385 }
3386
3387 test_notInstantiatedBound_error_typedef_direct() async {
3388 String code = r'''
3389 class A<K, V extends K> {}
3390 typedef void F<T extends A>();
3391 ''';
3392 await resolveTestUnit(code, noErrors: false);
3393 assertErrors(testSource, [StrongModeCode.NOT_INSTANTIATED_BOUND]);
3394 }
3395
3396 test_notInstantiatedBound_ok_class() async {
3397 String code = r'''
3398 class A<T extends int> {}
3399 class C1<T extends A> {}
3400 class C2<T extends List<A>> {}
3401 ''';
3402 await resolveTestUnit(code);
3403 assertNoErrors(testSource);
3404 }
3405
3406 test_notInstantiatedBound_ok_class_class2() async {
3407 String code = r'''
3408 class A<T> {}
3409 class C<T extends A<int>> {}
3410 class D<T extends C> {}
3411 ''';
3412 await resolveTestUnit(code);
3413 assertNoErrors(testSource);
3414 }
3415
3416 test_notInstantiatedBound_ok_class_class3() async {
3417 String code = r'''
3418 class A<T> {}
3419 class B<T extends int> {}
3420 class C<T extends A<B>> {}
3421 ''';
3422 await resolveTestUnit(code);
3423 assertNoErrors(testSource);
3424 }
3425
3426 test_notInstantiatedBound_ok_class_class4() async {
3427 String code = r''' 3375 String code = r'''
3428 class A<K, V> {} 3376 class A<K, V> {}
3429 class B<T extends int> {} 3377 class B<T extends int> {}
3430 class C<T extends A<B, B>> {} 3378 class C<T extends A<B, B>> {}
3431 '''; 3379 ''';
3432 await resolveTestUnit(code); 3380 await resolveTestUnit(code, noErrors: false);
3433 assertNoErrors(testSource); 3381 assertErrors(testSource, [
3434 } 3382 StrongModeCode.NOT_INSTANTIATED_BOUND,
3435 3383 StrongModeCode.NOT_INSTANTIATED_BOUND
3436 test_notInstantiatedBound_ok_class_typedef() async { 3384 ]);
3437 String code = r'''
3438 typedef void F<T extends int>();
3439 class C<T extends F> {}
3440 ''';
3441 await resolveTestUnit(code);
3442 assertNoErrors(testSource);
3443 }
3444
3445 test_notInstantiatedBound_ok_typedef_class() async {
3446 String code = r'''
3447 class C<T extends int> {}
3448 typedef void F<T extends C>();
3449 ''';
3450 await resolveTestUnit(code);
3451 assertNoErrors(testSource);
3452 } 3385 }
3453 3386
3454 test_objectMethodOnFunctions_Anonymous() async { 3387 test_objectMethodOnFunctions_Anonymous() async {
3455 String code = r''' 3388 String code = r'''
3456 void main() { 3389 void main() {
3457 var f = (x) => 3; 3390 var f = (x) => 3;
3458 // No errors, correct type 3391 // No errors, correct type
3459 var t0 = f.toString(); 3392 var t0 = f.toString();
3460 var t1 = f.toString; 3393 var t1 = f.toString;
3461 var t2 = f.hashCode; 3394 var t2 = f.hashCode;
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
3923 var v = x; 3856 var v = x;
3924 v; // marker 3857 v; // marker
3925 } 3858 }
3926 int x = 3; 3859 int x = 3;
3927 '''; 3860 ''';
3928 CompilationUnit unit = await resolveSource(code); 3861 CompilationUnit unit = await resolveSource(code);
3929 assertPropagatedAssignedType(code, unit, typeProvider.intType, null); 3862 assertPropagatedAssignedType(code, unit, typeProvider.intType, null);
3930 assertTypeOfMarkedExpression(code, unit, typeProvider.intType, null); 3863 assertTypeOfMarkedExpression(code, unit, typeProvider.intType, null);
3931 } 3864 }
3932 } 3865 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/task/dart.dart ('k') | pkg/analyzer/test/src/summary/resynthesize_ast_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698