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

Side by Side Diff: pkg/analyzer/lib/src/task/dart.dart

Issue 1119973003: Fix NPE when analyzing Object (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 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 | Annotate | Revision Log
« 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 analyzer.src.task.dart; 5 library analyzer.src.task.dart;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 import 'dart:math' as math; 8 import 'dart:math' as math;
9 9
10 import 'package:analyzer/src/generated/ast.dart'; 10 import 'package:analyzer/src/generated/ast.dart';
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 327
328 @override 328 @override
329 void internalPerform() { 329 void internalPerform() {
330 List<AnalysisError> errors = <AnalysisError>[]; 330 List<AnalysisError> errors = <AnalysisError>[];
331 // 331 //
332 // Prepare inputs. 332 // Prepare inputs.
333 // 333 //
334 ClassElementImpl classElement = this.target; 334 ClassElementImpl classElement = this.target;
335 List<ConstructorElement> superConstructors = inputs[SUPER_CONSTRUCTORS]; 335 List<ConstructorElement> superConstructors = inputs[SUPER_CONSTRUCTORS];
336 DartType superType = classElement.supertype; 336 DartType superType = classElement.supertype;
337 ClassElement superElement = superType.element;
338 // 337 //
339 // Shortcut for ClassElement(s) without implicit constructors. 338 // Shortcut for ClassElement(s) without implicit constructors.
340 // 339 //
341 if (superConstructors == null) { 340 if (superConstructors == null) {
342 outputs[CONSTRUCTORS] = classElement.constructors; 341 outputs[CONSTRUCTORS] = classElement.constructors;
343 outputs[CONSTRUCTORS_ERRORS] = AnalysisError.NO_ERRORS; 342 outputs[CONSTRUCTORS_ERRORS] = AnalysisError.NO_ERRORS;
344 return; 343 return;
345 } 344 }
346 // 345 //
347 // ClassTypeAlias 346 // ClassTypeAlias
348 // 347 //
349 if (classElement.isTypedef) { 348 if (classElement.isTypedef) {
350 List<ConstructorElement> implicitConstructors = 349 List<ConstructorElement> implicitConstructors =
351 new List<ConstructorElement>(); 350 new List<ConstructorElement>();
352 void callback(ConstructorElement explicitConstructor, 351 void callback(ConstructorElement explicitConstructor,
353 List<DartType> parameterTypes, List<DartType> argumentTypes) { 352 List<DartType> parameterTypes, List<DartType> argumentTypes) {
354 implicitConstructors.add(_createImplicitContructor(classElement.type, 353 implicitConstructors.add(_createImplicitContructor(classElement.type,
355 explicitConstructor, parameterTypes, argumentTypes)); 354 explicitConstructor, parameterTypes, argumentTypes));
356 } 355 }
357 if (_findForwardedConstructors(classElement, superType, callback)) { 356 if (_findForwardedConstructors(classElement, superType, callback)) {
358 if (implicitConstructors.isEmpty) { 357 if (implicitConstructors.isEmpty) {
359 errors.add(new AnalysisError.con2(classElement.source, 358 errors.add(new AnalysisError.con2(classElement.source,
360 classElement.nameOffset, classElement.name.length, 359 classElement.nameOffset, classElement.name.length,
361 CompileTimeErrorCode.MIXIN_HAS_NO_CONSTRUCTORS, 360 CompileTimeErrorCode.MIXIN_HAS_NO_CONSTRUCTORS,
362 [superElement.name])); 361 [superType.element.name]));
363 } else { 362 } else {
364 classElement.constructors = implicitConstructors; 363 classElement.constructors = implicitConstructors;
365 } 364 }
366 } 365 }
367 outputs[CONSTRUCTORS] = classElement.constructors; 366 outputs[CONSTRUCTORS] = classElement.constructors;
368 outputs[CONSTRUCTORS_ERRORS] = errors; 367 outputs[CONSTRUCTORS_ERRORS] = errors;
369 } 368 }
370 // 369 //
371 // ClassDeclaration 370 // ClassDeclaration
372 // 371 //
373 if (!classElement.isTypedef) { 372 if (!classElement.isTypedef) {
374 bool constructorFound = false; 373 bool constructorFound = false;
375 void callback(ConstructorElement explicitConstructor, 374 void callback(ConstructorElement explicitConstructor,
376 List<DartType> parameterTypes, List<DartType> argumentTypes) { 375 List<DartType> parameterTypes, List<DartType> argumentTypes) {
377 constructorFound = true; 376 constructorFound = true;
378 } 377 }
379 if (_findForwardedConstructors(classElement, superType, callback) && 378 if (_findForwardedConstructors(classElement, superType, callback) &&
380 !constructorFound) { 379 !constructorFound) {
381 SourceRange withRange = classElement.withClauseRange; 380 SourceRange withRange = classElement.withClauseRange;
382 errors.add(new AnalysisError.con2(classElement.source, withRange.offset, 381 errors.add(new AnalysisError.con2(classElement.source, withRange.offset,
383 withRange.length, CompileTimeErrorCode.MIXIN_HAS_NO_CONSTRUCTORS, 382 withRange.length, CompileTimeErrorCode.MIXIN_HAS_NO_CONSTRUCTORS,
384 [superElement.name])); 383 [superType.element.name]));
385 classElement.mixinErrorsReported = true; 384 classElement.mixinErrorsReported = true;
386 } 385 }
387 outputs[CONSTRUCTORS] = classElement.constructors; 386 outputs[CONSTRUCTORS] = classElement.constructors;
388 outputs[CONSTRUCTORS_ERRORS] = errors; 387 outputs[CONSTRUCTORS_ERRORS] = errors;
389 } 388 }
390 } 389 }
391 390
392 /** 391 /**
393 * Return a map from the names of the inputs of this kind of task to the task 392 * Return a map from the names of the inputs of this kind of task to the task
394 * input descriptors describing those inputs for a task with the 393 * input descriptors describing those inputs for a task with the
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 type.typeArguments = classType.typeArguments; 461 type.typeArguments = classType.typeArguments;
463 implicitConstructor.type = type; 462 implicitConstructor.type = type;
464 return implicitConstructor; 463 return implicitConstructor;
465 } 464 }
466 465
467 /** 466 /**
468 * Find all the constructors that should be forwarded from the given 467 * Find all the constructors that should be forwarded from the given
469 * [superType], to the class or mixin application [classElement], 468 * [superType], to the class or mixin application [classElement],
470 * and pass information about them to [callback]. 469 * and pass information about them to [callback].
471 * 470 *
472 * Return true if some constructors were considered. (A false return value 471 * Return `true` if some constructors were considered. (A `false` return value
473 * can only happen if the supeclass is a built-in type, in which case it 472 * can only happen if the supeclass is a built-in type, in which case it
474 * can't be used as a mixin anyway). 473 * can't be used as a mixin anyway).
475 */ 474 */
476 static bool _findForwardedConstructors(ClassElementImpl classElement, 475 static bool _findForwardedConstructors(ClassElementImpl classElement,
477 InterfaceType superType, void callback( 476 InterfaceType superType, void callback(
478 ConstructorElement explicitConstructor, List<DartType> parameterTypes, 477 ConstructorElement explicitConstructor, List<DartType> parameterTypes,
479 List<DartType> argumentTypes)) { 478 List<DartType> argumentTypes)) {
479 if (superType == null) {
480 return false;
481 }
480 ClassElement superclassElement = superType.element; 482 ClassElement superclassElement = superType.element;
481 List<ConstructorElement> constructors = superclassElement.constructors; 483 List<ConstructorElement> constructors = superclassElement.constructors;
482 int count = constructors.length; 484 int count = constructors.length;
483 if (count == 0) { 485 if (count == 0) {
484 return false; 486 return false;
485 } 487 }
486 List<DartType> parameterTypes = 488 List<DartType> parameterTypes =
487 TypeParameterTypeImpl.getTypes(superType.typeParameters); 489 TypeParameterTypeImpl.getTypes(superType.typeParameters);
488 List<DartType> argumentTypes = _getArgumentTypes(superType, parameterTypes); 490 List<DartType> argumentTypes = _getArgumentTypes(superType, parameterTypes);
489 for (int i = 0; i < count; i++) { 491 for (int i = 0; i < count; i++) {
(...skipping 2112 matching lines...) Expand 10 before | Expand all | Expand 10 after
2602 @override 2604 @override
2603 bool moveNext() { 2605 bool moveNext() {
2604 if (_newSources.isEmpty) { 2606 if (_newSources.isEmpty) {
2605 return false; 2607 return false;
2606 } 2608 }
2607 currentTarget = _newSources.first; 2609 currentTarget = _newSources.first;
2608 _newSources.remove(currentTarget); 2610 _newSources.remove(currentTarget);
2609 return true; 2611 return true;
2610 } 2612 }
2611 } 2613 }
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