Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,18 @@ public func returnLargestUnsignedByte() -> UInt8 {
UInt8.max
}

public func globalOverloaded(a: Int) -> Int {
a + 1
}

public func globalOverloaded(b: Int) -> Int {
b + 2
}

public func globalOverloaded(_ c: Int) -> Int {
c + 3
}

// ==== Internal helpers

func p(_ msg: String, file: String = #fileID, line: UInt = #line, function: String = #function) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,11 @@ void returnUnsignedByte_negative() {
void returnLargestUnsignedByte() {
assertEquals(-1, MySwiftLibrary.returnLargestUnsignedByte());
}
}

@Test
void labeledOverloads() {
assertEquals(101, MySwiftLibrary.globalOverloadedA(100));
assertEquals(202, MySwiftLibrary.globalOverloadedB(200));
assertEquals(303, MySwiftLibrary.globalOverloaded(300));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,10 @@ extension JNISwift2JavaGenerator {
private func printGlobalSwiftThunkSources(_ printer: inout CodePrinter) throws {
printHeader(&printer)

self.currentJavaIdentifiers = JavaIdentifierFactory(
self.analysis.importedGlobalFuncs + self.analysis.importedGlobalVariables
)

for decl in analysis.importedGlobalFuncs {
printSwiftFunctionThunk(&printer, decl)
printer.println()
Expand All @@ -290,9 +294,12 @@ extension JNISwift2JavaGenerator {

private func printNominalTypeThunks(_ printer: inout CodePrinter, _ type: ImportedNominalType) throws {
printHeader(&printer)

printer.println()

self.currentJavaIdentifiers = JavaIdentifierFactory(
type.initializers + type.variables + type.methods
)

switch type.swiftNominal.kind {
case .actor, .class, .enum, .struct:
printConcreteTypeThunks(&printer, type)
Expand Down
Loading