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

Subversion Repositories openrisc

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 700 jeremybenn
// errchk $G -e $D/$F.go
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
// Static error messages about interface conversions.
8
 
9
package main
10
 
11
type T struct {
12
        a int
13
}
14
 
15
var t *T
16
 
17
type I interface {
18
        M()
19
}
20
 
21
var i I
22
 
23
type I2 interface {
24
        M()
25
        N()
26
}
27
 
28
var i2 I2
29
 
30
type E interface{}
31
 
32
var e E
33
 
34
func main() {
35
        e = t // ok
36
        t = e // ERROR "need explicit|need type assertion"
37
 
38
        // neither of these can work,
39
        // because i has an extra method
40
        // that t does not, so i cannot contain a t.
41
        i = t // ERROR "incompatible|missing M method"
42
        t = i // ERROR "incompatible|need type assertion"
43
 
44
        i = i2 // ok
45
        i2 = i // ERROR "incompatible|missing N method"
46
 
47
        i = I(i2)  // ok
48
        i2 = I2(i) // ERROR "invalid|missing N method"
49
 
50
        e = E(t) // ok
51
        t = T(e) // ERROR "need explicit|need type assertion|incompatible" "as type [*]T"
52
}
53
 
54
type M interface {
55
        M()
56
}
57
 
58
var m M
59
 
60
var _ = m.(int) // ERROR "impossible type assertion"
61
 
62
type Int int
63
 
64
func (Int) M(float64) {}
65
 
66
var _ = m.(Int) // ERROR "impossible type assertion"
67
 
68
var ii int
69
var jj Int
70
 
71
var m1 M = ii // ERROR "incompatible|missing"
72
var m2 M = jj // ERROR "incompatible|wrong type for M method"
73
 
74
var m3 = M(ii) // ERROR "invalid|missing"
75
var m4 = M(jj) // ERROR "invalid|wrong type for M method"

powered by: WebSVN 2.1.0

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