Thodoris Sotiropoulos created GROOVY-11065:
----------------------------------------------

             Summary: STC takes the instantiation of a wrong type variable
                 Key: GROOVY-11065
                 URL: https://issues.apache.org/jira/browse/GROOVY-11065
             Project: Groovy
          Issue Type: Bug
            Reporter: Thodoris Sotiropoulos


I have the following program

{code}
import java.util.*
import java.util.function.*;


class LockVisitor<X> {
  <T> T applyWriteLocked(Function<X, T> func) {return null;}
}

class Main {
  static final <X>void test() {
    Function<PropertyPermission, Collection<? extends X>> func = null;
    LockVisitor<PropertyPermission> rec = null;
    var x = rec.applyWriteLocked(func);

    X arg = null;
    TreeSet<X> y = new java.util.TreeSet<>(x)
    y.floor(arg)
  }
}
{code}

h3. Actual behavior

{code}
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
test.groovy: 17: [Static type checking] - Cannot call 
java.util.TreeSet#floor(java.util.PropertyPermission) with arguments [X]
 @ line 17, column 5.
       y.floor(arg)
       ^

1 error
{code}

h3. Expected behavior

Compile successfully

h3. Notes

Tested against master (commit: 62097da6116edb5d55a72c02c1a33042137e07d7)

The error happens when type variables of class LockVisitor and function "test" 
have the same name.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to