| 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 7562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7573 ' abstract class D<U, V> { Map<V, U> get v; }', | 7573 ' abstract class D<U, V> { Map<V, U> get v; }', |
| 7574 className: 'C'); | 7574 className: 'C'); |
| 7575 EntityRef type = getTypeRefForSlot(cls.fields[0].inferredTypeSlot); | 7575 EntityRef type = getTypeRefForSlot(cls.fields[0].inferredTypeSlot); |
| 7576 // Check that v has inferred type Map<T, int>. | 7576 // Check that v has inferred type Map<T, int>. |
| 7577 checkLinkedTypeRef(type, 'dart:core', 'dart:core', 'Map', | 7577 checkLinkedTypeRef(type, 'dart:core', 'dart:core', 'Map', |
| 7578 allowTypeArguments: true, numTypeParameters: 2); | 7578 allowTypeArguments: true, numTypeParameters: 2); |
| 7579 checkParamTypeRef(type.typeArguments[0], 1); | 7579 checkParamTypeRef(type.typeArguments[0], 1); |
| 7580 checkLinkedTypeRef(type.typeArguments[1], 'dart:core', 'dart:core', 'int'); | 7580 checkLinkedTypeRef(type.typeArguments[1], 'dart:core', 'dart:core', 'int'); |
| 7581 } | 7581 } |
| 7582 | 7582 |
| 7583 test_inferred_type_refers_to_function_typed_param_of_typedef() { |
| 7584 if (!strongMode || skipFullyLinkedData) { |
| 7585 return; |
| 7586 } |
| 7587 UnlinkedVariable v = serializeVariableText(''' |
| 7588 typedef void F(int g(String s)); |
| 7589 h(F f) => null; |
| 7590 var v = h((y) {}); |
| 7591 '''); |
| 7592 expect(v.initializer.localFunctions, hasLength(1)); |
| 7593 UnlinkedExecutable closure = v.initializer.localFunctions[0]; |
| 7594 expect(closure.parameters, hasLength(1)); |
| 7595 UnlinkedParam y = closure.parameters[0]; |
| 7596 expect(y.name, 'y'); |
| 7597 EntityRef typeRef = getTypeRefForSlot(y.inferredTypeSlot); |
| 7598 checkLinkedTypeRef(typeRef, null, null, 'F', |
| 7599 expectedKind: ReferenceKind.typedef); |
| 7600 expect(typeRef.implicitFunctionTypeIndices, [0]); |
| 7601 } |
| 7602 |
| 7583 test_inferred_type_refers_to_function_typed_parameter_type_generic_class() { | 7603 test_inferred_type_refers_to_function_typed_parameter_type_generic_class() { |
| 7584 if (!strongMode || skipFullyLinkedData) { | 7604 if (!strongMode || skipFullyLinkedData) { |
| 7585 return; | 7605 return; |
| 7586 } | 7606 } |
| 7587 UnlinkedClass cls = serializeClassText( | 7607 UnlinkedClass cls = serializeClassText( |
| 7588 'class C<T, U> extends D<U, int> { void f(int x, g) {} }' | 7608 'class C<T, U> extends D<U, int> { void f(int x, g) {} }' |
| 7589 ' abstract class D<V, W> { void f(int x, W g(V s)); }', | 7609 ' abstract class D<V, W> { void f(int x, W g(V s)); }', |
| 7590 className: 'C'); | 7610 className: 'C'); |
| 7591 EntityRef type = | 7611 EntityRef type = |
| 7592 getTypeRefForSlot(cls.executables[0].parameters[1].inferredTypeSlot); | 7612 getTypeRefForSlot(cls.executables[0].parameters[1].inferredTypeSlot); |
| (...skipping 2180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9773 class _PrefixExpectation { | 9793 class _PrefixExpectation { |
| 9774 final ReferenceKind kind; | 9794 final ReferenceKind kind; |
| 9775 final String name; | 9795 final String name; |
| 9776 final String absoluteUri; | 9796 final String absoluteUri; |
| 9777 final String relativeUri; | 9797 final String relativeUri; |
| 9778 final int numTypeParameters; | 9798 final int numTypeParameters; |
| 9779 | 9799 |
| 9780 _PrefixExpectation(this.kind, this.name, | 9800 _PrefixExpectation(this.kind, this.name, |
| 9781 {this.absoluteUri, this.relativeUri, this.numTypeParameters: 0}); | 9801 {this.absoluteUri, this.relativeUri, this.numTypeParameters: 0}); |
| 9782 } | 9802 } |
| OLD | NEW |