mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Right now the ClangImporter relies on Sema to synthesize typealiases in some cases, which doesn't work if a Sema instance is not available, for example when the ClangImporter is asked to import a declaration while deserializing SIL during optimization. Begin addressing this by synthesizing typealiases for the following conformances: - ExpressibleByArrayLiteral.ArrayLiteralElement while importing OptionSets. - RawRepresentable.RawValue while importing raw-valued enums. - ObjectiveCBridgeable._ObjectiveCType while importing bridged newtypes. Until further changes land, this is mostly NFC, except for a change in generated interface printing where the new typealiases are now explicitly shown. Note that non-bridged newtypes whose raw type is ObjectiveCBridgeable still rely on associated type inference, because the ClangImporter cannot safely "copy" the _ObjectiveCType typealias from the raw type to the newtype, for various reasons mostly having to do with circularity. Subsequent patches will address this, in a rather novel fashion that will shock you.
42 lines
1.6 KiB
Swift
42 lines
1.6 KiB
Swift
// RUN: %target-swift-ide-test(mock-sdk: %clang-importer-sdk) -I %t -I %S/Inputs/custom-modules -print-module -source-filename %s -module-to-print=ImportAsMember.Class -always-argument-labels -skip-unavailable > %t.printed.Class.txt
|
|
|
|
// RUN: %FileCheck %s -check-prefix=PRINT-CLASS -strict-whitespace < %t.printed.Class.txt
|
|
|
|
// PRINT-CLASS-LABEL: class SomeClass : NSObject {
|
|
// PRINT-CLASS-NEXT: init()
|
|
// PRINT-CLASS-NEXT: }
|
|
// PRINT-CLASS-NEXT: extension SomeClass {
|
|
// PRINT-CLASS-NEXT: /*not inherited*/ init(value x: Double)
|
|
// PRINT-CLASS-NEXT: func applyOptions(_ options: SomeClass.Options)
|
|
// PRINT-CLASS-NEXT: struct Options : OptionSet {
|
|
// PRINT-CLASS-NEXT: init(rawValue rawValue: Int)
|
|
// PRINT-CLASS-NEXT: let rawValue: Int
|
|
// PRINT-CLASS-NEXT: typealias RawValue = Int
|
|
// PRINT-CLASS-NEXT: typealias Element = SomeClass
|
|
// PRINT-CLASS-NEXT: typealias ArrayLiteralElement = SomeClass
|
|
// PRINT-CLASS-NEXT: static var fuzzyDice: SomeClass.Options { get }
|
|
// PRINT-CLASS-NEXT: static var spoiler: SomeClass.Options { get }
|
|
// PRINT-CLASS-NEXT: }
|
|
// PRINT-CLASS-NEXT: }
|
|
|
|
// RUN: %target-typecheck-verify-swift -I %S/Inputs/custom-modules
|
|
// REQUIRES: objc_interop
|
|
|
|
import Foundation
|
|
import ImportAsMember.Class
|
|
import IAMError
|
|
|
|
// Errors
|
|
ErrorStruct.hasPrototype();
|
|
|
|
// Import into members of an imported, renamed class.
|
|
let someClassOpts: SomeClass.Options = .fuzzyDice
|
|
let someClass = SomeClass(value: 3.14159)
|
|
someClass.applyOptions(someClassOpts)
|
|
|
|
class SomeSub : UnavailableDefaultInitSub { }
|
|
|
|
// Handle default initializers.
|
|
let udi1 = UnavailableDefaultInit()
|
|
let udis1 = UnavailableDefaultInitSub()
|