diff --git a/src/libs/qmljs/qmljslink.cpp b/src/libs/qmljs/qmljslink.cpp
index 5b9d38fa291a35de424bb02ff0288a498cf81d13..276006dad38446fb1d577f428b8426420af76ad7 100644
--- a/src/libs/qmljs/qmljslink.cpp
+++ b/src/libs/qmljs/qmljslink.cpp
@@ -54,13 +54,16 @@ void Link::scopeChainAt(Document::Ptr doc, Node *currentObject)
         if (const ObjectValue *typeEnvironment = _context->typeEnvironment(doc.data()))
             _context->pushScope(typeEnvironment);
     } else {
-        // add scope chains for all components that source this document
-        foreach (Document::Ptr otherDoc, _docs) {
-            if (otherDoc->bind()->includedScripts().contains(doc->fileName()))
-                pushScopeChainForComponent(otherDoc, &linkedDocs);
-        }
+        // the global scope of a js file does not see the instantiating component
+        if (currentObject != 0) {
+            // add scope chains for all components that source this document
+            foreach (Document::Ptr otherDoc, _docs) {
+                if (otherDoc->bind()->includedScripts().contains(doc->fileName()))
+                    pushScopeChainForComponent(otherDoc, &linkedDocs);
+            }
 
-        // ### TODO: Which type environment do scripts see?
+            // ### TODO: Which type environment do scripts see?
+        }
 
         _context->pushScope(bind->rootObjectValue());
     }