diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-08-03 23:22:59 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-08-06 10:00:41 +0000 |
commit | 15ef80f1d92eb3a88dc135b4e6347f57a5982f9c (patch) | |
tree | 382bef078558dc1d5abcd0f5b79c809964310785 /src/qml/jsruntime/qv4runtime.cpp | |
parent | 6a85ec63a3a905e638b4f2e1e7cd92c17ad1a9f5 (diff) |
Fix some details in class initialization
Change-Id: Ib8a76362686f1bbba49daca59fa4a30773150103
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4runtime.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4runtime.cpp | 6 |
1 files changed, 5 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; |