Skip to content

Commit b099cd5

Browse files
authored
Merge pull request #72920 from slavapestov/fix-rdar126079282-6.0
[6.0] AST: Remove incorrect optimization from ASTContext::getOpenedExistentialSignature()
2 parents b4b7baa + 6efb8fa commit b099cd5

File tree

2 files changed

+25
-12
lines changed

2 files changed

+25
-12
lines changed

lib/AST/ASTContext.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5867,18 +5867,6 @@ ASTContext::getOpenedExistentialSignature(Type type, GenericSignature parentSig)
58675867
assert(parentSig || !constraint->hasTypeParameter() &&
58685868
"Interface type here requires a parent signature");
58695869

5870-
// The opened archetype signature for a protocol type is identical
5871-
// to the protocol's own canonical generic signature if there aren't any
5872-
// outer generic parameters to worry about.
5873-
if (parentSig.isNull()) {
5874-
if (const auto protoTy = dyn_cast<ProtocolType>(constraint)) {
5875-
return protoTy->getDecl()->getGenericSignature().getCanonicalSignature();
5876-
}
5877-
}
5878-
5879-
// Otherwise we need to build a generic signature that captures any outer
5880-
// generic parameters. This ensures that we keep e.g. generic superclass
5881-
// existentials contained in a well-formed generic context.
58825870
auto canParentSig = parentSig.getCanonicalSignature();
58835871
auto key = std::make_pair(constraint, canParentSig.getPointer());
58845872
auto found = getImpl().ExistentialSignatures.find(key);
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// RUN: %target-swift-frontend -emit-sil -O %s -enable-experimental-feature NoncopyableGenerics | %FileCheck %s
2+
3+
protocol P: ~Copyable {}
4+
5+
@_optimize(none)
6+
func f<T: P>(_: T) {}
7+
8+
public struct S: P {
9+
@_optimize(none)
10+
init() {}
11+
}
12+
13+
// CHECK-LABEL: sil @$s44sil_combine_concrete_existential_noncopyable1gyyF : $@convention(thin) () -> () {
14+
// CHECK: [[S_ADDR:%.*]] = alloc_stack $S
15+
// CHECK: [[INIT_FN:%.*]] = function_ref @$s44sil_combine_concrete_existential_noncopyable1SVACycfC : $@convention(method) (@thin S.Type) -> S
16+
// CHECK: [[S:%.*]] = apply [[INIT_FN]]({{%.*}}) : $@convention(method) (@thin S.Type) -> S
17+
// CHECK: store [[S]] to [[S_ADDR]]
18+
// CHECK: [[CALLEE_FN:%.*]] = function_ref @$s44sil_combine_concrete_existential_noncopyable1fyyxAA1PRzlF : $@convention(thin) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> ()
19+
// CHECK: apply [[CALLEE_FN]]<S>([[S_ADDR]])
20+
// CHECK: return
21+
22+
public func g() {
23+
let e: any P = S()
24+
f(e)
25+
}

0 commit comments

Comments
 (0)