diff --git a/src/libs/qmljs/qmljscheck.cpp b/src/libs/qmljs/qmljscheck.cpp
index 1639c5dcd0f084c6227e7e72bc72c88546ee111f..b8146540209b8ce58da9e4db57e37d697df11531 100644
--- a/src/libs/qmljs/qmljscheck.cpp
+++ b/src/libs/qmljs/qmljscheck.cpp
@@ -470,11 +470,12 @@ void Check::visitQmlObject(Node *ast, UiQualifiedId *typeId,
     }
 
     bool typeError = false;
+    const SourceLocation typeErrorLocation = fullLocationForQualifiedId(typeId);
     const ObjectValue *prototype = _context.lookupType(_doc.data(), typeId);
     if (!prototype) {
         typeError = true;
         if (_options & ErrCheckTypeErrors)
-            error(typeId->identifierToken,
+            error(typeErrorLocation,
                   Check::tr("unknown type"));
     } else {
         PrototypeIterator iter(prototype, &_context);
@@ -486,16 +487,16 @@ void Check::visitQmlObject(Node *ast, UiQualifiedId *typeId,
             if (iter.error() == PrototypeIterator::ReferenceResolutionError) {
                 if (const QmlPrototypeReference *ref =
                         dynamic_cast<const QmlPrototypeReference *>(lastPrototype->prototype())) {
-                    error(typeId->identifierToken,
+                    error(typeErrorLocation,
                           Check::tr("could not resolve the prototype %1 of %2").arg(
                               Bind::toString(ref->qmlTypeName()), lastPrototype->className()));
                 } else {
-                    error(typeId->identifierToken,
+                    error(typeErrorLocation,
                           Check::tr("could not resolve the prototype of %1").arg(
                               lastPrototype->className()));
                 }
             } else if (iter.error() == PrototypeIterator::CycleError) {
-                error(typeId->identifierToken,
+                error(typeErrorLocation,
                       Check::tr("prototype cycle, the last non-repeated object is %1").arg(
                           lastPrototype->className()));
             }