private AstExpression InferTypeGenericExpr(AstGenericExpr expr, CheezType expected, TypeInferenceContext context) { foreach (var param in expr.Parameters) { param.Scope = expr.Scope; param.TypeExpr.AttachTo(expr); param.TypeExpr = InferTypeHelper(param.TypeExpr, null, context); param.Type = param.TypeExpr.Value as CheezType; if (!ValidatePolymorphicParameterType(param.Location, param.Type)) { return(expr); } } expr.Type = new GenericType(expr); expr.Value = new PolyValue("generic"); return(expr); }
private AstExpression CallGenericExpr(AstGenericExpr expr, List <(int index, CheezType type, object value)> args, ILocation location = null)
public GenericType(AstGenericExpr expr) { Expression = expr; }
public virtual ReturnType VisitGenericExpr(AstGenericExpr expr, DataType data = default) => default;
public override string VisitGenericExpr(AstGenericExpr expr, int data = 0) { var args = string.Join(", ", expr.Parameters.Select(p => p.Accept(this))); return($"[{args}] {expr.SubExpression.Accept(this)}"); }