ObjectType findCommonSuperObject ( ObjectType a , ObjectType b ) { List < ObjectType > stackA = getSuperStack ( a ) ; List < ObjectType > stackB = getSuperStack ( b ) ; ObjectType result = getNativeObjectType ( JSTypeNative . OBJECT_TYPE ) ; while ( ! stackA . isEmpty ( ) && ! stackB . isEmpty ( ) ) { ObjectType currentA = stackA . remove ( stackA . size ( ) - 1 ) ; ObjectType currentB = stackB . remove ( stackB . size ( ) - 1 ) ; if ( currentA . isEquivalentTo ( currentB ) ) { result = currentA ; } else { return result ; } } return result ; }
Finds the common supertype of the two given object types .