in Scala backend and Scala Parser, should `object`...
# general
m
in Scala backend and Scala Parser, should
object
always be treated as recursive provided type, like jvm_artifact? The reason for this,
object
in scala can extend another
object
, Pants' Scala Parser has no way to know that object is providing more types than the actual code in it.
w
in order to subclass the other
object
, it needs to be imported, right? in that case, it should already be detected as a dependency of the file, which makes it available to consumers
scalac compilation currently uses transitive dependencies, unlike java. javac uses only direct dependencies because of export types: https://blog.pantsbuild.org/automatically-unlocking-concurrent-builds-and-fine-grained-caching-on-the-jvm-with-dependency-inference/#exporttypes … which we haven’t implemented for scala yet (https://github.com/pantsbuild/pants/issues/13836)
m
the extended object is detected, the problem is, all the provided symbols of the subclass are not recognized as provided symbols of the object.
for example: File A:
Copy code
object A {
  def a(x: Int): Int = ???
}
File B:
Copy code
import A

object B extends A {
  
}
File Main:
Copy code
import B.a

def main() = println(a(5))
the above won't compile at the moment, because pants scala-parser cannot find the symbol
B.a
w
mm, indeed… that’s probably the case for all inheritance currently, not just `object`s. cc @fast-nail-55400, @ancient-vegetable-10556
while the producer of the symbol could be made recursive, the consumer could also be made more lenient… by essentially declaring a dependency on both
B.a
and
B
when it encounters
B.a
but… yea, actually. having
class
or
object
declare themselves as recursive probably makes sense? they own that namespace. but that seems quite similar to not having symbol level awareness… Java doesn’t currently: https://github.com/pantsbuild/pants/issues/13765 . i’d need to page back in why we felt that symbol level awareness was necessary in the first place.
m
I think only objects provide symbols at the moment. Classes only consume them.