我试图实现两次通用接口,一次使用基本类型,一次使用更多派生类型 . 如果实现类B本身不是通用的,那么这种方法很有效,但是对于具有类型约束的通用类C来说它是失败的 .

给出的错误是:“无法实现接口'iB(Of TInterface)',因为它的实现可能与某些类型参数的另一个实现接口'iB(Of iA)'的实现相冲突 . ”

我认为C类应该像B类一样编译,因为TInterface来自iAA,我无法理解为什么编译器会抛出错误 . 编译器有缺陷吗?有人可以请教吗?

代码如下:

Interface iA
End Interface

Interface iAA
    Inherits iA
End Interface

Interface iB(Of T)
    ReadOnly Property GetValue As T 
End Interface


Class B
    Implements iB(Of iA)
    Implements iB(Of iAA)

    ReadOnly Public Property GetAA As iAA  Implements iB(Of iAA).GetValue
        Get
            Return Nothing
        End Get
    End Property

    ReadOnly Public Property GetA As iA Implements iB(Of iA).GetValue
        Get
            Return GetAA
        End Get
    End Property
End Class


Class C(Of TInterface As iAA)
    Implements iB(Of iA)
    Implements iB(Of TInterface) ' This gives a compilation error

    Public ReadOnly Property GetAA As TInterface Implements iB(Of TInterface).GetValue
        Get
            Return Nothing
        End Get
    End Property

    Public ReadOnly Property GetA As iA Implements iB(Of iA).GetValue
        Get
            Return GetAA
        End Get
    End Property
End Class