// expected: shadows declaration in enclosing scope // // The binding a type switch introduces is a declaration like any other, so // `switch s := s.(type)` shadows the parameter it reads. Legacy rejects it // through go/types scopes; stage4's position-insensitive shadow pass never saw // the binding, because a type switch keeps it in the guard rather than in an // assignment, so the same source compiled. The binding is declared now. package main type shape interface { area() (a int32) } type square struct { side int32 } func (s *square) area() (a int32) { return s.side * s.side } func measure(s shape) (n int32) { switch s := s.(type) { case *square: return s.area() } return 0 } func main() { println(measure(&square{side: 2})) }