diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/qml/jsruntime/qv4runtime.cpp | 6 | ||||
| -rw-r--r-- | src/qml/jsruntime/qv4scopedvalue_p.h | 13 |
2 files changed, 18 insertions, 1 deletions
diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp index 87d8c70061..d82eebd1d2 100644 --- a/src/qml/jsruntime/qv4runtime.cpp +++ b/src/qml/jsruntime/qv4runtime.cpp @@ -1570,7 +1570,9 @@ ReturnedValue Runtime::method_createClass(ExecutionEngine *engine, int classInde QV4::Function *f = cls->constructorFunction != UINT_MAX ? unit->runtimeFunctions[cls->constructorFunction] : nullptr; constructor = FunctionObject::createConstructorFunction(current, f, !superClass.isEmpty())->asReturnedValue(); constructor->setPrototypeUnchecked(constructorParent); - constructor->defineDefaultProperty(engine->id_prototype(), proto); + Value argCount = Primitive::fromInt32(f ? f->nFormals : 0); + constructor->defineReadonlyConfigurableProperty(scope.engine->id_length(), argCount); + constructor->defineReadonlyConfigurableProperty(engine->id_prototype(), proto); proto->defineDefaultProperty(engine->id_constructor(), constructor); ScopedString name(scope); @@ -1589,6 +1591,8 @@ ReturnedValue Runtime::method_createClass(ExecutionEngine *engine, int classInde receiver = proto; if (methods[i].name == UINT_MAX) { propertyName = computedNames->toPropertyKey(engine); + if (propertyName == scope.engine->id_prototype()->propertyKey() && receiver->d() == constructor->d()) + return engine->throwTypeError(QStringLiteral("Cannot declare a static method named 'prototype'.")); if (engine->hasException) return Encode::undefined(); ++computedNames; diff --git a/src/qml/jsruntime/qv4scopedvalue_p.h b/src/qml/jsruntime/qv4scopedvalue_p.h index 1f66c4a47e..8ac2213492 100644 --- a/src/qml/jsruntime/qv4scopedvalue_p.h +++ b/src/qml/jsruntime/qv4scopedvalue_p.h @@ -268,6 +268,19 @@ struct ScopedPropertyKey return *ptr; } + bool operator==(const PropertyKey &other) const { + return *ptr == other; + } + bool operator==(const ScopedPropertyKey &other) const { + return *ptr == *other.ptr; + } + bool operator!=(const PropertyKey &other) const { + return *ptr != other; + } + bool operator!=(const ScopedPropertyKey &other) const { + return *ptr != *other.ptr; + } + PropertyKey *ptr; }; |
