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

@TypedChecked error when using generics

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.1.0
    • 2.3.1
    • Static Type Checker
    • None
    • JDK 1.6.0.32, MVN 3.0.3, Groovy 2.1

    Description

      Type checking in Groovy 2.1 seems to have issues with "extended" Generics, see sample below, which makes use use explicit cast though we should not need to:

      abstract class ComponentAdapter<Fixture extends ComponentFixture> {
      
      	Fixture getFixture() {
              return fixture;
          }
      }
      
      abstract class ContainerAdapter<Fixture extends ContainerFixture> extends ComponentAdapter<Fixture> {
      
      }
      	
      @TypeChecked	
      class ButtonComponent extends ComponentAdapter<JButtonFixture> implements Clickable {	
      
      	void setFixtureResolver(final ContainerAdapter<? extends ContainerFixture> containerAdapter) {
              final ContainerFixture containerFixture   = (ContainerFixture)containerAdapter.getFixture(); //OK
      		final ContainerFixture containerFixture   = containerAdapter.getFixture(); //NOK ... see below
          }
      }
      
      [ERROR] D:\SVN\PROTECT\2200_Test_Development\cats-framework\trunk\cats-agents\cats-agent-festswing-scripting\src\main\groovy\scripts\agent\festswing\adapter\controller\component\ButtonComponent.groovy
      : 102: [Static type checking] - Cannot assign value of type org.fest.swing.fixture.ComponentFixture <org.fest.swing.fixture.ContainerFixture extends org.fest.swing.fixture.ContainerFixture> to variabl
      e of type org.fest.swing.fixture.ContainerFixture
      [ERROR] @ line 102, column 53.
      [ERROR] rFixture containerFixture   = containerA
      [ERROR] ^
      [ERROR]
      [ERROR] 1 error
      [ERROR] -> [Help 1]
      

      Attachments

        Activity

          People

            blackdrag Jochen Theodorou
            rpodlas Rainer Podlas
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: