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

tap - exception in phase 'instruction selection'

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.5.0-alpha-1
    • Fix Version/s: 2.5.0-beta-1
    • Component/s: Compiler
    • Labels:
      None

      Description

      import groovy.transform.CompileStatic
      
      @CompileStatic
      abstract class Person {
      	String firstName
      	String lastName
      }
      
      @CompileStatic
      class Student extends Person {
      	Set<String> courses
      }
      
      @CompileStatic
      final class Converter {
      	static <P extends Person> P toUser1(P person, Map map) { // ok
      		if (!map) {
      			return person
      		}
      
      		person.firstName = map['firstName']
      		person.lastName = map['lastName']
      		return person
      	}
      
      	static <P extends Person> P toUser2(P person, Map map) { // ok
      		if (!map) {
      			return person
      		}
      
      		person.tap {
      			firstName = map['firstName']
      			lastName = map['lastName']
      		}
      	}
      
      	static <P extends Person> P toUser3(P person, Map map) { // ok
      		person.tap {
      			firstName = map['firstName']
      			lastName = map['lastName']
      		}
      	}
      
      	// Caught: BUG! exception in phase 'instruction selection' in source unit '/reproducer.groovy' unexpected NullpointerException
      	static <P extends Person> P toUser4(P person, Map map) {
      		!map ? person : person.tap {
      			firstName = map['firstName']
      			lastName = map['lastName']
      		}
      	}
      
      	// static Student toStudent(Map map) {
      	// 	!map ? null : toUser4(new Student(), map)
      	// }
      }
      
      @CompileStatic
      class Reproducer {
      	static void reproduce() {
      		Map map = [firstName: 'John', lastName: 'Doe']
      
      		println Converter.toUser1(new Student(), map).dump()
      		println Converter.toUser2(new Student(), map).dump()
      		println Converter.toUser3(new Student(), map).dump()
      		//println Converter.toUser4(new Student(), map).dump()
      		//println Converter.toStudent(map).dump()
      	}	
      }
      
      Reproducer.reproduce()
      

        Issue Links

          Activity

          Hide
          githubbot ASF GitHub Bot added a comment -

          GitHub user paulk-asert opened a pull request:

          https://github.com/apache/groovy/pull/535

          GROOVY-8176: tap - exception in phase 'instruction selection'

          You can merge this pull request into a Git repository by running:

          $ git pull https://github.com/paulk-asert/groovy groovy8176

          Alternatively you can review and apply these changes as the patch at:

          https://github.com/apache/groovy/pull/535.patch

          To close this pull request, make a commit to your master/trunk branch
          with (at least) the following in the commit message:

          This closes #535


          commit 77a428ee8e4dd941ae94aab0ade2161b559b04f9
          Author: paulk <paulk@asert.com.au>
          Date: 2017-05-05T03:36:41Z

          GROOVY-8176: tap - exception in phase 'instruction selection'


          Show
          githubbot ASF GitHub Bot added a comment - GitHub user paulk-asert opened a pull request: https://github.com/apache/groovy/pull/535 GROOVY-8176 : tap - exception in phase 'instruction selection' You can merge this pull request into a Git repository by running: $ git pull https://github.com/paulk-asert/groovy groovy8176 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/groovy/pull/535.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #535 commit 77a428ee8e4dd941ae94aab0ade2161b559b04f9 Author: paulk <paulk@asert.com.au> Date: 2017-05-05T03:36:41Z GROOVY-8176 : tap - exception in phase 'instruction selection'
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user asfgit closed the pull request at:

          https://github.com/apache/groovy/pull/535

          Show
          githubbot ASF GitHub Bot added a comment - Github user asfgit closed the pull request at: https://github.com/apache/groovy/pull/535
          Hide
          paulk Paul King added a comment - - edited

          Proposed PR merged. Thanks for reporting the issue.

          Show
          paulk Paul King added a comment - - edited Proposed PR merged. Thanks for reporting the issue.

            People

            • Assignee:
              paulk Paul King
              Reporter:
              cazacugmihai Cazacu Mihai
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development