Source file test/fixedbugs/bug141.go

     1  // run
     2  
     3  // Copyright 2009 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 main
     8  
     9  import "os"
    10  
    11  type S struct { i int }
    12  func (p *S) Get() int { return p.i }
    13  
    14  type Empty interface {
    15  }
    16  
    17  type Getter interface {
    18  	Get() int;
    19  }
    20  
    21  func f1(p Empty) {
    22  	switch x := p.(type) {
    23  	default: println("failed to match interface", x); os.Exit(1);
    24  	case Getter: break;
    25  	}
    26  
    27  }
    28  
    29  func main() {
    30  	var s S;
    31  	f1(&s);
    32  }
    33  

View as plain text