mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[SourceKit] Workaround a bug that parameterized protocols without 'any' cannot be mangled
`typealias` is currently allowed to refer to a protocol without the `any` keyword. This breaks mangling the typealias type into a USR will crash because parameterized protocols are expected to be `any` types. Implement a SourceKit-specific minimal workaround for that problem by not computing USRs for parameterized protocols. rdar://98623438
This commit is contained in:
@@ -948,6 +948,22 @@ fillSymbolInfo(CursorSymbolInfo &Symbol, const DeclInfo &DInfo,
|
||||
}
|
||||
Symbol.TypeName = copyAndClearString(Allocator, Buffer);
|
||||
|
||||
// ParameterizedProtocolType should always be wrapped in ExistentialType and
|
||||
// cannot be mangled on its own.
|
||||
// But ParameterizedProtocolType can currently occur in 'typealias'
|
||||
// declarations. rdar://99176683
|
||||
// To avoid crashing in USR generation, return an error for now.
|
||||
if (auto Ty = DInfo.VD->getInterfaceType()) {
|
||||
while (auto MetaTy = Ty->getAs<MetatypeType>()) {
|
||||
Ty = MetaTy->getInstanceType();
|
||||
}
|
||||
if (Ty && Ty->getCanonicalType()->is<ParameterizedProtocolType>()) {
|
||||
return llvm::createStringError(
|
||||
llvm::inconvertibleErrorCode(),
|
||||
"Cannot mangle USR for ParameterizedProtocolType without 'any'.");
|
||||
}
|
||||
}
|
||||
|
||||
SwiftLangSupport::printDeclTypeUSR(DInfo.VD, OS);
|
||||
Symbol.TypeUSR = copyAndClearString(Allocator, Buffer);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user