Skip to content

[SR-15916] @MainActor-isolated default arguments for @MainActor-isolated functions #58177

@groue

Description

@groue
Previous ID SR-15916
Radar None
Original Reporter @groue
Type Bug
Environment

Xcode 13.3 beta 3 (13E5104i)

Additional Detail from JIRA
Votes 2
Component/s Compiler
Labels Bug
Assignee None
Priority Medium

md5: 618b69843e92ff0edf9587c87894767b

Issue Description:

Hello,

The following snippet does not compile:

@MainActor class Foo { }

// error: call to main actor-isolated initializer 'init()' in a synchronous nonisolated context
// @MainActor func f(foo: Foo = Foo()) { }
//                               ^
// note: calls to initializer 'init()' from outside of its actor context are implicitly asynchronous
// @MainActor class Foo {
//                  ^
@MainActor func f(foo: Foo = Foo()) { }

It should compile, since everything in the declaration of the f function is MainActor-isolated.

Metadata

Metadata

Assignees

Labels

actorFeature → concurrency: `actor` declarationsactor isolationFeature → concurrency: Actor isolationbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfconcurrencyFeature: umbrella label for concurrency language featuresdefault argumentsFeature: default arguments for value parameterstype checkerArea → compiler: Semantic analysisunexpected errorBug: Unexpected error

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions