Files
swift-mirror/test/SILGen/nsmanaged-witness.swift
Erik Eckstein 6a020f8f15 Stabilize and simplify SIL linkage and serialization
The main point of this change is to make sure that a shared function always has a body: both, in the optimizer pipeline and in the swiftmodule file.
This is important because the compiler always needs to emit code for a shared function. Shared functions cannot be referenced from outside the module.
In several corner cases we missed to maintain this invariant which resulted in unresolved-symbol linker errors.

As side-effect of this change we can drop the shared_external SIL linkage and the IsSerializable flag, which simplifies the serialization and linkage concept.
2022-03-09 15:28:05 +01:00

66 lines
1.6 KiB
Swift

// RUN: %target-swift-emit-silgen -sdk %S/Inputs %s -I %S/Inputs -enable-source-import | %FileCheck %s
// REQUIRES: objc_interop
import Foundation
@objc protocol ObjCReadOnly {
var name: String { get }
}
@objc protocol ObjCReadWrite {
var name: String { get set }
}
class SomeObject: NSObject, ObjCReadOnly, ObjCReadWrite {
@NSManaged var name: String
}
// We should not emit references to native Swift accessors for @NSManaged
// properties.
// CHECK-NOT: hidden_external {{.*}}main{{.*}}SomeObject{{.*}}name
protocol NativeReadWrite {
var name: String { get set }
}
protocol AnotherNativeReadWrite {
var name: String { get set }
}
class SomeOtherObject: NSObject, NativeReadWrite {
@NSManaged var name: String
}
// CHECK-NOT: hidden_external {{.*}}main{{.*}}SomeOtherObject{{.*}}name
class DynamicSubObject: DynamicObject, AnotherNativeReadWrite {
override var name: String {
get { return "" }
set {}
}
}
// CHECK-NOT: hidden_external {{.*}}main{{.*}}DynamicSubObject{{.*}}name
class DynamicObject: NativeReadWrite {
@objc dynamic var name: String = ""
}
// CHECK-NOT: hidden_external {{.*}}main{{.*}}DynamicObject{{.*}}name
protocol NativeIntProperty {
var intProperty: Int32 { get set }
}
// Foo is defined in ObjC with an 'intProperty' property
extension Foo: NativeIntProperty {}
// CHECK-NOT: hidden_external {{.*}}Foo{{.*}}intProperty
// TODO: We can't emit a vtable entry for modify for ObjC types.
// CHECK-NOT: class_method {{.*}}Foo{{.*}}intProperty{{.*}}modify
// CHECK-LABEL: sil shared [serialized] [ossa] @$sSo3FooC11intPropertys5Int32VvM