SHARE
TWEET

CompilerBug.groovy

a guest Jun 26th, 2015 194 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.function.Predicate
  2. import groovy.transform.CompileStatic
  3.  
  4. @CompileStatic
  5. class CompilerBug {
  6.  
  7.         void working() {
  8.                 List<String> list = []
  9.                 list + (String) null
  10.                 list + (String) null
  11.                 list + 'foo'
  12.                 list + (String) null
  13.                 list + 'bar'
  14.                 list + (String) null
  15.                
  16.                 assert 6 == list.size()
  17.                 list.removeIf( {it == null} as Predicate )
  18.                 assert 2 == list.size()
  19.         }
  20.  
  21.         void minimalWorking() {
  22.                 ([] as List<String>).removeIf({it == null} as Predicate)
  23.         }
  24.  
  25.         void broken() {
  26.                 List<String> list = []
  27.                 list + (String) null
  28.                 list + (String) null
  29.                 list + 'foo'
  30.                 list + (String) null
  31.                 list + 'bar'
  32.                 list + (String) null
  33.                
  34.                 assert 6 == list.size()
  35.                 list.removeIf( {it == null} as Predicate<?> )
  36.                 assert 2 == list.size()
  37.         }
  38.  
  39.         void minimalBroken() {
  40.                 ([] as List<String>).removeIf({it == null} as Predicate<?>)
  41.         }
  42. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top