codeconsole commented on PR #3090:
URL: https://github.com/apache/groovy/pull/3090#issuecomment-6526951328

   @daniellansun
   
   1. Either order. The only textual conflict with #3089 was that both PRs 
appended a test at the end of `ClosuresStaticCompileTest`; this PR now adds its 
test earlier in the file (e608a44e04), and `git merge-tree` merges the two 
branches cleanly both ways, to the same tree. Neither depends on the other's 
tests: on a merge of both, the `groovy.transform.stc` and 
`org.codehaus.groovy.classgen.asm.sc` packages pass. The STC metadata does not 
overlap: this PR records PARAMETER_TYPE on a named constructor argument's key, 
#3089 on call arguments. A closure assigned to a property becomes a cast here 
before the setter call is written, so #3089's writer sees an argument of the 
interface type and does not convert it again.
   
   2. Intentional. A Closure already is a `Runnable`, a `Callable` and a 
`GroovyCallable`, and `DefaultTypeTransformation.castToType` returns an object 
unchanged when it is an instance of the target type, so a cast would leave the 
Closure anyway; the check only skips a cast that does nothing. That is also 
what an assignment to a `Callable` variable and dynamic Groovy do. 
`ClosuresSTCTest.testClosureAssignedToACallableOrRunnableSubscriptOrPropertyStaysAClosure`
 assigns closures to a `Callable` subscript, property and named constructor 
argument and a `Runnable` property, and checks each stays a Closure and works, 
under `@TypeChecked` and `@CompileStatic` (8b73244656). Added a sentence to the 
description.
   
   3. Added 
`ClosuresSTCTest.testValueAssignedToAFunctionalSubscriptOrPropertyIsStoredAsItIsIfNotAClosure`:
 a `Supplier` variable, a method returning a `Supplier`, and an Elvis and a 
conditional whose branches are such values, assigned to a subscript and a 
property of type `Supplier`. Each stored value is the same object as the 
right-hand side, under `@TypeChecked` and `@CompileStatic` alike (8b73244656).
   
   Also merged master. The test changes are the only changes in this round; the 
Checkstyle and CodeNarc gates pass.
   


-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to