mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Previously, if a request R evaluated itself N times, we would emit N "circular reference" diagnostics. These add no value, so instead let's cache the user-provided default value on the first circular evaluation. This changes things slightly so that instead of returning an llvm::Expected<Request::OutputType>, various evaluator methods take a callback which can produce the default value. The existing evaluateOrDefault() interface is unchanged, and a new evaluateOrFatal() entry point replaces llvm::cantFail(ctx.evaluator(...)). Direct callers of the evaluator's operator() were updated to pass in the callback. The benefit of the callback over evaluateOrDefault() is that if the default value is expensive to constuct, like a dummy generic signature, we will only construct it in the case where a cycle actually happened, otherwise we just delete the callback. (cherry picked from commit b8fcf1c709efa6cd28e1217bd0efe876f7c0d2b7)
3.5 KiB
3.5 KiB