Files
swift-mirror/test/IDE/print_clang_swift_name.swift
Michael Ilseman d1efc80b1f [Import Decl] Don’t import as init using omit needless words
Previously, for an Objective-C class method declaration that could be
imported as init, we were making 4 decls:

1) The Swift 2 init
2) The Swift 2 class method decl (suppressing init formation)
3) The Swift 3 init (omitting needless words)
4) The Swift 3 class method decl (suppressing init formation and
   omitting needless words)

Decls 1), 2), and 4) exist for diagnostics and redirect the user at
3). But, 4) does not correspond to any actual Swift version name and
producing it correctly would require the user to understand how
omit-needless-words and other importer magic operates. It provides
very limited value and more importantly gets in the way of future
Clang importer refactoring. We’d like to turn Decl importing into
something that is simpler and language-version parameterized, but
there is no real Swift version to correspond to decl 4).

Therefore we will be making the following decls:

1) The "raw" decl, the name as it would appear to the user if they
   copy-pasted Objective-C code
2) The name as it appeared in Swift 2 (which could be an init)
3) The name as it appeared in Swift 3 (which could be an init and omit
   needless words)

This aligns with the language versions we want to import as in the
future: raw, swift2, swift3, …, and current.

Note that swift-ide-test prunes decls that are unavailable in the
current Swift version, so the Swift 2 non-init decls are not printed
out, though they are still present. Tests were updated and expanded to
ensure this was still the case.
2016-12-01 18:50:40 -08:00

72 lines
2.2 KiB
Swift

// RUN: rm -rf %t && mkdir -p %t
// RUN: %target-swift-ide-test(mock-sdk: %clang-importer-sdk) -print-module -source-filename %s -module-to-print=SwiftNameTests -function-definitions=false -print-regular-comments -F %S/Inputs/mock-sdk > %t.txt
// RUN: diff -u <(tail +9 %s) %t.txt
// REQUIRES: objc_interop
// EXPECTED OUTPUT STARTS BELOW THIS LINE.
@_exported import Foundation
class Test : NSObject {
@available(*, unavailable, message: "superseded by import of -[NSObject init]")
convenience init()
convenience init(dummyParam: ())
convenience init(cc x: Any)
convenience init(_ x: Any)
convenience init(aa a: Any, _ b: Any, cc c: Any)
/*not inherited*/ init(fixedType: ())
// Would-be initializers.
class func zz() -> Self
class func yy(aa x: Any) -> Self
class func xx(_ x: Any, bb xx: Any) -> Self
init()
}
class TestError : NSObject {
convenience init(error: ()) throws
convenience init(aa x: Any?, error: ()) throws
convenience init(aa x: Any?, error: (), block: @escaping () -> Void) throws
convenience init(error: (), block: @escaping () -> Void) throws
convenience init(aa x: Any?) throws
convenience init(aa x: Any?, block: @escaping () -> Void) throws
convenience init(block: @escaping () -> Void) throws
// Would-be initializers.
class func ww(_ x: Any?) throws -> Self
class func w2(_ x: Any?, error: ()) throws -> Self
class func vv() throws -> Self
class func v2(error: ()) throws -> Self
init()
}
class TestSub : Test {
@available(*, unavailable, message: "superseded by import of -[NSObject init]")
convenience init()
convenience init(dummyParam: ())
convenience init(cc x: Any)
convenience init(_ x: Any)
convenience init(aa a: Any, _ b: Any, cc c: Any)
init()
}
class TestErrorSub : TestError {
convenience init(error: ()) throws
convenience init(aa x: Any?, error: ()) throws
convenience init(aa x: Any?, error: (), block: @escaping () -> Void) throws
convenience init(error: (), block: @escaping () -> Void) throws
convenience init(aa x: Any?) throws
convenience init(aa x: Any?, block: @escaping () -> Void) throws
convenience init(block: @escaping () -> Void) throws
init()
}