From 291add48a44e2fe88256ef2958eba01f42df7713 Mon Sep 17 00:00:00 2001 From: Mateusz Poliwczak Date: Fri, 14 Feb 2025 19:35:40 +0100 Subject: [PATCH] add test case Change-Id: Ic0453367df8032afedd048916c9292eafd75c2f3 --- test/escape_iface_with_devirt_type_assertions.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/escape_iface_with_devirt_type_assertions.go b/test/escape_iface_with_devirt_type_assertions.go index abc72a9641d1ce..bf7cdfc052a178 100644 --- a/test/escape_iface_with_devirt_type_assertions.go +++ b/test/escape_iface_with_devirt_type_assertions.go @@ -119,6 +119,14 @@ func t2() { callA(a) // ERROR "devirtualizing" "inlining call" callIfA(a) // ERROR "devirtualizing" "inlining call" } + + { + var a M = &Impl{} // ERROR "does not escape" + // Note the !ok condition, devirtualizing here is fine. + if v, ok := a.(M); !ok { + v.M() // ERROR "devirtualizing" "inlining call" + } + } } func newM() M { // ERROR "can inline"