Skip to content

Commit fd1589f

Browse files
committed
Make all deprecated methods package-private
1 parent d38b49e commit fd1589f

15 files changed

Lines changed: 84 additions & 48 deletions

File tree

scalameta/dialects/shared/src/main/scala/scala/meta/Dialect.scala

Lines changed: 42 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ final class Dialect private[meta] (
1414
private[meta] val unquoteType: UnquoteType,
1515
// Are `&` intersection types supported by this dialect?
1616
@deprecated("allowAndTypes unneeded, infix types are supported", "4.5.1")
17-
val allowAndTypes: Boolean, // unused
17+
private[meta] val allowAndTypes: Boolean, // unused
1818
// Are extractor varargs specified using ats, i.e. is `case Extractor(xs @ _*)` legal or not?
1919
val allowAtForExtractorVarargs: Boolean,
2020
// Can case classes be declared without a parameter list?
@@ -41,7 +41,7 @@ final class Dialect private[meta] (
4141
val allowLiteralTypes: Boolean,
4242
// Are `|` (union types) supported by this dialect?
4343
@deprecated("allowOrTypes unneeded, infix types are supported", "4.5.1")
44-
val allowOrTypes: Boolean, // unused
44+
private[meta] val allowOrTypes: Boolean, // unused
4545
// Are naked underscores allowed after $ in pattern interpolators, i.e. is `case q"$_ + $_" =>` legal or not?
4646
val allowSpliceUnderscores: Boolean,
4747
// Are terms on the top level supported by this dialect?
@@ -58,13 +58,13 @@ final class Dialect private[meta] (
5858
// def f[A <% Int](a: A)
5959
// Removed in Dotty.
6060
@deprecated("allowViewBounds unneeded, it was only used for an error", ">4.10.2")
61-
val allowViewBounds: Boolean,
61+
private[meta] val allowViewBounds: Boolean,
6262
// Are XML literals supported by this dialect?
6363
// We plan to deprecate XML literal syntax, and some dialects
6464
// might go ahead and drop support completely.
6565
val allowXmlLiterals: Boolean,
6666
@deprecated("toplevelSeparator has never been used", ">4.4.35")
67-
val toplevelSeparator: String, // unused
67+
private[meta] val toplevelSeparator: String, // unused
6868
// Are numeric literal underscore separators, i.e. `1_000_000` legal or not?
6969
val allowNumericLiteralUnderscoreSeparators: Boolean,
7070
// Can try body contain any expression? (2.13.1 https://github.com/scala/scala/pull/8071)
@@ -96,7 +96,7 @@ final class Dialect private[meta] (
9696
val allowQuestionMarkAsTypeWildcard: Boolean,
9797
// Dotty rejects placeholder as Type parameter
9898
@deprecated("allowTypeParamUnderscore not used", "4.14.1")
99-
val allowTypeParamUnderscore: Boolean,
99+
private[meta] val allowTypeParamUnderscore: Boolean, // TODO: deprecate, not used
100100
// Dotty allows by-name repeated parameters
101101
val allowByNameRepeatedParameters: Boolean,
102102
// Dotty allows lazy val abstract values
@@ -189,6 +189,7 @@ final class Dialect private[meta] (
189189
// - add new `withX()` method to allow overriding that specific field.
190190
// - add new `x = FIELD_DEFAULT_VALUE` in the `def this()` constructor below.
191191

192+
@deprecated("Use Dialect.empty (or any of the predefined dialects) and `.withXxx` methods")
192193
def this(
193194
allowAndTypes: Boolean, // unused
194195
allowAtForExtractorVarargs: Boolean,
@@ -293,7 +294,7 @@ final class Dialect private[meta] (
293294
def allowMultilinePrograms: Boolean = unquoteType.isMultiline
294295

295296
@deprecated("allowAndTypes unneeded, infix types are supported", "4.5.1")
296-
def withAllowAndTypes(newValue: Boolean): Dialect = this
297+
private[meta] def withAllowAndTypes(newValue: Boolean): Dialect = this
297298
def withAllowAtForExtractorVarargs(newValue: Boolean): Dialect =
298299
privateCopy(allowAtForExtractorVarargs = newValue)
299300
def withAllowCaseClassWithoutParameterList(newValue: Boolean): Dialect =
@@ -311,7 +312,7 @@ final class Dialect private[meta] (
311312
def withAllowLiteralTypes(newValue: Boolean): Dialect = privateCopy(allowLiteralTypes = newValue)
312313
def withAllowMultilinePrograms(newValue: Boolean): Dialect = ???
313314
@deprecated("allowOrTypes unneeded, infix types are supported", "4.5.1")
314-
def withAllowOrTypes(newValue: Boolean): Dialect = this
315+
private[meta] def withAllowOrTypes(newValue: Boolean): Dialect = this
315316
def withAllowPatUnquotes(newValue: Boolean): Dialect = ???
316317
def withAllowSpliceUnderscores(newValue: Boolean): Dialect =
317318
privateCopy(allowSpliceUnderscores = newValue)
@@ -323,10 +324,10 @@ final class Dialect private[meta] (
323324
privateCopy(allowTraitParameters = newValue)
324325
def withAllowTypeLambdas(newValue: Boolean): Dialect = privateCopy(allowTypeLambdas = newValue)
325326
@deprecated("allowViewBounds unneeded, it was only used for an error", ">4.10.2")
326-
def withAllowViewBounds(newValue: Boolean): Dialect = this
327+
private[meta] def withAllowViewBounds(newValue: Boolean): Dialect = this
327328
def withAllowXmlLiterals(newValue: Boolean): Dialect = privateCopy(allowXmlLiterals = newValue)
328329
@deprecated("toplevelSeparator has never been used", ">4.4.35")
329-
def withToplevelSeparator(newValue: String): Dialect = this
330+
private[meta] def withToplevelSeparator(newValue: String): Dialect = this
330331
def withAllowNumericLiteralUnderscoreSeparators(newValue: Boolean): Dialect =
331332
privateCopy(allowNumericLiteralUnderscoreSeparators = newValue)
332333
def withAllowTryWithAnyExpr(newValue: Boolean): Dialect =
@@ -351,9 +352,9 @@ final class Dialect private[meta] (
351352
def withAllowQuestionMarkAsTypeWildcard(newValue: Boolean): Dialect =
352353
privateCopy(allowQuestionMarkAsTypeWildcard = newValue)
353354
@deprecated("use allowQuestionMarkAsTypeWildcard", ">4.5.13")
354-
def allowQuestionMarkPlaceholder: Boolean = allowQuestionMarkAsTypeWildcard
355+
private[meta] def allowQuestionMarkPlaceholder: Boolean = allowQuestionMarkAsTypeWildcard
355356
@deprecated("use withAllowQuestionMarkAsTypeWildcard", ">4.5.13")
356-
def withAllowQuestionMarkPlaceholder(newValue: Boolean): Dialect =
357+
private[meta] def withAllowQuestionMarkPlaceholder(newValue: Boolean): Dialect =
357358
withAllowQuestionMarkAsTypeWildcard(newValue)
358359

359360
@deprecated("allowTypeParamUnderscore not used", "4.14.1")
@@ -400,10 +401,11 @@ final class Dialect private[meta] (
400401
def withAllowStarAsTypePlaceholder(newValue: Boolean): Dialect =
401402
privateCopy(allowStarAsTypePlaceholder = newValue)
402403
@deprecated("use withAllowUnderscoreAsTypePlaceholder", ">4.5.13")
403-
def withAllowPlusMinusUnderscoreAsPlaceholder(newValue: Boolean): Dialect =
404+
private[meta] def withAllowPlusMinusUnderscoreAsPlaceholder(newValue: Boolean): Dialect =
404405
withAllowUnderscoreAsTypePlaceholder(newValue)
405406
@deprecated("use allowUnderscoreAsTypePlaceholder", ">4.5.13")
406-
def allowPlusMinusUnderscoreAsPlaceholder: Boolean = allowUnderscoreAsTypePlaceholder
407+
private[meta] def allowPlusMinusUnderscoreAsPlaceholder: Boolean =
408+
allowUnderscoreAsTypePlaceholder
407409

408410
def withAllowGivenImports(newValue: Boolean): Dialect = privateCopy(allowGivenImports = newValue)
409411

@@ -681,7 +683,7 @@ final class Dialect private[meta] (
681683
this.allowImprovedTypeClassesSyntax == that.allowImprovedTypeClassesSyntax
682684

683685
@deprecated("Use withX method instead", "4.3.11")
684-
def copy(
686+
private[meta] def copy(
685687
allowAndTypes: Boolean = true, // unused
686688
allowAtForExtractorVarargs: Boolean = this.allowAtForExtractorVarargs,
687689
allowCaseClassWithoutParameterList: Boolean = this.allowCaseClassWithoutParameterList,
@@ -736,6 +738,32 @@ final class Dialect private[meta] (
736738
}
737739

738740
object Dialect extends InternalDialect {
741+
val empty: Dialect = new Dialect(
742+
allowAndTypes = false,
743+
allowAtForExtractorVarargs = false,
744+
allowCaseClassWithoutParameterList = false,
745+
allowColonForExtractorVarargs = false,
746+
allowEnums = false,
747+
allowImplicitByNameParameters = false,
748+
allowInlineIdents = false,
749+
allowInlineMods = false,
750+
allowLiteralTypes = false,
751+
allowMultilinePrograms = false,
752+
allowOrTypes = false,
753+
allowPatUnquotes = false,
754+
allowSpliceUnderscores = false,
755+
allowTermUnquotes = false,
756+
allowToplevelTerms = false,
757+
allowTrailingCommas = false,
758+
allowTraitParameters = false,
759+
allowTypeLambdas = false,
760+
allowViewBounds = false,
761+
allowXmlLiterals = false,
762+
toplevelSeparator = ""
763+
).withAllowEmptyInfixArgs(false).withAllowSymbolLiterals(false).withAllowProcedureSyntax(false)
764+
.withAllowDoWhile(false)
765+
766+
@deprecated("Use Dialect.empty (or any of the predefined dialects) and `.withXxx` methods")
739767
def apply(
740768
@deprecated("allowAndTypes unneeded, infix types are supported", "4.5.1")
741769
allowAndTypes: Boolean, // unused

scalameta/io/shared/src/main/scala/scala/meta/io/Classpath.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ final case class Classpath(entries: List[AbsolutePath]) {
88
def ++(other: Classpath): Classpath = Classpath(entries ++ other.entries)
99

1010
@deprecated("Use .entries instead", "4.0.0")
11-
def shallow: List[AbsolutePath] = entries
11+
private[meta] def shallow: List[AbsolutePath] = entries
1212

1313
def syntax: String = entries.mkString(pathSeparator)
1414
def structure: String = s"""Classpath("$syntax")"""

scalameta/tokenizers/js/src/main/scala/scala/meta/internal/tokenizers/PlatformTokenizerCache.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import java.{util => ju}
1010
import scala.collection.mutable
1111

1212
@deprecated("No longer used", "4.3.0")
13-
object PlatformTokenizerCache {
13+
private[meta] object PlatformTokenizerCache {
1414
// On the JVM, this is a weak hashmap.
1515
// still used in scalafmt-dynamic-3.7.10
1616
val megaCache = new ju.HashMap[Dialect, mutable.Map[Input, Tokens]]()

scalameta/tokenizers/jvm/src/main/scala/scala/meta/internal/tokenizers/PlatformTokenizerCache.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import java.{util => ju}
1111
import scala.collection.mutable
1212

1313
@deprecated("No longer used", "4.3.0")
14-
object PlatformTokenizerCache {
14+
private[meta] object PlatformTokenizerCache {
1515
// NOTE: Manipulated by tokenization code in the ScalametaTokenizer class.
1616
// Caching just in toTokenize wouldn't be enough, because someone could call the tokenizer directly.
1717
// still used in scalafmt-dynamic-3.7.10

scalameta/tokenizers/native/src/main/scala/scala/meta/internal/tokenizers/PlatformTokenizerCache.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import java.{util => ju}
1010
import scala.collection.mutable
1111

1212
@deprecated("No longer used", "4.3.0")
13-
object PlatformTokenizerCache {
13+
private[meta] object PlatformTokenizerCache {
1414
// On the JVM, this is a weak hashmap.
1515
// still used in scalafmt-dynamic-3.7.10
1616
val megaCache = new ju.HashMap[Dialect, mutable.Map[Input, Tokens]]()

scalameta/trees/shared/src/main/scala/scala/meta/Trees.scala

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ object Term {
355355
final def args: List[Term] = argClause.values
356356
}
357357
@deprecated("Use Term.Apply, pass Mod.Using to Term.ArgClause", "4.6.0") @ast
358-
class ApplyUsing(fun: Term, argClause: ArgClause) extends Term with Member.Apply {
358+
private[meta] class ApplyUsing(fun: Term, argClause: ArgClause) extends Term with Member.Apply {
359359
@replacedField("4.6.0")
360360
final def args: List[Term] = argClause.values
361361
}
@@ -627,7 +627,7 @@ object Type {
627627
trait FunctionType extends ParamFunctionType {
628628
def paramClause: FuncParamClause
629629
@deprecated("Please use paramClause instead", "4.6.0")
630-
def params: List[Type]
630+
private[meta] def params: List[Type]
631631
def res: Type
632632
}
633633

@@ -661,7 +661,7 @@ object Type {
661661
}
662662

663663
@ast @deprecated("Implicit functions are not supported in any dialect")
664-
class ImplicitFunction(params: List[Type], res: Type) extends Type
664+
private[meta] class ImplicitFunction(params: List[Type], res: Type) extends Type
665665
@ast
666666
class Tuple(args: List[Type] @nonEmpty) extends Type with Member.Tuple {
667667
// tuple may have one element (see scala.Tuple1)
@@ -671,9 +671,9 @@ object Type {
671671
@ast
672672
class With(lhs: Type, rhs: Type) extends Type
673673
@deprecated("And unused, replaced by ApplyInfix", "4.5.1") @ast
674-
class And(lhs: Type, rhs: Type) extends Type
674+
private[meta] class And(lhs: Type, rhs: Type) extends Type
675675
@deprecated("Or unused, replaced by ApplyInfix", "4.5.1") @ast
676-
class Or(lhs: Type, rhs: Type) extends Type
676+
private[meta] class Or(lhs: Type, rhs: Type) extends Type
677677
@ast
678678
class Refine(tpe: Option[Type], body: Stat.Block) extends Type with Tree.WithStatsBlock {
679679
checkField(body, body.stats.forall(_.isRefineStat))
@@ -702,24 +702,32 @@ object Type {
702702
@ast
703703
class Macro(body: Term) extends Type with Tree.WithBody
704704
@deprecated("Method type syntax is no longer supported in any dialect", "4.4.3") @ast
705-
class Method(paramClauses: Seq[Term.ParamClause], tpe: Type) extends Type {
705+
private[meta] class Method(paramClauses: Seq[Term.ParamClause], tpe: Type) extends Type {
706706
checkParent(ParentChecks.TypeMethod)
707707
@replacedField("4.6.0")
708708
final def paramss: List[List[Term.Param]] = paramClauses.map(_.values).toList
709709
}
710710
@deprecated("Placeholder replaced with AnonymousParam and Wildcard", ">4.5.13") @branch
711711
trait Placeholder extends Type {
712-
def bounds: Bounds
713-
def copy(bounds: Bounds = this.bounds): Placeholder
712+
private[meta] def bounds: Bounds
713+
private[meta] def copy(bounds: Bounds = this.bounds): Placeholder
714714
}
715715
@deprecated("Placeholder replaced with AnonymousParam and Wildcard", ">4.5.13")
716-
object Placeholder {
717-
@ast
718-
private[meta] class Impl(bounds: Bounds) extends Placeholder
716+
private[meta] object Placeholder {
717+
private[meta] object Impl {
718+
private[meta] object Initial
719+
private[meta] object Quasi {
720+
private[meta] object Initial
721+
private[meta] object TypePlaceholderImplQuasiImpl
722+
private[meta] object sharedClassifier
723+
}
724+
private[meta] object TypePlaceholderImplImpl
725+
private[meta] object sharedClassifier
726+
}
719727
@inline
720-
def apply(bounds: Bounds): Placeholder = Impl(bounds)
728+
private[meta] def apply(bounds: Bounds): Placeholder = ???
721729
@inline
722-
final def unapply(tree: Placeholder): Option[Bounds] = Some(tree.bounds)
730+
private[meta] final def unapply(tree: Placeholder): Option[Bounds] = ???
723731
}
724732
@ast
725733
class PatWildcard extends Type
@@ -728,8 +736,9 @@ object Type {
728736
@ast
729737
class AnonymousParam(variant: Option[Mod.Variant]) extends Placeholder {
730738
@deprecated("Placeholder replaced with AnonymousParam and Wildcard", ">4.5.13")
731-
override final def bounds: Bounds = Bounds.empty
732-
override def copy(bounds: Bounds): Placeholder = Placeholder(bounds)
739+
override private[meta] final def bounds: Bounds = ???
740+
@deprecated("Placeholder replaced with AnonymousParam and Wildcard", ">4.5.13")
741+
override private[meta] def copy(bounds: Bounds): Placeholder = ???
733742
}
734743
@ast
735744
class Bounds(
@@ -1460,7 +1469,7 @@ object Mod {
14601469
@ast
14611470
class Annot(init: Init) extends Mod {
14621471
@deprecated("Use init instead", "1.9.0")
1463-
def body = init
1472+
private[meta] def body = init
14641473
}
14651474
@branch
14661475
trait WithWithin extends Mod {
@@ -1483,7 +1492,7 @@ object Mod {
14831492
@ast
14841493
class Open() extends Mod
14851494
@deprecated("Super traits introduced in dotty, but later removed.") @ast
1486-
class Super() extends Mod
1495+
private[meta] class Super() extends Mod
14871496
@ast
14881497
class Override() extends Mod
14891498
@ast

scalameta/trees/shared/src/main/scala/scala/meta/contrib/DocToken.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import fastparse._
77
* Represents a scaladoc line.
88
*/
99
@deprecated("Use scala.meta.internal.Scaladoc instead", "4.3.13")
10-
case class DocToken(kind: DocToken.Kind, name: Option[String], body: Option[String]) {
10+
private[meta] case class DocToken(kind: DocToken.Kind, name: Option[String], body: Option[String]) {
1111

1212
override def toString: String = ((name, body) match {
1313
case (Some(n), _) => s"$kind(name=$n, body=${body.getOrElse("")})"
@@ -37,7 +37,7 @@ case class DocToken(kind: DocToken.Kind, name: Option[String], body: Option[Stri
3737
* http://docs.scala-lang.org/overviews/scaladoc/for-library-authors.html
3838
*/
3939
@deprecated("Use scala.meta.internal.Scaladoc instead", "4.3.13")
40-
object DocToken {
40+
private[meta] object DocToken {
4141

4242
/**
4343
* Parser that for obtaining a class reference from an scaladoc body.

scalameta/trees/shared/src/main/scala/scala/meta/contrib/ScaladocParser.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import fastparse.NoWhitespace._
77
import fastparse._
88

99
@deprecated("Use scala.meta.internal.parsers.ScaladocParser instead", "4.3.13")
10-
object ScaladocParser {
10+
private[meta] object ScaladocParser {
1111

1212
private[this] val numberOfSupportedHeadingLevels = 6
1313

scalameta/trees/shared/src/main/scala/scala/meta/internal/trees/InternalTrees.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ trait InternalTree extends Product {
5959
// ==============================================================
6060

6161
@deprecated("dialect is ignored, use parameterless `tokens` method", "4.9.0")
62-
final def tokens(dialect: Dialect): Tokens = tokens
62+
private[meta] final def tokens(dialect: Dialect): Tokens = tokens
6363

6464
def tokens: Tokens = tokensOpt.getOrElse(
6565
throw new Error.MissingDialectException(

semanticdb/metac/src/main/scala/scala/meta/cli/Metac.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ object Metac {
1010
def main(args: Array[String]): Unit = sys.exit(process(args, Reporter()))
1111

1212
@deprecated("Use `process(Settings.parse(args.toList).get, Reporter())`.", "3.5.0")
13-
def process(args: Array[String]): Int = process(args, Reporter())
13+
private[meta] def process(args: Array[String]): Int = process(args, Reporter())
1414

1515
@deprecated("Use `process(Settings.parse(args.toList).get, Reporter(out, err))`.", "3.5.0")
16-
def process(args: Array[String], out: PrintStream, err: PrintStream): Int =
16+
private[meta] def process(args: Array[String], out: PrintStream, err: PrintStream): Int =
1717
process(args, Reporter().withOut(out).withErr(err))
1818

1919
private def process(args: Array[String], reporter: Reporter): Int = {

0 commit comments

Comments
 (0)