Skip to content

Commit d16eb33

Browse files
committed
Sema: Bind context generic params using the current ConstraintSystem's generic environment instead of the decl's DC.
Fixes SR-4833.
1 parent 5e31b5b commit d16eb33

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

lib/Sema/ConstraintSystem.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,7 @@ static void bindArchetypesFromContext(
868868
ConstraintLocator *locatorPtr,
869869
const OpenedTypeMap &replacements) {
870870

871-
auto *genericEnv = outerDC->getGenericEnvironmentOfContext();
871+
auto *genericEnv = cs.DC->getGenericEnvironmentOfContext();
872872

873873
for (const auto *parentDC = outerDC;
874874
!parentDC->isModuleScopeContext();
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// RUN: %target-swift-frontend -emit-silgen -verify %s
2+
3+
protocol AP {
4+
associatedtype B: BP
5+
var b: B { get }
6+
}
7+
protocol BP {}
8+
9+
func foo<A: AP>(x: A) -> A {
10+
func bar<B: BP>(x: B) {
11+
}
12+
func bas<B: BP>(x: B) {
13+
bar(x: x)
14+
}
15+
16+
func bang() -> A { return x }
17+
func bong(_: A) {}
18+
19+
let x = bang()
20+
bong(x)
21+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
// See https://swift.org/LICENSE.txt for license information
66
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
77

8-
// RUN: not --crash %target-swift-frontend %s -emit-ir
8+
// RUN: not %target-swift-frontend %s -emit-ir
99
protocol P extension P{var f=A.a}extension P{struct A{func a:Self

0 commit comments

Comments
 (0)