while (rtype->named_type() != NULL
&& rtype->named_type()->is_alias())
- rtype = rtype->named_type()->real_type();
+ rtype = rtype->named_type()->real_type()->forwarded();
if (rtype->is_error_type())
ret = Named_object::make_function(name, NULL, function);
else if (rtype->named_type() != NULL)
{
- ret = rtype->named_type()->add_method(name, function);
- if (!ret->is_function())
+ if (rtype->named_type()->named_object()->package() != NULL)
{
- // Redefinition error.
+ go_error_at(type->receiver()->location(),
+ "may not define methods on non-local type");
ret = Named_object::make_function(name, NULL, function);
}
+ else
+ {
+ ret = rtype->named_type()->add_method(name, function);
+ if (!ret->is_function())
+ {
+ // Redefinition error.
+ ret = Named_object::make_function(name, NULL, function);
+ }
+ }
}
else if (rtype->forward_declaration_type() != NULL)
{
if (global_no->is_type())
{
if (no->type_declaration_value()->has_methods())
- go_error_at(no->location(),
- "may not define methods for global type");
+ {
+ for (std::vector<Named_object*>::const_iterator p =
+ no->type_declaration_value()->methods()->begin();
+ p != no->type_declaration_value()->methods()->end();
+ p++)
+ go_error_at((*p)->location(),
+ "may not define methods on non-local type");
+ }
no->set_type_value(global_no->type_value());
}
else
// errorcheck
-// Copyright 2013 The Go Authors. All rights reserved.
+// Copyright 2013 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.
package p
-import "bufio" // GCCGO_ERROR "previous"
+import "bufio"
func (b *bufio.Reader) Buffered() int { // ERROR "non-local|redefinition"
return -1