Don't inherit metaclasses.

Also disallow super() in static methods. It won't do anything
useful (it always just delegates to Class) anyway.
This commit is contained in:
Bob Nystrom
2014-01-17 17:29:10 -08:00
parent 1d808cf49c
commit e8791b6bab
5 changed files with 20 additions and 42 deletions
+5 -8
View File
@@ -1645,14 +1645,7 @@ static void string(Compiler* compiler, bool allowAssignment)
// directly or indirectly contained in a method for a class.
static bool isInsideMethod(Compiler* compiler)
{
// Walk up the parent chain to see if there is an enclosing method.
while (compiler != NULL)
{
if (compiler->methodName != NULL) return true;
compiler = compiler->parent;
}
return false;
return compiler->fields != NULL;
}
static void new_(Compiler* compiler, bool allowAssignment)
@@ -1676,6 +1669,10 @@ static void super_(Compiler* compiler, bool allowAssignment)
{
error(compiler, "Cannot use 'super' outside of a method.");
}
else if (compiler->isStaticMethod)
{
error(compiler, "Cannot use 'super' in a static method.");
}
loadThis(compiler);