-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Open
Labels
Area-CompilersConcept-Design DebtEngineering Debt, Design Debt, or poor product code qualityEngineering Debt, Design Debt, or poor product code quality
Milestone
Description
In some error scenarios (bad overrides) we set the type of the property a second time.
The problem is that the first type matters (it causes side-effects) which are not undone when the type is set the second time.
See the constructor for SourcePropertySymbol:
// We do an extra check before copying the type to handle the case where the overriding
// property (incorrectly) has a different type than the overridden property. In such cases,
// we want to retain the original (incorrect) type to avoid hiding the type given in source.
if (type.Type.Equals(overriddenPropertyType.Type, TypeCompareKind.IgnoreCustomModifiersAndArraySizesAndLowerBounds | TypeCompareKind.IgnoreNullableModifiersForReferenceTypes | TypeCompareKind.IgnoreDynamic))
{
type = type.WithTypeAndModifiers(
CustomModifierUtils.CopyTypeCustomModifiers(overriddenPropertyType.Type, type.Type, this.ContainingAssembly),
overriddenPropertyType.CustomModifiers);
// Although we only do this in error scenarios, it is undesirable to mutate the symbol by setting its type twice.
// Tracked by https://github.com/dotnet/roslyn/issues/35381
Interlocked.Exchange(ref _lazyType, null);
Interlocked.CompareExchange(ref _lazyType, new StrongBox<TypeWithAnnotations>(type), null);
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Area-CompilersConcept-Design DebtEngineering Debt, Design Debt, or poor product code qualityEngineering Debt, Design Debt, or poor product code quality