You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2018/09/12 11:08:00 UTC
[jira] [Commented] (GROOVY-8703) Unexpected behavior with
@NamedVariant on constructor
[ https://issues.apache.org/jira/browse/GROOVY-8703?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16611918#comment-16611918 ]
ASF GitHub Bot commented on GROOVY-8703:
----------------------------------------
GitHub user paulk-asert opened a pull request:
https://github.com/apache/groovy/pull/795
GROOVY-8703: Unexpected behavior with @NamedVariant on constructor
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/paulk-asert/groovy groovy8703
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/groovy/pull/795.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 #795
----
commit 11234415719573756cc61807385523f1e6aeb534
Author: Paul King <pa...@...>
Date: 2018-09-12T11:05:47Z
GROOVY-8703: Unexpected behavior with @NamedVariant on constructor
----
> Unexpected behavior with @NamedVariant on constructor
> -----------------------------------------------------
>
> Key: GROOVY-8703
> URL: https://issues.apache.org/jira/browse/GROOVY-8703
> Project: Groovy
> Issue Type: Bug
> Affects Versions: 2.5.1
> Reporter: Eric Milles
> Priority: Major
>
> Tried this example and got cast exception converting Map to Integer. Should the print statement at the end use the generated map constructor as expected? (Note: I am compiling with indy variant; tried to use web console to try vanilla MOP...)
> {code:groovy}
> import groovy.transform.*
> import groovy.transform.options.*
> @ToString(includeNames=true)
> class Color {
> final Integer r, g, b
> @NamedVariant @VisibilityOptions(Visibility.PUBLIC)
> private Color(Integer r, Integer g, Integer b) {
> this.r = r
> this.g = g
> this.b = b
> }
> public static final Color BLACK = new Color(0, 0, 0)
> }
> print(new Color(g:12, b:42, r:12)) // gives org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object '{}' with class 'java.util.LinkedHashMap' to class 'java.lang.Integer'
> {code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)