diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index da65d980b706..b8fc6d624997 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -27,10 +27,10 @@ on: - cron: '0 3 * * *' # Every day at 3 AM workflow_dispatch: -# Cancels any in-progress runs within the same group identified by workflow name and GH reference (branch or tag) +# Cancels any in-progress runs within the same group identified by workflow name and GH reference (branch or tag) # For example it would: # - terminate previous PR CI execution after pushing more changes to the same PR branch -# - terminate previous on-push CI run after merging new PR to main +# - terminate previous on-push CI run after merging new PR to main concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} @@ -183,7 +183,7 @@ jobs: uses: actions/checkout@v4 - name: Test - run: sbt ";scala3-bootstrapped/compile; scala3-bootstrapped/testCompilation; scala3-presentation-compiler-bootstrapped/test; scala3-language-server/test" + run: sbt ";scala3-bootstrapped/compile; scala3-bootstrapped/testCompilation; scala3-presentation-compiler/test; scala3-language-server/test" shell: cmd - name: build binary diff --git a/build.sbt b/build.sbt index d6a366305f96..8f4a78338a97 100644 --- a/build.sbt +++ b/build.sbt @@ -29,7 +29,7 @@ val dist = Build.dist val `community-build` = Build.`community-build` val `sbt-community-build` = Build.`sbt-community-build` val `scala3-presentation-compiler` = Build.`scala3-presentation-compiler` -val `scala3-presentation-compiler-bootstrapped` = Build.`scala3-presentation-compiler-bootstrapped` +val `scala3-presentation-compiler-testcases` = Build.`scala3-presentation-compiler-testcases` val sjsSandbox = Build.sjsSandbox val sjsJUnitTests = Build.sjsJUnitTests diff --git a/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala b/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala index c4021f0c9724..8c682971adcb 100644 --- a/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala +++ b/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala @@ -108,6 +108,10 @@ trait TreeInfo[T <: Untyped] { self: Trees.Instance[T] => case _ => tree + def stripNamedArg(tree: Tree) = tree match + case NamedArg(_, arg) => arg + case _ => tree + /** The number of arguments in an application */ def numArgs(tree: Tree): Int = unsplice(tree) match { case Apply(fn, args) => numArgs(fn) + args.length diff --git a/presentation-compiler-testcases/src/tests/macros/20560.scala b/presentation-compiler-testcases/src/tests/macros/20560.scala new file mode 100644 index 000000000000..f72fc473f452 --- /dev/null +++ b/presentation-compiler-testcases/src/tests/macros/20560.scala @@ -0,0 +1,16 @@ +package tests.macros + +import scala.quoted.{Expr, Quotes} + +object Macro20560: + transparent inline def loadJavaSqlDriver: Int = ${ loadJavaSqlDriverImpl } + + private def loadJavaSqlDriverImpl(using Quotes): Expr[42] = + Class.forName("java.sql.Driver") + '{42} + + transparent inline def loadJavaSqlInexisting: Int = ${ loadJavaSqlInexistingImpl } + + private def loadJavaSqlInexistingImpl(using Quotes): Expr[42] = + Class.forName("java.sql.Inexisting") + '{42} diff --git a/presentation-compiler/test/dotty/tools/pc/base/BasePCSuite.scala b/presentation-compiler/test/dotty/tools/pc/base/BasePCSuite.scala index 9249d813a880..ae1e49e068fe 100644 --- a/presentation-compiler/test/dotty/tools/pc/base/BasePCSuite.scala +++ b/presentation-compiler/test/dotty/tools/pc/base/BasePCSuite.scala @@ -25,9 +25,9 @@ import org.junit.runner.RunWith import scala.meta.pc.CompletionItemPriority object TestResources: - val scalaLibrary = BuildInfo.ideTestsDependencyClasspath.map(_.toPath).toSeq + val classpath = BuildInfo.ideTestsDependencyClasspath.map(_.toPath).toSeq val classpathSearch = - ClasspathSearch.fromClasspath(scalaLibrary, ExcludedPackagesHandler.default) + ClasspathSearch.fromClasspath(classpath, ExcludedPackagesHandler.default) @RunWith(classOf[ReusableClassRunner]) abstract class BasePCSuite extends PcAssertions: @@ -38,11 +38,11 @@ abstract class BasePCSuite extends PcAssertions: val executorService: ScheduledExecutorService = Executors.newSingleThreadScheduledExecutor() val testingWorkspaceSearch = TestingWorkspaceSearch( - TestResources.scalaLibrary.map(_.toString) + TestResources.classpath.map(_.toString) ) lazy val presentationCompiler: PresentationCompiler = - val myclasspath: Seq[Path] = TestResources.scalaLibrary + val myclasspath: Seq[Path] = TestResources.classpath val scalacOpts = scalacOptions(myclasspath) val search = new MockSymbolSearch( testingWorkspaceSearch, diff --git a/presentation-compiler/test/dotty/tools/pc/tests/hover/HoverTermSuite.scala b/presentation-compiler/test/dotty/tools/pc/tests/hover/HoverTermSuite.scala index ac42663d929c..2828b946c7c3 100644 --- a/presentation-compiler/test/dotty/tools/pc/tests/hover/HoverTermSuite.scala +++ b/presentation-compiler/test/dotty/tools/pc/tests/hover/HoverTermSuite.scala @@ -596,6 +596,21 @@ class HoverTermSuite extends BaseHoverSuite: |""".stripMargin ) + @Test def `i20560`= + check( + "val re@@s = tests.macros.Macro20560.loadJavaSqlDriver", + """```scala + |val res: Int + |``` + |""".stripMargin + ) + + @Test def `i20560-2`= + check( + "val re@@s = tests.macros.Macro20560.loadJavaSqlInexisting", + "", // crashes in the Macro; no type info + ) + @Test def `import-rename` = check( """ diff --git a/project/Build.scala b/project/Build.scala index b19b1b5440c2..43aaad9c8e56 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -1153,26 +1153,23 @@ object Build { ) lazy val `scala3-presentation-compiler` = project.in(file("presentation-compiler")) - .asScala3PresentationCompiler(NonBootstrapped) - lazy val `scala3-presentation-compiler-bootstrapped` = project.in(file("presentation-compiler")) - .asScala3PresentationCompiler(Bootstrapped) + .withCommonSettings(Bootstrapped) + .dependsOn(`scala3-compiler-bootstrapped`, `scala3-library-bootstrapped`, `scala3-presentation-compiler-testcases` % "test->test") + .settings(presentationCompilerSettings) + .settings(scala3PresentationCompilerBuildInfo) - def scala3PresentationCompiler(implicit mode: Mode): Project = mode match { - case NonBootstrapped => `scala3-presentation-compiler` - case Bootstrapped => `scala3-presentation-compiler-bootstrapped` - } - - def scala3PresentationCompilerBuildInfo(implicit mode: Mode) = + def scala3PresentationCompilerBuildInfo = Seq( ideTestsDependencyClasspath := { - val dottyLib = (dottyLibrary / Compile / classDirectory).value + val testCasesLib = (`scala3-presentation-compiler-testcases` / Compile / classDirectory).value + val dottyLib = (`scala3-library-bootstrapped` / Compile / classDirectory).value val scalaLib = - (dottyLibrary / Compile / dependencyClasspath) + (`scala3-library-bootstrapped` / Compile / dependencyClasspath) .value .map(_.data) .filter(_.getName.matches("scala-library.*\\.jar")) .toList - dottyLib :: scalaLib + testCasesLib :: dottyLib :: scalaLib // Nil }, Compile / buildInfoPackage := "dotty.tools.pc.buildinfo", @@ -1231,6 +1228,10 @@ object Build { ) } + lazy val `scala3-presentation-compiler-testcases` = project.in(file("presentation-compiler-testcases")) + .dependsOn(`scala3-compiler-bootstrapped`) + .settings(commonBootstrappedSettings) + lazy val `scala3-language-server` = project.in(file("language-server")). dependsOn(dottyCompiler(Bootstrapped)). settings(commonBootstrappedSettings). @@ -1959,7 +1960,7 @@ object Build { // FIXME: we do not aggregate `bin` because its tests delete jars, thus breaking other tests def asDottyRoot(implicit mode: Mode): Project = project.withCommonSettings. - aggregate(`scala3-interfaces`, dottyLibrary, dottyCompiler, tastyCore, `scala3-sbt-bridge`, scala3PresentationCompiler). + aggregate(`scala3-interfaces`, dottyLibrary, dottyCompiler, tastyCore, `scala3-sbt-bridge`, `scala3-presentation-compiler`). bootstrappedAggregate(`scala3-language-server`, `scala3-staging`, `scala3-tasty-inspector`, `scala3-library-bootstrappedJS`, scaladoc). dependsOn(tastyCore).