Skip to content

Commit

Permalink
PROTOTYPE comments
Browse files Browse the repository at this point in the history
  • Loading branch information
cston committed Dec 10, 2024
1 parent 3f79290 commit 1fba2ac
Show file tree
Hide file tree
Showing 4 changed files with 239 additions and 7 deletions.
15 changes: 11 additions & 4 deletions src/Compilers/CSharp/Portable/Binder/Binder_Conversions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -932,12 +932,19 @@ private BoundCollectionExpression ConvertCollectionExpression(
}
else
{
if ((collectionTypeKind is CollectionExpressionTypeKind.ArrayInterface) ||
// Verify the existence of the well-known members that may be used in lowering, even
// though not all will be used for any particular collection expression. Checking all
// gives a consistent behavior, regardless of collection expression elements.
if (collectionTypeKind is CollectionExpressionTypeKind.DictionaryInterface)
{
_ = GetWellKnownTypeMember(WellKnownMember.System_Collections_Generic_Dictionary_KV__ctor, diagnostics, syntax: syntax);
_ = GetWellKnownTypeMember(WellKnownMember.System_Collections_Generic_Dictionary_KV__Add, diagnostics, syntax: syntax);
_ = GetWellKnownTypeMember(WellKnownMember.System_Collections_Generic_KeyValuePair_KV__get_Key, diagnostics, syntax: syntax);
_ = GetWellKnownTypeMember(WellKnownMember.System_Collections_Generic_KeyValuePair_KV__get_Value, diagnostics, syntax: syntax);
}
else if ((collectionTypeKind is CollectionExpressionTypeKind.ArrayInterface) ||
node.HasSpreadElements(out _, out _))
{
// Verify the existence of the List<T> members that may be used in lowering, even
// though not all will be used for any particular collection expression. Checking all
// gives a consistent behavior, regardless of collection expression elements.
_ = GetWellKnownTypeMember(WellKnownMember.System_Collections_Generic_List_T__ctor, diagnostics, syntax: syntax);
_ = GetWellKnownTypeMember(WellKnownMember.System_Collections_Generic_List_T__ctorInt32, diagnostics, syntax: syntax);
_ = GetWellKnownTypeMember(WellKnownMember.System_Collections_Generic_List_T__Add, diagnostics, syntax: syntax);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1714,7 +1714,6 @@ static bool isDictionaryInterface(CSharpCompilation compilation, TypeSymbol targ
(ReferenceEquals(namedType.OriginalDefinition, compilation.GetWellKnownType(WellKnownType.System_Collections_Generic_IDictionary_KV)) ||
ReferenceEquals(namedType.OriginalDefinition, compilation.GetWellKnownType(WellKnownType.System_Collections_Generic_IReadOnlyDictionary_KV))))
{
// PROTOTYPE: Test with missing KeyValuePair<,>.
elementType = TypeWithAnnotations.Create(compilation.GetWellKnownType(WellKnownType.System_Collections_Generic_KeyValuePair_KV).
Construct(namedType.TypeArgumentsWithAnnotationsNoUseSiteDiagnostics));
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1274,7 +1274,6 @@ private BoundExpression CreateAndPopulateDictionary(BoundCollectionExpression no
BoundLocal expressionTemp = _factory.StoreToTemp(VisitExpression(expression), out assignmentToTemp);
localsBuilder.Add(expressionTemp);
sideEffects.Add(assignmentToTemp);
// PROTOTYPE: Test with missing members. Presumably, these members should be checked in initial binding.
var getKeyMethod = ((MethodSymbol)_factory.WellKnownMember(WellKnownMember.System_Collections_Generic_KeyValuePair_KV__get_Key)).AsMember(sourceType);
var getValueMethod = ((MethodSymbol)_factory.WellKnownMember(WellKnownMember.System_Collections_Generic_KeyValuePair_KV__get_Value)).AsMember(sourceType);
return (_factory.Convert(addMethod.Parameters[0].Type, _factory.Call(expressionTemp, getKeyMethod)),
Expand Down
Loading

0 comments on commit 1fba2ac

Please sign in to comment.