]> Cypherpunks.ru repositories - gostls13.git/blob - test/typeparam/issue54456.go
cmd/compile/internal/inline: score call sites exposed by inlines
[gostls13.git] / test / typeparam / issue54456.go
1 // run
2
3 // Copyright 2022 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 // The Go 1.18 frontend failed to disambiguate instantiations of
8 // different, locally defined generic types with the same name.
9 //
10 // The unified frontend also exposed the scope-disambiguation mangling
11 // to end users in reflect data.
12
13 package main
14
15 import (
16         "reflect"
17 )
18
19 func one() any { type T[_ any] int; return T[int](0) }
20 func two() any { type T[_ any] int; return T[int](0) }
21
22 func main() {
23         p, q := one(), two()
24
25         // p and q have different dynamic types; this comparison should
26         // evaluate false.
27         if p == q {
28                 panic("bad type identity")
29         }
30
31         for _, x := range []any{p, q} {
32                 // The names here should not contain "·1" or "·2".
33                 if name := reflect.TypeOf(x).String(); name != "main.T[int]" {
34                         panic(name)
35                 }
36         }
37 }