A message representing a result of type checking a batch of SCCs. Only one of `result` or `blocker` can be non-None. The latter means there was a blocking error while type checking the SCCs. The `is_interface` flag indicates whether this is a result for interface or implementation
| 5262 | |
| 5263 | |
| 5264 | class SccResponseMessage(IPCMessage): |
| 5265 | """ |
| 5266 | A message representing a result of type checking a batch of SCCs. |
| 5267 | |
| 5268 | Only one of `result` or `blocker` can be non-None. The latter means there was |
| 5269 | a blocking error while type checking the SCCs. The `is_interface` flag indicates |
| 5270 | whether this is a result for interface or implementation phase of type-checking. |
| 5271 | """ |
| 5272 | |
| 5273 | def __init__( |
| 5274 | self, |
| 5275 | *, |
| 5276 | scc_ids: list[int], |
| 5277 | is_interface: bool, |
| 5278 | result: dict[str, ModuleResult] | None = None, |
| 5279 | blocker: CompileError | None = None, |
| 5280 | ) -> None: |
| 5281 | if result is not None: |
| 5282 | assert blocker is None |
| 5283 | if blocker is not None: |
| 5284 | assert result is None |
| 5285 | self.scc_ids = scc_ids |
| 5286 | self.is_interface = is_interface |
| 5287 | self.result = result |
| 5288 | self.blocker = blocker |
| 5289 | |
| 5290 | @classmethod |
| 5291 | def read(cls, buf: ReadBuffer) -> SccResponseMessage: |
| 5292 | scc_ids = read_int_list(buf) |
| 5293 | is_interface = read_bool(buf) |
| 5294 | tag = read_tag(buf) |
| 5295 | if tag == LITERAL_NONE: |
| 5296 | return SccResponseMessage( |
| 5297 | scc_ids=scc_ids, |
| 5298 | is_interface=is_interface, |
| 5299 | blocker=CompileError(read_str_list(buf), read_bool(buf), read_str_opt(buf)), |
| 5300 | ) |
| 5301 | else: |
| 5302 | assert tag == DICT_STR_GEN |
| 5303 | return SccResponseMessage( |
| 5304 | scc_ids=scc_ids, |
| 5305 | is_interface=is_interface, |
| 5306 | result={ |
| 5307 | read_str_bare(buf): ModuleResult.read(buf) for _ in range(read_int_bare(buf)) |
| 5308 | }, |
| 5309 | ) |
| 5310 | |
| 5311 | def write(self, buf: WriteBuffer) -> None: |
| 5312 | write_tag(buf, SCC_RESPONSE_MESSAGE) |
| 5313 | write_int_list(buf, self.scc_ids) |
| 5314 | write_bool(buf, self.is_interface) |
| 5315 | if self.result is None: |
| 5316 | assert self.blocker is not None |
| 5317 | write_tag(buf, LITERAL_NONE) |
| 5318 | write_str_list(buf, self.blocker.messages) |
| 5319 | write_bool(buf, self.blocker.use_stdout) |
| 5320 | write_str_opt(buf, self.blocker.module_with_blocker) |
| 5321 | else: |