Skip to content

FlatExpression: add SE-mirroring type-inferring factory overloads#514

Draft
Copilot wants to merge 2 commits intocopilot/data-oriented-expression-optimizationfrom
copilot/sub-pr-511
Draft

FlatExpression: add SE-mirroring type-inferring factory overloads#514
Copilot wants to merge 2 commits intocopilot/data-oriented-expression-optimizationfrom
copilot/sub-pr-511

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 13, 2026

ExpressionTree factory methods required an explicit Type argument everywhere, making it impossible to swap Expression.Add(a, b) for tree.Add(a, b) without callers threading types manually.

Changes

  • Type-inferring arithmetic overloadsAdd, Subtract, Multiply, Divide, Modulo infer result type from the left operand (NodeAt(left).Type); explicit-type overloads preserved
  • Type-inferring unary/assignNegate(operand) infers from operand; Assign(target, value) infers from target
  • Generic Binary without explicit typeBinary(nodeType, left, right) infers from left; explicit-type variant unchanged
  • Missing comparison helpersNotEqual, LessThan, LessThanOrEqual, GreaterThan, GreaterThanOrEqualtypeof(bool); AndAlso, OrElse → infer from left (matches SE behaviour for user-defined operators; for bool operands the inferred type is already bool)
var tree = default(ExpressionTree);
var px = tree.Parameter(typeof(int), "x");
var py = tree.Parameter(typeof(int), "y");

// Before: explicit Type required everywhere
var add = tree.Add(px, py, typeof(int));

// After: mirrors Expression.Add(px, py) — type inferred from left operand
var add = tree.Add(px, py);
var lt  = tree.LessThan(px, py);   // returns bool, no type arg needed

Copilot AI changed the title [WIP] Explore data-oriented flat expression tree implementation FlatExpression: add SE-mirroring type-inferring factory overloads Apr 13, 2026
Copilot AI requested a review from dadhi April 13, 2026 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants