I think that's exactly correct. My goal is to be able to define the type for a dynamic property and disallow anything else at compile time.
The example you give fails to compile:
class Token: ManagedObject {
var expiresAfter: Double? {
get { return self[dynamicMember: #function] }
set { self[dynamicMember: #function] = newValue }
}
var issuer: String? {
get { return self[dynamicMember: #function] } // š Cannot subscript a value of type 'Token'
set { self[dynamicMember: #function] = newValue } // š Cannot assign value of type 'String?' to type 'Double?'
}
}
I think this is correct, although with a different error as it's generated code. Something like this maybe?
'dynamic' var 'issuer' requires 'Token' to have method 'subscript(dynamicMember:) -> String?'