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 8428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8439 return; | 8439 return; |
8440 } | 8440 } |
8441 UnlinkedClass cls = serializeClassText('class C { final x = []; }'); | 8441 UnlinkedClass cls = serializeClassText('class C { final x = []; }'); |
8442 EntityRef type = getTypeRefForSlot(cls.fields[0].inferredTypeSlot); | 8442 EntityRef type = getTypeRefForSlot(cls.fields[0].inferredTypeSlot); |
8443 // Check that x has inferred type `List<dynamic>`. | 8443 // Check that x has inferred type `List<dynamic>`. |
8444 checkLinkedTypeRef(type, 'dart:core', 'dart:core', 'List', | 8444 checkLinkedTypeRef(type, 'dart:core', 'dart:core', 'List', |
8445 numTypeParameters: 1, numTypeArguments: 1); | 8445 numTypeParameters: 1, numTypeArguments: 1); |
8446 } | 8446 } |
8447 | 8447 |
8448 test_initializer_executable_with_bottom_return_type() { | 8448 test_initializer_executable_with_bottom_return_type() { |
8449 // The synthetic executable for `v` has type `() => Bottom`. | |
8450 UnlinkedVariable variable = serializeVariableText('int v = null;'); | 8449 UnlinkedVariable variable = serializeVariableText('int v = null;'); |
8451 expect(variable.initializer.returnType, isNull); | 8450 expect(variable.initializer.returnType, isNull); |
8452 checkInferredTypeSlot( | 8451 if (strongMode) { |
8453 variable.initializer.inferredReturnTypeSlot, null, null, '*bottom*', | 8452 // Strong mode infers a type for the closure of `() => int`. |
8454 onlyInStrongMode: false); | 8453 checkInferredTypeSlot(variable.initializer.inferredReturnTypeSlot, |
| 8454 'dart:core', 'dart:core', 'int', |
| 8455 onlyInStrongMode: false); |
| 8456 } else { |
| 8457 // In Dart1 mode the synthetic executable for `v` has type `() => Bottom`. |
| 8458 checkInferredTypeSlot( |
| 8459 variable.initializer.inferredReturnTypeSlot, null, null, '*bottom*', |
| 8460 onlyInStrongMode: false); |
| 8461 } |
8455 } | 8462 } |
8456 | 8463 |
8457 test_initializer_executable_with_imported_return_type() { | 8464 test_initializer_executable_with_imported_return_type() { |
8458 addNamedSource('/a.dart', 'class C { D d; } class D {}'); | 8465 addNamedSource('/a.dart', 'class C { D d; } class D {}'); |
8459 // The synthetic executable for `v` has type `() => D`; `D` is defined in | 8466 // The synthetic executable for `v` has type `() => D`; `D` is defined in |
8460 // a library that is imported. Note: `v` is mis-typed as `int` to prevent | 8467 // a library that is imported. Note: `v` is mis-typed as `int` to prevent |
8461 // type propagation, which would complicate the test. | 8468 // type propagation, which would complicate the test. |
8462 UnlinkedVariable variable = serializeVariableText( | 8469 UnlinkedVariable variable = serializeVariableText( |
8463 'import "a.dart"; int v = new C().d;', | 8470 'import "a.dart"; int v = new C().d;', |
8464 allowErrors: true); | 8471 allowErrors: true); |
(...skipping 2061 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10526 class _PrefixExpectation { | 10533 class _PrefixExpectation { |
10527 final ReferenceKind kind; | 10534 final ReferenceKind kind; |
10528 final String name; | 10535 final String name; |
10529 final String absoluteUri; | 10536 final String absoluteUri; |
10530 final String relativeUri; | 10537 final String relativeUri; |
10531 final int numTypeParameters; | 10538 final int numTypeParameters; |
10532 | 10539 |
10533 _PrefixExpectation(this.kind, this.name, | 10540 _PrefixExpectation(this.kind, this.name, |
10534 {this.absoluteUri, this.relativeUri, this.numTypeParameters: 0}); | 10541 {this.absoluteUri, this.relativeUri, this.numTypeParameters: 0}); |
10535 } | 10542 } |
OLD | NEW |