@@ -121,9 +121,22 @@ public struct PublishedObject<Value> {
121121#if FORCE_PUBLISHED_OBJECT_WRAPPER
122122/// Force PublishedObject when using ObservableObjects
123123@available ( iOS 13 . 0 , OSX 10 . 15 , tvOS 13 . 0 , watchOS 6 . 0 , * )
124- extension Published where Value: ObservableObject {
125- public init ( wrappedValue: Value ) {
126- fatalError ( " Use PublishedObject with ObservableObjects " )
124+ extension Published {
125+ public init ( wrappedValue: Value ) where Value: ObservableObject {
126+ fatalError ( " Use @PublishedObject with ObservableObjects " )
127+ }
128+ public init ( wrappedValue: Value ) where Value: _PublishedObjectInternalObservableObjectOptional {
129+ fatalError ( " Use @PublishedObject with optional ObservableObjects " )
130+ }
131+ public init ( wrappedValue: Value ) where Value: _PublishedObjectInternalObservableObjectArray {
132+ fatalError ( " Use @PublishedObject with arrays of ObservableObjects " )
127133 }
128134}
135+
136+ public protocol _PublishedObjectInternalObservableObjectOptional { }
137+ @available ( iOS 13 . 0 , OSX 10 . 15 , tvOS 13 . 0 , watchOS 6 . 0 , * )
138+ extension Optional : _PublishedObjectInternalObservableObjectOptional where Wrapped: ObservableObject { }
139+ public protocol _PublishedObjectInternalObservableObjectArray { }
140+ @available ( iOS 13 . 0 , OSX 10 . 15 , tvOS 13 . 0 , watchOS 6 . 0 , * )
141+ extension Array : _PublishedObjectInternalObservableObjectArray where Element: ObservableObject { }
129142#endif
0 commit comments