compiler: accept "any" as an alias for "interface{}"
authorIan Lance Taylor <iant@golang.org>
Tue, 1 Feb 2022 22:44:20 +0000 (14:44 -0800)
committerIan Lance Taylor <iant@golang.org>
Sat, 5 Feb 2022 00:44:43 +0000 (16:44 -0800)
For golang/go#33232

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/382248

gcc/go/gofrontend/MERGE
gcc/go/gofrontend/gogo.cc
gcc/testsuite/go.test/test/fixedbugs/issue14652.go

index a42d88d..f78561c 100644 (file)
@@ -1,4 +1,4 @@
-7d510bf5fcec9b0ccc0282f4193a80c0a164df63
+61f7cf4b9db0587ff099aa36832a355b90ee1bf9
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
index e2fd509..b1e210e 100644 (file)
@@ -141,6 +141,15 @@ Gogo::Gogo(Backend* backend, Linemap* linemap, int, int pointer_size)
     this->add_named_type(error_type);
   }
 
+  // "any" is an alias for the empty interface type.
+  {
+    Type* empty = Type::make_empty_interface_type(loc);
+    Named_object* no = Named_object::make_type("any", NULL, empty, loc);
+    Named_type* nt = no->type_value();
+    nt->set_is_alias();
+    this->add_named_type(nt);
+  }
+
   this->globals_->add_constant(Typed_identifier("true",
                                                Type::make_boolean_type(),
                                                loc),
index d53b412..586663b 100644 (file)
@@ -1,4 +1,4 @@
-// errorcheck
+// compile
 
 // Copyright 2016 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
@@ -6,4 +6,5 @@
 
 package p
 
-var x any // ERROR "undefined: any|undefined type .*any.*"
+// any is now permitted instead of interface{}
+var x any