Somehow ninja didn't rebuild everything, so I ended up pushing code
that didn't compile. I did a clean re-build and fixed a minor issue
in the logic, now the test passes.
When deriving substitutions from closure contexts, we end up with
a problem where we have an original type and a substituted type,
and the original type is not necessarily a type parameter.
We need to decompose the original and substituted types to derive
the substitutions that produced the substitution.
For example, deriveSubstitutions(Foo<T -> Int>, Foo<String -> Int>)
will give us a substitution of T := Int.
A TypeRef for C<T, U>, substituted to C<Int, Int>, should have the same
pointer identity as a C<Int, Int> created by other means. This prevents
repeating reflective layout work if we've already seen a particular
instantiation of a generic type.
We'd like to be able to compare TypeRefs with pointer equality,
but we can't link LLVMSupport, so make a lightweight TypeRefID
like FoldingSetID, that only supports the input types necessary
to unique TypeRefs.
rdar://problem/25924875