paulk-asert commented on PR #2353:
URL: https://github.com/apache/groovy/pull/2353#issuecomment-3688751632

   This seems good to me. I was previously using a testcase like below:
   
   ```
   import groovy.transform.*
   
   class Foo extends AbstractCollection {
       def peek() { 3 }
       int size() { -1 }
       void clear() { }
       Iterator iterator() { null }
   }
   
   @CompileStatic
   def method(idx) {
       def component = idx == 1 ? new ArrayDeque() : new Stack()
       if (idx == 3) component = new Foo()
       component.clear() // 'clear' in LUB (AbstractCollection or Serializable 
or Cloneable)
       if (component instanceof ArrayDeque) {
           component.addFirst(1) // 'addFirst' only in ArrayDeque
       } else if (component instanceof Stack) {
           component.addElement(2) // 'addElement' only in Stack
       }
       if (component instanceof Foo || component instanceof ArrayDeque || 
component instanceof Stack) {
           // checked duck typing
           assert component.peek() in 1..3 // 'peek' in ArrayDeque and Stack 
but not LUB
       }
   }
   method(1)
   method(2)
   method(3)
   ```
   
   Do you think that is already covered by existing cases?
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to