private boolean isSubtype ( Type . Callable lhs , Type . Callable rhs , LifetimeRelation lifetimes ) { Tuple < Type > parentParams = lhs . getParameters ( ) ; Tuple < Type > childParams = rhs . getParameters ( ) ; if ( parentParams . size ( ) != childParams . size ( ) ) { // Differing number of parameters / arguments. Since we don't // support variable-length argument lists (yet), there is nothing // more to consider. return false ; } // Number of parameters matches number of arguments. Now, check that // each argument is a subtype of its corresponding parameter. for ( int i = 0 ; i != parentParams . size ( ) ; ++ i ) { SemanticType parentParam = parentParams . get ( i ) ; SemanticType childParam = childParams . get ( i ) ; if ( ! subtypeOperator . isSubtype ( parentParam , childParam , lifetimes ) ) { return false ; } } // return true ; }
Check whether the type signature for a given function or method declaration is a super type of a given child declaration .