You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by GitBox <gi...@apache.org> on 2020/08/31 22:35:59 UTC
[GitHub] [groovy] eric-milles opened a new pull request #1359: GROOVY-9635: resolve "V" in T=V; "T" may have been reused as type param
eric-milles opened a new pull request #1359:
URL: https://github.com/apache/groovy/pull/1359
https://issues.apache.org/jira/browse/GROOVY-9635
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [groovy] eric-milles commented on pull request #1359: GROOVY-9635: resolve "V" in T=V; "T" may have been reused as type param
Posted by GitBox <gi...@apache.org>.
eric-milles commented on pull request #1359:
URL: https://github.com/apache/groovy/pull/1359#issuecomment-687158819
Is it because a Number type is never supplied for C?
From: Paul King <no...@github.com>
Sent: Friday, September 4, 2020 1:03 AM
To: apache/groovy <gr...@noreply.github.com>
Cc: Milles, Eric (TR Technology) <er...@thomsonreuters.com>; Author <au...@noreply.github.com>
Subject: Re: [apache/groovy] GROOVY-9635: resolve "V" in T=V; "T" may have been reused as type param (#1359)
The following script fails with a VerifyError with this PR merged:
import java.util.function.Function
@groovy.transform.CompileStatic
class C<R extends Number> {
def <V> V m(Function<C, V> f) { // R from C is confused with R->V from Function
V result = f.apply(this)
return result
}
}
@groovy.transform.CompileStatic
def method() {
def ret = new C().m(new Function<C, String>() {
@Override
String apply(C that) {
return 'foo'
}
})
assert ret == 'foo'
}
method()
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fapache%2Fgroovy%2Fpull%2F1359%23issuecomment-686930325&data=02%7C01%7Ceric.milles%40thomsonreuters.com%7C69b89ffe5a4847092fa308d85098342c%7C62ccb8646a1a4b5d8e1c397dec1a8258%7C0%7C0%7C637347961922283071&sdata=6vNHDl%2B%2B01KImfLmay9X%2BFOaGYNZiBWMzSxMU53QSbo%3D&reserved=0>, or unsubscribe<https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAEKZ3CSQBI52FUBYNSLQEUTSEB7J5ANCNFSM4QRAJSWQ&data=02%7C01%7Ceric.milles%40thomsonreuters.com%7C69b89ffe5a4847092fa308d85098342c%7C62ccb8646a1a4b5d8e1c397dec1a8258%7C0%7C0%7C637347961922293065&sdata=bObBkbDI9AZ9wgdR1oROTPw%2B88tXN2nQMx5glnrGf%2FY%3D&reserved=0>.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [groovy] paulk-asert commented on pull request #1359: GROOVY-9635: resolve "V" in T=V; "T" may have been reused as type param
Posted by GitBox <gi...@apache.org>.
paulk-asert commented on pull request #1359:
URL: https://github.com/apache/groovy/pull/1359#issuecomment-686930325
The following script fails with a `VerifyError` with this PR merged:
```
import java.util.function.Function
@groovy.transform.CompileStatic
class C<R extends Number> {
def <V> V m(Function<C, V> f) { // R from C is confused with R->V from Function
V result = f.apply(this)
return result
}
}
@groovy.transform.CompileStatic
def method() {
def ret = new C().m(new Function<C, String>() {
@Override
String apply(C that) {
return 'foo'
}
})
assert ret == 'foo'
}
method()
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [groovy] eric-milles edited a comment on pull request #1359: GROOVY-9635: resolve "V" in T=V; "T" may have been reused as type param
Posted by GitBox <gi...@apache.org>.
eric-milles edited a comment on pull request #1359:
URL: https://github.com/apache/groovy/pull/1359#issuecomment-687158819
Is it because a Number type is never supplied for C?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [groovy] asfgit closed pull request #1359: GROOVY-9635: resolve "V" in T=V; "T" may have been reused as type param
Posted by GitBox <gi...@apache.org>.
asfgit closed pull request #1359:
URL: https://github.com/apache/groovy/pull/1359
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [groovy] eric-milles edited a comment on pull request #1359: GROOVY-9635: resolve "V" in T=V; "T" may have been reused as type param
Posted by GitBox <gi...@apache.org>.
eric-milles edited a comment on pull request #1359:
URL: https://github.com/apache/groovy/pull/1359#issuecomment-687158819
Is it because a Number type is never supplied for C? I don't get any error. Is there a specific way I can run to get the error?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [groovy] paulk-asert commented on pull request #1359: GROOVY-9635: resolve "V" in T=V; "T" may have been reused as type param
Posted by GitBox <gi...@apache.org>.
paulk-asert commented on pull request #1359:
URL: https://github.com/apache/groovy/pull/1359#issuecomment-687582963
Found it. There was a misnamed metadata key in groovy-contracts. I am surprised more things didn't break, but fixed now in any case.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [groovy] paulk-asert commented on pull request #1359: GROOVY-9635: resolve "V" in T=V; "T" may have been reused as type param
Posted by GitBox <gi...@apache.org>.
paulk-asert commented on pull request #1359:
URL: https://github.com/apache/groovy/pull/1359#issuecomment-687582985
Merged, thanks!
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [groovy] eric-milles commented on pull request #1359: GROOVY-9635: resolve "V" in T=V; "T" may have been reused as type param
Posted by GitBox <gi...@apache.org>.
eric-milles commented on pull request #1359:
URL: https://github.com/apache/groovy/pull/1359#issuecomment-687290137
This is the java decompilation that Groovy Console is producing for the anonymous inner class:
```
@groovy.contracts.Contracted
public class script1599241127913$1 extends java.lang.Object implements java.util.function.Function<C, String>, groovy.lang.GroovyObject {
final script1599241127913 this$0
static final boolean $GCONTRACTS_ENABLED
private static org.codehaus.groovy.reflection.ClassInfo $staticClassInfo
public static transient boolean __$stMC
private transient groovy.lang.MetaClass metaClass
script1599241127913$1(script1599241127913 p0) {
this$0 = p0
super()
metaClass = /*BytecodeExpression*/
}
@java.lang.Override
public java.lang.String apply(C that) {
return 'foo'
}
...
protected void invariant_script1599241127913$1() {
if ( $GCONTRACTS_ENABLED ) {
try {
if (org.apache.groovy.contracts.generation.ContractExecutionTracker.track('script1599241127913$1', 'void invariant_script1599241127913$1()', 'invariant', false)) {
java.lang.Boolean $_gc_result = false
org.apache.groovy.contracts.ViolationTracker.init()
$_gc_result = true
if (!($_gc_result.booleanValue())) {
if (org.apache.groovy.contracts.ViolationTracker.violationsOccurred()) {
try {
org.apache.groovy.contracts.ViolationTracker.rethrowFirst()
}
finally {
org.apache.groovy.contracts.ViolationTracker.deinit()
}
}
}
}
}
finally {
org.apache.groovy.contracts.generation.ContractExecutionTracker.clear('script1599241127913$1', 'void invariant_script1599241127913$1()', 'invariant', false)
}
}
}
...
static {
$GCONTRACTS_ENABLED = org.apache.groovy.contracts.generation.Configurator.checkAssertionsEnabled('script1599241127913$1')
}
@groovy.transform.Generated
public volatile java.lang.Object apply(java.lang.Object param0) {
}
}
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [groovy] eric-milles commented on pull request #1359: GROOVY-9635: resolve "V" in T=V; "T" may have been reused as type param
Posted by GitBox <gi...@apache.org>.
eric-milles commented on pull request #1359:
URL: https://github.com/apache/groovy/pull/1359#issuecomment-687267811
So the issue is somewhere in the anon. inner class created for `Function<C, String>`. When I replace it with closure coercion, I don't get the error. I don't know that this problem didn't exist before these changes.
```groovy
@groovy.transform.CompileStatic
Function<C, String> func() {
/*
new Function<C, String>() {
@Override
String apply(C that) {
return 'foo'
}
}
*/
{ that -> 'foo' } as Function<C, String>
}
```
Here is the error I get. Any idea what "invariant" refers to? Is this coming from the contracts module integration?
```
java.lang.VerifyError: Bad type on operand stack
Exception Details:
Location:
ConsoleScript14$1.invariant_ConsoleScript14$1()V @55: invokevirtual
Reason:
Type 'ConsoleScript14' (current frame, stack[0]) is not assignable to 'java/lang/Boolean'
```
Any idea why I get this error when creating a full distribution and running within Groovy Console and not when running via GroovyShell through the unit tests?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org