| 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 7280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7291 | 7291 |
| 7292 test_import_uri() { | 7292 test_import_uri() { |
| 7293 String uriString = '"dart:async"'; | 7293 String uriString = '"dart:async"'; |
| 7294 String libraryText = 'import $uriString; Future x;'; | 7294 String libraryText = 'import $uriString; Future x;'; |
| 7295 serializeLibraryText(libraryText); | 7295 serializeLibraryText(libraryText); |
| 7296 // Second import is the implicit import of dart:core | 7296 // Second import is the implicit import of dart:core |
| 7297 expect(unlinkedUnits[0].imports, hasLength(2)); | 7297 expect(unlinkedUnits[0].imports, hasLength(2)); |
| 7298 expect(unlinkedUnits[0].imports[0].uri, 'dart:async'); | 7298 expect(unlinkedUnits[0].imports[0].uri, 'dart:async'); |
| 7299 } | 7299 } |
| 7300 | 7300 |
| 7301 test_inferred_type_keeps_leading_dynamic() { |
| 7302 if (!strongMode || skipFullyLinkedData) { |
| 7303 return; |
| 7304 } |
| 7305 UnlinkedClass cls = |
| 7306 serializeClassText('class C { final x = <dynamic, int>{}; }'); |
| 7307 EntityRef type = getTypeRefForSlot(cls.fields[0].inferredTypeSlot); |
| 7308 // Check that x has inferred type `Map<dynamic, int>`. |
| 7309 checkLinkedTypeRef(type, 'dart:core', 'dart:core', 'Map', |
| 7310 allowTypeArguments: true, numTypeParameters: 2); |
| 7311 expect(type.typeArguments, hasLength(2)); |
| 7312 checkLinkedTypeRef(type.typeArguments[0], null, null, 'dynamic'); |
| 7313 checkLinkedTypeRef(type.typeArguments[1], 'dart:core', 'dart:core', 'int'); |
| 7314 } |
| 7315 |
| 7301 test_inferred_type_refers_to_bound_type_param() { | 7316 test_inferred_type_refers_to_bound_type_param() { |
| 7302 if (!strongMode || skipFullyLinkedData) { | 7317 if (!strongMode || skipFullyLinkedData) { |
| 7303 return; | 7318 return; |
| 7304 } | 7319 } |
| 7305 UnlinkedClass cls = serializeClassText( | 7320 UnlinkedClass cls = serializeClassText( |
| 7306 'class C<T> extends D<int, T> { var v; }' | 7321 'class C<T> extends D<int, T> { var v; }' |
| 7307 ' abstract class D<U, V> { Map<V, U> get v; }', | 7322 ' abstract class D<U, V> { Map<V, U> get v; }', |
| 7308 className: 'C'); | 7323 className: 'C'); |
| 7309 EntityRef type = getTypeRefForSlot(cls.fields[0].inferredTypeSlot); | 7324 EntityRef type = getTypeRefForSlot(cls.fields[0].inferredTypeSlot); |
| 7310 // Check that v has inferred type Map<T, int>. | 7325 // Check that v has inferred type Map<T, int>. |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7428 expect(linkedReference.dependency, 0); | 7443 expect(linkedReference.dependency, 0); |
| 7429 expect(linkedReference.kind, ReferenceKind.propertyAccessor); | 7444 expect(linkedReference.kind, ReferenceKind.propertyAccessor); |
| 7430 expect(linkedReference.name, 'f='); | 7445 expect(linkedReference.name, 'f='); |
| 7431 expect(linkedReference.numTypeParameters, 0); | 7446 expect(linkedReference.numTypeParameters, 0); |
| 7432 expect(linkedReference.unit, 0); | 7447 expect(linkedReference.unit, 0); |
| 7433 expect(linkedReference.containingReference, isNot(0)); | 7448 expect(linkedReference.containingReference, isNot(0)); |
| 7434 expect(linkedReference.containingReference, lessThan(type.reference)); | 7449 expect(linkedReference.containingReference, lessThan(type.reference)); |
| 7435 checkReferenceIndex(linkedReference.containingReference, null, null, 'D'); | 7450 checkReferenceIndex(linkedReference.containingReference, null, null, 'D'); |
| 7436 } | 7451 } |
| 7437 | 7452 |
| 7453 test_inferred_type_skips_trailing_dynamic() { |
| 7454 if (!strongMode || skipFullyLinkedData) { |
| 7455 return; |
| 7456 } |
| 7457 UnlinkedClass cls = |
| 7458 serializeClassText('class C { final x = <int, dynamic>{}; }'); |
| 7459 EntityRef type = getTypeRefForSlot(cls.fields[0].inferredTypeSlot); |
| 7460 // Check that x has inferred type `Map<int>`. The trailing type argument |
| 7461 // `dynamic` is omitted. |
| 7462 checkLinkedTypeRef(type, 'dart:core', 'dart:core', 'Map', |
| 7463 allowTypeArguments: true, numTypeParameters: 2); |
| 7464 expect(type.typeArguments, hasLength(1)); |
| 7465 checkLinkedTypeRef(type.typeArguments[0], 'dart:core', 'dart:core', 'int'); |
| 7466 } |
| 7467 |
| 7468 test_inferred_type_skips_unnecessary_dynamic() { |
| 7469 if (!strongMode || skipFullyLinkedData) { |
| 7470 return; |
| 7471 } |
| 7472 UnlinkedClass cls = serializeClassText('class C { final x = []; }'); |
| 7473 EntityRef type = getTypeRefForSlot(cls.fields[0].inferredTypeSlot); |
| 7474 // Check that x has inferred type `List`, not `List<dynamic>`. |
| 7475 checkLinkedTypeRef(type, 'dart:core', 'dart:core', 'List', |
| 7476 numTypeParameters: 1); |
| 7477 } |
| 7478 |
| 7438 test_initializer_executable_with_bottom_return_type() { | 7479 test_initializer_executable_with_bottom_return_type() { |
| 7439 // The synthetic executable for `v` has type `() => Bottom`. | 7480 // The synthetic executable for `v` has type `() => Bottom`. |
| 7440 UnlinkedVariable variable = serializeVariableText('int v = null;'); | 7481 UnlinkedVariable variable = serializeVariableText('int v = null;'); |
| 7441 expect(variable.initializer.returnType, isNull); | 7482 expect(variable.initializer.returnType, isNull); |
| 7442 checkInferredTypeSlot( | 7483 checkInferredTypeSlot( |
| 7443 variable.initializer.inferredReturnTypeSlot, null, null, '*bottom*', | 7484 variable.initializer.inferredReturnTypeSlot, null, null, '*bottom*', |
| 7444 onlyInStrongMode: false); | 7485 onlyInStrongMode: false); |
| 7445 } | 7486 } |
| 7446 | 7487 |
| 7447 test_initializer_executable_with_imported_return_type() { | 7488 test_initializer_executable_with_imported_return_type() { |
| (...skipping 1868 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9316 class _PrefixExpectation { | 9357 class _PrefixExpectation { |
| 9317 final ReferenceKind kind; | 9358 final ReferenceKind kind; |
| 9318 final String name; | 9359 final String name; |
| 9319 final String absoluteUri; | 9360 final String absoluteUri; |
| 9320 final String relativeUri; | 9361 final String relativeUri; |
| 9321 final int numTypeParameters; | 9362 final int numTypeParameters; |
| 9322 | 9363 |
| 9323 _PrefixExpectation(this.kind, this.name, | 9364 _PrefixExpectation(this.kind, this.name, |
| 9324 {this.absoluteUri, this.relativeUri, this.numTypeParameters: 0}); | 9365 {this.absoluteUri, this.relativeUri, this.numTypeParameters: 0}); |
| 9325 } | 9366 } |
| OLD | NEW |