File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed
SwiftCompilerSources/Sources/Optimizer/InstructionSimplification Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -81,7 +81,9 @@ private extension UnconditionalCheckedCastInst {
8181 return
8282 }
8383 let conformance = sourceFormalType. instanceTypeOfMetatype. checkConformance ( to: proto)
84- guard conformance. isValid else {
84+ guard conformance. isValid,
85+ conformance. matchesActorIsolation ( in: parentFunction)
86+ else {
8587 return
8688 }
8789
Original file line number Diff line number Diff line change 1- // RUN: %target-sil-opt -enable-sil-verify-all %s -simplification -simplify-instruction=unconditional_checked_cast | %FileCheck %s
1+ // RUN: %target-sil-opt -enable-sil-verify-all %s -simplification -simplify-instruction=unconditional_checked_cast -enable-experimental-feature IsolatedConformances | %FileCheck %s
2+
3+ // REQUIRES: swift_feature_IsolatedConformances
4+ // REQUIRES: concurrency
25
36import Swift
47import Builtin
8+ import _Concurrency
59
610protocol P {}
711protocol PC: AnyObject {}
@@ -12,6 +16,8 @@ struct T {}
1216
1317class C {}
1418
19+ struct X : @MainActor P {}
20+
1521// CHECK-LABEL: sil [ossa] @test_conforming_struct :
1622// CHECK: %1 = init_existential_metatype %0, $@thick any P.Type
1723// CHECK-NEXT: return %1
@@ -52,3 +58,14 @@ bb0(%0 : $@thick S.Type):
5258 %1 = unconditional_checked_cast %0 to Int.Type
5359 return %1
5460}
61+
62+ // CHECK-LABEL: sil [ossa] @test_isolated_conformance :
63+ // CHECK: %1 = unconditional_checked_cast %0
64+ // CHECK-NEXT: return %1
65+ // CHECK: } // end sil function 'test_isolated_conformance'
66+ sil [ossa] @test_isolated_conformance : $@convention(thin) (@thick X.Type) -> @thick any P.Type {
67+ bb0(%0 : $@thick X.Type):
68+ %1 = unconditional_checked_cast %0 to any P.Type
69+ return %1
70+ }
71+
You can’t perform that action at this time.
0 commit comments