From 4bfc9019172929d0b0f1c8a1b7eb28cdbc9b87ef Mon Sep 17 00:00:00 2001 From: Mateusz Poliwczak Date: Sun, 16 Feb 2025 18:23:35 +0100 Subject: [PATCH] add test Change-Id: I0db78c67fcb1e7f2f2aaeed06a54414e634e8ab3 --- test/codegen/load_type_from_itab.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 test/codegen/load_type_from_itab.go diff --git a/test/codegen/load_type_from_itab.go b/test/codegen/load_type_from_itab.go new file mode 100644 index 0000000000..b47044fcbd --- /dev/null +++ b/test/codegen/load_type_from_itab.go @@ -0,0 +1,24 @@ +// asmcheck + +// Copyright 2025 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This test makes sure that we statically load a type from an itab, instead +// of doing a indirect load from thet itab. + +package codegen + +type M interface{ M() } +type A interface{ A() } + +type Impl struct{} + +func (*Impl) M() {} +func (*Impl) A() {} + +func main() { + var a M = &Impl{} + // amd64:`LEAQ\ttype:.*Impl` + a.(A).A() +}