Fix the case where an interface is referenced through a typedef.

Previously the imported name would mistakenly be the one of the typedef instead
of that of the referenced interface.

Change-Id: I18169d372005d4b3445f0cbc2f6a13269d33c422
diff --git a/AST.cpp b/AST.cpp
index 10de21b..eff3369 100644
--- a/AST.cpp
+++ b/AST.cpp
@@ -4,6 +4,7 @@
 #include "Formatter.h"
 #include "FQName.h"
 #include "HandleType.h"
+#include "Interface.h"
 #include "Scope.h"
 #include "TypeDef.h"
 
@@ -167,7 +168,14 @@
             FQName typesName(fqName.package(), fqName.version(), "types");
             mImportedNames.insert(typesName);
         } else {
-            mImportedNames.insert(fqName);
+            // Do _not_ use fqName, i.e. the name we used to look up the type,
+            // but instead use the name of the interface we found.
+            // This is necessary because if fqName pointed to a typedef which
+            // in turn referenced the found interface we'd mistakenly use the
+            // name of the typedef instead of the proper name of the interface.
+
+            mImportedNames.insert(
+                    static_cast<Interface *>(resultType)->fqName());
         }
     }