Skip to content

Commit 3d74a39

Browse files
committed
[Sema] Temporary disable l-value stripping while erasing opened existentials
Reverts part of #69950 because it causes failure in existing code.
1 parent e7475c8 commit 3d74a39

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

lib/Sema/ConstraintSystem.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2270,7 +2270,7 @@ static Type typeEraseExistentialSelfReferences(Type refTy, Type baseTy,
22702270
return parameterized->getBaseType();
22712271
}
22722272
}
2273-
2273+
/*
22742274
if (auto lvalue = dyn_cast<LValueType>(t)) {
22752275
auto objTy = lvalue->getObjectType();
22762276
auto erasedTy =
@@ -2284,6 +2284,7 @@ static Type typeEraseExistentialSelfReferences(Type refTy, Type baseTy,
22842284
22852285
return erasedTy;
22862286
}
2287+
*/
22872288

22882289
if (!predicateFn(t)) {
22892290
// Recurse.

test/Constraints/rdar121214563.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// RUN: %target-typecheck-verify-swift
2+
3+
protocol P<A>: AnyObject {
4+
associatedtype A: P2
5+
var x: A.A2 { get set }
6+
}
7+
8+
protocol P2 {
9+
associatedtype A2
10+
var x: A2 { get }
11+
}
12+
13+
func test<T: P2>(x: T.A2, y: any P<T>, z: any P2) {
14+
y.x = x // Ok
15+
y.x = z.x // expected-error {{cannot assign value of type 'Any' to type 'T.A2'}}
16+
}

test/Sema/open_existential_lvalue.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
// RUN: %target-typecheck-verify-swift
22

3+
// rdar://121214563
4+
// REQUIRES: rdar121214563
5+
36
protocol Q {}
47

58
protocol P {

0 commit comments

Comments
 (0)