main.mx raw

   1  // expected: (unexported method seal)
   2  //
   3  // A same-named method in another package is a DIFFERENT method: Go's method
   4  // identity includes the declaring package for an unexported name, so no type
   5  // outside unexported's package can satisfy its Sealed interface. Legacy reports
   6  // "cannot use &mine{...} ... (unexported method seal)"; stage4 accepted it
   7  // because the method sets matched by name.
   8  package main
   9  
  10  import "tests/restrictions/lib/unexported"
  11  
  12  type mine struct {
  13  	n int32
  14  }
  15  
  16  func (m *mine) seal() (n int32) { return m.n }
  17  
  18  func main() {
  19  	var s unexported.Sealed = &mine{n: 1}
  20  	println(s != nil)
  21  }
  22