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 6582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6593 // strong mode. | 6593 // strong mode. |
6594 // TODO(paulberry): once proper generic method syntax supports generic | 6594 // TODO(paulberry): once proper generic method syntax supports generic |
6595 // closures, rewrite the test below without using generic comment syntax, | 6595 // closures, rewrite the test below without using generic comment syntax, |
6596 // and remove this hack. See dartbug.com/25819 | 6596 // and remove this hack. See dartbug.com/25819 |
6597 return; | 6597 return; |
6598 } | 6598 } |
6599 UnlinkedVariable variable = serializeVariableText(''' | 6599 UnlinkedVariable variable = serializeVariableText(''' |
6600 final v = f() ? /*<T>*/(T t) => 0 : /*<T>*/(T t) => 1; | 6600 final v = f() ? /*<T>*/(T t) => 0 : /*<T>*/(T t) => 1; |
6601 bool f() => true; | 6601 bool f() => true; |
6602 '''); | 6602 '''); |
6603 // The inferred type of `v` is currently `(Object) -> int` due to | |
6604 // dartbug.com/25802. TODO(paulberry): fix this test when the bug is fixed. | |
6605 EntityRef inferredType = getTypeRefForSlot(variable.inferredTypeSlot); | 6603 EntityRef inferredType = getTypeRefForSlot(variable.inferredTypeSlot); |
6606 checkLinkedTypeRef( | 6604 checkLinkedTypeRef( |
6607 inferredType.syntheticReturnType, 'dart:core', 'dart:core', 'int'); | 6605 inferredType.syntheticReturnType, 'dart:core', 'dart:core', 'int'); |
6608 expect(inferredType.syntheticParams, hasLength(1)); | 6606 expect(inferredType.syntheticParams, hasLength(1)); |
6609 checkLinkedTypeRef(inferredType.syntheticParams[0].type, 'dart:core', | 6607 checkLinkedTypeRef( |
6610 'dart:core', 'Object'); | 6608 inferredType.syntheticParams[0].type, null, null, '*bottom*'); |
6611 } | 6609 } |
6612 | 6610 |
6613 test_syntheticFunctionType_genericClosure_inGenericFunction() { | 6611 test_syntheticFunctionType_genericClosure_inGenericFunction() { |
6614 if (skipFullyLinkedData) { | 6612 if (skipFullyLinkedData) { |
6615 return; | 6613 return; |
6616 } | 6614 } |
6617 if (!strongMode) { | 6615 if (!strongMode) { |
6618 // The test below uses generic comment syntax because proper generic | 6616 // The test below uses generic comment syntax because proper generic |
6619 // method syntax doesn't support generic closures. So it can only run in | 6617 // method syntax doesn't support generic closures. So it can only run in |
6620 // strong mode. | 6618 // strong mode. |
6621 // TODO(paulberry): once proper generic method syntax supports generic | 6619 // TODO(paulberry): once proper generic method syntax supports generic |
6622 // closures, rewrite the test below without using generic comment syntax, | 6620 // closures, rewrite the test below without using generic comment syntax, |
6623 // and remove this hack. See dartbug.com/25819 | 6621 // and remove this hack. See dartbug.com/25819 |
6624 return; | 6622 return; |
6625 } | 6623 } |
6626 UnlinkedVariable variable = serializeExecutableText(''' | 6624 UnlinkedVariable variable = serializeExecutableText(''' |
6627 void f<T, U>(bool b) { | 6625 void f<T, U>(bool b) { |
6628 final v = b ? /*<V>*/(T t, U u, V v) => 0 : /*<V>*/(T t, U u, V v) => 1; | 6626 final v = b ? /*<V>*/(T t, U u, V v) => 0 : /*<V>*/(T t, U u, V v) => 1; |
6629 } | 6627 } |
6630 ''').localVariables[0]; | 6628 ''').localVariables[0]; |
6631 // The inferred type of `v` is currently `(T, U, Object) -> int` due to | |
6632 // dartbug.com/25802. TODO(paulberry): fix this test when the bug is fixed. | |
6633 EntityRef inferredType = getTypeRefForSlot(variable.inferredTypeSlot); | 6629 EntityRef inferredType = getTypeRefForSlot(variable.inferredTypeSlot); |
6634 checkLinkedTypeRef( | 6630 checkLinkedTypeRef( |
6635 inferredType.syntheticReturnType, 'dart:core', 'dart:core', 'int'); | 6631 inferredType.syntheticReturnType, 'dart:core', 'dart:core', 'int'); |
6636 expect(inferredType.syntheticParams, hasLength(3)); | 6632 expect(inferredType.syntheticParams, hasLength(3)); |
6637 checkParamTypeRef(inferredType.syntheticParams[0].type, 2); | 6633 checkParamTypeRef(inferredType.syntheticParams[0].type, 2); |
6638 checkParamTypeRef(inferredType.syntheticParams[1].type, 1); | 6634 checkParamTypeRef(inferredType.syntheticParams[1].type, 1); |
6639 checkLinkedTypeRef(inferredType.syntheticParams[2].type, 'dart:core', | 6635 checkLinkedTypeRef( |
6640 'dart:core', 'Object'); | 6636 inferredType.syntheticParams[2].type, null, null, '*bottom*'); |
6641 } | 6637 } |
6642 | 6638 |
6643 test_syntheticFunctionType_inGenericClass() { | 6639 test_syntheticFunctionType_inGenericClass() { |
6644 if (skipFullyLinkedData) { | 6640 if (skipFullyLinkedData) { |
6645 return; | 6641 return; |
6646 } | 6642 } |
6647 UnlinkedVariable variable = serializeClassText(''' | 6643 UnlinkedVariable variable = serializeClassText(''' |
6648 class C<T, U> { | 6644 class C<T, U> { |
6649 var v = f() ? (T t, U u) => 0 : (T t, U u) => 1; | 6645 var v = f() ? (T t, U u) => 0 : (T t, U u) => 1; |
6650 } | 6646 } |
(...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7531 class _PrefixExpectation { | 7527 class _PrefixExpectation { |
7532 final ReferenceKind kind; | 7528 final ReferenceKind kind; |
7533 final String name; | 7529 final String name; |
7534 final String absoluteUri; | 7530 final String absoluteUri; |
7535 final String relativeUri; | 7531 final String relativeUri; |
7536 final int numTypeParameters; | 7532 final int numTypeParameters; |
7537 | 7533 |
7538 _PrefixExpectation(this.kind, this.name, | 7534 _PrefixExpectation(this.kind, this.name, |
7539 {this.absoluteUri, this.relativeUri, this.numTypeParameters: 0}); | 7535 {this.absoluteUri, this.relativeUri, this.numTypeParameters: 0}); |
7540 } | 7536 } |
OLD | NEW |