3 // Copyright 2016 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.
7 // Check the compiler's switch handling that happens
8 // at typechecking time.
9 // This must be separate from other checks,
10 // because errors during typechecking
11 // prevent other errors from being discovered.
15 // Verify that type switch statements with impossible cases are detected by the compiler.
18 case int: // ERROR "impossible type switch case: (int\n\t)?e \(.*type error\) cannot have dynamic type int \(missing method Error\)"
22 // Verify that the compiler rejects multiple default cases.
23 func f1(e interface{}) {
26 default: // ERROR "multiple defaults( in switch)?"
30 default: // ERROR "multiple defaults( in switch)?"
44 case X: // ERROR "impossible type switch case: (X\n\t)?i \(.*type I\) cannot have dynamic type X \(method Foo has pointer receiver\)"