You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've run into an issue where one of my "view models" has an associated type that itself has an associated type.
It looks like it's crashing the Swift compiler and I'm not sure if there is something I can potentially do to work around or alter my modeling to get past this.
Inside the ContentView.swift I have 3 approaches for different approaches for how the view model is defined in the view/how it's used.
This approach fails to compile -- triggers the crash
structContentView:View{@StorevarviewModel:anyMainViewModelProtocolvarbody:someView{VStack{Image(systemName:"globe").imageScale(.large).foregroundColor(.accentColor)Text("Hello, world!")}.padding().sheet(item: $viewModel.otherViewModel){ viewModel in // this is triggering the issue when the view model defined this way
Text(viewModel.otherText)}}}
This approach compiles, but isn't a valid solution
This approach also compiles, but is also not a valid solution for me.
structContentView:View{@StorevarviewModel=MainViewModel()varbody:someView{VStack{Image(systemName:"globe").imageScale(.large).foregroundColor(.accentColor)Text("Hello, world!")}.padding().sheet(item: $viewModel.otherViewModel){ viewModel in // doesn't seem to be an issue here when not using `any Protocol`
Text(viewModel.otherText)}}}
I've run into an issue where one of my "view models" has an associated type that itself has an associated type.
It looks like it's crashing the Swift compiler and I'm not sure if there is something I can potentially do to work around or alter my modeling to get past this.
Here is my project.
https://github.com/eito/xui-bug
Xcode 14.2
Inside the
ContentView.swift
I have 3 approaches for different approaches for how the view model is defined in the view/how it's used.This approach fails to compile -- triggers the crash
This approach compiles, but isn't a valid solution
This approach also compiles, but is also not a valid solution for me.
Any ideas? I'll also submit a Swift bug
The text was updated successfully, but these errors were encountered: