-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Labels
Area-CompilersBugFeature - Native IntFeature - Nullable Reference TypesNullable Reference TypesNullable Reference Types
Milestone
Description
A couple of recent PRs have changed MetadataWriter to accommodate type references that differ only by nullability: #38249 and #45714.
Since nullability is not persisted as part of the type reference, an alternative suggested by @AlekseyTs to changing MetadataWriter might be to hide nullability differences in PEModuleBuilder.Translate().
For instance, the following change to PEModuleBuilder.Translate() seems to work as an alternative to #45714.
internal Cci.INamedTypeReference Translate(
NamedTypeSymbol namedTypeSymbol,
SyntaxNode syntaxNodeOpt,
DiagnosticBag diagnostics,
bool fromImplements = false,
bool needDeclaration = false)
{
Debug.Assert(namedTypeSymbol.IsDefinitionOrDistinct());
Debug.Assert(diagnostics != null);
// If the only differences between the type and OriginalDefinition is nullability, use
// OriginalDefinition because nullability is not persisted as part of the type reference.
if (!namedTypeSymbol.IsDefinition)
{
var definition = namedTypeSymbol.OriginalDefinition;
if (namedTypeSymbol.Equals(definition, TypeCompareKind.AllNullableIgnoreOptions))
{
namedTypeSymbol = definition;
}
}
// ...See also related issue #40271 translating native integers.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Area-CompilersBugFeature - Native IntFeature - Nullable Reference TypesNullable Reference TypesNullable Reference Types