Fixed: When the compiler can't find a protocol in a class declaration it now gives an understandable error.

This fixes #2212
This commit is contained in:
Martin Carlberg
2014-09-16 20:13:42 +02:00
parent b9b396a279
commit 13fe318110
+11 -3
View File
@@ -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);