mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-08-25 04:57:03 +00:00
Fixed: Compiler can now handle only @action/IBAction declared return type when checking for 'Conflicting return type' method declaration.
Also made the warning message point to correct return type token when type is not declared.
This commit is contained in:
@@ -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];
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user