Add temp class circularity detection to EnsureResolved

There was already code checking that so we can create
a lambda and deduplicate code.

Bug: 431938390
Bug: 28830038
Flag: EXEMPT bugfix
Test: m test-art-host-gtest-art_runtime_tests64
Change-Id: Ie1122fe26f624cd0b7b8da3ea4f79495f047f206
2 files changed