提交 fede994d 编写于 作者: A acasey

DevDiv #909487: Implement SubstitutedFieldSymbol.AssociatedSymbol

Copied the C# implementation.

CR: AlekseyT (changeset 1214957)
上级 8f42d080
......@@ -111,7 +111,8 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
Public Overrides ReadOnly Property AssociatedSymbol As Symbol
Get
Return Nothing
Dim underlying = OriginalDefinition.AssociatedSymbol
Return If(underlying Is Nothing, Nothing, underlying.AsMember(ContainingType))
End Get
End Property
......
......@@ -495,6 +495,29 @@ BC30002: Type 'abcDef' is not defined.
</expected>)
End Sub
<Fact>
Public Sub AssociatedSymbolOfSubstitutedField()
Dim compilation = CompilationUtils.CreateCompilationWithMscorlib(
<compilation name="AAA">
<file name="a.vb">
Public Class C(Of T)
Public Property P As Integer
End Class
</file>
</compilation>)
Dim type = compilation.GlobalNamespace.GetMember(Of NamedTypeSymbol)("C")
Dim [property] = type.GetMember(Of PropertySymbol)("P")
Dim field = [property].AssociatedField
Assert.Equal([property], field.AssociatedSymbol)
Dim substitutedType = type.Construct(compilation.GetSpecialType(SpecialType.System_Int32))
Dim substitutedProperty = substitutedType.GetMember(Of PropertySymbol)("P")
Dim substitutedField = substitutedProperty.AssociatedField
Assert.IsType(Of SubstitutedFieldSymbol)(substitutedField)
Assert.Equal(substitutedProperty, substitutedField.AssociatedSymbol)
End Sub
End Class
End Namespace
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册