1// compile
2
3// Copyright 2015 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 11790: Incorrect error following named pointer dereference on field
8
9package main
10
11import "fmt"
12
13type T0 struct {
14	x int
15}
16
17func (*T0) M0() {
18	fmt.Println("M0")
19}
20
21type T2 struct {
22	*T0
23}
24
25type Q *T2
26
27func main() {
28	// If run, expected output is
29	// 42
30	// M0
31	t0 := T0{42}
32	t2 := T2{&t0}
33	var q Q = &t2
34	fmt.Println(q.x) // Comment out either this line or the next line and the program works
35	(*q).T0.M0()
36}
37