Use 'checked' names for synthesized vb intrinsic operators#63604
Use 'checked' names for synthesized vb intrinsic operators#63604CyrusNajmabadi merged 19 commits intodotnet:mainfrom
Conversation
src/Compilers/VisualBasic/Test/Semantic/Semantics/UnaryOperators.vb
Outdated
Show resolved
Hide resolved
src/Compilers/CSharp/Portable/Compilation/CSharpSemanticModel.cs
Outdated
Show resolved
Hide resolved
|
|
||
| public SynthesizedIntrinsicOperatorSymbol(TypeSymbol leftType, string name, TypeSymbol rightType, TypeSymbol returnType, bool isCheckedBuiltin) | ||
| { | ||
| Debug.Assert(SyntaxFacts.IsCheckedOperator(name) == isCheckedBuiltin); |
There was a problem hiding this comment.
hrmm... that surprises me. The way we get the name at the callsite is to feed this same boolean into the helper that produces the name. So i would expect these to match.
There was a problem hiding this comment.
basically, teh caller does this:
symbols = ImmutableArray.Create<Symbol>(new SynthesizedIntrinsicOperatorSymbol(objectType,
OperatorFacts.BinaryOperatorNameFromOperatorKind(op, isChecked: binaryOperator.OperatorKind.IsChecked()),
objectType,
binaryOperator.Type,
binaryOperator.OperatorKind.IsChecked()));(or the unary equivalent). So the same binaryOperator.OperatorKind.IsChecked() feeds into determining the name and passing the isCheckedBuiltIn flag through.
We could even consider not passing the boolean in and just determining it from the name if that works for you.
There was a problem hiding this comment.
We could even consider not passing the boolean in and just determining it from the name if that works for you.
Yes, that would work
There was a problem hiding this comment.
Done.
Note: tehre was an interesting change here (but as this only affects tehse 'ide' symbols i think it's fine). Specifically, it used to be possible to get 'IsCheckedBuiltin=true' methods even for a non-checked method name. This would happen with virtually all dynamic operators, even for operators that have no checked version.
Now, by using hte name, the checked-ness or not is based only on the name alone. This led to some changes in test behavior, but i think it's acceptable/appropriate.
|
|
||
| default: | ||
| expectChecked = type.IsDynamic(); | ||
| break; |
There was a problem hiding this comment.
now, no other op-types ever expect to be checked.
|
|
||
| default: | ||
| isChecked = isDynamic; | ||
| break; |
There was a problem hiding this comment.
now, no other op-types ever expect to be checked.
| var symbols2 = (from node2 in nodes select (IMethodSymbol)semanticModel.GetSymbolInfo(node2).Symbol).ToArray(); | ||
| foreach (var symbol2 in symbols2) | ||
| { | ||
| Assert.False(symbol2.IsCheckedBuiltin); |
There was a problem hiding this comment.
these equality operator methods are not checked anymore.
|
|
||
| for (int i = 0; i < symbols1.Length; i++) | ||
| { | ||
| Assert.Equal(symbols1[i], symbols2[i]); |
There was a problem hiding this comment.
because they're not checked, they are equal to the non-checked versions always.
| void Test(dynamic x) | ||
| { | ||
| var z1 = x + 0; | ||
| var z2 = 0 + x; |
There was a problem hiding this comment.
i added this new test with dynamic and operators to show where 'checked' might actually appear.
src/Compilers/CSharp/Portable/Symbols/Synthesized/SynthesizedIntrinsicOperatorSymbol.cs
Outdated
Show resolved
Hide resolved
src/Compilers/CSharp/Portable/Symbols/Synthesized/SynthesizedIntrinsicOperatorSymbol.cs
Outdated
Show resolved
Hide resolved
Let's make it a calculated property, name is available. In reply to: 1228555745 Refers to: src/Compilers/VisualBasic/Portable/Symbols/SynthesizedSymbols/SynthesizedIntrinsicOperatorSymbol.vb:168 in 7823890. [](commit_id = 7823890, deletion_comment = False) |
It looks like this condition can be removed now. In reply to: 1228557421 Refers to: src/Compilers/VisualBasic/Portable/Symbols/SynthesizedSymbols/SynthesizedIntrinsicOperatorSymbol.vb:78 in 7823890. [](commit_id = 7823890, deletion_comment = False) |
|
Done with review pass (commit 17) |
|
@AlekseyTs ptal when you have time :) |
AlekseyTs
left a comment
There was a problem hiding this comment.
LGTM (commit 19).Please squash commits in the process of merging.
Will do. |
…perators for the target language. Also ensure SymbolDisplay for VB can handle symbols for VB checked built-in operators after the recent change in dotnet#63604. This fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1615080.
…perators for the target language. (#64109) Also ensure SymbolDisplay for VB can handle symbols for VB checked built-in operators after the recent change in #63604. This fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1615080.
This brings VB in line with C#, which is nice for consistency, and helps the effort to add an API to generate intrinsic operators from a compilation (#63186)
Draft to see what breaks.