Skip to content

jextract: isolated actor property setters generate Swift thunks that cannot compile #977

Backlog

Description

@ktoso

#973 added JNIActorPropertyIsolationTests locking in the Java surface for actor properties, including:

public java.util.concurrent.CompletableFuture<java.lang.Void> setIsolatedValue(long newValue)

for an isolated actor property (public var isolatedValue: Int64 on public actor Record).

The generated Swift thunk for that setter cannot compile. The setter body is emitted as a plain cross-isolation assignment in JNISwift2JavaGenerator+SwiftThunkPrinting.swift (.setter case, ~line 741):

result = "\(callee).\(decl.name) = \(newValueArgument)"
// i.e. selfPointer$.pointee.isolatedValue = newValue

This is illegal, and async setters are also not supported.

Suggested fix

Don't emit setters for isolated actor properties at all (skip with a diagnostic).

Reproducer

Any public isolated property like e.g.:

public actor Record {
  public var isolatedValue: Int64
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions