1// compile 2 3// Copyright 2023 The Go Authors. All rights reserved. 4// Use of this source code is governed by a BSD-style 5// license that can be found in the LICENSE file. 6 7package main 8 9type ResourceFunc struct { 10 junk [8]int 11 base assignmentBaseResource 12} 13 14type SubscriptionAssignmentResource struct { 15 base assignmentBaseResource 16} 17 18type assignmentBaseResource struct{} 19 20//go:noinline 21func (a assignmentBaseResource) f(s string) ResourceFunc { 22 println(s) 23 return ResourceFunc{} 24} 25 26//go:noinline 27func (r SubscriptionAssignmentResource) Hi() ResourceFunc { 28 rf := r.base.f("Hello world") 29 rf.base = r.base 30 return rf 31} 32 33func main() { 34 var r SubscriptionAssignmentResource 35 r.Hi() 36} 37