Skip to content

Conversation

@AlekseyTs
Copy link
Contributor

No description provided.

@AlekseyTs AlekseyTs requested review from a team as code owners December 8, 2025 23:51
@dotnet-policy-service dotnet-policy-service bot added the Needs API Review Needs to be reviewed by the API review council label Dec 8, 2025
@dotnet-policy-service
Copy link
Contributor

This PR modifies public API files. Please follow the instructions at https://github.com/dotnet/roslyn/blob/main/docs/contributing/API%20Review%20Process.md for ensuring all public APIs are reviewed before merging.

@AlekseyTs
Copy link
Contributor Author

@RikkiGibson, @333fred, @dotnet/roslyn-compiler Please review

object System.Runtime.CompilerServices.IUnion.Value => throw null;
public static explicit operator S1(int x)
{
Copy link
Contributor Author

@AlekseyTs AlekseyTs Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{

Use throw body for clarity. #Closed

Copy link
Member

@333fred 333fred left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only a couple of small comments.

Microsoft.CodeAnalysis.CSharp.ForEachStatementInfo.MoveNextAwaitableInfo.get -> Microsoft.CodeAnalysis.CSharp.AwaitExpressionInfo
static Microsoft.CodeAnalysis.CSharp.CSharpExtensions.GetAwaitExpressionInfo(this Microsoft.CodeAnalysis.SemanticModel? semanticModel, Microsoft.CodeAnalysis.CSharp.Syntax.LocalDeclarationStatementSyntax! awaitUsingDeclaration) -> Microsoft.CodeAnalysis.CSharp.AwaitExpressionInfo
static Microsoft.CodeAnalysis.CSharp.CSharpExtensions.GetAwaitExpressionInfo(this Microsoft.CodeAnalysis.SemanticModel? semanticModel, Microsoft.CodeAnalysis.CSharp.Syntax.UsingStatementSyntax! awaitUsingStatement) -> Microsoft.CodeAnalysis.CSharp.AwaitExpressionInfo

Copy link
Member

@333fred 333fred Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
``` #WontFix

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The empty line is intentional. It makes it easy to deal with merges between branches

Comment on lines +3511 to +3516
// PROTOTYPE: The errors are coming from an attempt to classify Union conversion during overload resolution.
// Is there a relatively easy way to avoid reporting them? Perhaps that can be done if we limit Union
// types to structs only. This way we can expect all interfaces to be explicitly listed on the struct.
// IUnion cannot be implemented indirectly, i.e. by listing only a derived interface, or inheriting
// from a base implementing it. Therefore, we could rely on InterfacesNoUseSiteDiagnostics instead of
// AllInterfacesWithDefinitionUseSiteDiagnostics to check whether IUnion is among implemented interfaces.
Copy link
Member

@333fred 333fred Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My 2cents is that these won't be common enough to warrant concern about in general. There may be other good reasons to limit, but avoiding these diagnostics isn't one of them. #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My 2cents is that these won't be common enough to warrant concern about in general.

It is not clear what exactly you find uncommon. I think this kind of break to existing code might be common, because we will start reporting errors about interfaces that we never were interested in before.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't assume that the break will be limited to list pattern scenarios. This is just an example of an impact from examining interfaces in scenarios where we didn't do that before.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specifically, the additional missing assemblies errors. It's certainly possible that there is more direct fallout that has bad behavior, but the additional errors, specifically, are not concerning to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but the additional errors, specifically, are not concerning to me.

I do not consider additional errors as breaking. In this specific scenario, for example, they are the only errors. There were no errors before we started checking for Union conversions.

@AlekseyTs AlekseyTs requested a review from 333fred December 9, 2025 20:19
@AlekseyTs
Copy link
Contributor Author

@RikkiGibson, @dotnet/roslyn-compiler For a second review

@AlekseyTs AlekseyTs requested a review from a team December 9, 2025 22:23
Copy link
Member

@RikkiGibson RikkiGibson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, comments are not blocking.

return Conversion.NoConversion;
}

// SPEC: Find the set of applicable constructors
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


// Don't need to worry about checked user-defined operators
Debug.Assert(!conversion.IsUserDefined || result == ConstantValue.False || result == ConstantValue.Bad);
Debug.Assert((!conversion.IsUserDefined && !conversion.IsUnion) || result == ConstantValue.False || result == ConstantValue.Bad);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are checked together a lot, it might be helpful to declare property IsUserDefinedOrUnion to use in these places

@AlekseyTs AlekseyTs merged commit 55514f4 into dotnet:features/Unions Dec 11, 2025
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-Compilers Feature - Unions Needs API Review Needs to be reviewed by the API review council

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants