Browse Source

Subtituting `T!` with `T=string` where the caller is in null-oblivious code now results in oblivious `string` instead of `string!`.

pull/1730/head
Daniel Grunwald 6 years ago
parent
commit
e158ef45c5
  1. 17
      ICSharpCode.Decompiler/TypeSystem/TypeParameterSubstitution.cs

17
ICSharpCode.Decompiler/TypeSystem/TypeParameterSubstitution.cs

@ -18,6 +18,7 @@ @@ -18,6 +18,7 @@
using System.Collections.Generic;
using System.Text;
using ICSharpCode.Decompiler.TypeSystem.Implementation;
namespace ICSharpCode.Decompiler.TypeSystem
{
@ -186,7 +187,21 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -186,7 +187,21 @@ namespace ICSharpCode.Decompiler.TypeSystem
return base.VisitTypeParameter(type);
}
}
public override IType VisitNullabilityAnnotatedType(NullabilityAnnotatedType type)
{
if (type is NullabilityAnnotatedTypeParameter tp) {
if (tp.Nullability == Nullability.Nullable) {
return VisitTypeParameter(tp).ChangeNullability(Nullability.Nullable);
} else {
// T! substituted with T=oblivious string should result in oblivious string
return VisitTypeParameter(tp);
}
} else {
return base.VisitNullabilityAnnotatedType(type);
}
}
public override string ToString()
{
StringBuilder b = new StringBuilder();

Loading…
Cancel
Save