private static boolean couldHaveCommonSubtype ( Type type1 , Type type2 ) { // this is an optimistically naive implementation. // if they are parameterized types their parameters need to be checked,... // so we're just a bit too lenient here Class < ? > erased1 = GenericTypeReflector . erase ( type1 ) ; Class < ? > erased2 = GenericTypeReflector . erase ( type2 ) ; // if they are both classes if ( ! erased1 . isInterface ( ) && ! erased2 . isInterface ( ) ) { // then one needs to be a subclass of another if ( ! erased1 . isAssignableFrom ( erased2 ) && ! erased2 . isAssignableFrom ( erased1 ) ) { return false ; } } return true ; }
Checks if the intersection of two types is not empty .