[jira] [Commented] (GROOVY-9204) Compiler loses type info of superclass field

2020-03-11 Thread Daniil Ovchinnikov (Jira)


[ 
https://issues.apache.org/jira/browse/GROOVY-9204?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17057163#comment-17057163
 ] 

Daniil Ovchinnikov commented on GROOVY-9204:


[~katoquro] no. Next time please create another issue, since it will be much 
more easier to mark it as a duplicate if it turns out to be such.

> Compiler loses type info of superclass field
> 
>
> Key: GROOVY-9204
> URL: https://issues.apache.org/jira/browse/GROOVY-9204
> Project: Groovy
>  Issue Type: Bug
>  Components: Static compilation, Static Type Checker
>Affects Versions: 2.5.7
>Reporter: Daniil Ovchinnikov
>Assignee: Daniel Sun
>Priority: Blocker
> Fix For: 3.0.0, 2.5.10
>
>  Time Spent: 1.5h
>  Remaining Estimate: 0h
>
> {code:java|title=foo/bar/classes.java}
> package foo.bar;
> class F {
> void hi() {}
> }
> abstract class Base {
> protected T theField;
> }
> abstract class Middle extends Base {}
> abstract class Concrete extends Middle {}
> {code}
> {code:java|title=foo/bar/GroovyUsage.groovy}
> package foo.bar
> @groovy.transform.CompileStatic
> class GroovyUsage extends Concrete {
> def usage() {
> theField.hi() // Error:(7, 9) Groovyc: [Static type checking] - 
> Cannot find matching method java.lang.Object#hi(). Please check if the 
> declared type is correct and if the method exists.
> }
> }
> {code}
> Note this was working with 2.4.17.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (GROOVY-9204) Compiler loses type info of superclass field

2020-03-11 Thread Andrew Malyhin (Jira)


[ 
https://issues.apache.org/jira/browse/GROOVY-9204?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17057049#comment-17057049
 ] 

Andrew Malyhin commented on GROOVY-9204:


Hello! 

I think I've faced with the similar issue on 2.5.10 when I used apache sshd 

I have this compilation error 
{code:java}
shell/Example.groovy: 26: [Static type checking] - Cannot find matching method 
org.apache.sshd.client.SshClient#connect(org.apache.sshd.client.config.hosts.HostConfigEntry).
 Please check if the declared type is correct and if the method exists.
 @ line 26, column 33.
   ClientSession session = 
ssh.connect(hostConfig).verify(0L).getSession()
{code}
in the next code 

 
{code:java}
package shell

import groovy.transform.CompileStatic
import org.apache.sshd.client.SshClient
import org.apache.sshd.client.config.hosts.HostConfigEntry
import org.apache.sshd.client.session.ClientSession

import java.nio.file.Path

@CompileStatic abstract class Example {

final Path privateKey
final String username
final SshClient ssh

Example(SshClient ssh, Path privateKey, String username) {
this.ssh = ssh
this.privateKey = privateKey
this.username = username
}

protected ClientSession createSession(String host) {
HostConfigEntry hostConfig = new HostConfigEntry("", host, 22, username)
hostConfig.addIdentity(privateKey)

ClientSession session = ssh.connect(hostConfig).verify(0L).getSession()
session.auth().verify(0L)

return session
}
}

{code}
 

Is this the same issue? 

 
 

> Compiler loses type info of superclass field
> 
>
> Key: GROOVY-9204
> URL: https://issues.apache.org/jira/browse/GROOVY-9204
> Project: Groovy
>  Issue Type: Bug
>  Components: Static compilation, Static Type Checker
>Affects Versions: 2.5.7
>Reporter: Daniil Ovchinnikov
>Assignee: Daniel Sun
>Priority: Blocker
> Fix For: 3.0.0, 2.5.10
>
>  Time Spent: 1.5h
>  Remaining Estimate: 0h
>
> {code:java|title=foo/bar/classes.java}
> package foo.bar;
> class F {
> void hi() {}
> }
> abstract class Base {
> protected T theField;
> }
> abstract class Middle extends Base {}
> abstract class Concrete extends Middle {}
> {code}
> {code:java|title=foo/bar/GroovyUsage.groovy}
> package foo.bar
> @groovy.transform.CompileStatic
> class GroovyUsage extends Concrete {
> def usage() {
> theField.hi() // Error:(7, 9) Groovyc: [Static type checking] - 
> Cannot find matching method java.lang.Object#hi(). Please check if the 
> declared type is correct and if the method exists.
> }
> }
> {code}
> Note this was working with 2.4.17.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (GROOVY-9204) Compiler loses type info of superclass field

2019-08-07 Thread Eric Milles (JIRA)


[ 
https://issues.apache.org/jira/browse/GROOVY-9204?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16902173#comment-16902173
 ] 

Eric Milles commented on GROOVY-9204:
-

When trying to resolve the type of the {{theField}} in the method call 
expression, this call returns Object instead of F:

org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitVariableExpression(VariableExpression)
{code:java}
ClassNode actualType =
findActualTypeByGenericsPlaceholderName(
fieldNode.getOriginType().getUnresolvedName(),

makeDeclaringAndActualGenericsTypeMap(fieldNode.getDeclaringClass(), 
typeCheckingContext.getEnclosingClassNode())
);
{code}

> Compiler loses type info of superclass field
> 
>
> Key: GROOVY-9204
> URL: https://issues.apache.org/jira/browse/GROOVY-9204
> Project: Groovy
>  Issue Type: Bug
>  Components: Static compilation, Static Type Checker
>Affects Versions: 2.5.7
>Reporter: Daniil Ovchinnikov
>Priority: Blocker
>
> {code:java|title=foo/bar/classes.java}
> package foo.bar;
> class F {
> void hi() {}
> }
> abstract class Base {
> protected T theField;
> }
> abstract class Middle extends Base {}
> abstract class Concrete extends Middle {}
> {code}
> {code:java|title=foo/bar/GroovyUsage.groovy}
> package foo.bar
> @groovy.transform.CompileStatic
> class GroovyUsage extends Concrete {
> def usage() {
> theField.hi() // Error:(7, 9) Groovyc: [Static type checking] - 
> Cannot find matching method java.lang.Object#hi(). Please check if the 
> declared type is correct and if the method exists.
> }
> }
> {code}
> Note this was working with 2.4.17.



--
This message was sent by Atlassian JIRA
(v7.6.14#76016)