Russ Cox | b4f8e01 | 2008-10-08 09:21:57 -0700 | [diff] [blame] | 1 | // $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 | |
Russ Cox | c7d30bc | 2009-05-12 16:09:47 -0700 | [diff] [blame] | 7 | // Check that interface conversion fails when method is missing. |
| 8 | |
Russ Cox | b4f8e01 | 2008-10-08 09:21:57 -0700 | [diff] [blame] | 9 | package main |
| 10 | |
Russ Cox | 839a684 | 2009-01-20 14:40:40 -0800 | [diff] [blame] | 11 | type I interface { |
Russ Cox | b4f8e01 | 2008-10-08 09:21:57 -0700 | [diff] [blame] | 12 | Foo() |
| 13 | } |
| 14 | |
| 15 | func main() { |
Rob Pike | 4f61fc9 | 2010-09-04 10:36:13 +1000 | [diff] [blame] | 16 | var s *S |
| 17 | var i I |
| 18 | var e interface {} |
| 19 | e = s |
| 20 | i = e.(I) |
| 21 | _ = i |
Russ Cox | b4f8e01 | 2008-10-08 09:21:57 -0700 | [diff] [blame] | 22 | } |
| 23 | |
| 24 | // hide S down here to avoid static warning |
Russ Cox | 839a684 | 2009-01-20 14:40:40 -0800 | [diff] [blame] | 25 | type S struct { |
Russ Cox | b4f8e01 | 2008-10-08 09:21:57 -0700 | [diff] [blame] | 26 | } |