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

Side by Side Diff: pkg/analyzer/test/src/summary/linker_test.dart

Issue 2779993002: Store literal values and invocations arguments only for constants and untyped literals. (Closed)
Patch Set: Update IDL documentation. 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) 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 import 'package:analyzer/dart/element/type.dart'; 5 import 'package:analyzer/dart/element/type.dart';
6 import 'package:analyzer/src/dart/element/element.dart'; 6 import 'package:analyzer/src/dart/element/element.dart';
7 import 'package:analyzer/src/summary/format.dart'; 7 import 'package:analyzer/src/summary/format.dart';
8 import 'package:analyzer/src/summary/idl.dart'; 8 import 'package:analyzer/src/summary/idl.dart';
9 import 'package:analyzer/src/summary/link.dart'; 9 import 'package:analyzer/src/summary/link.dart';
10 import 'package:test/test.dart'; 10 import 'package:test/test.dart';
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 import 'a.dart'; 509 import 'a.dart';
510 class D { 510 class D {
511 var g = new C().f; // Inferred type: dynamic 511 var g = new C().f; // Inferred type: dynamic
512 } 512 }
513 '''); 513 ''');
514 LibraryElementForLink library = linker.getLibrary(linkerInputs.testDartUri); 514 LibraryElementForLink library = linker.getLibrary(linkerInputs.testDartUri);
515 ClassElementForLink_Class classD = library.getContainedName('D'); 515 ClassElementForLink_Class classD = library.getContainedName('D');
516 expect(classD.fields[0].inferredType.toString(), 'dynamic'); 516 expect(classD.fields[0].inferredType.toString(), 'dynamic');
517 } 517 }
518 518
519 void test_inferredTypeFromOutsideBuildUnit_methodParamType_viaGeneric() {
520 var bundle = createPackageBundle(
521 '''
522 class B {
523 T f<T>(T t) => t;
524 }
525 class C extends B {
526 f<T>(t) => t; // Inferred param type: T
527 }
528 ''',
529 path: '/a.dart');
530 addBundle('/a.ds', bundle);
531 createLinker('''
532 import 'a.dart';
533 var x = new C().f(0); // Inferred type: int
534 ''');
535 LibraryElementForLink library = linker.getLibrary(linkerInputs.testDartUri);
536 expect(_getVariable(library.getContainedName('x')).inferredType.toString(),
537 'int');
538 }
539
540 void test_inferredTypeFromOutsideBuildUnit_methodParamType_viaInheritance() { 519 void test_inferredTypeFromOutsideBuildUnit_methodParamType_viaInheritance() {
541 var bundle = createPackageBundle( 520 var bundle = createPackageBundle(
542 ''' 521 '''
543 class B { 522 class B {
544 void f(int i) {} 523 void f(int i) {}
545 } 524 }
546 class C extends B { 525 class C extends B {
547 f(i) {} // Inferred param type: int 526 f(i) {} // Inferred param type: int
548 } 527 }
549 ''', 528 ''',
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
965 */ 944 */
966 EntityRef _lookupInferredType(LinkedUnit unit, int slot) { 945 EntityRef _lookupInferredType(LinkedUnit unit, int slot) {
967 for (EntityRef ref in unit.types) { 946 for (EntityRef ref in unit.types) {
968 if (ref.slot == slot) { 947 if (ref.slot == slot) {
969 return ref; 948 return ref;
970 } 949 }
971 } 950 }
972 return null; 951 return null;
973 } 952 }
974 } 953 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698