Skip to content

Fix #3180: avoid invalid null-conditional extension calls - #4220

Merged
siegfriedpammer merged 2 commits into
masterfrom
fix/3180-nullprop-extension-method
Oct 7, 2026
Merged

siegfriedpammer merged 2 commits into
masterfrom
fix/3180-nullprop-extension-method

Conversation

@siegfriedpammer

Copy link
Copy Markdown
Member

Summary

  • prevent null propagation from emitting extension-method syntax unless the specific receiver and argument types bind back to the same method
  • reject extension syntax when normal member lookup finds a non-method member with the same name
  • add a pretty-test case covering the invalid ?.Count() rewrite

Tests

  • OPENSSL_ENABLE_SHA1_SIGNATURES=1 dotnet test --project ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj --filter "FullyQualifiedName~PrettyTestRunner.ExtensionMethods" --report-trx

Assisted-by: OpenCode:openai/gpt-5.5:OpenCode

Null propagation must not render an extension-method conditional access when normal member lookup would bind to a non-method member, because that produces invalid C# for ambiguous Count-style cases.

Assisted-by: OpenCode:openai/gpt-5.5:OpenCode
Avoid reusing a temporary receiver's stored value for extension-method lookup when its inferred source type no longer matches the local type.

Assisted-by: OpenCode:openai/gpt-5.5:OpenCode
@siegfriedpammer
siegfriedpammer merged commit accbd3e into master Oct 7, 2026
17 checks passed
@siegfriedpammer
siegfriedpammer deleted the fix/3180-nullprop-extension-method branch October 7, 2026 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant