diff --git a/src/Compilers/VisualBasic/Portable/BoundTree/BoundLValuePlaceholderBase.vb b/src/Compilers/VisualBasic/Portable/BoundTree/BoundLValuePlaceholderBase.vb index 902356c8a8ea909156f8e96dd02b09de9895ddc5..c0f2957b6d7dce44605778cc33d299c203be92e1 100644 --- a/src/Compilers/VisualBasic/Portable/BoundTree/BoundLValuePlaceholderBase.vb +++ b/src/Compilers/VisualBasic/Portable/BoundTree/BoundLValuePlaceholderBase.vb @@ -16,7 +16,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic End Property Protected NotOverridable Overrides Function MakeRValueImpl() As BoundExpression - Return New BoundLValueToRValueWrapper(Me.Syntax, Me, Me.Type) + Return New BoundLValueToRValueWrapper(Me.Syntax, Me, Me.Type).MakeCompilerGenerated() ' This is a compiler generated node End Function End Class diff --git a/src/Compilers/VisualBasic/Test/Semantic/Semantics/WithBlockSemanticModelTests.vb b/src/Compilers/VisualBasic/Test/Semantic/Semantics/WithBlockSemanticModelTests.vb index 4f1dde3ff818f2a62231209bacec2808bd478258..cd97b766fcaefa4d539f5e759a39deb9fc15cce8 100644 --- a/src/Compilers/VisualBasic/Test/Semantic/Semantics/WithBlockSemanticModelTests.vb +++ b/src/Compilers/VisualBasic/Test/Semantic/Semantics/WithBlockSemanticModelTests.vb @@ -217,6 +217,65 @@ End Module #End Region + + Public Sub Issue2662() + Dim compilation = CompilationUtils.CreateCompilationWithMscorlibAndVBRuntimeAndReferences( + + + Public Sub Print(ByVal cust As Customer, str As String) + Console.WriteLine(str) + End Sub + + Public Class Customer + Public Property Name As String + Public Property City As String + Public Property URL As String + + Public Property Comments As New List(Of String) + End Class +End Module + ]]> +, {SystemCoreRef}) + + compilation.AssertNoDiagnostics() + + Dim tree = compilation.SyntaxTrees.Single() + Dim model = compilation.GetSemanticModel(tree) + Dim withBlock = tree.GetCompilationUnitRoot().DescendantNodes().OfType(Of WithBlockSyntax)().Single() + + Dim name = withBlock.Statements(3).DescendantNodes().OfType(Of IdentifierNameSyntax).Where(Function(i) i.Identifier.ValueText = "Name").Single() + model.GetAliasInfo(name) + + Dim result2 = model.AnalyzeDataFlow(withBlock, withBlock) + Assert.True(result2.Succeeded) + + model = compilation.GetSemanticModel(tree) + model.GetAliasInfo(name) + + Assert.Equal("theCustomer As Program.Customer", model.GetSymbolInfo(withBlock.WithStatement.Expression).Symbol.ToTestDisplayString()) + End Sub + End Class End Namespace