From d9f5d2896d4e54d0abbf9a4ad3a7ef66f17c250a Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Fri, 3 Nov 2023 16:09:25 +0100 Subject: [PATCH] Deprecate `with` type operator in 3.4 --- compiler/src/dotty/tools/dotc/ast/untpd.scala | 2 +- compiler/src/dotty/tools/dotc/config/CliCommand.scala | 2 +- compiler/src/dotty/tools/dotc/parsing/Parsers.scala | 9 +++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/ast/untpd.scala b/compiler/src/dotty/tools/dotc/ast/untpd.scala index 41ba452fa80a..153100aa77ff 100644 --- a/compiler/src/dotty/tools/dotc/ast/untpd.scala +++ b/compiler/src/dotty/tools/dotc/ast/untpd.scala @@ -42,7 +42,7 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo { /** mods object name impl */ case class ModuleDef(name: TermName, impl: Template)(implicit @constructorOnly src: SourceFile) extends MemberDef { - type ThisTree[+T <: Untyped] <: Trees.NameTree[T] with Trees.MemberDef[T] with ModuleDef + type ThisTree[+T <: Untyped] <: Trees.NameTree[T] & Trees.MemberDef[T] & ModuleDef def withName(name: Name)(using Context): ModuleDef = cpy.ModuleDef(this)(name.toTermName, impl) } diff --git a/compiler/src/dotty/tools/dotc/config/CliCommand.scala b/compiler/src/dotty/tools/dotc/config/CliCommand.scala index 914df040fbf7..64f1d63c61ca 100644 --- a/compiler/src/dotty/tools/dotc/config/CliCommand.scala +++ b/compiler/src/dotty/tools/dotc/config/CliCommand.scala @@ -12,7 +12,7 @@ import scala.PartialFunction.cond trait CliCommand: - type ConcreteSettings <: CommonScalaSettings with Settings.SettingGroup + type ConcreteSettings <: CommonScalaSettings & Settings.SettingGroup def versionMsg: String diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala index c845ea8f74c7..8543fc070a13 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala @@ -1756,11 +1756,12 @@ object Parsers { if in.token == LBRACE || in.token == INDENT then t else - report.errorOrMigrationWarning( - DeprecatedWithOperator(rewriteNotice(`future-migration`)), + report.gradualErrorOrMigrationWarning( + DeprecatedWithOperator(rewriteNotice(`3.4-migration`)), in.sourcePos(withOffset), - from = future) - if sourceVersion == `future-migration` then + warnFrom = `3.4`, + errorFrom = future) + if sourceVersion.isAtLeast(`3.4-migration`) then patch(source, Span(withOffset, withOffset + 4), "&") atSpan(startOffset(t)) { makeAndType(t, withType()) } else t