Home | History | Annotate | Download | only in interface
      1 // errorcheck
      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 // Test that interface{M()} = *interface{M()} produces a compiler error.
      8 // Does not compile.
      9 
     10 package main
     11 
     12 type Inst interface {
     13 	Next() *Inst
     14 }
     15 
     16 type Regexp struct {
     17 	code  []Inst
     18 	start Inst
     19 }
     20 
     21 type Start struct {
     22 	foo *Inst
     23 }
     24 
     25 func (start *Start) Next() *Inst { return nil }
     26 
     27 
     28 func AddInst(Inst) *Inst {
     29 	print("ok in addinst\n")
     30 	return nil
     31 }
     32 
     33 func main() {
     34 	print("call addinst\n")
     35 	var x Inst = AddInst(new(Start)) // ERROR "pointer to interface"
     36 	print("return from  addinst\n")
     37 	var y *Inst = new(Start)  // ERROR "pointer to interface|incompatible type"
     38 }
     39