From d03cfe141c9602f64fc2a194d77ac9386d0ddcf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Sun, 21 Feb 2021 19:17:06 +0200 Subject: Add test from #7273 --- crates/hir_ty/src/tests/method_resolution.rs | 45 ++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'crates/hir_ty') diff --git a/crates/hir_ty/src/tests/method_resolution.rs b/crates/hir_ty/src/tests/method_resolution.rs index 659b8fce9..a9901d7b8 100644 --- a/crates/hir_ty/src/tests/method_resolution.rs +++ b/crates/hir_ty/src/tests/method_resolution.rs @@ -955,6 +955,51 @@ fn test() { foo.call(); } ); } +#[test] +fn super_trait_impl_return_trait_method_resolution() { + check_infer( + r#" + trait Base { + fn foo(self) -> usize; + } + + trait Super : Base {} + + fn base1() -> impl Base { loop {} } + fn super1() -> impl Super { loop {} } + + fn test(base2: impl Base, super2: impl Super) { + base1().foo(); + super1().foo(); + base2.foo(); + super2.foo(); + } + "#, + expect![[r#" + 24..28 'self': Self + 90..101 '{ loop {} }': ! + 92..99 'loop {}': ! + 97..99 '{}': () + 128..139 '{ loop {} }': ! + 130..137 'loop {}': ! + 135..137 '{}': () + 149..154 'base2': impl Base + 167..173 'super2': impl Super + 187..264 '{ ...o(); }': () + 193..198 'base1': fn base1() -> impl Base + 193..200 'base1()': impl Base + 193..206 'base1().foo()': usize + 212..218 'super1': fn super1() -> impl Super + 212..220 'super1()': impl Super + 212..226 'super1().foo()': usize + 232..237 'base2': impl Base + 232..243 'base2.foo()': usize + 249..255 'super2': impl Super + 249..261 'super2.foo()': usize + "#]], + ); +} + #[test] fn method_resolution_non_parameter_type() { check_types( -- cgit v1.2.3