Rémy Oudompheng | 2ece2f5 | 2012-02-18 22:15:42 +0100 | [diff] [blame] | 1 | // run |
Luuk van Dijk | 5ad9e2d | 2012-01-23 16:56:57 +0100 | [diff] [blame] | 2 | |
Emmanuel Odeke | 53fd522 | 2016-04-10 14:32:26 -0700 | [diff] [blame] | 3 | // Copyright 2011 The Go Authors. All rights reserved. |
Luuk van Dijk | 5ad9e2d | 2012-01-23 16:56:57 +0100 | [diff] [blame] | 4 | // Use of this source code is governed by a BSD-style |
| 5 | // license that can be found in the LICENSE file. |
| 6 | |
| 7 | // Issue 2582 |
Russ Cox | ee9bfb0 | 2012-01-25 17:53:50 -0500 | [diff] [blame] | 8 | package main |
| 9 | |
| 10 | type T struct{} |
| 11 | |
Todd Neal | e3e0122 | 2015-10-29 21:45:19 -0500 | [diff] [blame] | 12 | //go:noinline |
Luuk van Dijk | 5ad9e2d | 2012-01-23 16:56:57 +0100 | [diff] [blame] | 13 | func (T) cplx() complex128 { |
Russ Cox | ee9bfb0 | 2012-01-25 17:53:50 -0500 | [diff] [blame] | 14 | return complex(1, 0) |
| 15 | } |
| 16 | |
| 17 | func (T) cplx2() complex128 { |
| 18 | return complex(0, 1) |
Luuk van Dijk | 5ad9e2d | 2012-01-23 16:56:57 +0100 | [diff] [blame] | 19 | } |
| 20 | |
| 21 | type I interface { |
| 22 | cplx() complex128 |
| 23 | } |
| 24 | |
Russ Cox | ee9bfb0 | 2012-01-25 17:53:50 -0500 | [diff] [blame] | 25 | func main() { |
Luuk van Dijk | 5ad9e2d | 2012-01-23 16:56:57 +0100 | [diff] [blame] | 26 | |
Russ Cox | ee9bfb0 | 2012-01-25 17:53:50 -0500 | [diff] [blame] | 27 | var t T |
| 28 | |
| 29 | if v := real(t.cplx()); v != 1 { |
| 30 | panic("not-inlined complex call failed") |
| 31 | } |
| 32 | _ = imag(t.cplx()) |
| 33 | |
| 34 | _ = real(t.cplx2()) |
| 35 | if v := imag(t.cplx2()); v != 1 { |
| 36 | panic("potentially inlined complex call failed") |
| 37 | } |
Luuk van Dijk | 5ad9e2d | 2012-01-23 16:56:57 +0100 | [diff] [blame] | 38 | |
| 39 | var i I |
| 40 | i = t |
Russ Cox | ee9bfb0 | 2012-01-25 17:53:50 -0500 | [diff] [blame] | 41 | if v := real(i.cplx()); v != 1 { |
| 42 | panic("potentially inlined complex call failed") |
| 43 | } |
| 44 | _ = imag(i.cplx()) |
| 45 | } |