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
Copy file name to clipboardExpand all lines: Sources/SafeDI/Decorators/Instantiated.swift
+1-2Lines changed: 1 addition & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -22,8 +22,7 @@
22
22
///
23
23
/// An example of the macro in use:
24
24
///
25
-
/// @Instantiated
26
-
/// private let dependency: DependencyType
25
+
/// @Instantiated private let dependency: DependencyType
27
26
///
28
27
/// Note that the access level of the dependency in the above example does not affect the dependency tree – a `private` dependency can still be `@Received` by `@Instantiable`-decorated types further down the dependency tree.
@Instantiated(fulfilledByType: "Module.ConcreteType") let instantiatedA: InstantiatedA
79
77
}
80
78
"""
81
79
} expansion:{
@@ -84,6 +82,7 @@ import SafeDICore
84
82
init(instantiatedA: InstantiatedA) {
85
83
self.instantiatedA = instantiatedA
86
84
}
85
+
87
86
let instantiatedA: InstantiatedA
88
87
}
89
88
"""
@@ -100,8 +99,7 @@ import SafeDICore
100
99
self.instantiatedA = instantiatedA
101
100
}
102
101
103
-
@Instantiated
104
-
var instantiatedA: InstantiatedA
102
+
@Instantiated var instantiatedA: InstantiatedA
105
103
}
106
104
"""
107
105
} diagnostics:{
@@ -111,11 +109,10 @@ import SafeDICore
111
109
self.instantiatedA = instantiatedA
112
110
}
113
111
114
-
@Instantiated
115
-
var instantiatedA: InstantiatedA
116
-
┬──
117
-
╰─ 🛑 Dependency can not be mutable unless it is decorated with a property wrapper. Mutations to a dependency are not propagated through the dependency tree.
118
-
✏️ Replace `var` with `let`
112
+
@Instantiated var instantiatedA: InstantiatedA
113
+
┬──
114
+
╰─ 🛑 Dependency can not be mutable unless it is decorated with a property wrapper. Mutations to a dependency are not propagated through the dependency tree.
╰─ 🛑 The argument `fulfilledByType` can not be used on an `Instantiator` or `SendableInstantiator`. Use an `ErasedInstantiator` or `SendableErasedInstantiator` instead
199
-
let loginViewControllerBuilder: Instantiator<UIViewController>
200
194
}
201
195
"""
202
196
}
@@ -206,17 +200,15 @@ import SafeDICore
206
200
assertMacro{
207
201
"""
208
202
public struct ExampleService {
209
-
@Instantiated
210
-
let loginViewControllerBuilder: ErasedInstantiator<UIViewController>
203
+
@Instantiated let loginViewControllerBuilder: ErasedInstantiator<UIViewController>
211
204
}
212
205
"""
213
206
} diagnostics:{
214
207
"""
215
208
public struct ExampleService {
216
-
@Instantiated
209
+
@Instantiated let loginViewControllerBuilder: ErasedInstantiator<UIViewController>
217
210
┬────────────
218
211
╰─ 🛑 `ErasedInstantiator` and `SendableErasedInstantiator` require use of the argument `fulfilledByType`
219
-
let loginViewControllerBuilder: ErasedInstantiator<UIViewController>
220
212
}
221
213
"""
222
214
}
@@ -230,8 +222,7 @@ import SafeDICore
230
222
self.instantiatedA = instantiatedA
231
223
}
232
224
233
-
@Received
234
-
static let instantiatedA: InstantiatedA
225
+
@Received static let instantiatedA: InstantiatedA
235
226
}
236
227
"""
237
228
} diagnostics:{
@@ -241,10 +232,9 @@ import SafeDICore
241
232
self.instantiatedA = instantiatedA
242
233
}
243
234
244
-
@Received
235
+
@Received static let instantiatedA: InstantiatedA
245
236
┬────────
246
237
╰─ 🛑 This macro can not decorate `static` variables
247
-
static let instantiatedA: InstantiatedA
248
238
}
249
239
"""
250
240
}
@@ -275,8 +265,7 @@ import SafeDICore
275
265
}
276
266
277
267
static let fulfilledByType = "ConcreteType"
278
-
@Instantiated(fulfilledByType: fulfilledByType)
279
-
let instantiatedA: InstantiatedA
268
+
@Instantiated(fulfilledByType: fulfilledByType) let instantiatedA: InstantiatedA
280
269
}
281
270
"""
282
271
} diagnostics:{
@@ -287,10 +276,9 @@ import SafeDICore
287
276
}
288
277
289
278
static let fulfilledByType = "ConcreteType"
290
-
@Instantiated(fulfilledByType: fulfilledByType)
279
+
@Instantiated(fulfilledByType: fulfilledByType) let instantiatedA: InstantiatedA
291
280
┬──────────────────────────────────────────────
292
281
╰─ 🛑 The argument `fulfilledByType` must be a string literal
0 commit comments