mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[IDE] Teach type checker about conditional conformance extensions.
Before conditional conformances, the archetypes in conformance extensions (i.e. extension Foo: SomeProtocol) were equivalent to those in the type decl, with the same protocol bounds and so on. The code for printing "synthesized" members relied on this fact. This commit teaches that code to deal with archetypes in the conditional conformance extension when required. Fixes rdar://problem/36553066 and SR-6930.
This commit is contained in:
@@ -433,19 +433,20 @@ void SwiftLangSupport::printFullyAnnotatedDeclaration(const ValueDecl *VD,
|
||||
VD->print(Printer, PO);
|
||||
}
|
||||
|
||||
void SwiftLangSupport::
|
||||
printFullyAnnotatedSynthesizedDeclaration(const swift::ValueDecl *VD,
|
||||
swift::NominalTypeDecl *Target,
|
||||
llvm::raw_ostream &OS) {
|
||||
void SwiftLangSupport::printFullyAnnotatedSynthesizedDeclaration(
|
||||
const swift::ValueDecl *VD, TypeOrExtensionDecl Target,
|
||||
llvm::raw_ostream &OS) {
|
||||
// FIXME: Mutable global variable - gross!
|
||||
static llvm::SmallDenseMap<swift::ValueDecl*,
|
||||
std::unique_ptr<swift::SynthesizedExtensionAnalyzer>> TargetToAnalyzerMap;
|
||||
FullyAnnotatedDeclarationPrinter Printer(OS);
|
||||
PrintOptions PO = PrintOptions::printQuickHelpDeclaration();
|
||||
if (TargetToAnalyzerMap.count(Target) == 0) {
|
||||
NominalTypeDecl *TargetNTD = Target.getBaseNominal();
|
||||
|
||||
if (TargetToAnalyzerMap.count(TargetNTD) == 0) {
|
||||
std::unique_ptr<SynthesizedExtensionAnalyzer> Analyzer(
|
||||
new SynthesizedExtensionAnalyzer(Target, PO));
|
||||
TargetToAnalyzerMap.insert({Target, std::move(Analyzer)});
|
||||
new SynthesizedExtensionAnalyzer(TargetNTD, PO));
|
||||
TargetToAnalyzerMap.insert({TargetNTD, std::move(Analyzer)});
|
||||
}
|
||||
PO.initForSynthesizedExtension(Target);
|
||||
PO.PrintAsMember = true;
|
||||
|
||||
Reference in New Issue
Block a user