You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Thodoris Sotiropoulos (Jira)" <ji...@apache.org> on 2023/03/17 11:49:00 UTC
[jira] [Created] (GROOVY-10977) STC does not catch the type error when a generic is instantiated with bounded type parameter
Thodoris Sotiropoulos created GROOVY-10977:
----------------------------------------------
Summary: 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
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)