Following results
This construction makes the code less general than indicated by type annotations. The type of the variable "P" was limited to the type of "bool".
for the right side of let myValue = and
This code is less general than required by its annotations because an explicit variable of type 'P' cannot be generalized. He was limited to be a "bool".
for the general <'P> in the Value method:
type MyTypeA<'T> (myObject : 'T) as this = let myValue = this.Value<bool> "SomeBooleanProperty" member this.Value<'P> name = typeof<'T>.GetProperty(name, typeof<'P>).GetValue(myObject, null) :?> 'P`
However, this compiles just fine and does not give any warnings or errors:
type MyTypeB<'T> (myObject : 'T) as this = member this.Value<'P> name = typeof<'T>.GetProperty(name, typeof<'P>).GetValue(myObject, null) :?> 'P member this.Method<'P> name = this.Value<'P> name
What is going on here? Why is the first example a method recognized when assigning a private value, but not as a legally general method?
source share