diff --git a/Objective-J/ObjJAcornCompiler.js b/Objective-J/ObjJAcornCompiler.js index 39685ca3d..61318fbc5 100644 --- a/Objective-J/ObjJAcornCompiler.js +++ b/Objective-J/ObjJAcornCompiler.js @@ -2029,12 +2029,13 @@ MethodDeclarationStatement: function(node, st, c) { var typeSize = declaredTypes.length; if (typeSize > 0) { // First type is return type - var returnType = declaredTypes[0]; + var declaredReturnType = declaredTypes[0]; - if (returnType !== types[0] && !(returnType === 'id' && node.returntype.typeisclass)) - compiler.addWarning(createMessage("Conflicting return type in implementation of '" + selector + "': '" + returnType + "' vs '" + types[0] + "'", node.returntype || node, compiler.source)); + // Create warning if return types is not the same. It is ok if superclass has 'id' and subclass has a class type + if (declaredReturnType !== types[0] && !(declaredReturnType === 'id' && returnType && returnType.typeisclass)) + compiler.addWarning(createMessage("Conflicting return type in implementation of '" + selector + "': '" + declaredReturnType + "' vs '" + types[0] + "'", returnType || node.action || selectors[0], compiler.source)); - // Check the parameter types. The size of the two type arrays should be the same + // Check the parameter types. The size of the two type arrays should be the same as they have the same selector. for (var i = 1; i < typeSize; i++) { var parameterType = declaredTypes[i]; diff --git a/Objective-J/acorn.js b/Objective-J/acorn.js index 445984be6..f12994057 100644 --- a/Objective-J/acorn.js +++ b/Objective-J/acorn.js @@ -2369,10 +2369,13 @@ var preIfLevel = 0; expect(_plusmin, "Method declaration must start with '+' or '-'"); // If we find a '(' we have a return type to parse if (eat(_parenL)) { - if (eat(_action)) - node.action = true; + var typeNode = startNode(); + if (eat(_action)) { + node.action = finishNode(typeNode, "ObjectiveJActionType"); + typeNode = startNode(); + } if (!eat(_parenR)) { - node.returntype = parseObjectiveJType(); + node.returntype = parseObjectiveJType(typeNode); expect(_parenR, "Expected closing ')' after method return type"); } } @@ -3010,8 +3013,8 @@ var preIfLevel = 0; // It can be 'char', 'byte', 'short', 'int' or 'long' // 'int' can be followed by an optinal 'long'. 'long' can be followed by an optional extra 'long' - function parseObjectiveJType() { - var node = startNode(); + function parseObjectiveJType(startFrom) { + var node = startFrom ? startNodeFrom(startFrom) : startNode(); if (tokType === _name) { // It should be a class name node.name = tokVal;