[
https://issues.apache.org/jira/browse/GROOVY-7880?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15415250#comment-15415250
]
ASF GitHub Bot commented on GROOVY-7880:
----------------------------------------
GitHub user paulk-asert opened a pull request:
https://github.com/apache/groovy/pull/382
GROOVY-7880: Diamond Operator for own class causes NullPointerExcepti…
…on if Static Compilation is enabled
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/paulk-asert/groovy groovy7880
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/groovy/pull/382.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 #382
----
commit 9a9b039c26826c326dd539cbfee78a3650a7d98e
Author: paulk <[email protected]>
Date: 2016-08-10T13:07:01Z
GROOVY-7880: Diamond Operator for own class causes NullPointerException if
Static Compilation is enabled
----
> Diamond Operator for own class causes NullPointerException if Static
> Compilation is enabled
> -------------------------------------------------------------------------------------------
>
> Key: GROOVY-7880
> URL: https://issues.apache.org/jira/browse/GROOVY-7880
> Project: Groovy
> Issue Type: Bug
> Components: Compiler, Static compilation, Static Type Checker
> Affects Versions: 2.4.3, 2.4.7
> Environment: Test Machine 1: ArchLinux x64,
> openjdk version "1.8.0_92"
> OpenJDK Runtime Environment (build 1.8.0_92-b14)
> OpenJDK 64-Bit Server VM (build 25.92-b14, mixed mode)
> Test Machine 2: MacOSX 10.11.3
> Oracle Java Version: 1.8.0_05
> Reporter: Roman Leuprecht
> Priority: Minor
>
> When the diamond operator is used to instantiate a generic and the generic is
> specialized on the class the method is in, static compilation fails with a
> Nullpointer Exception. Dynamic compilation works, also replacing the diamond
> operator with the exact type or using "raw" typing.
> The following code reproduces the bug on both machines(listed in Environment):
> {code:java}
> import groovy.transform.CompileStatic
> @CompileStatic
> class BugTest {
> private class CompilerKiller<T> {
> private T t
> public CompilerKiller(T t){
> this.t = t
> }
> }
> public void "This causes a NPE"(){
> CompilerKiller<BugTest> sample = new CompilerKiller<>(this)
> }
> public void "This causes a NPE as well"(){
> CompilerKiller<BugTest> sample = new CompilerKiller<>(new BugTest())
> }
> public void "This does work"(){
> CompilerKiller<BugTest> sample = new CompilerKiller<BugTest>(this)
> }
> public void "This works as well"(){
> CompilerKiller<BugTest> sample = new CompilerKiller(this)
> }
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)