C#: Do not assume that extension methods on nullable types do unsafe dereference.

This commit is contained in:
Michael Nebel
2025-05-27 13:29:43 +02:00
parent 0355ea8733
commit 36eab47ab4

View File

@@ -544,8 +544,13 @@ class Dereference extends G::DereferenceableExpr {
p.hasExtensionMethodModifier() and
not emc.isConditional()
|
p.fromSource() // assume all non-source extension methods perform a dereference
implies
// Assume all non-source extension methods on
// (1) nullable types are null-safe
// (2) non-nullable types are doing a dereference.
p.fromLibrary() and
not p.getAnnotatedType().isNullableRefType()
or
p.fromSource() and
exists(
Ssa::ImplicitParameterDefinition def,
AssignableDefinitions::ImplicitParameterDefinition pdef