Fixing a crash in ASTMangler.cpp

Hello, dear colleagues :wave:t2:

I have discovered a crash in Swift 5.9 a while ago while trying to optimize swift-syntax package compilation duration.

So I decided to go ahead and fix the crash.

What I have uncovered at the moment, using this simplified code sample which causes the crash:

  1. When ASTMangler.cpp is trying to mangle the function body which passes OpenedArchetype as a value to an argument which expects a generic constraint conforming to that same OpenedArchetype, method ASTMangler::appendType tries to mangle TypeKind::OpenedArchetype, which is not supported anymore (since this PR)
  2. When reverting the changes mentioned in the PR, and attempting to mangle the OpenedArchetype implicitly as its InterfaceType's type, the following string is generated:
    ..._tFyxcACcfu_...
  3. When changing the expected method argument from the generic constraint to the OpenedArchetype, like Constraint.Type -> ActualType.Type in the function signature (you can see an example which does not crash the compiler, and works, in the same example Swift code), the following string is generated:
    ..._tFyAHcACcfu_...

As can be seen, mangler is able to mangle the OpenedArchetype as AH.

This is as far as I could debug it. Right now I am stuck because I do not have a clear strategy how to resolve this crash.
Reverting the PR is not an option, because then when SILRequest would be attempting to lower the mangled code, in particular, that function's arguments, it would not be able to demangle that x (which was mangled before the disabling-implicit-mangling-PR) - i.e. it'd not be able to deserialize the mangled string using SILBasicBlock *SILNode::getParentBlock function (it returns nullptr).

I'd appreciate any help, but also, please tell me, if I should use another part of this forum for such questions.

Kind regards