-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Open
Labels
Area-CompilersConcept-Design DebtEngineering Debt, Design Debt, or poor product code qualityEngineering Debt, Design Debt, or poor product code quality
Milestone
Description
After annotating MethodTypeInferrer._compilation
, it became clear that one of the usage sites is not prepared to deal with null
, which could lead to a null
dereference.
In practice, I don't think this is reachable at the moment, because a null
compilation is used when reducing extension methods and new extension members, and I don't think a function type could contribute to the inference in such a case. But we should confirm and strengthen this code.
bool fromFunctionType = false;
if (isFunctionType(best, out var functionType))
{
// Realize the type as TDelegate, or Expression<TDelegate> if the type parameter
// is constrained to System.Linq.Expressions.Expression.
var resultType = functionType.GetInternalDelegateType();
if (hasExpressionTypeConstraint(typeParameter))
{
var expressionOfTType = compilation.GetWellKnownType(WellKnownType.System_Linq_Expressions_Expression_T);
resultType = expressionOfTType.Construct(resultType);
}
best = TypeWithAnnotations.Create(resultType, best.NullableAnnotation);
fromFunctionType = true;
}
Found in #80659
Metadata
Metadata
Assignees
Labels
Area-CompilersConcept-Design DebtEngineering Debt, Design Debt, or poor product code qualityEngineering Debt, Design Debt, or poor product code quality