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 | |
parent | 6a85ec63a3a905e638b4f2e1e7cd92c17ad1a9f5 (diff) |
Fix some details in class initialization
Change-Id: Ib8a76362686f1bbba49daca59fa4a30773150103
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
-rw-r--r-- | src/qml/jsruntime/qv4runtime.cpp | 6 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4scopedvalue_p.h | 13 | ||||
-rw-r--r-- | tests/auto/qml/ecmascripttests/TestExpectations | 8 |
3 files changed, 18 insertions, 9 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; }; diff --git a/tests/auto/qml/ecmascripttests/TestExpectations b/tests/auto/qml/ecmascripttests/TestExpectations index b8243db29e..25693f7f47 100644 --- a/tests/auto/qml/ecmascripttests/TestExpectations +++ b/tests/auto/qml/ecmascripttests/TestExpectations @@ -1726,13 +1726,9 @@ built-ins/global/global-object.js fails built-ins/global/property-descriptor.js fails built-ins/isFinite/toprimitive-not-callable-throws.js fails built-ins/isNaN/toprimitive-not-callable-throws.js fails -language/computed-property-names/class/static/generator-prototype.js fails -language/computed-property-names/class/static/getter-prototype.js fails -language/computed-property-names/class/static/method-prototype.js fails language/computed-property-names/class/static/method-number.js fails language/computed-property-names/class/static/method-string.js fails language/computed-property-names/class/static/method-symbol.js fails -language/computed-property-names/class/static/setter-prototype.js fails language/eval-code/direct/lex-env-no-init-cls.js fails language/eval-code/direct/lex-env-no-init-const.js fails language/eval-code/direct/lex-env-no-init-let.js fails @@ -2302,7 +2298,6 @@ language/statements/class/constructor-inferred-observable-iteration.js fails language/statements/class/cptn-decl.js fails language/statements/class/definition/accessors.js fails language/statements/class/definition/class-method-returns-promise.js fails -language/statements/class/definition/getters-non-configurable-err.js fails language/statements/class/definition/getters-prop-desc.js fails language/statements/class/definition/getters-restricted-ids.js fails language/statements/class/definition/invalid-extends.js strictFails @@ -2316,7 +2311,6 @@ language/statements/class/definition/prototype-getter.js fails language/statements/class/definition/prototype-property.js fails language/statements/class/definition/prototype-setter.js fails language/statements/class/definition/prototype-wiring.js fails -language/statements/class/definition/setters-non-configurable-err.js fails language/statements/class/definition/setters-prop-desc.js fails language/statements/class/definition/setters-restricted-ids.js fails language/statements/class/definition/this-access-restriction-2.js fails @@ -2339,8 +2333,6 @@ language/statements/class/scope-setter-paramsbody-var-open.js fails language/statements/class/scope-static-gen-meth-paramsbody-var-open.js fails language/statements/class/scope-static-meth-paramsbody-var-open.js fails language/statements/class/scope-static-setter-paramsbody-var-open.js fails -language/statements/class/static-method-gen-non-configurable-err.js fails -language/statements/class/static-method-non-configurable-err.js fails language/statements/class/subclass/bound-function.js fails language/statements/class/subclass/builtin-objects/Array/super-must-be-called.js fails language/statements/class/subclass/builtin-objects/ArrayBuffer/regular-subclassing.js fails |