Cryptic F#error - 签名和实现不兼容,因为type参数的声明需要约束为“T = null”

时间:2016-07-07 04:10:02

标签: wpf f#

我有一小段F#代码产生了一个我无法弄清楚的神秘错误......

namespace epic.View

open System
open FSharp.Desktop.UI

[<AbstractClass>]
type public FieldModelBase<'ValueType>() = 
    inherit Model() 
    let mutable fieldCaption: string = null
    let mutable fieldValue: 'ValueType = null
    [<DerivedProperty>]
    member this.Caption with public get() = sprintf "%s" fieldCaption and set value = fieldCaption <- sprintf "%s" value; this.NotifyPropertyChanged "Caption"
    [<DerivedProperty>]
    member inline this.Value with public get() = fieldValue and set value = fieldValue <- value; this.NotifyPropertyChanged "Value"

会产生以下错误:

  

签名和实现不兼容,因为   声明类型参数&#39; ValueType&#39;需要约束   表单&#39; ValueType:null

这是什么意思,我该如何解决?看起来我应该在&#39; ValueType类型参数上添加一个类型约束,要求它是......可变的?是吗?

0 个答案:

没有答案