# Actor Inferencing?

**URL:** <https://forums.swift.org/t/actor-inferencing/54590>\
**Category:** Using Swift\
**Tags:** concurrency\
**Created:** [January 13, 2022, 4:32am UTC](https://forums.swift.org/t/actor-inferencing/54590 "2022-01-13T04:32:27Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Alejandro\_Martinez](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/alejandro_martinez/32/821_2.png) [@Alejandro\_Martinez](https://forums.swift.org/u/Alejandro_Martinez)\
**Post date:** [January 13, 2022, 10:05am UTC](https://forums.swift.org/t/actor-inferencing/54590/2 "2022-01-13T10:05:15Z")

</div>

I don't have an answer but...

> [@Chris\_Eidhof](#):
>
> I've looked at the involved protocols and types ( `View` , `@StateObject` , etc.) but can't figure it out. Is this compiler magic?

My guess is that those types have @MainActor somewhere we can't see. Xcode interfaces don't show the entire truth. Like when you look at `Task.init` there is no way to know why it inherits the actor and your own closures don't! You need to look at the stdlib source code for that. So maybe the same is happening here. Maybe is not even annotated at the Swift level but somehow on the internals of SwiftUI.

Hopefully somebody can bring more light into this!

> [@Chris\_Eidhof](#):
>
> I think it could be useful to have better ways to figure out on which execution context asynchronous code will run.

This recent pitch helps in some scenarios ([[Pitch] Clarify the execution of non-actor-isolated `async` functions](https://forums.swift.org/t/pitch-clarify-the-execution-of-non-actor-isolated-async-functions/54435/)) but not in this one. But codifying more rules around this is good fur understanding. Worth looking into it ;)

> [@Chris\_Eidhof](#):
>
> I guess it could/should be something that you can see in the editor.

I wish Xcode showed more things inline. Android Studio does this for variables and is very handy, specially since what we call "context" is actually an object in Kotlin, a coroutine scope, which lets the IDE show it like any other variable overlayed in source. Very handy.

---

_[View the full topic](https://forums.swift.org/t/actor-inferencing/54590)._
