Source file test/escape_iface_nounified.go

     1  // errorcheck -0 -m -l
     2  //go:build !goexperiment.unified
     3  // +build !goexperiment.unified
     4  
     5  // Copyright 2015 The Go Authors. All rights reserved.
     6  // Use of this source code is governed by a BSD-style
     7  // license that can be found in the LICENSE file.
     8  
     9  package escape
    10  
    11  var sink interface{}
    12  
    13  func dotTypeEscape2() { // #13805, #15796
    14  	{
    15  		i := 0
    16  		j := 0
    17  		var ok bool
    18  		var x interface{} = i // ERROR "i does not escape"
    19  		var y interface{} = j // ERROR "j does not escape"
    20  
    21  		sink = x.(int) // ERROR "x.\(int\) escapes to heap"
    22  		// BAD: should be "y.\(int\) escapes to heap" too
    23  		sink, *(&ok) = y.(int)
    24  	}
    25  }
    26  

View as plain text