eric-milles opened a new pull request, #2353:
URL: https://github.com/apache/groovy/pull/2353

   NOTE: I still have some refactoring to do to make the push/pop/peek 
interactions with the temp type info data structure a bit better.  I thought I 
would get this in front of you to see the solution design.  I also try not to 
use union and intersection to maintain clarity.
   
   see also #1293 and #1269
   
   ```groovy
   if (x instanceof String || x instanceof Number || x instanceof Pattern)
       x.something()
   ```
   
   ```groovy
   switch (x) {
     case String:
     case Number:
     case Pattern:
       x.something()
   }
   ```
   
   Treat both of these cases as typeof(x) is (String | Number | Pattern) for 
STC.  Maybe extend to `catch (Exception | Error e)`.
   
   The `UnionTypeClassNode` represents the any-of type alternatives, as 
described in its javadoc.  So use it for that, not for all-of types.  
`LowestUpperBoundClassNode` is one type that represents (Type & Serializable) 
for example.  I did not want to overload its usage, so I opted to create a 
`ClassNode` instance with abstract modifier, Type as the super class, and 
Serializable as one interface. See `getInferredTypeFromTempInfo`.
   
   The duck-typing is in place for a `UnionTypeClassNode`.  Thus 8965 (Deque 
and Stack peek) keeps working.  I modified the switch case handling to collect 
types together in a union so the temp types list represents the and 
relationship and any element of the list may represent an or relationship (that 
is be an `UnionTypeClassNode`).
   
   When processing a logical-or binary expression, temp types are collected for 
left and right sides.  If an `instanceof` expression appears on either side, a 
(T | U) type is created and added to the temp type list.  The logical-and 
binary expression remanins as before, adding any `instanceof` types from left 
or right expression directly to the temp type list as strong guarantees.


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