| OLD | NEW |
| 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.summary.summary_common; | 5 library analyzer.test.src.summary.summary_common; |
| 6 | 6 |
| 7 import 'package:analyzer/analyzer.dart'; | 7 import 'package:analyzer/analyzer.dart'; |
| 8 import 'package:analyzer/dart/ast/ast.dart'; | 8 import 'package:analyzer/dart/ast/ast.dart'; |
| 9 import 'package:analyzer/dart/element/element.dart'; | 9 import 'package:analyzer/dart/element/element.dart'; |
| 10 import 'package:analyzer/src/dart/scanner/reader.dart'; | 10 import 'package:analyzer/src/dart/scanner/reader.dart'; |
| (...skipping 7531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7542 | 7542 |
| 7543 test_import_uri() { | 7543 test_import_uri() { |
| 7544 String uriString = '"dart:async"'; | 7544 String uriString = '"dart:async"'; |
| 7545 String libraryText = 'import $uriString; Future x;'; | 7545 String libraryText = 'import $uriString; Future x;'; |
| 7546 serializeLibraryText(libraryText); | 7546 serializeLibraryText(libraryText); |
| 7547 // Second import is the implicit import of dart:core | 7547 // Second import is the implicit import of dart:core |
| 7548 expect(unlinkedUnits[0].imports, hasLength(2)); | 7548 expect(unlinkedUnits[0].imports, hasLength(2)); |
| 7549 expect(unlinkedUnits[0].imports[0].uri, 'dart:async'); | 7549 expect(unlinkedUnits[0].imports[0].uri, 'dart:async'); |
| 7550 } | 7550 } |
| 7551 | 7551 |
| 7552 test_inferred_function_type_parameter_type_with_unrelated_type_param() { |
| 7553 if (!strongMode || skipFullyLinkedData) { |
| 7554 return; |
| 7555 } |
| 7556 // The type that is inferred for C.f's parameter g is "() -> void". |
| 7557 // Since the associated element for that function type is B.f's parameter g, |
| 7558 // and B has a type parameter, the inferred type will record a type |
| 7559 // parameter. However, since that type parameter is irrelevant, the summary |
| 7560 // should encode it as `dynamic`. |
| 7561 UnlinkedClass c = serializeClassText(''' |
| 7562 abstract class B<T> { |
| 7563 void f(void g()); |
| 7564 } |
| 7565 class C<T> extends B<T> { |
| 7566 void f(g) {} |
| 7567 } |
| 7568 '''); |
| 7569 expect(c.executables, hasLength(1)); |
| 7570 UnlinkedExecutable f = c.executables[0]; |
| 7571 expect(f.parameters, hasLength(1)); |
| 7572 UnlinkedParam g = f.parameters[0]; |
| 7573 expect(g.name, 'g'); |
| 7574 EntityRef typeRef = getTypeRefForSlot(g.inferredTypeSlot); |
| 7575 checkLinkedTypeRef(typeRef, null, null, 'f', |
| 7576 expectedKind: ReferenceKind.method, allowTypeArguments: true); |
| 7577 expect(typeRef.typeArguments, hasLength(1)); |
| 7578 checkLinkedTypeRef(typeRef.typeArguments[0], null, null, 'dynamic'); |
| 7579 } |
| 7580 |
| 7552 test_inferred_type_keeps_leading_dynamic() { | 7581 test_inferred_type_keeps_leading_dynamic() { |
| 7553 if (!strongMode || skipFullyLinkedData) { | 7582 if (!strongMode || skipFullyLinkedData) { |
| 7554 return; | 7583 return; |
| 7555 } | 7584 } |
| 7556 UnlinkedClass cls = | 7585 UnlinkedClass cls = |
| 7557 serializeClassText('class C { final x = <dynamic, int>{}; }'); | 7586 serializeClassText('class C { final x = <dynamic, int>{}; }'); |
| 7558 EntityRef type = getTypeRefForSlot(cls.fields[0].inferredTypeSlot); | 7587 EntityRef type = getTypeRefForSlot(cls.fields[0].inferredTypeSlot); |
| 7559 // Check that x has inferred type `Map<dynamic, int>`. | 7588 // Check that x has inferred type `Map<dynamic, int>`. |
| 7560 checkLinkedTypeRef(type, 'dart:core', 'dart:core', 'Map', | 7589 checkLinkedTypeRef(type, 'dart:core', 'dart:core', 'Map', |
| 7561 allowTypeArguments: true, numTypeParameters: 2); | 7590 allowTypeArguments: true, numTypeParameters: 2); |
| (...skipping 2269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9831 class _PrefixExpectation { | 9860 class _PrefixExpectation { |
| 9832 final ReferenceKind kind; | 9861 final ReferenceKind kind; |
| 9833 final String name; | 9862 final String name; |
| 9834 final String absoluteUri; | 9863 final String absoluteUri; |
| 9835 final String relativeUri; | 9864 final String relativeUri; |
| 9836 final int numTypeParameters; | 9865 final int numTypeParameters; |
| 9837 | 9866 |
| 9838 _PrefixExpectation(this.kind, this.name, | 9867 _PrefixExpectation(this.kind, this.name, |
| 9839 {this.absoluteUri, this.relativeUri, this.numTypeParameters: 0}); | 9868 {this.absoluteUri, this.relativeUri, this.numTypeParameters: 0}); |
| 9840 } | 9869 } |
| OLD | NEW |