From d110fbde6c6b775ec9e7f41455c28e51da1810ef Mon Sep 17 00:00:00 2001 From: Ayaz Hafiz Date: Wed, 13 Apr 2022 10:44:34 -0400 Subject: [PATCH] Annotation specializes ability --- compiler/can/src/def.rs | 4 +++- compiler/solve/tests/solve_expr.rs | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/compiler/can/src/def.rs b/compiler/can/src/def.rs index f5417708fa..54c64f8c92 100644 --- a/compiler/can/src/def.rs +++ b/compiler/can/src/def.rs @@ -1218,7 +1218,9 @@ fn canonicalize_pending_value_def<'a>( } }; - if let Pattern::Identifier(symbol) = loc_can_pattern.value { + if let Pattern::Identifier(symbol) + | Pattern::AbilityMemberSpecialization { ident: symbol, .. } = loc_can_pattern.value + { let def = single_can_def( loc_can_pattern, loc_can_expr, diff --git a/compiler/solve/tests/solve_expr.rs b/compiler/solve/tests/solve_expr.rs index b926ebf467..c781854cfa 100644 --- a/compiler/solve/tests/solve_expr.rs +++ b/compiler/solve/tests/solve_expr.rs @@ -5860,4 +5860,23 @@ mod solve_expr { [("hash", "Id")], ) } + + #[test] + fn ability_checked_specialization_with_annotation_only() { + check_inferred_abilities( + indoc!( + r#" + app "test" provides [ hash ] to "./platform" + + Hash has + hash : a -> U64 | a has Hash + + Id := U64 + + hash : Id -> U64 + "# + ), + [("hash", "Id")], + ) + } }