mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Sourcekit/DocSupport: fix an assertion when generating documentation for extensions with attributes
When sanitizing the documentation comments for synthesized extensions, we expect some text like "<declaration>extension". This isn't the case when use-facing attributes are present. rdar://50913510
This commit is contained in:
@@ -39,6 +39,9 @@ static bool shouldPrintAsFavorable(const Decl *D, const PrintOptions &Options) {
|
|||||||
const auto *FD = dyn_cast<FuncDecl>(D);
|
const auto *FD = dyn_cast<FuncDecl>(D);
|
||||||
if (!FD)
|
if (!FD)
|
||||||
return true;
|
return true;
|
||||||
|
// Don't check overload choices for accessor decls.
|
||||||
|
if (isa<AccessorDecl>(FD))
|
||||||
|
return true;
|
||||||
ResolvedMemberResult Result =
|
ResolvedMemberResult Result =
|
||||||
resolveValueMember(*DC, BaseTy, FD->getEffectiveFullName());
|
resolveValueMember(*DC, BaseTy, FD->getEffectiveFullName());
|
||||||
return !(Result.hasBestOverload() && Result.getBestOverload() != D);
|
return !(Result.hasBestOverload() && Result.getBestOverload() != D);
|
||||||
|
|||||||
@@ -98,3 +98,11 @@ public struct S3<Wrapped: P5>: P5 {
|
|||||||
public typealias Element = Wrapped.Element
|
public typealias Element = Wrapped.Element
|
||||||
}
|
}
|
||||||
extension S3: P6 where Wrapped: P6 {}
|
extension S3: P6 where Wrapped: P6 {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
some comments
|
||||||
|
*/
|
||||||
|
@available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *)
|
||||||
|
public extension C1 {
|
||||||
|
func addition() {}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// RUN: %empty-directory(%t.mod)
|
// RUN: %empty-directory(%t.mod)
|
||||||
// RUN: %swift -emit-module -o %t.mod/cake.swiftmodule %S/Inputs/cake.swift -parse-as-library -enable-objc-interop
|
// RUN: %swift -emit-module -o %t.mod/cake.swiftmodule %S/Inputs/cake.swift -parse-as-library -enable-objc-interop -emit-module-doc-path %t.mod/cake.swiftdoc
|
||||||
// RUN: %sourcekitd-test -req=doc-info -module cake -- -I %t.mod > %t.response
|
// RUN: %sourcekitd-test -req=doc-info -module cake -- -I %t.mod > %t.response
|
||||||
// RUN: diff -u %s.response %t.response
|
// RUN: diff -u %s.response %t.response
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -368,7 +368,7 @@ static bool initDocEntityInfo(const Decl *D,
|
|||||||
StringRef DocRef = (StringRef)DocBuffer;
|
StringRef DocRef = (StringRef)DocBuffer;
|
||||||
if (IsSynthesizedExtension &&
|
if (IsSynthesizedExtension &&
|
||||||
DocRef.find("<Declaration>") != StringRef::npos) {
|
DocRef.find("<Declaration>") != StringRef::npos) {
|
||||||
StringRef Open = "<Declaration>extension ";
|
StringRef Open = "extension ";
|
||||||
assert(DocRef.find(Open) != StringRef::npos);
|
assert(DocRef.find(Open) != StringRef::npos);
|
||||||
auto FirstPart = DocRef.substr(0, DocRef.find(Open) + (Open).size());
|
auto FirstPart = DocRef.substr(0, DocRef.find(Open) + (Open).size());
|
||||||
auto SecondPart = DocRef.substr(FirstPart.size());
|
auto SecondPart = DocRef.substr(FirstPart.size());
|
||||||
|
|||||||
Reference in New Issue
Block a user