Sin descripción

type_sets.go 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. package main
  2. // TYPE OMIT
  3. type Integer interface {
  4. int
  5. }
  6. // TYPE OMIT
  7. // INVALID OMIT
  8. // EmbeddedParameter is INVALID.
  9. type EmbeddedParameter[T any] interface {
  10. T // INVALID: may not list a plain type parameter
  11. }
  12. // INVALID OMIT
  13. // APPRO OMIT
  14. type MyInt int
  15. type AnyInteger interface {
  16. ~int
  17. }
  18. // APPRO OMIT
  19. // ALL INVALID OMIT
  20. type MyString string
  21. // ApproximateMyString is INVALID.
  22. type ApproximateMyString interface {
  23. ~MyString // INVALID: underlying type of MyString is not MyString
  24. }
  25. // ApproximateParameter is INVALID.
  26. type ApproximateParameter[T any] interface {
  27. ~T // INVALID: T is a type parameter
  28. }
  29. type MyInterface {}
  30. // ApproximateInterface is INVALID.
  31. type ApproximateInterface interface {
  32. ~MyInterface // INVALID: T is an interface type
  33. }
  34. // ALL INVALID OMIT
  35. // ONION EXAMPLE OMIT
  36. // PredeclaredSignedInteger is a constraint that matches the
  37. // five predeclared signed integer types.
  38. type PredeclaredSignedInteger interface {
  39. int | int8 | int16 | int32 | int64
  40. }
  41. // SignedInteger is a constraint that matches any signed integer type.
  42. type SignedInteger interface {
  43. ~int | ~int8 | ~int16 | ~int32 | ~int64
  44. }
  45. // ONION EXAMPLE OMIT
  46. // StringableSignedInteger OMIT
  47. type StringableSignedInteger interface {
  48. ~int | ~int8 | ~int16 | ~int32 | ~int64
  49. String() string
  50. }
  51. // StringableSignedInteger OMIT