| Index: compiler/java/com/google/dart/compiler/resolver/Resolver.java
|
| diff --git a/compiler/java/com/google/dart/compiler/resolver/Resolver.java b/compiler/java/com/google/dart/compiler/resolver/Resolver.java
|
| index b95c72624f1fd0c379217c77478a361b7943534f..ae97c70238e2b69e5d62028328f970d78fa49228 100644
|
| --- a/compiler/java/com/google/dart/compiler/resolver/Resolver.java
|
| +++ b/compiler/java/com/google/dart/compiler/resolver/Resolver.java
|
| @@ -84,7 +84,6 @@ import com.google.dart.compiler.type.Type;
|
| import com.google.dart.compiler.type.TypeKind;
|
| import com.google.dart.compiler.type.TypeVariable;
|
| import com.google.dart.compiler.type.Types;
|
| -import com.google.dart.compiler.util.apache.StringUtils;
|
|
|
| import java.util.EnumSet;
|
| import java.util.Iterator;
|
| @@ -374,14 +373,6 @@ public class Resolver {
|
|
|
| // Make sure the default class matches the interface type parameters
|
| checkInterfaceTypeParamsToDefault(classElement, defaultClass);
|
| -
|
| - // Check that interface constructors have corresponding methods in default class.
|
| - checkInterfaceConstructors(classElement);
|
| - } else if (classElement.isInterface() && classElement.getConstructors() != null) {
|
| - for (ConstructorElement interfaceConstructor : classElement.getConstructors()) {
|
| - onError(interfaceConstructor.getNameLocation(),
|
| - ResolverErrorCode.ILLEGAL_CONSTRUCTOR_NO_DEFAULT_IN_INTERFACE);
|
| - }
|
| }
|
|
|
| if (!classElement.isInterface() && Elements.needsImplicitDefaultConstructor(classElement)) {
|
| @@ -545,57 +536,6 @@ public class Resolver {
|
| }
|
|
|
| /**
|
| - * Checks that interface constructors have corresponding methods in default class.
|
| - */
|
| - private void checkInterfaceConstructors(ClassElement interfaceElement) {
|
| - String interfaceClassName = interfaceElement.getName();
|
| - String defaultClassName = interfaceElement.getDefaultClass().getElement().getName();
|
| -
|
| - for (ConstructorElement interfaceConstructor : interfaceElement.getConstructors()) {
|
| - ConstructorElement defaultConstructor =
|
| - resolveInterfaceConstructorInDefaultClass(
|
| - interfaceConstructor,
|
| - interfaceConstructor);
|
| - if (defaultConstructor != null) {
|
| - // Remember for TypeAnalyzer.
|
| - interfaceConstructor.setDefaultConstructor(defaultConstructor);
|
| - // Validate number of required parameters.
|
| - {
|
| - int numReqInterface = Elements.getNumberOfRequiredParameters(interfaceConstructor);
|
| - int numReqDefault = Elements.getNumberOfRequiredParameters(defaultConstructor);
|
| - if (numReqInterface != numReqDefault) {
|
| - onError(
|
| - interfaceConstructor,
|
| - ResolverErrorCode.DEFAULT_CONSTRUCTOR_NUMBER_OF_REQUIRED_PARAMETERS,
|
| - Elements.getRawMethodName(interfaceConstructor),
|
| - interfaceClassName,
|
| - numReqInterface,
|
| - Elements.getRawMethodName(defaultConstructor),
|
| - defaultClassName,
|
| - numReqDefault);
|
| - }
|
| - }
|
| - // Validate names of named parameters.
|
| - {
|
| - List<String> interfaceNames = Elements.getNamedParameters(interfaceConstructor);
|
| - List<String> defaultNames = Elements.getNamedParameters(defaultConstructor);
|
| - if (!interfaceNames.equals(defaultNames)) {
|
| - onError(
|
| - interfaceConstructor,
|
| - ResolverErrorCode.DEFAULT_CONSTRUCTOR_NAMED_PARAMETERS,
|
| - Elements.getRawMethodName(interfaceConstructor),
|
| - interfaceClassName,
|
| - interfaceNames,
|
| - Elements.getRawMethodName(defaultConstructor),
|
| - defaultClassName,
|
| - defaultNames);
|
| - }
|
| - }
|
| - }
|
| - }
|
| - }
|
| -
|
| - /**
|
| * Returns <code>true</code> if the {@link ClassElement} has an implicit or a declared
|
| * default constructor.
|
| */
|
| @@ -1696,9 +1636,6 @@ public class Resolver {
|
| // Will check that element is not null.
|
| ConstructorElement constructor = checkIsConstructor(x, element);
|
|
|
| - // try to lookup the constructor in the default class.
|
| - constructor = resolveInterfaceConstructorInDefaultClass(x.getConstructor(), constructor);
|
| -
|
| // Check constructor.
|
| if (constructor != null) {
|
| boolean constConstructor = constructor.getModifiers().isConstant();
|
| @@ -1721,87 +1658,6 @@ public class Resolver {
|
| return recordElement(x, constructor);
|
| }
|
|
|
| - /**
|
| - * If given {@link ConstructorElement} is declared in interface, try to resolve it in
|
| - * corresponding default class.
|
| - *
|
| - * @return the resolved {@link ConstructorElement}, or same as given.
|
| - */
|
| - private ConstructorElement resolveInterfaceConstructorInDefaultClass(HasSourceInfo errorTarget,
|
| - ConstructorElement constructor) {
|
| - // If no default class, use existing constructor.
|
| - if (constructor == null || constructor.getConstructorType().getDefaultClass() == null) {
|
| - return constructor;
|
| - }
|
| - // Prepare elements and names for classes.
|
| - ClassElement originalClass = constructor.getConstructorType();
|
| - ClassElement defaultClass = originalClass.getDefaultClass().getElement();
|
| - String originalClassName = originalClass.getName();
|
| - String defaultClassName = defaultClass.getName();
|
| - // Prepare "qualifier.name" for original constructor.
|
| - String rawOriginalMethodName = Elements.getRawMethodName(constructor);
|
| - int originalDotIndex = rawOriginalMethodName.indexOf('.');
|
| - String originalQualifier = StringUtils.substringBefore(rawOriginalMethodName, ".");
|
| - String originalName = StringUtils.substringAfter(rawOriginalMethodName, ".");
|
| - // Separate checks for cases when factory implements interface and not.
|
| - boolean factoryImplementsInterface = Elements.implementsType(defaultClass, originalClass);
|
| - if (factoryImplementsInterface) {
|
| - for (ConstructorElement defaultConstructor : defaultClass.getConstructors()) {
|
| - String rawDefaultMethodName = Elements.getRawMethodName(defaultConstructor);
|
| - // kI == nI and kF == nF
|
| - if (rawOriginalMethodName.equals(originalClassName)
|
| - && rawDefaultMethodName.equals(defaultClassName)) {
|
| - return defaultConstructor;
|
| - }
|
| - // kI == nI.name and kF == nF.name
|
| - if (originalDotIndex != -1) {
|
| - int defaultDotIndex = rawDefaultMethodName.indexOf('.');
|
| - if (defaultDotIndex != -1) {
|
| - String defaultQualifier = StringUtils.substringBefore(rawDefaultMethodName, ".");
|
| - String defaultName = StringUtils.substringAfter(rawDefaultMethodName, ".");
|
| - if (defaultQualifier.equals(defaultClassName)
|
| - && originalQualifier.equals(originalClassName)
|
| - && defaultName.equals(originalName)) {
|
| - return defaultConstructor;
|
| - }
|
| - }
|
| - }
|
| - }
|
| - } else {
|
| - for (ConstructorElement defaultConstructor : defaultClass.getConstructors()) {
|
| - String rawDefaultMethodName = Elements.getRawMethodName(defaultConstructor);
|
| - if (rawDefaultMethodName.equals(rawOriginalMethodName)) {
|
| - return defaultConstructor;
|
| - }
|
| - }
|
| - }
|
| - // If constructor not found, try implicit default constructor of the default class.
|
| - if (Elements.isDefaultConstructor(constructor)
|
| - && (Elements.isSyntheticConstructor(constructor) || factoryImplementsInterface)
|
| - && Elements.needsImplicitDefaultConstructor(defaultClass)) {
|
| - return new SyntheticDefaultConstructorElement(null, defaultClass, typeProvider);
|
| - }
|
| - // Factory constructor not resolved, report error with specific message for each case.
|
| - {
|
| - String expectedFactoryConstructorName;
|
| - if (factoryImplementsInterface) {
|
| - if (originalDotIndex == -1) {
|
| - expectedFactoryConstructorName = defaultClassName;
|
| - } else {
|
| - expectedFactoryConstructorName = defaultClassName + "." + originalName;
|
| - }
|
| - } else {
|
| - expectedFactoryConstructorName = rawOriginalMethodName;
|
| - }
|
| - onError(
|
| - errorTarget,
|
| - ResolverErrorCode.DEFAULT_CONSTRUCTOR_UNRESOLVED,
|
| - expectedFactoryConstructorName,
|
| - defaultClassName);
|
| - return null;
|
| - }
|
| - }
|
| -
|
| @Override
|
| public Element visitGotoStatement(DartGotoStatement x) {
|
| // Don't bother unless there's a target.
|
|
|