groovy
  1. groovy
  2. GROOVY-2503 MOP 2.0 design inflluencing issues
  3. GROOVY-2500

Assignment calls the wrong setter, depending on order of declaration

    Details

    • Type: Sub-task Sub-task
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.5.1
    • Fix Version/s: 2.4.0-beta-4
    • Component/s: groovy-runtime
    • Labels:
      None
    • Environment:
      Windows XP, java 6 update 4, ant 1.7, groovy 1.6 beta 1
    • Number of attachments :
      0

      Description

      The following build.xml fails:

      <?xml version="1.0" encoding="UTF-8"?>
      <project name="test" default="run">
      
      	<path id="groovy.classpath">
      		<fileset dir="." includes="groovy-*.jar"/>
      	</path>
      
      	<taskdef name="groovy" classname="org.codehaus.groovy.ant.Groovy" classpathref="groovy.classpath"/>
      
      	<target name="compile">
      		<echo file="Test.java">
      			public class Test
      			{
      				public void setField( String value )
      				{ 
      					System.out.println( "String" );
      				}
      			
      				public void setField( Integer value )
      				{ 
      					System.out.println( "Integer" );
      				}
      			}
      		</echo>
      		<javac srcdir="." includes="Test.java"/>
      	</target>
      
      	<target name="run" depends="compile">
      		<groovy>
      			try
      			{
      				new Test().setField( "sss" ) // This works
      				println "success 1"
      				new Test().field = "sss" // This gives exception
      				println "success 2"
      			}
      			catch( Exception e )
      			{
      				e.printStackTrace( System.out )
      			}
      		</groovy>
      	</target>
      
      </project>
      

      (you need to put the groovy.jar in the same folder)

      The setField() succeeds, but the assignment fails.

      If I change the order of the two setField() methods, both succeed.

        Issue Links

          Activity

          blackdrag blackdrag made changes -
          Field Original Value New Value
          Link This issue is depended upon by GROOVY-2503 [ GROOVY-2503 ]
          blackdrag blackdrag made changes -
          Priority Critical [ 2 ] Major [ 3 ]
          Fix Version/s 1.5.2 [ 13939 ]
          Affects Version/s 1.5.1 [ 13923 ]
          blackdrag blackdrag made changes -
          Fix Version/s 2.0 [ 13489 ]
          blackdrag blackdrag made changes -
          Link This issue is duplicated by GROOVY-3632 [ GROOVY-3632 ]
          blackdrag blackdrag made changes -
          Link This issue is duplicated by GROOVY-2049 [ GROOVY-2049 ]
          blackdrag blackdrag made changes -
          Parent GROOVY-2503 [ 61571 ]
          Issue Type Bug [ 1 ] Sub-task [ 7 ]
          blackdrag blackdrag made changes -
          Fix Version/s 3.0 [ 13489 ]
          blackdrag blackdrag made changes -
          Component/s groovy-runtime [ 16250 ]
          Cédric Champeau made changes -
          Resolution Fixed [ 1 ]
          Fix Version/s 2.4.0-beta-4 [ 20612 ]
          Assignee Cédric Champeau [ melix ]
          Status Open [ 1 ] Resolved [ 5 ]

            People

            • Assignee:
              Cédric Champeau
              Reporter:
              René de Bloois
            • Votes:
              2 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: