The typechecking code was doing an extra, unnecessary
indirection.
Fixes #4458.
R=golang-dev, daniel.morsing, rsc
CC=golang-dev
https://golang.org/cl/
6998051
static int
looktypedot(Node *n, Type *t, int dostrcmp)
{
- Type *f1, *f2, *tt;
+ Type *f1, *f2;
Sym *s;
s = n->right->sym;
return 1;
}
- tt = t;
- if(t->sym == S && isptr[t->etype])
- tt = t->type;
-
- f2 = methtype(tt, 0);
+ // Find the base type: methtype will fail if t
+ // is not of the form T or *T.
+ f2 = methtype(t, 0);
if(f2 == T)
return 0;
--- /dev/null
+// errorcheck
+
+// Copyright 2012 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.
+
+// Issue 4458: gc accepts invalid method expressions
+// like (**T).Method.
+
+package main
+
+type T struct{}
+
+func (T) foo() {}
+
+func main() {
+ av := T{}
+ pav := &av
+ (**T).foo(&pav) // ERROR "no method foo"
+}