Files
swift-mirror/test/ClangImporter/MixedSource/mixed-target-using-module.swift
Brent Royal-Gordon bf074b093e Run some implicit imports through import resolution
Unloaded implicit imports (e.g. the `-import-module` flag) will now be processed by import resolution, and will be fully validated and cross-imported. Preloaded imports, like the standard library import, are still not run through full import resolution, but this is a definite improvement over the status quo.

This also folds `-import-underlying-module` and `@_exported import <ParentModule>` into a single code path, slightly changing the diagnostic for a failed overlay-style underlying module import.
2020-10-09 18:59:19 -07:00

88 lines
3.4 KiB
Swift

// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -F %S/Inputs/mixed-target/ -module-name Mixed -import-underlying-module -typecheck %s -verify -enable-objc-interop -disable-objc-attr-requires-foundation-module
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -F %S/Inputs/mixed-target/ -module-name Mixed -import-underlying-module -enable-objc-interop -emit-ir %S/../../Inputs/empty.swift | %FileCheck -check-prefix=CHECK-AUTOLINK %s
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -F %S/Inputs/mixed-target/ -module-name Mixed -DOVERLAY_STYLE_RIGHT -enable-objc-interop -emit-ir %S/../../Inputs/empty.swift | %FileCheck -check-prefix=CHECK-AUTOLINK %s
// RUN: not %target-swift-frontend(mock-sdk: %clang-importer-sdk) -F %S/Inputs/mixed-target/ -module-name WrongName -import-underlying-module -typecheck %s -enable-objc-interop -disable-objc-attr-requires-foundation-module 2>&1 | %FileCheck -check-prefix=CHECK-WRONG-NAME %s
// RUN: not %target-swift-frontend(mock-sdk: %clang-importer-sdk) -F %S/Inputs/mixed-target/ -module-name WrongName -DOVERLAY_STYLE_WRONG -typecheck %s -enable-objc-interop -disable-objc-attr-requires-foundation-module 2>&1 | %FileCheck -check-prefix=CHECK-WRONG-NAME %s
#if OVERLAY_STYLE_RIGHT
@_exported import Mixed
#elseif OVERLAY_STYLE_WRONG
@_exported import WrongName
#endif
// CHECK-AUTOLINK: !llvm.linker.options = !{
// CHECK-AUTOLINK-NOT: !"-framework"
// CHECK-WRONG-NAME: underlying Objective-C module 'WrongName' not found
@objc class ForwardClass : NSObject {
}
@objc protocol ForwardProto : NSObjectProtocol {
}
@objc class ForwardProtoAdopter : NSObject, ForwardProto {
}
@objc class PartialBaseClass {
}
@objc class PartialSubClass : NSObject {
}
func testCFunction() {
doSomething(ForwardClass())
doSomethingProto(ForwardProtoAdopter())
doSomethingPartialBase(PartialBaseClass())
doSomethingPartialSub(PartialSubClass())
}
class Derived : Base {
override func safeOverride(_ arg: NSObject) -> ForwardClass { // no-warning
return ForwardClass()
}
override func unsafeOverrideParam(_ arg: ForwardClass) -> NSObject { // expected-error{{does not override}}
return arg
}
override func unsafeOverrideReturn(_ arg: ForwardClass) -> NSObject { // expected-error{{does not override}}
return arg
}
override func safeOverridePartialSub(_ arg: NSObject?) -> PartialSubClass { // no-warning
return PartialSubClass()
}
override func unsafeOverridePartialSubParam(_ arg: PartialSubClass) -> NSObject { // expected-error{{does not override}}
return arg
}
override func unsafeOverridePartialSubReturn(_ arg: PartialSubClass) -> NSObject { // expected-error{{does not override}}
return arg
}
}
func testMethod(_ container: Base, input: ForwardClass, inputProto: ForwardProto, inputPartial: PartialSubClass) {
_ = container.unsafeOverrideReturn(input) as ForwardClass// no-warning
_ = container.unsafeOverrideProtoReturn(inputProto) as ForwardProto // no-warning
_ = container.unsafeOverridePartialSubReturn(inputPartial) as PartialSubClass// no-warning
}
class ProtoConformer : ForwardClassUser {
@objc func consumeForwardClass(_ arg: ForwardClass) {}
@objc var forward = ForwardClass()
}
func testProtocolWrapper(_ conformer: ForwardClassUser) {
conformer.consumeForwardClass(conformer.forward)
}
testProtocolWrapper(ProtoConformer())
func testDeclsNestedInObjCContainers() {
let _: NameInInterface = 0
let _: NameInProtocol = 0
let _: NameInCategory = 0
}