aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/types2/example_test.go
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2021-01-22 16:59:45 -0800
committerRobert Griesemer <gri@golang.org>2021-01-23 01:57:35 +0000
commita49e9410276975d187a5cfda1a396194c45d4464 (patch)
treeb8fc9e70e84289f514cc6168ebf5b970710939ea /src/cmd/compile/internal/types2/example_test.go
parent5347241b5e64eb9a7b0ef97b12d899f32a05c2b8 (diff)
downloadgo-a49e9410276975d187a5cfda1a396194c45d4464.tar.gz
go-a49e9410276975d187a5cfda1a396194c45d4464.zip
[dev.typeparams] cmd/compile/internal/types2: remove MethodSet code - not used by types2
We can always re-introduce it if we decide to make use of it. Change-Id: Ia939fdae978568edc58e21d1af732c6137744aab Reviewed-on: https://go-review.googlesource.com/c/go/+/285678 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'src/cmd/compile/internal/types2/example_test.go')
-rw-r--r--src/cmd/compile/internal/types2/example_test.go55
1 files changed, 0 insertions, 55 deletions
diff --git a/src/cmd/compile/internal/types2/example_test.go b/src/cmd/compile/internal/types2/example_test.go
index dcdeaca0c0..ffd54fe459 100644
--- a/src/cmd/compile/internal/types2/example_test.go
+++ b/src/cmd/compile/internal/types2/example_test.go
@@ -107,61 +107,6 @@ func Unused() { {}; {{ var x int; _ = x }} } // make sure empty block scopes get
// }
}
-// ExampleMethodSet prints the method sets of various types.
-func ExampleMethodSet() {
- // Parse a single source file.
- const input = `
-package temperature
-import "fmt"
-type Celsius float64
-func (c Celsius) String() string { return fmt.Sprintf("%g°C", c) }
-func (c *Celsius) SetF(f float64) { *c = Celsius(f - 32 / 9 * 5) }
-
-type S struct { I; m int }
-type I interface { m() byte }
-`
- f, err := parseSrc("celsius.go", input)
- if err != nil {
- log.Fatal(err)
- }
-
- // Type-check a package consisting of this file.
- // Type information for the imported packages
- // comes from $GOROOT/pkg/$GOOS_$GOOARCH/fmt.a.
- conf := types2.Config{Importer: defaultImporter()}
- pkg, err := conf.Check("temperature", []*syntax.File{f}, nil)
- if err != nil {
- log.Fatal(err)
- }
-
- // Print the method sets of Celsius and *Celsius.
- celsius := pkg.Scope().Lookup("Celsius").Type()
- for _, t := range []types2.Type{celsius, types2.NewPointer(celsius)} {
- fmt.Printf("Method set of %s:\n", t)
- mset := types2.NewMethodSet(t)
- for i := 0; i < mset.Len(); i++ {
- fmt.Println(mset.At(i))
- }
- fmt.Println()
- }
-
- // Print the method set of S.
- styp := pkg.Scope().Lookup("S").Type()
- fmt.Printf("Method set of %s:\n", styp)
- fmt.Println(types2.NewMethodSet(styp))
-
- // Output:
- // Method set of temperature.Celsius:
- // method (temperature.Celsius) String() string
- //
- // Method set of *temperature.Celsius:
- // method (*temperature.Celsius) SetF(f float64)
- // method (*temperature.Celsius) String() string
- //
- // Method set of temperature.S:
- // MethodSet {}
-}
-
// ExampleInfo prints various facts recorded by the type checker in a
// types2.Info struct: definitions of and references to each named object,
// and the type, value, and mode of every expression in the package.