1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490
|
// RUN: %empty-directory(%t/Frameworks)
// RUN: INPUT_DIR=%S/Inputs
// RUN: cp -R $INPUT_DIR/Alpha.framework %t/Frameworks/
// RUN: %empty-directory(%t/Frameworks/Alpha.framework/Modules/Alpha.swiftmodule)
// RUN: %empty-directory(%t/Frameworks/Alpha.framework/Headers/)
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -enable-experimental-feature IsolatedDeinit -disable-implicit-string-processing-module-import -parse-as-library -disable-availability-checking -module-name Alpha \
// RUN: -emit-module -o %t/Frameworks/Alpha.framework/Modules/Alpha.swiftmodule/%module-target-triple.swiftmodule \
// RUN: -enable-objc-interop -disable-objc-attr-requires-foundation-module \
// RUN: -emit-objc-header -emit-objc-header-path %t/Frameworks/Alpha.framework/Headers/Alpha-Swift.h $INPUT_DIR/Alpha.swift
// RUN: cp -R $INPUT_DIR/Beta.framework %t/Frameworks/
// RUN: %empty-directory(%t/Frameworks/Beta.framework/Headers/)
// RUN: cp $INPUT_DIR/Beta.h %t/Frameworks/Beta.framework/Headers/Beta.h
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -enable-experimental-feature IsolatedDeinit -disable-implicit-string-processing-module-import -disable-availability-checking -typecheck -verify %s -F %t/Frameworks -F %clang-importer-sdk-path/frameworks
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -enable-experimental-feature IsolatedDeinit -disable-implicit-string-processing-module-import -disable-availability-checking -parse-as-library -emit-silgen -DSILGEN %s -F %t/Frameworks -F %clang-importer-sdk-path/frameworks | %FileCheck %s
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -enable-experimental-feature IsolatedDeinit -disable-implicit-string-processing-module-import -disable-availability-checking -parse-as-library -emit-silgen -DSILGEN %s -F %t/Frameworks -F %clang-importer-sdk-path/frameworks | %FileCheck -check-prefix=CHECK-SYMB %s
// REQUIRES: concurrency
// REQUIRES: objc_interop
// REQUIRES: swift_feature_IsolatedDeinit
// Note: intentionally importing Alpha implicitly
import Beta
@globalActor final actor AnotherActor {
static let shared = AnotherActor()
}
// MARK: - RoundtripNonisolated
@MainActor
func isolatedFunc() {} // expected-note 15{{calls to global function 'isolatedFunc()' from outside of its actor context are implicitly asynchronous}}
// CHECK-LABEL: @objc @_inheritsConvenienceInitializers class ProbeImplicit_RoundtripNonisolated : RoundtripNonisolated {
// CHECK: @objc deinit
// CHECK: }
// CHECK-SYMB-NOT: ProbeImplicit_RoundtripNonisolated.__isolated_deallocating_deinit
// CHECK-SYMB-NOT: @$s4test34ProbeImplicit_RoundtripNonisolatedCfZ
// CHECK-SYMB: // ProbeImplicit_RoundtripNonisolated.__deallocating_deinit
// CHECK-SYMB-NEXT: // Isolation: nonisolated
// CHECK-SYMB-NEXT: sil hidden [ossa] @$s4test34ProbeImplicit_RoundtripNonisolatedCfD : $@convention(method) (@owned ProbeImplicit_RoundtripNonisolated) -> () {
class ProbeImplicit_RoundtripNonisolated: RoundtripNonisolated {}
// CHECK-LABEL: @objc @_inheritsConvenienceInitializers class ProbeDefault_RoundtripNonisolated : RoundtripNonisolated {
// CHECK: @objc deinit
// CHECK: }
// CHECK-SYMB-NOT: ProbeDefault_RoundtripNonisolated.__isolated_deallocating_deinit
// CHECK-SYMB-NOT: @$s4test33ProbeDefault_RoundtripNonisolatedCfZ
// CHECK-SYMB: // ProbeDefault_RoundtripNonisolated.__deallocating_deinit
// CHECK-SYMB-NEXT: // Isolation: nonisolated
// CHECK-SYMB-NEXT: sil hidden [ossa] @$s4test33ProbeDefault_RoundtripNonisolatedCfD : $@convention(method) (@owned ProbeDefault_RoundtripNonisolated) -> () {
class ProbeDefault_RoundtripNonisolated: RoundtripNonisolated {
deinit {
#if !SILGEN
isolatedFunc() // expected-error {{call to main actor-isolated global function 'isolatedFunc()' in a synchronous nonisolated context}}
#endif
}
}
#if !SILGEN
class ProbeIsolated_RoundtripNonisolated: RoundtripNonisolated {
isolated deinit { // expected-error {{deinit is marked isolated, but containing class 'ProbeIsolated_RoundtripNonisolated' is not isolated to an actor}}
isolatedFunc() // expected-error {{call to main actor-isolated global function 'isolatedFunc()' in a synchronous nonisolated context}}
}
}
#endif
// CHECK-LABEL: @objc @_inheritsConvenienceInitializers class ProbeGlobal_RoundtripNonisolated : RoundtripNonisolated {
// CHECK: @objc @AnotherActor deinit
// CHECK: }
// CHECK-SYMB: ProbeGlobal_RoundtripNonisolated.__isolated_deallocating_deinit
// CHECK-SYMB-NEXT: // Isolation: global_actor. type: AnotherActor
// CHECK-SYMB-NEXT: sil hidden [ossa] @$s4test32ProbeGlobal_RoundtripNonisolatedCfZ : $@convention(thin) (@owned ProbeGlobal_RoundtripNonisolated) -> () {
// CHECK-SYMB: // ProbeGlobal_RoundtripNonisolated.__deallocating_deinit
// CHECK-SYMB-NEXT: // Isolation: nonisolated
// CHECK-SYMB-NEXT: sil hidden [ossa] @$s4test32ProbeGlobal_RoundtripNonisolatedCfD : $@convention(method) (@owned ProbeGlobal_RoundtripNonisolated) -> () {
class ProbeGlobal_RoundtripNonisolated: RoundtripNonisolated {
@AnotherActor deinit {
#if !SILGEN
isolatedFunc() // expected-error {{call to main actor-isolated global function 'isolatedFunc()' in a synchronous global actor 'AnotherActor'-isolated context}}
#endif
}
}
// MARK: - RoundtripIsolated
// CHECK-LABEL: @objc @_inheritsConvenienceInitializers class ProbeImplicit_RoundtripIsolated : RoundtripIsolated {
// Note: Type-checked as isolated, but no @MainActor attribute, because attributes are not added for overriding members
// CHECK: @objc deinit
// CHECK: }
// CHECK-SYMB: ProbeImplicit_RoundtripIsolated.__isolated_deallocating_deinit
// CHECK-SYMB-NEXT: // Isolation: global_actor. type: MainActor
// CHECK-SYMB-NEXT: sil hidden [ossa] @$s4test31ProbeImplicit_RoundtripIsolatedCfZ : $@convention(thin) (@owned ProbeImplicit_RoundtripIsolated) -> () {
// CHECK-SYMB: // ProbeImplicit_RoundtripIsolated.__deallocating_deinit
// CHECK-SYMB-NEXT: // Isolation: nonisolated
// CHECK-SYMB-NEXT: sil hidden [ossa] @$s4test31ProbeImplicit_RoundtripIsolatedCfD : $@convention(method) (@owned ProbeImplicit_RoundtripIsolated) -> () {
class ProbeImplicit_RoundtripIsolated: RoundtripIsolated {}
#if !SILGEN
class ProbeDefault_RoundtripIsolated: RoundtripIsolated {
deinit {} // expected-error {{nonisolated deinitializer 'deinit' has different actor isolation from main actor-isolated overridden declaration}}
}
#endif
#if !SILGEN
class ProbeIsolated_RoundtripIsolated: RoundtripIsolated {
isolated deinit { // expected-error {{deinit is marked isolated, but containing class 'ProbeIsolated_RoundtripIsolated' is not isolated to an actor}}
isolatedFunc() // ok, isolation of the overridden deinit is used as a recovery strategy
}
}
#endif
// CHECK-LABEL: @objc @_inheritsConvenienceInitializers class ProbeGlobal_RoundtripIsolated : RoundtripIsolated {
// CHECK: @objc @MainActor deinit
// CHECK: }
// CHECK-SYMB: ProbeGlobal_RoundtripIsolated.__isolated_deallocating_deinit
// CHECK-SYMB-NEXT: // Isolation: global_actor. type: MainActor
// CHECK-SYMB-NEXT: sil hidden [ossa] @$s4test29ProbeGlobal_RoundtripIsolatedCfZ : $@convention(thin) (@owned ProbeGlobal_RoundtripIsolated) -> () {
// CHECK-SYMB: // ProbeGlobal_RoundtripIsolated.__deallocating_deinit
// CHECK-SYMB-NEXT: // Isolation: nonisolated
// CHECK-SYMB-NEXT: sil hidden [ossa] @$s4test29ProbeGlobal_RoundtripIsolatedCfD : $@convention(method) (@owned ProbeGlobal_RoundtripIsolated) -> () {
class ProbeGlobal_RoundtripIsolated: RoundtripIsolated {
#if !SILGEN
@AnotherActor deinit {} // expected-error {{global actor 'AnotherActor'-isolated deinitializer 'deinit' has different actor isolation from main actor-isolated overridden declaration}}
#else
@MainActor deinit {}
#endif
}
// MARK: - BaseNonisolated
// CHECK-LABEL: @objc @_inheritsConvenienceInitializers class ProbeImplicit_BaseNonisolated : BaseNonisolated {
// CHECK: @objc deinit
// CHECK: }
// CHECK-SYMB-NOT: ProbeImplicit_BaseNonisolated.__isolated_deallocating_deinit
// CHECK-SYMB-NOT: @$s4test29ProbeImplicit_BaseNonisolatedCfZ
// CHECK-SYMB: // ProbeImplicit_BaseNonisolated.__deallocating_deinit
// CHECK-SYMB-NEXT: // Isolation: nonisolated
// CHECK-SYMB-NEXT: sil hidden [ossa] @$s4test29ProbeImplicit_BaseNonisolatedCfD : $@convention(method) (@owned ProbeImplicit_BaseNonisolated) -> () {
class ProbeImplicit_BaseNonisolated: BaseNonisolated {}
// CHECK-LABEL: @objc @_inheritsConvenienceInitializers class ProbeDefault_BaseNonisolated : BaseNonisolated {
// CHECK: @objc deinit
// CHECK: }
// CHECK-SYMB-NOT: ProbeDefault_BaseNonisolated.__isolated_deallocating_deinit
// CHECK-SYMB-NOT: @$s4test28ProbeDefault_BaseNonisolatedCfZ
// CHECK-SYMB: // ProbeDefault_BaseNonisolated.__deallocating_deinit
// CHECK-SYMB-NEXT: // Isolation: nonisolated
// CHECK-SYMB-NEXT: sil hidden [ossa] @$s4test28ProbeDefault_BaseNonisolatedCfD : $@convention(method) (@owned ProbeDefault_BaseNonisolated) -> () {
class ProbeDefault_BaseNonisolated: BaseNonisolated {
deinit {
#if !SILGEN
isolatedFunc() // expected-error {{call to main actor-isolated global function 'isolatedFunc()' in a synchronous nonisolated context}}
#endif
}
}
#if !SILGEN
class ProbeIsolated_BaseNonisolated: BaseNonisolated {
isolated deinit { // expected-error {{deinit is marked isolated, but containing class 'ProbeIsolated_BaseNonisolated' is not isolated to an actor}}
isolatedFunc() // expected-error {{call to main actor-isolated global function 'isolatedFunc()' in a synchronous nonisolated context}}
}
}
#endif
// CHECK-LABEL: @objc @_inheritsConvenienceInitializers class ProbeGlobal_BaseNonisolated : BaseNonisolated {
// CHECK: @objc @AnotherActor deinit
// CHECK: }
// CHECK-SYMB: ProbeGlobal_BaseNonisolated.__isolated_deallocating_deinit
// CHECK-SYMB-NEXT: // Isolation: global_actor. type: AnotherActor
// CHECK-SYMB-NEXT: sil hidden [ossa] @$s4test27ProbeGlobal_BaseNonisolatedCfZ : $@convention(thin) (@owned ProbeGlobal_BaseNonisolated) -> () {
// CHECK-SYMB: // ProbeGlobal_BaseNonisolated.__deallocating_deinit
// CHECK-SYMB-NEXT: // Isolation: nonisolated
// CHECK-SYMB-NEXT: sil hidden [ossa] @$s4test27ProbeGlobal_BaseNonisolatedCfD : $@convention(method) (@owned ProbeGlobal_BaseNonisolated) -> () {
class ProbeGlobal_BaseNonisolated: BaseNonisolated {
@AnotherActor deinit {
#if !SILGEN
isolatedFunc() // expected-error {{call to main actor-isolated global function 'isolatedFunc()' in a synchronous global actor 'AnotherActor'-isolated context}}
#endif
}
}
// MARK: - DerivedNonisolated
// CHECK-LABEL: @objc @_inheritsConvenienceInitializers class ProbeImplicit_DerivedNonisolated : DerivedNonisolated {
// CHECK: @objc deinit
// CHECK: }
// CHECK-SYMB-NOT: ProbeImplicit_DerivedNonisolated.__isolated_deallocating_deinit
// CHECK-SYMB-NOT: @$s4test32ProbeImplicit_DerivedNonisolatedCfZ
// CHECK-SYMB: // ProbeImplicit_DerivedNonisolated.__deallocating_deinit
// CHECK-SYMB-NEXT: // Isolation: nonisolated
// CHECK-SYMB-NEXT: sil hidden [ossa] @$s4test32ProbeImplicit_DerivedNonisolatedCfD : $@convention(method) (@owned ProbeImplicit_DerivedNonisolated) -> () {
class ProbeImplicit_DerivedNonisolated: DerivedNonisolated {}
// CHECK-LABEL: @objc @_inheritsConvenienceInitializers class ProbeDefault_DerivedNonisolated : DerivedNonisolated {
// CHECK: @objc deinit
// CHECK: }
// CHECK-SYMB-NOT: ProbeDefault_DerivedNonisolated.__isolated_deallocating_deinit
// CHECK-SYMB-NOT: @$s4test31ProbeDefault_DerivedNonisolatedCfZ
// CHECK-SYMB: // ProbeDefault_DerivedNonisolated.__deallocating_deinit
// CHECK-SYMB-NEXT: // Isolation: nonisolated
// CHECK-SYMB-NEXT: sil hidden [ossa] @$s4test31ProbeDefault_DerivedNonisolatedCfD : $@convention(method) (@owned ProbeDefault_DerivedNonisolated) -> () {
class ProbeDefault_DerivedNonisolated: DerivedNonisolated {
deinit {
#if !SILGEN
isolatedFunc() // expected-error {{call to main actor-isolated global function 'isolatedFunc()' in a synchronous nonisolated context}}
#endif
}
}
#if !SILGEN
class ProbeIsolated_DerivedNonisolated: DerivedNonisolated {
isolated deinit { // expected-error {{deinit is marked isolated, but containing class 'ProbeIsolated_DerivedNonisolated' is not isolated to an actor}}
isolatedFunc() // expected-error {{call to main actor-isolated global function 'isolatedFunc()' in a synchronous nonisolated context}}
}
}
#endif
// CHECK-LABEL: @objc @_inheritsConvenienceInitializers class ProbeGlobal_DerivedNonisolated : DerivedNonisolated {
// CHECK: @objc @AnotherActor deinit
// CHECK: }
// CHECK-SYMB: ProbeGlobal_DerivedNonisolated.__isolated_deallocating_deinit
// CHECK-SYMB-NEXT: // Isolation: global_actor. type: AnotherActor
// CHECK-SYMB-NEXT: sil hidden [ossa] @$s4test30ProbeGlobal_DerivedNonisolatedCfZ : $@convention(thin) (@owned ProbeGlobal_DerivedNonisolated) -> () {
// CHECK-SYMB: // ProbeGlobal_DerivedNonisolated.__deallocating_deinit
// CHECK-SYMB-NEXT: // Isolation: nonisolated
// CHECK-SYMB-NEXT: sil hidden [ossa] @$s4test30ProbeGlobal_DerivedNonisolatedCfD : $@convention(method) (@owned ProbeGlobal_DerivedNonisolated) -> () {
class ProbeGlobal_DerivedNonisolated: DerivedNonisolated {
@AnotherActor deinit {
#if !SILGEN
isolatedFunc() // expected-error {{call to main actor-isolated global function 'isolatedFunc()' in a synchronous global actor 'AnotherActor'-isolated context}}
#endif
}
}
// MARK: - BaseIsolatedClass
// CHECK-LABEL: @objc @_inheritsConvenienceInitializers @MainActor @preconcurrency class ProbeImplicit_BaseIsolatedClass : BaseIsolatedClass {
// CHECK: @objc deinit
// CHECK: }
// CHECK-SYMB-NOT: ProbeImplicit_BaseIsolatedClass.__isolated_deallocating_deinit
// CHECK-SYMB-NOT: @$s4test31ProbeImplicit_BaseIsolatedClassCfZ
// CHECK-SYMB: // ProbeImplicit_BaseIsolatedClass.__deallocating_deinit
// CHECK-SYMB-NEXT: // Isolation: nonisolated
// CHECK-SYMB-NEXT: sil hidden [ossa] @$s4test31ProbeImplicit_BaseIsolatedClassCfD : $@convention(method) (@owned ProbeImplicit_BaseIsolatedClass) -> () {
class ProbeImplicit_BaseIsolatedClass: BaseIsolatedClass {}
// CHECK-LABEL: @objc @_inheritsConvenienceInitializers @MainActor @preconcurrency class ProbeDefault_BaseIsolatedClass : BaseIsolatedClass {
// CHECK: @objc deinit
// CHECK: }
// CHECK-SYMB-NOT: ProbeDefault_BaseIsolatedClass.__isolated_deallocating_deinit
// CHECK-SYMB-NOT: @$s4test30ProbeDefault_BaseIsolatedClassCfZ
// CHECK-SYMB: // ProbeDefault_BaseIsolatedClass.__deallocating_deinit
// CHECK-SYMB-NEXT: // Isolation: nonisolated
// CHECK-SYMB-NEXT: sil hidden [ossa] @$s4test30ProbeDefault_BaseIsolatedClassCfD : $@convention(method) (@owned ProbeDefault_BaseIsolatedClass) -> () {
class ProbeDefault_BaseIsolatedClass: BaseIsolatedClass {
deinit {
#if !SILGEN
isolatedFunc() // expected-error {{call to main actor-isolated global function 'isolatedFunc()' in a synchronous nonisolated context}}
#endif
}
}
// CHECK-LABEL: @objc @_inheritsConvenienceInitializers @MainActor @preconcurrency class ProbeIsolated_BaseIsolatedClass : BaseIsolatedClass {
// CHECK: @objc @preconcurrency isolated deinit
// CHECK: }
// CHECK-SYMB: ProbeIsolated_BaseIsolatedClass.__isolated_deallocating_deinit
// CHECK-SYMB-NEXT: // Isolation: global_actor. type: MainActor
// CHECK-SYMB-NEXT: sil hidden [ossa] @$s4test018ProbeIsolated_BaseC5ClassCfZ : $@convention(thin) (@owned ProbeIsolated_BaseIsolatedClass) -> () {
// CHECK-SYMB: // ProbeIsolated_BaseIsolatedClass.__deallocating_deinit
// CHECK-SYMB-NEXT: // Isolation: nonisolated
// CHECK-SYMB-NEXT: sil hidden [ossa] @$s4test018ProbeIsolated_BaseC5ClassCfD : $@convention(method) (@owned ProbeIsolated_BaseIsolatedClass) -> () {
class ProbeIsolated_BaseIsolatedClass: BaseIsolatedClass {
isolated deinit {
isolatedFunc()
}
}
// CHECK-LABEL: @objc @_inheritsConvenienceInitializers @MainActor @preconcurrency class ProbeGlobal_BaseIsolatedClass : BaseIsolatedClass {
// CHECK: @objc @AnotherActor deinit
// CHECK: }
// CHECK-SYMB: ProbeGlobal_BaseIsolatedClass.__isolated_deallocating_deinit
// CHECK-SYMB-NEXT: // Isolation: global_actor. type: AnotherActor
// CHECK-SYMB-NEXT: sil hidden [ossa] @$s4test29ProbeGlobal_BaseIsolatedClassCfZ : $@convention(thin) (@owned ProbeGlobal_BaseIsolatedClass) -> () {
// CHECK-SYMB: // ProbeGlobal_BaseIsolatedClass.__deallocating_deinit
// CHECK-SYMB-NEXT: // Isolation: nonisolated
// CHECK-SYMB-NEXT: sil hidden [ossa] @$s4test29ProbeGlobal_BaseIsolatedClassCfD : $@convention(method) (@owned ProbeGlobal_BaseIsolatedClass) -> () {
class ProbeGlobal_BaseIsolatedClass: BaseIsolatedClass {
@AnotherActor deinit {
#if !SILGEN
isolatedFunc() // expected-error {{call to main actor-isolated global function 'isolatedFunc()' in a synchronous global actor 'AnotherActor'-isolated context}}
#endif
}
}
// MARK: - DerivedIsolatedClass
// CHECK-LABEL: @objc @_inheritsConvenienceInitializers @MainActor @preconcurrency class ProbeImplicit_DerivedIsolatedClass : DerivedIsolatedClass {
// CHECK: @objc deinit
// CHECK: }
// CHECK-SYMB-NOT: ProbeImplicit_DerivedIsolatedClass.__isolated_deallocating_deinit
// CHECK-SYMB-NOT: @$s4test34ProbeImplicit_DerivedIsolatedClassCfZ
// CHECK-SYMB: // ProbeImplicit_DerivedIsolatedClass.__deallocating_deinit
// CHECK-SYMB-NEXT: // Isolation: nonisolated
// CHECK-SYMB-NEXT: sil hidden [ossa] @$s4test34ProbeImplicit_DerivedIsolatedClassCfD : $@convention(method) (@owned ProbeImplicit_DerivedIsolatedClass) -> () {
class ProbeImplicit_DerivedIsolatedClass: DerivedIsolatedClass {}
// CHECK-LABEL: @objc @_inheritsConvenienceInitializers @MainActor @preconcurrency class ProbeDefault_DerivedIsolatedClass : DerivedIsolatedClass {
// CHECK: @objc deinit
// CHECK: }
// CHECK-SYMB-NOT: ProbeDefault_DerivedIsolatedClass.__isolated_deallocating_deinit
// CHECK-SYMB-NOT: @$s4test33ProbeDefault_DerivedIsolatedClassCfZ
// CHECK-SYMB: // ProbeDefault_DerivedIsolatedClass.__deallocating_deinit
// CHECK-SYMB-NEXT: // Isolation: nonisolated
// CHECK-SYMB-NEXT: sil hidden [ossa] @$s4test33ProbeDefault_DerivedIsolatedClassCfD : $@convention(method) (@owned ProbeDefault_DerivedIsolatedClass) -> () {
class ProbeDefault_DerivedIsolatedClass: DerivedIsolatedClass {
deinit {
#if !SILGEN
isolatedFunc() // expected-error {{call to main actor-isolated global function 'isolatedFunc()' in a synchronous nonisolated context}}
#endif
}
}
// CHECK-LABEL: @objc @_inheritsConvenienceInitializers @MainActor @preconcurrency class ProbeIsolated_DerivedIsolatedClass : DerivedIsolatedClass {
// CHECK: @objc @preconcurrency isolated deinit
// CHECK: }
// CHECK-SYMB: ProbeIsolated_DerivedIsolatedClass.__isolated_deallocating_deinit
// CHECK-SYMB-NEXT: // Isolation: global_actor. type: MainActor
// CHECK-SYMB-NEXT: sil hidden [ossa] @$s4test021ProbeIsolated_DerivedC5ClassCfZ : $@convention(thin) (@owned ProbeIsolated_DerivedIsolatedClass) -> () {
// CHECK-SYMB: // ProbeIsolated_DerivedIsolatedClass.__deallocating_deinit
// CHECK-SYMB-NEXT: // Isolation: nonisolated
// CHECK-SYMB-NEXT: sil hidden [ossa] @$s4test021ProbeIsolated_DerivedC5ClassCfD : $@convention(method) (@owned ProbeIsolated_DerivedIsolatedClass) -> () {
class ProbeIsolated_DerivedIsolatedClass: DerivedIsolatedClass {
isolated deinit {
isolatedFunc()
}
}
// CHECK-LABEL: @objc @_inheritsConvenienceInitializers @MainActor @preconcurrency class ProbeGlobal_DerivedIsolatedClass : DerivedIsolatedClass {
// CHECK: @objc @AnotherActor deinit
// CHECK: }
// CHECK-SYMB: ProbeGlobal_DerivedIsolatedClass.__isolated_deallocating_deinit
// CHECK-SYMB-NEXT: // Isolation: global_actor. type: AnotherActor
// CHECK-SYMB-NEXT: sil hidden [ossa] @$s4test32ProbeGlobal_DerivedIsolatedClassCfZ : $@convention(thin) (@owned ProbeGlobal_DerivedIsolatedClass) -> () {
// CHECK-SYMB: // ProbeGlobal_DerivedIsolatedClass.__deallocating_deinit
// CHECK-SYMB-NEXT: // Isolation: nonisolated
// CHECK-SYMB-NEXT: sil hidden [ossa] @$s4test32ProbeGlobal_DerivedIsolatedClassCfD : $@convention(method) (@owned ProbeGlobal_DerivedIsolatedClass) -> () {
class ProbeGlobal_DerivedIsolatedClass: DerivedIsolatedClass {
@AnotherActor deinit {
#if !SILGEN
isolatedFunc() // expected-error {{call to main actor-isolated global function 'isolatedFunc()' in a synchronous global actor 'AnotherActor'-isolated context}}
#endif
}
}
// MARK: - BaseIsolatedDealloc
// If isolation was introduced in ObjC code, then we assume that ObjC code also
// overrides retain/release to make sure that dealloc is called on the correct
// executor in the first place.
// CHECK-LABEL: @objc @_inheritsConvenienceInitializers class ProbeImplicit_BaseIsolatedDealloc : BaseIsolatedDealloc {
// CHECK: @objc deinit
// CHECK: }
// CHECK-SYMB-NOT: ProbeImplicit_BaseIsolatedDealloc.__isolated_deallocating_deinit
// CHECK-SYMB-NOT: @$s4test33ProbeImplicit_BaseIsolatedDeallocCfZ
// CHECK-SYMB: // ProbeImplicit_BaseIsolatedDealloc.__deallocating_deinit
// CHECK-SYMB-NEXT: // Isolation: nonisolated
// CHECK-SYMB-NEXT: sil hidden [ossa] @$s4test33ProbeImplicit_BaseIsolatedDeallocCfD : $@convention(method) (@owned ProbeImplicit_BaseIsolatedDealloc) -> () {
class ProbeImplicit_BaseIsolatedDealloc: BaseIsolatedDealloc {}
#if !SILGEN
class ProbeDefault_BaseIsolatedDealloc: BaseIsolatedDealloc {
deinit { // expected-error {{nonisolated deinitializer 'deinit' has different actor isolation from main actor-isolated overridden declaration}}
isolatedFunc() // expected-error {{call to main actor-isolated global function 'isolatedFunc()' in a synchronous nonisolated context}}
}
}
#endif
#if !SILGEN
class ProbeIsolated_BaseIsolatedDealloc: BaseIsolatedDealloc {
isolated deinit { //expected-error {{deinit is marked isolated, but containing class 'ProbeIsolated_BaseIsolatedDealloc' is not isolated to an actor}}
isolatedFunc() // ok, isolation of the overridden deinit is used as a recovery strategy
}
}
#endif
// CHECK-LABEL: @objc @_inheritsConvenienceInitializers class ProbeGlobal_BaseIsolatedDealloc : BaseIsolatedDealloc {
// CHECK: @objc @MainActor deinit
// CHECK: }
// CHECK-SYMB-NOT: ProbeGlobal_BaseIsolatedDealloc.__isolated_deallocating_deinit
// CHECK-SYMB-NOT: @$s4test31ProbeGlobal_BaseIsolatedDeallocCfZ
// CHECK-SYMB: // ProbeGlobal_BaseIsolatedDealloc.__deallocating_deinit
// CHECK-SYMB-NEXT: // Isolation: nonisolated
// CHECK-SYMB-NEXT: sil hidden [ossa] @$s4test31ProbeGlobal_BaseIsolatedDeallocCfD : $@convention(method) (@owned ProbeGlobal_BaseIsolatedDealloc) -> () {
class ProbeGlobal_BaseIsolatedDealloc: BaseIsolatedDealloc {
#if !SILGEN
@AnotherActor deinit {} // expected-error {{global actor 'AnotherActor'-isolated deinitializer 'deinit' has different actor isolation from main actor-isolated overridden declaration}}
#else
@MainActor deinit {}
#endif
}
// MARK: - DerivedIsolatedDealloc
// CHECK-LABEL: @objc @_inheritsConvenienceInitializers class ProbeImplicit_DerivedIsolatedDealloc : DerivedIsolatedDealloc {
// Note: Type-checked as isolated, but no @MainActor attribute, because attributes are not added for overriding members
// CHECK: @objc deinit
// CHECK: }
// CHECK-SYMB-NOT: ProbeImplicit_DerivedIsolatedDealloc.__isolated_deallocating_deinit
// CHECK-SYMB-NOT: @$s4test36ProbeImplicit_DerivedIsolatedDeallocCfZ
// CHECK-SYMB: // ProbeImplicit_DerivedIsolatedDealloc.__deallocating_deinit
// CHECK-SYMB-NEXT: // Isolation: nonisolated
// CHECK-SYMB-NEXT: sil hidden [ossa] @$s4test36ProbeImplicit_DerivedIsolatedDeallocCfD : $@convention(method) (@owned ProbeImplicit_DerivedIsolatedDealloc) -> () {
class ProbeImplicit_DerivedIsolatedDealloc: DerivedIsolatedDealloc {}
#if !SILGEN
class ProbeDefault_DerivedIsolatedDealloc: DerivedIsolatedDealloc {
deinit { // expected-error {{nonisolated deinitializer 'deinit' has different actor isolation from main actor-isolated overridden declaration}}
isolatedFunc() // expected-error {{call to main actor-isolated global function 'isolatedFunc()' in a synchronous nonisolated context}}
}
}
#endif
#if !SILGEN
class ProbeIsolated_DerivedIsolatedDealloc: DerivedIsolatedDealloc {
isolated deinit { //expected-error {{deinit is marked isolated, but containing class 'ProbeIsolated_DerivedIsolatedDealloc' is not isolated to an actor}}
isolatedFunc() // ok, isolation of the overridden deinit is used as a recovery strategy
}
}
#endif
// CHECK-LABEL: @objc @_inheritsConvenienceInitializers class ProbeGlobal_DerivedIsolatedDealloc : DerivedIsolatedDealloc {
// CHECK: @objc @MainActor deinit
// CHECK: }
// CHECK-SYMB-NOT: ProbeGlobal_DerivedIsolatedDealloc.__isolated_deallocating_deinit
// CHECK-SYMB-NOT: @$s4test34ProbeGlobal_DerivedIsolatedDeallocCfZ
// CHECK-SYMB: // ProbeGlobal_DerivedIsolatedDealloc.__deallocating_deinit
// CHECK-SYMB-NEXT: // Isolation: nonisolated
// CHECK-SYMB-NEXT: sil hidden [ossa] @$s4test34ProbeGlobal_DerivedIsolatedDeallocCfD : $@convention(method) (@owned ProbeGlobal_DerivedIsolatedDealloc) -> () {
class ProbeGlobal_DerivedIsolatedDealloc: DerivedIsolatedDealloc {
#if !SILGEN
@AnotherActor deinit {} // expected-error {{global actor 'AnotherActor'-isolated deinitializer 'deinit' has different actor isolation from main actor-isolated overridden declaration}}
#else
@MainActor deinit {}
#endif
}
// MARK: - Isolated dealloc outside main declaration
// CHECK-LABEL: @objc @_inheritsConvenienceInitializers class ProbeImplicit_DeallocIsolatedFromProtocol : DeallocIsolatedFromProtocol {
// CHECK: @objc deinit
// CHECK: }
// CHECK-SYMB-NOT: ProbeImplicit_DeallocIsolatedFromProtocol.__isolated_deallocating_deinit
// CHECK-SYMB-NOT: @$s4test41ProbeImplicit_DeallocIsolatedFromProtocolCfZ
// CHECK-SYMB: // ProbeImplicit_DeallocIsolatedFromProtocol.__deallocating_deinit
// CHECK-SYMB-NEXT: // Isolation: nonisolated
// CHECK-SYMB-NEXT: sil hidden [ossa] @$s4test41ProbeImplicit_DeallocIsolatedFromProtocolCfD : $@convention(method) (@owned ProbeImplicit_DeallocIsolatedFromProtocol) -> () {
class ProbeImplicit_DeallocIsolatedFromProtocol: DeallocIsolatedFromProtocol {}
class ProbeGlobal_DeallocIsolatedFromProtocol: DeallocIsolatedFromProtocol {
@AnotherActor deinit {} // ok, base is not isolated
}
// CHECK-LABEL: @objc @_inheritsConvenienceInitializers class ProbeImplicit_DeallocIsolatedFromCategory : DeallocIsolatedFromCategory {
// CHECK: @objc deinit
// CHECK: }
// CHECK-SYMB-NOT: ProbeImplicit_DeallocIsolatedFromCategory.__isolated_deallocating_deinit
// CHECK-SYMB-NOT: @$s4test41ProbeImplicit_DeallocIsolatedFromCategoryCfZ
// CHECK-SYMB: // ProbeImplicit_DeallocIsolatedFromCategory.__deallocating_deinit
// CHECK-SYMB-NEXT: // Isolation: nonisolated
// CHECK-SYMB-NEXT: sil hidden [ossa] @$s4test41ProbeImplicit_DeallocIsolatedFromCategoryCfD : $@convention(method) (@owned ProbeImplicit_DeallocIsolatedFromCategory) -> () {
class ProbeImplicit_DeallocIsolatedFromCategory: DeallocIsolatedFromCategory {}
class ProbeGlobal_DeallocIsolatedFromCategory: DeallocIsolatedFromCategory {
@AnotherActor deinit {} // ok, base is not isolated
}
// CHECK-LABEL: @objc @_inheritsConvenienceInitializers class ProbeImplicit_DeallocIsolatedFromExtension : DeallocIsolatedFromExtension {
// CHECK: @objc deinit
// CHECK: }
// CHECK-SYMB-NOT: ProbeImplicit_DeallocIsolatedFromExtension.__isolated_deallocating_deinit
// CHECK-SYMB-NOT: @$s4test42ProbeImplicit_DeallocIsolatedFromExtensionCfZ
// CHECK-SYMB: // ProbeImplicit_DeallocIsolatedFromExtension.__deallocating_deinit
// CHECK-SYMB-NEXT: // Isolation: nonisolated
// CHECK-SYMB-NEXT: sil hidden [ossa] @$s4test42ProbeImplicit_DeallocIsolatedFromExtensionCfD : $@convention(method) (@owned ProbeImplicit_DeallocIsolatedFromExtension) -> () {
class ProbeImplicit_DeallocIsolatedFromExtension: DeallocIsolatedFromExtension {}
class ProbeGlobal_DeallocIsolatedFromExtension: DeallocIsolatedFromExtension {
@AnotherActor deinit {} // ok, base is not isolated
}
|