~john-koepi/ubuntu/trusty/golang/default

« back to all changes in this revision

Viewing changes to test/interface/returntype.go

  • Committer: Bazaar Package Importer
  • Author(s): Ondřej Surý
  • Date: 2011-04-20 17:36:48 UTC
  • Revision ID: james.westby@ubuntu.com-20110420173648-ifergoxyrm832trd
Tags: upstream-2011.03.07.1
Import upstream version 2011.03.07.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// $G $D/$F.go && $L $F.$A && (! ./$A.out || echo BUG: should not succeed)
 
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
        var i1 I1
 
22
        var s *S
 
23
        i1 = s
 
24
        print(i1.(I2).Name())
 
25
}