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

Side by Side Diff: pkg/analyzer/test/src/task/strong/front_end_inference_test.dart

Issue 2915913004: Fix inference test annotation of named/optional parameters in function types. (Closed)
Patch Set: Created 3 years, 6 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
« no previous file with comments | « no previous file | pkg/front_end/test/fasta/strong.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 import 'dart:async'; 5 import 'dart:async';
6 import 'dart:convert'; 6 import 'dart:convert';
7 import 'dart:io'; 7 import 'dart:io';
8 8
9 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/dart/ast/visitor.dart'; 10 import 'package:analyzer/dart/ast/visitor.dart';
11 import 'package:analyzer/dart/element/element.dart'; 11 import 'package:analyzer/dart/element/element.dart';
12 import 'package:analyzer/dart/element/type.dart'; 12 import 'package:analyzer/dart/element/type.dart';
13 import 'package:analyzer/src/dart/analysis/driver.dart'; 13 import 'package:analyzer/src/dart/analysis/driver.dart';
14 import 'package:analyzer/src/generated/source.dart'; 14 import 'package:analyzer/src/generated/source.dart';
15 import 'package:analyzer/src/generated/utilities_dart.dart';
15 import 'package:front_end/src/base/instrumentation.dart' as fasta; 16 import 'package:front_end/src/base/instrumentation.dart' as fasta;
16 import 'package:front_end/src/fasta/compiler_context.dart' as fasta; 17 import 'package:front_end/src/fasta/compiler_context.dart' as fasta;
17 import 'package:front_end/src/fasta/testing/validating_instrumentation.dart' 18 import 'package:front_end/src/fasta/testing/validating_instrumentation.dart'
18 as fasta; 19 as fasta;
19 import 'package:front_end/src/fasta/util/relativize.dart' show relativizeUri; 20 import 'package:front_end/src/fasta/util/relativize.dart' show relativizeUri;
20 import 'package:kernel/kernel.dart' as fasta; 21 import 'package:kernel/kernel.dart' as fasta;
21 import 'package:path/path.dart' as pathos; 22 import 'package:path/path.dart' as pathos;
22 import 'package:test/test.dart'; 23 import 'package:test/test.dart';
23 import 'package:test_reflective_loader/test_reflective_loader.dart'; 24 import 'package:test_reflective_loader/test_reflective_loader.dart';
24 25
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 buffer.write(separator); 206 buffer.write(separator);
206 } 207 }
207 writeItem(item); 208 writeItem(item);
208 first = false; 209 first = false;
209 } 210 }
210 buffer.write(close); 211 buffer.write(close);
211 } 212 }
212 213
213 void _appendParameters( 214 void _appendParameters(
214 StringBuffer buffer, List<ParameterElement> parameters) { 215 StringBuffer buffer, List<ParameterElement> parameters) {
215 _appendList<ParameterElement>(buffer, '(', ')', parameters, ', ', 216 buffer.write('(');
216 (parameter) { 217 bool first = true;
218 ParameterKind lastKind = ParameterKind.REQUIRED;
219 for (var parameter in parameters) {
220 if (!first) {
221 buffer.write(', ');
222 }
223 if (lastKind != parameter.parameterKind) {
224 if (parameter.parameterKind == ParameterKind.POSITIONAL) {
225 buffer.write('[');
226 } else if (parameter.parameterKind == ParameterKind.NAMED) {
227 buffer.write('{');
228 }
229 }
230 if (parameter.parameterKind == ParameterKind.NAMED) {
231 buffer.write(parameter.name);
232 buffer.write(': ');
233 }
217 _appendType(buffer, parameter.type); 234 _appendType(buffer, parameter.type);
218 }, includeEmpty: true); 235 lastKind = parameter.parameterKind;
236 first = false;
237 }
238 if (lastKind == ParameterKind.POSITIONAL) {
239 buffer.write(']');
240 } else if (lastKind == ParameterKind.NAMED) {
241 buffer.write('}');
242 }
243 buffer.write(')');
219 } 244 }
220 245
221 void _appendType(StringBuffer buffer, DartType type) { 246 void _appendType(StringBuffer buffer, DartType type) {
222 if (type is FunctionType) { 247 if (type is FunctionType) {
223 _appendTypeArguments(buffer, type.typeArguments); 248 _appendTypeArguments(buffer, type.typeArguments);
224 _appendParameters(buffer, type.parameters); 249 _appendParameters(buffer, type.parameters);
225 buffer.write(' -> '); 250 buffer.write(' -> ');
226 _appendType(buffer, type.returnType); 251 _appendType(buffer, type.returnType);
227 } else if (type is InterfaceType) { 252 } else if (type is InterfaceType) {
228 ClassElement element = type.element; 253 ClassElement element = type.element;
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 518
494 /// Based on DDC code generator's `_recoverTypeArguments` 519 /// Based on DDC code generator's `_recoverTypeArguments`
495 Iterable<DartType> _recoverTypeArguments(FunctionType g, FunctionType f) { 520 Iterable<DartType> _recoverTypeArguments(FunctionType g, FunctionType f) {
496 assert(identical(g.element, f.element)); 521 assert(identical(g.element, f.element));
497 assert(g.typeFormals.isNotEmpty && f.typeFormals.isEmpty); 522 assert(g.typeFormals.isNotEmpty && f.typeFormals.isEmpty);
498 assert(g.typeFormals.length + g.typeArguments.length == 523 assert(g.typeFormals.length + g.typeArguments.length ==
499 f.typeArguments.length); 524 f.typeArguments.length);
500 return f.typeArguments.skip(g.typeArguments.length); 525 return f.typeArguments.skip(g.typeArguments.length);
501 } 526 }
502 } 527 }
OLDNEW
« no previous file with comments | « no previous file | pkg/front_end/test/fasta/strong.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698