Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SynthesizedReadOnlyListTypeSymbol.Create - Check for MissingMetadataTypeSymbol #71330

Merged
merged 4 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ internal static NamedTypeSymbol Create(SourceModuleSymbol containingModule, stri
DiagnosticInfo? diagnosticInfo = null;

var hasReadOnlyInterfaces =
!compilation.IsTypeMissing(SpecialType.System_Collections_Generic_IReadOnlyCollection_T)
&& !compilation.IsTypeMissing(SpecialType.System_Collections_Generic_IReadOnlyList_T);
compilation.GetSpecialType(SpecialType.System_Collections_Generic_IReadOnlyCollection_T) is not MissingMetadataTypeSymbol &&
Copy link
Contributor

@AlekseyTs AlekseyTs Dec 18, 2023

Choose a reason for hiding this comment

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

compilation.GetSpecialType(SpecialType.System_Collections_Generic_IReadOnlyCollection_T) is not MissingMetadataTypeSymbol &&

It looks like we are fixing a real bug, but not adding any unit-tests. I think we should add a unit-test that makes the problem observable. I.e. a test that fails without the fix. #Closed

compilation.GetSpecialType(SpecialType.System_Collections_Generic_IReadOnlyList_T) is not MissingMetadataTypeSymbol;

foreach (var type in s_requiredSpecialTypes)
{
Expand Down
8 changes: 4 additions & 4 deletions src/Compilers/Core/Portable/Compilation/Compilation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3657,12 +3657,12 @@ internal void MakeMemberMissing(SpecialMember member)
MakeMemberMissing(-(int)member - 1);
}

internal bool IsMemberMissing(WellKnownMember member)
private protected bool IsMemberMissing(WellKnownMember member)
{
return IsMemberMissing((int)member);
}

internal bool IsMemberMissing(SpecialMember member)
private protected bool IsMemberMissing(SpecialMember member)
{
return IsMemberMissing(-(int)member - 1);
}
Expand Down Expand Up @@ -3702,12 +3702,12 @@ private void MakeTypeMissing(int type)
_lazyMakeWellKnownTypeMissingMap[(int)type] = true;
}

internal bool IsTypeMissing(SpecialType type)
private protected bool IsTypeMissing(SpecialType type)
{
return IsTypeMissing((int)type);
}

internal bool IsTypeMissing(WellKnownType type)
private protected bool IsTypeMissing(WellKnownType type)
{
return IsTypeMissing((int)type);
}
Expand Down
Loading