groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul King (JIRA)" <j...@apache.org>
Subject [jira] [Closed] (GROOVY-8176) tap - exception in phase 'instruction selection'
Date Mon, 12 Jun 2017 00:13:21 GMT

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

Paul King closed GROOVY-8176.
-----------------------------

> tap - exception in phase 'instruction selection'
> ------------------------------------------------
>
>                 Key: GROOVY-8176
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8176
>             Project: Groovy
>          Issue Type: Bug
>          Components: Compiler
>    Affects Versions: 2.5.0-alpha-1
>            Reporter: Cazacu Mihai
>            Assignee: Paul King
>             Fix For: 2.5.0-beta-1
>
>
> {code}
> 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()
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Mime
View raw message