Fix for classes that are the default factory for multiple other classes/interfaces.

BUG=5009110

Review URL: https://chromereviews.googleplex.com/3522018

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@47 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
jgw@google.com 2011-10-05 16:25:25 +00:00
parent 288938bd88
commit da2581daa9
6 changed files with 12 additions and 8 deletions

View file

@ -218,7 +218,6 @@ LangGuideTest/02_Language_Constructs/02_11_Exceptions/A05/t01: Fail
LangGuideTest/02_Language_Constructs/02_1_Class/02_1_Class_Construction/A05/t01: Fail
LangGuideTest/02_Language_Constructs/02_1_Class/02_1_Class_Construction/A12/t01: Fail
LangGuideTest/02_Language_Constructs/02_1_Class/02_1_Class_Construction/A12/t02: Fail
LangGuideTest/02_Language_Constructs/02_1_Class/02_1_Class_Construction/A16/t02: Fail
LangGuideTest/02_Language_Constructs/02_1_Class/A02/t04: Skip # Times out.
LangGuideTest/02_Language_Constructs/02_5_Meaning_of_Names/A02/t02: Fail
LangGuideTest/02_Language_Constructs/02_6_Functions/A04/t01: Fail

View file

@ -136,7 +136,7 @@ public enum DartCompilerErrorCode implements ErrorCode {
MULTIPLE_REST_PARAMETERS("multiple rest parameters"),
MULTIPLE_SOURCE_LISTS("'source' may be specified only once"),
NAMED_AND_VARIADIC_PARAMETERS("Cannot have both named and variadic parameters"),
NAME_CLASSES_EXISTING_MEMBER("name clashes with another previously defined member"),
NAME_CLASSES_EXISTING_MEMBER("name clashes with a previously defined member"),
NEW_EXPRESSION_NOT_CONSTRUCTOR("New expression does not resolve to a constructor"),
NON_CONST_STATIC_MEMBER_IN_INTERFACE("SyntaxError: non-final static members are not allowed in "
+ "interfaces"),

View file

@ -967,8 +967,7 @@ public class GenerateJavascriptAST {
// The factory becomes a member of <class> and should therefore be declared in the same
// scope as all other members.
String className = element.getConstructorType().getName();
String factoryName = mangler.createFactorySyntax(className, constructorName,
unitLibrary);
String factoryName = mangler.createFactorySyntax(className, constructorName, unitLibrary);
JsName factoryJsName =
classMemberScope.declareName(factoryName, factoryName, constructorName);
// Factories are globally accessible.
@ -2661,7 +2660,7 @@ public class GenerateJavascriptAST {
@Override
public JsNode visitNewExpression(DartNewExpression x) {
ConstructorElement element = x.getSymbol();
String className = element.getEnclosingElement().getName();
String className = element.getConstructorType().getName();
// TODO(floitsch): We should have a JsNames instead of creating the string representations.
String name = mangler.createFactorySyntax(className, element.getName(), unitLibrary);
// We add the class name of the holder of the constructor as a qualifier.

View file

@ -100,7 +100,7 @@ class GenerateNamesAndScopes extends NormalizedVisitor {
return generateConstructorName(x);
}
if (x.getModifiers().isFactory()) {
String className = element.getEnclosingElement().getName();
String className = ((ConstructorElement) element).getConstructorType().getName();
String name = translationContext.getMangler().createFactorySyntax(className, element.getName(), unitLibrary);
JsName jsName = function(x.getSymbol(), name, element.getName(), x.getFunction());
// Factories are globally accessible.

View file

@ -421,6 +421,14 @@ public class MemberBuilder {
return;
}
// Both can be constructors, as long as they're for different classes.
if (oIsConstructor && eIsConstructor) {
if (((ConstructorElement) e).getConstructorType() !=
((ConstructorElement) other).getConstructorType()) {
return;
}
}
boolean eIsOperator = e.getModifiers().isOperator();
boolean oIsOperator = other.getModifiers().isOperator();
if (oIsOperator != eIsOperator) {

View file

@ -65,7 +65,6 @@ Switch3NegativeTest: Crash # Bug 5318228
[ $arch == dartc || $arch == chromium ]
Prefix11NegativeTest: Fail # Bug 5406175
Prefix12NegativeTest: Fail,Crash # Bug 5406175
DefaultFactoryTest: Fail # Bug 5009110
FunctionTypeParameterNegativeTest: Fail # Bug 4568007
ImplicitScopeTest: FAIL # Nested statements can be declarations
ResolveTest: FAIL # 4254120 (implicit constructors)
@ -91,7 +90,6 @@ InstFieldInitializerTest: Fail # Cannot deal with static final values in c
RegExp3Test: Fail # 5299683
InterfaceFactory3NegativeTest: Fail # 5387405
GenericParameterizedExtendsTest: Skip # Bug 5392297
InterfaceFactoryMultiTest: Fail # Bug 5399939
ConstObjectsAreImmutableTest: Fail # Bug 5202940
# Crashes in dartc.