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 2023/04/15 15:54:00 UTC
[jira] [Updated] (GROOVY-10977) STC does not catch the type error when a generic is instantiated with bounded type parameter
[ https://issues.apache.org/jira/browse/GROOVY-10977?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Eric Milles updated GROOVY-10977:
---------------------------------
Priority: Minor (was: Major)
> STC does not catch the type error when a generic is instantiated with bounded type parameter
> --------------------------------------------------------------------------------------------
>
> Key: GROOVY-10977
> URL: https://issues.apache.org/jira/browse/GROOVY-10977
> Project: Groovy
> Issue Type: Bug
> Components: Static Type Checker
> Reporter: Thodoris Sotiropoulos
> Assignee: Eric Milles
> Priority: Minor
>
> Probably this is a regression, because groovyc 4.0.10 catches the error.
> Program:
> {code}
> import java.util.*;
> public class Test {
> public static <T extends Number> void test() {
> List<T> d = null;
> d.add(false);
> }
> }
> {code}
> h3. Actual behavior
> Groovyc compiles the code
> h3. Expected behavior
> Groovyc rejects the code with a message of the form:
> {code}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
> test.groovy: 8: [Static type checking] - Cannot find matching method java.util.List#add(boolean). Please check if the declared type is correct and if the method exists.
> @ line 8, column 7.
> d.add(false);
> ^
> 1 error
> {code}
> Tested against master
--
This message was sent by Atlassian Jira
(v8.20.10#820010)