fabiomfv@google.com 2011-11-01 18:42:54 +00:00
parent 74866724b7
commit ec78d3fce6
5 changed files with 11 additions and 8 deletions

View file

@ -870,7 +870,7 @@ public class DartParser extends CompletionHooksParserBase {
modifiers = modifiers.makeNative();
function = new DartFunction(formals, parseNativeBlock(modifiers), null);
} else {
function = new DartFunction(formals, parseBlock(), null);
function = new DartFunction(formals, parseFunctionStatementBody(true), null);
}
doneWithoutConsuming(function);
return DartMethodDefinition.create(name, function, modifiers, null, typeParameters);

View file

@ -113,6 +113,7 @@ public class MemberBuilder {
case NONE:
case CONSTRUCTOR:
element = buildConstructor(method);
checkConstructor(element, method);
addConstructor((ClassElement) currentHolder, (ConstructorElement) element);
break;
@ -429,6 +430,13 @@ public class MemberBuilder {
// example const and missing body.
}
private void checkConstructor(MethodElement element, DartMethodDefinition method) {
if (Elements.isNonFactoryConstructor(element) && method.getFunction() != null
&& method.getFunction().getReturnTypeNode() != null) {
resolutionError(method, ResolverErrorCode.CONSTRUCTOR_CANNOT_HAVE_RETURN_TYPE);
}
}
private void checkUniqueName(EnclosingElement holder, Element e) {
Element other = lookupElementByName(holder, e.getName(), e.getModifiers());
assert e != other : "forgot to call checkUniqueName() before adding to the class?";

View file

@ -33,6 +33,7 @@ public enum ResolverErrorCode implements ErrorCode {
"super type %s does not have a default constructor"),
CONSTRUCTOR_CANNOT_BE_ABSTRACT("A constructor cannot be asbstract"),
CONSTRUCTOR_CANNOT_BE_STATIC("A constructor cannot be static"),
CONSTRUCTOR_CANNOT_HAVE_RETURN_TYPE("Generative constructors cannot have return type"),
CONST_CONSTRUCTOR_CANNOT_HAVE_BODY("A const constructor cannot have a body"),
CONST_CONSTRUCTOR_MUST_CALL_CONST_SUPER("const constructor must call const super constructor"),
CONSTANTS_MUST_BE_INITIALIZED("constants must be initialized"),

View file

@ -34,17 +34,14 @@ LangGuideTest/02_Language_Constructs/02_11_Exceptions/A09/t02: Fail # Issue 219
LangGuideTest/02_Language_Constructs/02_1_Class/02_1_Class_Const_Expressions/A04/t01: Fail # Bug 5371670.
LangGuideTest/02_Language_Constructs/02_1_Class/02_1_Class_Const_Expressions/A02/t01: Fail # Bug 5371670.
LangGuideTest/02_Language_Constructs/02_1_Class/02_1_Class_Construction/A02/t02: Fail # Bug 5371670.
LangGuideTest/02_Language_Constructs/02_1_Class/02_1_Class_Construction/A02/t03: Fail # Bug 5371670.
LangGuideTest/02_Language_Constructs/02_1_Class/02_1_Class_Construction/A02/t04: Fail # Bug 5371670.
LangGuideTest/02_Language_Constructs/02_1_Class/02_1_Class_Construction/A03/t01: Fail # Bug 5371670.
LangGuideTest/02_Language_Constructs/02_1_Class/02_1_Class_Construction/A06/t04: Fail # Bug 5371670.
LangGuideTest/02_Language_Constructs/02_1_Class/02_1_Class_Construction/A10/t01: Fail # Bug 5371670.
LangGuideTest/02_Language_Constructs/02_1_Class/02_1_Class_Construction/A13/t01: Fail # Bug 5371670.
LangGuideTest/02_Language_Constructs/02_1_Class/02_1_Class_Construction/A18/t01: Fail # Bug 5371670.
LangGuideTest/02_Language_Constructs/02_2_Interface/A02/t03: Fail # Bug 5371670.
LangGuideTest/02_Language_Constructs/02_7_Abstract_Methods/A02/t01: Fail # Bug 5371670.
LangGuideTest/07_Overriding/A02/t01: Fail # Bug 5371670.
LangGuideTest/07_Overriding/A02/t02: Fail # Bug 5371670.
LangGuideTest/07_Overriding/A05/t01: Fail # Bug 5371670.
@ -177,7 +174,6 @@ LibTest/core/List/List.fromList/*: Fail
# New problems on 2011-11-01.
[ $component == dartc ]
LangGuideTest/02_Language_Constructs/02_1_Class/02_1_Class_Construction/A02/t01: Fail
LangSpecTest/13_Types/13_1_Static_Types/A04/t01: Fail
LangSpecTest/13_Types/13_2_Dynamic_Type_System/A01/t01: Fail
LangSpecTest/13_Types/13_2_Dynamic_Type_System/A01/t02: Fail

View file

@ -158,8 +158,6 @@ BlackListedTest/10: Fail # Bug 5469684
BlackListedTest/11: Fail # Bug 5469684
BlackListedTest/12: Fail # Bug 5469684
FactoryArrowTest: Fail # Issue 223
# VM specific tests that should not be run by DartC.
*VMTest: Skip