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

Side by Side Diff: pkg/analyzer/lib/src/generated/error_verifier.dart

Issue 724133003: Improve error reporting when a mixin application is invalid. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month 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
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 engine.resolver.error_verifier; 5 library engine.resolver.error_verifier;
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 'java_engine.dart'; 10 import 'java_engine.dart';
(...skipping 3978 matching lines...) Expand 10 before | Expand all | Expand 10 after
3989 3989
3990 /** 3990 /**
3991 * This checks that if the passed class declaration implicitly calls default c onstructor of its 3991 * This checks that if the passed class declaration implicitly calls default c onstructor of its
3992 * superclass, there should be such default constructor - implicit or explicit . 3992 * superclass, there should be such default constructor - implicit or explicit .
3993 * 3993 *
3994 * @param node the [ClassDeclaration] to evaluate 3994 * @param node the [ClassDeclaration] to evaluate
3995 * @return `true` if and only if an error code is generated on the passed node 3995 * @return `true` if and only if an error code is generated on the passed node
3996 * See [CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]. 3996 * See [CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT].
3997 */ 3997 */
3998 bool _checkForNoDefaultSuperConstructorImplicit(ClassDeclaration node) { 3998 bool _checkForNoDefaultSuperConstructorImplicit(ClassDeclaration node) {
3999 // do nothing if mixin errors have already been reported for this class.
4000 if (_enclosingClass.mixinErrorsReported) {
4001 return false;
4002 }
3999 // do nothing if there is explicit constructor 4003 // do nothing if there is explicit constructor
4000 List<ConstructorElement> constructors = _enclosingClass.constructors; 4004 List<ConstructorElement> constructors = _enclosingClass.constructors;
4001 if (!constructors[0].isSynthetic) { 4005 if (!constructors[0].isSynthetic) {
4002 return false; 4006 return false;
4003 } 4007 }
4004 // prepare super 4008 // prepare super
4005 InterfaceType superType = _enclosingClass.supertype; 4009 InterfaceType superType = _enclosingClass.supertype;
4006 if (superType == null) { 4010 if (superType == null) {
4007 return false; 4011 return false;
4008 } 4012 }
(...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after
4828 * invocation nor a redirecting constructor invocation, that the superclass ha s a default 4832 * invocation nor a redirecting constructor invocation, that the superclass ha s a default
4829 * generative constructor. 4833 * generative constructor.
4830 * 4834 *
4831 * @param node the constructor declaration to evaluate 4835 * @param node the constructor declaration to evaluate
4832 * @return `true` if and only if an error code is generated on the passed node 4836 * @return `true` if and only if an error code is generated on the passed node
4833 * See [CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER_DEFAULT], 4837 * See [CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER_DEFAULT],
4834 * [CompileTimeErrorCode.NON_GENERATIVE_CONSTRUCTOR], and 4838 * [CompileTimeErrorCode.NON_GENERATIVE_CONSTRUCTOR], and
4835 * [StaticWarningCode.NO_DEFAULT_SUPER_CONSTRUCTOR_EXPLICIT]. 4839 * [StaticWarningCode.NO_DEFAULT_SUPER_CONSTRUCTOR_EXPLICIT].
4836 */ 4840 */
4837 bool _checkForUndefinedConstructorInInitializerImplicit(ConstructorDeclaration node) { 4841 bool _checkForUndefinedConstructorInInitializerImplicit(ConstructorDeclaration node) {
4842 if (_enclosingClass == null) {
4843 return false;
4844 }
4845 // do nothing if mixin errors have already been reported for this class.
4846 if (_enclosingClass.mixinErrorsReported) {
4847 return false;
4848 }
4838 // 4849 //
4839 // Ignore if the constructor is not generative. 4850 // Ignore if the constructor is not generative.
4840 // 4851 //
4841 if (node.factoryKeyword != null) { 4852 if (node.factoryKeyword != null) {
4842 return false; 4853 return false;
4843 } 4854 }
4844 // 4855 //
4845 // Ignore if the constructor has either an implicit super constructor invoca tion or a 4856 // Ignore if the constructor has either an implicit super constructor invoca tion or a
4846 // redirecting constructor invocation. 4857 // redirecting constructor invocation.
4847 // 4858 //
4848 for (ConstructorInitializer constructorInitializer in node.initializers) { 4859 for (ConstructorInitializer constructorInitializer in node.initializers) {
4849 if (constructorInitializer is SuperConstructorInvocation || constructorIni tializer is RedirectingConstructorInvocation) { 4860 if (constructorInitializer is SuperConstructorInvocation || constructorIni tializer is RedirectingConstructorInvocation) {
4850 return false; 4861 return false;
4851 } 4862 }
4852 } 4863 }
4853 // 4864 //
4854 // Check to see whether the superclass has a non-factory unnamed constructor . 4865 // Check to see whether the superclass has a non-factory unnamed constructor .
4855 // 4866 //
4856 if (_enclosingClass == null) {
4857 return false;
4858 }
4859 InterfaceType superType = _enclosingClass.supertype; 4867 InterfaceType superType = _enclosingClass.supertype;
4860 if (superType == null) { 4868 if (superType == null) {
4861 return false; 4869 return false;
4862 } 4870 }
4863 ClassElement superElement = superType.element; 4871 ClassElement superElement = superType.element;
4864 ConstructorElement superUnnamedConstructor = superElement.unnamedConstructor ; 4872 ConstructorElement superUnnamedConstructor = superElement.unnamedConstructor ;
4865 if (superUnnamedConstructor != null) { 4873 if (superUnnamedConstructor != null) {
4866 if (superUnnamedConstructor.isFactory) { 4874 if (superUnnamedConstructor.isFactory) {
4867 _errorReporter.reportErrorForNode(CompileTimeErrorCode.NON_GENERATIVE_CO NSTRUCTOR, node.returnType, [superUnnamedConstructor]); 4875 _errorReporter.reportErrorForNode(CompileTimeErrorCode.NON_GENERATIVE_CO NSTRUCTOR, node.returnType, [superUnnamedConstructor]);
4868 return true; 4876 return true;
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after
5467 toCheck.add(type.element); 5475 toCheck.add(type.element);
5468 // type arguments 5476 // type arguments
5469 if (type is InterfaceType) { 5477 if (type is InterfaceType) {
5470 InterfaceType interfaceType = type; 5478 InterfaceType interfaceType = type;
5471 for (DartType typeArgument in interfaceType.typeArguments) { 5479 for (DartType typeArgument in interfaceType.typeArguments) {
5472 _addTypeToCheck(typeArgument); 5480 _addTypeToCheck(typeArgument);
5473 } 5481 }
5474 } 5482 }
5475 } 5483 }
5476 } 5484 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698