swiftlang / swiftlang/swift-java

Conforming to Equatable generates uncompilable Swift code

Open
#531 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature:jextract mode:ffm mode:jni
Dominant language
Swift
Stars
1.2k
Forks
123
Avg merge
1d 7h
Merged PRs (30d)
16

Description

Reproduction

Conform to Equatable using:

extension MySwiftClass: Equatable {
    public static func ==(lhs: MySwiftClass, rhs: MySwiftClass) -> Bool {
        return false
    }
}

in Samples/SwiftJavaExtractFFMSampleApp/Sources/MySwiftLibrary/MySwiftClass.swift and run ./gradlew :Samples:SwiftJavaExtractFFMSampleApp:jextract -i.

The Swift compilation currently fails with:

102 | public func swiftjava_MySwiftLibrary_MySwiftClass_==_lhs_rhs(_ lhs: UnsafeRawPointer, _ rhs: UnsafeRawPointer) -> Bool {
    |                                                   `- error: expressions are not allowed at the top level

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with Samples/SwiftJavaExtractFFMSampleApp/Sources/MySwiftLibrary/MySwiftClass.swift and run ./gradlew :Samples:SwiftJavaExtractFFMSampleApp:jextract -i. Inspect the generated Swift around swiftjava_MySwiftLibrary_MySwiftClass_==_lhs_rhs and determine why the Equatable operator produces invalid syntax. Done means the reproduction generates Swift that compiles successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.