Skip to content

Commit d412ea4

Browse files
committed
[Diagnostics] Unsatisfied requirement in reference diagnostics expect type context
Resolves: rdar://problem/50666427
1 parent 0895235 commit d412ea4

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

lib/Sema/CSDiagnostics.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,9 @@ bool RequirementFailure::diagnoseAsError() {
336336
return true;
337337
}
338338

339-
if (genericCtx != reqDC && (genericCtx->isChildContextOf(reqDC) ||
340-
isStaticOrInstanceMember(AffectedDecl))) {
339+
if (reqDC->isTypeContext() && genericCtx != reqDC &&
340+
(genericCtx->isChildContextOf(reqDC) ||
341+
isStaticOrInstanceMember(AffectedDecl))) {
341342
auto *NTD = reqDC->getSelfNominalTypeDecl();
342343
emitDiagnostic(anchor->getLoc(), getDiagnosticInRereference(),
343344
AffectedDecl->getDescriptiveKind(),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// RUN: not %target-swift-frontend %s -typecheck
2+
3+
protocol A {}
4+
5+
class C<T> where T: A {}
6+
7+
extension C {
8+
func foo() {
9+
extension C where T: Undefined {
10+
class Inner: Encodable {
11+
var foo: Int
12+
}
13+
}
14+
}
15+
}

0 commit comments

Comments
 (0)