Github user daniel-huss commented on a diff in the pull request:

    https://github.com/apache/groovy/pull/643#discussion_r168272512
  
    --- Diff: src/test/groovy/transform/stc/MethodCallsSTCTest.groovy ---
    @@ -383,6 +406,94 @@ class MethodCallsSTCTest extends 
StaticTypeCheckingTestCase {
                 ''', 'Reference to method is ambiguous'
         }
     
    +    void testShouldFailWithMultiplePossibleMethods2() {
    +        shouldFailWithMessages '''
    +                static String foo(String s) {
    +                    'String'
    +                }
    +                static String foo(Integer s) {
    +                    'Integer'
    +                }
    +                static String foo(Boolean s) {
    +                    'Boolean'
    +                }
    +                ['foo',123,true].each { argument ->
    +                    if (argument instanceof String || argument instanceof 
Boolean || argument instanceof Integer) {
    +                        foo(argument)
    +                    }
    +                }
    +            ''', 'Reference to method is ambiguous'
    +    }
    +
    +    void testInstanceOfOnExplicitParameter() {
    +        assertScript '''
    +                1.with { obj ->
    +                    if (obj instanceof String) {
    +                        obj.toUpperCase() 
    +                    }
    +                }
    +            '''
    +    }
    +
    +    void testSAMWithExplicitParameter() {
    +        assertScript '''
    +            public interface SAM {
    +                boolean run(String var1, Thread th);
    +            }
    +            
    +            static boolean foo(SAM sam) {
    +               sam.run("foo",  new Thread())
    +            }
    +            
    +            static def callSAM() {
    +                foo { str, th ->
    +                    str.toUpperCase().equals(th.getName())
    +                }
    +            }
    +            '''
    +    }
    +
    +    void testGroovy8241() {
    +        assertScript '''
    +            import java.util.function.Predicate
    +            
    +            static boolean foo(Predicate<? super String> p) {
    +                p.test("foo")
    +            }
    +            
    +            static def testPredicate() {
    +                foo { it ->
    +                    it.toUpperCase()
    --- End diff --
    
    Oh, you're right. I forgot Groovy's interpretation of <? super X> is simply 
<X> :)


---

Reply via email to