diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2014-02-20 12:21:21 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-03-02 14:48:03 +0100 |
commit | 1c509a887a177939556514cd7cd389031d05117c (patch) | |
tree | 4c3694e329a1f6c7416a15924e5c96347ccde510 /src | |
parent | 8a81380cca802e230011464c9f25c0c1604909d7 (diff) |
[new compiler] When resolving names of attached properties, don't report the error at import time
Instead report it later with a more specific error message. This is consistent with the old compiler.
Change-Id: Iba345b7ecc8a9ff474938f69118665eb0d965594
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/qml/compiler/qqmlcodegenerator.cpp | 2 | ||||
-rw-r--r-- | src/qml/compiler/qqmltypecompiler.cpp | 3 | ||||
-rw-r--r-- | src/qml/compiler/qv4compileddata_p.h | 4 | ||||
-rw-r--r-- | src/qml/qml/qqmltypeloader.cpp | 6 |
4 files changed, 10 insertions, 5 deletions
diff --git a/src/qml/compiler/qqmlcodegenerator.cpp b/src/qml/compiler/qqmlcodegenerator.cpp index 9f94118a60..45d97d48bd 100644 --- a/src/qml/compiler/qqmlcodegenerator.cpp +++ b/src/qml/compiler/qqmlcodegenerator.cpp @@ -1160,6 +1160,7 @@ void QQmlCodeGenerator::collectTypeReferences() if (obj->inheritedTypeNameIndex != emptyStringIndex) { QV4::CompiledData::TypeReference &r = _typeReferences.add(obj->inheritedTypeNameIndex, obj->location); r.needsCreation = true; + r.errorWhenNotFound = true; } for (const QmlProperty *prop = obj->firstProperty(); prop; prop = prop->next) { @@ -1168,6 +1169,7 @@ void QQmlCodeGenerator::collectTypeReferences() // compiler can't and the tests expect it to be the object location right now. QV4::CompiledData::TypeReference &r = _typeReferences.add(prop->customTypeNameIndex, obj->location); r.needsCreation = true; + r.errorWhenNotFound = true; } } diff --git a/src/qml/compiler/qqmltypecompiler.cpp b/src/qml/compiler/qqmltypecompiler.cpp index abb2f3f5e2..71a7c71dc1 100644 --- a/src/qml/compiler/qqmltypecompiler.cpp +++ b/src/qml/compiler/qqmltypecompiler.cpp @@ -468,8 +468,7 @@ bool QQmlPropertyCacheCreator::buildMetaObjectRecursively(int objectIndex, int r } else if (instantiatingBinding && instantiatingBinding->isAttachedProperty()) { QQmlCompiledData::TypeReference *typeRef = resolvedTypes->value(instantiatingBinding->propertyNameIndex); Q_ASSERT(typeRef); - Q_ASSERT(typeRef->type); - const QMetaObject *attachedMo = typeRef->type->attachedPropertiesType(); + const QMetaObject *attachedMo = typeRef->type ? typeRef->type->attachedPropertiesType() : 0; if (!attachedMo) { recordError(instantiatingBinding->location, tr("Non-existent attached object")); return false; diff --git a/src/qml/compiler/qv4compileddata_p.h b/src/qml/compiler/qv4compileddata_p.h index 675282fb8c..1f6bdfb2cf 100644 --- a/src/qml/compiler/qv4compileddata_p.h +++ b/src/qml/compiler/qv4compileddata_p.h @@ -80,9 +80,11 @@ struct TypeReference TypeReference(const Location &loc) : location(loc) , needsCreation(false) + , errorWhenNotFound(false) {} Location location; // first use - bool needsCreation; // whether the type needs to be creatable or not + bool needsCreation : 1; // whether the type needs to be creatable or not + bool errorWhenNotFound: 1; }; // map from name index to location of first use diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp index 1b947c421a..75f983d9e8 100644 --- a/src/qml/qml/qqmltypeloader.cpp +++ b/src/qml/qml/qqmltypeloader.cpp @@ -2414,6 +2414,8 @@ void QQmlTypeData::resolveTypes() TypeReference ref; // resolved reference + const bool reportErrors = unresolvedRef->errorWhenNotFound; + int majorVersion = -1; int minorVersion = -1; QQmlImportNamespace *typeNamespace = 0; @@ -2434,7 +2436,7 @@ void QQmlTypeData::resolveTypes() } } - if (!typeFound || typeNamespace) { + if ((!typeFound || typeNamespace) && reportErrors) { // Known to not be a type: // - known to be a namespace (Namespace {}) // - type with unknown namespace (UnknownNamespace.SomeType {}) @@ -2461,7 +2463,7 @@ void QQmlTypeData::resolveTypes() return; } - if (ref.type->isComposite()) { + if (ref.type && ref.type->isComposite()) { ref.typeData = typeLoader()->getType(ref.type->sourceUrl()); addDependency(ref.typeData); } |