aboutsummaryrefslogtreecommitdiffhomepage
path: root/testdata/interface.go
diff options
context:
space:
mode:
Diffstat (limited to 'testdata/interface.go')
-rw-r--r--testdata/interface.go35
1 files changed, 35 insertions, 0 deletions
diff --git a/testdata/interface.go b/testdata/interface.go
index d13399f36..7820538a4 100644
--- a/testdata/interface.go
+++ b/testdata/interface.go
@@ -93,6 +93,12 @@ func main() {
a int
b int
}{3, 6}},
+ {true, named1(), named1()},
+ {true, named2(), named2()},
+ {false, named1(), named2()},
+ {false, named2(), named3()},
+ {true, namedptr1(), namedptr1()},
+ {false, namedptr1(), namedptr2()},
}
for i, tc := range interfaceEqualTests {
if (tc.lhs == tc.rhs) != tc.equal {
@@ -277,3 +283,32 @@ func (f FooByte) Byte() byte { return byte(f) }
type Byter interface {
Byte() uint8
}
+
+// Make sure that named types inside functions do not alias with any other named
+// functions.
+
+type named int
+
+func named1() any {
+ return named(0)
+}
+
+func named2() any {
+ type named int
+ return named(0)
+}
+
+func named3() any {
+ type named int
+ return named(0)
+}
+
+func namedptr1() interface{} {
+ type Test int
+ return (*Test)(nil)
+}
+
+func namedptr2() interface{} {
+ type Test byte
+ return (*Test)(nil)
+}