fix InvalidCastException in TypeSystemAstBuilder