OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [go.test/] [test/] [interface/] [returntype.go] - Blame information for rev 700

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 700 jeremybenn
// $G $D/$F.go && $L $F.$A && ./$A.out
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
// Check methods with different return types.
8
 
9
package main
10
 
11
type S struct { a int }
12
type T struct { b string }
13
 
14
func (s *S) Name() int8 { return 1 }
15
func (t *T) Name() int64 { return 64 }
16
 
17
type I1 interface { Name() int8 }
18
type I2 interface { Name() int64 }
19
 
20
func main() {
21
        shouldPanic(p1)
22
}
23
 
24
func p1() {
25
        var i1 I1
26
        var s *S
27
        i1 = s
28
        print(i1.(I2).Name())
29
}
30
 
31
func shouldPanic(f func()) {
32
        defer func() {
33
                if recover() == nil {
34
                        panic("function should panic")
35
                }
36
        }()
37
        f()
38
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.