Skip to content

nonisolated(nonsending)@isolated(any) conversion uses nil actor #83760

@AnthonyLatsis

Description

@AnthonyLatsis

Description

We should be partially applying a nonisolated(nonsending) function to the actor it should run on, if any, before converting to @isolated(any). Instead, we are unconditionally applying it a nil actor.

Reproduction

func test(_ fn: @isolated(any) () async -> Void) {
  print(fn.isolation) // nil
}

nonisolated(nonsending) func foo() async {
  test {}
}

@main struct Foo {
  @MainActor
  static func main() async throws {
    await foo()
  }
}

Expected behavior

MainActor in this case.

Environment

a868d92.

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    @isolated(any)Feature → attributes: The @isolated(any) attributeSILGenArea → compiler: The SIL generation stageactor isolationFeature → concurrency: Actor isolationbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfconcurrencyFeature: umbrella label for concurrency language featuresswift 6.2unexpected behaviorBug: Unexpected behavior or incorrect output

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions