Determines whether `typs` are compatible with `self`.
(&self, ecx: &ExprContext, typs: &[CoercibleScalarType])
| 598 | impl 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 { |
no test coverage detected