Skip to content

Commit

Permalink
Make private[this] a migration warning
Browse files Browse the repository at this point in the history
* In `3.4` we emit the deprecation warning and enable the patch with -rewrite.
* In `future` we emit we make this syntax an error
  • Loading branch information
nicolasstucki committed Nov 8, 2023
1 parent f61026d commit a0699ae
Show file tree
Hide file tree
Showing 63 changed files with 305 additions and 168 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ object projects:
project = "shapeless-3",
sbtTestCommand = "testJVM; testJS",
sbtDocCommand = forceDoc("typeable", "deriving"),
scalacOptions = SbtCommunityProject.scalacOptions.filter(_ != "-Ysafe-init"), // due to -Xfatal-warnings
scalacOptions = "-source" :: "3.3" :: SbtCommunityProject.scalacOptions.filter(_ != "-Ysafe-init"), // due to -Xfatal-warnings
)

lazy val xmlInterpolator = SbtCommunityProject(
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/TypeComparer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
* every time we compare components of the previous pair of types.
* This type is used for capture conversion in `isSubArgs`.
*/
private [this] var leftRoot: Type | Null = null
private var leftRoot: Type | Null = null

/** Are we forbidden from recording GADT constraints? */
private var frozenGadt = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import java.io.{DataInputStream, InputStream}
import java.nio.{BufferUnderflowException, ByteBuffer}

final class ReusableDataReader() extends DataReader {
private[this] var data = new Array[Byte](32768)
private[this] var bb: ByteBuffer = ByteBuffer.wrap(data)
private[this] var size = 0
private[this] val reader: DataInputStream = {
private var data = new Array[Byte](32768)
private var bb: ByteBuffer = ByteBuffer.wrap(data)
private var size = 0
private val reader: DataInputStream = {
val stream = new InputStream {
override def read(): Int = try {
bb.get & 0xff
Expand Down
16 changes: 12 additions & 4 deletions compiler/src/dotty/tools/dotc/parsing/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3112,15 +3112,23 @@ object Parsers {
if (in.token == LBRACKET) {
if (mods.is(Local) || mods.hasPrivateWithin)
syntaxError(DuplicatePrivateProtectedQualifier())
inBrackets {
val startOffset = in.offset
val mods1 = inBrackets {
if in.token == THIS then
if sourceVersion.isAtLeast(future) then
deprecationWarning(
em"The [this] qualifier will be deprecated in the future; it should be dropped.")
in.nextToken()
mods | Local
else mods.withPrivateWithin(ident().toTypeName)
}
if mods1.is(Local) then
report.gradualErrorOrMigrationWarning(
em"""The [this] qualifier will be deprecated in the future; it should be dropped.
|See: https://docs.scala-lang.org/scala3/reference/dropped-features/this-qualifier.html${rewriteNotice(`3.4-migration`)}""",
in.sourcePos(),
warnFrom = `3.4`,
errorFrom = future)
if sourceVersion.isMigrating && sourceVersion.isAtLeast(`3.4-migration`) then
patch(source, Span(startOffset, in.lastOffset), "")
mods1
}
else mods

Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/reporting/WConf.scala
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ object WConf:
else Right(WConf(configs))

class Suppression(val annotPos: SourcePosition, filters: List[MessageFilter], val start: Int, end: Int, val verbose: Boolean):
private[this] var _used = false
private var _used = false
def used: Boolean = _used
def markUsed(): Unit = { _used = true }

Expand Down
12 changes: 6 additions & 6 deletions compiler/src/dotty/tools/dotc/semanticdb/generated/Access.scala
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ final case class AccessMessage(
sealedValue: dotty.tools.dotc.semanticdb.AccessMessage.SealedValue = dotty.tools.dotc.semanticdb.AccessMessage.SealedValue.Empty
) extends SemanticdbGeneratedMessage derives CanEqual {
@transient @sharable
private[this] var __serializedSizeMemoized: _root_.scala.Int = 0
private[this] def __computeSerializedSize(): _root_.scala.Int = {
private var __serializedSizeMemoized: _root_.scala.Int = 0
private def __computeSerializedSize(): _root_.scala.Int = {
var __size = 0
if (sealedValue.privateAccess.isDefined) {
val __value = sealedValue.privateAccess.get
Expand Down Expand Up @@ -379,8 +379,8 @@ final case class PrivateWithinAccess(
symbol: _root_.scala.Predef.String = ""
) extends dotty.tools.dotc.semanticdb.Access.NonEmpty with SemanticdbGeneratedMessage derives CanEqual {
@transient @sharable
private[this] var __serializedSizeMemoized: _root_.scala.Int = 0
private[this] def __computeSerializedSize(): _root_.scala.Int = {
private var __serializedSizeMemoized: _root_.scala.Int = 0
private def __computeSerializedSize(): _root_.scala.Int = {
var __size = 0

{
Expand Down Expand Up @@ -539,8 +539,8 @@ final case class ProtectedWithinAccess(
symbol: _root_.scala.Predef.String = ""
) extends dotty.tools.dotc.semanticdb.Access.NonEmpty with SemanticdbGeneratedMessage derives CanEqual {
@transient @sharable
private[this] var __serializedSizeMemoized: _root_.scala.Int = 0
private[this] def __computeSerializedSize(): _root_.scala.Int = {
private var __serializedSizeMemoized: _root_.scala.Int = 0
private def __computeSerializedSize(): _root_.scala.Int = {
var __size = 0

{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ final case class Annotation(
tpe: dotty.tools.dotc.semanticdb.Type = dotty.tools.dotc.semanticdb.Annotation._typemapper_tpe.toCustom(dotty.tools.dotc.semanticdb.TypeMessage.defaultInstance)
) extends SemanticdbGeneratedMessage derives CanEqual {
@transient @sharable
private[this] var __serializedSizeMemoized: _root_.scala.Int = 0
private[this] def __computeSerializedSize(): _root_.scala.Int = {
private var __serializedSizeMemoized: _root_.scala.Int = 0
private def __computeSerializedSize(): _root_.scala.Int = {
var __size = 0

{
Expand Down
40 changes: 20 additions & 20 deletions compiler/src/dotty/tools/dotc/semanticdb/generated/Constant.scala
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ final case class ConstantMessage(
sealedValue: dotty.tools.dotc.semanticdb.ConstantMessage.SealedValue = dotty.tools.dotc.semanticdb.ConstantMessage.SealedValue.Empty
) extends SemanticdbGeneratedMessage derives CanEqual {
@transient @sharable
private[this] var __serializedSizeMemoized: _root_.scala.Int = 0
private[this] def __computeSerializedSize(): _root_.scala.Int = {
private var __serializedSizeMemoized: _root_.scala.Int = 0
private def __computeSerializedSize(): _root_.scala.Int = {
var __size = 0
if (sealedValue.unitConstant.isDefined) {
val __value = sealedValue.unitConstant.get
Expand Down Expand Up @@ -442,8 +442,8 @@ final case class BooleanConstant(
value: _root_.scala.Boolean = false
) extends dotty.tools.dotc.semanticdb.Constant.NonEmpty with SemanticdbGeneratedMessage derives CanEqual {
@transient @sharable
private[this] var __serializedSizeMemoized: _root_.scala.Int = 0
private[this] def __computeSerializedSize(): _root_.scala.Int = {
private var __serializedSizeMemoized: _root_.scala.Int = 0
private def __computeSerializedSize(): _root_.scala.Int = {
var __size = 0

{
Expand Down Expand Up @@ -520,8 +520,8 @@ final case class ByteConstant(
value: _root_.scala.Int = 0
) extends dotty.tools.dotc.semanticdb.Constant.NonEmpty with SemanticdbGeneratedMessage derives CanEqual {
@transient @sharable
private[this] var __serializedSizeMemoized: _root_.scala.Int = 0
private[this] def __computeSerializedSize(): _root_.scala.Int = {
private var __serializedSizeMemoized: _root_.scala.Int = 0
private def __computeSerializedSize(): _root_.scala.Int = {
var __size = 0

{
Expand Down Expand Up @@ -598,8 +598,8 @@ final case class ShortConstant(
value: _root_.scala.Int = 0
) extends dotty.tools.dotc.semanticdb.Constant.NonEmpty with SemanticdbGeneratedMessage derives CanEqual {
@transient @sharable
private[this] var __serializedSizeMemoized: _root_.scala.Int = 0
private[this] def __computeSerializedSize(): _root_.scala.Int = {
private var __serializedSizeMemoized: _root_.scala.Int = 0
private def __computeSerializedSize(): _root_.scala.Int = {
var __size = 0

{
Expand Down Expand Up @@ -676,8 +676,8 @@ final case class CharConstant(
value: _root_.scala.Int = 0
) extends dotty.tools.dotc.semanticdb.Constant.NonEmpty with SemanticdbGeneratedMessage derives CanEqual {
@transient @sharable
private[this] var __serializedSizeMemoized: _root_.scala.Int = 0
private[this] def __computeSerializedSize(): _root_.scala.Int = {
private var __serializedSizeMemoized: _root_.scala.Int = 0
private def __computeSerializedSize(): _root_.scala.Int = {
var __size = 0

{
Expand Down Expand Up @@ -754,8 +754,8 @@ final case class IntConstant(
value: _root_.scala.Int = 0
) extends dotty.tools.dotc.semanticdb.Constant.NonEmpty with SemanticdbGeneratedMessage derives CanEqual {
@transient @sharable
private[this] var __serializedSizeMemoized: _root_.scala.Int = 0
private[this] def __computeSerializedSize(): _root_.scala.Int = {
private var __serializedSizeMemoized: _root_.scala.Int = 0
private def __computeSerializedSize(): _root_.scala.Int = {
var __size = 0

{
Expand Down Expand Up @@ -832,8 +832,8 @@ final case class LongConstant(
value: _root_.scala.Long = 0L
) extends dotty.tools.dotc.semanticdb.Constant.NonEmpty with SemanticdbGeneratedMessage derives CanEqual {
@transient @sharable
private[this] var __serializedSizeMemoized: _root_.scala.Int = 0
private[this] def __computeSerializedSize(): _root_.scala.Int = {
private var __serializedSizeMemoized: _root_.scala.Int = 0
private def __computeSerializedSize(): _root_.scala.Int = {
var __size = 0

{
Expand Down Expand Up @@ -910,8 +910,8 @@ final case class FloatConstant(
value: _root_.scala.Float = 0.0f
) extends dotty.tools.dotc.semanticdb.Constant.NonEmpty with SemanticdbGeneratedMessage derives CanEqual {
@transient @sharable
private[this] var __serializedSizeMemoized: _root_.scala.Int = 0
private[this] def __computeSerializedSize(): _root_.scala.Int = {
private var __serializedSizeMemoized: _root_.scala.Int = 0
private def __computeSerializedSize(): _root_.scala.Int = {
var __size = 0

{
Expand Down Expand Up @@ -988,8 +988,8 @@ final case class DoubleConstant(
value: _root_.scala.Double = 0.0
) extends dotty.tools.dotc.semanticdb.Constant.NonEmpty with SemanticdbGeneratedMessage derives CanEqual {
@transient @sharable
private[this] var __serializedSizeMemoized: _root_.scala.Int = 0
private[this] def __computeSerializedSize(): _root_.scala.Int = {
private var __serializedSizeMemoized: _root_.scala.Int = 0
private def __computeSerializedSize(): _root_.scala.Int = {
var __size = 0

{
Expand Down Expand Up @@ -1066,8 +1066,8 @@ final case class StringConstant(
value: _root_.scala.Predef.String = ""
) extends dotty.tools.dotc.semanticdb.Constant.NonEmpty with SemanticdbGeneratedMessage derives CanEqual {
@transient @sharable
private[this] var __serializedSizeMemoized: _root_.scala.Int = 0
private[this] def __computeSerializedSize(): _root_.scala.Int = {
private var __serializedSizeMemoized: _root_.scala.Int = 0
private def __computeSerializedSize(): _root_.scala.Int = {
var __size = 0

{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ final case class Diagnostic(
message: _root_.scala.Predef.String = ""
) extends SemanticdbGeneratedMessage derives CanEqual {
@transient @sharable
private[this] var __serializedSizeMemoized: _root_.scala.Int = 0
private[this] def __computeSerializedSize(): _root_.scala.Int = {
private var __serializedSizeMemoized: _root_.scala.Int = 0
private def __computeSerializedSize(): _root_.scala.Int = {
var __size = 0
if (range.isDefined) {
val __value = range.get
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ final case class Documentation(
format: dotty.tools.dotc.semanticdb.Documentation.Format = dotty.tools.dotc.semanticdb.Documentation.Format.HTML
) extends SemanticdbGeneratedMessage derives CanEqual {
@transient @sharable
private[this] var __serializedSizeMemoized: _root_.scala.Int = 0
private[this] def __computeSerializedSize(): _root_.scala.Int = {
private var __serializedSizeMemoized: _root_.scala.Int = 0
private def __computeSerializedSize(): _root_.scala.Int = {
var __size = 0

{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ final case class Location(
range: _root_.scala.Option[dotty.tools.dotc.semanticdb.Range] = _root_.scala.None
) extends SemanticdbGeneratedMessage derives CanEqual {
@transient @sharable
private[this] var __serializedSizeMemoized: _root_.scala.Int = 0
private[this] def __computeSerializedSize(): _root_.scala.Int = {
private var __serializedSizeMemoized: _root_.scala.Int = 0
private def __computeSerializedSize(): _root_.scala.Int = {
var __size = 0

{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ final case class Range(
endCharacter: _root_.scala.Int = 0
) extends SemanticdbGeneratedMessage derives CanEqual {
@transient @sharable
private[this] var __serializedSizeMemoized: _root_.scala.Int = 0
private[this] def __computeSerializedSize(): _root_.scala.Int = {
private var __serializedSizeMemoized: _root_.scala.Int = 0
private def __computeSerializedSize(): _root_.scala.Int = {
var __size = 0

{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ final case class Scope(
hardlinks: _root_.scala.Seq[dotty.tools.dotc.semanticdb.SymbolInformation] = _root_.scala.Seq.empty
) extends SemanticdbGeneratedMessage derives CanEqual {
@transient @sharable
private[this] var __serializedSizeMemoized: _root_.scala.Int = 0
private[this] def __computeSerializedSize(): _root_.scala.Int = {
private var __serializedSizeMemoized: _root_.scala.Int = 0
private def __computeSerializedSize(): _root_.scala.Int = {
var __size = 0
symlinks.foreach { __item =>
val __value = __item
Expand Down
20 changes: 10 additions & 10 deletions compiler/src/dotty/tools/dotc/semanticdb/generated/Signature.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ final case class SignatureMessage(
sealedValue: dotty.tools.dotc.semanticdb.SignatureMessage.SealedValue = dotty.tools.dotc.semanticdb.SignatureMessage.SealedValue.Empty
) extends SemanticdbGeneratedMessage derives CanEqual {
@transient @sharable
private[this] var __serializedSizeMemoized: _root_.scala.Int = 0
private[this] def __computeSerializedSize(): _root_.scala.Int = {
private var __serializedSizeMemoized: _root_.scala.Int = 0
private def __computeSerializedSize(): _root_.scala.Int = {
var __size = 0
if (sealedValue.classSignature.isDefined) {
val __value = sealedValue.classSignature.get
Expand Down Expand Up @@ -222,8 +222,8 @@ final case class ClassSignature(
declarations: _root_.scala.Option[dotty.tools.dotc.semanticdb.Scope] = _root_.scala.None
) extends dotty.tools.dotc.semanticdb.Signature.NonEmpty with SemanticdbGeneratedMessage derives CanEqual {
@transient @sharable
private[this] var __serializedSizeMemoized: _root_.scala.Int = 0
private[this] def __computeSerializedSize(): _root_.scala.Int = {
private var __serializedSizeMemoized: _root_.scala.Int = 0
private def __computeSerializedSize(): _root_.scala.Int = {
var __size = 0
if (typeParameters.isDefined) {
val __value = typeParameters.get
Expand Down Expand Up @@ -372,8 +372,8 @@ final case class MethodSignature(
returnType: dotty.tools.dotc.semanticdb.Type = dotty.tools.dotc.semanticdb.MethodSignature._typemapper_returnType.toCustom(dotty.tools.dotc.semanticdb.TypeMessage.defaultInstance)
) extends dotty.tools.dotc.semanticdb.Signature.NonEmpty with SemanticdbGeneratedMessage derives CanEqual {
@transient @sharable
private[this] var __serializedSizeMemoized: _root_.scala.Int = 0
private[this] def __computeSerializedSize(): _root_.scala.Int = {
private var __serializedSizeMemoized: _root_.scala.Int = 0
private def __computeSerializedSize(): _root_.scala.Int = {
var __size = 0
if (typeParameters.isDefined) {
val __value = typeParameters.get
Expand Down Expand Up @@ -499,8 +499,8 @@ final case class TypeSignature(
upperBound: dotty.tools.dotc.semanticdb.Type = dotty.tools.dotc.semanticdb.TypeSignature._typemapper_upperBound.toCustom(dotty.tools.dotc.semanticdb.TypeMessage.defaultInstance)
) extends dotty.tools.dotc.semanticdb.Signature.NonEmpty with SemanticdbGeneratedMessage derives CanEqual {
@transient @sharable
private[this] var __serializedSizeMemoized: _root_.scala.Int = 0
private[this] def __computeSerializedSize(): _root_.scala.Int = {
private var __serializedSizeMemoized: _root_.scala.Int = 0
private def __computeSerializedSize(): _root_.scala.Int = {
var __size = 0
if (typeParameters.isDefined) {
val __value = typeParameters.get
Expand Down Expand Up @@ -628,8 +628,8 @@ final case class ValueSignature(
tpe: dotty.tools.dotc.semanticdb.Type = dotty.tools.dotc.semanticdb.ValueSignature._typemapper_tpe.toCustom(dotty.tools.dotc.semanticdb.TypeMessage.defaultInstance)
) extends dotty.tools.dotc.semanticdb.Signature.NonEmpty with SemanticdbGeneratedMessage derives CanEqual {
@transient @sharable
private[this] var __serializedSizeMemoized: _root_.scala.Int = 0
private[this] def __computeSerializedSize(): _root_.scala.Int = {
private var __serializedSizeMemoized: _root_.scala.Int = 0
private def __computeSerializedSize(): _root_.scala.Int = {
var __size = 0

{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ final case class SymbolInformation(
documentation: _root_.scala.Option[dotty.tools.dotc.semanticdb.Documentation] = _root_.scala.None
) extends SemanticdbGeneratedMessage derives CanEqual {
@transient @sharable
private[this] var __serializedSizeMemoized: _root_.scala.Int = 0
private[this] def __computeSerializedSize(): _root_.scala.Int = {
private var __serializedSizeMemoized: _root_.scala.Int = 0
private def __computeSerializedSize(): _root_.scala.Int = {
var __size = 0

{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ final case class SymbolOccurrence(
role: dotty.tools.dotc.semanticdb.SymbolOccurrence.Role = dotty.tools.dotc.semanticdb.SymbolOccurrence.Role.UNKNOWN_ROLE
) extends SemanticdbGeneratedMessage derives CanEqual {
@transient @sharable
private[this] var __serializedSizeMemoized: _root_.scala.Int = 0
private[this] def __computeSerializedSize(): _root_.scala.Int = {
private var __serializedSizeMemoized: _root_.scala.Int = 0
private def __computeSerializedSize(): _root_.scala.Int = {
var __size = 0
if (range.isDefined) {
val __value = range.get
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ final case class Synthetic(
tree: dotty.tools.dotc.semanticdb.Tree = dotty.tools.dotc.semanticdb.Synthetic._typemapper_tree.toCustom(dotty.tools.dotc.semanticdb.TreeMessage.defaultInstance)
) extends SemanticdbGeneratedMessage derives CanEqual {
@transient @sharable
private[this] var __serializedSizeMemoized: _root_.scala.Int = 0
private[this] def __computeSerializedSize(): _root_.scala.Int = {
private var __serializedSizeMemoized: _root_.scala.Int = 0
private def __computeSerializedSize(): _root_.scala.Int = {
var __size = 0
if (range.isDefined) {
val __value = range.get
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ final case class TextDocument(
synthetics: _root_.scala.Seq[dotty.tools.dotc.semanticdb.Synthetic] = _root_.scala.Seq.empty
) extends SemanticdbGeneratedMessage derives CanEqual {
@transient @sharable
private[this] var __serializedSizeMemoized: _root_.scala.Int = 0
private[this] def __computeSerializedSize(): _root_.scala.Int = {
private var __serializedSizeMemoized: _root_.scala.Int = 0
private def __computeSerializedSize(): _root_.scala.Int = {
var __size = 0

{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ final case class TextDocuments(
documents: _root_.scala.Seq[dotty.tools.dotc.semanticdb.TextDocument] = _root_.scala.Seq.empty
) extends SemanticdbGeneratedMessage derives CanEqual {
@transient @sharable
private[this] var __serializedSizeMemoized: _root_.scala.Int = 0
private[this] def __computeSerializedSize(): _root_.scala.Int = {
private var __serializedSizeMemoized: _root_.scala.Int = 0
private def __computeSerializedSize(): _root_.scala.Int = {
var __size = 0
documents.foreach { __item =>
val __value = __item
Expand Down
Loading

0 comments on commit a0699ae

Please sign in to comment.