ancient-vegetable-10556
11/30/2021, 11:07 PMancient-vegetable-10556
11/30/2021, 11:08 PMjava.util.function
is always an implicit dependency):
return java.util.function.Function.identity().apply("Hello, World!");
ancient-vegetable-10556
11/30/2021, 11:10 PMjava.util
and java.util.function
and java.util.function.Function
are all “field access” expressions, so it’s not immediately clear at which point an actual type is accessed.
I could theoretically make it output java
, java.util
, java.util.function
and java.util.function.Function
as consumed types, but it’s not clear to me if this is wasteful. (cc @fast-nail-55400 @witty-crayon-22786)witty-crayon-22786
11/30/2021, 11:12 PMancient-vegetable-10556
11/30/2021, 11:13 PMwitty-crayon-22786
11/30/2021, 11:13 PMancient-vegetable-10556
11/30/2021, 11:13 PMancient-vegetable-10556
11/30/2021, 11:14 PMwitty-crayon-22786
11/30/2021, 11:14 PMancient-vegetable-10556
11/30/2021, 11:14 PMwitty-crayon-22786
11/30/2021, 11:14 PMancient-vegetable-10556
11/30/2021, 11:15 PMancient-vegetable-10556
11/30/2021, 11:15 PMwitty-crayon-22786
11/30/2021, 11:15 PMancient-vegetable-10556
11/30/2021, 11:15 PMwitty-crayon-22786
11/30/2021, 11:15 PMwitty-crayon-22786
11/30/2021, 11:16 PMancient-vegetable-10556
11/30/2021, 11:17 PMconsumedType
, and Pants reconciles that with what it knows about the universe of packages and typeswitty-crayon-22786
11/30/2021, 11:17 PMwitty-crayon-22786
11/30/2021, 11:17 PMancient-vegetable-10556
11/30/2021, 11:18 PMjava.util.function.Function
:
java
java.util
java.util.function
java.util.function.Function
witty-crayon-22786
11/30/2021, 11:19 PMancient-vegetable-10556
11/30/2021, 11:19 PMwitty-crayon-22786
11/30/2021, 11:20 PMFunction
?ancient-vegetable-10556
11/30/2021, 11:20 PMancient-vegetable-10556
11/30/2021, 11:20 PMFunction
ancient-vegetable-10556
11/30/2021, 11:20 PMwitty-crayon-22786
11/30/2021, 11:21 PMconsumed_type
of just java.util.function.Function
(ideally)ancient-vegetable-10556
11/30/2021, 11:21 PMwitty-crayon-22786
11/30/2021, 11:21 PMwitty-crayon-22786
11/30/2021, 11:22 PMconsumed_type
would need to become consumed_symbol
instead…?ancient-vegetable-10556
11/30/2021, 11:23 PMjava
is a name, and java.util
. java.util.function
, java.util.function.Function
are _field_s of their respective parent scopeswitty-crayon-22786
11/30/2021, 11:23 PMancient-vegetable-10556
11/30/2021, 11:23 PMwitty-crayon-22786
11/30/2021, 11:24 PMandyea, sure. but calling the whole thing (.java.util
,java.util.function
are _field_s of their respective parent scopesjava.util.function.Function
java.util.function.Function
) a symbol is accurate i think. and that’s what we do for scalawitty-crayon-22786
11/30/2021, 11:24 PMjava.util.function.Function.apply
or whatever other methodsancient-vegetable-10556
11/30/2021, 11:25 PMjava.util.function.Function.identity().apply("Hello, World!");
You can get to java.util.Function
and say that’s a consumed type, probably. If it were inside a nested type, things get more complicatedwitty-crayon-22786
11/30/2021, 11:25 PMjava.util.function.Function.identity
ancient-vegetable-10556
11/30/2021, 11:25 PMwitty-crayon-22786
11/30/2021, 11:25 PMancient-vegetable-10556
11/30/2021, 11:26 PMjava.util.function.Function.identity
doesn’t describe anything we can infer. But j.u.f.F
is something we can infer. If there were a nested class in there, like your enum case, things get considerably more complicatedancient-vegetable-10556
11/30/2021, 11:27 PMwitty-crayon-22786
11/30/2021, 11:27 PMancient-vegetable-10556
11/30/2021, 11:28 PMwitty-crayon-22786
11/30/2021, 11:28 PMfast-nail-55400
11/30/2021, 11:30 PMancient-vegetable-10556
11/30/2021, 11:31 PMfast-nail-55400
11/30/2021, 11:31 PMjava.util.function.Function.identity
, split on .
and then work in reverse and strip off components until reach the first one that starts with a capitalancient-vegetable-10556
11/30/2021, 11:31 PMfast-nail-55400
11/30/2021, 11:32 PMwitty-crayon-22786
11/30/2021, 11:32 PMjava.util.function.Function.identity
, then you’re golden, right?witty-crayon-22786
11/30/2021, 11:33 PMfast-nail-55400
11/30/2021, 11:33 PMorg.pantsbuild.example.Outer.Inner.apply
, maybe generate org.pantsbuild.example.Outer.Inner
and org.pantsbuild.example.Outer
as symbolsancient-vegetable-10556
11/30/2021, 11:33 PMfast-nail-55400
11/30/2021, 11:33 PMancient-vegetable-10556
11/30/2021, 11:33 PMwitty-crayon-22786
11/30/2021, 11:33 PMancient-vegetable-10556
11/30/2021, 11:34 PMwitty-crayon-22786
11/30/2021, 11:34 PMorg.pantsbuild.**
matches org.pantsbuild.example.Outer.Inner.apply
witty-crayon-22786
11/30/2021, 11:34 PMwitty-crayon-22786
11/30/2021, 11:35 PMancient-vegetable-10556
11/30/2021, 11:36 PMwitty-crayon-22786
11/30/2021, 11:37 PMancient-vegetable-10556
11/30/2021, 11:37 PMwitty-crayon-22786
11/30/2021, 11:39 PMwitty-crayon-22786
11/30/2021, 11:39 PMfast-nail-55400
11/30/2021, 11:40 PMancient-vegetable-10556
11/30/2021, 11:40 PMfast-nail-55400
11/30/2021, 11:41 PMwitty-crayon-22786
11/30/2021, 11:41 PMwith…you’re end up multiplying by the number of wildcard imports slash the possibility that something isn’t fully qualified, maybe generateorg.pantsbuild.example.Outer.Inner.apply
andorg.pantsbuild.example.Outer.Inner
as symbolsorg.pantsbuild.example.Outer
ancient-vegetable-10556
11/30/2021, 11:41 PMfast-nail-55400
11/30/2021, 11:42 PMat the moment we only export “Top level types”. Exporting more symbols will deliver more wins with nested types and such, but it’s complicatedwhereas with Scala, I ended up writing it so nested types are exported as “provided symbols” — something that I don’t think I did with Java.
witty-crayon-22786
11/30/2021, 11:42 PMfast-nail-55400
11/30/2021, 11:42 PMancient-vegetable-10556
11/30/2021, 11:44 PMancient-vegetable-10556
11/30/2021, 11:44 PMwitty-crayon-22786
11/30/2021, 11:47 PMwitty-crayon-22786
11/30/2021, 11:48 PMwitty-crayon-22786
11/30/2021, 11:50 PMancient-vegetable-10556
12/01/2021, 4:10 PMancient-vegetable-10556
12/01/2021, 4:52 PMancient-vegetable-10556
12/01/2021, 4:55 PMwitty-crayon-22786
12/01/2021, 5:46 PMwitty-crayon-22786
12/01/2021, 5:46 PMancient-vegetable-10556
12/01/2021, 5:48 PM