diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Issue3909.cs b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Issue3909.cs index 5bc5a4b75..8d8284974 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Issue3909.cs +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Issue3909.cs @@ -222,5 +222,28 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty return null; } } +#if CS130 + public class BaseWithAllowsRefStruct + { + public virtual void Annotated(T? value) where T : allows ref struct + { + } + + public virtual void Plain(T value) where T : allows ref struct + { + } + } + + public class DerivedWithAllowsRefStruct : BaseWithAllowsRefStruct + { + public override void Annotated(T? value) where T : default + { + } + + public override void Plain(T value) + { + } + } +#endif } } diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/TypeSystemAstBuilder.cs b/ICSharpCode.Decompiler/CSharp/Syntax/TypeSystemAstBuilder.cs index dc2d2f955..a1e99ea6c 100644 --- a/ICSharpCode.Decompiler/CSharp/Syntax/TypeSystemAstBuilder.cs +++ b/ICSharpCode.Decompiler/CSharp/Syntax/TypeSystemAstBuilder.cs @@ -2619,6 +2619,9 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax // metadata, so which disambiguator is legal follows from them without resolving the base // member. The restated disambiguator leaves no metadata trace of its own, hence it must be // derived rather than read back. + // The clause is built here rather than through ConvertTypeParameterConstraint, which also + // prints 'allows ref struct' from the byreflike flag. That flag is re-emitted on the + // override's own type parameter as well, and restating it is CS0460. void AddNullabilityDisambiguatingConstraints(MethodDeclaration decl, IMethod method) { if (method.TypeParameters.Count == 0)