Skip to content

Commit 7017045

Browse files
committed
Do cross version checks on import qualifiers
- keep all imports around until erasure - traverse import qualifiers to do cross version checks on their constituents - fix parts of the build that imported the deprecated package scala.collection.JavaConverters Fixes #15479
1 parent 0059d1d commit 7017045

22 files changed

+49
-26
lines changed

compiler/src/dotty/tools/backend/jvm/GenBCode.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import dotty.tools.dotc.ast.tpd
88
import dotty.tools.dotc.core.Phases.Phase
99

1010
import scala.collection.mutable
11-
import scala.collection.JavaConverters._
11+
import scala.jdk.CollectionConverters._
1212
import dotty.tools.dotc.transform.SymUtils._
1313
import dotty.tools.dotc.interfaces
1414
import dotty.tools.dotc.report
@@ -605,13 +605,13 @@ class GenBCodePipeline(val int: DottyBackendInterface, val primitives: DottyPrim
605605
// Statistics.stopTimer(BackendStats.bcodeWriteTimer, writeStart)
606606
catch
607607
case e: MethodTooLargeException =>
608-
val method =
608+
val method =
609609
s"${e.getClassName.replaceAll("/", ".")}.${e.getMethodName}"
610-
val msg =
611-
s"Generated bytecode for method '$method' is too large. Size: ${e.getCodeSize} bytes. Limit is 64KB"
610+
val msg =
611+
s"Generated bytecode for method '$method' is too large. Size: ${e.getCodeSize} bytes. Limit is 64KB"
612612
report.error(msg)
613613
case e: ClassTooLargeException =>
614-
val msg =
614+
val msg =
615615
s"Class '${e.getClassName.replaceAll("/", ".")}' is too large. Constant pool size: ${e.getConstantPoolCount}. Limit is 64K entries"
616616
report.error(msg)
617617

compiler/src/dotty/tools/dotc/classpath/DirectoryClassPath.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import dotty.tools.io.{AbstractFile, PlainFile, ClassPath, ClassRepresentation,
1414
import FileUtils._
1515
import PlainFile.toPlainFile
1616

17-
import scala.collection.JavaConverters._
17+
import scala.jdk.CollectionConverters._
1818
import scala.collection.immutable.ArraySeq
1919
import scala.util.control.NonFatal
2020

compiler/src/dotty/tools/dotc/config/CommandLineParser.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import scala.annotation.tailrec
44
import scala.collection.mutable.ArrayBuffer
55
import java.lang.Character.isWhitespace
66
import java.nio.file.{Files, Paths}
7-
import scala.collection.JavaConverters._
7+
import scala.jdk.CollectionConverters._
88

99
/** A simple enough command line parser.
1010
*/

compiler/src/dotty/tools/dotc/config/WrappedProperties.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ trait WrappedProperties extends PropertiesTrait {
2222
override def envOrNone(name: String): Option[String] = wrap(super.envOrNone(name)).flatten
2323

2424
def systemProperties: Iterator[(String, String)] = {
25-
import scala.collection.JavaConverters._
25+
import scala.jdk.CollectionConverters._
2626
wrap(System.getProperties.asScala.iterator) getOrElse Iterator.empty
2727
}
2828
}

compiler/src/dotty/tools/dotc/profile/Profiler.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ private [profile] object NoOpProfiler extends Profiler {
8181
override def finished(): Unit = ()
8282
}
8383
private [profile] object RealProfiler {
84-
import scala.collection.JavaConverters._
84+
import scala.jdk.CollectionConverters._
8585
val runtimeMx: RuntimeMXBean = ManagementFactory.getRuntimeMXBean
8686
val memoryMx: MemoryMXBean = ManagementFactory.getMemoryMXBean
8787
val gcMx: List[GarbageCollectorMXBean] = ManagementFactory.getGarbageCollectorMXBeans.asScala.toList

compiler/src/dotty/tools/dotc/semanticdb/Tools.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package dotty.tools.dotc.semanticdb
22

33
import java.nio.file._
44
import java.nio.charset.StandardCharsets
5-
import scala.collection.JavaConverters._
5+
import scala.jdk.CollectionConverters._
66
import dotty.tools.dotc.util.SourceFile
77
import dotty.tools.dotc.semanticdb.Scala3.given
88

compiler/src/dotty/tools/dotc/transform/FirstTransform.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ class FirstTransform extends MiniPhase with InfoTransformer { thisPhase =>
138138
}
139139

140140
override def transformOther(tree: Tree)(using Context): Tree = tree match {
141-
case tree: Import if untpd.languageImport(tree.expr).isEmpty => EmptyTree
142141
case tree: Export => EmptyTree
143142
case tree: NamedArg => transformAllDeep(tree.arg)
144143
case tree => if (tree.isType) toTypeTree(tree) else tree

compiler/src/dotty/tools/dotc/typer/CrossVersionChecks.scala

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class CrossVersionChecks extends MiniPhase:
3333
val xMigrationValue = ctx.settings.Xmigration.value
3434
if xMigrationValue != NoScalaVersion then
3535
checkMigration(sym, pos, xMigrationValue)
36-
36+
end checkUndesiredProperties
3737

3838
/** If @deprecated is present, and the point of reference is not enclosed
3939
* in either a deprecated member or a scala bridge method, issue a warning.
@@ -176,6 +176,15 @@ class CrossVersionChecks extends MiniPhase:
176176
tree
177177
}
178178

179+
override def transformOther(tree: Tree)(using Context): Tree = tree match
180+
case tree: Import =>
181+
tree.foreachSubTree {
182+
case t: RefTree => checkUndesiredProperties(t.symbol, t.srcPos)
183+
case _ =>
184+
}
185+
tree
186+
case _ => tree
187+
179188
end CrossVersionChecks
180189

181190
object CrossVersionChecks:

compiler/src/dotty/tools/repl/ReplDriver.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import org.jline.reader._
3636

3737
import scala.annotation.tailrec
3838
import scala.collection.mutable
39-
import scala.collection.JavaConverters._
39+
import scala.jdk.CollectionConverters._
4040
import scala.util.Using
4141

4242
/** The state of the REPL contains necessary bindings instead of having to have

compiler/test/dotty/tools/TestSources.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import scala.language.unsafeNulls
55
import java.io.File
66
import java.nio.file._
77

8-
import scala.collection.JavaConverters._
8+
import scala.jdk.CollectionConverters._
99

1010
object TestSources {
1111

0 commit comments

Comments
 (0)