You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2021/11/05 16:14:00 UTC

[jira] [Updated] (GROOVY-10347) STC: lowed bound wildcard inference produces false positives

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

Eric Milles updated GROOVY-10347:
---------------------------------
    Description: 
Follow up from GROOVY-10339 and possibly related to GROOVY-10047, GROOVY-9998 and GROOVY-9803.  Consider the following:
{code:groovy}
class Pogo {
  String x
}
class Sorter implements Comparator<Pogo>, Serializable {
  int compare(Pogo p1, Pogo p2) { p1.x <=> p2.x }
}
@groovy.transform.TypeChecked
void test(Pogo[] pogos) {
  List<String> strings = pogos.sort(true, new Sorter()).collect { Pogo pogo ->
    pogo.x
  }
  print strings
}
test(new Pogo(x:'foo'),new Pogo(x:'bar'))
{code}

Current STC has difficulty with multiple type witnesses for the "sort" call, which supplies {{Pogo[]}} for {{T[]}} and {{Sorter}} for {{Comparator<? super T>}}.

  was:
Follow up from GROOVY-10339 and possibly related to GROOVY-10047 and GROOVY-9998.  Consider the following:
{code:groovy}
class Pogo {
  String x
}
class Sorter implements Comparator<Pogo>, Serializable {
  int compare(Pogo p1, Pogo p2) { p1.x <=> p2.x }
}
@groovy.transform.TypeChecked
void test(Pogo[] pogos) {
  List<String> strings = pogos.sort(true, new Sorter()).collect { Pogo pogo ->
    pogo.x
  }
  print strings
}
test(new Pogo(x:'foo'),new Pogo(x:'bar'))
{code}

Current STC has difficulty with multiple type witnesses for the "sort" call, which supplies {{Pogo[]}} for {{T[]}} and {{Sorter}} for {{Comparator<? super T>}}.


> STC: lowed bound wildcard inference produces false positives
> ------------------------------------------------------------
>
>                 Key: GROOVY-10347
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10347
>             Project: Groovy
>          Issue Type: Bug
>            Reporter: Eric Milles
>            Assignee: Eric Milles
>            Priority: Minor
>
> Follow up from GROOVY-10339 and possibly related to GROOVY-10047, GROOVY-9998 and GROOVY-9803.  Consider the following:
> {code:groovy}
> class Pogo {
>   String x
> }
> class Sorter implements Comparator<Pogo>, Serializable {
>   int compare(Pogo p1, Pogo p2) { p1.x <=> p2.x }
> }
> @groovy.transform.TypeChecked
> void test(Pogo[] pogos) {
>   List<String> strings = pogos.sort(true, new Sorter()).collect { Pogo pogo ->
>     pogo.x
>   }
>   print strings
> }
> test(new Pogo(x:'foo'),new Pogo(x:'bar'))
> {code}
> Current STC has difficulty with multiple type witnesses for the "sort" call, which supplies {{Pogo[]}} for {{T[]}} and {{Sorter}} for {{Comparator<? super T>}}.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)