Files
swift-mirror/test/ClangModules/nullability_silgen.swift
Doug Gregor 56443538e9 Clang importer: hammer over inconsistencies between property/getter/setter optionality.
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
2015-03-17 00:03:33 +00:00

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
}