You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// <para>This type assists with nullable reinference of generic types used in expressions.</para>
8372
+
///
8373
+
/// <para>
8374
+
/// "Type argument inference" is the step we do during initial binding,
8375
+
/// when producing the bound tree used as input to nullable analysis, lowering, and a bunch of other steps.
8376
+
/// This inference is flow-independent, so, an expression used at any point in a method,
8377
+
/// would get the same type arguments for the calls in it, assuming the stuff the expression is using is still in scope.
8378
+
/// </para>
8379
+
///
8380
+
/// <para>
8381
+
/// "Reinference" is done during nullable analysis, in order to enrich the results of
8382
+
/// the initial type argument inference, based on the flow state of expressions at the particular point of usage.
8383
+
/// </para>
8384
+
///
8385
+
/// <para>What it comes down to is scenarios like the following:</para>
8386
+
///
8387
+
/// <code>
8388
+
/// var str = GetStringOrNull();
8389
+
///
8390
+
/// var arr1 = ImmutableArray.Create(str);
8391
+
/// arr1[0].ToString(); // warning: possible null dereference
8392
+
///
8393
+
/// if (str == null)
8394
+
/// return;
8395
+
///
8396
+
/// var arr2 = ImmutableArray.Create(str);
8397
+
/// arr2[0].ToString(); // ok
8398
+
/// </code>
8399
+
///
8400
+
/// <para>
8401
+
/// For both calls to ImmutableArray.Create, initial binding will do a flow-independent type argument inference,
8402
+
/// and both will receive type argument `string` (oblivious).
8403
+
/// </para>
8404
+
///
8405
+
/// <para>
8406
+
/// During nullable analysis, we will do a reinference of the call. The first call will get type argument `string?`.
8407
+
/// The second call will get type argument `string` (non-nullable), based on the flow state of `str` at that point.
8408
+
/// That needs to propagate to the next points in the control flow and be surfaced in public API for the types of the expressions and so on.
8409
+
/// </para>
8410
+
///
8411
+
/// <para>
8412
+
/// Reinference needs to be done on pretty much any expression which can represent a usage of either a generic method or a member of a generic type.
8413
+
/// That ends up including calls (obviously) but also things like binary/unary operators, compound assignments, foreach statements, await-exprs, collection expression elements and so on.
8414
+
/// </para>
8415
+
/// </remarks>
8335
8416
private sealed class MethodInferenceExtensions : MethodTypeInferrer.Extensions
@@ -48776,7 +48896,6 @@ public int Property { set { } }
48776
48896
}
48777
48897
""";
48778
48898
48779
-
// Tracked by https://github.com/dotnet/roslyn/issues/78828 : incorrect nullability analysis for with-expression with extension property (unexpected warning)
48780
48899
var comp = CreateCompilation(src);
48781
48900
comp.VerifyEmitDiagnostics(
48782
48901
// (4,5): warning CS8602: Dereference of a possibly null reference.
@@ -48806,7 +48925,7 @@ public int Property { set { } }
48806
48925
}
48807
48926
}
48808
48927
""";
48809
-
// Tracked by https://github.com/dotnet/roslyn/issues/78828 : unexpected nullability warning
48928
+
48810
48929
var comp = CreateCompilation(src);
48811
48930
comp.VerifyEmitDiagnostics(
48812
48931
// (4,5): warning CS8602: Dereference of a possibly null reference.
@@ -48844,6 +48963,79 @@ public int Property { set { } }
0 commit comments