Fix a bug in computing supertype