Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(4)

Delta Between Two Patch Sets: test/interface/fail.go

Issue 10255047: code review 10255047: cmd/gc: don't attempt to generate wrappers for blank in... (Closed)
Left Patch Set: diff -r 916cb45c0d5f https://code.google.com/p/go/ Created 11 years, 9 months ago
Right Patch Set: diff -r 372ae572457a https://code.google.com/p/go/ Created 11 years, 8 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « test/interface/explicit.go ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 // run 1 // run
2 2
3 // Copyright 2009 The Go Authors. All rights reserved. 3 // Copyright 2009 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style 4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file. 5 // license that can be found in the LICENSE file.
6 6
7 // Test that interface conversion fails when method is missing. 7 // Test that interface conversion fails when method is missing.
8 8
9 package main 9 package main
10 10
11 type I interface { 11 type I interface {
12 Foo() 12 Foo()
13 } 13 }
14 14
15 func main() { 15 func main() {
16 shouldPanic(p1) 16 shouldPanic(p1)
17 shouldPanic(p2)
17 } 18 }
18 19
19 func p1() { 20 func p1() {
20 var s *S 21 var s *S
21 var i I 22 var i I
22 » var e interface {} 23 » var e interface{}
23 e = s 24 e = s
24 i = e.(I) 25 i = e.(I)
25 _ = i 26 _ = i
26 } 27 }
27 28
28 type S struct { 29 type S struct{}
30
31 func (s *S) _() {}
32
33 type B interface {
34 » _()
35 }
36
37 func p2() {
38 » var s *S
39 » var b B
40 » var e interface{}
41 » e = s
42 » b = e.(B)
43 » _ = b
29 } 44 }
30 45
31 func shouldPanic(f func()) { 46 func shouldPanic(f func()) {
32 defer func() { 47 defer func() {
33 if recover() == nil { 48 if recover() == nil {
34 panic("function should panic") 49 panic("function should panic")
35 } 50 }
36 }() 51 }()
37 f() 52 f()
38 } 53 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b