[ https://issues.apache.org/jira/browse/GROOVY-11065?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Thodoris Sotiropoulos updated GROOVY-11065: ------------------------------------------- Component/s: Static Type Checker > 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 > Components: Static Type Checker > Reporter: Thodoris Sotiropoulos > Priority: Minor > > 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. > The test case adapted from the following program that uses the > apache-commons-lang3 lib. > {code} > import java.util.* > import java.util.function.*; > import org.apache.commons.lang3.concurrent.locks.LockingVisitors.LockVisitor; > import org.apache.commons.lang3.function.FailableFunction; > import org.apache.commons.lang3.concurrent.CircuitBreaker > class Main { > static final <O>void test() { > FailableFunction<PropertyPermission, Collection<? extends Set<O>>, ?> x = > null; > LockVisitor<PropertyPermission, String> rec = null; > final var blandest = rec.applyWriteLocked(x); > TreeSet<Set<O>> y = new java.util.TreeSet<>(blandest) > final Set<O> arg = null; > y.floor(arg) > } > } > {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)