mirror of
https://github.com/github/codeql.git
synced 2026-04-25 00:35:20 +02:00
C#: When creating conditionally accessed expressions, use the typeinfo from the conditional expression to ensure correct flow state and type nullability.
This commit is contained in:
@@ -292,7 +292,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
protected Expression(ExpressionNodeInfo info)
|
||||
: base(info)
|
||||
{
|
||||
Syntax = (SyntaxNode)info.Node;
|
||||
Syntax = (SyntaxNode)info.Node;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -374,7 +374,8 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
public bool IsCompilerGenerated { get; }
|
||||
public string ExprValue { get; }
|
||||
|
||||
public ExpressionInfo(Context cx, AnnotatedType type, Extraction.Entities.Location location, ExprKind kind, IExpressionParentEntity parent, int child, bool isCompilerGenerated, string value)
|
||||
public ExpressionInfo(Context cx, AnnotatedType type, Extraction.Entities.Location location, ExprKind kind,
|
||||
IExpressionParentEntity parent, int child, bool isCompilerGenerated, string value)
|
||||
{
|
||||
Context = cx;
|
||||
Type = type;
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
public static Expression Create(ExpressionNodeInfo info, ConditionalAccessExpressionSyntax node) =>
|
||||
// The qualifier is located by walking the syntax tree.
|
||||
// `node.WhenNotNull` will contain a MemberBindingExpressionSyntax, calling the method below.
|
||||
Create(info.Context, node.WhenNotNull, info.Parent, info.Child);
|
||||
CreateFromNode(new ExpressionNodeInfo(info.Context, node.WhenNotNull, info.Parent, info.Child, info.TypeInfo));
|
||||
|
||||
public static Expression Create(ExpressionNodeInfo info, MemberBindingExpressionSyntax node)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user