Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: reduce amount of scalac dependencies #2048

Merged
merged 1 commit into from
Aug 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ lazy val core = projectMatrix
googleDiff,
metaconfig,
scalametaFor3Use2_13,
semanticdbScalacCore,
semanticdbSharedFor3Use2_13,
collectionCompat
)
)
Expand All @@ -95,8 +95,7 @@ lazy val core3 = project
metaconfig
) ++ Seq(
scalametaFor3Use2_13,
// CrossVersion.for3Use2_13 would only lookup a binary version artifact, but this is published with full version
semanticdbScalacCore.cross(CrossVersion.constant(scala213))
semanticdbSharedFor3Use2_13
).map { mod =>
mod
.exclude("com.lihaoyi", "sourcecode_2.13")
Expand Down Expand Up @@ -149,6 +148,7 @@ lazy val reflect = projectMatrix
moduleName := "scalafix-reflect",
isFullCrossVersion,
libraryDependencies ++= Seq(
semanticdbScalacCore,
Copy link
Collaborator Author

@bjaglin bjaglin Aug 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated to this PR, but this change highlights a limitation: I wonder how much of the current implementation of GlobalSymbolTable works against class files produced by dotty.... We haven't got any issue but I guess it's just because the Symbol lookup API is not used much on symbols that are not in the document, or maybe it's mostly on Java and Scala standard library classes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"org.scala-lang" % "scala-compiler" % scalaVersion.value,
"org.scala-lang" % "scala-reflect" % scalaVersion.value
)
Expand All @@ -165,8 +165,14 @@ lazy val reflect3 = project
isFullCrossVersion,
noPublishAndNoMima,
scalaVersion := scala3LTS,
libraryDependencies +=
libraryDependencies ++= Seq(
// CrossVersion.for3Use2_13 would only lookup a binary version artifact, but this is published with full version
semanticdbScalacCore
.cross(CrossVersion.constant(scala213))
.exclude("com.lihaoyi", "sourcecode_2.13")
.exclude("org.scala-lang.modules", "scala-collection-compat_2.13"),
"org.scala-lang" %% "scala3-compiler" % scalaVersion.value
)
)
.dependsOn(core3)

Expand Down
1 change: 1 addition & 0 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ object Dependencies {
val scalatest = "org.scalatest" %% "scalatest" % scalatestV
val munit = "org.scalameta" %% "munit" % munitV
val semanticdbScalacCore = "org.scalameta" % "semanticdb-scalac-core" % scalametaV cross CrossVersion.full
val semanticdbSharedFor3Use2_13 = "org.scalameta" % "semanticdb-shared" % scalametaV cross CrossVersion.for3Use2_13
Copy link
Collaborator Author

@bjaglin bjaglin Aug 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


// scala-steward:off

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package scala.meta.internal.symtab
Copy link
Collaborator Author

@bjaglin bjaglin Aug 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/scalameta/scalameta/blob/v4.9.9/semanticdb/scalac/library/src/main/scala/scala/meta/internal/symtab/SymbolTable.scala

I am not super happy about this hack, since eventual drift between this version and the upstream one will cause runtime errors in reflect and cli, but for the foreseeable future tests should pick that up and I think it's worth it to keep core clean until we contractualize with scalameta what could be exposed as a public API.


import scala.meta.internal.semanticdb.SymbolInformation

trait SymbolTable {

/**
* Returns the SymbolInformation for the given symbol, or None if the symbol
* is missing.
*/
def info(symbol: String): Option[SymbolInformation]

}