[new compiler] When resolving names of attached properties, don't report the error...
authorSimon Hausmann <simon.hausmann@digia.com>
Thu, 20 Feb 2014 11:21:21 +0000 (12:21 +0100)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Sun, 2 Mar 2014 13:48:03 +0000 (14:48 +0100)
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>
src/qml/compiler/qqmlcodegenerator.cpp
src/qml/compiler/qqmltypecompiler.cpp
src/qml/compiler/qv4compileddata_p.h
src/qml/qml/qqmltypeloader.cpp

index 9f94118a6021ba2ff300bedcc8f51a24ef85b991..45d97d48bd04dcf2ce2327ea3c7a0cf3bd5ef698 100644 (file)
@@ -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;
             }
         }
 
index abb2f3f5e26e57e58227243965e66f459c9ce0b8..71a7c71dc1fd7eac17a3e9c77ccb5e99bfedcf3a 100644 (file)
@@ -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;
index 675282fb8c1de1d233e7036a9e188a9ef55e2943..1f6bdfb2cf67bff0859cb26732a49f48ef4db488 100644 (file)
@@ -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
index 1b947c421a0c850030e38f3cf7406c87ffe9d962..75f983d9e8977ffb45e5f95297ad590df86bc27b 100644 (file)
@@ -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);
         }