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

Side by Side Diff: pkg/analyzer/test/src/task/strong/checker_test.dart

Issue 2214833002: fix #26965, allow promotion from type param upper bound in strong mode (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 4 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/type_system.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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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.src.task.strong.checker_test; 5 library analyzer.test.src.task.strong.checker_test;
6 6
7 import '../../../reflective_tests.dart'; 7 import '../../../reflective_tests.dart';
8 import 'strong_test_helper.dart'; 8 import 'strong_test_helper.dart';
9 9
10 void main() { 10 void main() {
(...skipping 3388 matching lines...) Expand 10 before | Expand all | Expand 10 after
3399 g() { 3399 g() {
3400 Object x; 3400 Object x;
3401 if (x is int) { 3401 if (x is int) {
3402 int y = x; 3402 int y = x;
3403 String z = /*error:INVALID_ASSIGNMENT*/x; 3403 String z = /*error:INVALID_ASSIGNMENT*/x;
3404 } 3404 }
3405 } 3405 }
3406 '''); 3406 ''');
3407 } 3407 }
3408 3408
3409 void test_typePromotionFromTypeParameter() {
3410 // Regression test for https://github.com/dart-lang/sdk/issues/26965
3411 checkFile(r'''
3412 void f/*<T>*/(/*=T*/ object) {
3413 if (object is String) print(object.substring(1));
3414 }
3415 void g/*<T extends num>*/(/*=T*/ object) {
3416 if (object is int) print(object.isEven);
3417 if (object is String) print(/*info:DYNAMIC_INVOKE*/object.substring(1));
Leaf 2016/08/04 16:49:06 There should be a type error here, shouldn't there
Jennifer Messerly 2016/08/04 18:26:16 yeah, it is, but we suppress the UNDEFINED_METHOD
3418 }
3419 class Clonable<T> {}
3420 class SubClonable<T> extends Clonable<T> {
3421 T m(T t) => t;
3422 }
3423 void h/*<T extends Clonable<T>>*/(/*=T*/ object) {
3424 if (/*info:NON_GROUND_TYPE_CHECK_INFO*/object is SubClonable/*<T>*/) {
3425 // Note we need to cast back to T, because promotion lost that type info.
3426 print(object.m(object as dynamic/*=T*/));
3427 }
3428 }
3429 ''');
3430 }
3431
3409 void test_typeSubtyping_assigningClass() { 3432 void test_typeSubtyping_assigningClass() {
3410 checkFile(''' 3433 checkFile('''
3411 class A {} 3434 class A {}
3412 class B extends A {} 3435 class B extends A {}
3413 3436
3414 void main() { 3437 void main() {
3415 dynamic y; 3438 dynamic y;
3416 Object o; 3439 Object o;
3417 int i = 0; 3440 int i = 0;
3418 double d = 0.0; 3441 double d = 0.0;
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
3609 // Regression test for https://github.com/dart-lang/sdk/issues/25069 3632 // Regression test for https://github.com/dart-lang/sdk/issues/25069
3610 checkFile(''' 3633 checkFile('''
3611 typedef int Foo(); 3634 typedef int Foo();
3612 void foo() {} 3635 void foo() {}
3613 void main () { 3636 void main () {
3614 Foo x = /*error:INVALID_ASSIGNMENT,info:USE_OF_VOID_RESULT*/foo(); 3637 Foo x = /*error:INVALID_ASSIGNMENT,info:USE_OF_VOID_RESULT*/foo();
3615 } 3638 }
3616 '''); 3639 ''');
3617 } 3640 }
3618 } 3641 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/type_system.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698