1// run 2 3// Copyright 2012 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 7// Issue 3824. 8// Method calls are ignored when deciding initialization 9// order. 10 11package main 12 13type T int 14 15func (r T) Method1() int { return a } 16func (r T) Method2() int { return b } 17 18// dummy1 and dummy2 must be initialized after a and b. 19var dummy1 = T(0).Method1() 20var dummy2 = T.Method2(0) 21 22// Use a function call to force generating code. 23var a = identity(1) 24var b = identity(2) 25 26func identity(a int) int { return a } 27 28func main() { 29 if dummy1 != 1 { 30 panic("dummy1 != 1") 31 } 32 if dummy2 != 2 { 33 panic("dummy2 != 2") 34 } 35} 36 37