Browse Source

Fix assertion: UnknownType for unresolved reference can still be nullable; only the SpecialType.Unknown cannot.

pull/2993/head
Daniel Grunwald 2 years ago
parent
commit
94ee5ed216
  1. 1
      ICSharpCode.Decompiler/TypeSystem/Implementation/NullabilityAnnotatedType.cs
  2. 2
      ICSharpCode.Decompiler/TypeSystem/Implementation/UnknownType.cs

1
ICSharpCode.Decompiler/TypeSystem/Implementation/NullabilityAnnotatedType.cs

@ -20,6 +20,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -20,6 +20,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
// the NullabilityAnnotatedType wrapper only in some limited places.
Debug.Assert(type is ITypeDefinition { IsReferenceType: not false }
|| type.Kind == TypeKind.Dynamic
|| type.Kind == TypeKind.Unknown
|| (type is ITypeParameter && this is ITypeParameter));
this.nullability = nullability;
}

2
ICSharpCode.Decompiler/TypeSystem/Implementation/UnknownType.cs

@ -107,7 +107,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -107,7 +107,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
public override IType ChangeNullability(Nullability nullability)
{
if (nullability == Nullability.Oblivious)
if (nullability == Nullability.Oblivious || isReferenceType == false)
return this;
else
return new NullabilityAnnotatedType(this, nullability);

Loading…
Cancel
Save