]> Cypherpunks repositories - gostls13.git/commitdiff
test: add new test case for 51219 that triggers the types2 issue
authorDan Scales <danscales@google.com>
Thu, 24 Feb 2022 01:57:09 +0000 (17:57 -0800)
committerDan Scales <danscales@google.com>
Mon, 28 Feb 2022 14:59:04 +0000 (14:59 +0000)
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 <danscales@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
test/typeparam/issue51219.dir/a.go
test/typeparam/issue51219.dir/main.go
test/typeparam/issue51219.out
test/typeparam/issue51219b.dir/a.go [new file with mode: 0644]
test/typeparam/issue51219b.dir/b.go [moved from test/typeparam/issue51219.dir/b.go with 77% similarity]
test/typeparam/issue51219b.dir/p.go [new file with mode: 0644]
test/typeparam/issue51219b.go [new file with mode: 0644]

index 3ed4322dbf4e22290dd47d94e999ce5629753cf1..29670df0d3a764eddd6a8fd293aa022bb27c736d 100644 (file)
@@ -18,42 +18,3 @@ type IConstraint interface {
 
 type I[T IConstraint] struct {
 }
-
-// The following types form an even more complex recursion (through two type
-// constraints), and model the actual types in the issue (#51219) more closely.
-// However, they don't reveal any new issue. But it seems useful to leave this
-// complex set of types in a test in case it might be broken by future changes.
-
-type Message struct {
-       Interaction *Interaction[JsonRaw] `json:"interaction,omitempty"`
-}
-
-type ResolvedDataConstraint interface {
-       User | Message
-}
-
-type Snowflake uint64
-
-type ResolvedData[T ResolvedDataConstraint] map[Snowflake]T
-
-type User struct {
-}
-
-type Resolved struct {
-       Users ResolvedData[User] `json:"users,omitempty"`
-}
-
-type resolvedInteractionWithOptions struct {
-       Resolved Resolved `json:"resolved,omitempty"`
-}
-
-type UserCommandInteractionData struct {
-       resolvedInteractionWithOptions
-}
-
-type InteractionDataConstraint interface {
-       JsonRaw | UserCommandInteractionData
-}
-
-type Interaction[DataT InteractionDataConstraint] struct {
-}
index c5cffd111c5d89e06d252f617218692120661383..999b4a96a1b953c554968da3eeeff13e2f86df40 100644 (file)
@@ -6,13 +6,11 @@ package main
 
 import (
        "a"
-       "b"
        "fmt"
 )
 
 func main() {
        var x a.I[a.JsonRaw]
-       var y b.InteractionRequest[a.JsonRaw]
 
-       fmt.Printf("%v %v\n", x, y)
+       fmt.Printf("%v\n", x)
 }
index 99c5b9aa9b60d8a91420a0079b383286d3878645..0967ef424bce6791893e9a57bb952f80fd536e93 100644 (file)
@@ -1 +1 @@
-{} {{}}
+{}
diff --git a/test/typeparam/issue51219b.dir/a.go b/test/typeparam/issue51219b.dir/a.go
new file mode 100644 (file)
index 0000000..1904940
--- /dev/null
@@ -0,0 +1,37 @@
+// Copyright 2022 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 a
+
+type Interaction[DataT InteractionDataConstraint] struct {
+}
+
+type InteractionDataConstraint interface {
+       []byte |
+               UserCommandInteractionData
+}
+
+type UserCommandInteractionData struct {
+       resolvedInteractionWithOptions
+}
+
+type resolvedInteractionWithOptions struct {
+       Resolved Resolved `json:"resolved,omitempty"`
+}
+
+type Resolved struct {
+       Users ResolvedData[User] `json:"users,omitempty"`
+}
+
+type ResolvedData[T ResolvedDataConstraint] map[uint64]T
+
+type ResolvedDataConstraint interface {
+       User | Message
+}
+
+type User struct{}
+
+type Message struct {
+       Interaction *Interaction[[]byte] `json:"interaction,omitempty"`
+}
similarity index 77%
rename from test/typeparam/issue51219.dir/b.go
rename to test/typeparam/issue51219b.dir/b.go
index c1590725b045666c84066777fbc404d5531d1ef8..8413d666b7e2cd9fce155d9aeedc8897a5443dc2 100644 (file)
@@ -4,8 +4,11 @@
 
 package b
 
-import "a"
+import (
+       "./a"
+)
 
+// InteractionRequest is an incoming request Interaction
 type InteractionRequest[T a.InteractionDataConstraint] struct {
        a.Interaction[T]
 }
diff --git a/test/typeparam/issue51219b.dir/p.go b/test/typeparam/issue51219b.dir/p.go
new file mode 100644 (file)
index 0000000..9f8b840
--- /dev/null
@@ -0,0 +1,14 @@
+// Copyright 2022 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 (
+       "./b"
+)
+
+// ResponseWriterMock mocks corde's ResponseWriter interface
+type ResponseWriterMock struct {
+       x b.InteractionRequest[[]byte]
+}
diff --git a/test/typeparam/issue51219b.go b/test/typeparam/issue51219b.go
new file mode 100644 (file)
index 0000000..060a121
--- /dev/null
@@ -0,0 +1,7 @@
+// compiledir -G=3
+
+// Copyright 2022 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 ignored