@@ -527,6 +527,33 @@ object Build {
527527 recur(lines, false )
528528 }
529529
530+ /** replace imports of `com.google.protobuf.*` with compiler implemented version */
531+ def replaceProtobuf (lines : List [String ]): List [String ] = {
532+ def recur (ls : List [String ]): List [String ] = ls match {
533+ case l :: rest =>
534+ val lt = l.trim()
535+ if (lt.isEmpty || lt.startsWith(" package " ) || lt.startsWith(" import " )) {
536+ val newLine =
537+ if (lt.startsWith(" import com.google.protobuf." )) {
538+ if (lt == " import com.google.protobuf.CodedInputStream" ) {
539+ " import dotty.tools.dotc.semanticdb.internal.SemanticdbInputStream as CodedInputStream"
540+ } else if (lt == " import com.google.protobuf.CodedOutputStream" ) {
541+ " import dotty.tools.dotc.semanticdb.internal.SemanticdbOutputStream as CodedOutputStream"
542+ } else {
543+ l
544+ }
545+ } else {
546+ l
547+ }
548+ newLine :: recur(rest)
549+ } else {
550+ ls // don't check rest of file
551+ }
552+ case _ => ls
553+ }
554+ recur(lines)
555+ }
556+
530557 // Settings shared between scala3-compiler and scala3-compiler-bootstrapped
531558 lazy val commonDottyCompilerSettings = Seq (
532559 // Note: bench/profiles/projects.yml should be updated accordingly.
@@ -556,7 +583,7 @@ object Build {
556583 // get libraries onboard
557584 libraryDependencies ++= Seq (
558585 " org.scala-lang.modules" % " scala-asm" % " 9.5.0-scala-1" , // used by the backend
559- Dependencies .newCompilerInterface, // we stick to the old version to avoid deprecation warnings
586+ Dependencies .compilerInterface,
560587 " org.jline" % " jline-reader" % " 3.19.0" , // used by the REPL
561588 " org.jline" % " jline-terminal" % " 3.19.0" ,
562589 " org.jline" % " jline-terminal-jna" % " 3.19.0" , // needed for Windows
@@ -1140,8 +1167,7 @@ object Build {
11401167 // when sbt reads the settings.
11411168 Test / test := (LocalProject (" scala3-sbt-bridge-tests" ) / Test / test).value,
11421169
1143- // The `newCompilerInterface` is backward compatible with the `oldCompilerInterface`
1144- libraryDependencies += Dependencies .newCompilerInterface % Provided
1170+ libraryDependencies += Dependencies .compilerInterface % Provided
11451171 )
11461172
11471173 // We use a separate project for the bridge tests since they can only be run
@@ -1225,7 +1251,8 @@ object Build {
12251251 val mtagsSharedSources = (targetDir ** " *.scala" ).get.toSet
12261252 mtagsSharedSources.foreach(f => {
12271253 val lines = IO .readLines(f)
1228- IO .writeLines(f, insertUnsafeNullsImport(lines))
1254+ val substitutions = (replaceProtobuf(_)) andThen (insertUnsafeNullsImport(_))
1255+ IO .writeLines(f, substitutions(lines))
12291256 })
12301257 mtagsSharedSources
12311258 } (Set (mtagsSharedSourceJar)).toSeq
0 commit comments