mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
When an imported Objective-C property has nullability, force that nullability onto the result of its getter and the parameter of its setter, so that we have consisteny nullability among the three. SILGen assumes that this is the case, so this fixes the null_resettable-based crash in <rdar://problem/20145910>. Swift SVN r26198
20 lines
565 B
Swift
20 lines
565 B
Swift
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-silgen -I %S/Inputs/custom-modules %s | FileCheck %s
|
|
|
|
// REQUIRES: objc_interop
|
|
|
|
import nullability;
|
|
|
|
// null_resettable properties.
|
|
// CHECK-LABEL: sil hidden @_TF18nullability_silgen18testNullResettable
|
|
func testNullResettable(sc: SomeClass) {
|
|
sc.defaultedProperty = nil
|
|
sc.defaultedProperty = "hello"
|
|
let str: String = sc.defaultedProperty
|
|
if sc.defaultedProperty == nil { }
|
|
}
|
|
|
|
func testFunnyProperty(sc: SomeClass) {
|
|
sc.funnyProperty = "hello"
|
|
var str: String = sc.funnyProperty
|
|
}
|