You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Steven Dolg (Issue Comment Edited) (JIRA)" <ji...@apache.org> on 2012/02/06 21:56:59 UTC

[jira] [Issue Comment Edited] (SANDBOX-388) Generic Type inference doesn't work in Eclipse

    [ https://issues.apache.org/jira/browse/SANDBOX-388?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13201572#comment-13201572 ] 

Steven Dolg edited comment on SANDBOX-388 at 2/6/12 8:55 PM:
-------------------------------------------------------------

A quick workaround might be overloading the methods in question, using a type of graph that allows to connect the disobedient generic to Graph in the type parameters of the method header.

Like this:
{noformat}
    public static <V extends Vertex, WE extends WeightedEdge<W>, W, G extends DirectedMutableWeightedGraph<V, WE, W>> FromHeadBuilder<V, WE, W, G> findMaxFlow( G graph )

    public static <V extends Vertex, WE extends WeightedEdge<W>, W, G extends DirectedGraph<V, WE>> FromHeadBuilder<V, WE, W, G> findMaxFlow( G graph )
{noformat}
and this
{noformat}
    public static <V extends Vertex, WE extends WeightedEdge<W>, W, G extends UndirectedMutableWeightedGraph<V, WE, W>> SpanningTreeSourceSelector<V, W, WE, G> minimumSpanningTree( G graph )

    public static <V extends Vertex, WE extends WeightedEdge<W>, W, G extends Graph<V, WE>> SpanningTreeSourceSelector<V, W, WE, G> minimumSpanningTree( G graph )
{noformat}

This fixes all the compile error in my Eclipse (exact same version as mentioned in the issue description).
Not sure if this works everywhere or if it is desirable at all, but I wanted to mention it anyway.
                
      was (Author: steven.dolg):
    A quick workaround might be overloading the methods in question, using a type of graph that allows to mention the disobedient generic in the type parameters of the method header.

Like this:
{noformat}
    public static <V extends Vertex, WE extends WeightedEdge<W>, W, G extends DirectedMutableWeightedGraph<V, WE, W>> FromHeadBuilder<V, WE, W, G> findMaxFlow( G graph )

    public static <V extends Vertex, WE extends WeightedEdge<W>, W, G extends DirectedGraph<V, WE>> FromHeadBuilder<V, WE, W, G> findMaxFlow( G graph )
{noformat}
and this
{noformat}
    public static <V extends Vertex, WE extends WeightedEdge<W>, W, G extends UndirectedMutableWeightedGraph<V, WE, W>> SpanningTreeSourceSelector<V, W, WE, G> minimumSpanningTree( G graph )

    public static <V extends Vertex, WE extends WeightedEdge<W>, W, G extends Graph<V, WE>> SpanningTreeSourceSelector<V, W, WE, G> minimumSpanningTree( G graph )
{noformat}

This fixes all the compile error in my Eclipse (exact same version as mentioned in the issue description).
Not sure if this works everywhere or if it is desirable at all, but I wanted to mention it anyway.
                  
> Generic Type inference doesn't work in Eclipse
> ----------------------------------------------
>
>                 Key: SANDBOX-388
>                 URL: https://issues.apache.org/jira/browse/SANDBOX-388
>             Project: Commons Sandbox
>          Issue Type: Bug
>          Components: Graph
>         Environment: Eclipse Java EE IDE for Web Developers.
> Version: Indigo Service Release 1
> Build id: 20110916-0149
>            Reporter: Simone Tripodi
>            Priority: Blocker
>
> {{Flow}} and {{MST}} EDSL is affected by generic type inference issue, it simply doesn't work in Eclipse. It works in IDEA, but in the Eclipse forum they reported that doesn't work if the code is compiled with Oracle JDK7.
> One of the reported error in Eclipse is:
> {quote}
> Type mismatch: cannot convert from SpanningTree<BaseLabeledVertex,BaseLabeledWeightedEdge<Double>,Object> to SpanningTree<BaseLabeledVertex,BaseLabeledWeightedEdge<Double>,Double>
> {quote}
> Looking for a solution

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira