if (actual != expected) {
throw new IllegalStateException("Incorrect # of type parameters to "
+ genericType.getQualifiedBinaryName() + ": expected " + expected
+ ", actual=" + actual);
}
JClassType genericEnc = genericType.getEnclosingType();
if (outer == null && genericEnc != null) {
// Sometimes the signature is like Foo$Bar<H> even if Foo is a
// generic class. The cases I have seen are where Foo's type
// parameter is also named H and has the same bounds. That
// manifests itself as getting visitClassType("Foo$Bar") and
// then VisitTypeArgument/etc, rather than the usual
// visitClassType("Foo"), visitTypeArgument/etc,
// visitInnerClass("Bar"), visitTypeArgument/etc.
//
// So, in this case we have to build our own chain of enclosing
// classes here, properly parameterizing any generics along the
// way.
// TODO(jat): more testing to validate this assumption
JClassType[] outerArgs = null;
JGenericType genericEncGeneric = genericEnc.isGenericType();
if (genericEncGeneric != null) {
JTypeParameter[] encTypeParams = genericEncGeneric.getTypeParameters();
int n = encTypeParams.length;
outerArgs = new JClassType[n];
for (int i = 0; i < n; ++i) {