Avoid constructing types with errors.

BUG=27626735

Rationale:
Do not construct classes with a link error. Without this,
the error type thought it was Object (mirror's method
IsObjectClass() returns true if there is no superclass).

(cherry picked from commit 8b3f9b246d5bdbf67faeb2b872b75b8d72777bc0)
(also contains follow-up commit 31244b4cde9156632a08103a8bf1cbff4cbae3cc)

Change-Id: I4443779dda47c320115975c1c71b22e118bd8252
diff --git a/compiler/optimizing/inliner.cc b/compiler/optimizing/inliner.cc
index 77e0cbc..ba6ae6f 100644
--- a/compiler/optimizing/inliner.cc
+++ b/compiler/optimizing/inliner.cc
@@ -1303,11 +1303,12 @@
         DCHECK(return_replacement->IsPhi());
         size_t pointer_size = Runtime::Current()->GetClassLinker()->GetImagePointerSize();
         mirror::Class* cls = resolved_method->GetReturnType(false /* resolve */, pointer_size);
-        if (cls != nullptr) {
+        if (cls != nullptr && !cls->IsErroneous()) {
           ReferenceTypeInfo::TypeHandle return_handle = handles_->NewHandle(cls);
           return_replacement->SetReferenceTypeInfo(ReferenceTypeInfo::Create(
               return_handle, return_handle->CannotBeAssignedFromOtherTypes() /* is_exact */));
         } else {
+          // Return inexact object type on failures.
           return_replacement->SetReferenceTypeInfo(graph_->GetInexactObjectRti());
         }
       }