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

Side by Side Diff: tests/compiler/dart2js/simple_inferrer_test.dart

Issue 23353002: Fix receiver refining optimization in the presence of null: any Object method can be called on the … (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 import 'package:expect/expect.dart'; 5 import 'package:expect/expect.dart';
6 import 6 import
7 '../../../sdk/lib/_internal/compiler/implementation/types/types.dart' 7 '../../../sdk/lib/_internal/compiler/implementation/types/types.dart'
8 show TypeMask; 8 show TypeMask;
9 9
10 import 'compiler_helper.dart'; 10 import 'compiler_helper.dart';
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 434
435 testSpecialization2() { 435 testSpecialization2() {
436 var a = topLevelGetter(); 436 var a = topLevelGetter();
437 // Make [a] a captured variable. This should disable receiver 437 // Make [a] a captured variable. This should disable receiver
438 // specialization on [a]. 438 // specialization on [a].
439 (() => a.toString())(); 439 (() => a.toString())();
440 a - 42; 440 a - 42;
441 return a; 441 return a;
442 } 442 }
443 443
444 testSpecialization3() {
445 var a = returnDynamic() ? null : 42;
446 a.toString();
447 // Test that calling an [Object] method on [a] will not lead to
448 // infer that [a] is not null;
449 return a;
450 }
451
444 testReturnInvokeDynamicGetter() => new A().myFactory(); 452 testReturnInvokeDynamicGetter() => new A().myFactory();
445 453
446 var topLevelConstList = const [42]; 454 var topLevelConstList = const [42];
447 455
448 get topLevelGetter => 42; 456 get topLevelGetter => 42;
449 returnDynamic() => topLevelGetter(42); 457 returnDynamic() => topLevelGetter(42);
450 returnTopLevelGetter() => topLevelGetter; 458 returnTopLevelGetter() => topLevelGetter;
451 459
452 class A { 460 class A {
453 factory A() = A.generative; 461 factory A() = A.generative;
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 ..returnInt8() 583 ..returnInt8()
576 ..returnInt9(); 584 ..returnInt9();
577 testReturnElementOfConstList1(); 585 testReturnElementOfConstList1();
578 testReturnElementOfConstList2(); 586 testReturnElementOfConstList2();
579 testReturnItselfOrInt(topLevelGetter()); 587 testReturnItselfOrInt(topLevelGetter());
580 testReturnInvokeDynamicGetter(); 588 testReturnInvokeDynamicGetter();
581 testCascade1(); 589 testCascade1();
582 testCascade2(); 590 testCascade2();
583 testSpecialization1(); 591 testSpecialization1();
584 testSpecialization2(); 592 testSpecialization2();
593 testSpecialization3();
585 } 594 }
586 """; 595 """;
587 596
588 void main() { 597 void main() {
589 Uri uri = new Uri(scheme: 'source'); 598 Uri uri = new Uri(scheme: 'source');
590 var compiler = compilerFor(TEST, uri); 599 var compiler = compilerFor(TEST, uri);
591 compiler.runCompiler(uri); 600 compiler.runCompiler(uri);
592 var typesTask = compiler.typesTask; 601 var typesTask = compiler.typesTask;
593 var typesInferrer = typesTask.typesInferrer; 602 var typesInferrer = typesTask.typesInferrer;
594 603
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 Expect.equals(new TypeMask.nonNullExact(cls.rawType), 708 Expect.equals(new TypeMask.nonNullExact(cls.rawType),
700 typesInferrer.getReturnTypeOfElement(element)); 709 typesInferrer.getReturnTypeOfElement(element));
701 } 710 }
702 checkFactoryConstructor('A', ''); 711 checkFactoryConstructor('A', '');
703 712
704 checkReturn('testCascade1', typesTask.growableListType); 713 checkReturn('testCascade1', typesTask.growableListType);
705 checkReturn('testCascade2', new TypeMask.nonNullExact( 714 checkReturn('testCascade2', new TypeMask.nonNullExact(
706 typesTask.rawTypeOf(findElement(compiler, 'CascadeHelper')))); 715 typesTask.rawTypeOf(findElement(compiler, 'CascadeHelper'))));
707 checkReturn('testSpecialization1', typesTask.numType); 716 checkReturn('testSpecialization1', typesTask.numType);
708 checkReturn('testSpecialization2', typesTask.dynamicType); 717 checkReturn('testSpecialization2', typesTask.dynamicType);
718 checkReturn('testSpecialization3', typesTask.intType.nullable());
709 } 719 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/mock_compiler.dart ('k') | tests/language/refine_receiver_null_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698