Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-10309

Improper type variable substitution when involving type parameters with conficting names

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 4.0.0-beta-2
    • Static Type Checker
    • None

    Description

      I have the following code

      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);
        }
      }
      

      Actual behaviour

      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
      

      Expected behaviour

      Compile successfully

      Tested against master

      Attachments

        Activity

          People

            emilles Eric Milles
            theosot Thodoris Sotiropoulos
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: