-
Notifications
You must be signed in to change notification settings - Fork 4k
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Collection literals: address comments #68793
Collection literals: address comments #68793
Conversation
@@ -548,18 +548,13 @@ BoundExpression convertArrayElement(BoundExpression element, TypeSymbol elementT | |||
} | |||
|
|||
var implicitReceiver = new BoundObjectOrCollectionValuePlaceholder(syntax, isNewInstance: true, targetType) { WasCompilerGenerated = true }; | |||
// PROTOTYPE: When generating a List<T>, should we use the well-known |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added open issue to test plan #66418.
var collectionInitializerAddMethodBinder = this.WithAdditionalFlags(BinderFlags.CollectionInitializerAddMethod); | ||
var builder = ArrayBuilder<BoundExpression>.GetInstance(node.Elements.Length); | ||
foreach (var element in node.Elements) | ||
{ | ||
var result = element switch | ||
{ | ||
BoundBadExpression => element, | ||
// PROTOTYPE: Should spread elements support target type? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added open issue to test plan #66418.
@@ -1173,7 +1173,6 @@ static void Main() | |||
} | |||
} | |||
"""; | |||
// PROTOTYPE: Should compile and run successfully: expectedOutput: "[1, 2, 3], " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -1325,7 +1324,6 @@ static void Main() | |||
CompileAndVerify(new[] { source, s_collectionExtensions }, expectedOutput: "(System.Int32[]) [1, 2, 3], "); | |||
} | |||
|
|||
// PROTOTYPE: Test other variance cases. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -2087,10 +2207,6 @@ static void Main() | |||
} | |||
} | |||
"""; | |||
// PROTOTYPE: Confirm we should generate ListBase<int> instances for both x and y. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -4156,7 +4272,7 @@ static void Main() | |||
[ConditionalTheory(typeof(CoreClrOnly))] | |||
[CombinatorialData] | |||
public void SpreadElement_01( | |||
[CombinatorialValues("IEnumerable", "IEnumerable<int>", "int[]", "List<int>", "Span<int>", "ReadOnlySpan<int>")] string spreadType, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -4584,7 +4697,6 @@ static void Main() | |||
} | |||
"""; | |||
var comp = CreateCompilation(source); | |||
// PROTOTYPE: Should spread elements support target type? (Should we infer IEnumerable<int>?) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added open issue to test plan #66418.
@@ -4606,7 +4718,6 @@ static string[] Append(string a, string b, bool c) | |||
} | |||
} | |||
"""; | |||
// PROTOTYPE: Should spread elements support target type? (Should we infer IEnumerable<string>?) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added open issue to test plan #66418.
@@ -6303,33 +6441,5 @@ static async Task<T> F<T>(T t) | |||
"""; | |||
CompileAndVerify(new[] { source, s_collectionExtensions }, expectedOutput: "[3, 1, 2, 4], "); | |||
} | |||
|
|||
[ConditionalFact(typeof(CoreClrOnly), AlwaysSkip = "PROTOTYPE: 'IAsyncEnumerable<int>' does not contain a definition for 'GetAwaiter'")] | |||
public void Async_03() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added open issue to test plan #66418: support IAsyncEnumerable<T>
for spread element?
…nto collections-comments
@@ -5365,8 +5364,8 @@ public void CastVersusIndexAmbiguity24_B() | |||
[Fact] | |||
public void CastVersusIndexAmbiguity24_C() | |||
{ | |||
// PROTOTYPE: This is not a great diagnostic. Users could easily run into this and be confused. Can we do | |||
// better. For example: | |||
// This is not a great diagnostic. Users could easily run into this and be confused. Can we do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tracking issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This particular case involves a dictionary element which is not currently supported. I've logged an issue to improve the diagnostic for the previous example (A)[1]
: #68862.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One comment, otherwise LGTM
@@ -3836,7 +3836,6 @@ internal uint GetValEscape(BoundExpression expr, uint scopeOfTheContainingExpres | |||
return GetValEscape(switchExpr.SwitchArms.SelectAsArray(a => a.Value), scopeOfTheContainingExpression); | |||
|
|||
case BoundKind.CollectionLiteralExpression: | |||
// PROTOTYPE: Revisit if spans may be optimized to avoid heap allocation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a test plan #66418 item tracking this now.
…nto collections-comments
…nto collections-comments
Address PROTOTYPE comments.