-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
List-patterns: add a few tests and add HasValidate flag #57914
Changes from 8 commits
e033f3b
ea9f5d6
36b4917
9695eae
5eeebe4
3ed14b9
b6d1139
4398672
9135c4a
88e4503
ccb7dea
92622a0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -238,7 +238,6 @@ private BoundPattern BindSlicePattern( | |
pattern = BindPattern(node.Pattern, sliceType, GetValEscape(sliceType, inputValEscape), permitDesignations, hasErrors, diagnostics); | ||
} | ||
|
||
Debug.Assert(GetIndexerOrImplicitIndexerSymbol(indexerAccess) is var _); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
return new BoundSlicePattern(node, pattern, indexerAccess, receiverPlaceholder, argumentPlaceholder, inputType: inputType, narrowedType: inputType, hasErrors); | ||
} | ||
|
||
|
@@ -317,7 +316,6 @@ private BoundListPattern BindListPattern( | |
inputValEscape, permitDesignations, typeSyntax: null, diagnostics, ref hasErrors, | ||
out Symbol? variableSymbol, out BoundExpression? variableAccess); | ||
|
||
Debug.Assert(GetIndexerOrImplicitIndexerSymbol(indexerAccess) is var _); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
return new BoundListPattern( | ||
syntax: node, subpatterns: subpatterns, hasSlice: sawSlice, lengthAccess: lengthAccess, | ||
indexerAccess: indexerAccess, receiverPlaceholder, argumentPlaceholder, variable: variableSymbol, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -108,6 +108,11 @@ public override bool IsEquivalentTo(BoundDagEvaluation obj) | |
return base.IsEquivalentTo(obj) && | ||
this.Index == ((BoundDagIndexerEvaluation)obj).Index; | ||
} | ||
|
||
private partial void Validate() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
{ | ||
Debug.Assert(IndexerAccess is BoundIndexerAccess or BoundImplicitIndexerAccess or BoundArrayAccess); | ||
} | ||
} | ||
|
||
partial class BoundDagSliceEvaluation | ||
|
@@ -119,6 +124,11 @@ public override bool IsEquivalentTo(BoundDagEvaluation obj) | |
(BoundDagSliceEvaluation)obj is var e && | ||
this.StartIndex == e.StartIndex && this.EndIndex == e.EndIndex; | ||
} | ||
|
||
private partial void Validate() | ||
{ | ||
Debug.Assert(IndexerAccess is BoundIndexerAccess or BoundImplicitIndexerAccess or BoundArrayAccess); | ||
} | ||
} | ||
|
||
partial class BoundDagAssignmentEvaluation | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,5 +29,11 @@ internal BoundExpression GetReceiver() | |
Debug.Assert(receiver is not null); | ||
return receiver; | ||
} | ||
|
||
private partial void Validate() | ||
{ | ||
Debug.Assert(LengthOrCountAccess is BoundPropertyAccess or BoundLocal or BoundBadExpression); | ||
Debug.Assert(IndexerOrSliceAccess is BoundIndexerAccess or BoundCall or BoundArrayAccess or BoundBadExpression); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System.Diagnostics; | ||
|
||
namespace Microsoft.CodeAnalysis.CSharp | ||
{ | ||
internal partial class BoundListPattern | ||
{ | ||
private partial void Validate() | ||
{ | ||
Debug.Assert(LengthAccess is null or BoundPropertyAccess or BoundBadExpression); | ||
Debug.Assert(IndexerAccess is BoundIndexerAccess or BoundImplicitIndexerAccess or BoundArrayAccess or BoundBadExpression or BoundDynamicIndexerAccess); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
Debug.Assert(Binder.GetIndexerOrImplicitIndexerSymbol(IndexerAccess) is var _); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System.Diagnostics; | ||
|
||
namespace Microsoft.CodeAnalysis.CSharp | ||
{ | ||
internal partial class BoundSlicePattern | ||
{ | ||
private partial void Validate() | ||
{ | ||
Debug.Assert(IndexerAccess is BoundIndexerAccess or BoundImplicitIndexerAccess or BoundArrayAccess or BoundBadExpression or BoundDynamicIndexerAccess); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can it be null? #Closed |
||
Debug.Assert(Binder.GetIndexerOrImplicitIndexerSymbol(IndexerAccess) is var _); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
@jcouv is this something we expect to be useful on an ongoing basis? should we do something like flip the existing TODO comments over to TODO2 and change this to prevent introduction of new TODO comments to main?
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.
I don't think we can do much about existing TODO comments. I've been using TODO2 comments to track things within a PR and having this helps me ensure I don't let any into the main branch or feature branches.