OLD | NEW |
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 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 addBundle('/a.ds', bundle); | 344 addBundle('/a.ds', bundle); |
345 createLinker(''' | 345 createLinker(''' |
346 import 'a.dart'; | 346 import 'a.dart'; |
347 var y = C.x; | 347 var y = C.x; |
348 '''); | 348 '''); |
349 LibraryElementForLink library = linker.getLibrary(linkerInputs.testDartUri); | 349 LibraryElementForLink library = linker.getLibrary(linkerInputs.testDartUri); |
350 expect(_getVariable(library.getContainedName('y')).inferredType.toString(), | 350 expect(_getVariable(library.getContainedName('y')).inferredType.toString(), |
351 '(D) → E'); | 351 '(D) → E'); |
352 } | 352 } |
353 | 353 |
| 354 void test_inferredType_instanceField_conditional_genericFunctions() { |
| 355 createLinker(''' |
| 356 class C { |
| 357 final f = true ? <T>(T t) => 0 : <T>(T t) => 1; |
| 358 } |
| 359 '''); |
| 360 LibraryElementForLink library = linker.getLibrary(linkerInputs.testDartUri); |
| 361 library.libraryCycleForLink.ensureLinked(); |
| 362 ClassElementForLink_Class cls = library.getContainedName('C'); |
| 363 expect(cls.fields, hasLength(1)); |
| 364 var field = cls.fields[0]; |
| 365 expect(field.type.toString(), '(<bottom>) → dynamic'); |
| 366 } |
| 367 |
354 void test_inferredType_instanceField_dynamic() { | 368 void test_inferredType_instanceField_dynamic() { |
355 createLinker(''' | 369 createLinker(''' |
356 var x; | 370 var x; |
357 class C { | 371 class C { |
358 var f = x; // Inferred type: dynamic | 372 var f = x; // Inferred type: dynamic |
359 } | 373 } |
360 '''); | 374 '''); |
361 LibraryElementForLink library = linker.getLibrary(linkerInputs.testDartUri); | 375 LibraryElementForLink library = linker.getLibrary(linkerInputs.testDartUri); |
362 library.libraryCycleForLink.ensureLinked(); | 376 library.libraryCycleForLink.ensureLinked(); |
363 ClassElementForLink_Class cls = library.getContainedName('C'); | 377 ClassElementForLink_Class cls = library.getContainedName('C'); |
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
951 */ | 965 */ |
952 EntityRef _lookupInferredType(LinkedUnit unit, int slot) { | 966 EntityRef _lookupInferredType(LinkedUnit unit, int slot) { |
953 for (EntityRef ref in unit.types) { | 967 for (EntityRef ref in unit.types) { |
954 if (ref.slot == slot) { | 968 if (ref.slot == slot) { |
955 return ref; | 969 return ref; |
956 } | 970 } |
957 } | 971 } |
958 return null; | 972 return null; |
959 } | 973 } |
960 } | 974 } |
OLD | NEW |