Fix strong references

Makes strong references to deal with interface corner case explicitly.
Makes hidl-gen to detect a cycle through typedef.

Cycle example:
typedef S A;
struct S {
    A foo;
};

Fixes: 65559985

Test: mma
Test: error test in follow up CL
Change-Id: I132037995c3fc99edfe3e57a1fe84d3c36ca6993
diff --git a/Interface.cpp b/Interface.cpp
index 2e0d931..0fd702c 100644
--- a/Interface.cpp
+++ b/Interface.cpp
@@ -486,14 +486,17 @@
     // Interface is a special case as a reference:
     // its definiton must be completed for extension but
     // not necessary for other references.
-    // As interface declaration appears only in global scope and
-    // method declaration appears only in interface, we may assume
-    // that all references in method definitions are acyclic.
 
     std::vector<const Reference<Type>*> ret;
     if (superType() != nullptr) {
         ret.push_back(&mSuperType);
     }
+
+    for (const auto* method : methods()) {
+        const auto& references = method->getStrongReferences();
+        ret.insert(ret.end(), references.begin(), references.end());
+    }
+
     return ret;
 }
 
@@ -982,5 +985,9 @@
     return Scope::isJavaCompatible(visited);
 }
 
+bool Interface::isNeverStrongReference() const {
+    return true;
+}
+
 }  // namespace android