From 13fe318110af1d7b459daab22db09bae082ff0ca Mon Sep 17 00:00:00 2001 From: Martin Carlberg Date: Tue, 16 Sep 2014 20:13:42 +0200 Subject: [PATCH] Fixed: When the compiler can't find a protocol in a class declaration it now gives an understandable error. This fixes #2212 --- Objective-J/ObjJAcornCompiler.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Objective-J/ObjJAcornCompiler.js b/Objective-J/ObjJAcornCompiler.js index e1cf72b07..8aacfa23c 100644 --- a/Objective-J/ObjJAcornCompiler.js +++ b/Objective-J/ObjJAcornCompiler.js @@ -1778,7 +1778,8 @@ ClassDeclarationStatement: function(node, st, c) { var getterSetterBuffer = new StringBuffer(); // Add the class declaration to compile accessors correctly - getterSetterBuffer.concat(compiler.source.substring(node.start, node.endOfIvars)); + // Remove all protocols from class declaration + getterSetterBuffer.concat(compiler.source.substring(node.start, node.endOfIvars).replace(/<.*>/g, "")); getterSetterBuffer.concat("\n"); for (var i = 0; i < node.ivardeclarations.length; ++i) @@ -1893,8 +1894,15 @@ ClassDeclarationStatement: function(node, st, c) { // Lookup the protocolDefs for the protocols var protocolDefs = []; - for (var i = 0, size = protocols.length; i < size; i++) - protocolDefs.push(compiler.getProtocolDef(protocols[i].name)); + for (var i = 0, size = protocols.length; i < size; i++) { + var protocol = protocols[i], + protocolDef = compiler.getProtocolDef(protocol.name); + + if (!protocolDef) + throw compiler.error_message("Cannot find protocol declaration for '" + protocol.name + "'", protocol); + + protocolDefs.push(protocolDef); + } var unimplementedMethods = classDef.listOfNotImplementedMethodsForProtocols(protocolDefs);