Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(159)

Side by Side Diff: pkg/analyzer/test/src/summary/summary_common.dart

Issue 1950333003: Fix a corner case of inferred types with function-typed parameters. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Also test resynthesis. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 7674 matching lines...) Expand 10 before | Expand all | Expand 10 after
7685 expect(linkedReference.dependency, 0); 7685 expect(linkedReference.dependency, 0);
7686 expect(linkedReference.kind, ReferenceKind.method); 7686 expect(linkedReference.kind, ReferenceKind.method);
7687 expect(linkedReference.name, 'f'); 7687 expect(linkedReference.name, 'f');
7688 expect(linkedReference.numTypeParameters, 0); 7688 expect(linkedReference.numTypeParameters, 0);
7689 expect(linkedReference.unit, 0); 7689 expect(linkedReference.unit, 0);
7690 expect(linkedReference.containingReference, isNot(0)); 7690 expect(linkedReference.containingReference, isNot(0));
7691 expect(linkedReference.containingReference, lessThan(type.reference)); 7691 expect(linkedReference.containingReference, lessThan(type.reference));
7692 checkReferenceIndex(linkedReference.containingReference, null, null, 'D'); 7692 checkReferenceIndex(linkedReference.containingReference, null, null, 'D');
7693 } 7693 }
7694 7694
7695 test_inferred_type_refers_to_nested_function_typed_param_of_typedef() {
7696 if (!strongMode || skipFullyLinkedData) {
7697 return;
7698 }
7699 UnlinkedVariable v = serializeVariableText('''
7700 f(void g(int x, void h())) => null;
7701 var v = f((x, y) {});
7702 ''');
7703 expect(v.initializer.localFunctions, hasLength(1));
7704 UnlinkedExecutable closure = v.initializer.localFunctions[0];
7705 expect(closure.parameters, hasLength(2));
7706 UnlinkedParam y = closure.parameters[1];
7707 expect(y.name, 'y');
7708 EntityRef typeRef = getTypeRefForSlot(y.inferredTypeSlot);
7709 checkLinkedTypeRef(typeRef, null, null, 'f',
7710 expectedKind: ReferenceKind.topLevelFunction);
7711 expect(typeRef.implicitFunctionTypeIndices, [0, 1]);
7712 }
7713
7714 test_inferred_type_refers_to_nested_function_typed_param_of_typedef_named() {
7715 if (!strongMode || skipFullyLinkedData) {
7716 return;
7717 }
7718 UnlinkedVariable v = serializeVariableText('''
7719 f({void g(int x, void h())}) => null;
7720 var v = f(g: (x, y) {});
7721 ''');
7722 expect(v.initializer.localFunctions, hasLength(1));
7723 UnlinkedExecutable closure = v.initializer.localFunctions[0];
7724 expect(closure.parameters, hasLength(2));
7725 UnlinkedParam y = closure.parameters[1];
7726 expect(y.name, 'y');
7727 EntityRef typeRef = getTypeRefForSlot(y.inferredTypeSlot);
7728 checkLinkedTypeRef(typeRef, null, null, 'f',
7729 expectedKind: ReferenceKind.topLevelFunction);
7730 expect(typeRef.implicitFunctionTypeIndices, [0, 1]);
7731 }
7732
7695 test_inferred_type_refers_to_setter_function_typed_parameter_type() { 7733 test_inferred_type_refers_to_setter_function_typed_parameter_type() {
7696 if (!strongMode || skipFullyLinkedData) { 7734 if (!strongMode || skipFullyLinkedData) {
7697 return; 7735 return;
7698 } 7736 }
7699 UnlinkedClass cls = serializeClassText( 7737 UnlinkedClass cls = serializeClassText(
7700 'class C extends D { void set f(g) {} }' 7738 'class C extends D { void set f(g) {} }'
7701 ' abstract class D { void set f(int g(String s)); }', 7739 ' abstract class D { void set f(int g(String s)); }',
7702 className: 'C'); 7740 className: 'C');
7703 EntityRef type = 7741 EntityRef type =
7704 getTypeRefForSlot(cls.executables[0].parameters[0].inferredTypeSlot); 7742 getTypeRefForSlot(cls.executables[0].parameters[0].inferredTypeSlot);
(...skipping 2088 matching lines...) Expand 10 before | Expand all | Expand 10 after
9793 class _PrefixExpectation { 9831 class _PrefixExpectation {
9794 final ReferenceKind kind; 9832 final ReferenceKind kind;
9795 final String name; 9833 final String name;
9796 final String absoluteUri; 9834 final String absoluteUri;
9797 final String relativeUri; 9835 final String relativeUri;
9798 final int numTypeParameters; 9836 final int numTypeParameters;
9799 9837
9800 _PrefixExpectation(this.kind, this.name, 9838 _PrefixExpectation(this.kind, this.name,
9801 {this.absoluteUri, this.relativeUri, this.numTypeParameters: 0}); 9839 {this.absoluteUri, this.relativeUri, this.numTypeParameters: 0});
9802 } 9840 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698