You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Thodoris Sotiropoulos (Jira)" <ji...@apache.org> on 2021/10/15 12:28:00 UTC

[jira] [Updated] (GROOVY-10309) Improper type variable substitution when involving type parameters with conficting names

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

Thodoris Sotiropoulos updated GROOVY-10309:
-------------------------------------------
    Description: 
I have the following code

{code:java}
class A<T, Y> {
  T f1;
  Y f2;
  A(T f1, Y f2) {
    this.f1 = f1;
    this.f2 = f2;
  }

}

class C<T, X> {
  void test() {
    A<X, T> x = new A<X, T>((X) null, (T) null);
  }
}
{code}

h3. Actual behaviour

{code}
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
test.groovy: 23: [Static type checking] - Cannot call A#<init>(X, T) with arguments [X, T]
 @ line 23, column 17.
       A<X, T> x = new A<X, T>((X) null, (T) null);
                   ^

1 error
{code}

h3. Expected behaviour

Compile successfully

Tested against master

  was:
I have the following code

{code:java}
class A<T, Y> {
  T f1;
  Y f2;
  A(T f1, Y f2) {
    this.f1 = f1;
    this.f2 = f2;
  }


}


class B<T> {
  T x;
  B(T x) {
    this.x = x;
  }
}


class C<T, X> {
  void test() {
    A<X, T> x = new A<X, T>((X) null, (T) null);
  }
}
{code}

h3. Actual behaviour

{code}
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
test.groovy: 23: [Static type checking] - Cannot call A#<init>(X, T) with arguments [X, T]
 @ line 23, column 17.
       A<X, T> x = new A<X, T>((X) null, (T) null);
                   ^

1 error
{code}

h3. Expected behaviour

Compile successfully

Tested against master


> Improper type variable substitution when involving type parameters with conficting names
> ----------------------------------------------------------------------------------------
>
>                 Key: GROOVY-10309
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10309
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static Type Checker
>            Reporter: Thodoris Sotiropoulos
>            Priority: Major
>
> I have the following code
> {code:java}
> class A<T, Y> {
>   T f1;
>   Y f2;
>   A(T f1, Y f2) {
>     this.f1 = f1;
>     this.f2 = f2;
>   }
> }
> class C<T, X> {
>   void test() {
>     A<X, T> x = new A<X, T>((X) null, (T) null);
>   }
> }
> {code}
> h3. Actual behaviour
> {code}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
> test.groovy: 23: [Static type checking] - Cannot call A#<init>(X, T) with arguments [X, T]
>  @ line 23, column 17.
>        A<X, T> x = new A<X, T>((X) null, (T) null);
>                    ^
> 1 error
> {code}
> h3. Expected behaviour
> Compile successfully
> Tested against master



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