Skip to content

Commit 57dda97

Browse files
committed
test: add new test case for 51219 that triggers the types2 issue
The existing test for 51219 didn't actually trigger the types2 issue - I hadn't been able to minimize the test case yet properly. This new test case issue51219b.go now does trigger the types2 issue (it's only slightly different). Updates #51219 Change-Id: Iaba8144b4702ff4fefec86c899b8acef127b10dc Reviewed-on: https://go-review.googlesource.com/c/go/+/387814 Trust: Dan Scales <[email protected]> Reviewed-by: Robert Findley <[email protected]>
1 parent a064a4f commit 57dda97

File tree

7 files changed

+64
-44
lines changed

7 files changed

+64
-44
lines changed

test/typeparam/issue51219.dir/a.go

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -18,42 +18,3 @@ type IConstraint interface {
1818

1919
type I[T IConstraint] struct {
2020
}
21-
22-
// The following types form an even more complex recursion (through two type
23-
// constraints), and model the actual types in the issue (#51219) more closely.
24-
// However, they don't reveal any new issue. But it seems useful to leave this
25-
// complex set of types in a test in case it might be broken by future changes.
26-
27-
type Message struct {
28-
Interaction *Interaction[JsonRaw] `json:"interaction,omitempty"`
29-
}
30-
31-
type ResolvedDataConstraint interface {
32-
User | Message
33-
}
34-
35-
type Snowflake uint64
36-
37-
type ResolvedData[T ResolvedDataConstraint] map[Snowflake]T
38-
39-
type User struct {
40-
}
41-
42-
type Resolved struct {
43-
Users ResolvedData[User] `json:"users,omitempty"`
44-
}
45-
46-
type resolvedInteractionWithOptions struct {
47-
Resolved Resolved `json:"resolved,omitempty"`
48-
}
49-
50-
type UserCommandInteractionData struct {
51-
resolvedInteractionWithOptions
52-
}
53-
54-
type InteractionDataConstraint interface {
55-
JsonRaw | UserCommandInteractionData
56-
}
57-
58-
type Interaction[DataT InteractionDataConstraint] struct {
59-
}

test/typeparam/issue51219.dir/main.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@ package main
66

77
import (
88
"a"
9-
"b"
109
"fmt"
1110
)
1211

1312
func main() {
1413
var x a.I[a.JsonRaw]
15-
var y b.InteractionRequest[a.JsonRaw]
1614

17-
fmt.Printf("%v %v\n", x, y)
15+
fmt.Printf("%v\n", x)
1816
}

test/typeparam/issue51219.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{} {{}}
1+
{}

test/typeparam/issue51219b.dir/a.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright 2022 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
package a
6+
7+
type Interaction[DataT InteractionDataConstraint] struct {
8+
}
9+
10+
type InteractionDataConstraint interface {
11+
[]byte |
12+
UserCommandInteractionData
13+
}
14+
15+
type UserCommandInteractionData struct {
16+
resolvedInteractionWithOptions
17+
}
18+
19+
type resolvedInteractionWithOptions struct {
20+
Resolved Resolved `json:"resolved,omitempty"`
21+
}
22+
23+
type Resolved struct {
24+
Users ResolvedData[User] `json:"users,omitempty"`
25+
}
26+
27+
type ResolvedData[T ResolvedDataConstraint] map[uint64]T
28+
29+
type ResolvedDataConstraint interface {
30+
User | Message
31+
}
32+
33+
type User struct{}
34+
35+
type Message struct {
36+
Interaction *Interaction[[]byte] `json:"interaction,omitempty"`
37+
}

test/typeparam/issue51219.dir/b.go renamed to test/typeparam/issue51219b.dir/b.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@
44

55
package b
66

7-
import "a"
7+
import (
8+
"./a"
9+
)
810

11+
// InteractionRequest is an incoming request Interaction
912
type InteractionRequest[T a.InteractionDataConstraint] struct {
1013
a.Interaction[T]
1114
}

test/typeparam/issue51219b.dir/p.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright 2022 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
package p
6+
7+
import (
8+
"./b"
9+
)
10+
11+
// ResponseWriterMock mocks corde's ResponseWriter interface
12+
type ResponseWriterMock struct {
13+
x b.InteractionRequest[[]byte]
14+
}

test/typeparam/issue51219b.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// compiledir -G=3
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+
package ignored

0 commit comments

Comments
 (0)