/// Attempt to resolve all polymorphic types to a single "key" type. For
/// `target_for_param_type` to be useful, this must have already been
/// called.
Attempt to resolve all polymorphic types to a single "key" type. For
`target_for_param_type` to be useful, this must have already been
called.
Attempt to resolve all polymorphic types to a single " key " type . For ` target_for_param_type ` to be useful this must have already been called .
fn determine_key(&mut self, ecx: &ExprContext) -> bool {
        self.key = if !self.seen.iter().any(|v| v.is_some()) {
            match &self.compat {
                // No encountered param was polymorphic
                None => None,
                // Params were polymorphic, but we never received a known type.
                // This cannot be delegated to `guess_best_common_type`, which
                // will incorrectly guess string, which is incompatible with
                // `BestCommonList`, `BestCommonMap`.
                Some(t) => match t {
                    PolymorphicCompatClass::BestCommonAny => Some(ScalarType::String),
                    PolymorphicCompatClass::BestCommonList => Some(ScalarType::List {
                        custom_id: None,
                        element_type: Box::new(ScalarType::String),
                    }),
                    PolymorphicCompatClass::BestCommonMap => Some(ScalarType::Map {
                        value_type: Box::new(ScalarType::String),
                        custom_id: None,
                    }),
                    // Do not infer type.
                    PolymorphicCompatClass::StructuralEq | PolymorphicCompatClass::BaseEq => None,
                },
            }
        } else {
            // If we saw any polymorphic parameters, we must have determined the
            // compatibility type.
            let compat = self.compat.as_ref().unwrap();
            let r = match typeconv::guess_best_common_type(ecx, &self.seen) {
                Ok(r) => r,
                Err(_) => return false,
            };
            // Ensure the best common type is compatible.
            for t in self.seen.iter() {
                if let Some(t) = t {
                    if !compat.compatible(ecx, t, &r) {
                        return false;
                    }
                }
            }
            Some(r)
        };
        true
    }
fn determine_key ( & mut self , ecx : & ExprContext ) -> bool { self . key = if ! self . seen . iter ( ) . any ( | v | v . is_some ( ) ) { match & self . compat { // No encountered param was polymorphic None => None , // Params were polymorphic, but we never received a known type. // This cannot be delegated to `guess_best_common_type`, which // will incorrectly guess string, which is incompatible with // `BestCommonList`, `BestCommonMap`. Some ( t ) => match t { PolymorphicCompatClass :: BestCommonAny => Some ( ScalarType :: String ) , PolymorphicCompatClass :: BestCommonList => Some ( ScalarType :: List { custom_id : None , element_type : Box :: new ( ScalarType :: String ) , } ) , PolymorphicCompatClass :: BestCommonMap => Some ( ScalarType :: Map { value_type : Box :: new ( ScalarType :: String ) , custom_id : None , } ) , // Do not infer type. PolymorphicCompatClass :: StructuralEq | PolymorphicCompatClass :: BaseEq => None , } , } } else { // If we saw any polymorphic parameters, we must have determined the // compatibility type. let compat = self . compat . as_ref ( ) . unwrap ( ) ; let r = match typeconv :: guess_best_common_type ( ecx , & self . seen ) { Ok ( r ) => r , Err ( _ ) => return false , } ; // Ensure the best common type is compatible. for t in self . seen . iter ( ) { if let Some ( t ) = t { if ! compat . compatible ( ecx , t , & r ) { return false ; } } } Some ( r ) } ; true }
Attempt to resolve all polymorphic types to a single "key" type.
Attempt to resolve all polymorphic types to a single " key " type .
&mut self
ecx
&ExprContext