mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
preserve the original method name. This heuristic is based on the Objective-C selector and therefore doesn't really handle factory methods that would conflict with initializers, but we can hope that those simply don't come up in the wild. It's not clear that this is the best thing to do --- it tends to promote the non-throwing API over what's probably a newer, throwing API --- but it's significantly easier, and it unblocks code without creating deployment problems. Swift SVN r28066
54 lines
1.6 KiB
Swift
54 lines
1.6 KiB
Swift
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-silgen -parse-as-library -verify %s
|
|
|
|
// REQUIRES: objc_interop
|
|
|
|
import Foundation
|
|
import errors
|
|
|
|
func test0() {
|
|
try ErrorProne.fail() // expected-error {{errors thrown from here are not handled}}
|
|
}
|
|
|
|
// Test "AndReturnError" stripping.
|
|
// rdar://20722195
|
|
func testAndReturnError() throws {
|
|
try ErrorProne.fail()
|
|
try ErrorProne.go()
|
|
try ErrorProne.tryAndReturnError() // collides with 'try' keyword
|
|
}
|
|
|
|
func testInheritedInit() throws {
|
|
try ReallyErrorProne(one: nil)
|
|
}
|
|
|
|
func testInheritedFactory() throws {
|
|
try ReallyErrorProne(two: nil)
|
|
}
|
|
|
|
// Resolve a conflict between -foo and -foo: by just not
|
|
// importing the latter as throwing.
|
|
func testConflict1(obj: ErrorProne) throws {
|
|
try obj.conflict1() // expected-warning {{no calls to throwing functions occur within 'try'}}
|
|
}
|
|
func testConflict1_error(obj: ErrorProne) throws {
|
|
var error: NSError?
|
|
obj.conflict1(&error)
|
|
}
|
|
|
|
// Resolve a conflict between -foo and -fooAndReturnError:
|
|
// by not changing the name of the latter.
|
|
func testConflict2(obj: ErrorProne) throws {
|
|
try obj.conflict2() // expected-warning {{no calls to throwing functions occur within 'try'}}
|
|
}
|
|
func testConflict2_error(obj: ErrorProne) throws {
|
|
try obj.conflict2AndReturnError()
|
|
}
|
|
|
|
// Resolve a conflict between -foo: and -foo:error: by not
|
|
// changing the name of the latter.
|
|
func testConflict3(obj: ErrorProne) throws {
|
|
try obj.conflict3(nil) // expected-warning {{no calls to throwing functions occur within 'try'}}
|
|
}
|
|
func testConflict3_error(obj: ErrorProne) throws {
|
|
try obj.conflict3(nil, error: ())
|
|
} |