[ 
https://issues.apache.org/jira/browse/GROOVY-11094?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Eric Milles updated GROOVY-11094:
---------------------------------
    Description: 
I have the following program:
{code}
import java.util.*;
import java.util.function.*;

class Bar {
  LinkedList<String> collect(Supplier<String> function) {
    return null;
  }
  List<String> collect(String x, int y, int d) { return null; }
}

class Main {
  static final void test() {
    Bar x = null;
    LinkedList<String> d = x.collect(() -> "fda");
  }
}
{code}

h3. Actual behaviour

{code}
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
test.groovy: 14: [Static type checking] - Cannot assign value of type 
java.util.List<java.lang.String> to variable of type 
java.util.LinkedList<java.lang.String>
 @ line 14, column 28.
       LinkedList<String> d = x.collect(() -> "fda");
                              ^

1 error
{code}

h3. Expected behaviour

Compile successfully

h3. Notes

Tested against master (commit: cac91791764b8f0b3338318248474412f89e3456)

Adapted from:

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

import org.eclipse.collections.api.tuple.primitive.BooleanBooleanPair;
import org.eclipse.collections.api.map.primitive.*;
import org.eclipse.collections.api.factory.map.primitive.*;
import org.eclipse.collections.api.collection.*;
import 
org.eclipse.collections.api.factory.map.primitive.MutableDoubleFloatMapFactory;

class Main {
  static final <G, W>void test() {
    ImmutableObjectDoubleMap<LongFunction<BooleanBooleanPair>> d = null;
    final ImmutableCollection<MutableDoubleFloatMapFactory> x = d.collect((p) 
-> (MutableDoubleFloatMapFactory) null );
  }
}
{code}

  was:
Somewhat related to GROOVY-GROOVY-11002.

I have the following program

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

class Bar {
  LinkedList<String> collect(Supplier<String> function) {
    return null;
  }
  List<String> collect(String x, int y, int d) { return null; }
}

class Main {
  static final void test() {
    Bar x = null;
    LinkedList<String> d = x.collect(() -> "fda");
  }
}
{code}

h3. Actual behaviour

{code}
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
test.groovy: 14: [Static type checking] - Cannot assign value of type 
java.util.List<java.lang.String> to variable of type 
java.util.LinkedList<java.lang.String>
 @ line 14, column 28.
       LinkedList<String> d = x.collect(() -> "fda");
                              ^

1 error
{code}

h3. Expected behaviour

Compile successfully

h3. Notes

Tested against master (commit: cac91791764b8f0b3338318248474412f89e3456)

Adapted from:

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

import org.eclipse.collections.api.tuple.primitive.BooleanBooleanPair;
import org.eclipse.collections.api.map.primitive.*;
import org.eclipse.collections.api.factory.map.primitive.*;
import org.eclipse.collections.api.collection.*;
import 
org.eclipse.collections.api.factory.map.primitive.MutableDoubleFloatMapFactory;

class Main {
  static final <G, W>void test() {
    ImmutableObjectDoubleMap<LongFunction<BooleanBooleanPair>> d = null;
    final ImmutableCollection<MutableDoubleFloatMapFactory> x = d.collect((p) 
-> (MutableDoubleFloatMapFactory) null );
  }
}
{code}


> SAM types not working well along with overloading
> -------------------------------------------------
>
>                 Key: GROOVY-11094
>                 URL: https://issues.apache.org/jira/browse/GROOVY-11094
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static Type Checker
>            Reporter: Thodoris Sotiropoulos
>            Assignee: Eric Milles
>            Priority: Minor
>              Labels: SAM, overloading
>
> I have the following program:
> {code}
> import java.util.*;
> import java.util.function.*;
> class Bar {
>   LinkedList<String> collect(Supplier<String> function) {
>     return null;
>   }
>   List<String> collect(String x, int y, int d) { return null; }
> }
> class Main {
>   static final void test() {
>     Bar x = null;
>     LinkedList<String> d = x.collect(() -> "fda");
>   }
> }
> {code}
> h3. Actual behaviour
> {code}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup 
> failed:
> test.groovy: 14: [Static type checking] - Cannot assign value of type 
> java.util.List<java.lang.String> to variable of type 
> java.util.LinkedList<java.lang.String>
>  @ line 14, column 28.
>        LinkedList<String> d = x.collect(() -> "fda");
>                               ^
> 1 error
> {code}
> h3. Expected behaviour
> Compile successfully
> h3. Notes
> Tested against master (commit: cac91791764b8f0b3338318248474412f89e3456)
> Adapted from:
> {code}
> import java.util.*;
> import java.util.function.*;
> import org.eclipse.collections.api.tuple.primitive.BooleanBooleanPair;
> import org.eclipse.collections.api.map.primitive.*;
> import org.eclipse.collections.api.factory.map.primitive.*;
> import org.eclipse.collections.api.collection.*;
> import 
> org.eclipse.collections.api.factory.map.primitive.MutableDoubleFloatMapFactory;
> class Main {
>   static final <G, W>void test() {
>     ImmutableObjectDoubleMap<LongFunction<BooleanBooleanPair>> d = null;
>     final ImmutableCollection<MutableDoubleFloatMapFactory> x = d.collect((p) 
> -> (MutableDoubleFloatMapFactory) null );
>   }
> }
> {code}



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

Reply via email to