| Index: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/TypeResolverVisitor.java
|
| diff --git a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/TypeResolverVisitor.java b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/TypeResolverVisitor.java
|
| index 859188a76877da5d2bf40b843705b0be834f81e9..f2b06f88c1658dc92254bb36ea14d75ac61bf3dc 100644
|
| --- a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/TypeResolverVisitor.java
|
| +++ b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/TypeResolverVisitor.java
|
| @@ -48,6 +48,7 @@ import com.google.dart.engine.ast.VariableDeclarationList;
|
| import com.google.dart.engine.ast.WithClause;
|
| import com.google.dart.engine.ast.visitor.UnifyingASTVisitor;
|
| import com.google.dart.engine.element.ClassElement;
|
| +import com.google.dart.engine.element.ConstructorElement;
|
| import com.google.dart.engine.element.Element;
|
| import com.google.dart.engine.element.FieldElement;
|
| import com.google.dart.engine.element.FieldFormalParameterElement;
|
| @@ -66,6 +67,7 @@ import com.google.dart.engine.error.ErrorCode;
|
| import com.google.dart.engine.error.StaticTypeWarningCode;
|
| import com.google.dart.engine.error.StaticWarningCode;
|
| import com.google.dart.engine.internal.element.ClassElementImpl;
|
| +import com.google.dart.engine.internal.element.ConstructorElementImpl;
|
| import com.google.dart.engine.internal.element.ExecutableElementImpl;
|
| import com.google.dart.engine.internal.element.FunctionTypeAliasElementImpl;
|
| import com.google.dart.engine.internal.element.LocalVariableElementImpl;
|
| @@ -79,6 +81,7 @@ import com.google.dart.engine.internal.type.DynamicTypeImpl;
|
| import com.google.dart.engine.internal.type.FunctionTypeImpl;
|
| import com.google.dart.engine.internal.type.InterfaceTypeImpl;
|
| import com.google.dart.engine.internal.type.TypeImpl;
|
| +import com.google.dart.engine.internal.type.TypeParameterTypeImpl;
|
| import com.google.dart.engine.internal.type.VoidTypeImpl;
|
| import com.google.dart.engine.scanner.Keyword;
|
| import com.google.dart.engine.scanner.Token;
|
| @@ -256,6 +259,31 @@ public class TypeResolverVisitor extends ScopedVisitor {
|
| }
|
| if (classElement != null && superclassType != null) {
|
| classElement.setSupertype(superclassType);
|
| + ClassElement superclassElement = superclassType.getElement();
|
| + if (superclassElement != null) {
|
| + ConstructorElement[] constructors = superclassElement.getConstructors();
|
| + int count = constructors.length;
|
| + if (count > 0) {
|
| + Type[] parameterTypes = TypeParameterTypeImpl.getTypes(superclassType.getTypeParameters());
|
| + Type[] argumentTypes = getArgumentTypes(
|
| + node.getSuperclass().getTypeArguments(),
|
| + parameterTypes);
|
| + InterfaceType classType = classElement.getType();
|
| + ArrayList<ConstructorElement> implicitConstructors = new ArrayList<ConstructorElement>(
|
| + count);
|
| + for (int i = 0; i < count; i++) {
|
| + ConstructorElement explicitConstructor = constructors[i];
|
| + if (!explicitConstructor.isFactory()) {
|
| + implicitConstructors.add(createImplicitContructor(
|
| + classType,
|
| + explicitConstructor,
|
| + parameterTypes,
|
| + argumentTypes));
|
| + }
|
| + }
|
| + classElement.setConstructors(implicitConstructors.toArray(new ConstructorElement[implicitConstructors.size()]));
|
| + }
|
| + }
|
| }
|
| resolve(classElement, node.getWithClause(), node.getImplementsClause());
|
| return null;
|
| @@ -761,6 +789,79 @@ public class TypeResolverVisitor extends ScopedVisitor {
|
| }
|
|
|
| /**
|
| + * Create an implicit constructor that is copied from the given constructor, but that is in the
|
| + * given class.
|
| + *
|
| + * @param classType the class in which the implicit constructor is defined
|
| + * @param explicitConstructor the constructor on which the implicit constructor is modeled
|
| + * @param parameterTypes the types to be replaced when creating parameters
|
| + * @param argumentTypes the types with which the parameters are to be replaced
|
| + * @return the implicit constructor that was created
|
| + */
|
| + private ConstructorElement createImplicitContructor(InterfaceType classType,
|
| + ConstructorElement explicitConstructor, Type[] parameterTypes, Type[] argumentTypes) {
|
| + ConstructorElementImpl implicitConstructor = new ConstructorElementImpl(
|
| + explicitConstructor.getName(),
|
| + -1);
|
| + implicitConstructor.setSynthetic(true);
|
| + implicitConstructor.setConst(explicitConstructor.isConst());
|
| + implicitConstructor.setReturnType(classType);
|
| + ParameterElement[] explicitParameters = explicitConstructor.getParameters();
|
| + int count = explicitParameters.length;
|
| + if (count > 0) {
|
| + ParameterElement[] implicitParameters = new ParameterElement[count];
|
| + for (int i = 0; i < count; i++) {
|
| + ParameterElement explicitParameter = explicitParameters[i];
|
| + ParameterElementImpl implicitParameter = new ParameterElementImpl(
|
| + explicitParameter.getName(),
|
| + -1);
|
| + implicitParameter.setConst(explicitParameter.isConst());
|
| + implicitParameter.setFinal(explicitParameter.isFinal());
|
| + implicitParameter.setParameterKind(explicitParameter.getParameterKind());
|
| + implicitParameter.setSynthetic(true);
|
| + implicitParameter.setType(explicitParameter.getType().substitute(
|
| + argumentTypes,
|
| + parameterTypes));
|
| + implicitParameters[i] = implicitParameter;
|
| + }
|
| + implicitConstructor.setParameters(implicitParameters);
|
| + }
|
| + FunctionTypeImpl type = new FunctionTypeImpl(implicitConstructor);
|
| + type.setTypeArguments(classType.getTypeArguments());
|
| + implicitConstructor.setType(type);
|
| + return implicitConstructor;
|
| + }
|
| +
|
| + /**
|
| + * Return an array of argument types that corresponds to the array of parameter types and that are
|
| + * derived from the given list of type arguments.
|
| + *
|
| + * @param typeArguments the type arguments from which the types will be taken
|
| + * @param parameterTypes the parameter types that must be matched by the type arguments
|
| + * @return the argument types that correspond to the parameter types
|
| + */
|
| + private Type[] getArgumentTypes(TypeArgumentList typeArguments, Type[] parameterTypes) {
|
| + DynamicTypeImpl dynamic = DynamicTypeImpl.getInstance();
|
| + int parameterCount = parameterTypes.length;
|
| + Type[] types = new Type[parameterCount];
|
| + if (typeArguments == null) {
|
| + for (int i = 0; i < parameterCount; i++) {
|
| + types[i] = dynamic;
|
| + }
|
| + } else {
|
| + NodeList<TypeName> arguments = typeArguments.getArguments();
|
| + int argumentCount = arguments.size();
|
| + for (int i = 0; i < argumentCount; i++) {
|
| + types[i] = arguments.get(i).getType();
|
| + }
|
| + for (int i = argumentCount; i < parameterCount; i++) {
|
| + types[i] = dynamic;
|
| + }
|
| + }
|
| + return types;
|
| + }
|
| +
|
| + /**
|
| * Return the class element that represents the class whose name was provided.
|
| *
|
| * @param identifier the name from the declaration of a class
|
|
|