Skip to content

Commit d62e4ac

Browse files
committed
[SymbolGraph] Don't use innermost context for swiftExtension
`getInnerMostContext` can return the same value if it is a type, but `swiftExtension` should always look upward for an extension. rdar://61746582
1 parent 8324fed commit d62e4ac

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

lib/SymbolGraphGen/Symbol.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ void Symbol::serializeSwiftGenericMixin(llvm::json::OStream &OS) const {
287287

288288
void Symbol::serializeSwiftExtensionMixin(llvm::json::OStream &OS) const {
289289
if (const auto *Extension
290-
= dyn_cast_or_null<ExtensionDecl>(VD->getInnermostDeclContext())) {
290+
= dyn_cast_or_null<ExtensionDecl>(VD->getDeclContext())) {
291291
::serialize(Extension, OS);
292292
}
293293
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-build-swift %s -module-name Extension -emit-module-path %t/Extension.swiftmodule
3+
// RUN: %target-swift-symbolgraph-extract -module-name Extension -I %t -pretty-print -output-dir %t
4+
// RUN: %FileCheck %s --input-file %t/Extension.symbols.json
5+
6+
public struct Outer<T> {
7+
public var x: T
8+
public init(x: T) {
9+
self.x = x
10+
}
11+
}
12+
13+
extension Outer where T == Int {
14+
// This type's swiftExtension mixin should not include generic
15+
// constraints regarding U.
16+
17+
// CHECK: swiftExtension
18+
// CHECK: constraints
19+
// CHECK: "kind": "sameType"
20+
// CHECK: "lhs": "T"
21+
// CHECK: "rhs": "Int"
22+
public struct Inner<U: Sequence> {
23+
public var x: U
24+
public init(x: U) {
25+
self.x = x
26+
}
27+
}
28+
}

0 commit comments

Comments
 (0)