C#: Improved extraction of type nullability

This commit is contained in:
Tom Hvitved
2021-01-14 11:21:55 +01:00
parent 81ce29c6c8
commit 9a9a57716c
38 changed files with 147 additions and 176 deletions

View File

@@ -85,14 +85,14 @@ namespace Semmle.Extraction.CSharp.Entities
Context.PopulateLater(() =>
{
var loc = Context.Create(initializer.GetLocation());
var annotatedType = new AnnotatedType(type, NullableAnnotation.None);
var annotatedType = AnnotatedTypeSymbol.CreateNotAnnotated(symbol.Type);
var simpleAssignExpr = new Expression(new ExpressionInfo(Context, annotatedType, loc, ExprKind.SIMPLE_ASSIGN, this, child++, false, null));
Expression.CreateFromNode(new ExpressionNodeInfo(Context, initializer.Value, simpleAssignExpr, 0));
var access = new Expression(new ExpressionInfo(Context, annotatedType, Location, ExprKind.PROPERTY_ACCESS, simpleAssignExpr, 1, false, null));
trapFile.expr_access(access, this);
if (!symbol.IsStatic)
{
This.CreateImplicit(Context, Type.Create(Context, symbol.ContainingType), Location, access, -1);
This.CreateImplicit(Context, symbol.ContainingType, Location, access, -1);
}
});
}