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

Side by Side Diff: pkg/analyzer/lib/src/summary/summarize_elements.dart

Issue 1688343003: Make "Unbound type parameter" bugs easier to investigate. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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 | no next file » | 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) 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 serialization.elements; 5 library serialization.elements;
6 6
7 import 'package:analyzer/dart/element/element.dart'; 7 import 'package:analyzer/dart/element/element.dart';
8 import 'package:analyzer/dart/element/type.dart'; 8 import 'package:analyzer/dart/element/type.dart';
9 import 'package:analyzer/src/dart/element/element.dart'; 9 import 'package:analyzer/src/dart/element/element.dart';
10 import 'package:analyzer/src/dart/element/member.dart'; 10 import 'package:analyzer/src/dart/element/member.dart';
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 linkedUnit.types = deferredLinkedTypes 288 linkedUnit.types = deferredLinkedTypes
289 .map((_SerializeTypeRef closure) => closure()) 289 .map((_SerializeTypeRef closure) => closure())
290 .toList(); 290 .toList();
291 } 291 }
292 292
293 /** 293 /**
294 * Compute the appropriate De Bruijn index to represent the given type 294 * Compute the appropriate De Bruijn index to represent the given type
295 * parameter [type]. 295 * parameter [type].
296 */ 296 */
297 int findTypeParameterIndex(TypeParameterType type, Element context) { 297 int findTypeParameterIndex(TypeParameterType type, Element context) {
298 Element originalContext = context;
298 int index = 0; 299 int index = 0;
299 while (context != null) { 300 while (context != null) {
300 List<TypeParameterElement> typeParameters; 301 List<TypeParameterElement> typeParameters;
301 if (context is ClassElement) { 302 if (context is ClassElement) {
302 typeParameters = context.typeParameters; 303 typeParameters = context.typeParameters;
303 } else if (context is FunctionTypeAliasElement) { 304 } else if (context is FunctionTypeAliasElement) {
304 typeParameters = context.typeParameters; 305 typeParameters = context.typeParameters;
305 } else if (context is ExecutableElement) { 306 } else if (context is ExecutableElement) {
306 typeParameters = context.typeParameters; 307 typeParameters = context.typeParameters;
307 } 308 }
308 if (typeParameters != null) { 309 if (typeParameters != null) {
309 for (int i = 0; i < typeParameters.length; i++) { 310 for (int i = 0; i < typeParameters.length; i++) {
310 TypeParameterElement param = typeParameters[i]; 311 TypeParameterElement param = typeParameters[i];
311 if (param == type.element) { 312 if (param == type.element) {
312 return index + typeParameters.length - i; 313 return index + typeParameters.length - i;
313 } 314 }
314 } 315 }
315 index += typeParameters.length; 316 index += typeParameters.length;
316 } 317 }
317 context = context.enclosingElement; 318 context = context.enclosingElement;
318 } 319 }
319 throw new StateError('Unbound type parameter $type'); 320 throw new StateError(
321 'Unbound type parameter $type (${originalContext?.location})');
320 } 322 }
321 323
322 /** 324 /**
323 * Get the type arguments for the given [type], or `null` if the type has no 325 * Get the type arguments for the given [type], or `null` if the type has no
324 * type arguments. 326 * type arguments.
325 * 327 *
326 * TODO(paulberry): consider adding an abstract getter to [DartType] to do 328 * TODO(paulberry): consider adding an abstract getter to [DartType] to do
327 * this. 329 * this.
328 */ 330 */
329 List<DartType> getTypeArguments(DartType type) { 331 List<DartType> getTypeArguments(DartType type) {
(...skipping 980 matching lines...) Expand 10 before | Expand all | Expand 10 after
1310 exportNames.add(new LinkedExportNameBuilder( 1312 exportNames.add(new LinkedExportNameBuilder(
1311 name: name, 1313 name: name,
1312 dependency: serializeDependency(dependentLibrary), 1314 dependency: serializeDependency(dependentLibrary),
1313 unit: unit, 1315 unit: unit,
1314 kind: kind)); 1316 kind: kind));
1315 } 1317 }
1316 pb.exportNames = exportNames; 1318 pb.exportNames = exportNames;
1317 return pb; 1319 return pb;
1318 } 1320 }
1319 } 1321 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698