Function with Self as parameter type causing IRGen crashed

The following code will crash IRGen:

import Foundation

extension NSObject {
  func foo(bar: (Self) -> Void) {}
}

let object = NSObject()
object.foo { _ in } 

Compile error:

error: compile command failed due to signal 11 (use -v to see invocation)
Untitled.swift:9:8: warning: result of call to 'foo(bar:)' is unused
object.foo { _ in } 
       ^   ~~~~~~~~
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace.
Stack dump:
0.	Program arguments: /Applications/Xcode-13.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend -frontend -c -primary-file Untitled.swift -target arm64-apple-macosx12.0 -Xllvm -aarch64-use-tbi -enable-objc-interop -stack-check -sdk /Applications/Xcode-13.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk -new-driver-path /Applications/Xcode-13.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-driver -resource-dir /Applications/Xcode-13.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift -module-name Untitled -target-sdk-version 12.3 -o /var/folders/0g/19fzt3zj69dgvkfh_v7tbl1h0000gn/T/TemporaryDirectory.21rYb6/Untitled-1.o
1.	Apple Swift version 5.6.1 (swiftlang-5.6.0.323.66 clang-1316.0.20.12)
2.	Compiling with the current language version
3.	While evaluating request IRGenRequest(IR Generation for file "Untitled.swift")
4.	While emitting IR SIL function "@main".
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  swift-frontend           0x0000000107453078 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x000000010745208c llvm::sys::RunSignalHandlers() + 112
2  swift-frontend           0x0000000107453708 SignalHandler(int) + 344
3  libsystem_platform.dylib 0x00000001ac4d74a4 _sigtramp + 56
4  swift-frontend           0x000000010320bda0 emitDirectTypeMetadataRef(swift::irgen::IRGenFunction&, swift::CanType, swift::irgen::DynamicMetadataRequest) + 272
5  swift-frontend           0x000000010320bda0 emitDirectTypeMetadataRef(swift::irgen::IRGenFunction&, swift::CanType, swift::irgen::DynamicMetadataRequest) + 272
6  swift-frontend           0x000000010320b508 swift::irgen::IRGenFunction::emitTypeMetadataRef(swift::CanType, swift::irgen::DynamicMetadataRequest) + 256
7  swift-frontend           0x000000010320ee8c swift::irgen::emitMetatypeRef(swift::irgen::IRGenFunction&, swift::CanTypeWrapper<swift::MetatypeType>, swift::irgen::Explosion&) + 72
8  swift-frontend           0x00000001031cbf48 swift::SILInstructionVisitor<(anonymous namespace)::IRGenSILFunction, void>::visit(swift::SILInstruction*) + 1876
9  swift-frontend           0x00000001031c690c swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*) + 8532
10 swift-frontend           0x000000010309b288 swift::irgen::IRGenerator::emitGlobalTopLevel(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&) + 1560
11 swift-frontend           0x00000001031972d4 swift::IRGenRequest::evaluate(swift::Evaluator&, swift::IRGenDescriptor) const + 7140
12 swift-frontend           0x00000001031c44ec swift::SimpleRequest<swift::IRGenRequest, swift::GeneratedModule (swift::IRGenDescriptor), (swift::RequestFlags)9>::evaluateRequest(swift::IRGenRequest const&, swift::Evaluator&) + 188
13 swift-frontend           0x00000001031a1eb4 llvm::Expected<swift::IRGenRequest::OutputType> swift::Evaluator::getResultUncached<swift::IRGenRequest>(swift::IRGenRequest const&) + 736
14 swift-frontend           0x000000010319bea4 swift::performIRGeneration(swift::FileUnit*, swift::IRGenOptions const&, swift::TBDGenOptions const&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, llvm::StringRef, swift::PrimarySpecificPaths const&, llvm::StringRef, llvm::GlobalVariable**) + 236
15 swift-frontend           0x0000000102d013f4 performCompileStepsPostSILGen(swift::CompilerInstance&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::PrimarySpecificPaths const&, int&, swift::FrontendObserver*) + 2524
16 swift-frontend           0x0000000102cf4acc swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 5344
17 swift-frontend           0x0000000102cbc3c4 swift::mainEntry(int, char const**) + 808
18 dyld                     0x0000000109d3d08c start + 520

Filed an issue on GitHub already.