diff --git a/src/Compilers/CSharp/Portable/BoundTree/Expression.cs b/src/Compilers/CSharp/Portable/BoundTree/Expression.cs index 0a2e53e1c85fa47c84affd48b62d1c2db45a6871..47f0d51a9218611026c7e21509e212e56df7bb33 100644 --- a/src/Compilers/CSharp/Portable/BoundTree/Expression.cs +++ b/src/Compilers/CSharp/Portable/BoundTree/Expression.cs @@ -1,14 +1,13 @@ // Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using System; +using System.Collections.Concurrent; using System.Collections.Immutable; using System.Diagnostics; using System.Runtime.CompilerServices; +using Microsoft.CodeAnalysis.Collections; +using Microsoft.CodeAnalysis.CSharp.Symbols; using Microsoft.CodeAnalysis.Semantics; using Roslyn.Utilities; -using Microsoft.CodeAnalysis.CSharp.Symbols; -using Microsoft.CodeAnalysis.Collections; -using System.Collections.Concurrent; namespace Microsoft.CodeAnalysis.CSharp { @@ -155,7 +154,7 @@ private static IArgument DeriveArgument(int parameterIndex, int argumentIndex, I if (refMode != RefKind.None) { - return new Argument(ArgumentKind.Positional, parameter, argument); + return new Argument(ArgumentKind.Explicit, parameter, argument); } if (argumentIndex >= parameters.Length - 1 && @@ -170,7 +169,7 @@ private static IArgument DeriveArgument(int parameterIndex, int argumentIndex, I } else { - return new Argument(ArgumentKind.Positional, parameter, argument); + return new Argument(ArgumentKind.Explicit, parameter, argument); } } @@ -192,7 +191,7 @@ private static IArgument DeriveArgument(int parameterIndex, int argumentIndex, I return new Argument(ArgumentKind.ParamArray, parameter, CreateParamArray(parameter, argument)); } - return new Argument(ArgumentKind.Named, parameter, argument); + return new Argument(ArgumentKind.Explicit, parameter, argument); }); } diff --git a/src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_IArgument.cs b/src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_IArgument.cs index 68524616415c92e8d77ea9bf8b6bee7181754319..47689408923338c15597eeaf7c9dc39b960484f6 100644 --- a/src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_IArgument.cs +++ b/src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_IArgument.cs @@ -26,9 +26,9 @@ static void M1() "; string expectedOperationTree = @" IInvocationExpression (static void P.M2(System.Int32 x, System.Double y)) (OperationKind.InvocationExpression, Type: System.Void) (Syntax: 'M2(1, 2.0)') - Arguments(2): IArgument (ArgumentKind.Positional Matching Parameter: x) (OperationKind.Argument) (Syntax: '1') + Arguments(2): IArgument (ArgumentKind.Explicit Matching Parameter: x) (OperationKind.Argument) (Syntax: '1') ILiteralExpression (Text: 1) (OperationKind.LiteralExpression, Type: System.Int32, Constant: 1) (Syntax: '1') - IArgument (ArgumentKind.Positional Matching Parameter: y) (OperationKind.Argument) (Syntax: '2.0') + IArgument (ArgumentKind.Explicit Matching Parameter: y) (OperationKind.Argument) (Syntax: '2.0') ILiteralExpression (OperationKind.LiteralExpression, Type: System.Double, Constant: 2) (Syntax: '2.0') "; var expectedDiagnostics = DiagnosticDescription.None; @@ -52,7 +52,7 @@ static void M1() "; string expectedOperationTree = @" IInvocationExpression (static void P.M2(System.Int32 x, [System.Double y = 0])) (OperationKind.InvocationExpression, Type: System.Void) (Syntax: 'M2(1)') - Arguments(2): IArgument (ArgumentKind.Positional Matching Parameter: x) (OperationKind.Argument) (Syntax: '1') + Arguments(2): IArgument (ArgumentKind.Explicit Matching Parameter: x) (OperationKind.Argument) (Syntax: '1') ILiteralExpression (Text: 1) (OperationKind.LiteralExpression, Type: System.Int32, Constant: 1) (Syntax: '1') IArgument (ArgumentKind.DefaultValue Matching Parameter: y) (OperationKind.Argument) (Syntax: 'M2(1)') ILiteralExpression (Text: 0) (OperationKind.LiteralExpression, Type: System.Double, Constant: 0) (Syntax: 'M2(1)') @@ -78,9 +78,9 @@ static void M1() "; string expectedOperationTree = @" IInvocationExpression (static void P.M2(System.Int32 x, [System.Double y = 0])) (OperationKind.InvocationExpression, Type: System.Void) (Syntax: 'M2(x: 1, y: 9.9)') - Arguments(2): IArgument (ArgumentKind.Named Matching Parameter: x) (OperationKind.Argument) (Syntax: '1') + Arguments(2): IArgument (ArgumentKind.Explicit Matching Parameter: x) (OperationKind.Argument) (Syntax: '1') ILiteralExpression (Text: 1) (OperationKind.LiteralExpression, Type: System.Int32, Constant: 1) (Syntax: '1') - IArgument (ArgumentKind.Named Matching Parameter: y) (OperationKind.Argument) (Syntax: '9.9') + IArgument (ArgumentKind.Explicit Matching Parameter: y) (OperationKind.Argument) (Syntax: '9.9') ILiteralExpression (Text: 9.9) (OperationKind.LiteralExpression, Type: System.Double, Constant: 9.9) (Syntax: '9.9') "; var expectedDiagnostics = DiagnosticDescription.None; @@ -105,9 +105,9 @@ static void M1() "; string expectedOperationTree = @" IInvocationExpression (static void P.M2(System.Int32 x, [System.Double y = 0])) (OperationKind.InvocationExpression, Type: System.Void) (Syntax: 'M2(y: 9.9, x: 1)') - Arguments(2): IArgument (ArgumentKind.Named Matching Parameter: y) (OperationKind.Argument) (Syntax: '9.9') + Arguments(2): IArgument (ArgumentKind.Explicit Matching Parameter: y) (OperationKind.Argument) (Syntax: '9.9') ILiteralExpression (Text: 9.9) (OperationKind.LiteralExpression, Type: System.Double, Constant: 9.9) (Syntax: '9.9') - IArgument (ArgumentKind.Named Matching Parameter: x) (OperationKind.Argument) (Syntax: '1') + IArgument (ArgumentKind.Explicit Matching Parameter: x) (OperationKind.Argument) (Syntax: '1') ILiteralExpression (Text: 1) (OperationKind.LiteralExpression, Type: System.Int32, Constant: 1) (Syntax: '1') "; var expectedDiagnostics = DiagnosticDescription.None; @@ -131,7 +131,7 @@ static void M1() "; string expectedOperationTree = @" IInvocationExpression (static void P.M2([System.Int32 x = 1], [System.Double y = 0])) (OperationKind.InvocationExpression, Type: System.Void) (Syntax: 'M2(y: 9.9)') - Arguments(2): IArgument (ArgumentKind.Named Matching Parameter: y) (OperationKind.Argument) (Syntax: '9.9') + Arguments(2): IArgument (ArgumentKind.Explicit Matching Parameter: y) (OperationKind.Argument) (Syntax: '9.9') ILiteralExpression (Text: 9.9) (OperationKind.LiteralExpression, Type: System.Double, Constant: 9.9) (Syntax: '9.9') IArgument (ArgumentKind.DefaultValue Matching Parameter: x) (OperationKind.Argument) (Syntax: 'M2(y: 9.9)') ILiteralExpression (Text: 1) (OperationKind.LiteralExpression, Type: System.Int32, Constant: 1) (Syntax: 'M2(y: 9.9)') @@ -157,9 +157,9 @@ static void M1() "; string expectedOperationTree = @" IInvocationExpression (static void P.M2([System.Int32 x = 1], [System.Int32 y = 2], [System.Int32 z = 3])) (OperationKind.InvocationExpression, Type: System.Void) (Syntax: 'M2(1, z: 10)') - Arguments(3): IArgument (ArgumentKind.Positional Matching Parameter: x) (OperationKind.Argument) (Syntax: '1') + Arguments(3): IArgument (ArgumentKind.Explicit Matching Parameter: x) (OperationKind.Argument) (Syntax: '1') ILiteralExpression (Text: 1) (OperationKind.LiteralExpression, Type: System.Int32, Constant: 1) (Syntax: '1') - IArgument (ArgumentKind.Named Matching Parameter: z) (OperationKind.Argument) (Syntax: '10') + IArgument (ArgumentKind.Explicit Matching Parameter: z) (OperationKind.Argument) (Syntax: '10') ILiteralExpression (Text: 10) (OperationKind.LiteralExpression, Type: System.Int32, Constant: 10) (Syntax: '10') IArgument (ArgumentKind.DefaultValue Matching Parameter: y) (OperationKind.Argument) (Syntax: 'M2(1, z: 10)') ILiteralExpression (Text: 2) (OperationKind.LiteralExpression, Type: System.Int32, Constant: 2) (Syntax: 'M2(1, z: 10)') @@ -188,9 +188,9 @@ void M1() string expectedOperationTree = @" IInvocationExpression ( void P.M2(ref System.Int32 x, out System.Int32 y)) (OperationKind.InvocationExpression, Type: System.Void) (Syntax: 'M2(ref a, out b)') Instance Receiver: IInstanceReferenceExpression (InstanceReferenceKind.Implicit) (OperationKind.InstanceReferenceExpression, Type: P) (Syntax: 'M2') - Arguments(2): IArgument (ArgumentKind.Positional Matching Parameter: x) (OperationKind.Argument) (Syntax: 'a') + Arguments(2): IArgument (ArgumentKind.Explicit Matching Parameter: x) (OperationKind.Argument) (Syntax: 'a') ILocalReferenceExpression: a (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'a') - IArgument (ArgumentKind.Positional Matching Parameter: y) (OperationKind.Argument) (Syntax: 'b') + IArgument (ArgumentKind.Explicit Matching Parameter: y) (OperationKind.Argument) (Syntax: 'b') ILocalReferenceExpression: b (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'b') "; var expectedDiagnostics = DiagnosticDescription.None; @@ -217,9 +217,9 @@ void M1() string expectedOperationTree = @" IInvocationExpression ( void P.M2(ref System.Int32 x, out System.Int32 y)) (OperationKind.InvocationExpression, Type: System.Void) (Syntax: 'M2(y: out b, x: ref a)') Instance Receiver: IInstanceReferenceExpression (InstanceReferenceKind.Implicit) (OperationKind.InstanceReferenceExpression, Type: P) (Syntax: 'M2') - Arguments(2): IArgument (ArgumentKind.Named Matching Parameter: y) (OperationKind.Argument) (Syntax: 'b') + Arguments(2): IArgument (ArgumentKind.Explicit Matching Parameter: y) (OperationKind.Argument) (Syntax: 'b') ILocalReferenceExpression: b (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'b') - IArgument (ArgumentKind.Named Matching Parameter: x) (OperationKind.Argument) (Syntax: 'a') + IArgument (ArgumentKind.Explicit Matching Parameter: x) (OperationKind.Argument) (Syntax: 'a') ILocalReferenceExpression: a (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'a') "; var expectedDiagnostics = DiagnosticDescription.None; @@ -244,7 +244,7 @@ void M1() string expectedOperationTree = @" IInvocationExpression ( void P.M2(System.String str, params System.Int32[] array)) (OperationKind.InvocationExpression, Type: System.Void) (Syntax: 'M2(null)') Instance Receiver: IInstanceReferenceExpression (InstanceReferenceKind.Implicit) (OperationKind.InstanceReferenceExpression, Type: P) (Syntax: 'M2') - Arguments(2): IArgument (ArgumentKind.Positional Matching Parameter: str) (OperationKind.Argument) (Syntax: 'null') + Arguments(2): IArgument (ArgumentKind.Explicit Matching Parameter: str) (OperationKind.Argument) (Syntax: 'null') IConversionExpression (ConversionKind.Cast, Implicit) (OperationKind.ConversionExpression, Type: System.String, Constant: null) (Syntax: 'null') ILiteralExpression (Text: null) (OperationKind.LiteralExpression, Type: null, Constant: null) (Syntax: 'null') IArgument (ArgumentKind.ParamArray Matching Parameter: array) (OperationKind.Argument) (Syntax: 'M2(null)') @@ -274,7 +274,7 @@ void M1() string expectedOperationTree = @" IInvocationExpression ( void P.M2(System.String str, params System.Int32[] array)) (OperationKind.InvocationExpression, Type: System.Void) (Syntax: 'M2(null, 1, 2)') Instance Receiver: IInstanceReferenceExpression (InstanceReferenceKind.Implicit) (OperationKind.InstanceReferenceExpression, Type: P) (Syntax: 'M2') - Arguments(2): IArgument (ArgumentKind.Positional Matching Parameter: str) (OperationKind.Argument) (Syntax: 'null') + Arguments(2): IArgument (ArgumentKind.Explicit Matching Parameter: str) (OperationKind.Argument) (Syntax: 'null') IConversionExpression (ConversionKind.Cast, Implicit) (OperationKind.ConversionExpression, Type: System.String, Constant: null) (Syntax: 'null') ILiteralExpression (Text: null) (OperationKind.LiteralExpression, Type: null, Constant: null) (Syntax: 'null') IArgument (ArgumentKind.ParamArray Matching Parameter: array) (OperationKind.Argument) (Syntax: '1') @@ -306,10 +306,10 @@ void M1() string expectedOperationTree = @" IInvocationExpression ( void P.M2(System.String str, params System.Int32[] array)) (OperationKind.InvocationExpression, Type: System.Void) (Syntax: 'M2(null, new[] { 1, 2 })') Instance Receiver: IInstanceReferenceExpression (InstanceReferenceKind.Implicit) (OperationKind.InstanceReferenceExpression, Type: P) (Syntax: 'M2') - Arguments(2): IArgument (ArgumentKind.Positional Matching Parameter: str) (OperationKind.Argument) (Syntax: 'null') + Arguments(2): IArgument (ArgumentKind.Explicit Matching Parameter: str) (OperationKind.Argument) (Syntax: 'null') IConversionExpression (ConversionKind.Cast, Implicit) (OperationKind.ConversionExpression, Type: System.String, Constant: null) (Syntax: 'null') ILiteralExpression (Text: null) (OperationKind.LiteralExpression, Type: null, Constant: null) (Syntax: 'null') - IArgument (ArgumentKind.Positional Matching Parameter: array) (OperationKind.Argument) (Syntax: 'new[] { 1, 2 }') + IArgument (ArgumentKind.Explicit Matching Parameter: array) (OperationKind.Argument) (Syntax: 'new[] { 1, 2 }') IArrayCreationExpression (Element Type: System.Int32) (OperationKind.ArrayCreationExpression, Type: System.Int32[]) (Syntax: 'new[] { 1, 2 }') Dimension Sizes(1): ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 2) (Syntax: 'new[] { 1, 2 }') Initializer: IArrayInitializer (OperationKind.ArrayInitializer) (Syntax: '{ 1, 2 }') @@ -343,7 +343,7 @@ void M1() Dimension Sizes(1): ILiteralExpression (Text: 1) (OperationKind.LiteralExpression, Type: null, Constant: 1) (Syntax: '1') Initializer: IArrayInitializer (OperationKind.ArrayInitializer) (Syntax: '1') Element Values(1): ILiteralExpression (Text: 1) (OperationKind.LiteralExpression, Type: System.Int32, Constant: 1) (Syntax: '1') - IArgument (ArgumentKind.Named Matching Parameter: str) (OperationKind.Argument) (Syntax: 'null') + IArgument (ArgumentKind.Explicit Matching Parameter: str) (OperationKind.Argument) (Syntax: 'null') IConversionExpression (ConversionKind.Cast, Implicit) (OperationKind.ConversionExpression, Type: System.String, Constant: null) (Syntax: 'null') ILiteralExpression (Text: null) (OperationKind.LiteralExpression, Type: null, Constant: null) (Syntax: 'null') "; @@ -369,13 +369,13 @@ void M1() string expectedOperationTree = @" IInvocationExpression ( void P.M2(System.String str, params System.Int32[] array)) (OperationKind.InvocationExpression, Type: System.Void) (Syntax: 'M2(array: n ... str: null)') Instance Receiver: IInstanceReferenceExpression (InstanceReferenceKind.Implicit) (OperationKind.InstanceReferenceExpression, Type: P) (Syntax: 'M2') - Arguments(2): IArgument (ArgumentKind.Named Matching Parameter: array) (OperationKind.Argument) (Syntax: 'new[] { 1, 2 }') + Arguments(2): IArgument (ArgumentKind.Explicit Matching Parameter: array) (OperationKind.Argument) (Syntax: 'new[] { 1, 2 }') IArrayCreationExpression (Element Type: System.Int32) (OperationKind.ArrayCreationExpression, Type: System.Int32[]) (Syntax: 'new[] { 1, 2 }') Dimension Sizes(1): ILiteralExpression (OperationKind.LiteralExpression, Type: System.Int32, Constant: 2) (Syntax: 'new[] { 1, 2 }') Initializer: IArrayInitializer (OperationKind.ArrayInitializer) (Syntax: '{ 1, 2 }') Element Values(2): ILiteralExpression (Text: 1) (OperationKind.LiteralExpression, Type: System.Int32, Constant: 1) (Syntax: '1') ILiteralExpression (Text: 2) (OperationKind.LiteralExpression, Type: System.Int32, Constant: 2) (Syntax: '2') - IArgument (ArgumentKind.Named Matching Parameter: str) (OperationKind.Argument) (Syntax: 'null') + IArgument (ArgumentKind.Explicit Matching Parameter: str) (OperationKind.Argument) (Syntax: 'null') IConversionExpression (ConversionKind.Cast, Implicit) (OperationKind.ConversionExpression, Type: System.String, Constant: null) (Syntax: 'null') ILiteralExpression (Text: null) (OperationKind.LiteralExpression, Type: null, Constant: null) (Syntax: 'null') "; diff --git a/src/Compilers/Core/Portable/Operations/ArgumentKind.cs b/src/Compilers/Core/Portable/Operations/ArgumentKind.cs index 8e56d7393b89fb8efbea989cd6ce1bd04c4e4128..3de4db0c4dccd37d37f5b3299d3243a5445566bc 100644 --- a/src/Compilers/Core/Portable/Operations/ArgumentKind.cs +++ b/src/Compilers/Core/Portable/Operations/ArgumentKind.cs @@ -1,7 +1,5 @@ // Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System.Collections.Immutable; - + namespace Microsoft.CodeAnalysis.Semantics { /// @@ -12,21 +10,20 @@ public enum ArgumentKind None = 0x0, /// - /// Argument is specified positionally and matches the parameter of the same ordinality. - /// - Positional = 0x1, - /// - /// Argument is specified by name and matches the parameter of the same name. + /// Argument value is explicitly supplied. /// - Named = 0x2, + Explicit = 0x1, + /// - /// Argument becomes an element of an array that matches a trailing C# params or VB ParamArray parameter. + /// Argument is a param array created by compilers for the matching C# params or VB ParamArray parameter. + /// Note, the value is a an array creation expression that encapsulates all the elements, if any. /// - ParamArray = 0x3, + ParamArray = 0x2, + /// - /// Argument was omitted in source but has a default value supplied automatically. + /// Argument is a default value supplied automatically by the compilers. /// - DefaultValue = 0x4 + DefaultValue = 0x3 } } diff --git a/src/Compilers/Core/Portable/Operations/IArgument.cs b/src/Compilers/Core/Portable/Operations/IArgument.cs index a8977367c1d6416d89d7f404dc7f856e341fc21e..f943dbac3298f04ba3441327ce594543f86e54e7 100644 --- a/src/Compilers/Core/Portable/Operations/IArgument.cs +++ b/src/Compilers/Core/Portable/Operations/IArgument.cs @@ -1,7 +1,5 @@ // Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using System.Collections.Immutable; - namespace Microsoft.CodeAnalysis.Semantics { /// diff --git a/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt b/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt index cc6e80f6fa47d3b936765553578a7027c8ee2b3a..4719ebed1d3bb707128b91e8c6157b7d6a103c4a 100644 --- a/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt +++ b/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt @@ -1,3 +1,7 @@ +*REMOVED*Microsoft.CodeAnalysis.Semantics.ArgumentKind.DefaultValue = 4 -> Microsoft.CodeAnalysis.Semantics.ArgumentKind +*REMOVED*Microsoft.CodeAnalysis.Semantics.ArgumentKind.Named = 2 -> Microsoft.CodeAnalysis.Semantics.ArgumentKind +*REMOVED*Microsoft.CodeAnalysis.Semantics.ArgumentKind.ParamArray = 3 -> Microsoft.CodeAnalysis.Semantics.ArgumentKind +*REMOVED*Microsoft.CodeAnalysis.Semantics.ArgumentKind.Positional = 1 -> Microsoft.CodeAnalysis.Semantics.ArgumentKind *REMOVED*Microsoft.CodeAnalysis.Semantics.IHasArgumentsExpression.ArgumentsInParameterOrder.get -> System.Collections.Immutable.ImmutableArray *REMOVED*Microsoft.CodeAnalysis.Semantics.IHasArgumentsExpression.GetArgumentMatchingParameter(Microsoft.CodeAnalysis.IParameterSymbol parameter) -> Microsoft.CodeAnalysis.Semantics.IArgument *REMOVED*Microsoft.CodeAnalysis.Semantics.IInvocationExpression.ArgumentsInSourceOrder.get -> System.Collections.Immutable.ImmutableArray @@ -8,6 +12,9 @@ Microsoft.CodeAnalysis.CommandLineReference.CommandLineReference(string referenc Microsoft.CodeAnalysis.CommandLineSourceFile.CommandLineSourceFile(string path, bool isScript) -> void Microsoft.CodeAnalysis.ParseOptions.Errors.get -> System.Collections.Immutable.ImmutableArray Microsoft.CodeAnalysis.ParseOptions.SpecifiedKind.get -> Microsoft.CodeAnalysis.SourceCodeKind +Microsoft.CodeAnalysis.Semantics.ArgumentKind.DefaultValue = 3 -> Microsoft.CodeAnalysis.Semantics.ArgumentKind +Microsoft.CodeAnalysis.Semantics.ArgumentKind.Explicit = 1 -> Microsoft.CodeAnalysis.Semantics.ArgumentKind +Microsoft.CodeAnalysis.Semantics.ArgumentKind.ParamArray = 2 -> Microsoft.CodeAnalysis.Semantics.ArgumentKind Microsoft.CodeAnalysis.Semantics.IHasArgumentsExpression.ArgumentsInEvaluationOrder.get -> System.Collections.Immutable.ImmutableArray Microsoft.CodeAnalysis.Semantics.IInvalidExpression.Children.get -> System.Collections.Immutable.ImmutableArray Microsoft.CodeAnalysis.Semantics.IInvalidStatement.Children.get -> System.Collections.Immutable.ImmutableArray diff --git a/src/Compilers/VisualBasic/Portable/BoundTree/Expression.vb b/src/Compilers/VisualBasic/Portable/BoundTree/Expression.vb index 07cb55ff09d03fd85752fbd9fe014d891fc55617..6c691b76f655be78319786826b34e61df46f2336 100644 --- a/src/Compilers/VisualBasic/Portable/BoundTree/Expression.vb +++ b/src/Compilers/VisualBasic/Portable/BoundTree/Expression.vb @@ -355,14 +355,24 @@ Namespace Microsoft.CodeAnalysis.VisualBasic argument, Function(argumentValue) New ByRefArgument(If(CUInt(index) < CUInt(parameters.Length), parameters(index), Nothing), DirectCast(argumentValue, BoundByRefArgumentWithCopyBack))) Case Else - ' Apparently the VB bound trees don't encode named arguments, which seems unnecesarily lossy. Return s_argumentMappings.GetValue( argument, Function(argumentValue) - If index >= parameters.Length - 1 AndAlso parameters.Length > 0 AndAlso parameters(parameters.Length - 1).IsParamArray Then - Return New Argument(ArgumentKind.ParamArray, parameters(parameters.Length - 1), argumentValue) + Dim lastParameterIndex = parameters.Length - 1 + If index >= lastParameterIndex AndAlso parameters.Length > 0 AndAlso parameters(lastParameterIndex).IsParamArray Then + ' TODO: figure out if this is true: + ' a compiler generated argument for a ParamArray parameter is created iff + ' a list of arguments (including 0 argument) is provided for ParamArray parameter in source + Dim kind = If(argument.WasCompilerGenerated, ArgumentKind.ParamArray, ArgumentKind.Explicit) + Debug.Assert(argument.Type.TypeKind = TypeKind.Array) + Return New Argument(kind, parameters(lastParameterIndex), argumentValue) Else - Return New Argument(ArgumentKind.Positional, If(CUInt(index) < CUInt(parameters.Length), parameters(index), Nothing), argumentValue) + ' TODO: figure our if this is true: + ' a compiler generated argument for an Optional parameter is created iff + ' the argument is omitted from the source + Dim kind = If(argument.WasCompilerGenerated, ArgumentKind.DefaultValue, ArgumentKind.Explicit) + Dim parameter = If(CUInt(index) < CUInt(parameters.Length), parameters(index), Nothing) + Return New Argument(kind, parameter, argumentValue) End If End Function) End Select @@ -476,8 +486,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic Public Overrides ReadOnly Property ArgumentKind As ArgumentKind Get - ' Do the VB bound trees encode named arguments? - Return ArgumentKind.Positional + Return ArgumentKind.Explicit End Get End Property diff --git a/src/Compilers/VisualBasic/Test/Semantic/IOperation/IOperationTests_IArgument.vb b/src/Compilers/VisualBasic/Test/Semantic/IOperation/IOperationTests_IArgument.vb index fb389aae25ed936a8bea4686dcd1712f3b5b84c8..3cd24be7245356cc7c6c4297c4e70617d423d8e8 100644 --- a/src/Compilers/VisualBasic/Test/Semantic/IOperation/IOperationTests_IArgument.vb +++ b/src/Compilers/VisualBasic/Test/Semantic/IOperation/IOperationTests_IArgument.vb @@ -23,9 +23,9 @@ End Class]]>.Value Dim expectedOperationTree = .Value @@ -49,10 +49,10 @@ End Class]]>.Value Dim expectedOperationTree = .Value @@ -77,9 +77,9 @@ End Class]]>.Value Dim expectedOperationTree = .Value @@ -103,9 +103,9 @@ End Class]]>.Value Dim expectedOperationTree = .Value @@ -129,7 +129,7 @@ End Class]]>.Value Dim expectedOperationTree = .Value Dim expectedOperationTree =