| 1 |
// asmcheck |
| 2 |
|
| 3 |
// Copyright 2024 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 codegen |
| 8 |
|
| 9 |
type Ix interface { |
| 10 |
X() |
| 11 |
} |
| 12 |
|
| 13 |
type Iy interface { |
| 14 |
Y() |
| 15 |
} |
| 16 |
|
| 17 |
type Iz interface { |
| 18 |
Z() |
| 19 |
} |
| 20 |
|
| 21 |
func swXYZ(a Ix) { |
| 22 |
switch t := a.(type) { |
| 23 |
case Iy: // amd64:-".*typeAssert" |
| 24 |
t.Y() |
| 25 |
case Iz: // amd64:-".*typeAssert" |
| 26 |
t.Z() |
| 27 |
} |
| 28 |
} |
| 29 |
|
| 30 |
type Ig[T any] interface { |
| 31 |
G() T |
| 32 |
} |
| 33 |
|
| 34 |
func swGYZ[T any](a Ig[T]) { |
| 35 |
switch t := a.(type) { |
| 36 |
case Iy: // amd64:-".*typeAssert" |
| 37 |
t.Y() |
| 38 |
case Iz: // amd64:-".*typeAssert" |
| 39 |
t.Z() |
| 40 |
case interface{ G() T }: // amd64:-".*typeAssert" -".*assertE2I\\(" ".*assertE2I2" |
| 41 |
t.G() |
| 42 |
} |
| 43 |
} |
| 44 |
|
| 45 |
func swE2G[T any](a any) { |
| 46 |
switch t := a.(type) { |
| 47 |
case Iy: |
| 48 |
t.Y() |
| 49 |
case Ig[T]: // amd64:-".*assertE2I\\(" ".*assertE2I2" |
| 50 |
t.G() |
| 51 |
} |
| 52 |
} |
| 53 |
|
| 54 |
func swI2G[T any](a Ix) { |
| 55 |
switch t := a.(type) { |
| 56 |
case Iy: |
| 57 |
t.Y() |
| 58 |
case Ig[T]: // amd64:-".*assertE2I\\(" ".*assertE2I2" |
| 59 |
t.G() |
| 60 |
} |
| 61 |
} |
| 62 |
|
| 63 |
func swCaller() { |
| 64 |
swGYZ[int]((Ig[int])(nil)) |
| 65 |
swE2G[int]((Ig[int])(nil)) |
| 66 |
swI2G[int]((Ix)(nil)) |
| 67 |
} |