Skip to content
This repository has been archived by the owner on Nov 5, 2022. It is now read-only.

CPS transformation should honor the return type signature #12

Closed
kohsuke opened this issue Apr 30, 2015 · 1 comment
Closed

CPS transformation should honor the return type signature #12

kohsuke opened this issue Apr 30, 2015 · 1 comment

Comments

@kohsuke
Copy link
Contributor

kohsuke commented Apr 30, 2015

CPS transformation ignores the declared return type of function, and always treat as if it is typed as Object.

This creates a behaviour difference between normal Groovy code vs CPS-transformed code.

int foo() { return "abc" }
foo();  // compiles fine but at runtime throws ClassCastException

void bar() { 42; }
x=bar(); // runs fine but assigns null

This should be relatively easy by having Continuation check the type of the value (or substitute it by null in case of void methods)

@dwnusbaum
Copy link
Member

I noticed this while working on SECURITY-2824. I added a new test that demonstrates the issue:

@Test public void methodReturnValuesShouldBeCastToDeclaredReturnType() throws Throwable {

I am closing this issue. If anyone comes across this and cares about the behavior, feel free to file a new issue on https://issues.jenkins.io/ with the component set to workflow-cps-plugin, but note that unless you work on it yourself it is very unlikely to ever be fixed.

@dwnusbaum dwnusbaum closed this as not planned Won't fix, can't repro, duplicate, stale Nov 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants