Skip to content

Commit

Permalink
Deprecate given _ import syntax
Browse files Browse the repository at this point in the history
Was superceded by `given` in scala#9949.
  • Loading branch information
odersky authored and smarter committed Oct 22, 2020
1 parent 5ad149c commit 3a52817
Show file tree
Hide file tree
Showing 26 changed files with 31 additions and 30 deletions.
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/backend/jvm/BCodeAsmCommon.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import dotty.tools.dotc.report
* the compiler cake (Global).
*/
final class BCodeAsmCommon[I <: DottyBackendInterface](val interface: I) {
import interface.{_, given _}
import interface.{_, given}
import DottyBackendInterface.symExtensions

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
// import global._
// import definitions._
import tpd._
import int.{_, given _}
import int.{_, given}
import DottyBackendInterface.symExtensions
import bTypes._
import coreBTypes._
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/backend/jvm/BCodeHelpers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ trait BCodeHelpers extends BCodeIdiomatic with BytecodeWriters {
import bTypes._
import tpd._
import coreBTypes._
import int.{_, given _}
import int.{_, given}
import DottyBackendInterface._

def ScalaATTRName: String = "Scala"
Expand Down Expand Up @@ -468,7 +468,7 @@ trait BCodeHelpers extends BCodeIdiomatic with BytecodeWriters {
} // end of trait BCAnnotGen

trait BCJGenSigGen {
import int.{_, given _}
import int.{_, given}

def getCurrentCUnit(): CompilationUnit

Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/backend/jvm/BCodeIdiomatic.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ trait BCodeIdiomatic {
val int: DottyBackendInterface
final lazy val bTypes = new BTypesFromSymbols[int.type](int)

import int.{_, given _}
import int.{_, given}
import bTypes._
import coreBTypes._

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import dotty.tools.dotc.transform.SymUtils._
*
*/
trait BCodeSkelBuilder extends BCodeHelpers {
import int.{_, given _}
import int.{_, given}
import DottyBackendInterface.{symExtensions, _}
import tpd._
import bTypes._
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/backend/jvm/BCodeSyncAndTry.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import dotty.tools.dotc.ast.tpd.TreeOps
*
*/
trait BCodeSyncAndTry extends BCodeBodyBuilder {
import int.{_, given _}
import int.{_, given}
import tpd._
import bTypes._
import coreBTypes._
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/backend/jvm/BTypes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import scala.tools.asm
abstract class BTypes {

val int: DottyBackendInterface
import int.{_, given _}
import int.{_, given}
/**
* A map from internal names to ClassBTypes. Every ClassBType is added to this map on its
* construction.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import dotty.tools.dotc.util.WeakHashSet
* not have access to the compiler instance.
*/
class BTypesFromSymbols[I <: DottyBackendInterface](val int: I) extends BTypes {
import int.{_, given _}
import int.{_, given}
import DottyBackendInterface.{symExtensions, _}

lazy val TransientAttr = requiredClass[scala.transient]
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/backend/jvm/BytecodeWriters.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class FileConflictException(msg: String, val file: AbstractFile) extends IOExcep
*/
trait BytecodeWriters {
val int: DottyBackendInterface
import int.{_, given _}
import int.{_, given}

/**
* @param clsName cls.getName
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/backend/jvm/CoreBTypes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import dotty.tools.dotc.transform.Erasure
*/
class CoreBTypes[BTFS <: BTypesFromSymbols[_ <: DottyBackendInterface]](val bTypes: BTFS) {
import bTypes._
import int.{_, given _}
import int.{_, given}
import DottyBackendInterface._

//import global._
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/config/Feature.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package config
import core._
import Contexts._, Symbols._, Names._, NameOps._, Phases._
import StdNames.nme
import Decorators.{_, given _}
import Decorators.{_, given}
import util.SrcPos
import SourceVersion._
import reporting.Message
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/config/SourceVersion.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package config
import core.Contexts._
import core.Names.TermName
import core.StdNames.nme
import core.Decorators.{_, given _}
import core.Decorators.{_, given}
import util.Property

enum SourceVersion:
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/Contexts.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import ast.untpd
import Flags.GivenOrImplicit
import util.{NoSource, SimpleIdentityMap, SourceFile, HashSet}
import typer.{Implicits, ImportInfo, Inliner, SearchHistory, SearchRoot, TypeAssigner, Typer, Nullables}
import Nullables.{NotNullInfo, given _}
import Nullables.{NotNullInfo, given}
import Implicits.ContextualImplicits
import config.Settings._
import config.Config
Expand Down
3 changes: 2 additions & 1 deletion compiler/src/dotty/tools/dotc/parsing/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3117,8 +3117,9 @@ object Parsers {
case GIVEN =>
val start = in.skipToken()
if in.token == USCORE then
deprecationWarning(em"`given _` is deprecated in imports; replace with just `given`", start)
in.nextToken()
ImportSelector(givenSelectorId(start)) // Let the selector span all of `given _`; needed for -Ytest-pickler
ImportSelector(givenSelectorId(start)) // Let the selector span all of `given`; needed for -Ytest-pickler
else if canStartTypeTokens.contains(in.token) then
ImportSelector(givenSelectorId(start), bound = rejectWildcardType(infixType()))
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import dotty.tools.dotc.transform.SymUtils._

import PartialFunction.condOpt

import ast.untpd.{given _}
import ast.untpd.given
import NameOps._

import scala.annotation.{ threadUnsafe => tu, tailrec }
Expand All @@ -32,8 +32,8 @@ import scala.annotation.{ threadUnsafe => tu, tailrec }
* TODO: Also extract type information
*/
class ExtractSemanticDB extends Phase:
import Scala3.{_, given _}
import Symbols.{given _}
import Scala3.{_, given}
import Symbols.given

override val phaseName: String = ExtractSemanticDB.name

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 @@ -4,7 +4,7 @@ import java.nio.file._
import java.nio.charset.StandardCharsets
import scala.collection.JavaConverters._
import dotty.tools.dotc.util.SourceFile
import dotty.tools.dotc.semanticdb.Scala3.{_, given _}
import dotty.tools.dotc.semanticdb.Scala3.{_, given}

object Tools:

Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/typer/Applications.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import Inferencing._
import reporting._
import transform.TypeUtils._
import transform.SymUtils._
import Nullables.{postProcessByNameArgs, given _}
import Nullables.{postProcessByNameArgs, given}
import config.Feature

import collection.mutable
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/typer/Docstrings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package dotc
package typer

import core._
import Contexts._, Symbols._, Decorators._, Comments.{_, given _}
import Contexts._, Symbols._, Decorators._, Comments.{_, given}
import ast.tpd

object Docstrings {
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/typer/Inliner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import config.Printers.inlining
import ErrorReporting.errorTree
import dotty.tools.dotc.util.{SimpleIdentityMap, SimpleIdentitySet, EqHashMap, SourceFile, SourcePosition, SrcPos}
import dotty.tools.dotc.parsing.Parsers.Parser
import Nullables.{given _}
import Nullables.given

import collection.mutable
import reporting.trace
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/typer/Namer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import core._
import ast._
import Trees._, StdNames._, Scopes._, Denotations._, NamerOps._, ContextOps._
import Contexts._, Symbols._, Types._, SymDenotations._, Names._, NameOps._, Flags._
import Decorators._, Comments.{_, given _}
import Decorators._, Comments.{_, given}
import NameKinds.DefaultGetterName
import TypeApplications.TypeParamInfo
import ast.desugar, ast.desugar._
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/typer/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import NavigateAST._
import transform.SymUtils._
import transform.TypeUtils._
import reporting._
import Nullables.{NotNullInfo, given _}
import Nullables.{NotNullInfo, given}
import NullOpsDecorator._

object Typer {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ object ModifiersParsingTest {


class ModifiersParsingTest {
import ModifiersParsingTest.{_, given _}
import ModifiersParsingTest.{_, given}


@Test def valDef = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import org.junit.experimental.categories.Category

import dotty.BootstrappedOnlyTests
import dotty.tools.dotc.Main
import dotty.tools.dotc.semanticdb.Scala3.{given _}
import dotty.tools.dotc.semanticdb.Scala3.given
import dotty.tools.dotc.util.SourceFile

@main def updateExpect =
Expand Down
2 changes: 1 addition & 1 deletion doc-tool/src/dotty/tools/dottydoc/util/syntax.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package dottydoc
package util

import dotc.core.Contexts.{Context, ctx}
import dotc.core.Comments.{_, given _}
import dotc.core.Comments.{_, given}
import model.Package
import core.ContextDottydoc
import dotc.core.Symbols._
Expand Down
2 changes: 1 addition & 1 deletion tests/neg/i9928.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ object Magic:

opaque type Foo = String
object Foo:
import Magic.{given _}
import Magic.given
def apply(s: String): Foo = s

given Magic[Foo]:
Expand Down
4 changes: 2 additions & 2 deletions tests/run/i9928.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ object test1:

opaque type Foo = String
object Foo extends LowPrio:
import Magic.{given _}
import Magic.given
def apply(s: String): Foo = s

given Magic[Foo]:
Expand All @@ -32,7 +32,7 @@ object test2:

opaque type Foo = String
object Foo extends LowPrio:
import Magic.{given _}
import Magic.given
def apply(s: String): Foo = s

def test: Unit =
Expand Down

0 comments on commit 3a52817

Please sign in to comment.