aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMitchell Hashimoto <mitchell.hashimoto@gmail.com>2022-02-25 18:47:10 -0800
committerMitchell Hashimoto <mitchell.hashimoto@gmail.com>2022-02-25 18:47:10 -0800
commit91af552f87817f3a5fa23d812cecc79649c7e506 (patch)
treec9739231d5ac57aabe6ed81f0a55b836c45ee6ab /src
parent943ee59bb1524a46dd13af6a55d30025e25dd061 (diff)
downloadzig-91af552f87817f3a5fa23d812cecc79649c7e506.tar.gz
zig-91af552f87817f3a5fa23d812cecc79649c7e506.zip
stage2: resolve peer types that trivially coerce
Diffstat (limited to 'src')
-rw-r--r--src/Sema.zig12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/Sema.zig b/src/Sema.zig
index af240d43d1..650349f744 100644
--- a/src/Sema.zig
+++ b/src/Sema.zig
@@ -16993,6 +16993,18 @@ fn resolvePeerTypes(
const chosen_ty = sema.typeOf(chosen);
if (candidate_ty.eql(chosen_ty))
continue;
+
+ // If the candidate can coernce into our chosen type, we're done.
+ // If the chosen type can coerce into the candidate, use that.
+ if ((try sema.coerceInMemoryAllowed(block, chosen_ty, candidate_ty, false, target, src, src)) == .ok) {
+ continue;
+ }
+ if ((try sema.coerceInMemoryAllowed(block, candidate_ty, chosen_ty, false, target, src, src)) == .ok) {
+ chosen = candidate;
+ chosen_i = candidate_i + 1;
+ continue;
+ }
+
const candidate_ty_tag = candidate_ty.zigTypeTag();
const chosen_ty_tag = chosen_ty.zigTypeTag();