[jira] [Commented] (TINKERPOP-3015) Use wildcard instead of Object for hasId predicates
[ https://issues.apache.org/jira/browse/TINKERPOP-3015?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17876107#comment-17876107 ] Christopher Smith commented on TINKERPOP-3015: -- Commenting because I'm still running into this problem in new code with 3.7.2; I get the following compilation error (which correctly implements the generic semantics): {code} [Static type checking] - Cannot call org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal#hasId(org.apache.tinkerpop.gremlin.process.traversal.P) with arguments [org.apache.tinkerpop.gremlin.process.traversal.P] {code} > Use wildcard instead of Object for hasId predicates > --- > > Key: TINKERPOP-3015 > URL: https://issues.apache.org/jira/browse/TINKERPOP-3015 > Project: TinkerPop > Issue Type: Improvement > Components: process >Affects Versions: 3.5.7, 3.6.5 >Reporter: Christopher Smith >Priority: Minor > > From both {{GraphTraversal}} and {{__}}, the {{hasId(P)}} steps specify a > {{P}}. Common predicates, such as {{within}}, propagate the generic > type from their own arguments, so that this produces a compile-time error: > {code} > Collection ids = ... > g.V().hasId(P.within(ids)) > {code} > I believe that without loss of safety, the signature in both locations could > be changed to {{P}}, making the typical case of "here's a collection of > IDs of known type" work smoothly. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (TINKERPOP-3015) Use wildcard instead of Object for hasId predicates
[ https://issues.apache.org/jira/browse/TINKERPOP-3015?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17798360#comment-17798360 ] Christopher Smith commented on TINKERPOP-3015: -- That's exactly what I meant: The _implementation_ has a (kinda hacky) check to see if it is, but the actual API specification says that that method, which has a binary name, does something else. Updating the signature from {{P}} to {{P}} would align the specification and the ABI correctly. > Use wildcard instead of Object for hasId predicates > --- > > Key: TINKERPOP-3015 > URL: https://issues.apache.org/jira/browse/TINKERPOP-3015 > Project: TinkerPop > Issue Type: Improvement >Affects Versions: 3.5.7, 3.6.5 >Reporter: Christopher Smith >Priority: Minor > > From both {{GraphTraversal}} and {{__}}, the {{hasId(P)}} steps specify a > {{P}}. Common predicates, such as {{within}}, propagate the generic > type from their own arguments, so that this produces a compile-time error: > {code} > Collection ids = ... > g.V().hasId(P.within(ids)) > {code} > I believe that without loss of safety, the signature in both locations could > be changed to {{P}}, making the typical case of "here's a collection of > IDs of known type" work smoothly. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (TINKERPOP-3015) Use wildcard instead of Object for hasId predicates
[ https://issues.apache.org/jira/browse/TINKERPOP-3015?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17798353#comment-17798353 ] Valentyn Kahamlyk commented on TINKERPOP-3015: -- now it's equivalent https://github.com/apache/tinkerpop/blob/master/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.java#L2382 > Use wildcard instead of Object for hasId predicates > --- > > Key: TINKERPOP-3015 > URL: https://issues.apache.org/jira/browse/TINKERPOP-3015 > Project: TinkerPop > Issue Type: Improvement >Affects Versions: 3.5.7, 3.6.5 >Reporter: Christopher Smith >Priority: Minor > > From both {{GraphTraversal}} and {{__}}, the {{hasId(P)}} steps specify a > {{P}}. Common predicates, such as {{within}}, propagate the generic > type from their own arguments, so that this produces a compile-time error: > {code} > Collection ids = ... > g.V().hasId(P.within(ids)) > {code} > I believe that without loss of safety, the signature in both locations could > be changed to {{P}}, making the typical case of "here's a collection of > IDs of known type" work smoothly. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (TINKERPOP-3015) Use wildcard instead of Object for hasId predicates
[ https://issues.apache.org/jira/browse/TINKERPOP-3015?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17798300#comment-17798300 ] Christopher Smith commented on TINKERPOP-3015: -- There exists a compilation error with that exact code in 3.5, and I suspect it also exists in 3.6 and 3.7. Specifically, even if your code words by coincidence, I believe inspecting the generated bytecode (e.g., with {{javap -v}}) will show that the wrong overload is being selected. {code}Collection asString = List.of("a", "b"); @SuppressWarnings({ "unchecked", "rawtypes" }) Collection asObject = (Collection) asString; gts.V().hasId(P.within(asString)).iterate(); gts.V().hasId(P.within(asObject)).iterate(); {code} correctly produces the following bytecode snippet, where you can see that the invocation of {{hasId(P)}} is resolved to {{hasId(Object, Object...)}} {code} #60 = InterfaceMethodref #61.#63 // org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.hasId:(Ljava/lang/Object;[Ljava/lang/Object;)Lorg/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal; #61 = Class #62 // org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal #62 = Utf8 org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal #63 = NameAndType#64:#65 // hasId:(Ljava/lang/Object;[Ljava/lang/Object;)Lorg/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal; #64 = Utf8 hasId #65 = Utf8 (Ljava/lang/Object;[Ljava/lang/Object;)Lorg/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal; #66 = InterfaceMethodref #61.#67 // org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.iterate:()Lorg/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal; #67 = NameAndType#68:#69 // iterate:()Lorg/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal; #68 = Utf8 iterate #69 = Utf8 ()Lorg/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal; #70 = InterfaceMethodref #61.#71 // org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.hasId:(Lorg/apache/tinkerpop/gremlin/process/traversal/P;)Lorg/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal; {code} The fact that this produces the desired results in the current implementation is an implementation detail and not guaranteed by the API semantics. > Use wildcard instead of Object for hasId predicates > --- > > Key: TINKERPOP-3015 > URL: https://issues.apache.org/jira/browse/TINKERPOP-3015 > Project: TinkerPop > Issue Type: Improvement >Affects Versions: 3.5.7, 3.6.5 >Reporter: Christopher Smith >Priority: Minor > > From both {{GraphTraversal}} and {{__}}, the {{hasId(P)}} steps specify a > {{P}}. Common predicates, such as {{within}}, propagate the generic > type from their own arguments, so that this produces a compile-time error: > {code} > Collection ids = ... > g.V().hasId(P.within(ids)) > {code} > I believe that without loss of safety, the signature in both locations could > be changed to {{P}}, making the typical case of "here's a collection of > IDs of known type" work smoothly. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (TINKERPOP-3015) Use wildcard instead of Object for hasId predicates
[ https://issues.apache.org/jira/browse/TINKERPOP-3015?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17786480#comment-17786480 ] Valentyn Kahamlyk commented on TINKERPOP-3015: -- Could you share code example with compilation error? For me works without issues with latest 3.6.x and 3.7.x {code:java} Graph graph = TinkerFactory.createModern(); GraphTraversalSource g = graph.traversal(); Collection ids = Arrays.asList("1","2","3"); List vertices = g.V().hasId(P.within(ids)).toList(); System.out.println(vertices);{code} > Use wildcard instead of Object for hasId predicates > --- > > Key: TINKERPOP-3015 > URL: https://issues.apache.org/jira/browse/TINKERPOP-3015 > Project: TinkerPop > Issue Type: Improvement >Affects Versions: 3.5.7, 3.6.5 >Reporter: Christopher Smith >Priority: Minor > > From both {{GraphTraversal}} and {{__}}, the {{hasId(P)}} steps specify a > {{P}}. Common predicates, such as {{within}}, propagate the generic > type from their own arguments, so that this produces a compile-time error: > {code} > Collection ids = ... > g.V().hasId(P.within(ids)) > {code} > I believe that without loss of safety, the signature in both locations could > be changed to {{P}}, making the typical case of "here's a collection of > IDs of known type" work smoothly. -- This message was sent by Atlassian Jira (v8.20.10#820010)