Skip to content

Commit c2df13e

Browse files
committed
[repro] module maps created for or on objc_library do not propagate to transitive objc_library
this is a repro of an issue i've identified while trying to move to `mixed_language_library` from our custom macro. Regardless of how `module_map` is hinted in `swift_interop_info`, generated, or otherwise attached to an `objc_library`, out-of-the-box these module maps are not propagated to downstream `objc_library` in a `objc -> swift -> objc` arrangement. this is especially problematic in scenarios where PrintAsClang, going by its own uncontrollable heuristics, inserts an `@import` line for the upstream objc library in a generated header. this is something that needs to change in either `swift_clang_module_aspect` or `objc_library` to discover or otherwise propagate the upstream module maps, as this simple example does not work without customization of the rules or introducing manual dependencies on modulemaps (which isn't possible if relying on the generated modulemaps from the aspect).
1 parent ed87447 commit c2df13e

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

examples/apple/objc_interop_modulemap/OIPrintStream.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,16 @@
1414

1515
#import <Foundation/Foundation.h>
1616

17+
@protocol Stupid
18+
@end
19+
1720
/** A very contrived interface for writing strings to a file handle. */
18-
@interface OIPrintStream : NSObject
21+
@interface OIPrintStream<PrintType> : NSObject
1922

2023
- (nonnull instancetype)initWithFileHandle:(nonnull NSFileHandle *)fileHandle;
2124

25+
- (void)print:(nonnull PrintType)message;
26+
2227
- (void)printString:(nonnull NSString *)message;
2328

2429
@end

examples/apple/objc_interop_modulemap/OIPrintStream.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ - (instancetype)initWithFileHandle:(nonnull NSFileHandle *)fileHandle {
2525
return self;
2626
}
2727

28+
- (void)print:(nonnull id)message {
29+
}
30+
2831
- (void)printString:(nonnull NSString *)message {
2932
NSData *data = [message dataUsingEncoding:NSUTF8StringEncoding];
3033
[_fileHandle writeData:data];

examples/apple/objc_interop_modulemap/Printer.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,24 @@
1515
import Foundation
1616
import examples_apple_objc_interop_modulemap_PrintStream
1717

18+
@objc public protocol MyStupid {
19+
}
20+
1821
@objc(OIPrinter)
1922
public class Printer: NSObject {
2023

21-
private let stream: OIPrintStream
24+
private let stream: OIPrintStream<MyStupid>
2225
private let prefix: String
2326

2427
@objc public init(prefix: NSString) {
2528
self.stream = OIPrintStream(fileHandle: .standardOutput)
2629
self.prefix = prefix as String
2730
}
2831

32+
@objc public func stream(_ thing: MyStupid) -> OIPrintStream<MyStupid> {
33+
return stream
34+
}
35+
2936
@objc public func print(_ message: NSString) {
3037
stream.print("\(prefix)\(message)")
3138
}

0 commit comments

Comments
 (0)