Commit 90943c8e authored by Ian Lance Taylor's avatar Ian Lance Taylor

Test that interfaces work in type switches.

R=ken,rsc
DELTA=30  (30 added, 0 deleted, 0 changed)
OCL=26599
CL=26604
parent 7d443bb6
// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: should run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
type S struct { i int }
func (p *S) Get() int { return p.i }
type Empty interface {
}
type Getter interface {
Get() int;
}
func f1(p Empty) {
switch x := p.(type) {
default: println("failed to match interface"); sys.Exit(1);
case Getter: break;
}
}
func main() {
var s S;
f1(&s);
}
......@@ -141,6 +141,10 @@ bugs/bug140.go:6: syntax error near L1
bugs/bug140.go:7: syntax error near L2
BUG should compile
=========== bugs/bug141.go
failed to match interface
BUG: should run
=========== fixedbugs/bug016.go
fixedbugs/bug016.go:7: constant -3 overflows uint
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment