Skip to content

Commit 157528e

Browse files
committed
fix invalid assertion error when inheriting features through the public-private-public inheritance pattern
1 parent 23d6a2c commit 157528e

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

Sources/SymbolGraphCompiler/SSGC.TypeChecker.swift

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,37 @@ extension SSGC.TypeChecker
450450
""")
451451
}
452452
guard
453-
let conformance:Symbol.Decl = feature.scopes.first, feature.scopes.count == 1
453+
let conformance:Symbol.Decl = feature.scopes.first
454+
else
455+
{
456+
// We hit this on an extremely unusual edge case where a feature and an heir
457+
// are public, but the protocol the feature is defined on is not. Here is some
458+
// valid Swift code that demonstrates this:
459+
//
460+
/* ```
461+
protocol P
462+
{
463+
}
464+
extension P
465+
{
466+
public
467+
func f()
468+
{
469+
}
470+
}
471+
472+
public
473+
struct S:P
474+
{
475+
}
476+
```
477+
*/
478+
// Ideally, lib/SymbolGraphGen would not emit the feature in this case, but
479+
// it does anyway.
480+
return
481+
}
482+
483+
guard feature.scopes.count == 1
454484
else
455485
{
456486
throw AssertionError.init(message: """

0 commit comments

Comments
 (0)