mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Introduce a new runtime entry point,
`swift_objc_swift3ImplicitObjCEntrypoint`, which is called from any
Objective-C method that was generated due to `@objc` inference rules
that were removed by SE-0160. Aside from being a central place where
users can set a breakpoint to catch when this occurs, this operation
provides logging capabilities that can be enabled by setting the
environment variable SWIFT_DEBUG_IMPLICIT_OBJC_ENTRYPOINT:
SWIFT_DEBUG_IMPLICIT_OBJC_ENTRYPOINT=0 (default): do not log
SWIFT_DEBUG_IMPLICIT_OBJC_ENTRYPOINT=1: log failed messages
SWIFT_DEBUG_IMPLICIT_OBJC_ENTRYPOINT=2: log failed messages with
backtrace
SWIFT_DEBUG_IMPLICIT_OBJC_ENTRYPOINT=3: log failed messages with
backtrace and abort the process.
The log messages look something like:
***Swift runtime: entrypoint -[t.MyClass foo] generated by
implicit @objc inference is deprecated and will be removed in
Swift 4
49 lines
1.8 KiB
Swift
49 lines
1.8 KiB
Swift
// RUN: rm -rf %t && mkdir -p %t
|
|
// RUN: %target-build-swift %s -o %t/a.out
|
|
// RUN: %target-run %t/a.out 2>&1 | %FileCheck %s -check-prefix=CHECK_NOTHING
|
|
// RUN: env SWIFT_DEBUG_IMPLICIT_OBJC_ENTRYPOINT=0 %target-run %t/a.out 2>&1 | %FileCheck %s -check-prefix=CHECK_NOTHING
|
|
|
|
// RUN: env SWIFT_DEBUG_IMPLICIT_OBJC_ENTRYPOINT=1 %target-run %t/a.out > %t/level1.log 2>&1
|
|
// RUN: %FileCheck %s -check-prefix=CHECK_WARNINGS < %t/level1.log
|
|
|
|
// RUN: env SWIFT_DEBUG_IMPLICIT_OBJC_ENTRYPOINT=2 %target-run %t/a.out > %t/level2.log 2>&1
|
|
// RUN: %FileCheck %s -check-prefix=CHECK_WARNINGS < %t/level2.log
|
|
|
|
// RUN: SWIFT_DEBUG_IMPLICIT_OBJC_ENTRYPOINT=3 not --crash %target-run %t/a.out > %t/level3.log 2>&1
|
|
// RUN: %FileCheck %s -check-prefix=CHECK_CRASH < %t/level3.log
|
|
|
|
// REQUIRES: executable_test
|
|
// REQUIRES: objc_interop
|
|
|
|
import StdlibUnittest
|
|
import Foundation
|
|
import Darwin
|
|
|
|
// var ObjCFailableInitTestSuite = TestSuite("ObjCFailableInit")
|
|
|
|
class MyClass : NSObject {
|
|
func foo() { }
|
|
class func bar() { }
|
|
}
|
|
|
|
let x = MyClass()
|
|
let fooSel = "foo"
|
|
let barSel = "bar"
|
|
|
|
// CHECK_NOTHING: ---Begin
|
|
// CHECK_WARNINGS: ---Begin
|
|
// CHECK_CRASH: ---Begin
|
|
fputs("---Begin\n", stderr)
|
|
|
|
// CHECK_WARNINGS: ***Swift runtime: entrypoint -[a.MyClass foo] generated by implicit @objc inference is deprecated and will be removed in Swift 4
|
|
// CHECK_CRASH: ***Swift runtime: entrypoint -[a.MyClass foo] generated by implicit @objc inference is deprecated and will be removed in Swift 4
|
|
x.perform(Selector(fooSel))
|
|
|
|
// CHECK_WARNINGS: ***Swift runtime: entrypoint +[a.MyClass bar] generated by implicit @objc inference is deprecated and will be removed in Swift 4
|
|
type(of: x).perform(Selector(barSel))
|
|
|
|
// CHECK_NOTHING-NEXT: ---End
|
|
// CHECK_WARNINGS: ---End
|
|
// CHECK_CRASH-NOT: ---End
|
|
fputs("---End\n", stderr)
|