MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / matches_argtypes

Method matches_argtypes

src/sql/src/func.rs:600–623  ·  view source on GitHub ↗

Determines whether `typs` are compatible with `self`.

(&self, ecx: &ExprContext, typs: &[CoercibleScalarType])

Source from the content-addressed store, hash-verified

598impl ParamList {
599 /// Determines whether `typs` are compatible with `self`.
600 fn matches_argtypes(&self, ecx: &ExprContext, typs: &[CoercibleScalarType]) -> bool {
601 if !self.validate_arg_len(typs.len()) {
602 return false;
603 }
604
605 for (i, typ) in typs.iter().enumerate() {
606 let param = &self[i];
607 if let CoercibleScalarType::Coerced(typ) = typ {
608 // Ensures either `typ` can at least be implicitly cast to a
609 // type `param` accepts. Implicit in this check is that unknown
610 // type arguments can be cast to any type.
611 //
612 // N.B. this will require more fallthrough checks once we
613 // support RECORD types in functions.
614 if !param.accepts_type(ecx, typ) {
615 return false;
616 }
617 }
618 }
619
620 // Ensure a polymorphic solution exists (non-polymorphic functions have
621 // trivial polymorphic solutions that evaluate to `None`).
622 PolymorphicSolution::new(ecx, typs, self).is_some()
623 }
624
625 /// Validates that the number of input elements are viable for `self`.
626 fn validate_arg_len(&self, input_len: usize) -> bool {

Callers 2

select_implFunction · 0.80
find_matchFunction · 0.80

Calls 6

validate_arg_lenMethod · 0.80
enumerateMethod · 0.80
accepts_typeMethod · 0.80
is_someMethod · 0.80
lenMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected