Skip to content

Can't use existential 'any' with InjectedObject property wrapper #170

@mobileuidev

Description

@mobileuidev

I can't use the existential 'any' keyword with @InjectedObject property wrapper, the fired error is:
Type 'any Test' cannot conform to 'ObservableObject'

the example is as follows:

protocol Test: ObservableObject {
    
}

class MyViewModel: Test {
    
}

struct MyView: View {
    @InjectedObject var viewModel: any Test //<---- the error fires here
    
    var body: some View {
        Text("Hello")
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions