@@ -527,6 +527,33 @@ object Build {
527
527
recur(lines, false )
528
528
}
529
529
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
+
530
557
// Settings shared between scala3-compiler and scala3-compiler-bootstrapped
531
558
lazy val commonDottyCompilerSettings = Seq (
532
559
// Note: bench/profiles/projects.yml should be updated accordingly.
@@ -556,7 +583,7 @@ object Build {
556
583
// get libraries onboard
557
584
libraryDependencies ++= Seq (
558
585
" 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,
560
587
" org.jline" % " jline-reader" % " 3.19.0" , // used by the REPL
561
588
" org.jline" % " jline-terminal" % " 3.19.0" ,
562
589
" org.jline" % " jline-terminal-jna" % " 3.19.0" , // needed for Windows
@@ -1140,8 +1167,7 @@ object Build {
1140
1167
// when sbt reads the settings.
1141
1168
Test / test := (LocalProject (" scala3-sbt-bridge-tests" ) / Test / test).value,
1142
1169
1143
- // The `newCompilerInterface` is backward compatible with the `oldCompilerInterface`
1144
- libraryDependencies += Dependencies .newCompilerInterface % Provided
1170
+ libraryDependencies += Dependencies .compilerInterface % Provided
1145
1171
)
1146
1172
1147
1173
// We use a separate project for the bridge tests since they can only be run
@@ -1225,7 +1251,8 @@ object Build {
1225
1251
val mtagsSharedSources = (targetDir ** " *.scala" ).get.toSet
1226
1252
mtagsSharedSources.foreach(f => {
1227
1253
val lines = IO .readLines(f)
1228
- IO .writeLines(f, insertUnsafeNullsImport(lines))
1254
+ val substitutions = (replaceProtobuf(_)) andThen (insertUnsafeNullsImport(_))
1255
+ IO .writeLines(f, substitutions(lines))
1229
1256
})
1230
1257
mtagsSharedSources
1231
1258
} (Set (mtagsSharedSourceJar)).toSeq
0 commit comments