File tree Expand file tree Collapse file tree 2 files changed +37
-2
lines changed Expand file tree Collapse file tree 2 files changed +37
-2
lines changed Original file line number Diff line number Diff line change @@ -1638,11 +1638,25 @@ ProtocolConformance *ProtocolConformance::getCanonicalConformance() {
1638
1638
1639
1639
switch (getKind ()) {
1640
1640
case ProtocolConformanceKind::Self:
1641
- case ProtocolConformanceKind::Normal:
1642
- case ProtocolConformanceKind::Builtin: {
1641
+ case ProtocolConformanceKind::Normal: {
1643
1642
// Root conformances are always canonical by construction.
1644
1643
return this ;
1645
1644
}
1645
+ case ProtocolConformanceKind::Builtin: {
1646
+ // Canonicalize the subject type of the builtin conformance.
1647
+ auto &Ctx = getType ()->getASTContext ();
1648
+ auto builtinConformance = cast<BuiltinProtocolConformance>(this );
1649
+ SmallVector<Requirement, 4 > canonicalRequirements;
1650
+ for (auto &reqt : builtinConformance->getConditionalRequirements ()) {
1651
+ canonicalRequirements.push_back (reqt.getCanonical ());
1652
+ }
1653
+ return Ctx.getBuiltinConformance (
1654
+ builtinConformance->getType ()->getCanonicalType (builtinConformance->getGenericSignature ()),
1655
+ builtinConformance->getProtocol (),
1656
+ builtinConformance->getGenericSignature ().getCanonicalSignature (),
1657
+ canonicalRequirements,
1658
+ builtinConformance->getBuiltinConformanceKind ());
1659
+ }
1646
1660
1647
1661
case ProtocolConformanceKind::Inherited: {
1648
1662
auto &Ctx = getType ()->getASTContext ();
Original file line number Diff line number Diff line change
1
+ // RUN: %target-swift-emit-silgen -disable-availability-checking -verify %s
2
+
3
+ // rdar://94877954
4
+
5
+ // `dynamic` prevents SILGen from lowering away
6
+ // the opaque return type of `foo`
7
+ dynamic func foo< T: Sendable > ( f: ( ) -> T ) -> some Sendable {
8
+ if #available( macOS 11 . 0 , * ) {
9
+ return f ( )
10
+ } else {
11
+ return ( )
12
+ }
13
+ }
14
+
15
+ func bar( ) {
16
+ let x : Void = ( )
17
+ let y : ( ) = ( )
18
+ var a = foo { x }
19
+ a = foo { y }
20
+ _ = a
21
+ }
You can’t perform that action at this time.
0 commit comments