Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Merge 'features/ParamsCollections' into 'main'#72511

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
AlekseyTs merged 44 commits intodotnet:mainfromAlekseyTs:ParamsCollections_35
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
44 commits
Select commitHold shift + click to select a range
2bedf28
Merge main to ParamsCollections (#71150)
AlekseyTsDec 7, 2023
569dcb7
Make trivial Params Collections scenarios working end to end (#71136)
AlekseyTsDec 11, 2023
60a4581
Params Collections: Implement language version check. (#71228)
AlekseyTsDec 13, 2023
88c8859
Params Collections: Implement "Better function member" section of the…
AlekseyTsDec 18, 2023
07fc1db
IOperation - drop synthesized conversion placed on top of params coll…
AlekseyTsDec 20, 2023
0e16ec0
Add handling of params collections for natural delegate types (#71334)
AlekseyTsJan 6, 2024
a91ef66
Params Collections - Adjust binding in presence of dynamic arguments …
AlekseyTsJan 8, 2024
a9ffbe0
Params Collections: misc chanages (#71423)
AlekseyTsJan 9, 2024
4fb7084
Merge 'dotnet/main' into ParamsCollections
AlekseyTsJan 9, 2024
99ef47c
Temporarily skip some tests to unblock merge from `main`
AlekseyTsJan 9, 2024
0be7dc3
Merge 'dotnet/main' into ParamsCollections (#71545)
AlekseyTsJan 9, 2024
6bc0d9b
Enable some dynamic collection expression tests which were disabled d…
AlekseyTsJan 10, 2024
7f00d15
Add a test for 'Params Collections.' (#71572)
AlekseyTsJan 11, 2024
55b6a79
Params Collections: Add a bunch of PROTOTYPE comments and a couple of…
AlekseyTsJan 12, 2024
ba5ee92
Use ParamCollectionAttribute to mark params collections in metadata (…
AlekseyTsJan 26, 2024
399026e
Merge 'dotnet/main' into ParamsCollections
AlekseyTsJan 26, 2024
882ccbc
Follow up on merge from 'main'
AlekseyTsJan 26, 2024
897fd49
Merge 'dotnet/main' into ParamsCollections(#71824)
AlekseyTsJan 26, 2024
1c5c7e2
Adjust public API based on API review feedback (#71940)
AlekseyTsFeb 5, 2024
6cd3f1e
Align `params` type validation with the the spec (#71918)
AlekseyTsFeb 7, 2024
6fcac7d
Params parameters are implicitly scoped when their type is a ref stru…
AlekseyTsFeb 9, 2024
18852b8
Merge remote-tracking branch 'dotnet/main' into ParamsCollections_20
AlekseyTsFeb 10, 2024
25414ee
Update test according to changes in ParamsCollections branch
AlekseyTsFeb 10, 2024
1dbe23e
Merge 'dotnet/main' into ParamsCollections (#72042)
AlekseyTsFeb 12, 2024
2b8a744
Break a cycle through attributes (#72041)
AlekseyTsFeb 12, 2024
7ddc662
Add more tests and address some of the PROTOTYPE comments (#72089)
AlekseyTsFeb 14, 2024
ba462cc
Address more PROTOTYPE comments (#72113)
AlekseyTsFeb 16, 2024
03fd758
Clone some IDE tests for params collections (#72228)
AlekseyTsFeb 22, 2024
05cf517
Add `ArgumentKind.ParamCollection` (#72221)
AlekseyTsFeb 22, 2024
8085621
Rename BoundNode flag for clarity (#72235)
AlekseyTsFeb 23, 2024
9180f98
Params parameter is implicitly scoped if and only if `params` is expl…
AlekseyTsFeb 27, 2024
835dd26
Address some PROTOTYPE comments (#72298)
AlekseyTsFeb 29, 2024
5b563bf
Merge 'main' into ParamsCollections
AlekseyTsMar 5, 2024
637dec2
Regenerate ErrorFacts.Generated.cs
AlekseyTsMar 5, 2024
811c275
Merge 'main' into ParamsCollections (#72390)
AlekseyTsMar 5, 2024
b6f9fe5
Rename IDS_ParamsCollections to IDS_FeatureParamsCollections (#72399)
AlekseyTsMar 5, 2024
91815cb
Misc. work for params collections (#72408)
AlekseyTsMar 6, 2024
512187f
Ensure obsolete diagnostics about required constructor or Add method …
AlekseyTsMar 8, 2024
84d12e1
Merge 'main' into ParamsCollections
AlekseyTsMar 12, 2024
bf22912
Merge 'main' into ParamsCollections (#72497)
AlekseyTsMar 12, 2024
99f3521
Adjust GetUnderlyingCollectionExpressionElement to handle params coll…
AlekseyTsMar 12, 2024
bc9a7f0
Pack resource IDs and adjust Compiler Test Plan (#72499)
AlekseyTsMar 12, 2024
3d0bcbb
Merge 'features/ParamsCollections' into 'main'
AlekseyTsMar 12, 2024
d073ac9
Adjust test baselines
AlekseyTsMar 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
Params Collections: misc chanages (#71423)
- Params Collections in attributes- Params Collections in lambdas- Params Collections and interpolated string handler- Order of evaluation:  - named arguments  - compound assignment  - object initializerAlsofixes#71488.
  • Loading branch information
@AlekseyTs
AlekseyTs authoredJan 9, 2024
commita9ffbe01a6456122edffa6ddfd5da4eb795ca767
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -380,10 +380,11 @@ ImmutableArray<int> makeSourceIndices()
constructorArgumentSourceIndices.Count = lengthAfterRewriting;
for (int argIndex = 0; argIndex < lengthAfterRewriting; argIndex++)
{
Debug.Assert(!arguments[argIndex].IsParamsCollection || arguments[argIndex] is BoundArrayCreation);

int paramIndex = argsToParamsOpt.IsDefault ? argIndex : argsToParamsOpt[argIndex];
constructorArgumentSourceIndices[paramIndex] =
defaultArguments[argIndex] ||
// PROTOTYPE(ParamsCollections): Adjust?
(arguments[argIndex].IsParamsCollection && arguments[argIndex] is BoundArrayCreation { Bounds: [BoundLiteral { ConstantValueOpt.Value: 0 }] }) ?
-1 : argIndex;
}
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -825,7 +825,7 @@ private void GenerateImplicitConversionErrorForCollectionExpression(
if (collectionTypeKind == CollectionExpressionTypeKind.CollectionBuilder)
{
Debug.Assert(elementTypeWithAnnotations.Type is null); // GetCollectionExpressionTypeKind() does not set elementType for CollectionBuilder cases.
if (!TryGetCollectionIterationType((ExpressionSyntax)node.Syntax, targetType, out elementTypeWithAnnotations))
if (!TryGetCollectionIterationType(node.Syntax, targetType, out elementTypeWithAnnotations))
{
Error(diagnostics, ErrorCode.ERR_CollectionBuilderNoElementType, node.Syntax, targetType);
return;
Expand DownExpand Up@@ -1454,8 +1454,7 @@ lambdaParameter is not SourceComplexParameterSymbolBase
}
}

// PROTOTYPE(ParamsCollections): Adjust
if (lambdaParameter.IsParams && !delegateParameter.IsParams && p == lambdaSymbol.ParameterCount - 1 && lambdaParameter.Type.IsSZArray())
if (lambdaParameter.IsParams && !delegateParameter.IsParams && p == lambdaSymbol.ParameterCount - 1)
{
// Parameter {0} has params modifier in lambda but not in target delegate type.
Error(diagnostics, ErrorCode.WRN_ParamsArrayInLambdaOnly, lambdaParameter.GetFirstLocation(), p + 1);
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3408,7 +3408,7 @@ private void CheckAndCoerceArguments<TMember>(
Debug.Assert(argument is BoundUnconvertedInterpolatedString or BoundBinaryOperator { IsUnconvertedInterpolatedStringAddition: true });
TypeWithAnnotations parameterTypeWithAnnotations = GetCorrespondingParameterTypeWithAnnotations(ref result, parameters, arg);
reportUnsafeIfNeeded(methodResult, diagnostics, argument, parameterTypeWithAnnotations);
arguments[arg] = BindInterpolatedStringHandlerInMemberCall(argument, arguments, parameters, ref result, arg, receiver, diagnostics);
arguments[arg] = BindInterpolatedStringHandlerInMemberCall(argument,parameterTypeWithAnnotations.Type,arguments, parameters, ref result, arg, receiver, diagnostics);
}
// https://github.com/dotnet/roslyn/issues/37119 : should we create an (Identity) conversion when the kind is Identity but the types differ?
else if (!kind.IsIdentity)
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -876,6 +876,7 @@ private ImmutableArray<BoundExpression> BindInterpolatedStringParts(BoundUnconve

private BoundExpression BindInterpolatedStringHandlerInMemberCall(
BoundExpression unconvertedString,
TypeSymbol handlerType,
ArrayBuilder<BoundExpression> arguments,
ImmutableArray<ParameterSymbol> parameters,
ref MemberAnalysisResult memberAnalysisResult,
Expand All@@ -886,36 +887,42 @@ private BoundExpression BindInterpolatedStringHandlerInMemberCall(
Debug.Assert(unconvertedString is BoundUnconvertedInterpolatedString or BoundBinaryOperator { IsUnconvertedInterpolatedStringAddition: true });
var interpolatedStringConversion = memberAnalysisResult.ConversionForArg(interpolatedStringArgNum);
Debug.Assert(interpolatedStringConversion.IsInterpolatedStringHandler);
var interpolatedStringParameter = GetCorrespondingParameter(ref memberAnalysisResult, parameters, interpolatedStringArgNum);
Debug.Assert(interpolatedStringParameter is { Type: NamedTypeSymbol { IsInterpolatedStringHandlerType: true } }
#pragma warning disable format
or
{
IsParams: true,
// PROTOTYPE(ParamsCollections): Adjust
Type: ArrayTypeSymbol { ElementType: NamedTypeSymbol { IsInterpolatedStringHandlerType: true } },
InterpolatedStringHandlerArgumentIndexes.IsEmpty: true
});
#pragma warning restore format
Debug.Assert(!interpolatedStringParameter.IsParams || memberAnalysisResult.Kind == MemberResolutionKind.ApplicableInExpandedForm);

if (interpolatedStringParameter.HasInterpolatedStringHandlerArgumentError)
Debug.Assert(handlerType is NamedTypeSymbol { IsInterpolatedStringHandlerType: true });

var correspondingParameter = GetCorrespondingParameter(ref memberAnalysisResult, parameters, interpolatedStringArgNum);
var handlerParameterIndexes = correspondingParameter.InterpolatedStringHandlerArgumentIndexes;

if (memberAnalysisResult.Kind == MemberResolutionKind.ApplicableInExpandedForm && correspondingParameter.Ordinal == parameters.Length - 1)
{
Debug.Assert(handlerParameterIndexes.IsEmpty);

// No arguments, fall back to the standard conversion steps.
return CreateConversion(
unconvertedString.Syntax,
unconvertedString,
interpolatedStringConversion,
isCast: false,
conversionGroupOpt: null,
handlerType,
diagnostics);
}

if (correspondingParameter.HasInterpolatedStringHandlerArgumentError)
{
// The InterpolatedStringHandlerArgumentAttribute applied to parameter '{0}' is malformed and cannot be interpreted. Construct an instance of '{1}' manually.
diagnostics.Add(ErrorCode.ERR_InterpolatedStringHandlerArgumentAttributeMalformed, unconvertedString.Syntax.Location,interpolatedStringParameter, interpolatedStringParameter.Type);
diagnostics.Add(ErrorCode.ERR_InterpolatedStringHandlerArgumentAttributeMalformed, unconvertedString.Syntax.Location,correspondingParameter, handlerType);
return CreateConversion(
unconvertedString.Syntax,
unconvertedString,
interpolatedStringConversion,
isCast: false,
conversionGroupOpt: null,
wasCompilerGenerated: false,
interpolatedStringParameter.Type,
handlerType,
diagnostics,
hasErrors: true);
}

var handlerParameterIndexes = interpolatedStringParameter.InterpolatedStringHandlerArgumentIndexes;
if (handlerParameterIndexes.IsEmpty)
{
// No arguments, fall back to the standard conversion steps.
Expand All@@ -925,8 +932,7 @@ private BoundExpression BindInterpolatedStringHandlerInMemberCall(
interpolatedStringConversion,
isCast: false,
conversionGroupOpt: null,
// PROTOTYPE(ParamsCollections): Adjust
interpolatedStringParameter.IsParams ? ((ArrayTypeSymbol)interpolatedStringParameter.Type).ElementType : interpolatedStringParameter.Type,
handlerType,
diagnostics);
}

Expand DownExpand Up@@ -1007,7 +1013,7 @@ private BoundExpression BindInterpolatedStringHandlerInMemberCall(
ErrorCode.ERR_InterpolatedStringHandlerArgumentOptionalNotSpecified,
unconvertedString.Syntax.Location,
parameter.Name,
interpolatedStringParameter.Name);
correspondingParameter.Name);
hasErrors = true;
}

Expand All@@ -1026,7 +1032,7 @@ private BoundExpression BindInterpolatedStringHandlerInMemberCall(
ErrorCode.ERR_InterpolatedStringHandlerArgumentLocatedAfterInterpolatedString,
arguments[argumentIndex].Syntax.Location,
parameter.Name,
interpolatedStringParameter.Name);
correspondingParameter.Name);
hasErrors = true;
}

Expand DownExpand Up@@ -1073,7 +1079,7 @@ private BoundExpression BindInterpolatedStringHandlerInMemberCall(

var interpolatedString = BindUnconvertedInterpolatedExpressionToHandlerType(
unconvertedString,
(NamedTypeSymbol)interpolatedStringParameter.Type,
(NamedTypeSymbol)handlerType,
diagnostics,
additionalConstructorArguments: argumentPlaceholdersBuilder.ToImmutableAndFree(),
additionalConstructorRefKinds: argumentRefKindsBuilder.ToImmutableAndFree());
Expand All@@ -1086,7 +1092,7 @@ private BoundExpression BindInterpolatedStringHandlerInMemberCall(
explicitCastInCode: false,
conversionGroupOpt: null,
constantValueOpt: null,
interpolatedStringParameter.Type,
handlerType,
hasErrors || interpolatedString.HasErrors);
}
}
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -170,7 +170,7 @@ protected override Conversion GetCollectionExpressionConversion(

case CollectionExpressionTypeKind.CollectionBuilder:
{
_binder.TryGetCollectionIterationType((Syntax.ExpressionSyntax)syntax, targetType, out elementTypeWithAnnotations);
_binder.TryGetCollectionIterationType(syntax, targetType, out elementTypeWithAnnotations);
elementType = elementTypeWithAnnotations.Type;
if (elementType is null)
{
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1312,7 +1312,7 @@ private void BuildStoresToTemps(

Debug.Assert(arguments[p] == null);

if (argument.IsParamsCollection) // PROTOTYPE(ParamsCollections): Do we need to do the same special case for collections other than arrays?
if (argument.IsParamsCollection)
{
Debug.Assert(expanded);
Debug.Assert(p == parameters.Length - 1);
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -343,10 +343,9 @@ private BoundIndexerAccess TransformIndexerAccessContinued(
refKinds,
storesToTemps);

if (expanded)
if (expanded && actualArguments[actualArguments.Length - 1] is { IsParamsCollection: true } array)
{
BoundExpression array = actualArguments[actualArguments.Length - 1];
Debug.Assert(array.IsParamsCollection); // PROTOTYPE(ParamsCollections): This Assert is likely to fail for a non-array case. The code path needs an adjustment in general.
Debug.Assert(array is BoundArrayCreation);

if (TryOptimizeParamsArray(array, out BoundExpression? optimized))
{
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -295,7 +295,7 @@ private void AddObjectInitializer(

if (!memberInit.Arguments.IsDefaultOrEmpty)
{
Debug.Assert(memberInit.Arguments.Count(a => a.IsParamsCollection)== (memberInit.Expanded ? 1 : 0)); // PROTOTYPE(ParamsCollections): Adjust?
Debug.Assert(memberInit.Arguments.Count(a => a.IsParamsCollection)<= (memberInit.Expanded ? 1 : 0));

var args = EvaluateSideEffectingArgumentsToTemps(
memberInit.Arguments,
Expand DownExpand Up@@ -530,7 +530,6 @@ void addIndexes(ArrayBuilder<BoundExpression> result, BoundAssignmentOperator as
{
foreach (var argument in initializerMember.Arguments)
{
// PROTOTYPE(ParamsCollections): Do we need to do the same special case for collections other than arrays?
if (argument is BoundArrayCreation { IsParamsCollection: true, InitializerOpt: var initializers })
{
Debug.Assert(initializers is not null);
Expand DownExpand Up@@ -589,7 +588,7 @@ private ImmutableArray<BoundExpression> EvaluateSideEffectingArgumentsToTemps(

BoundExpression replacement;

if (arg.IsParamsCollection) // PROTOTYPE(ParamsCollections): Do we need to recreate the same special handling for collections other than arrays?
if (arg.IsParamsCollection)
{
// Capturing the array instead is going to lead to an observable behavior difference. Not just an IL difference,
// see Microsoft.CodeAnalysis.CSharp.UnitTests.CodeGen.ObjectAndCollectionInitializerTests.DictionaryInitializerTestSideeffects001param for example.
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp