You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2021/02/17 03:06:00 UTC
[jira] [Assigned] (GROOVY-9947) Cannot pass numeric constant to a
method with a generic type
[ https://issues.apache.org/jira/browse/GROOVY-9947?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Eric Milles reassigned GROOVY-9947:
-----------------------------------
Assignee: Eric Milles
> Cannot pass numeric constant to a method with a generic type
> ------------------------------------------------------------
>
> Key: GROOVY-9947
> URL: https://issues.apache.org/jira/browse/GROOVY-9947
> Project: Groovy
> Issue Type: Bug
> Components: Static compilation, Static Type Checker
> Affects Versions: 4.0.0-alpha-2
> Reporter: Stefanos Chaliasos
> Assignee: Eric Milles
> Priority: Major
>
> I have the following Groovy program.
> {code:groovy}
> @groovy.transform.TypeChecked
> class Main {
> public static final void main(String[] args) {
> final A<Float> a = new A<Float>()
> a.foo(10)
> a.bar(10) // Fails here
> }
> }
> final class A<T> {
> final void foo(Float x) {}
> final void bar(T x) {}
> }
> {code}
> h2. Actual Behavior
> The program does not compile, and I get the following error.
> {code:java}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
> Main.groovy: 6: [Static type checking] - Cannot call A <Float>#bar(java.lang.Float) with arguments [int]
> @ line 6, column 5.
> a.bar(10)
> ^
> 1 error
> {code}
> h2. Expected Behavior
> Compile successfully.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)