import SceneKit
let action = SCNAction.run { _ in
print("foo")
}
< /code>
Вот мой прогресс: < /p>
protocol RLAction {}
struct RLCallbackAction: RLAction {}
extension RLAction where Self == RLCallbackAction {
static func run() -> RLCallbackAction {
return RLCallbackAction()
}
}
< /code>
Тогда это работает < /p>
let action: RLAction = .run()
< /code>
Но это не удается: < /p>
let action = RLAction.run()
< /code>
С сообщением об ошибке: < /p>
Referencing static method 'run()' on 'RLAction' requires the types 'Self' and 'RLCallbackAction' be equivalent
< /code>
Я полностью понимаю, что могу просто сделать: < /p>
let action = RLCallbackAction.run()
Но это не так эргономично, как rlaction.run () (аналогично scnaction.run ()
public protocol RLActionImplementation {
// ...
}
public struct RLAction {
var duration: TimeInterval
let implementation: Implementation
}
public struct RLAggregationActionImplementation: RLActionImplementation {
public enum Aggregation {
case sequence
case group
}
// ERROR here
public let actions: [RLAction]
public let aggregation: Aggregation
< /code>
Приведенная выше приводит к этой ошибке: < /p>
Property declares an opaque return type, but has no initializer expression from which to infer an underlying type
Я строю систему действий в реальности, похожая на Scenekit. В частности, я хочу сделать что -то вроде: < /p> [code]import SceneKit let action = SCNAction.run { _ in print("foo") } < /code> Вот мой прогресс: < /p>
< /code> Тогда это работает < /p> let action: RLAction = .run() < /code> Но это не удается: < /p> let action = RLAction.run() < /code> С сообщением об ошибке: < /p> Referencing static method 'run()' on 'RLAction' requires the types 'Self' and 'RLCallbackAction' be equivalent < /code> Я полностью понимаю, что могу просто сделать: < /p> let action = RLCallbackAction.run() [/code] Но это не так эргономично, как rlaction.run () (аналогично scnaction.run () [code]
public protocol RLActionImplementation { // ... }
public struct RLAction { var duration: TimeInterval let implementation: Implementation }
public struct RLAggregationActionImplementation: RLActionImplementation {
public enum Aggregation { case sequence case group }
// ERROR here public let actions: [RLAction] public let aggregation: Aggregation
< /code> Приведенная выше приводит к этой ошибке: < /p> Property declares an opaque return type, but has no initializer expression from which to infer an underlying type [/code] Теперь я застрял.