In the code below, when I try to access genericVar.someFunc() I get the error
"Value of type 'MyProtocol?' has no member 'someFunc'".
Being a generic variable, when I initialize the MyOtherStruct object, I will have to pass a concrete implementation of a MyProtocol conforming object, so why would I be getting this error?
public protocol MyProtocol { associatedtype T func someFunc() -> T } public struct myStruct: MyProtocol { public typealias T = Int16 public func someFunc() -> Int16 { let myVar: Int16 = 7 return myVar } } public struct myOtherStruct<MyProtocol> { var genericVar: MyProtocol? public init(localVal: MyProtocol?) { self.genericVar = localVal if genericVar != nil { var my = genericVar.someFunc() } } }