mirror of
https://github.com/golang/go
synced 2024-11-11 20:20:23 -07:00
test: add test cases for issue47892.
This issue has been fixed in https://golang.org/cl/345411 Fixes: #47892 Change-Id: I13dd3814650913da065e5f24a0c61d30adb0633a Reviewed-on: https://go-review.googlesource.com/c/go/+/345229 Reviewed-by: Dan Scales <danscales@google.com> Trust: Dan Scales <danscales@google.com> Trust: Keith Randall <khr@golang.org> Trust: Alberto Donizetti <alb.donizetti@gmail.com> Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com> TryBot-Result: Go Bot <gobot@golang.org>
This commit is contained in:
parent
f4cd001b57
commit
f29abccd8a
17
test/typeparam/issue47892.dir/a.go
Normal file
17
test/typeparam/issue47892.dir/a.go
Normal file
@ -0,0 +1,17 @@
|
||||
// Copyright 2021 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 Index[T any] interface {
|
||||
G() T
|
||||
}
|
||||
|
||||
type I1[T any] struct {
|
||||
a T
|
||||
}
|
||||
|
||||
func (i *I1[T]) G() T {
|
||||
return i.a
|
||||
}
|
21
test/typeparam/issue47892.dir/main.go
Normal file
21
test/typeparam/issue47892.dir/main.go
Normal file
@ -0,0 +1,21 @@
|
||||
// Copyright 2021 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 main
|
||||
|
||||
import "a"
|
||||
|
||||
type Model[T any] struct {
|
||||
index a.Index[T]
|
||||
}
|
||||
|
||||
func NewModel[T any](index a.Index[T]) Model[T] {
|
||||
return Model[T]{
|
||||
index: index,
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
_ = NewModel[int]((*a.I1[int])(nil))
|
||||
}
|
7
test/typeparam/issue47892.go
Normal file
7
test/typeparam/issue47892.go
Normal file
@ -0,0 +1,7 @@
|
||||
// rundir -G=3
|
||||
|
||||
// Copyright 2021 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
|
29
test/typeparam/issue47892b.dir/a.go
Normal file
29
test/typeparam/issue47892b.dir/a.go
Normal file
@ -0,0 +1,29 @@
|
||||
// Copyright 2021 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 T struct{ p *int64 }
|
||||
|
||||
type i struct{}
|
||||
|
||||
func G() *T { return &T{nil} }
|
||||
|
||||
func (j i) F(a, b *T) *T {
|
||||
n := *a.p + *b.p
|
||||
return &T{&n}
|
||||
}
|
||||
|
||||
func (j i) G() *T {
|
||||
return &T{}
|
||||
}
|
||||
|
||||
type I[Idx any] interface {
|
||||
G() Idx
|
||||
F(a, b Idx) Idx
|
||||
}
|
||||
|
||||
func Gen() I[*T] {
|
||||
return i{}
|
||||
}
|
17
test/typeparam/issue47892b.dir/main.go
Normal file
17
test/typeparam/issue47892b.dir/main.go
Normal file
@ -0,0 +1,17 @@
|
||||
// Copyright 2021 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 main
|
||||
|
||||
import "a"
|
||||
|
||||
type S[Idx any] struct {
|
||||
A string
|
||||
B Idx
|
||||
}
|
||||
|
||||
type O[Idx any] struct {
|
||||
A int
|
||||
B a.I[Idx]
|
||||
}
|
7
test/typeparam/issue47892b.go
Normal file
7
test/typeparam/issue47892b.go
Normal file
@ -0,0 +1,7 @@
|
||||
// compiledir -G=3
|
||||
|
||||
// Copyright 2021 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
|
Loading…
Reference in New Issue
Block a user