Skip to content

Do cross version checks on import qualifiers #15489

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

Merged
merged 5 commits into from
Jun 22, 2022
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
2 changes: 1 addition & 1 deletion bench/src/main/scala/Benchmarks.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import org.openjdk.jmh.results.format._
import java.util.concurrent.TimeUnit

import java.io.{File, FileOutputStream, BufferedWriter, FileWriter}
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
import scala.io.Source
import scala.util.Using

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def log(msg: String) = println(Console.GREEN + msg + Console.RESET)

/** Executes shell command, returns false in case of error. */
def exec(projectDir: Path, binary: String, arguments: Seq[String], environment: Map[String, String]): Int =
import collection.JavaConverters._
import scala.jdk.CollectionConverters._
val command = binary +: arguments
log(command.mkString(" "))
val builder = new ProcessBuilder(command: _*).directory(projectDir.toFile).inheritIO()
Expand Down
10 changes: 5 additions & 5 deletions compiler/src/dotty/tools/backend/jvm/GenBCode.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import dotty.tools.dotc.ast.tpd
import dotty.tools.dotc.core.Phases.Phase

import scala.collection.mutable
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
import dotty.tools.dotc.transform.SymUtils._
import dotty.tools.dotc.interfaces
import dotty.tools.dotc.report
Expand Down Expand Up @@ -605,13 +605,13 @@ class GenBCodePipeline(val int: DottyBackendInterface, val primitives: DottyPrim
// Statistics.stopTimer(BackendStats.bcodeWriteTimer, writeStart)
catch
case e: MethodTooLargeException =>
val method =
val method =
s"${e.getClassName.replaceAll("/", ".")}.${e.getMethodName}"
val msg =
s"Generated bytecode for method '$method' is too large. Size: ${e.getCodeSize} bytes. Limit is 64KB"
val msg =
s"Generated bytecode for method '$method' is too large. Size: ${e.getCodeSize} bytes. Limit is 64KB"
report.error(msg)
case e: ClassTooLargeException =>
val msg =
val msg =
s"Class '${e.getClassName.replaceAll("/", ".")}' is too large. Constant pool size: ${e.getConstantPoolCount}. Limit is 64K entries"
report.error(msg)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import dotty.tools.io.{AbstractFile, PlainFile, ClassPath, ClassRepresentation,
import FileUtils._
import PlainFile.toPlainFile

import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
import scala.collection.immutable.ArraySeq
import scala.util.control.NonFatal

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import scala.annotation.tailrec
import scala.collection.mutable.ArrayBuffer
import java.lang.Character.isWhitespace
import java.nio.file.{Files, Paths}
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._

/** A simple enough command line parser.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ trait WrappedProperties extends PropertiesTrait {
override def envOrNone(name: String): Option[String] = wrap(super.envOrNone(name)).flatten

def systemProperties: Iterator[(String, String)] = {
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
wrap(System.getProperties.asScala.iterator) getOrElse Iterator.empty
}
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/profile/Profiler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ private [profile] object NoOpProfiler extends Profiler {
override def finished(): Unit = ()
}
private [profile] object RealProfiler {
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
val runtimeMx: RuntimeMXBean = ManagementFactory.getRuntimeMXBean
val memoryMx: MemoryMXBean = ManagementFactory.getMemoryMXBean
val gcMx: List[GarbageCollectorMXBean] = ManagementFactory.getGarbageCollectorMXBeans.asScala.toList
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/semanticdb/Tools.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package dotty.tools.dotc.semanticdb

import java.nio.file._
import java.nio.charset.StandardCharsets
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
import dotty.tools.dotc.util.SourceFile
import dotty.tools.dotc.semanticdb.Scala3.given

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ class FirstTransform extends MiniPhase with InfoTransformer { thisPhase =>
}

override def transformOther(tree: Tree)(using Context): Tree = tree match {
case tree: Import if untpd.languageImport(tree.expr).isEmpty => EmptyTree
case tree: Export => EmptyTree
case tree: NamedArg => transformAllDeep(tree.arg)
case tree => if (tree.isType) toTypeTree(tree) else tree
Expand Down
11 changes: 10 additions & 1 deletion compiler/src/dotty/tools/dotc/typer/CrossVersionChecks.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class CrossVersionChecks extends MiniPhase:
val xMigrationValue = ctx.settings.Xmigration.value
if xMigrationValue != NoScalaVersion then
checkMigration(sym, pos, xMigrationValue)

end checkUndesiredProperties

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

override def transformOther(tree: Tree)(using Context): Tree = tree match
case tree: Import =>
tree.foreachSubTree {
case t: RefTree => checkUndesiredProperties(t.symbol, t.srcPos)
case _ =>
}
tree
case _ => tree

end CrossVersionChecks

object CrossVersionChecks:
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/repl/ReplDriver.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import org.jline.reader._

import scala.annotation.tailrec
import scala.collection.mutable
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
import scala.util.Using

/** The state of the REPL contains necessary bindings instead of having to have
Expand Down
2 changes: 1 addition & 1 deletion compiler/test/dotty/tools/TestSources.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import scala.language.unsafeNulls
import java.io.File
import java.nio.file._

import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._

object TestSources {

Expand Down
2 changes: 1 addition & 1 deletion compiler/test/dotty/tools/backend/jvm/AsmConverters.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import scala.language.unsafeNulls
import scala.tools.asm
import asm._
import asm.tree._
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._

/** Makes using ASM from tests more convenient.
*
Expand Down
2 changes: 1 addition & 1 deletion compiler/test/dotty/tools/backend/jvm/AsmNode.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import java.lang.reflect.Modifier
import scala.tools.asm
import asm._
import asm.tree._
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._

sealed trait AsmNode[+T] {
def node: T
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ import dotty.tools.io.{VirtualDirectory => Directory}
import scala.tools.asm
import asm._
import asm.tree._
import scala.collection.JavaConverters._

import io.{AbstractFile, JavaClassPath, VirtualDirectory}
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
import scala.tools.asm.{ClassWriter, ClassReader}
import scala.tools.asm.tree._
import java.io.{File => JFile, InputStream}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import org.junit.Test

import scala.tools.asm.Opcodes._

import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._

class InlineBytecodeTests extends DottyBytecodeTest {
import ASMConverters._
Expand Down
2 changes: 1 addition & 1 deletion compiler/test/dotty/tools/dotc/CompilationTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import org.junit.experimental.categories.Category
import java.io.File
import java.nio.file._
import java.util.stream.{ Stream => JStream }
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
import scala.util.matching.Regex
import scala.concurrent.duration._
import TestSources.sources
Expand Down
2 changes: 1 addition & 1 deletion compiler/test/dotty/tools/dotc/ConstantFoldingTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import dotty.tools.dotc.config.CompilerCommand
import dotty.tools.dotc.core.Contexts.FreshContext
import scala.tools.asm.tree.MethodNode

import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._

class ConstantFoldingTests extends DottyBytecodeTest {

Expand Down
2 changes: 1 addition & 1 deletion compiler/test/dotty/tools/dotc/TastyBootstrapTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import org.junit.experimental.categories.Category
import java.io.File
import java.nio.file._
import java.util.stream.{ Stream => JStream }
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
import scala.util.matching.Regex
import scala.concurrent.duration._
import TestSources.sources
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import java.util.jar.Attributes.Name
import org.junit.Assert._
import org.junit.Test

import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
import scala.util.Properties

class MultiReleaseJarTest extends dotty.tools.backend.jvm.DottyBytecodeTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import dotty.tools.backend.jvm.DottyBytecodeTest

class SpecializeFunctionsTests extends DottyBytecodeTest {

import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._

@Test def specializeParentIntToInt = {
val source = """
Expand Down
2 changes: 1 addition & 1 deletion compiler/test/dotty/tools/vulpix/SummaryReport.scala
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ final class NoSummaryReport extends SummaryReporting {
* which outputs to a log file in `./testlogs/`
*/
final class SummaryReport extends SummaryReporting {
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._

private val startingMessages = new java.util.concurrent.ConcurrentLinkedDeque[String]
private val failedTests = new java.util.concurrent.ConcurrentLinkedDeque[String]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import com.fasterxml.jackson.databind.ObjectMapper
import org.eclipse.lsp4j

import scala.collection._
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
import scala.util.control.NonFatal
import scala.io.Codec

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import dotty.tools.languageserver.util.server.TestFile
import org.eclipse.lsp4j.{CompletionItem, CompletionItemKind}
import org.junit.Assert.{assertEquals, assertFalse, assertTrue}

import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._

/**
* An action requesting for code completion at `marker`, expecting `expected`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package dotty.tools.languageserver.util.actions
import dotty.tools.languageserver.util.{CodeRange, PositionContext}
import dotty.tools.languageserver.util.embedded.CodeMarker

import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._

import org.junit.Assert.assertEquals

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import dotty.tools.languageserver.util.{CodeRange, PositionContext}
import org.eclipse.lsp4j.DocumentHighlightKind
import org.junit.Assert.assertEquals

import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._

/**
* An action requesting for the ranges that should be highlighted, when a position within `range`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import dotty.tools.languageserver.util.embedded.CodeMarker
import dotty.tools.languageserver.util.{PositionContext, SymInfo}
import org.junit.Assert.assertEquals

import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._

/**
* An action requesting for the symbols found in the document matching `marker`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import dotty.tools.languageserver.util.{CodeRange, PositionContext}

import org.junit.Assert.{assertEquals, assertNull, assertTrue}

import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._

/**
* An action requesting for the info shown when `range` is hovered.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import org.junit.Assert.assertEquals

import org.eclipse.lsp4j.Location

import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._

/**
* An action requesting for all the references to the symbol in `range` within the workspace.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import org.eclipse.lsp4j.{MessageActionItem, ShowMessageRequestParams}

import java.util.concurrent.CompletableFuture

import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._

/**
* An action requesting for a rename of the symbol at `marker`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import dotty.tools.languageserver.util.{PositionContext, SymInfo}
import org.eclipse.lsp4j.WorkspaceSymbolParams
import org.junit.Assert.assertEquals

import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._

/**
* An action requesting for all the symbols in the workspace matching `query`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import org.eclipse.lsp4j.Location

import org.junit.Assert.assertEquals

import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._

/**
* An action requesting the implementations of the symbol inside `range`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import dotty.tools.dotc.util.Signatures.Signature
import org.eclipse.lsp4j.{MarkupContent, ParameterInformation, SignatureInformation}
import org.junit.Assert.{assertEquals, assertFalse, assertTrue}

import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._

import SignatureHelp._

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package dotty.tools.languageserver.util.embedded
import dotty.tools.languageserver.util.server.TestFile
import dotty.tools.languageserver.util.{CodeRange, PositionContext}

import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._

import org.eclipse.lsp4j._

Expand Down
2 changes: 1 addition & 1 deletion sbt-test/source-dependencies/typeargref/A.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
import java.util.{ Map => JMap }

class A {
Expand Down
2 changes: 1 addition & 1 deletion sbt-test/source-dependencies/typeargref/changes/A1.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
import java.util.{ Map => JMap }

class A {
Expand Down
2 changes: 1 addition & 1 deletion scaladoc/src/dotty/tools/scaladoc/DocContext.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.Paths

import collection.JavaConverters._
import scala.jdk.CollectionConverters._
import dotty.tools.scaladoc.site.StaticSiteContext
import dotty.tools.dotc.core.Contexts._
import dotty.tools.dotc.util.SourceFile
Expand Down
2 changes: 1 addition & 1 deletion scaladoc/src/dotty/tools/scaladoc/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package dotty.tools.scaladoc
import java.util.ServiceLoader
import java.io.File
import java.util.jar._
import collection.JavaConverters._
import scala.jdk.CollectionConverters._
import collection.immutable.ArraySeq

import java.nio.file.Files
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package dotty.tools.scaladoc

import dotty.tools.scaladoc.tasty.ScaladocTastyInspector
import collection.JavaConverters._
import scala.jdk.CollectionConverters._
import transformers._

case class Module(rootPackage: Member, members: Map[DRI, Member])
Expand Down
2 changes: 1 addition & 1 deletion scaladoc/src/dotty/tools/scaladoc/Scaladoc.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import java.util.ServiceLoader
import java.io.File
import java.io.FileWriter
import java.util.jar._
import collection.JavaConverters._
import scala.jdk.CollectionConverters._
import collection.immutable.ArraySeq

import java.nio.file.{ Files, Paths }
Expand Down
Loading