diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala index 5dddba6277bf..f299d73758a1 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala @@ -2315,7 +2315,7 @@ object Parsers { possibleTemplateStart() val parents = if in.isNestedStart then Nil - else constrApp() :: withConstrApps() + else constrApps(commaOK = false) colonAtEOLOpt() possibleTemplateStart(isNew = true) parents match { @@ -3494,7 +3494,7 @@ object Parsers { val parents = if (in.token == EXTENDS) { in.nextToken() - constrApps() + constrApps(commaOK = true) } else Nil Template(constr, parents, Nil, EmptyValDef, Nil) @@ -3628,35 +3628,22 @@ object Parsers { /** ConstrApps ::= ConstrApp ({‘,’ ConstrApp} | {‘with’ ConstrApp}) */ - def constrApps(): List[Tree] = + def constrApps(commaOK: Boolean): List[Tree] = val t = constrApp() - val ts = if in.token == COMMA then commaConstrApps() else withConstrApps() + val ts = + if in.token == WITH || commaOK && in.token == COMMA then + in.nextToken() + constrApps(commaOK) + else Nil t :: ts - /** `{`,` ConstrApp} */ - def commaConstrApps(): List[Tree] = - if in.token == COMMA then - in.nextToken() - constrApp() :: commaConstrApps() - else Nil /** `{`with` ConstrApp} but no EOL allowed after `with`. */ def withConstrApps(): List[Tree] = def isTemplateStart = val la = in.lookahead - la.token == LBRACE - || la.isAfterLineEnd - && { - if migrateTo3 then - warning( - em"""In Scala 3, `with` at the end of a line will start definitions, - |so it cannot be used in front of a parent constructor anymore. - |Place the `with` at the beginning of the next line instead.""") - false - else - true - } + la.isAfterLineEnd || la.token == LBRACE if in.token == WITH && !isTemplateStart then in.nextToken() constrApp() :: withConstrApps() @@ -3675,7 +3662,7 @@ object Parsers { in.sourcePos()) Nil } - else constrApps() + else constrApps(commaOK = true) } else Nil newLinesOptWhenFollowedBy(nme.derives) @@ -3819,16 +3806,7 @@ object Parsers { } else { stats += first - if in.token == WITH then - syntaxError( - i"""end of statement expected but ${showToken(WITH)} found - | - |Maybe you meant to write a mixin in an extends clause? - |Note that this requires the `with` to come first now. - |I.e. - | - | with $first""") - else acceptStatSepUnlessAtEnd(stats) + acceptStatSepUnlessAtEnd(stats) } } var exitOnError = false diff --git a/docs/docs/internals/syntax.md b/docs/docs/internals/syntax.md index 9a1de5dc1b46..508b4f3ef48f 100644 --- a/docs/docs/internals/syntax.md +++ b/docs/docs/internals/syntax.md @@ -83,6 +83,7 @@ comment ::= ‘/*’ “any sequence of characters; nested comments ar nl ::= “new line character” semi ::= ‘;’ | nl {nl} +colonEol ::= ": at end of line that can start a template body" ``` ## Keywords @@ -217,8 +218,9 @@ SimpleExpr ::= SimpleRef | ‘$’ ‘{’ Block ‘}’ | Quoted | quoteId -- only inside splices - | ‘new’ ConstrApp {‘with’ ConstrApp} [TemplateBody] New(constr | templ) - | ‘new’ TemplateBody + | ‘new’ ConstrApp {‘with’ ConstrApp} New(constr | templ) + [[colonEol] TemplateBody + | ‘new’ [colonEol] TemplateBody | ‘(’ ExprsInParens ‘)’ Parens(exprs) | SimpleExpr ‘.’ id Select(expr, id) | SimpleExpr ‘.’ MatchClause @@ -384,15 +386,15 @@ ClassDef ::= id ClassConstr [Template] ClassConstr ::= [ClsTypeParamClause] [ConstrMods] ClsParamClauses with DefDef(_, , Nil, vparamss, EmptyTree, EmptyTree) as first stat ConstrMods ::= {Annotation} [AccessModifier] ObjectDef ::= id [Template] ModuleDef(mods, name, template) // no constructor -EnumDef ::= id ClassConstr InheritClauses EnumBody +EnumDef ::= id ClassConstr InheritClauses [colonEol] EnumBody GivenDef ::= [GivenSig] (AnnotType [‘=’ Expr] | StructuralInstance) GivenSig ::= [id] [DefTypeParamClause] {UsingParamClause} ‘:’ -- one of `id`, `DefParamClause`, `UsingParamClause` must be present -StructuralInstance ::= ConstrApp {‘with’ ConstrApp} TemplateBody +StructuralInstance ::= ConstrApp {‘with’ ConstrApp} ‘with’ TemplateBody Extension ::= ‘extension’ [DefTypeParamClause] ‘(’ DefParam ‘)’ {UsingParamClause}] ExtMethods ExtMethods ::= ExtMethod | [nl] ‘{’ ExtMethod {semi ExtMethod ‘}’ ExtMethod ::= {Annotation [nl]} {Modifier} ‘def’ DefDef -Template ::= InheritClauses [TemplateBody] Template(constr, parents, self, stats) +Template ::= InheritClauses [colonEol] [TemplateBody] Template(constr, parents, self, stats) InheritClauses ::= [‘extends’ ConstrApps] [‘derives’ QualId {‘,’ QualId}] ConstrApps ::= ConstrApp ({‘,’ ConstrApp} | {‘with’ ConstrApp}) ConstrApp ::= SimpleType1 {Annotation} {ParArgumentExprs} Apply(tp, args) @@ -400,7 +402,7 @@ ConstrExpr ::= SelfInvocation | ‘{’ SelfInvocation {semi BlockStat} ‘}’ SelfInvocation ::= ‘this’ ArgumentExprs {ArgumentExprs} -TemplateBody ::= [nl | ‘with’] ‘{’ [SelfType] TemplateStat {semi TemplateStat} ‘}’ +TemplateBody ::= [nl] ‘{’ [SelfType] TemplateStat {semi TemplateStat} ‘}’ TemplateStat ::= Import | Export | {Annotation [nl]} {Modifier} Def @@ -412,7 +414,7 @@ TemplateStat ::= Import SelfType ::= id [‘:’ InfixType] ‘=>’ ValDef(_, name, tpt, _) | ‘this’ ‘:’ InfixType ‘=>’ -EnumBody ::= [nl | ‘with’] ‘{’ [SelfType] EnumStat {semi EnumStat} ‘}’ +EnumBody ::= [nl] ‘{’ [SelfType] EnumStat {semi EnumStat} ‘}’ EnumStat ::= TemplateStat | {Annotation [nl]} {Modifier} EnumCase EnumCase ::= ‘case’ (id ClassConstr [‘extends’ ConstrApps]] | ids) @@ -426,7 +428,7 @@ TopStat ::= Import | PackageObject | EndMarker | -Packaging ::= ‘package’ QualId [nl| ‘with’] ‘{’ TopStatSeq ‘}’ Package(qid, stats) +Packaging ::= ‘package’ QualId [nl | colonEol] ‘{’ TopStatSeq ‘}’ Package(qid, stats) PackageObject ::= ‘package’ ‘object’ ObjectDef object with package in mods. CompilationUnit ::= {‘package’ QualId semi} TopStatSeq Package(qid, stats) diff --git a/docs/docs/reference/changed-features/compiler-plugins.md b/docs/docs/reference/changed-features/compiler-plugins.md index 7009659e0f1a..19f39ea759c4 100644 --- a/docs/docs/reference/changed-features/compiler-plugins.md +++ b/docs/docs/reference/changed-features/compiler-plugins.md @@ -62,14 +62,14 @@ import dotty.tools.dotc.core.Symbols._ import dotty.tools.dotc.plugins.{PluginPhase, StandardPlugin} import dotty.tools.dotc.transform.{Pickler, Staging} -class DivideZero extends StandardPlugin with +class DivideZero extends StandardPlugin: val name: String = "divideZero" override val description: String = "divide zero check" def init(options: List[String]): List[PluginPhase] = (new DivideZeroPhase) :: Nil -class DivideZeroPhase extends PluginPhase with +class DivideZeroPhase extends PluginPhase: import tpd._ val phaseName = "divideZero" @@ -108,7 +108,7 @@ import dotty.tools.dotc.core.Contexts.Context import dotty.tools.dotc.core.Phases.Phase import dotty.tools.dotc.plugins.ResearchPlugin -class DummyResearchPlugin extends ResearchPlugin with +class DummyResearchPlugin extends ResearchPlugin: val name: String = "dummy" override val description: String = "dummy research plugin" diff --git a/docs/docs/reference/changed-features/implicit-conversions-spec.md b/docs/docs/reference/changed-features/implicit-conversions-spec.md index 127bad7ef2cc..33557ecef72c 100644 --- a/docs/docs/reference/changed-features/implicit-conversions-spec.md +++ b/docs/docs/reference/changed-features/implicit-conversions-spec.md @@ -16,7 +16,7 @@ The standard library defines an abstract class `Conversion`: ```scala package scala @java.lang.FunctionalInterface -abstract class Conversion[-T, +U] extends Function1[T, U] with +abstract class Conversion[-T, +U] extends Function1[T, U]: def apply(x: T): U ``` diff --git a/docs/docs/reference/changed-features/main-functions.md b/docs/docs/reference/changed-features/main-functions.md index 29aac8f5f522..b6897762797b 100644 --- a/docs/docs/reference/changed-features/main-functions.md +++ b/docs/docs/reference/changed-features/main-functions.md @@ -61,7 +61,7 @@ The Scala compiler generates a program from a `@main` method `f` as follows: For instance, the `happyBirthDay` method above would generate additional code equivalent to the following class: ```scala -final class happyBirthday with +final class happyBirthday: import scala.util.{CommandLineParser => CLP} def main(args: Array[String]): Unit = try diff --git a/docs/docs/reference/changed-features/numeric-literals.md b/docs/docs/reference/changed-features/numeric-literals.md index 397d4e57c7c2..3ac84541592f 100644 --- a/docs/docs/reference/changed-features/numeric-literals.md +++ b/docs/docs/reference/changed-features/numeric-literals.md @@ -130,7 +130,7 @@ class MalformedNumber(msg: String = "malformed number literal") extends FromDigi As a fully worked out example, here is an implementation of a new numeric class, `BigFloat`, that accepts numeric literals. `BigFloat` is defined in terms of a `BigInt` mantissa and an `Int` exponent: ```scala -case class BigFloat(mantissa: BigInt, exponent: Int) with +case class BigFloat(mantissa: BigInt, exponent: Int): override def toString = s"${mantissa}e${exponent}" ``` @@ -145,7 +145,7 @@ The companion object of `BigFloat` defines an `apply` constructor method to cons from a `digits` string. Here is a possible implementation: ```scala -object BigFloat with +object BigFloat: import scala.util.FromDigits def apply(digits: String): BigFloat = @@ -206,7 +206,7 @@ To do this, replace the `FromDigits` instance in the `BigFloat` object by the fo object BigFloat: ... - class FromDigits extends FromDigits.Floating[BigFloat] with + class FromDigits extends FromDigits.Floating[BigFloat]: def fromDigits(digits: String) = apply(digits) given FromDigits with diff --git a/docs/docs/reference/changed-features/pattern-matching.md b/docs/docs/reference/changed-features/pattern-matching.md index 1f2ea964f95e..b61ce8fa886e 100644 --- a/docs/docs/reference/changed-features/pattern-matching.md +++ b/docs/docs/reference/changed-features/pattern-matching.md @@ -121,7 +121,7 @@ For example: ```scala -class FirstChars(s: String) extends Product with +class FirstChars(s: String) extends Product: def _1 = s.charAt(0) def _2 = s.charAt(1) @@ -147,7 +147,7 @@ object FirstChars: ```scala -class Nat(val x: Int) with +class Nat(val x: Int): def get: Int = x def isEmpty = x < 0 diff --git a/docs/docs/reference/changed-features/structural-types.md b/docs/docs/reference/changed-features/structural-types.md index 059f9b353e5a..9a056fb2beee 100644 --- a/docs/docs/reference/changed-features/structural-types.md +++ b/docs/docs/reference/changed-features/structural-types.md @@ -34,13 +34,13 @@ configure how fields and methods should be resolved. Here's an example of a structural type `Person`: ```scala - class Record(elems: (String, Any)*) extends Selectable with + class Record(elems: (String, Any)*) extends Selectable: private val fields = elems.toMap def selectDynamic(name: String): Any = fields(name) type Person = Record { val name: String; val age: Int } ``` - + The type `Person` adds a _refinement_ to its parent type `Record` that defines the two fields `name` and `age`. We say the refinement is _structural_ since `name` and `age` are not defined in the parent type. But they exist nevertheless as members of class `Person`. For instance, the following program would print "Emma is 42 years old.": @@ -82,10 +82,10 @@ Structural types can also be accessed using [Java reflection](https://www.oracle ```scala type Closeable = { def close(): Unit } - class FileInputStream with + class FileInputStream: def close(): Unit - class Channel with + class Channel: def close(): Unit ``` diff --git a/docs/docs/reference/contextual/context-functions.md b/docs/docs/reference/contextual/context-functions.md index c63e9015cbdf..46b7ffa539ae 100644 --- a/docs/docs/reference/contextual/context-functions.md +++ b/docs/docs/reference/contextual/context-functions.md @@ -67,12 +67,12 @@ the aim is to construct tables like this: The idea is to define classes for `Table` and `Row` that allow the addition of elements via `add`: ```scala - class Table with + class Table: val rows = new ArrayBuffer[Row] def add(r: Row): Unit = rows += r override def toString = rows.mkString("Table(", ", ", ")") - class Row with + class Row: val cells = new ArrayBuffer[Cell] def add(c: Cell): Unit = cells += c override def toString = cells.mkString("Row(", ", ", ")") diff --git a/docs/docs/reference/contextual/conversions.md b/docs/docs/reference/contextual/conversions.md index 26476e1fc3c3..5dae928c9620 100644 --- a/docs/docs/reference/contextual/conversions.md +++ b/docs/docs/reference/contextual/conversions.md @@ -6,7 +6,7 @@ title: "Implicit Conversions" Implicit conversions are defined by given instances of the `scala.Conversion` class. This class is defined in package `scala` as follows: ```scala -abstract class Conversion[-T, +U] extends (T => U) with +abstract class Conversion[-T, +U] extends (T => U): def apply (x: T): U ``` For example, here is an implicit conversion from `String` to `Token`: @@ -43,15 +43,15 @@ conversion from `Int` to `java.lang.Integer` can be defined as follows: 2. The "magnet" pattern is sometimes used to express many variants of a method. Instead of defining overloaded versions of the method, one can also let the method take one or more arguments of specially defined "magnet" types, into which various argument types can be converted. Example: ```scala - object Completions with + object Completions: // The argument "magnet" type - enum CompletionArg with + enum CompletionArg: case Error(s: String) case Response(f: Future[HttpResponse]) case Status(code: Future[StatusCode]) - object CompletionArg with + object CompletionArg: // conversions defining the possible arguments to pass to `complete` // these always come with CompletionArg diff --git a/docs/docs/reference/contextual/extension-methods.md b/docs/docs/reference/contextual/extension-methods.md index 647fd95afc1e..a89658d14608 100644 --- a/docs/docs/reference/contextual/extension-methods.md +++ b/docs/docs/reference/contextual/extension-methods.md @@ -174,7 +174,7 @@ There are four possible ways for an extension method to be applicable: Here is an example for the first rule: ```scala -trait IntOps with +trait IntOps: extension (i: Int) def isZero: Boolean = i == 0 extension (i: Int) def safeMod(x: Int): Option[Int] = @@ -182,13 +182,13 @@ trait IntOps with if x.isZero then None else Some(i % x) -object IntOpsEx extends IntOps with +object IntOpsEx extends IntOps: extension (i: Int) def safeDiv(x: Int): Option[Int] = // extension method brought into scope via inheritance from IntOps if x.isZero then None else Some(i / x) -trait SafeDiv with +trait SafeDiv: import IntOpsEx._ // brings safeDiv and safeMod into scope extension (i: Int) def divide(d: Int): Option[(Int, Int)] = @@ -209,9 +209,9 @@ given ops1: IntOps with {} // brings safeMod into scope By the third and fourth rule, an extension method is available if it is in the implicit scope of the receiver type or in a given instance in that scope. Example: ```scala -class List[T] with +class List[T]: ... -object List with +object List: ... extension [T](xs: List[List[T]]) def flatten: List[T] = xs.foldLeft(Nil: List[T])(_ ++ _) diff --git a/docs/docs/reference/contextual/givens.md b/docs/docs/reference/contextual/givens.md index 7279f78c48a9..b289b6cf9bca 100644 --- a/docs/docs/reference/contextual/givens.md +++ b/docs/docs/reference/contextual/givens.md @@ -7,7 +7,7 @@ Given instances (or, simply, "givens") define "canonical" values of certain type that serve for synthesizing arguments to [context parameters](./using-clauses.md). Example: ```scala -trait Ord[T] with +trait Ord[T]: def compare(x: T, y: T): Int extension (x: T) def < (y: T) = compare(x, y) < 0 extension (x: T) def > (y: T) = compare(x, y) > 0 @@ -130,7 +130,7 @@ import scala.util.NotGiven trait Tagged[A] case class Foo[A](value: Boolean) -object Foo with +object Foo: given fooTagged[A](using Tagged[A]): Foo[A] = Foo(true) given fooNotTagged[A](using NotGiven[Tagged[A]]): Foo[A] = Foo(false) diff --git a/docs/docs/reference/contextual/multiversal-equality.md b/docs/docs/reference/contextual/multiversal-equality.md index c3cc82bd688f..35a232903576 100644 --- a/docs/docs/reference/contextual/multiversal-equality.md +++ b/docs/docs/reference/contextual/multiversal-equality.md @@ -172,7 +172,7 @@ we are dealing with a refinement of pre-existing, universal equality. It is best Say you want to come up with a safe version of the `contains` method on `List[T]`. The original definition of `contains` in the standard library was: ```scala -class List[+T] with +class List[+T]: ... def contains(x: Any): Boolean ``` diff --git a/docs/docs/reference/contextual/type-classes.md b/docs/docs/reference/contextual/type-classes.md index 742e4022481a..5911eff48eed 100644 --- a/docs/docs/reference/contextual/type-classes.md +++ b/docs/docs/reference/contextual/type-classes.md @@ -16,10 +16,10 @@ Here are some examples of common type classes: Here's the `Monoid` type class definition: ```scala -trait SemiGroup[T] with +trait SemiGroup[T]: extension (x: T) def combine (y: T): T -trait Monoid[T] extends SemiGroup[T] with +trait Monoid[T] extends SemiGroup[T]: def unit: T ``` @@ -49,7 +49,7 @@ def combineAll[T: Monoid](xs: List[T]): T = To get rid of the `summon[...]` we can define a `Monoid` object as follows: ```scala -object Monoid with +object Monoid: def apply[T](using m: Monoid[T]) = m ``` @@ -68,7 +68,7 @@ Therefore we write it `F[_]`, hinting that the type `F` takes another type as ar The definition of a generic `Functor` would thus be written as: ```scala -trait Functor[F[_]] with +trait Functor[F[_]]: def map[A, B](x: F[A], f: A => B): F[B] ``` @@ -100,7 +100,7 @@ That's a first step, but in practice we probably would like the `map` function t As in the previous example of Monoids, [`extension` methods](extension-methods.md) help achieving that. Let's re-define the `Functor` type class with extension methods. ```scala -trait Functor[F[_]] with +trait Functor[F[_]]: extension [A](x: F[A]) def map[B](f: A => B): F[B] ``` @@ -138,7 +138,7 @@ That's where `Monad` comes in. A `Monad` for type `F[_]` is a `Functor[F]` with Here is the translation of this definition in Scala 3: ```scala -trait Monad[F[_]] extends Functor[F] with +trait Monad[F[_]] extends Functor[F]: /** The unit value for a monad */ def pure[A](x: A): F[A] diff --git a/docs/docs/reference/dropped-features/auto-apply.md b/docs/docs/reference/dropped-features/auto-apply.md index 78d699e81596..9ff9aa648502 100644 --- a/docs/docs/reference/dropped-features/auto-apply.md +++ b/docs/docs/reference/dropped-features/auto-apply.md @@ -73,10 +73,10 @@ by a nullary method or _vice versa_. Instead, both methods must agree exactly in their parameter lists. ```scala -class A with +class A: def next(): Int -class B extends A with +class B extends A: def next: Int // overriding error: incompatible type ``` diff --git a/docs/docs/reference/enums/adts.md b/docs/docs/reference/enums/adts.md index 2cddf5d83fbb..6bfb188b349d 100644 --- a/docs/docs/reference/enums/adts.md +++ b/docs/docs/reference/enums/adts.md @@ -8,7 +8,7 @@ types (ADTs) and their generalized version (GADTs). Here is an example how an `Option` type can be represented as an ADT: ```scala -enum Option[+T] with +enum Option[+T]: case Some(x: T) case None ``` @@ -23,7 +23,7 @@ The `extends` clauses that were omitted in the example above can also be given explicitly: ```scala -enum Option[+T] with +enum Option[+T]: case Some(x: T) extends Option[T] case None extends Option[Nothing] ``` @@ -59,7 +59,7 @@ As all other enums, ADTs can define methods. For instance, here is `Option` agai `isDefined` method and an `Option(...)` constructor in its companion object. ```scala -enum Option[+T] with +enum Option[+T]: case Some(x: T) case None diff --git a/docs/docs/reference/enums/enums.md b/docs/docs/reference/enums/enums.md index 37dc5c842a83..219a831a445e 100644 --- a/docs/docs/reference/enums/enums.md +++ b/docs/docs/reference/enums/enums.md @@ -153,7 +153,7 @@ For a more in-depth example of using Scala 3 enums from Java, see [this test](ht ### Implementation Enums are represented as `sealed` classes that extend the `scala.reflect.Enum` trait. -This trait defines a single public method, `ordinal` with +This trait defines a single public method, `ordinal`: ```scala package scala.reflect diff --git a/docs/docs/reference/metaprogramming/erased-terms.md b/docs/docs/reference/metaprogramming/erased-terms.md index 1e7cde748d5a..dde296ebff83 100644 --- a/docs/docs/reference/metaprogramming/erased-terms.md +++ b/docs/docs/reference/metaprogramming/erased-terms.md @@ -23,7 +23,7 @@ class IsOff[S <: State] object IsOff: given isOff: IsOff[Off] = new IsOff[Off] -class Machine[S <: State] with +class Machine[S <: State]: def turnedOn(using IsOff[S]): Machine[On] = new Machine[On] val m = new Machine[Off] @@ -130,7 +130,7 @@ object IsOn: // require that this evidence exists at compile time erased given IsOn[On] = new IsOn[On] -class Machine[S <: State] private () with +class Machine[S <: State] private (): // ev will disappear from both functions def turnedOn(using erased ev: IsOff[S]): Machine[On] = new Machine[On] def turnedOff(using erased ev: IsOn[S]): Machine[Off] = new Machine[Off] @@ -163,7 +163,7 @@ sealed trait State final class On extends State final class Off extends State -class Machine[S <: State] with +class Machine[S <: State]: transparent inline def turnOn(): Machine[On] = inline erasedValue[S] match case _: Off => new Machine[On] diff --git a/docs/docs/reference/metaprogramming/inline.md b/docs/docs/reference/metaprogramming/inline.md index a77540af5099..ba18f55d76d8 100644 --- a/docs/docs/reference/metaprogramming/inline.md +++ b/docs/docs/reference/metaprogramming/inline.md @@ -143,11 +143,11 @@ Inline methods can override other non-inline methods. The rules are as follows: 1. If an inline method `f` implements or overrides another, non-inline method, the inline method can also be invoked at runtime. For instance, consider the scenario: ```scala - abstract class A with + abstract class A: def f: Int def g: Int = f - class B extends A with + class B extends A: inline def f = 22 override inline def g = f + 11 @@ -168,7 +168,7 @@ Inline methods can override other non-inline methods. The rules are as follows: 3. Inline methods can also be abstract. An abstract inline method can be implemented only by other inline methods. It cannot be invoked directly: ```scala - abstract class A with + abstract class A: inline def f: Int object B extends A: @@ -250,7 +250,7 @@ specialized to a more precise type upon expansion. Example: ```scala class A -class B extends A with +class B extends A: def m = true transparent inline def choose(b: Boolean): A = @@ -535,7 +535,7 @@ not. We can create a set of implicit definitions like this: ```scala trait SetFor[T, S <: Set[T]] -class LowPriority with +class LowPriority: implicit def hashSetFor[T]: SetFor[T, HashSet[T]] = ... object SetsFor extends LowPriority: diff --git a/docs/docs/reference/metaprogramming/tasty-inspect.md b/docs/docs/reference/metaprogramming/tasty-inspect.md index f02b7fdbdb08..3547b8939a3d 100644 --- a/docs/docs/reference/metaprogramming/tasty-inspect.md +++ b/docs/docs/reference/metaprogramming/tasty-inspect.md @@ -21,7 +21,7 @@ To inspect the trees of a TASTy file a consumer can be defined in the following import scala.quoted._ import scala.tasty.inspector._ -class MyInspector extends TastyInspector with +class MyInspector extends TastyInspector: protected def processCompilationUnit(using Quotes)(tree: quotes.reflect.Tree): Unit = import quotes.reflect._ // Do something with the tree @@ -30,7 +30,7 @@ class MyInspector extends TastyInspector with Then the consumer can be instantiated with the following code to get the tree of the `foo/Bar.tasty` file. ```scala -object Test with +object Test: def main(args: Array[String]): Unit = new MyInspector().inspectTastyFiles("foo/Bar.tasty") ``` diff --git a/docs/docs/reference/new-types/dependent-function-types-spec.md b/docs/docs/reference/new-types/dependent-function-types-spec.md index 0cf3a8c00b16..5f9bf9cf5f6a 100644 --- a/docs/docs/reference/new-types/dependent-function-types-spec.md +++ b/docs/docs/reference/new-types/dependent-function-types-spec.md @@ -75,7 +75,7 @@ In the following example the depend type `f.Eff` refers to the effect type `CanT trait Effect // Type X => Y -abstract class Fun[-X, +Y] with +abstract class Fun[-X, +Y]: type Eff <: Effect def apply(x: X): Eff ?=> Y @@ -85,11 +85,11 @@ class CanIO extends Effect given ct: CanThrow = new CanThrow given ci: CanIO = new CanIO -class I2S extends Fun[Int, String] with +class I2S extends Fun[Int, String]: type Eff = CanThrow def apply(x: Int) = x.toString -class S2I extends Fun[String, Int] with +class S2I extends Fun[String, Int]: type Eff = CanIO def apply(x: String) = x.length diff --git a/docs/docs/reference/new-types/intersection-types.md b/docs/docs/reference/new-types/intersection-types.md index cf232c621ace..a2cfc1f380c8 100644 --- a/docs/docs/reference/new-types/intersection-types.md +++ b/docs/docs/reference/new-types/intersection-types.md @@ -59,7 +59,7 @@ So if one defines a class `C` that inherits `A` and `B`, one needs to give at that point a definition of a `children` method with the required type. ```scala -class C extends A, B with +class C extends A, B: def children: List[A & B] = ??? ``` diff --git a/docs/docs/reference/other-new-features/creator-applications.md b/docs/docs/reference/other-new-features/creator-applications.md index 0369e3f0c35b..387202720f9c 100644 --- a/docs/docs/reference/other-new-features/creator-applications.md +++ b/docs/docs/reference/other-new-features/creator-applications.md @@ -9,7 +9,7 @@ function application, without needing to write `new`. Scala 3 generalizes this scheme to all concrete classes. Example: ```scala -class StringBuilder(s: String) with +class StringBuilder(s: String): def this() = this("") StringBuilder("abc") // same as new StringBuilder("abc") diff --git a/docs/docs/reference/other-new-features/explicit-nulls.md b/docs/docs/reference/other-new-features/explicit-nulls.md index 82f61eead706..b531774ac1d5 100644 --- a/docs/docs/reference/other-new-features/explicit-nulls.md +++ b/docs/docs/reference/other-new-features/explicit-nulls.md @@ -39,7 +39,7 @@ The new type system is unsound with respect to `null`. This means there are stil The unsoundness happens because uninitialized fields in a class start out as `null`: ```scala -class C with +class C: val f: String = foo(f) def foo(f2: String): String = f2 @@ -114,7 +114,7 @@ Specifically, we patch ``` ==> ```scala - class C with + class C: val s: String|UncheckedNull val x: Int ``` @@ -132,7 +132,7 @@ Specifically, we patch Notice this is rule is sometimes too conservative, as witnessed by ```scala - class InScala with + class InScala: val c: C[Bool] = ??? // C as above val b: Bool = c.foo() // no longer typechecks, since foo now returns Bool|Null ``` @@ -169,7 +169,7 @@ Specifically, we patch ``` ==> ```scala - class BoxFactory[T] with + class BoxFactory[T]: def makeBox(): Box[T | UncheckedNull] | UncheckedNull def makeCrazyBoxes(): List[Box[List[T] | UncheckedNull]] | UncheckedNull ``` @@ -195,7 +195,7 @@ Specifically, we patch ``` ==> ```scala - class Constants with + class Constants: val NAME: String("name") = "name" val AGE: Int(0) = 0 val CHAR: Char('a') = 'a' @@ -215,7 +215,7 @@ Specifically, we patch ``` ==> ```scala - class C with + class C: val name: String def getNames(prefix: String | UncheckedNull): List[String] // we still need to nullify the paramter types def getBoxedName(): Box[String | UncheckedNull] // we don't append `UncheckedNull` to the outmost level, but we still need to nullify inside diff --git a/docs/docs/reference/other-new-features/export.md b/docs/docs/reference/other-new-features/export.md index 697939f053ae..2a7aaada28ef 100644 --- a/docs/docs/reference/other-new-features/export.md +++ b/docs/docs/reference/other-new-features/export.md @@ -9,16 +9,16 @@ An export clause defines aliases for selected members of an object. Example: class BitMap class InkJet -class Printer with +class Printer: type PrinterType def print(bits: BitMap): Unit = ??? def status: List[String] = ??? -class Scanner with +class Scanner: def scan(): BitMap = ??? def status: List[String] = ??? -class Copier with +class Copier: private val printUnit = new Printer { type PrinterType = InkJet } private val scanUnit = new Scanner diff --git a/docs/docs/reference/other-new-features/indentation.md b/docs/docs/reference/other-new-features/indentation.md index 691fd1500265..08cd79f02a71 100644 --- a/docs/docs/reference/other-new-features/indentation.md +++ b/docs/docs/reference/other-new-features/indentation.md @@ -122,7 +122,7 @@ With these new rules, the following constructs are all valid: trait A: def f: Int -class C(x: Int) extends A with +class C(x: Int) extends A: def f = x object O: @@ -258,7 +258,7 @@ For instance, the following end markers are all legal: ```scala package p1.p2: - abstract class C() with + abstract class C(): def this(x: Int) = this() diff --git a/docs/docs/reference/other-new-features/matchable.md b/docs/docs/reference/other-new-features/matchable.md index 3513e0f20049..c4814af64f3f 100644 --- a/docs/docs/reference/other-new-features/matchable.md +++ b/docs/docs/reference/other-new-features/matchable.md @@ -75,7 +75,7 @@ extended by both `AnyVal` and `AnyRef`. Since `Matchable` is a supertype of ever Here is the hierarchy of top-level classes and traits with their defined methods: ```scala -abstract class Any with +abstract class Any: def getClass def isInstanceOf def asInstanceOf @@ -102,7 +102,7 @@ Matchable warning is turned on. The most common such method is the universal `equals` method. It will have to be written as in the following example: ```scala -class C(val x: String) with +class C(val x: String): override def equals(that: Any): Boolean = that.asInstanceOf[Matchable] match diff --git a/docs/docs/reference/other-new-features/open-classes.md b/docs/docs/reference/other-new-features/open-classes.md index 1de2e57fc66d..c1ee2def453b 100644 --- a/docs/docs/reference/other-new-features/open-classes.md +++ b/docs/docs/reference/other-new-features/open-classes.md @@ -8,7 +8,7 @@ An `open` modifier on a class signals that the class is planned for extensions. // File Writer.scala package p -open class Writer[T] with +open class Writer[T]: /** Sends to stdout, can be overridden */ def send(x: T) = println(x) @@ -20,7 +20,7 @@ end Writer // File EncryptedWriter.scala package p -class EncryptedWriter[T: Encryptable] extends Writer[T] with +class EncryptedWriter[T: Encryptable] extends Writer[T]: override def send(x: T) = super.send(encrypt(x)) ``` An open class typically comes with some documentation that describes diff --git a/docs/docs/reference/other-new-features/safe-initialization.md b/docs/docs/reference/other-new-features/safe-initialization.md index 1a23474de166..2d115745bb57 100644 --- a/docs/docs/reference/other-new-features/safe-initialization.md +++ b/docs/docs/reference/other-new-features/safe-initialization.md @@ -14,11 +14,11 @@ To get a feel of how it works, we first show several examples below. Given the following code snippet: ``` scala -abstract class AbstractFile with +abstract class AbstractFile: def name: String val extension: String = name.substring(4) -class RemoteFile(url: String) extends AbstractFile with +class RemoteFile(url: String) extends AbstractFile: val localFile: String = s"${url.##}.tmp" // error: usage of `localFile` before it's initialized def name: String = localFile ``` @@ -63,11 +63,11 @@ The checker will report: Given the code below: ``` scala -abstract class Parent with +abstract class Parent: val f: () => String = () => this.message def message: String -class Child extends Parent with +class Child extends Parent: val a = f() val b = "hello" // error def message: String = b @@ -122,11 +122,11 @@ following example shows: ``` scala class MyException(val b: B) extends Exception("") -class A with +class A: val b = try { new B } catch { case myEx: MyException => myEx.b } println(b.a) -class B with +class B: throw new MyException(this) val a: Int = 1 ``` @@ -141,10 +141,10 @@ field points to an initialized object may not later point to an object under initialization. As an example, the following code will be rejected: ``` scala -trait Reporter with +trait Reporter: def report(msg: String): Unit -class FileReporter(ctx: Context) extends Reporter with +class FileReporter(ctx: Context) extends Reporter: ctx.typer.reporter = this // ctx now reaches an uninitialized object val file: File = new File("report.txt") def report(msg: String) = file.write(msg) @@ -214,11 +214,11 @@ project boundaries. For example, the following code passes the check when the two classes are defined in the same project: ```Scala -class Base with +class Base: private val map: mutable.Map[Int, String] = mutable.Map.empty def enter(k: Int, v: String) = map(k) = v -class Child extends Base with +class Child extends Base: enter(1, "one") enter(2, "two") ``` diff --git a/docs/docs/reference/other-new-features/targetName.md b/docs/docs/reference/other-new-features/targetName.md index a1b8f9150c38..572d7a5e2146 100644 --- a/docs/docs/reference/other-new-features/targetName.md +++ b/docs/docs/reference/other-new-features/targetName.md @@ -70,9 +70,9 @@ between two definitions that have otherwise the same names and types. So the fol ```scala import annotation.targetName -class A with +class A: def f(): Int = 1 -class B extends A with +class B extends A: @targetName("g") def f(): Int = 2 ``` @@ -98,9 +98,9 @@ be present in the original code. So the following example would also be in error ```scala import annotation.targetName -class A with +class A: def f(): Int = 1 -class B extends A with +class B extends A: @targetName("f") def g(): Int = 2 ``` @@ -109,7 +109,7 @@ different names. But once we switch to target names, there is a clash that is re ``` -- [E120] Naming Error: test.scala:4:6 ----------------------------------------- -4 |class B extends A with +4 |class B extends A: | ^ | Name clash between defined and inherited member: | def f(): Int in class A at line 3 and diff --git a/docs/docs/reference/other-new-features/threadUnsafe-annotation.md b/docs/docs/reference/other-new-features/threadUnsafe-annotation.md index 56ae89ea7e96..2c5a3df9c82c 100644 --- a/docs/docs/reference/other-new-features/threadUnsafe-annotation.md +++ b/docs/docs/reference/other-new-features/threadUnsafe-annotation.md @@ -12,6 +12,6 @@ a `lazy val`. When this annotation is used, the initialization of the ```scala import scala.annotation.threadUnsafe -class Hello with +class Hello: @threadUnsafe lazy val x: Int = 1 ``` diff --git a/docs/docs/reference/other-new-features/trait-parameters.md b/docs/docs/reference/other-new-features/trait-parameters.md index fd200c92bf53..1655e338b32c 100644 --- a/docs/docs/reference/other-new-features/trait-parameters.md +++ b/docs/docs/reference/other-new-features/trait-parameters.md @@ -9,7 +9,7 @@ Scala 3 allows traits to have parameters, just like classes have parameters. trait Greeting(val name: String): def msg = s"How are you, $name" -class C extends Greeting("Bob") with +class C extends Greeting("Bob"): println(msg) ``` diff --git a/docs/docs/release-notes/syntax-changes-0.22.md b/docs/docs/release-notes/syntax-changes-0.22.md index cc5cf45ebf1e..64207d72e9d1 100644 --- a/docs/docs/release-notes/syntax-changes-0.22.md +++ b/docs/docs/release-notes/syntax-changes-0.22.md @@ -94,7 +94,7 @@ class Str(str: String) extends Text: class Append(txt1: Text, txt2: Text) extends Text: def toString = txt1 ++ txt2 -object Empty extends Text with +object Empty extends Text: def toString = "" extension on (t: Text): diff --git a/stdlib-bootstrapped-tasty-tests/test/BootstrappedStdLibTASYyTest.scala b/stdlib-bootstrapped-tasty-tests/test/BootstrappedStdLibTASYyTest.scala index 43f365410fc3..ef004baa191a 100644 --- a/stdlib-bootstrapped-tasty-tests/test/BootstrappedStdLibTASYyTest.scala +++ b/stdlib-bootstrapped-tasty-tests/test/BootstrappedStdLibTASYyTest.scala @@ -12,7 +12,7 @@ import scala.quoted._ import java.io.File.pathSeparator import java.io.File.separator -class BootstrappedStdLibTASYyTest with +class BootstrappedStdLibTASYyTest: import BootstrappedStdLibTASYyTest._ @@ -88,7 +88,7 @@ class BootstrappedStdLibTASYyTest with end BootstrappedStdLibTASYyTest -object BootstrappedStdLibTASYyTest with +object BootstrappedStdLibTASYyTest: def scalaLibJarPath = System.getProperty("dotty.scala.library") def scalaLibClassesPath = diff --git a/stdlib-bootstrapped/test/Main.scala b/stdlib-bootstrapped/test/Main.scala index 8c2782b90b0e..1dad89eceffc 100644 --- a/stdlib-bootstrapped/test/Main.scala +++ b/stdlib-bootstrapped/test/Main.scala @@ -3,7 +3,7 @@ package hello enum Color: case Red, Green, Blue -object HelloWorld with +object HelloWorld: def main(args: Array[String]): Unit = { println("hello dotty.superbootstrapped!") println(Color.Red) diff --git a/tests/bench/string-interpolation-macro/Test.scala b/tests/bench/string-interpolation-macro/Test.scala index 094462aa175b..e32eeea2fef7 100644 --- a/tests/bench/string-interpolation-macro/Test.scala +++ b/tests/bench/string-interpolation-macro/Test.scala @@ -1,4 +1,4 @@ import Macro._ -class Test with +class Test: def test: String = x"a${1}b${2}c${3}d${4}e${5}f" diff --git a/tests/disabled/pos/i8311.scala b/tests/disabled/pos/i8311.scala index 0d4423d93fb8..eeecd97a7e7e 100644 --- a/tests/disabled/pos/i8311.scala +++ b/tests/disabled/pos/i8311.scala @@ -1,12 +1,12 @@ -trait Show[O] with +trait Show[O]: extension (o: O) def show: String class Box[A] class Foo -object test with +object test: given box[A](using Show[A]): Show[Box[A]] = _.toString given foo: Show[Foo] = _.toString diff --git a/tests/neg-custom-args/explicit-nulls/byname-nullables.scala b/tests/neg-custom-args/explicit-nulls/byname-nullables.scala index ada838b269f6..4da2659bbde6 100644 --- a/tests/neg-custom-args/explicit-nulls/byname-nullables.scala +++ b/tests/neg-custom-args/explicit-nulls/byname-nullables.scala @@ -1,4 +1,4 @@ -object Test1 with +object Test1: def f(x: String) = x ++ x @@ -9,7 +9,7 @@ object Test1 with else x -object Test2 with +object Test2: def f(x: => String) = x ++ x @@ -19,7 +19,7 @@ object Test2 with if x != null then f(x) // error: f is call-by-name else x -object Test3 with +object Test3: def f(x: String, y: String) = x @@ -31,7 +31,7 @@ object Test3 with if x != null then f(x, 1) // OK: not-null check successfully dropped else x -object Test4 with +object Test4: def f(x: String, y: String) = x @@ -43,7 +43,7 @@ object Test4 with if x != null then f(identity(x), 1) // error: dropping not null check fails typing else x -object Test5 with +object Test5: import compiletime.byName def f(x: String, y: String) = x @@ -56,7 +56,7 @@ object Test5 with if x != null then f(byName(identity(x)), 1) // OK, byName avoids the flow typing else x -object Test6 with +object Test6: def f(x: String, y: String) = x @@ -68,7 +68,7 @@ object Test6 with if x != null then f(x, 1) // error: dropping not null check typechecks OK, but gives incompatible result type else x -object Test7 with +object Test7: import compiletime.byName def f(x: String, y: String) = x diff --git a/tests/neg-custom-args/explicit-nulls/byname-nullables1.scala b/tests/neg-custom-args/explicit-nulls/byname-nullables1.scala index eb28a5af96c0..a1c1924c545e 100644 --- a/tests/neg-custom-args/explicit-nulls/byname-nullables1.scala +++ b/tests/neg-custom-args/explicit-nulls/byname-nullables1.scala @@ -1,7 +1,7 @@ def f(op: => Boolean): Unit = () def f(op: Int): Unit = () -class C with +class C: var fld: String | Null = null def test() = diff --git a/tests/neg-custom-args/fatal-warnings/enum-variance.scala b/tests/neg-custom-args/fatal-warnings/enum-variance.scala index b342a28091f2..efe0dbbc6cdd 100644 --- a/tests/neg-custom-args/fatal-warnings/enum-variance.scala +++ b/tests/neg-custom-args/fatal-warnings/enum-variance.scala @@ -1,10 +1,10 @@ -enum View[-T] with +enum View[-T]: case Refl(f: T => T) // error: enum case Refl requires explicit declaration of type T enum ExplicitView[-T]: // desugared version of View case Refl[-T](f: T => T) extends ExplicitView[T] // error: contravariant type T occurs in covariant position -enum InvariantView[-T, +U] extends (T => U) with +enum InvariantView[-T, +U] extends (T => U): case Refl[T](f: T => T) extends InvariantView[T, T] final def apply(t: T): U = this match diff --git a/tests/neg-custom-args/fatal-warnings/i8781b.scala b/tests/neg-custom-args/fatal-warnings/i8781b.scala index ebd3e02d42f8..a30b0e5249c9 100644 --- a/tests/neg-custom-args/fatal-warnings/i8781b.scala +++ b/tests/neg-custom-args/fatal-warnings/i8781b.scala @@ -1,4 +1,4 @@ -object Test with +object Test: println((3: Boolean | Int).isInstanceOf[Boolean]) diff --git a/tests/neg-custom-args/fatal-warnings/opaque-match.scala b/tests/neg-custom-args/fatal-warnings/opaque-match.scala index 8f167932406a..f48a11168274 100644 --- a/tests/neg-custom-args/fatal-warnings/opaque-match.scala +++ b/tests/neg-custom-args/fatal-warnings/opaque-match.scala @@ -1,6 +1,6 @@ case class C() -object O with +object O: opaque type T <: C = C val x: T = C() (??? : Any) match @@ -17,7 +17,7 @@ def Test[T] = (??? : Any) match case _: List[O.T] => ??? // error (??? : Any) match - case _: List[O.T @unchecked] => ??? // OK + case _: List[O.T @unchecked] => ??? // OK (??? : Any) match case _: List[T] => ??? // error diff --git a/tests/neg-custom-args/fatal-warnings/supertraits.scala b/tests/neg-custom-args/fatal-warnings/supertraits.scala index 039c2713a9d4..9337e2f925a3 100644 --- a/tests/neg-custom-args/fatal-warnings/supertraits.scala +++ b/tests/neg-custom-args/fatal-warnings/supertraits.scala @@ -4,7 +4,7 @@ trait S case object a extends S, TA, TB case object b extends S, TA, TB -object Test with +object Test: def choose0[X](x: X, y: X): X = x def choose1[X <: TA](x: X, y: X): X = x diff --git a/tests/neg-custom-args/infix.scala b/tests/neg-custom-args/infix.scala index cc77f40d24d4..f6f3053087dd 100644 --- a/tests/neg-custom-args/infix.scala +++ b/tests/neg-custom-args/infix.scala @@ -1,11 +1,11 @@ // Compile with -strict -Xfatal-warnings -deprecation -class C with +class C: infix def op(x: Int): Int = ??? def meth(x: Int): Int = ??? def matching(x: Int => Int) = ??? def +(x: Int): Int = ??? -object C with +object C: given AnyRef with extension (x: C) infix def iop (y: Int) = ??? diff --git a/tests/neg-macros/BigFloat/BigFloatFromDigitsImpl_1.scala b/tests/neg-macros/BigFloat/BigFloatFromDigitsImpl_1.scala index 093aa33c682d..a1ecc31b776e 100644 --- a/tests/neg-macros/BigFloat/BigFloatFromDigitsImpl_1.scala +++ b/tests/neg-macros/BigFloat/BigFloatFromDigitsImpl_1.scala @@ -3,7 +3,7 @@ import language.experimental.genericNumberLiterals import scala.util.FromDigits import scala.quoted._ -object BigFloatFromDigitsImpl with +object BigFloatFromDigitsImpl: def apply(digits: Expr[String])(using Quotes): Expr[BigFloat] = digits.value match case Some(ds) => diff --git a/tests/neg-macros/GenericNumLits/EvenFromDigitsImpl_1.scala b/tests/neg-macros/GenericNumLits/EvenFromDigitsImpl_1.scala index 80e2e80ea4e9..1d2e484daa5d 100644 --- a/tests/neg-macros/GenericNumLits/EvenFromDigitsImpl_1.scala +++ b/tests/neg-macros/GenericNumLits/EvenFromDigitsImpl_1.scala @@ -3,7 +3,7 @@ import scala.util.FromDigits import scala.quoted._ import Even._ -object EvenFromDigitsImpl with +object EvenFromDigitsImpl: def apply(digits: Expr[String])(using Quotes): Expr[Even] = digits.value match { case Some(ds) => val ev = diff --git a/tests/neg-macros/i9972b/Test_2.scala b/tests/neg-macros/i9972b/Test_2.scala index 85c50e1880ad..1f94ccf18ee8 100644 --- a/tests/neg-macros/i9972b/Test_2.scala +++ b/tests/neg-macros/i9972b/Test_2.scala @@ -1,5 +1,5 @@ class T[A] -object T with +object T: implicit inline def derived[A]: T[A] = new T[A] diff --git a/tests/neg-with-compiler/GenericNumLits/EvenFromDigitsImpl_1.scala b/tests/neg-with-compiler/GenericNumLits/EvenFromDigitsImpl_1.scala index 80e2e80ea4e9..1d2e484daa5d 100644 --- a/tests/neg-with-compiler/GenericNumLits/EvenFromDigitsImpl_1.scala +++ b/tests/neg-with-compiler/GenericNumLits/EvenFromDigitsImpl_1.scala @@ -3,7 +3,7 @@ import scala.util.FromDigits import scala.quoted._ import Even._ -object EvenFromDigitsImpl with +object EvenFromDigitsImpl: def apply(digits: Expr[String])(using Quotes): Expr[Even] = digits.value match { case Some(ds) => val ev = diff --git a/tests/neg/abstract-givens.scala b/tests/neg/abstract-givens.scala index fbfb1ba2adbe..5aa5bdee88e3 100644 --- a/tests/neg/abstract-givens.scala +++ b/tests/neg/abstract-givens.scala @@ -1,9 +1,9 @@ -trait T with +trait T: given x: Int given y(using Int): String = summon[Int].toString given z[T](using T): List[T] -object Test extends T with +object Test extends T: given x: Int = 22 given y(using Int): String = summon[Int].toString * 22 // error given z[T](using T): Seq[T] = List(summon[T]) // error diff --git a/tests/neg/abstract-inline-val.scala b/tests/neg/abstract-inline-val.scala index 4aa3ede2b578..1bcca078ad52 100644 --- a/tests/neg/abstract-inline-val.scala +++ b/tests/neg/abstract-inline-val.scala @@ -1,4 +1,4 @@ -trait C with +trait C: inline def x: Int inline val y: Int diff --git a/tests/neg/ambiref.scala b/tests/neg/ambiref.scala index 95dc06e1573f..e7a5d5efbd7e 100644 --- a/tests/neg/ambiref.scala +++ b/tests/neg/ambiref.scala @@ -1,43 +1,43 @@ -object test1 with +object test1: - class C with + class C: val x = 0 - object Test with + object Test: val x = 1 - class D extends C with + class D extends C: println(x) // error - new C with + new C: println(x) // error -object test2 with +object test2: def c(y: Float) = - class D with + class D: val y = 2 - new D with + new D: println(y) // error -object test3 with +object test3: def c(y: Float) = - class D with + class D: val y = 2 - class E extends D with - class F with + class E extends D: + class F: println(y) // error -object test4 with +object test4: - class C with + class C: val x = 0 - object Test with + object Test: val x = 1 - class D extends C with + class D extends C: def x(y: Int) = 3 val y: Int = this.x // OK val z: Int = x // OK end test4 val global = 0 -class C with +class C: val global = 1 -object D extends C with +object D extends C: println(global) // OK, since global is defined in package \ No newline at end of file diff --git a/tests/neg/bad-unapplies.scala b/tests/neg/bad-unapplies.scala index ab898d6f86c3..6bf70c3ae6d3 100644 --- a/tests/neg/bad-unapplies.scala +++ b/tests/neg/bad-unapplies.scala @@ -1,19 +1,19 @@ trait A trait B class C extends A, B -object A with +object A: def unapply(x: A): Option[String] = Some(x.toString) def unapply(x: B): Option[String] = Some(x.toString) object B -object D with +object D: def unapply(x: A, y: B): Option[String] = Some(x.toString) -object E with +object E: val unapply: Option[String] = Some("") -object F with +object F: def unapply(x: Int): Boolean = true diff --git a/tests/neg/case-semi.scala b/tests/neg/case-semi.scala index d05919805fa6..b7dfe0a7e524 100644 --- a/tests/neg/case-semi.scala +++ b/tests/neg/case-semi.scala @@ -1,4 +1,4 @@ -object Test with +object Test: type X = Int val x: X = 1 diff --git a/tests/neg/creator-ambiguous.scala b/tests/neg/creator-ambiguous.scala index feed4083ff56..dd476933db1e 100644 --- a/tests/neg/creator-ambiguous.scala +++ b/tests/neg/creator-ambiguous.scala @@ -2,11 +2,11 @@ // This used to succeed with old creator methods scheme // What happened was: the overloading resolution gave an ambiguous // overload, but then the falblback picked the constructor -object Test with +object Test: case class Record(elems: (String, Any)*) - object Record with + object Record: inline def apply[R <: Record](elems: (String, Any)*) : R = new Record(elems: _*).asInstanceOf[R] diff --git a/tests/neg/curried-dependent-ift.scala b/tests/neg/curried-dependent-ift.scala index 8aab2dd89ebe..359514505613 100644 --- a/tests/neg/curried-dependent-ift.scala +++ b/tests/neg/curried-dependent-ift.scala @@ -1,9 +1,9 @@ -trait Ctx1 with +trait Ctx1: type T val x: T val y: T -trait Ctx2 with +trait Ctx2: type T val x: T val y: T diff --git a/tests/neg/endmarkers.scala b/tests/neg/endmarkers.scala index 19880fbc7beb..5c7c1c686cd0 100644 --- a/tests/neg/endmarkers.scala +++ b/tests/neg/endmarkers.scala @@ -1,4 +1,4 @@ -object Test with +object Test: locally { var x = 0 @@ -43,11 +43,11 @@ object Test with x < 10 do () -class Test2 with +class Test2: self => def foo = 1 - object x with + object x: new Test2 { override def foo = 2 end new // error: misaligned end marker @@ -56,16 +56,16 @@ class Test2 with end Test2 // error: misaligned end marker end Test2 -class Test3 with +class Test3: self => def foo = 1 end Test3 // error: misaligned end marker import collection.mutable.HashMap -class Coder(words: List[String]) with +class Coder(words: List[String]): - class Foo with + class Foo: println() end Foo // error: misaligned end marker diff --git a/tests/neg/endmarkers1.scala b/tests/neg/endmarkers1.scala index 2205395b0036..b2b746c57371 100644 --- a/tests/neg/endmarkers1.scala +++ b/tests/neg/endmarkers1.scala @@ -4,7 +4,7 @@ def f7[T](x: Option[T]) = x match case None => end if // error: misaligned end marker -object Test4 with +object Test4: def f[T](x: Option[T]) = x match case Some(y) => case None => diff --git a/tests/neg/enum-values.scala b/tests/neg/enum-values.scala index 9bf531abae98..08069251af0e 100644 --- a/tests/neg/enum-values.scala +++ b/tests/neg/enum-values.scala @@ -1,26 +1,26 @@ package example -enum Tag[T] with +enum Tag[T]: case Int extends Tag[Int] case String extends Tag[String] case OfClass[T]()(using val tag: reflect.ClassTag[T]) extends Tag[T] -enum ListLike[+T] with +enum ListLike[+T]: case Cons[T](head: T, tail: ListLike[T]) extends ListLike[T] case EmptyListLike -object ListLike with +object ListLike: def valuef(s: String): ListLike[?] = ??? // this will usually trigger a "- did you mean ListLike.valuef" addendum -object Extensions with +object Extensions: extension (foo: Nothing) // this will usually trigger an attempted extension method addendum def values: Array[Tag[?]] = ??? -enum TypeCtorsK[F[_]] with +enum TypeCtorsK[F[_]]: case List extends TypeCtorsK[List] case Option extends TypeCtorsK[Option] case Const[T]() extends TypeCtorsK[[U] =>> T] -object UnimportedExtensions with +object UnimportedExtensions: extension (TypeCtorsKModule: TypeCtorsK.type) // this will usually trigger an import suggestions addendum def valueOf(name: String): TypeCtorsK[?] = ??? diff --git a/tests/neg/enums.scala b/tests/neg/enums.scala index c43fb829d9b9..6335def433c1 100644 --- a/tests/neg/enums.scala +++ b/tests/neg/enums.scala @@ -42,10 +42,10 @@ enum Option[+T] derives CanEqual { object DollarNew { - enum MyEnum with + enum MyEnum: case A - object MyEnum with + object MyEnum: def $new: MyEnum = new MyEnum with runtime.EnumValue { // error: anonymous class in method $new extends enum MyEnum, but extending enums is prohibited. override def $ordinal = 1 diff --git a/tests/neg/enumvalues.scala b/tests/neg/enumvalues.scala index 10aa4f3eb6d9..f9d847f5fb63 100644 --- a/tests/neg/enumvalues.scala +++ b/tests/neg/enumvalues.scala @@ -1,7 +1,7 @@ -enum Color with +enum Color: case Red, Green, Blue -enum Option[+T] with +enum Option[+T]: case None extends Option[Nothing] import scala.runtime.EnumValue diff --git a/tests/neg/eql.scala b/tests/neg/eql.scala index a68f73bd5a8a..58378800bbc5 100644 --- a/tests/neg/eql.scala +++ b/tests/neg/eql.scala @@ -1,6 +1,6 @@ -object lst with +object lst: opaque type Lst[+T] = Any - object Lst with + object Lst: given lstCanEqual[T, U]: CanEqual[Lst[T], Lst[U]] = CanEqual.derived val Empty: Lst[Nothing] = ??? end lst diff --git a/tests/neg/exports1.scala b/tests/neg/exports1.scala index 698ab25ac7f8..ecd89c694043 100644 --- a/tests/neg/exports1.scala +++ b/tests/neg/exports1.scala @@ -1,20 +1,20 @@ -object A with +object A: def f: String = "" -trait B with +trait B: def f: String = "abc" -trait B2 extends B with +trait B2 extends B: override def f: String = "abc" -object D extends B with +object D extends B: object b extends B export b._ // ok -object D1 extends B with +object D1 extends B: object b extends B export b.f // error -object D2 extends B with +object D2 extends B: object b2 extends B2 export b2.f // error diff --git a/tests/neg/exports2.scala b/tests/neg/exports2.scala index 6fa18ae52900..913248a2041a 100644 --- a/tests/neg/exports2.scala +++ b/tests/neg/exports2.scala @@ -1,9 +1,9 @@ -object A with +object A: def f: String = "" -trait B with +trait B: def f: String = "abc" -object C extends B with +object C extends B: export A._ // error diff --git a/tests/neg/extend-java-enum-nonstatic.scala b/tests/neg/extend-java-enum-nonstatic.scala index 0bd72cc7d7da..5f0b6d36f8a8 100644 --- a/tests/neg/extend-java-enum-nonstatic.scala +++ b/tests/neg/extend-java-enum-nonstatic.scala @@ -1,22 +1,22 @@ import java.{lang => jl} -object TestSuite with +object TestSuite: def test(op: => Unit): Unit = op test { enum E extends jl.Enum[E] { case A } // error: enum extending java.lang.Enum must be declared in a static scope } -class Container with +class Container: enum E extends jl.Enum[E] { case A } // error: enum extending java.lang.Enum must be declared in a static scope -object Wrap with +object Wrap: def force = enum E extends jl.Enum[E] { case A } // error: enum extending java.lang.Enum must be declared in a static scope -trait Universe with +trait Universe: enum E extends jl.Enum[E] { case A } // error: enum extending java.lang.Enum must be declared in a static scope enum E extends jl.Enum[E] { case A } // ok, a declaration at package level is static. -object Static with +object Static: enum E extends jl.Enum[E] { case A } // ok, a declaration within a static object is static. diff --git a/tests/neg/gadt-approximation-interaction.scala b/tests/neg/gadt-approximation-interaction.scala index 39ed7c1ce60b..683d0668f4a2 100644 --- a/tests/neg/gadt-approximation-interaction.scala +++ b/tests/neg/gadt-approximation-interaction.scala @@ -1,5 +1,5 @@ object MemberHealing { - enum SUB[-A, +B] with + enum SUB[-A, +B]: case Refl[S]() extends SUB[S, S] def foo[T](t: T, ev: T SUB Int) = @@ -9,7 +9,7 @@ object MemberHealing { } object ImplicitLookup { - enum SUB[-A, +B] with + enum SUB[-A, +B]: case Refl[S]() extends SUB[S, S] class Tag[T] @@ -23,7 +23,7 @@ object ImplicitLookup { } object GivenLookup { - enum SUB[-A, +B] with + enum SUB[-A, +B]: case Refl[S]() extends SUB[S, S] class Tag[T] @@ -37,10 +37,10 @@ object GivenLookup { } object ImplicitConversion { - enum SUB[-A, +B] with + enum SUB[-A, +B]: case Refl[S]() extends SUB[S, S] - class Pow(self: Int) with + class Pow(self: Int): def **(other: Int): Int = math.pow(self, other).toInt implicit def pow(i: Int): Pow = Pow(i) @@ -57,10 +57,10 @@ object ImplicitConversion { } object GivenConversion { - enum SUB[-A, +B] with + enum SUB[-A, +B]: case Refl[S]() extends SUB[S, S] - class Pow(self: Int) with + class Pow(self: Int): def **(other: Int): Int = math.pow(self, other).toInt given Conversion[Int, Pow] = (i: Int) => Pow(i) @@ -77,7 +77,7 @@ object GivenConversion { } object ExtensionMethod { - enum SUB[-A, +B] with + enum SUB[-A, +B]: case Refl[S]() extends SUB[S, S] extension (x: Int) @@ -90,10 +90,10 @@ object ExtensionMethod { } object HKFun { - enum SUB[-A, +B] with + enum SUB[-A, +B]: case Refl[S]() extends SUB[S, S] - enum HKSUB[-F[_], +G[_]] with + enum HKSUB[-F[_], +G[_]]: case Refl[H[_]]() extends HKSUB[H, H] def foo[F[_], T](ft: F[T], hkev: F HKSUB Option, ev: T SUB Int) = @@ -107,7 +107,7 @@ object HKFun { } } - enum COVHKSUB[-F[+_], +G[+_]] with + enum COVHKSUB[-F[+_], +G[+_]]: case Refl[H[_]]() extends COVHKSUB[H, H] def bar[F[+_], T](ft: F[T], hkev: F COVHKSUB Option, ev: T SUB Int) = @@ -123,7 +123,7 @@ object HKFun { } object NestedConstrained { - enum SUB[-A, +B] with + enum SUB[-A, +B]: case Refl[S]() extends SUB[S, S] def foo[A, B](a: A, ev1: A SUB Option[B], ev2: B SUB Int) = diff --git a/tests/neg/given-eta.scala b/tests/neg/given-eta.scala index 6b0ae63947e4..db9ab3744963 100644 --- a/tests/neg/given-eta.scala +++ b/tests/neg/given-eta.scala @@ -1,5 +1,5 @@ -trait D with +trait D: type T def trans(other: T): T diff --git a/tests/neg/i10546.scala b/tests/neg/i10546.scala index cfe31a7e9e38..33407872f77e 100644 --- a/tests/neg/i10546.scala +++ b/tests/neg/i10546.scala @@ -1,4 +1,4 @@ -object test with +object test: def times(num : Int)(block : => Unit) : Unit = () times(10): println("ah") // error: end of statement expected but '(' found // error diff --git a/tests/neg/i10817.scala b/tests/neg/i10817.scala index 6a3e01fca9ea..c9388274fc25 100644 --- a/tests/neg/i10817.scala +++ b/tests/neg/i10817.scala @@ -1,6 +1,6 @@ import annotation.static -class T with +class T: @static val foo = 10 // error val x = (new T).foo \ No newline at end of file diff --git a/tests/neg/i10857.scala b/tests/neg/i10857.scala index 1ab4d9d5091e..b9128933484f 100644 --- a/tests/neg/i10857.scala +++ b/tests/neg/i10857.scala @@ -1,25 +1,25 @@ -object Module with +object Module: class Bar class Baz class Qux - object Givens with + object Givens: given GivenBar: Bar = new Bar() def GivenBar(ignored: Int): Bar = new Bar() class GivenBar - object Members with + object Members: given Member: Baz = new Baz() private def Member(ignored1: String)(ignored2: Int): Bar = new Bar() def Member(ignored: Int): Baz = new Baz() class Member - object Combined with + object Combined: given GivenQux: Qux = new Qux() def GivenQux(ignored: Int): Qux = new Qux() - enum Color with + enum Color: case Red, Green, Blue export Color._ // will only export synthetic defs with same name as standard definition diff --git a/tests/neg/i10870.scala b/tests/neg/i10870.scala index 9d840ad1f4a0..55669d580dc5 100644 --- a/tests/neg/i10870.scala +++ b/tests/neg/i10870.scala @@ -1,7 +1,7 @@ final case class A() final case class B(a:A) -object Test with +object Test: extension(a:A) def x = 5 diff --git a/tests/neg/i10901.scala b/tests/neg/i10901.scala index c163a8e427ea..9552047c402f 100644 --- a/tests/neg/i10901.scala +++ b/tests/neg/i10901.scala @@ -52,10 +52,10 @@ object BugExp4Point2D { class C -object Container with +object Container: given C with {} -object Test with +object Test: extension (x: String)(using C) def foo: String = x diff --git a/tests/neg/i11066.scala b/tests/neg/i11066.scala index c61694f31cd0..4b8e16e85e9d 100644 --- a/tests/neg/i11066.scala +++ b/tests/neg/i11066.scala @@ -1,12 +1,12 @@ class PreferredPrompt(val preference: String) -object Greeter with +object Greeter: def greet(name: String)(using prompt: PreferredPrompt) = println(s"Welcome, $name. The system is ready.") println(prompt.preference) -object JillsPrefs with +object JillsPrefs: given jillsPrompt: PreferredPrompt = PreferredPrompt("Your wish> ") -object JoesPrefs with +object JoesPrefs: given joesPrompt: PreferredPrompt = PreferredPrompt("relax> ") diff --git a/tests/neg/i11081.scala b/tests/neg/i11081.scala index 4385f7039984..7c1e6ce6dec6 100644 --- a/tests/neg/i11081.scala +++ b/tests/neg/i11081.scala @@ -1,6 +1,6 @@ -enum Outer with +enum Outer: case Foo(u: Unavailable) // error case Bar(u: DefinitelyNotAvailable) // error -object Outer with +object Outer: class Unavailable(i: Int) case class DefinitelyNotAvailable() diff --git a/tests/neg/i1501.scala b/tests/neg/i1501.scala index dbc08a7ba442..68556640383a 100644 --- a/tests/neg/i1501.scala +++ b/tests/neg/i1501.scala @@ -24,5 +24,5 @@ object Test2 { trait TSubA extends SubA(2) // error: trait TSubA may not call constructor of class SubA - class Foo extends TA with TSubA // error: missing argument for parameter x of constructor SubA with + class Foo extends TA with TSubA // error: missing argument for parameter x of constructor SubA: } diff --git a/tests/neg/i3253.scala b/tests/neg/i3253.scala index 20965742046f..04a79bb73ea0 100644 --- a/tests/neg/i3253.scala +++ b/tests/neg/i3253.scala @@ -1,5 +1,5 @@ import Test.test -class A with +class A: def test = " " * 10 // error object Test extends A diff --git a/tests/neg/i6183.scala b/tests/neg/i6183.scala index e9de3fde8ee8..30eae3abdbe3 100644 --- a/tests/neg/i6183.scala +++ b/tests/neg/i6183.scala @@ -1,4 +1,4 @@ -object Test with +object Test: extension [A](a: A) def render: String = "Hi" extension [B](b: B) def render(using DummyImplicit): Char = 'x' diff --git a/tests/neg/i6205.scala b/tests/neg/i6205.scala index fd1d0202f552..32537e5b2fbb 100644 --- a/tests/neg/i6205.scala +++ b/tests/neg/i6205.scala @@ -1,6 +1,6 @@ class Contra[-T >: Null] -object Test with +object Test: def foo = // error class A new Contra[A] diff --git a/tests/neg/i6779.scala b/tests/neg/i6779.scala index 805ae9c54eb2..c83a2368940e 100644 --- a/tests/neg/i6779.scala +++ b/tests/neg/i6779.scala @@ -3,7 +3,7 @@ type G[T] type Stuff given Stuff = ??? -object Test with +object Test: extension [T](x: T) def f(using Stuff): F[T] = ??? diff --git a/tests/neg/i7359-g.scala b/tests/neg/i7359-g.scala index e22b39e2b370..ad7082dd21e3 100644 --- a/tests/neg/i7359-g.scala +++ b/tests/neg/i7359-g.scala @@ -1,4 +1,4 @@ -trait SAMTrait with +trait SAMTrait: def first(): String def equals(obj: Int): Boolean diff --git a/tests/neg/i7359.scala b/tests/neg/i7359.scala index e229af5e85ab..c65a33a66a18 100644 --- a/tests/neg/i7359.scala +++ b/tests/neg/i7359.scala @@ -1,3 +1,3 @@ -trait SAMTrait with +trait SAMTrait: def first(): String def notify(): Unit // error diff --git a/tests/neg/i7526.scala b/tests/neg/i7526.scala index 57119abdf054..ed37df14aa73 100644 --- a/tests/neg/i7526.scala +++ b/tests/neg/i7526.scala @@ -1,9 +1,9 @@ type Tr[-I, +O, +A] = I => (O, A) -trait NetApi with +trait NetApi: type Comp -trait NetDB extends NetApi with +trait NetDB extends NetApi: class Comp trait NetHelper extends NetApi diff --git a/tests/neg/i7709.scala b/tests/neg/i7709.scala index 2e7236c9fb8d..80bc4d8d518f 100644 --- a/tests/neg/i7709.scala +++ b/tests/neg/i7709.scala @@ -1,31 +1,31 @@ -object X with +object X: protected class Y -object A with +object A: class B extends X.Y // error class B2 extends X.Y: // error def this(n: Int) = this() class B3(x: Any) class B4 extends B3(new X.Y) // error - class B5(x: String) with + class B5(x: String): def this(n: Int) = this(new X.Y().toString) // error -trait T with +trait T: class B extends X.Y // error -class XX with +class XX: protected class Y -class C with +class C: def xx = new XX def y = new xx.Y // error -class D with +class D: def this(n: Int) = { this() def xx = new XX def y = new xx.Y // error } -class YY extends XX with +class YY extends XX: def y = new Y package p: - object X with + object X: protected class Y class Q extends X.Y // error diff --git a/tests/neg/i7980.scala b/tests/neg/i7980.scala index 6d950830e58a..b2f769056dcb 100644 --- a/tests/neg/i7980.scala +++ b/tests/neg/i7980.scala @@ -1,6 +1,6 @@ trait Evidence[X] -trait Trait[X : Evidence] with +trait Trait[X : Evidence]: def method(x : X) : X given ev: Evidence[Int] = new Evidence[Int]{} diff --git a/tests/neg/i8050.scala b/tests/neg/i8050.scala index 94520c3d3de7..029e8d8195d5 100644 --- a/tests/neg/i8050.scala +++ b/tests/neg/i8050.scala @@ -1,4 +1,4 @@ -object stuff with +object stuff: def exec(dir: Int) = ??? extension (a: Int) diff --git a/tests/neg/i8069.scala b/tests/neg/i8069.scala index fc94d7c057a1..50f8b7a3480e 100644 --- a/tests/neg/i8069.scala +++ b/tests/neg/i8069.scala @@ -1,7 +1,7 @@ -trait A with +trait A: type B -enum Test with +enum Test: case Test(a: A, b: a.B) // error: Implementation restriction: case classes cannot have dependencies between parameters case class Test2(a: A, b: a.B) // error: Implementation restriction: case classes cannot have dependencies between parameters diff --git a/tests/neg/i8333.scala b/tests/neg/i8333.scala index e5c19bd37228..12a35ac2d636 100644 --- a/tests/neg/i8333.scala +++ b/tests/neg/i8333.scala @@ -1,12 +1,12 @@ -class A with +class A: type T = Int // can also be class T -class B(x: A, y: A) with +class B(x: A, y: A): export x._ export y._ // error: duplicate -class C(x: A) with +class C(x: A): type T = String export x._ // error: duplicate -class D(x: A) with +class D(x: A): export x._ // error: duplicate type T = String diff --git a/tests/neg/i8407.scala b/tests/neg/i8407.scala index 941412d462b0..34d7fa20914c 100644 --- a/tests/neg/i8407.scala +++ b/tests/neg/i8407.scala @@ -1,4 +1,4 @@ -object Test with +object Test: val xs = List(1, 2, 3, 4, 5) xs match { case List(1, 2, xs1 @ xs2: _*) => println(xs2) // error // error diff --git a/tests/neg/i8623.scala b/tests/neg/i8623.scala index f07a911a27c1..f402a6ceeedd 100644 --- a/tests/neg/i8623.scala +++ b/tests/neg/i8623.scala @@ -1,6 +1,6 @@ -trait QC with - object tasty with +trait QC: + object tasty: type Tree extension (tree: Tree) def pos: Tree = ??? diff --git a/tests/neg/i8731.scala b/tests/neg/i8731.scala index 6f20519a5be7..97ae8308b20b 100644 --- a/tests/neg/i8731.scala +++ b/tests/neg/i8731.scala @@ -1,4 +1,4 @@ -object test with +object test: 3 match case 3 => ??? diff --git a/tests/neg/i9014.scala b/tests/neg/i9014.scala index 287d29d392bf..2a82d54be9d9 100644 --- a/tests/neg/i9014.scala +++ b/tests/neg/i9014.scala @@ -1,4 +1,4 @@ trait Bar -object Bar with +object Bar: inline given Bar = compiletime.error("Failed to expand!") val tests = summon[Bar] // error diff --git a/tests/neg/i9051.scala b/tests/neg/i9051.scala index cb2908ce83de..360f3b20eec7 100644 --- a/tests/neg/i9051.scala +++ b/tests/neg/i9051.scala @@ -1,11 +1,11 @@ package zio: class ZRef - object ZRef with + object ZRef: - private[zio] implicit class ZRefSyntax(private val self: ZRef) with + private[zio] implicit class ZRefSyntax(private val self: ZRef): def unsafeUpdate: Boolean = true -object Main with +object Main: val ref = new zio.ZRef println(ref.unsafeUpdate) // error diff --git a/tests/neg/i9437.scala b/tests/neg/i9437.scala index 389945ba3985..13cb2e74dc7a 100644 --- a/tests/neg/i9437.scala +++ b/tests/neg/i9437.scala @@ -1,7 +1,7 @@ class Bag extends reflect.Selectable @main def Test = - val x = new Bag with + val x = new Bag: val f1 = 23 println(x.f1()) // error \ No newline at end of file diff --git a/tests/neg/i9562.scala b/tests/neg/i9562.scala index d73df61895df..23d1bebdbba9 100644 --- a/tests/neg/i9562.scala +++ b/tests/neg/i9562.scala @@ -1,7 +1,7 @@ -class Foo with +class Foo: def foo = 23 -object Unrelated with +object Unrelated: extension (f: Foo) def g = f.foo // OK diff --git a/tests/neg/i9790.scala b/tests/neg/i9790.scala index d247222ee0bc..3417c4b2c7b0 100644 --- a/tests/neg/i9790.scala +++ b/tests/neg/i9790.scala @@ -1,4 +1,4 @@ -object A with +object A: def fn: Unit = if true then println(1) diff --git a/tests/neg/i9928.scala b/tests/neg/i9928.scala index 44e4a35bb982..a1034b1f20e9 100644 --- a/tests/neg/i9928.scala +++ b/tests/neg/i9928.scala @@ -1,14 +1,14 @@ -trait Magic[F] with +trait Magic[F]: extension (x: Int) def read: F -object Magic with +object Magic: given Magic[String] with extension(x: Int) def read: String = println("In string") s"$x" opaque type Foo = String -object Foo with +object Foo: import Magic.given def apply(s: String): Foo = s diff --git a/tests/neg/import-given.scala b/tests/neg/import-given.scala index f1ad6aeb5880..ddc3da2fa5cb 100644 --- a/tests/neg/import-given.scala +++ b/tests/neg/import-given.scala @@ -25,6 +25,6 @@ object E { foo // ok foo(using tc) // ok } -object F with +object F: import A.{given ?} // error: unbound wildcard type diff --git a/tests/neg/inline-abstract.scala b/tests/neg/inline-abstract.scala index 95f67ae4ba5d..2f4596f38ea6 100644 --- a/tests/neg/inline-abstract.scala +++ b/tests/neg/inline-abstract.scala @@ -1,7 +1,7 @@ -class A with +class A: inline def f(): Int -class B extends A with +class B extends A: inline def f() = 1 def Test = diff --git a/tests/neg/missing-implicit1.scala b/tests/neg/missing-implicit1.scala index 30ba99904186..66c70f446d37 100644 --- a/tests/neg/missing-implicit1.scala +++ b/tests/neg/missing-implicit1.scala @@ -1,4 +1,4 @@ -object testObjectInstance with +object testObjectInstance: trait Zip[F[_]] trait Traverse[F[_]] { extension [A, B, G[_] : Zip](fa: F[A]) def traverse(f: A => G[B]): G[F[B]] diff --git a/tests/neg/missing-implicit2.scala b/tests/neg/missing-implicit2.scala index a673797e8738..53e30eeb9ee1 100644 --- a/tests/neg/missing-implicit2.scala +++ b/tests/neg/missing-implicit2.scala @@ -1,6 +1,6 @@ trait X trait Y -object test with +object test: def f(using x: X) = ??? object instances { given y: Y = ??? diff --git a/tests/neg/missing-implicit5.scala b/tests/neg/missing-implicit5.scala index a9132b0407d8..c294412da53b 100644 --- a/tests/neg/missing-implicit5.scala +++ b/tests/neg/missing-implicit5.scala @@ -1,4 +1,4 @@ -object testObjectInstance with +object testObjectInstance: trait Zip[F[_]] trait Traverse[F[_]] { extension [A, B, G[_] : Zip](fa: F[A]) def traverse(f: A => G[B]): G[F[B]] diff --git a/tests/neg/name-hints.scala b/tests/neg/name-hints.scala index aca20e067e0f..cb4cb8884087 100644 --- a/tests/neg/name-hints.scala +++ b/tests/neg/name-hints.scala @@ -1,8 +1,8 @@ -object O with +object O: val abcde: Int = 0 val xy: Int = 1 -object Test with +object Test: val x1 = Int.maxvalue // error val x2 = Int.MxValue // error val x3 = Int.MaxxValue // error diff --git a/tests/neg/namedTypeParams.scala b/tests/neg/namedTypeParams.scala index bc78ac09a208..8ed7c92241ea 100644 --- a/tests/neg/namedTypeParams.scala +++ b/tests/neg/namedTypeParams.scala @@ -1,7 +1,7 @@ class C[T] class D[type T] // error: identifier expected, but `type` found -object Test0 with +object Test0: def f[X, Y](x: X, y: Y): Int = ??? f[X = Int, Y = Int](1, 2) // error: experimental // error: experimental diff --git a/tests/neg/null-anyval.scala b/tests/neg/null-anyval.scala index df54c48bfd8a..82b4b9ad9433 100644 --- a/tests/neg/null-anyval.scala +++ b/tests/neg/null-anyval.scala @@ -1,4 +1,4 @@ -object Test with +object Test: val x: Int = 0 val y: Int | Null = x // during erasure, x is boxed here, and Int | Null becomes Object val z0: Int = identity(y) // error @@ -8,5 +8,5 @@ object Test with class StrWrapper(x: String) extends AnyVal val z3: StrWrapper = null // error val z4: O.T = null // error -object O with +object O: opaque type T = String diff --git a/tests/neg/override-erasure-clash.scala b/tests/neg/override-erasure-clash.scala index 6706004964c5..688eb816afcc 100644 --- a/tests/neg/override-erasure-clash.scala +++ b/tests/neg/override-erasure-clash.scala @@ -1,5 +1,5 @@ import annotation.targetName -class A with +class A: def f(): Int = 1 class B extends A: // error @targetName("f") def g(): Int = 2 diff --git a/tests/neg/override-inner-class.scala b/tests/neg/override-inner-class.scala index 5ff65519f5bd..4c4daaccb88a 100644 --- a/tests/neg/override-inner-class.scala +++ b/tests/neg/override-inner-class.scala @@ -1,5 +1,5 @@ -class C with +class C: type T >: String <: Any -class D extends C with +class D extends C: class T // error diff --git a/tests/neg/source-import.scala b/tests/neg/source-import.scala index 5479f823d91a..5cb7f532ea5c 100644 --- a/tests/neg/source-import.scala +++ b/tests/neg/source-import.scala @@ -1,6 +1,6 @@ import language.`3.0` import language.`3.0` // error -class C with +class C: import language.`3.0-migration` // error diff --git a/tests/neg/spaces-vs-tabs.scala b/tests/neg/spaces-vs-tabs.scala index c4e8bee9ada8..ff8d1a1c328e 100644 --- a/tests/neg/spaces-vs-tabs.scala +++ b/tests/neg/spaces-vs-tabs.scala @@ -1,4 +1,4 @@ -object Test with +object Test: if true then println(1) // ok @@ -7,7 +7,7 @@ object Test with println(4) // error else () // error - object Test2 with + object Test2: if true then 1 diff --git a/tests/neg/targetName-override-2.scala b/tests/neg/targetName-override-2.scala index 05b2071d3481..531efbfd931f 100644 --- a/tests/neg/targetName-override-2.scala +++ b/tests/neg/targetName-override-2.scala @@ -1,6 +1,6 @@ import annotation.targetName -class Alpha[T] with +class Alpha[T]: def foo() = 1 diff --git a/tests/neg/transparent-inline.scala b/tests/neg/transparent-inline.scala index be6b5ad65bab..a5158d9b8a27 100644 --- a/tests/neg/transparent-inline.scala +++ b/tests/neg/transparent-inline.scala @@ -1,6 +1,6 @@ transparent def bar: Any = 2 // error: transparent can be used only with inline -object test1 with +object test1: def x: Int = baz(true) // error: type mismatch inline def baz(x: Boolean): Any = @@ -9,7 +9,7 @@ object test1 with if x then 1 else "" def y: Int = bam(true) // error: type mismatch -object test2 with +object test2: def x: 1 = baz(true) // OK transparent inline def baz(x: Boolean) = @@ -18,7 +18,7 @@ object test2 with if x then 1 else "" def y: 1 = bam(true) // OK -object test3 with +object test3: def x: Int = baz(true) // error: type mismatch inline def baz(x: Boolean) = @@ -27,7 +27,7 @@ object test3 with if x then 1 else "" def y: Int = bam(true) // error: type mismatch -object test4 with +object test4: def x: 1 = baz(true) // OK transparent inline def baz(x: Boolean): Any = diff --git a/tests/new/test.scala b/tests/new/test.scala index 924334fca8e1..ac8f67d1530f 100644 --- a/tests/new/test.scala +++ b/tests/new/test.scala @@ -1,2 +1,3 @@ -object Test with - val x = 1 +object Test: + + def test = ??? diff --git a/tests/patmat/i10085.scala b/tests/patmat/i10085.scala index ac8d2b448eaf..314f4253cde8 100644 --- a/tests/patmat/i10085.scala +++ b/tests/patmat/i10085.scala @@ -1,10 +1,10 @@ -enum Bool with +enum Bool: case True case False import Bool._ -enum SBool[B <: Bool] with +enum SBool[B <: Bool]: case STrue extends SBool[True.type] case SFalse extends SBool[False.type] diff --git a/tests/patmat/i8922.scala b/tests/patmat/i8922.scala index 8fd616dbae58..946b1834998f 100644 --- a/tests/patmat/i8922.scala +++ b/tests/patmat/i8922.scala @@ -1,6 +1,6 @@ case class Token(tokenType: TokenType, lexeme: String, line: Int) -enum TokenType with +enum TokenType: // Single-character tokens. case MINUS, PLUS, SLASH, STAR, @@ -14,7 +14,7 @@ enum Expr { case Binary(left: Expr, operator: Token, right: Expr) } -object Interpreter with +object Interpreter: import Expr._ import TokenType._ diff --git a/tests/patmat/i8922c.scala b/tests/patmat/i8922c.scala index b6c07e43828c..63d968c80345 100644 --- a/tests/patmat/i8922c.scala +++ b/tests/patmat/i8922c.scala @@ -1,6 +1,6 @@ case class Token(tokenType: TokenType, lexeme: String, line: Int) -enum TokenType with +enum TokenType: // Single-character tokens. case MINUS, PLUS, SLASH, STAR, @@ -14,7 +14,7 @@ enum Expr { case Binary(left: Expr, operator: Token, right: Expr) } -object Interpreter with +object Interpreter: import Expr._ import TokenType._ diff --git a/tests/pending/pos/cps-async-failure.scala b/tests/pending/pos/cps-async-failure.scala index 6cb8d2482989..9f8da4c7f8b8 100644 --- a/tests/pending/pos/cps-async-failure.scala +++ b/tests/pending/pos/cps-async-failure.scala @@ -1,7 +1,7 @@ import scala.quoted._ -trait App[F[_],CT] with +trait App[F[_],CT]: this: Base[F,CT] => import quotes.reflect._ @@ -39,10 +39,10 @@ trait Base[F[_]:Type,CT:Type] // Both :Type context bounds are necessary for fa extends Cps with Root[F, CT] with App[F, CT]: implicit val qctx: Quotes -trait Root[F[_], CT] with +trait Root[F[_], CT]: this: Base[F, CT] => def runRoot(): CpsTree = ??? -trait Cps with +trait Cps: sealed abstract class CpsTree diff --git a/tests/pending/pos/inlinetuple.scala b/tests/pending/pos/inlinetuple.scala index 1fdb6abfd02f..ac457ebfa0d9 100644 --- a/tests/pending/pos/inlinetuple.scala +++ b/tests/pending/pos/inlinetuple.scala @@ -1,6 +1,6 @@ // TODO: Ensure that this inlines properly. So far only // x._1 inlines, but not x._2. -object Test with +object Test: def g(x: Int, y: Int) = x + y inline def f(inline x: (Int, Int)) = g(x._1, x._2) diff --git a/tests/pos-custom-args/erased/i10848b.scala b/tests/pos-custom-args/erased/i10848b.scala index bb808b6238f5..71292b1b859c 100644 --- a/tests/pos-custom-args/erased/i10848b.scala +++ b/tests/pos-custom-args/erased/i10848b.scala @@ -1,4 +1,4 @@ -class Foo with +class Foo: erased given Int = 1 def foo(using erased x: Int): Unit = () foo diff --git a/tests/pos-custom-args/semanticdb/inline-unapply/Macro_1.scala b/tests/pos-custom-args/semanticdb/inline-unapply/Macro_1.scala index b15e2282961a..dc431c14ef14 100644 --- a/tests/pos-custom-args/semanticdb/inline-unapply/Macro_1.scala +++ b/tests/pos-custom-args/semanticdb/inline-unapply/Macro_1.scala @@ -1,6 +1,6 @@ import scala.quoted._ -object Succ with +object Succ: inline def unapply(n: Int): Option[Int] = ${ impl('n) } diff --git a/tests/pos-macros/i10151/Macro_1.scala b/tests/pos-macros/i10151/Macro_1.scala index b2ee78a860fa..f5170c83da12 100644 --- a/tests/pos-macros/i10151/Macro_1.scala +++ b/tests/pos-macros/i10151/Macro_1.scala @@ -2,20 +2,20 @@ package x import scala.quoted._ -trait CB[T] with +trait CB[T]: def map[S](f: T=>S): CB[S] = ??? def flatMap[S](f: T=>CB[S]): CB[S] = ??? -class MyArr[AK,AV] with +class MyArr[AK,AV]: def map1[BK,BV](f: ((AK,AV)) => (BK, BV)):MyArr[BK,BV] = ??? def map1Out[BK, BV](f: ((AK,AV)) => CB[(BK,BV)]): CB[MyArr[BK,BV]] = ??? def await[T](x:CB[T]):T = ??? -object CBM with +object CBM: def pure[T](t:T):CB[T] = ??? -object X with +object X: inline def process[T](inline f:T) = ${ processImpl[T]('f) diff --git a/tests/pos-macros/i10211/Macro_1.scala b/tests/pos-macros/i10211/Macro_1.scala index 72fa30e47cc7..ebf9b76ff77e 100644 --- a/tests/pos-macros/i10211/Macro_1.scala +++ b/tests/pos-macros/i10211/Macro_1.scala @@ -2,11 +2,11 @@ package x import scala.quoted._ -trait CB[T] with +trait CB[T]: def map[S](f: T=>S): CB[S] = ??? -class MyArr[A] with +class MyArr[A]: def map[B](f: A=>B):MyArr[B] = ??? def mapOut[B](f: A=> CB[B]): CB[MyArr[B]] = ??? def flatMap[B](f: A=>MyArr[B]):MyArr[B] = ??? @@ -15,7 +15,7 @@ class MyArr[A] with def withFilterOut(p: A=>CB[Boolean]): DelayedWithFilter[A] = ??? def map2[B](f: A=>B):MyArr[B] = ??? -class DelayedWithFilter[A] with +class DelayedWithFilter[A]: def map[B](f: A=>B):MyArr[B] = ??? def mapOut[B](f: A=> CB[B]): CB[MyArr[B]] = ??? def flatMap[B](f: A=>MyArr[B]):MyArr[B] = ??? @@ -25,11 +25,11 @@ class DelayedWithFilter[A] with def await[T](x:CB[T]):T = ??? -object CBM with +object CBM: def pure[T](t:T):CB[T] = ??? def map[T,S](a:CB[T])(f:T=>S):CB[S] = ??? -object X with +object X: inline def process[T](inline f:T) = ${ processImpl[T]('f) diff --git a/tests/pos-macros/i10771/MacroA_1.scala b/tests/pos-macros/i10771/MacroA_1.scala index 22b5be9e22c6..88da14fe31ac 100644 --- a/tests/pos-macros/i10771/MacroA_1.scala +++ b/tests/pos-macros/i10771/MacroA_1.scala @@ -2,7 +2,7 @@ import scala.quoted._ case class MyQuoted(val ast: String, runtimeQuotes: List[String]) -object MyQuoteMacro with +object MyQuoteMacro: inline def myquote: MyQuoted = ${ MyQuoteMacro.apply } def apply(using Quotes): Expr[MyQuoted] = '{ MyQuoted("p", ${Expr.ofList(List( '{ "foo" } ))}) } diff --git a/tests/pos-macros/i10771/MacroB_1.scala b/tests/pos-macros/i10771/MacroB_1.scala index 4eb1566461dd..e9bfe73fb1a2 100644 --- a/tests/pos-macros/i10771/MacroB_1.scala +++ b/tests/pos-macros/i10771/MacroB_1.scala @@ -1,6 +1,6 @@ import scala.quoted._ -object PullAst with +object PullAst: def applyImpl(quoted: Expr[MyQuoted])(using qctx: Quotes): Expr[String] = '{ $quoted.ast.toString } inline def apply(inline quoted: MyQuoted): String = diff --git a/tests/pos-macros/i10771/Test_2.scala b/tests/pos-macros/i10771/Test_2.scala index 30203c7cf9e2..7777454cfc36 100644 --- a/tests/pos-macros/i10771/Test_2.scala +++ b/tests/pos-macros/i10771/Test_2.scala @@ -1,3 +1,3 @@ -object Test with +object Test: def main(args: Array[String]): Unit = println( PullAst.apply( MyQuoteMacro.myquote ) ) diff --git a/tests/pos-macros/i10910/Macro_1.scala b/tests/pos-macros/i10910/Macro_1.scala index ccb32baa03d7..ae5643b1a9ea 100644 --- a/tests/pos-macros/i10910/Macro_1.scala +++ b/tests/pos-macros/i10910/Macro_1.scala @@ -2,15 +2,15 @@ package x import scala.quoted._ -trait CB[T] with +trait CB[T]: def map[S](f: T=>S): CB[S] = ??? def await[T](x:CB[T]):T = ??? -object CBM with +object CBM: def pure[T](t:T):CB[T] = ??? -object X with +object X: inline def process[T](inline f:T) = ${ processImpl[T]('f) diff --git a/tests/pos-macros/i8325/Macro_1.scala b/tests/pos-macros/i8325/Macro_1.scala index 037d995f23d7..b3f14e80157c 100644 --- a/tests/pos-macros/i8325/Macro_1.scala +++ b/tests/pos-macros/i8325/Macro_1.scala @@ -3,7 +3,7 @@ package a import scala.quoted._ -object A with +object A: inline def transform[A](inline expr: A): A = ${ transformImplExpr('expr) diff --git a/tests/pos-macros/i8325b/Macro_1.scala b/tests/pos-macros/i8325b/Macro_1.scala index 70808b82c8d7..aa4255f6f3a0 100644 --- a/tests/pos-macros/i8325b/Macro_1.scala +++ b/tests/pos-macros/i8325b/Macro_1.scala @@ -3,7 +3,7 @@ package a import scala.quoted._ -object A with +object A: inline def transform[A](inline expr: A): A = ${ transformImplExpr('expr) diff --git a/tests/pos-macros/i9812.scala b/tests/pos-macros/i9812.scala index 0764a1eeb827..e09db34fea2a 100644 --- a/tests/pos-macros/i9812.scala +++ b/tests/pos-macros/i9812.scala @@ -2,7 +2,7 @@ import quoted._ sealed abstract class SomeEnum -object SomeEnum with +object SomeEnum: final val Foo = new SomeEnum {} def quoteFoo: Quotes ?=> Expr[SomeEnum.Foo.type] = '{SomeEnum.Foo} diff --git a/tests/pos-macros/i9894/Macro_1.scala b/tests/pos-macros/i9894/Macro_1.scala index aa0e902ba300..7135cb6a7029 100644 --- a/tests/pos-macros/i9894/Macro_1.scala +++ b/tests/pos-macros/i9894/Macro_1.scala @@ -2,19 +2,19 @@ package x import scala.quoted._ -trait CB[T] with +trait CB[T]: def map[S](f: T=>S): CB[S] = ??? -class MyArr[A] with +class MyArr[A]: def map1[B](f: A=>B):MyArr[B] = ??? def map1Out[B](f: A=> CB[B]): CB[MyArr[B]] = ??? def await[T](x:CB[T]):T = ??? -object CBM with +object CBM: def pure[T](t:T):CB[T] = ??? -object X with +object X: inline def process[T](inline f:T) = ${ processImpl[T]('f) diff --git a/tests/pos-macros/nil-liftable.scala b/tests/pos-macros/nil-liftable.scala index 2771baff7078..490291bc48f7 100644 --- a/tests/pos-macros/nil-liftable.scala +++ b/tests/pos-macros/nil-liftable.scala @@ -1,6 +1,6 @@ import scala.quoted._ -class Test with +class Test: given NilToExpr: ToExpr[Nil.type] with { def apply(xs: Nil.type)(using Quotes): Expr[Nil.type] = '{ Nil } diff --git a/tests/pos-macros/quote-aliases.scala b/tests/pos-macros/quote-aliases.scala index 50b1b1b4566f..e6c0e50593fb 100644 --- a/tests/pos-macros/quote-aliases.scala +++ b/tests/pos-macros/quote-aliases.scala @@ -1,6 +1,6 @@ import scala.quoted._ -object Test with +object Test: def f1(using Quotes)(t: quotes.reflect.Tree): Unit = () diff --git a/tests/pos-special/fatal-warnings/i10259.scala b/tests/pos-special/fatal-warnings/i10259.scala index a089814cce80..5b4c628cd126 100644 --- a/tests/pos-special/fatal-warnings/i10259.scala +++ b/tests/pos-special/fatal-warnings/i10259.scala @@ -1,4 +1,4 @@ -trait S[T] extends (T => T) with +trait S[T] extends (T => T): def apply(x: T) = ??? extension (x: T) def show: String diff --git a/tests/pos-special/fatal-warnings/i9260.scala b/tests/pos-special/fatal-warnings/i9260.scala index a930a0b803a0..df548f393eea 100644 --- a/tests/pos-special/fatal-warnings/i9260.scala +++ b/tests/pos-special/fatal-warnings/i9260.scala @@ -1,14 +1,14 @@ package asts -enum Ast[-T >: Null] with +enum Ast[-T >: Null]: case DefDef() -trait AstImpl[T >: Null] with +trait AstImpl[T >: Null]: type Ast = asts.Ast[T] type DefDef = Ast.DefDef[T] end AstImpl -object untpd extends AstImpl[Null] with +object untpd extends AstImpl[Null]: def DefDef(ast: Ast): DefDef = ast match case ast: DefDef => ast diff --git a/tests/pos-special/fatal-warnings/patmat-exhaustive.scala b/tests/pos-special/fatal-warnings/patmat-exhaustive.scala index 796ada8a13a8..c5c95c455b8c 100644 --- a/tests/pos-special/fatal-warnings/patmat-exhaustive.scala +++ b/tests/pos-special/fatal-warnings/patmat-exhaustive.scala @@ -1,5 +1,5 @@ def foo: Unit = - object O with + object O: sealed abstract class A class B extends O.A class C extends O.A diff --git a/tests/pos-special/fatal-warnings/type-test-matchable.scala b/tests/pos-special/fatal-warnings/type-test-matchable.scala index 8e1acaa6dc44..5becee6f2e9f 100644 --- a/tests/pos-special/fatal-warnings/type-test-matchable.scala +++ b/tests/pos-special/fatal-warnings/type-test-matchable.scala @@ -1,13 +1,13 @@ import scala.language.`3.1-migration` import scala.reflect.TypeTest -trait Foo with +trait Foo: type X type Y <: X def x: X given TypeTest[X, Y] = ??? -object Test with +object Test: def test(foo: Foo): Unit = foo.x match case x: foo.Y => diff --git a/tests/pos-special/i7296.scala b/tests/pos-special/i7296.scala index 6811c80d7e77..3b582ad284b8 100644 --- a/tests/pos-special/i7296.scala +++ b/tests/pos-special/i7296.scala @@ -1,2 +1,2 @@ -class Foo with +class Foo: private var blah: Double = 0L \ No newline at end of file diff --git a/tests/pos-special/indent-colons.scala b/tests/pos-special/indent-colons.scala index e5b712ef2e77..44fe09b39cd4 100644 --- a/tests/pos-special/indent-colons.scala +++ b/tests/pos-special/indent-colons.scala @@ -1,4 +1,4 @@ -object Test with +object Test: locally: var x = 0 @@ -56,26 +56,26 @@ object Test with x < 10 do () -class Test2 with +class Test2: self => def foo = 1 val x = - new Test2 with + new Test2: override def foo = 2 end new end x end Test2 -class Test3 with +class Test3: self => def foo = 1 import collection.mutable.HashMap -class Coder(words: List[String]) with +class Coder(words: List[String]): - class Foo with + class Foo: println() end Foo @@ -114,5 +114,5 @@ class Coder(words: List[String]) with case (digit, str) => str map (ltr => ltr -> digit) end Coder -object Test22 with +object Test22: def foo: Int = 22 \ No newline at end of file diff --git a/tests/pos-special/notNull.scala b/tests/pos-special/notNull.scala index bcc0154b0a80..11a506d8184d 100644 --- a/tests/pos-special/notNull.scala +++ b/tests/pos-special/notNull.scala @@ -1,4 +1,4 @@ -object Test with +object Test: def notNull[A](x: A | Null): x.type & A = assert(x != null) x.asInstanceOf // TODO: drop the .asInstanceOf when explicit nulls are implemented diff --git a/tests/pos-special/sourcepath/outer/nested/indent1.scala b/tests/pos-special/sourcepath/outer/nested/indent1.scala index 0b2d74832f28..cba9ddddece1 100644 --- a/tests/pos-special/sourcepath/outer/nested/indent1.scala +++ b/tests/pos-special/sourcepath/outer/nested/indent1.scala @@ -1,8 +1,8 @@ package outer package nested -object indent1 with - object inner with +object indent1: + object inner: def x: Int = 1 end inner val y: Int = 2 diff --git a/tests/pos/abstract-inline-val.scala b/tests/pos/abstract-inline-val.scala index ccf2ebd6ff60..6ea95eea5151 100644 --- a/tests/pos/abstract-inline-val.scala +++ b/tests/pos/abstract-inline-val.scala @@ -1,11 +1,11 @@ -trait C with +trait C: inline def x: Int inline val y: Int -class C1 extends C with +class C1 extends C: inline val x = 1 inline val y = 2 -class C2 extends C with +class C2 extends C: inline def x = 3 inline val y = 4 diff --git a/tests/pos/consume.scala b/tests/pos/consume.scala index 41965b522682..d17638bb84a0 100644 --- a/tests/pos/consume.scala +++ b/tests/pos/consume.scala @@ -1,4 +1,4 @@ -object Test1 with +object Test1: def consume(xs: List[Int], limit: Int): List[Int] = xs match case x :: xs1 if limit > 0 => consume(xs1, limit - x) case _ => xs @@ -16,18 +16,18 @@ object Test2 { } } -object math3 with - trait Ord[T] with +object math3: + trait Ord[T]: extension (x: T) def > (t: T): Boolean = ??? extension (x: T) def <= (t: T): Boolean = ??? - trait Numeric[T] extends Ord[T] with + trait Numeric[T] extends Ord[T]: extension (x: T) def + (y: T): T = ??? extension (x: T) def - (y: T): T = ??? extension (x: Int) def numeric: T = ??? end math3 -object Test3 with +object Test3: import math3.Numeric import collection.immutable.Seq diff --git a/tests/pos/end-nested.scala b/tests/pos/end-nested.scala index 96c25c2b1ea2..38e8cce6c8a9 100644 --- a/tests/pos/end-nested.scala +++ b/tests/pos/end-nested.scala @@ -3,7 +3,7 @@ def f[T](x: Option[T]) = x match case None => end f -object Test with +object Test: try List(1, 2, 3) match case x :: xs => println(x) case Nil => println("Nil") diff --git a/tests/pos/endmarkers.scala b/tests/pos/endmarkers.scala index 13c3b92912b7..5b85ce3763cd 100644 --- a/tests/pos/endmarkers.scala +++ b/tests/pos/endmarkers.scala @@ -1,5 +1,5 @@ -trait T with - object O with +trait T: + object O: def foo = 1 end foo @@ -13,7 +13,7 @@ end T package p1.p2: - abstract class C() with + abstract class C(): def this(x: Int) = this() @@ -42,9 +42,9 @@ package p1.p2: def f: String end C - object C with + object C: given C = - new C with + new C: def f = "!" end f end new diff --git a/tests/pos/enum-companion-first.scala b/tests/pos/enum-companion-first.scala index 014066fb43f4..d4c1eb370031 100644 --- a/tests/pos/enum-companion-first.scala +++ b/tests/pos/enum-companion-first.scala @@ -1,7 +1,7 @@ -object Planet with +object Planet: final val G = 6.67300E-11 -enum Planet(mass: Double, radius: Double) extends Enum[Planet] with +enum Planet(mass: Double, radius: Double) extends Enum[Planet]: def surfaceGravity = Planet.G * mass / (radius * radius) def surfaceWeight(otherMass: Double) = otherMass * surfaceGravity diff --git a/tests/pos/enum-variance.scala b/tests/pos/enum-variance.scala index ca13c44d7a3f..82fa5bdf91a0 100644 --- a/tests/pos/enum-variance.scala +++ b/tests/pos/enum-variance.scala @@ -1,14 +1,14 @@ class Animal class Dog extends Animal -enum Opt[+T] with +enum Opt[+T]: case Sm(t: T) case None val smDog: Opt.Sm[Dog] = new Opt.Sm(Dog()) val smAnimal: Opt.Sm[Animal] = smDog -enum Show[-T] with +enum Show[-T]: case Refl(op: T => String) def show(t: T): String = this match diff --git a/tests/pos/enum-widen.scala b/tests/pos/enum-widen.scala index 8fb4e8707da1..32bbcf9a3242 100644 --- a/tests/pos/enum-widen.scala +++ b/tests/pos/enum-widen.scala @@ -1,6 +1,6 @@ -object test with +object test: - enum Option[+T] with + enum Option[+T]: case Some[T](x: T) extends Option[T] case None @@ -13,7 +13,7 @@ object test with x = None xc = None - enum Nat with + enum Nat: case Z case S[N <: Z.type | S[_]](pred: N) import Nat._ diff --git a/tests/pos/extmethods.scala b/tests/pos/extmethods.scala index b8bc0f25dea6..368b4f439916 100644 --- a/tests/pos/extmethods.scala +++ b/tests/pos/extmethods.scala @@ -32,7 +32,7 @@ val y1: List[Int] = y val z = (1 :: Nil).concat(Nil) val z1: List[Int] = z -trait TT with +trait TT: type A val m: A def f[B <: A](x: B): A = if ??? then m else x @@ -40,7 +40,7 @@ trait TT with extension (x: TT) def foo[B <: x.A](y: B) = x.f(y) -object CC extends TT with +object CC extends TT: type A = Seq[Int] val m = Nil diff --git a/tests/pos/i10080.scala b/tests/pos/i10080.scala index 15ca51e93a42..81146e18ed82 100644 --- a/tests/pos/i10080.scala +++ b/tests/pos/i10080.scala @@ -1,4 +1,4 @@ -trait Foo with +trait Foo: end Foo trait Bar diff --git a/tests/pos/i10082.scala b/tests/pos/i10082.scala index 5c989ecceffe..a1dc6160788e 100644 --- a/tests/pos/i10082.scala +++ b/tests/pos/i10082.scala @@ -1,4 +1,4 @@ -object Kotlin with +object Kotlin: def it[T](using t: T) = t def fun[T, U](fn: T ?=> U)(x: T): U = fn(using x) diff --git a/tests/pos/i10253.scala b/tests/pos/i10253.scala index aedd93ce45dd..15f872c59be0 100644 --- a/tests/pos/i10253.scala +++ b/tests/pos/i10253.scala @@ -1,9 +1,9 @@ -object test with +object test: def foo(qc: QC): Unit = object treeMap extends qc.reflect.TreeMap -trait QC with +trait QC: val reflect: Reflection - trait Reflection with - trait TreeMap with + trait Reflection: + trait TreeMap: def transformTree: Unit = ??? \ No newline at end of file diff --git a/tests/pos/i10295.scala b/tests/pos/i10295.scala index a100cca18cf8..8fc237e2e853 100644 --- a/tests/pos/i10295.scala +++ b/tests/pos/i10295.scala @@ -1,6 +1,6 @@ -trait M with +trait M: type X - object X with + object X: def foo(): X = ??? inline def m(using m: M): m.type = m diff --git a/tests/pos/i10311.scala b/tests/pos/i10311.scala index c89083446405..bfa0c15f3493 100644 --- a/tests/pos/i10311.scala +++ b/tests/pos/i10311.scala @@ -7,7 +7,7 @@ object Module { extension (self: MyInt) def y: Int = self.y } } -object test with +object test: import Module._ val a = new MyInt(42, 43) diff --git a/tests/pos/i10495.scala b/tests/pos/i10495.scala index 9eb2bb9b4976..931e5fe73f72 100644 --- a/tests/pos/i10495.scala +++ b/tests/pos/i10495.scala @@ -1,7 +1,7 @@ -class Foo with +class Foo: extension(x: String) def run: Unit = ??? -object Bar extends Foo with +object Bar extends Foo: def run(v: Int): Unit = ??? "ABC".run // Failed before: Reference to run is ambiguous... diff --git a/tests/pos/i10634/BasicSupport.scala b/tests/pos/i10634/BasicSupport.scala index 0e4f0fa31a82..cf4ae7190ce4 100644 --- a/tests/pos/i10634/BasicSupport.scala +++ b/tests/pos/i10634/BasicSupport.scala @@ -1,5 +1,5 @@ // BasicSupport.scala -trait BasicSupport with +trait BasicSupport: self: Parser => object SymOps extends SymOps[ctx.type](ctx) diff --git a/tests/pos/i10634/Context.scala b/tests/pos/i10634/Context.scala index 76ae72ae3f6b..0e22fd29d17d 100644 --- a/tests/pos/i10634/Context.scala +++ b/tests/pos/i10634/Context.scala @@ -1,8 +1,8 @@ // Context.scala -trait Context with +trait Context: type Symbol -trait SymOps[C <: Context](val c: C) with +trait SymOps[C <: Context](val c: C): extension (sym: c.Symbol) def getVisibility(): Int = 0 diff --git a/tests/pos/i10951.scala b/tests/pos/i10951.scala index fd71ca59c073..2520536a491c 100644 --- a/tests/pos/i10951.scala +++ b/tests/pos/i10951.scala @@ -1,6 +1,6 @@ import scala.language.dynamics -object Dyn extends Dynamic with +object Dyn extends Dynamic: def selectDynamic[T](name: String): Option[T] = None val a: Option[(Int, Int)] = Dyn.asdf[Tuple2[Int, Int]] diff --git a/tests/pos/i11081.scala b/tests/pos/i11081.scala index d77f56505d7b..cd333d7e407d 100644 --- a/tests/pos/i11081.scala +++ b/tests/pos/i11081.scala @@ -1,6 +1,6 @@ -enum Outer with +enum Outer: case Foo -object Outer with +object Outer: trait Bar case class Baz(bar: Bar) case class Bam(bar: Bar = new Bar() {}) diff --git a/tests/pos/i4561.scala b/tests/pos/i4561.scala index a0791313633a..5a51cb668a37 100644 --- a/tests/pos/i4561.scala +++ b/tests/pos/i4561.scala @@ -1,6 +1,6 @@ -object abc with +object abc: trait Test0 - trait Test1[T] with + trait Test1[T]: def apply(f: T => T): Unit def apply(s: String): Unit diff --git a/tests/pos/i6375.scala b/tests/pos/i6375.scala index 4df662e3c1ec..aa682483b52d 100644 --- a/tests/pos/i6375.scala +++ b/tests/pos/i6375.scala @@ -28,7 +28,7 @@ } } */ -class Test with +class Test: given Int = 0 def f(): Int ?=> Boolean = true : (Int ?=> Boolean) diff --git a/tests/pos/i6734.scala b/tests/pos/i6734.scala index 904b36aa9e9b..fa7d9946ada4 100644 --- a/tests/pos/i6734.scala +++ b/tests/pos/i6734.scala @@ -1,4 +1,4 @@ -object Bug with +object Bug: extension [A, B, Z](ab: (A, B)) def pipe2(f: (A, B) => Z): Z = f(ab._1, ab._2) diff --git a/tests/pos/i6900.scala b/tests/pos/i6900.scala index 75999b25e7ec..55587a18b4ba 100644 --- a/tests/pos/i6900.scala +++ b/tests/pos/i6900.scala @@ -1,15 +1,15 @@ object Test1 { - trait Foo[A] with + trait Foo[A]: def foo[C]: C => A // Works with old-style conversion - implicit def i2f[A](a: A): Foo[A] = new Foo[A] with + implicit def i2f[A](a: A): Foo[A] = new Foo[A]: def foo[C]: C => A = _ => a // But not with newstyle /* given [A]: Conversion[A, Foo[A]] with - def apply(a: A) = new Foo[A] with + def apply(a: A) = new Foo[A]: def foo[C]: C => A = _ => a */ diff --git a/tests/pos/i6938.scala b/tests/pos/i6938.scala index 706aee5d3c1d..e58ab2829cf9 100644 --- a/tests/pos/i6938.scala +++ b/tests/pos/i6938.scala @@ -1,5 +1,5 @@ trait Foo[T] -object Foo with +object Foo: given [T]: Foo[Tuple1[T]] with {} given [T, U]: Foo[(T, U)] with {} given [T, U, V]: Foo[(T, U, V)] with {} \ No newline at end of file diff --git a/tests/pos/i7217.scala b/tests/pos/i7217.scala index 2a3c3f64fa6a..1c2a92c731b7 100644 --- a/tests/pos/i7217.scala +++ b/tests/pos/i7217.scala @@ -1,4 +1,4 @@ -class Foo(p1: String, p2: String) with +class Foo(p1: String, p2: String): def this(p1: String) = this(p1, "blah") val x = { Foo("blah", "hah") } diff --git a/tests/pos/i7359.scala b/tests/pos/i7359.scala index 97908254e99d..697b20b23cd0 100644 --- a/tests/pos/i7359.scala +++ b/tests/pos/i7359.scala @@ -1,95 +1,95 @@ package test -trait ObjectInterface with +trait ObjectInterface: def equals(obj: Any): Boolean def hashCode(): Int def toString(): String -trait SAMPlain with +trait SAMPlain: def first(): String -trait SAMPlainWithOverriddenObjectMethods with +trait SAMPlainWithOverriddenObjectMethods: def first(): String def equals(obj: Any): Boolean def hashCode(): Int def toString(): String -trait SAMPlainWithExtends extends ObjectInterface with +trait SAMPlainWithExtends extends ObjectInterface: def first(): String -trait SAMPlainWithExtendsAndOverride extends ObjectInterface with +trait SAMPlainWithExtendsAndOverride extends ObjectInterface: def first(): String override def equals(obj: Any): Boolean override def hashCode(): Int override def toString(): String -trait SAMPlainCovariantOut[+O] with +trait SAMPlainCovariantOut[+O]: def first(): O -trait SAMCovariantOut[+O] with +trait SAMCovariantOut[+O]: def first(): O def equals(obj: Any): Boolean def hashCode(): Int def toString(): String -trait SAMCovariantOutExtends[+O] extends ObjectInterface with +trait SAMCovariantOutExtends[+O] extends ObjectInterface: def first(): O -trait SAMCovariantOutExtendsAndOverride[+O] extends ObjectInterface with +trait SAMCovariantOutExtendsAndOverride[+O] extends ObjectInterface: def first(): O override def equals(obj: Any): Boolean override def hashCode(): Int override def toString(): String -trait SAMPlainContravariantIn[-I] with +trait SAMPlainContravariantIn[-I]: def first(in: I): Unit -trait SAMContravariantIn[-I] with +trait SAMContravariantIn[-I]: def first(in: I): Unit def equals(obj: Any): Boolean def hashCode(): Int def toString(): String -trait SAMContravariantInExtends[-I] extends ObjectInterface with +trait SAMContravariantInExtends[-I] extends ObjectInterface: def first(in: I): Unit -trait SAMContravariantInExtendsAndOverride[-I] extends ObjectInterface with +trait SAMContravariantInExtendsAndOverride[-I] extends ObjectInterface: def first(in: I): Unit override def equals(obj: Any): Boolean override def hashCode(): Int override def toString(): String -trait SAMPlainInvariant[T] with +trait SAMPlainInvariant[T]: def first(in: T): T -trait SAMInvariant[T] with +trait SAMInvariant[T]: def first(in: T): T def equals(obj: Any): Boolean def hashCode(): Int def toString(): String -trait SAMInvariantExtends[T] extends ObjectInterface with +trait SAMInvariantExtends[T] extends ObjectInterface: def first(in: T): T -trait SAMInvariantExtendsAndOverride[T] extends ObjectInterface with +trait SAMInvariantExtendsAndOverride[T] extends ObjectInterface: def first(in: T): T override def equals(obj: Any): Boolean override def hashCode(): Int override def toString(): String -trait SAMPlainInOut[-I, +O] with +trait SAMPlainInOut[-I, +O]: def first(in: I): O -trait SAMInOut[-I, +O] with +trait SAMInOut[-I, +O]: def first(in: I): O def equals(obj: Any): Boolean def hashCode(): Int def toString(): String -trait SAMInOutExtends[-I, +O] extends ObjectInterface with +trait SAMInOutExtends[-I, +O] extends ObjectInterface: def first(in: I): O -trait SAMInOutExtendsAndOverride[-I, +O] extends ObjectInterface with +trait SAMInOutExtendsAndOverride[-I, +O] extends ObjectInterface: def first(in: I): O override def equals(obj: Any): Boolean override def hashCode(): Int @@ -99,13 +99,13 @@ type CustomString = String type CustomBoolean = Boolean type CustomInt = Int -trait SAMWithCustomAliases with +trait SAMWithCustomAliases: def first(): String def equals(obj: Any): CustomBoolean def hashCode(): CustomInt def toString(): CustomString -object Main with +object Main: def main(args: Array[String]) = val samPlain : SAMPlain = () => "Hello, World!" val samPlainWithOverriddenObjectMethods: SAMPlainWithOverriddenObjectMethods = () => "Hello, World!" diff --git a/tests/pos/i7375.scala b/tests/pos/i7375.scala index 96bdd0b41b50..9da548f99ce7 100644 --- a/tests/pos/i7375.scala +++ b/tests/pos/i7375.scala @@ -1,10 +1,10 @@ -trait Entity[M, T, P] with +trait Entity[M, T, P]: extension (me: M) def receive(sender: T)(msg: P)(using Entity[T, M, P]): Unit extension (me: M) def name(): String class GreetingPerson(private val name: String) -object GreetingPerson with +object GreetingPerson: given GreetingPersonEntity: Entity[GreetingPerson, GreetedPerson, String] with extension (me: GreetingPerson) def receive(sender: GreetedPerson)(msg: String)(using Entity[GreetedPerson, GreetingPerson, String]): Unit = println(f"Thanks for saying $msg, ${sender.name()}") @@ -14,7 +14,7 @@ object GreetingPerson with class GreetedPerson(private val name: String) -object GreetedPerson with +object GreetedPerson: given GreetedPersonEntity: Entity[GreetedPerson, GreetingPerson, String] with extension (me: GreetedPerson) def receive(sender: GreetingPerson)(msg: String)(using Entity[GreetingPerson, GreetedPerson, String]): Unit = println(f"Thanks for saying $msg, ${sender.name()}") diff --git a/tests/pos/i7413.scala b/tests/pos/i7413.scala index 5b04cee445cf..ebc0c5b2777a 100644 --- a/tests/pos/i7413.scala +++ b/tests/pos/i7413.scala @@ -2,20 +2,20 @@ import scala.language.implicitConversions trait Fixture[A] extends Conversion[0, A] -trait TestFramework[A] with +trait TestFramework[A]: extension (testName: String) def in(test: Fixture[A] ?=> Unit): Unit = ??? -trait Greeter with +trait Greeter: def greet(name: String): String = s"Hello $name" case class MyFixture(name: String, greeter: Greeter) -object Test1 with +object Test1: given conv: Conversion[0, Greeter] with def apply(x: 0): Greeter = ??? val g: Greeter = 0 -class MyTest extends TestFramework[MyFixture] with +class MyTest extends TestFramework[MyFixture]: "say hello" in { assert(0.greeter.greet(0.name) == s"Hello ${0.name}") } diff --git a/tests/pos/i7428.scala b/tests/pos/i7428.scala index e1ab2ffd91e8..b702c7146cc5 100644 --- a/tests/pos/i7428.scala +++ b/tests/pos/i7428.scala @@ -1,5 +1,5 @@ -class ABug with - enum Tag with +class ABug: + enum Tag: case first import Tag.first val xx = first diff --git a/tests/pos/i7648.scala b/tests/pos/i7648.scala index 13dd1376c9e5..12e4a025f859 100644 --- a/tests/pos/i7648.scala +++ b/tests/pos/i7648.scala @@ -11,7 +11,7 @@ class Stream[+F[_], +A] { } } -object Test with +object Test: implicit val ioMonad: Monad[IO] = null diff --git a/tests/pos/i7700.scala b/tests/pos/i7700.scala index 56151dc5554c..fdcfc23c9105 100644 --- a/tests/pos/i7700.scala +++ b/tests/pos/i7700.scala @@ -1,12 +1,12 @@ package test -trait Show[-A] with +trait Show[-A]: def show(a: A): String -object Macros with +object Macros: extension (sc: StringContext) inline def show(args: =>Any*): String = ??? -object Show with +object Show: extension [A] (a: A) def show(using S: Show[A]): String = S.show(a) export Macros.show \ No newline at end of file diff --git a/tests/pos/i7757.scala b/tests/pos/i7757.scala index f1c7b2b48122..cebd6fc3ad84 100644 --- a/tests/pos/i7757.scala +++ b/tests/pos/i7757.scala @@ -1,7 +1,7 @@ val m: Map[Int, String] = ??? val _ = m.map((a, b) => a + b.length) -trait Foo with +trait Foo: def g(f: ((Int, Int)) => Int): Int = 1 def g(f: ((Int, Int)) => (Int, Int)): String = "2" diff --git a/tests/pos/i7793.scala b/tests/pos/i7793.scala index f0c394208a07..3458315c48c5 100644 --- a/tests/pos/i7793.scala +++ b/tests/pos/i7793.scala @@ -1,4 +1,4 @@ -trait Foo with +trait Foo: def g(f: Int => Int): Int = 1 def g(using String)(f: Int => String): String = "2" diff --git a/tests/pos/i7807.scala b/tests/pos/i7807.scala index 36193f26a972..df8a41ddcf8d 100644 --- a/tests/pos/i7807.scala +++ b/tests/pos/i7807.scala @@ -1,4 +1,4 @@ -object Test with +object Test: def flip: (x: 0 | 1) => x.type match { case 0 => 1 case 1 => 0 } = ??? diff --git a/tests/pos/i8181.scala b/tests/pos/i8181.scala index 5afdf5950ba4..d36214c3068a 100644 --- a/tests/pos/i8181.scala +++ b/tests/pos/i8181.scala @@ -1,4 +1,4 @@ -object Main with +object Main: def main(args: Array[String]): Unit = extension (a: AnyRef) def putout(): Unit = println(a) diff --git a/tests/pos/i8182.scala b/tests/pos/i8182.scala index 8679ad224ec1..9acf2941c570 100644 --- a/tests/pos/i8182.scala +++ b/tests/pos/i8182.scala @@ -1,6 +1,6 @@ package example -trait Show[-A] with +trait Show[-A]: extension (a: A) def show: String given (using rec: Show[String]): Show[String] = ??? // must be Show[String] as the argument diff --git a/tests/pos/i8319.scala b/tests/pos/i8319.scala index 412d33260be1..d08ba85e7115 100644 --- a/tests/pos/i8319.scala +++ b/tests/pos/i8319.scala @@ -5,7 +5,7 @@ case class Lam[T,U]() extends Tree[Any] case class App[T,U]() extends Tree[Any] case class Var() extends Tree[Any] -object Branch with +object Branch: def unapply(branch: Lam[?,?] | App[?,?]): true = true private def foo(s: Option[Tree[?]]) = s match // seems to only occur in a nested pattern diff --git a/tests/pos/i8397.scala b/tests/pos/i8397.scala index e0e126d60687..d0b97f84129d 100644 --- a/tests/pos/i8397.scala +++ b/tests/pos/i8397.scala @@ -3,13 +3,13 @@ given foo(using x: Int): AnyRef with // #7859 -trait Lub2[A, B] with +trait Lub2[A, B]: type Output given [A <: C, B <: C, C]: Lub2[A, B] with type Output = C -trait Lub[Union] with +trait Lub[Union]: type Output given [A]: Lub[A] with diff --git a/tests/pos/i8530.scala b/tests/pos/i8530.scala index e0b1963cb7bc..2eab9f9e74c8 100644 --- a/tests/pos/i8530.scala +++ b/tests/pos/i8530.scala @@ -1,19 +1,19 @@ -object MyBoooleanUnapply with +object MyBoooleanUnapply: inline def unapply(x: Int): Boolean = true -object MyOptionUnapply with +object MyOptionUnapply: inline def unapply(x: Int): Option[Long] = Some(x) -object MyUnapplyImplicits with +object MyUnapplyImplicits: inline def unapply(x: Int)(using DummyImplicit): Option[Long] = Some(x) -object MyPolyUnapply with +object MyPolyUnapply: inline def unapply[T](x: T): Option[T] = Some(x) -object MySeqUnapply with +object MySeqUnapply: inline def unapplySeq(x: Int): Seq[Int] = Seq(x, x) -object MyWhiteboxUnapply with +object MyWhiteboxUnapply: transparent inline def unapply(x: Int): Option[Any] = Some(x) def test: Unit = diff --git a/tests/pos/i8623.scala b/tests/pos/i8623.scala index 3f505ca54f47..e0df48811e1c 100644 --- a/tests/pos/i8623.scala +++ b/tests/pos/i8623.scala @@ -1,6 +1,6 @@ -trait QC with - object tasty with +trait QC: + object tasty: type Tree extension (tree: Tree) def pos: Tree = ??? diff --git a/tests/pos/i8750.scala b/tests/pos/i8750.scala index 5fb9c68a8d75..a88cfb51acd2 100644 --- a/tests/pos/i8750.scala +++ b/tests/pos/i8750.scala @@ -1,4 +1,4 @@ -class Abc with +class Abc: opaque type Log = Double val v : Abc = new Abc \ No newline at end of file diff --git a/tests/pos/i8801.scala b/tests/pos/i8801.scala index 2b122340e3a7..f925a60dbfe3 100644 --- a/tests/pos/i8801.scala +++ b/tests/pos/i8801.scala @@ -1,4 +1,4 @@ -object Foo with +object Foo: locally { case class Baz() } diff --git a/tests/pos/i8843.scala b/tests/pos/i8843.scala index aac14dfa838b..d6744d4096f5 100644 --- a/tests/pos/i8843.scala +++ b/tests/pos/i8843.scala @@ -1,4 +1,4 @@ -class C with +class C: type X <: Tuple inline def f(c: C): Unit = { diff --git a/tests/pos/i8845.scala b/tests/pos/i8845.scala index c30fa6b51e8e..52e41cbc9605 100644 --- a/tests/pos/i8845.scala +++ b/tests/pos/i8845.scala @@ -1,4 +1,4 @@ -trait IntToLong with +trait IntToLong: def apply(v: Int) : Long inline def convert1( f: IntToLong) = ??? diff --git a/tests/pos/i8874.scala b/tests/pos/i8874.scala index a458e5c2ddc6..cc19ee330ac0 100644 --- a/tests/pos/i8874.scala +++ b/tests/pos/i8874.scala @@ -1,4 +1,4 @@ -trait Abc with +trait Abc: opaque type Log = Double class AbcClass extends Abc diff --git a/tests/pos/i8892.scala b/tests/pos/i8892.scala index 6763e8fdc895..f08b12341d3b 100644 --- a/tests/pos/i8892.scala +++ b/tests/pos/i8892.scala @@ -1,7 +1,7 @@ -trait Reporter with +trait Reporter: def report(m: String): Unit -class Dummy extends Reporter with +class Dummy extends Reporter: def report(m: String) = () object ABug { diff --git a/tests/pos/i8920/Qu_1.scala b/tests/pos/i8920/Qu_1.scala index 08c6e3e90ffa..c0ddfdcaae8e 100644 --- a/tests/pos/i8920/Qu_1.scala +++ b/tests/pos/i8920/Qu_1.scala @@ -1,9 +1,9 @@ package scala.collection.mutable -class Qu[A] protected (array: Array[AnyRef], start: Int, end: Int) with +class Qu[A] protected (array: Array[AnyRef], start: Int, end: Int): def this(initialSize: Int = ArrayDeque.DefaultInitialSize) = this(ArrayDeque.alloc(initialSize), start = 0, end = 0) -object Qu with +object Qu: def f[A](array: Array[AnyRef], start: Int, end: Int) = 1 def f[A](initialSize: Int = 1) = 2 diff --git a/tests/pos/i8927.scala b/tests/pos/i8927.scala index 1cf45c0045fa..2dfb419abab3 100644 --- a/tests/pos/i8927.scala +++ b/tests/pos/i8927.scala @@ -1,14 +1,14 @@ import scala.language.implicitConversions -trait Eq[k <: AnyKind, K[_ <: k]] with +trait Eq[k <: AnyKind, K[_ <: k]]: extension [A <: k, B <: k](k: K[A]) def isEq (k2: K[B]): Eq.GEQ[k, K, A, B] -object Eq with - enum GEQ[k <: AnyKind, K[_ <: k], A <: k, B <: k] with +object Eq: + enum GEQ[k <: AnyKind, K[_ <: k], A <: k, B <: k]: case Y[k <: AnyKind, K[_ <: k], A <: k](res: K[A]) extends GEQ[k, K, A, A] case N() -sealed trait DPair[k <: AnyKind, K[_ <: k], +V[_ <: k]] with +sealed trait DPair[k <: AnyKind, K[_ <: k], +V[_ <: k]]: type A <: k val key: K[A] val value: V[A] @@ -16,8 +16,8 @@ sealed trait DPair[k <: AnyKind, K[_ <: k], +V[_ <: k]] with case y: Eq.GEQ.Y[k, K, A] => Some(value) case _ => None -object DPair with +object DPair: given pair [k, K[_ <: k], V[_ <: k], C <: k]: Conversion[(K[C], V[C]), DPair[k, K, V]] = tup => - case class dpair(key: K[C], value: V[C]) extends DPair[k, K, V] with + case class dpair(key: K[C], value: V[C]) extends DPair[k, K, V]: type A = C dpair(tup._1, tup._2) diff --git a/tests/pos/i8968.scala b/tests/pos/i8968.scala index 915eb2681561..ac76dd5ca56c 100644 --- a/tests/pos/i8968.scala +++ b/tests/pos/i8968.scala @@ -1,7 +1,7 @@ -object Foo with +object Foo: inline def get = 0 -object Bar with +object Bar: export Foo._ val v = Bar.get diff --git a/tests/pos/i8972.scala b/tests/pos/i8972.scala index ffa003d65424..e4678718aa4f 100644 --- a/tests/pos/i8972.scala +++ b/tests/pos/i8972.scala @@ -1,7 +1,7 @@ -trait Num with +trait Num: type Nat -object IsInt with +object IsInt: def unapply(using num: Num)(sc: num.Nat): Option[Int] = ??? def test(using num: Num)(x: num.Nat) = diff --git a/tests/pos/i8997.scala b/tests/pos/i8997.scala index 9e5fba6a77cf..4a34902b97c4 100644 --- a/tests/pos/i8997.scala +++ b/tests/pos/i8997.scala @@ -1,4 +1,4 @@ -object Foo with +object Foo: def unapply(n: Int)(using x: DummyImplicit)(using y: Int): Option[Int] = ??? def test = diff --git a/tests/pos/i9052/A.scala b/tests/pos/i9052/A.scala index cc24250c7c91..1ff6fa0df82e 100644 --- a/tests/pos/i9052/A.scala +++ b/tests/pos/i9052/A.scala @@ -1,4 +1,4 @@ -object impl with +object impl: case object UNone import impl._ diff --git a/tests/pos/i9069/Wrapper.scala b/tests/pos/i9069/Wrapper.scala index f25c128a5f4c..1c3952b683e1 100644 --- a/tests/pos/i9069/Wrapper.scala +++ b/tests/pos/i9069/Wrapper.scala @@ -1,4 +1,4 @@ sealed trait Foo -object Foo with +object Foo: case object Baz extends Foo case class Bar(x: Int) extends Foo diff --git a/tests/pos/i9103.scala b/tests/pos/i9103.scala index e84d194d299f..c33eb8166201 100644 --- a/tests/pos/i9103.scala +++ b/tests/pos/i9103.scala @@ -1,4 +1,4 @@ -object a with +object a: trait Foo[T] given Foo[Unit] = ??? diff --git a/tests/pos/i9213.scala b/tests/pos/i9213.scala index e8fc2a862292..1a6488c4c0fb 100644 --- a/tests/pos/i9213.scala +++ b/tests/pos/i9213.scala @@ -1,5 +1,5 @@ trait A(a: Any, b: Int) -trait B(a: Any, b: Int) with +trait B(a: Any, b: Int): var x = 0 class C(a: String, b: Int) diff --git a/tests/pos/i9307.scala b/tests/pos/i9307.scala index 4b5f7fae1708..a795f1d3fc62 100644 --- a/tests/pos/i9307.scala +++ b/tests/pos/i9307.scala @@ -1,4 +1,4 @@ -class Foo with +class Foo: private var foo1: Int = _ private var foo2: Array[Int] = _ private[this] var foo3: Array[Int] = _ diff --git a/tests/pos/i9342b.scala b/tests/pos/i9342b.scala index 39e224d528e0..e317391f9bb8 100644 --- a/tests/pos/i9342b.scala +++ b/tests/pos/i9342b.scala @@ -1,4 +1,4 @@ -trait Label[A] with +trait Label[A]: def apply(v: A): String given [A]: Label[A] = _.toString diff --git a/tests/pos/i9342c.scala b/tests/pos/i9342c.scala index 27efc0baabdc..eed9d45326f1 100644 --- a/tests/pos/i9342c.scala +++ b/tests/pos/i9342c.scala @@ -1,4 +1,4 @@ -trait Label[A] with +trait Label[A]: def apply(v: A): String def g[A]: Label[A] = _.toString diff --git a/tests/pos/i9352.scala b/tests/pos/i9352.scala index ee45cdebee2a..db757b48b027 100644 --- a/tests/pos/i9352.scala +++ b/tests/pos/i9352.scala @@ -1,6 +1,6 @@ abstract class Foo[B] extends Bar[B] -trait Bar[A] with +trait Bar[A]: self: Foo[A] => def foo : Unit = bar(???) diff --git a/tests/pos/i9457.scala b/tests/pos/i9457.scala index 32550e351ebb..c210e3dc92ff 100644 --- a/tests/pos/i9457.scala +++ b/tests/pos/i9457.scala @@ -1,4 +1,4 @@ -object inlinetuple with +object inlinetuple: def test: Int = f((1, 2)) inline def f(inline p: (Int, Int)): Int = diff --git a/tests/pos/i9464.scala b/tests/pos/i9464.scala index d0a94ed3dd9f..56cef7aedff8 100644 --- a/tests/pos/i9464.scala +++ b/tests/pos/i9464.scala @@ -1,4 +1,4 @@ -trait T with +trait T: type X def x: X diff --git a/tests/pos/i9530.scala b/tests/pos/i9530.scala index aa5e0d1b04e0..32b2f26dbd6c 100644 --- a/tests/pos/i9530.scala +++ b/tests/pos/i9530.scala @@ -1,12 +1,12 @@ trait Food case class Banana(color: String) extends Food -trait Diet[A <: Animal] with +trait Diet[A <: Animal]: type F <: Food def food: Seq[F] trait Animal -object Animal with +object Animal: extension [A <: Animal](using diet: Diet[A])(animal: A) def food1 = diet.food extension [A <: Animal](animal: A)(using diet: Diet[A]) def food2 = diet.food diff --git a/tests/pos/i9562.scala b/tests/pos/i9562.scala index a1cd86a2993b..9f58ff309d3c 100644 --- a/tests/pos/i9562.scala +++ b/tests/pos/i9562.scala @@ -1,7 +1,7 @@ -class Foo with +class Foo: def foo = 23 -object Unrelated with +object Unrelated: extension (f: Foo) def g = f.foo // OK diff --git a/tests/pos/i9844.scala b/tests/pos/i9844.scala index f4c2427fde90..a660c5046c5b 100644 --- a/tests/pos/i9844.scala +++ b/tests/pos/i9844.scala @@ -1,4 +1,4 @@ -object test1 with +object test1: trait Foo[A] trait Baz[A] { @@ -8,13 +8,13 @@ object test1 with } } -object test2 with +object test2: - trait Foo with + trait Foo: private var f = "abc" trait Baz { - trait Bam with + trait Bam: val f = 0 trait Bar extends Bam { this: Foo => @@ -23,7 +23,7 @@ object test2 with } } -object test3 with +object test3: object DetSkipOctree { sealed trait Leaf [PL] sealed trait Branch[PL] diff --git a/tests/pos/i9967.scala b/tests/pos/i9967.scala index 0b506d5323df..4e915a27bfbf 100644 --- a/tests/pos/i9967.scala +++ b/tests/pos/i9967.scala @@ -1,6 +1,6 @@ import collection.mutable -class MaxSizeMap[K, V](maxSize: Int)(using o: Ordering[K]) with +class MaxSizeMap[K, V](maxSize: Int)(using o: Ordering[K]): val sortedMap: mutable.TreeMap[K, V] = mutable.TreeMap.empty[K, V](o) export sortedMap._ diff --git a/tests/pos/i9994.scala b/tests/pos/i9994.scala index d94e5d4d8f77..d2125fe07df9 100644 --- a/tests/pos/i9994.scala +++ b/tests/pos/i9994.scala @@ -1,7 +1,7 @@ package pkg -trait Foo with +trait Foo: def foo: this.type -final class Bar extends Foo with +final class Bar extends Foo: def foo: this.type = this diff --git a/tests/pos/indent.scala b/tests/pos/indent.scala index c6289884980a..03502a26fe79 100644 --- a/tests/pos/indent.scala +++ b/tests/pos/indent.scala @@ -1,4 +1,4 @@ -object Test with +object Test: locally { var x = 0 @@ -82,7 +82,7 @@ object Test with x < 10 do () -class Test2 with +class Test2: self => def foo(x: Int) = if x < 0 then throw @@ -97,15 +97,15 @@ class Test2 with end x end Test2 -class Test3 with +class Test3: self => def foo = 1 import collection.mutable.HashMap -class Coder(words: List[String]) with +class Coder(words: List[String]): - class Foo with + class Foo: println() end Foo @@ -146,5 +146,5 @@ class Coder(words: List[String]) with } end Coder -object Test22 with +object Test22: def foo: Int = 22 \ No newline at end of file diff --git a/tests/pos/indent2.scala b/tests/pos/indent2.scala index 6df51b51cf81..bbe07dae959a 100644 --- a/tests/pos/indent2.scala +++ b/tests/pos/indent2.scala @@ -1,6 +1,6 @@ -object testindent with +object testindent: - class C with + class C: val x = 0 val c = new C diff --git a/tests/pos/indent4.scala b/tests/pos/indent4.scala index ee76ea84186c..fa80b62d7db4 100644 --- a/tests/pos/indent4.scala +++ b/tests/pos/indent4.scala @@ -1,4 +1,4 @@ -object testindent with +object testindent: if (true) val x = 1 diff --git a/tests/pos/inline-val-constValue-1.scala b/tests/pos/inline-val-constValue-1.scala index f9cec9f466ad..efd482cd5c09 100644 --- a/tests/pos/inline-val-constValue-1.scala +++ b/tests/pos/inline-val-constValue-1.scala @@ -1,6 +1,6 @@ import compiletime._ -class C with +class C: type X <: Tuple def test: Unit = diff --git a/tests/pos/inline-val-constValue-2.scala b/tests/pos/inline-val-constValue-2.scala index 2ff62a31d34f..33ae23069fa2 100644 --- a/tests/pos/inline-val-constValue-2.scala +++ b/tests/pos/inline-val-constValue-2.scala @@ -1,6 +1,6 @@ import compiletime._ -class C with +class C: type N <: Int def test: Unit = diff --git a/tests/pos/main-method-scheme-class-based.scala b/tests/pos/main-method-scheme-class-based.scala index 41b51432afe6..86393d05c953 100644 --- a/tests/pos/main-method-scheme-class-based.scala +++ b/tests/pos/main-method-scheme-class-based.scala @@ -11,7 +11,7 @@ import collection.mutable * or `command.argsGetter` if is a final varargs parameter, * - a call to `command.run` with the closure of user-main applied to all arguments. */ -trait MainAnnotation extends StaticAnnotation with +trait MainAnnotation extends StaticAnnotation: /** The class used for argument string parsing. E.g. `scala.util.CommandLineParser.FromString`, * but could be something else @@ -25,7 +25,7 @@ trait MainAnnotation extends StaticAnnotation with def command(args: Array[String]): Command /** A class representing a command to run */ - abstract class Command with + abstract class Command: /** The getter for the next argument of type `T` */ def argGetter[T](argName: String, fromString: ArgumentParser[T], defaultValue: Option[T] = None): () => T @@ -42,12 +42,12 @@ end MainAnnotation //Sample main class, can be freely implemented: -class main extends MainAnnotation with +class main extends MainAnnotation: type ArgumentParser[T] = util.CommandLineParser.FromString[T] type MainResultType = Any - def command(args: Array[String]): Command = new Command with + def command(args: Array[String]): Command = new Command: /** A buffer of demanded argument names, plus * "?" if it has a default @@ -135,7 +135,7 @@ end main // Sample main method -object myProgram with +object myProgram: /** Adds two numbers */ @main def add(num: Int, inc: Int = 1): Unit = @@ -145,7 +145,7 @@ end myProgram // Compiler generated code: -object add extends main with +object add extends main: def main(args: Array[String]) = val cmd = command(args) val arg1 = cmd.argGetter[Int]("num", summon[ArgumentParser[Int]]) diff --git a/tests/pos/main-method-scheme.scala b/tests/pos/main-method-scheme.scala index df6ec31692d2..c65f7c928efd 100644 --- a/tests/pos/main-method-scheme.scala +++ b/tests/pos/main-method-scheme.scala @@ -1,7 +1,7 @@ import annotation.StaticAnnotation import collection.mutable -trait MainAnnotation extends StaticAnnotation with +trait MainAnnotation extends StaticAnnotation: type ArgumentParser[T] @@ -18,7 +18,7 @@ end MainAnnotation //Sample main class, can be freely implemented: -class main(progName: String, args: Array[String], docComment: String) extends MainAnnotation with +class main(progName: String, args: Array[String], docComment: String) extends MainAnnotation: def this() = this("", Array(), "") @@ -106,7 +106,7 @@ end main // Sample main method -object myProgram with +object myProgram: /** Adds two numbers */ @main def add(num: Int, inc: Int = 1) = @@ -116,7 +116,7 @@ end myProgram // Compiler generated code: -object add with +object add: def main(args: Array[String]) = val cmd = new main("add", args, "Adds two numbers") val arg1 = cmd.getArg[Int]("num", summon[cmd.ArgumentParser[Int]]) diff --git a/tests/pos/matches.scala b/tests/pos/matches.scala index 3f724dbef756..7b590d5bb422 100644 --- a/tests/pos/matches.scala +++ b/tests/pos/matches.scala @@ -1,5 +1,5 @@ package matches -object Test with +object Test: 2 min 3 match case 2 => "OK" case 3 => "?" diff --git a/tests/pos/matrixOps.scala b/tests/pos/matrixOps.scala index 44fc5bc2052d..ab96a09389a5 100644 --- a/tests/pos/matrixOps.scala +++ b/tests/pos/matrixOps.scala @@ -1,4 +1,4 @@ -object Test with +object Test: type Matrix = Array[Array[Double]] type Vector = Array[Double] diff --git a/tests/pos/opaques-queue.scala b/tests/pos/opaques-queue.scala index b03b9c8e0210..079ef7fde4f6 100644 --- a/tests/pos/opaques-queue.scala +++ b/tests/pos/opaques-queue.scala @@ -1,11 +1,11 @@ class Elem -trait QueueSignature with +trait QueueSignature: type Queue def empty: Queue def append(q: Queue, e: Elem): Queue def pop(q: Queue): Option[(Elem, Queue)] val QueueModule: QueueSignature = - object QueueImpl extends QueueSignature with + object QueueImpl extends QueueSignature: type Queue = (List[Elem], List[Elem]) def empty = (Nil, Nil) def append(q: Queue, e: Elem): Queue = (q._1, e :: q._2) @@ -15,7 +15,7 @@ val QueueModule: QueueSignature = case (Nil, ys) => pop((ys.reverse, Nil)) QueueImpl -object queues with +object queues: opaque type Queue = (List[Elem], List[Elem]) def empty = (Nil, Nil) def append(q: Queue, e: Elem): Queue = (q._1, e :: q._2) diff --git a/tests/pos/packagings.scala b/tests/pos/packagings.scala index 96ce1a66e34c..47e1df204b34 100644 --- a/tests/pos/packagings.scala +++ b/tests/pos/packagings.scala @@ -1,10 +1,10 @@ package foo: package bar: - object A with + object A: def foo = 1 end bar end foo package baz: - object B with + object B: def f = foo.bar.A.foo end baz diff --git a/tests/pos/postconditions.scala b/tests/pos/postconditions.scala index c492231d517f..90117c17b207 100644 --- a/tests/pos/postconditions.scala +++ b/tests/pos/postconditions.scala @@ -1,4 +1,4 @@ -object PostConditions with +object PostConditions: opaque type WrappedResult[T] = T def result[T](using r: WrappedResult[T]): T = r @@ -8,6 +8,6 @@ object PostConditions with assert(condition) x -object Test with +object Test: import PostConditions.{ensuring, result} val s = List(1, 2, 3).sum.ensuring(result == 6) diff --git a/tests/pos/reference/adts.scala b/tests/pos/reference/adts.scala index e93bb843f97c..41ea6660638e 100644 --- a/tests/pos/reference/adts.scala +++ b/tests/pos/reference/adts.scala @@ -1,25 +1,25 @@ package adts -object t1 with +object t1: - enum Option[+T] with + enum Option[+T]: case Some[T](x: T) extends Option[T] case None -object t2 with +object t2: - enum Option[+T] with + enum Option[+T]: case Some[T](x: T) extends Option[T] case None extends Option[Nothing] -enum Color(val rgb: Int) with +enum Color(val rgb: Int): case Red extends Color(0xFF0000) case Green extends Color(0x00FF00) case Blue extends Color(0x0000FF) case Mix(mix: Int) extends Color(mix) -object t3 with +object t3: - enum Option[+T] with + enum Option[+T]: case Some[T](x: T) extends Option[T] case None @@ -27,6 +27,6 @@ object t3 with case None => false case some => true - object Option with + object Option: def apply[T >: Null](x: T): Option[T] = if (x == null) None else Some(x) diff --git a/tests/pos/reference/auto-param-tupling.scala b/tests/pos/reference/auto-param-tupling.scala index c2dd9889fa98..c32173867fe6 100644 --- a/tests/pos/reference/auto-param-tupling.scala +++ b/tests/pos/reference/auto-param-tupling.scala @@ -1,6 +1,6 @@ package autoParamTupling -object t1 with +object t1: val xs: List[(Int, Int)] = ??? xs.map { diff --git a/tests/pos/reference/compile-time.scala b/tests/pos/reference/compile-time.scala index 119d16f51718..32ea7660c898 100644 --- a/tests/pos/reference/compile-time.scala +++ b/tests/pos/reference/compile-time.scala @@ -1,6 +1,6 @@ package compiletime -class Test with +class Test: import scala.compiletime.{constValue, erasedValue, S} trait Nat diff --git a/tests/pos/reference/delegate-match.scala b/tests/pos/reference/delegate-match.scala index bf026b2d4ea8..3ab00cc46701 100644 --- a/tests/pos/reference/delegate-match.scala +++ b/tests/pos/reference/delegate-match.scala @@ -1,6 +1,6 @@ package implicitmatch -class Test extends App with +class Test extends App: import scala.collection.immutable.{TreeSet, HashSet} import scala.compiletime.summonFrom diff --git a/tests/pos/reference/delegates.scala b/tests/pos/reference/delegates.scala index 35bd6ebdddff..88002d939330 100644 --- a/tests/pos/reference/delegates.scala +++ b/tests/pos/reference/delegates.scala @@ -1,30 +1,30 @@ -class Common with +class Common: - trait Ord[T] with + trait Ord[T]: extension (x: T) def compareTo(y: T): Int extension (x: T) def < (y: T) = x.compareTo(y) < 0 extension (x: T) def > (y: T) = x.compareTo(y) > 0 - trait Convertible[From, To] with + trait Convertible[From, To]: extension (x: From) def convert: To - trait SemiGroup[T] with + trait SemiGroup[T]: extension (x: T) def combine(y: T): T - trait Monoid[T] extends SemiGroup[T] with + trait Monoid[T] extends SemiGroup[T]: def unit: T - trait Functor[F[_]] with + trait Functor[F[_]]: extension [A](x: F[A]) def map[B](f: A => B): F[B] - trait Monad[F[_]] extends Functor[F] with + trait Monad[F[_]] extends Functor[F]: extension [A](x: F[A]) def flatMap[B](f: A => F[B]): F[B] extension [A](x: F[A]) def map[B](f: A => B) = x.flatMap(f `andThen` pure) def pure[A](x: A): F[A] end Common -object Instances extends Common with +object Instances extends Common: given intOrd: Ord[Int] with extension (x: Int) def compareTo(y: Int) = @@ -64,7 +64,7 @@ object Instances extends Common with def maximum[T](xs: List[T])(using Ord[T]): T = xs.reduceLeft((x, y) => if (x < y) y else x) - def descending[T](using asc: Ord[T]): Ord[T] = new Ord[T] with + def descending[T](using asc: Ord[T]): Ord[T] = new Ord[T]: extension (x: T) def compareTo(y: T) = asc.compareTo(y)(x) def minimum[T](xs: List[T])(using Ord[T]) = @@ -85,20 +85,20 @@ object Instances extends Common with class B val ab: (x: A, y: B) ?=> Int = (a: A, b: B) ?=> 22 - trait TastyAPI with + trait TastyAPI: type Symbol - trait SymDeco with + trait SymDeco: extension (sym: Symbol) def name: String given symDeco: SymDeco - object TastyImpl extends TastyAPI with + object TastyImpl extends TastyAPI: type Symbol = String given symDeco: SymDeco with extension (sym: Symbol) def name = sym class D[T] - class C(using ctx: Context) with + class C(using ctx: Context): def f() = locally { given Context = this.ctx @@ -121,14 +121,14 @@ object Instances extends Common with class Token(str: String) - object Token with + object Token: given StringToToken: Conversion[String, Token] with def apply(str: String): Token = new Token(str) val x: Token = "if" end Instances -object PostConditions with +object PostConditions: opaque type WrappedResult[T] = T def result[T](using x: WrappedResult[T]): T = x @@ -139,7 +139,7 @@ object PostConditions with x end PostConditions -object AnonymousInstances extends Common with +object AnonymousInstances extends Common: given Ord[Int] with extension (x: Int) def compareTo(y: Int) = if (x < y) -1 else if (x > y) +1 else 0 @@ -173,12 +173,12 @@ object AnonymousInstances extends Common with xs.foldLeft(summon[Monoid[T]].unit)(_.combine(_)) end AnonymousInstances -object Implicits extends Common with - implicit object IntOrd extends Ord[Int] with +object Implicits extends Common: + implicit object IntOrd extends Ord[Int]: extension (x: Int) def compareTo(y: Int) = if (x < y) -1 else if (x > y) +1 else 0 - class ListOrd[T: Ord] extends Ord[List[T]] with + class ListOrd[T: Ord] extends Ord[List[T]]: extension (xs: List[T]) def compareTo(ys: List[T]): Int = (xs, ys).match case (Nil, Nil) => 0 case (Nil, _) => -1 @@ -199,31 +199,31 @@ object Implicits extends Common with (implicit cmp: Ord[T]): T = xs.reduceLeft((x, y) => if (x < y) y else x) - def descending[T](implicit asc: Ord[T]): Ord[T] = new Ord[T] with + def descending[T](implicit asc: Ord[T]): Ord[T] = new Ord[T]: extension (x: T) def compareTo(y: T) = asc.compareTo(y)(x) def minimum[T](xs: List[T])(implicit cmp: Ord[T]) = maximum(xs)(descending) -object Test extends App with +object Test extends App: Instances.test() import PostConditions.{result, ensuring} val s = List(1, 2, 3).sum s.ensuring(result == 6) end Test -object Completions with +object Completions: class Future[T] class HttpResponse class StatusCode // The argument "magnet" type - enum CompletionArg with + enum CompletionArg: case Error(s: String) case Response(f: Future[HttpResponse]) case Status(code: Future[StatusCode]) - object CompletionArg with + object CompletionArg: // conversions defining the possible arguments to pass to `complete` // these always come with CompletionArg diff --git a/tests/pos/reference/extension-methods.scala b/tests/pos/reference/extension-methods.scala index 15c8da3f6586..daa187cafa50 100644 --- a/tests/pos/reference/extension-methods.scala +++ b/tests/pos/reference/extension-methods.scala @@ -1,4 +1,4 @@ -object ExtMethods with +object ExtMethods: case class Circle(x: Double, y: Double, radius: Double) @@ -44,7 +44,7 @@ object ExtMethods with val limit = smallest(n).max xs.zipWithIndex.collect { case (x, i) if x <= limit => i } - trait IntOps with + trait IntOps: extension (i: Int) def isZero: Boolean = i == 0 extension (i: Int) def safeMod(x: Int): Option[Int] = @@ -53,13 +53,13 @@ object ExtMethods with else Some(i % x) end IntOps - object IntOpsEx extends IntOps with + object IntOpsEx extends IntOps: extension (i: Int) def safeDiv(x: Int): Option[Int] = // extension method brought into scope via inheritance from IntOps if x.isZero then None else Some(i / x) - trait SafeDiv with + trait SafeDiv: import IntOpsEx._ // brings safeDiv and safeMod into scope extension (i: Int) def divide(d: Int) : Option[(Int, Int)] = @@ -73,19 +73,19 @@ object ExtMethods with given ops1: IntOps with {} // brings safeMod into scope 1.safeMod(2) - class Lst[T](xs: T*) with + class Lst[T](xs: T*): private val elems = xs.toList def foldLeft[U](x: U)(op: (U, T) => U): U = elems.foldLeft(x)(op) def ++ (other: Lst[T]): Lst[T] = Lst(elems ++ other.elems: _*) - trait Ord[T] with + trait Ord[T]: extension (x: T) def less (y: T): Boolean - object Ord with + object Ord: given Ord[Int] with extension (x: Int) def less (y: Int): Boolean = x < y end Ord - object Lst with + object Lst: extension [T](xs: Lst[Lst[T]]) def flatten: Lst[T] = xs.foldLeft(Lst())(_ ++ _) @@ -110,7 +110,7 @@ object ExtMethods with if n < s.length && s(n) != ch then position(ch, n + 1) else n - object DoubleOps with + object DoubleOps: extension (x: Double) def ** (exponent: Int): Double = require(exponent > 0) if exponent == 0 then 1 else x * (x ** (exponent - 1)) diff --git a/tests/pos/reference/structural-closeable.scala b/tests/pos/reference/structural-closeable.scala index c396555ac6ab..771a6ae4ebc8 100644 --- a/tests/pos/reference/structural-closeable.scala +++ b/tests/pos/reference/structural-closeable.scala @@ -2,10 +2,10 @@ type Closeable = { def close(): Unit } -class FileInputStream with +class FileInputStream: def close(): Unit = () -class Channel with +class Channel: def close(): Unit = () import scala.reflect.Selectable.reflectiveSelectable diff --git a/tests/pos/single-case.scala b/tests/pos/single-case.scala index 82466ec31733..2552f05129a6 100644 --- a/tests/pos/single-case.scala +++ b/tests/pos/single-case.scala @@ -1,4 +1,4 @@ -object test with +object test: try println("hi") diff --git a/tests/pos/targetName-infer-result.scala b/tests/pos/targetName-infer-result.scala index 42da8d36b457..7e732395a483 100644 --- a/tests/pos/targetName-infer-result.scala +++ b/tests/pos/targetName-infer-result.scala @@ -1,23 +1,23 @@ import annotation.targetName -enum Tree with +enum Tree: case Bind(sym: Symbol, body: Tree) class Symbol -object Test1 with - abstract class TreeAccumulator[X] with +object Test1: + abstract class TreeAccumulator[X]: def app(x: X, tree: Tree): X def app(x: X, trees: List[Tree]): X = ??? - val acc = new TreeAccumulator[List[Symbol]] with + val acc = new TreeAccumulator[List[Symbol]]: def app(syms: List[Symbol], tree: Tree) = tree match case Tree.Bind(sym, body) => app(sym :: syms, body) -object Test2 with - abstract class TreeAccumulator[X] with +object Test2: + abstract class TreeAccumulator[X]: @targetName("apply") def app(x: X, tree: Tree): X def app(x: X, trees: List[Tree]): X = ??? - val acc = new TreeAccumulator[List[Symbol]] with + val acc = new TreeAccumulator[List[Symbol]]: @targetName("apply") def app(syms: List[Symbol], tree: Tree) = tree match case Tree.Bind(sym, body) => app(sym :: syms, body) diff --git a/tests/pos/targetName-override.scala b/tests/pos/targetName-override.scala index 202f0a272ca5..a15ce5594a76 100644 --- a/tests/pos/targetName-override.scala +++ b/tests/pos/targetName-override.scala @@ -1,11 +1,11 @@ import scala.annotation.targetName -class A with +class A: @targetName("ff") def f(x: => Int): Int = x def f(x: => String): Int = x.length -class B extends A with +class B extends A: @targetName("ff") override def f(x: => Int): Int = x // OK override def f(x: => String): Int = x.length // OK diff --git a/tests/pos/targetName-refine.scala b/tests/pos/targetName-refine.scala index ae6206a18de0..eaa02b8b7976 100644 --- a/tests/pos/targetName-refine.scala +++ b/tests/pos/targetName-refine.scala @@ -1,7 +1,7 @@ import annotation.targetName -trait T with +trait T: @targetName("f2") def f: Any -class C extends T with +class C extends T: @targetName("f2") def f: Int = 1 val x: T { def f: Int } = C() diff --git a/tests/pos/tasty-tags-obscure.scala b/tests/pos/tasty-tags-obscure.scala index 8a73d714272e..cd883ee0aeba 100644 --- a/tests/pos/tasty-tags-obscure.scala +++ b/tests/pos/tasty-tags-obscure.scala @@ -1,15 +1,15 @@ -object ObscureTasty with +object ObscureTasty: def foo(f: [t] => List[t] ?=> Unit) = ??? def test1 = foo([t] => (a: List[t]) ?=> ()) // POLYtype => GIVENMETHODType def bar(f: [t] => List[t] => Unit) = ??? def test2 = bar([t] => (a: List[t]) => ()) // POLYtype => METHODType - class Bar with + class Bar: final val bar = "Bar.bar" - class Foo extends Bar with - object A with + class Foo extends Bar: + object A: def unapply(a: Any): Some[Foo.super.bar.type] = ??? def foo = diff --git a/tests/pos/typeclass-encoding3.scala b/tests/pos/typeclass-encoding3.scala index 7ae34427acb9..363826d2d6bd 100644 --- a/tests/pos/typeclass-encoding3.scala +++ b/tests/pos/typeclass-encoding3.scala @@ -45,7 +45,7 @@ object Test { class Str(val s: String) extends Monoid def combine(that: Str): Str = new Str(this.s + that.s) - object Str with + object Str: def unit = "" extension for String : Monoid diff --git a/tests/pos/widen-union.scala b/tests/pos/widen-union.scala index 6cd2e7787660..b0b64f0dc6c6 100644 --- a/tests/pos/widen-union.scala +++ b/tests/pos/widen-union.scala @@ -1,10 +1,10 @@ -object Test1 with +object Test1: val x: Int | String = 1 val y = x val z: Int | String = y -object Test2 with +object Test2: type Sig = Int | String def consistent(x: Sig, y: Sig): Boolean = ???// x == y @@ -12,7 +12,7 @@ object Test2 with xs.corresponds(ys)(consistent) // OK || xs.corresponds(ys)(consistent(_, _)) // error, found: Any, required: Int | String -object Test3 with +object Test3: def g[X](x: X | String): Int = ??? def y: Boolean | String = ??? diff --git a/tests/run-custom-args/tasty-inspector/i10359.scala b/tests/run-custom-args/tasty-inspector/i10359.scala index c2c9dad128a0..b724d0431b4a 100644 --- a/tests/run-custom-args/tasty-inspector/i10359.scala +++ b/tests/run-custom-args/tasty-inspector/i10359.scala @@ -33,7 +33,7 @@ object Test { } } -class TestInspector() extends TastyInspector with +class TestInspector() extends TastyInspector: protected def processCompilationUnit(using Quotes)(root: quotes.reflect.Tree): Unit = import quotes.reflect._ diff --git a/tests/run-custom-args/tasty-inspector/i8163.scala b/tests/run-custom-args/tasty-inspector/i8163.scala index e2bfba37aede..2ac769b321f1 100644 --- a/tests/run-custom-args/tasty-inspector/i8163.scala +++ b/tests/run-custom-args/tasty-inspector/i8163.scala @@ -20,7 +20,7 @@ object Test { } } -class TestInspector() extends TastyInspector with +class TestInspector() extends TastyInspector: protected def processCompilationUnit(using Quotes)(root: quotes.reflect.Tree): Unit = inspectClass(root) diff --git a/tests/run-custom-args/tasty-inspector/i8460.scala b/tests/run-custom-args/tasty-inspector/i8460.scala index 4e1c590cbf11..4f2d9ba6df44 100644 --- a/tests/run-custom-args/tasty-inspector/i8460.scala +++ b/tests/run-custom-args/tasty-inspector/i8460.scala @@ -33,7 +33,7 @@ object Test { } } -class TestInspector_Children() extends TastyInspector with +class TestInspector_Children() extends TastyInspector: var kids: List[String] = Nil diff --git a/tests/run-custom-args/tasty-inspector/i9970.scala b/tests/run-custom-args/tasty-inspector/i9970.scala index 6bf79569cbfd..fc76ea5e0fb5 100644 --- a/tests/run-custom-args/tasty-inspector/i9970.scala +++ b/tests/run-custom-args/tasty-inspector/i9970.scala @@ -46,7 +46,7 @@ object Test { // Inspector that performs the actual tests -class TestInspector() extends TastyInspector with +class TestInspector() extends TastyInspector: private var foundIOApp: Boolean = false private var foundSimple: Boolean = false diff --git a/tests/run-macros/BigFloat/BigFloatFromDigitsImpl_1.scala b/tests/run-macros/BigFloat/BigFloatFromDigitsImpl_1.scala index 324a583aead3..d77cf6334f2f 100644 --- a/tests/run-macros/BigFloat/BigFloatFromDigitsImpl_1.scala +++ b/tests/run-macros/BigFloat/BigFloatFromDigitsImpl_1.scala @@ -3,7 +3,7 @@ import language.experimental.genericNumberLiterals import scala.util.FromDigits import scala.quoted._ -object BigFloatFromDigitsImpl with +object BigFloatFromDigitsImpl: def apply(digits: Expr[String])(using Quotes): Expr[BigFloat] = digits.value match case Some(ds) => diff --git a/tests/run-macros/enum-nat-macro/Macros_2.scala b/tests/run-macros/enum-nat-macro/Macros_2.scala index d92878e1443f..19339ef403e8 100644 --- a/tests/run-macros/enum-nat-macro/Macros_2.scala +++ b/tests/run-macros/enum-nat-macro/Macros_2.scala @@ -4,7 +4,7 @@ import Nat._ inline def ZeroMacro: Zero.type = ${ Macros.natZero } transparent inline def toNatMacro(inline int: Int): Nat = ${ Macros.toNatImpl('int) } - object Macros with + object Macros: import quoted._ def toIntImpl(nat: Expr[Nat])(using Quotes): Expr[Int] = diff --git a/tests/run-macros/enum-nat-macro/Nat_1.scala b/tests/run-macros/enum-nat-macro/Nat_1.scala index 14733b4b57e2..fbb209698469 100644 --- a/tests/run-macros/enum-nat-macro/Nat_1.scala +++ b/tests/run-macros/enum-nat-macro/Nat_1.scala @@ -1,3 +1,3 @@ -enum Nat with +enum Nat: case Zero case Succ[N <: Nat](n: N) diff --git a/tests/run-macros/i10464/Person_1.scala b/tests/run-macros/i10464/Person_1.scala index 4c0845973a48..3973f018dd83 100644 --- a/tests/run-macros/i10464/Person_1.scala +++ b/tests/run-macros/i10464/Person_1.scala @@ -1,4 +1,4 @@ -trait Person with +trait Person: def name: String case class PersonA(name: String) extends Person diff --git a/tests/run-macros/i7716/Macro_1.scala b/tests/run-macros/i7716/Macro_1.scala index fe4b1c413c0a..01f4e5184a12 100644 --- a/tests/run-macros/i7716/Macro_1.scala +++ b/tests/run-macros/i7716/Macro_1.scala @@ -1,14 +1,14 @@ import scala.quoted._ -trait Foo with +trait Foo: def mcrImpl1(e: Expr[Any])(using ctx: Quotes): Expr[Any] = '{println(s"Hello ${$e}")} -object Foo extends Foo with +object Foo extends Foo: def mcrImpl2(e: Expr[Any])(using ctx: Quotes): Expr[Any] = '{println(s"Hello ${$e}")} -object Bar with +object Bar: import Foo._ inline def mcr1(e: => Any) = ${mcrImpl1('e)} diff --git a/tests/run-macros/i8530/Macro_1.scala b/tests/run-macros/i8530/Macro_1.scala index b15e2282961a..dc431c14ef14 100644 --- a/tests/run-macros/i8530/Macro_1.scala +++ b/tests/run-macros/i8530/Macro_1.scala @@ -1,6 +1,6 @@ import scala.quoted._ -object Succ with +object Succ: inline def unapply(n: Int): Option[Int] = ${ impl('n) } diff --git a/tests/run-macros/i9812b/Macro_1.scala b/tests/run-macros/i9812b/Macro_1.scala index 8b2e6f46cc52..ed1873195323 100644 --- a/tests/run-macros/i9812b/Macro_1.scala +++ b/tests/run-macros/i9812b/Macro_1.scala @@ -6,14 +6,14 @@ trait Liftable[T] { def toExpr(x: T): Quotes ?=> Expr[T] } -object Lift with +object Lift: def apply[T: Liftable](t: T)(using q: Quotes, ev: Liftable[T]): Expr[T] = ev.toExpr(t) sealed abstract class SomeEnum -object SomeEnum with +object SomeEnum: final val Foo = new SomeEnum {} final case class Bar[S <: SomeEnum](s: S) extends SomeEnum - object Bar with + object Bar: def apply[S <: SomeEnum](s: S): SomeEnum = new Bar(s) given LiftFoo: Liftable[Foo.type] with diff --git a/tests/run-macros/paramSymss/Test_2.scala b/tests/run-macros/paramSymss/Test_2.scala index 2ca016ddbcf6..4e2b53060c8b 100644 --- a/tests/run-macros/paramSymss/Test_2.scala +++ b/tests/run-macros/paramSymss/Test_2.scala @@ -16,5 +16,5 @@ object Test { println(showParamSyms(new Test(1, 2))) } -class Test[T](a: T) with +class Test[T](a: T): def this(a: Int, b: T) = this(b) diff --git a/tests/run-macros/refined-selectable-macro/Macro_1.scala b/tests/run-macros/refined-selectable-macro/Macro_1.scala index 05471dfd0adc..27dcbaa01082 100644 --- a/tests/run-macros/refined-selectable-macro/Macro_1.scala +++ b/tests/run-macros/refined-selectable-macro/Macro_1.scala @@ -2,7 +2,7 @@ import scala.quoted._ object Macro { - trait Selectable extends scala.Selectable with + trait Selectable extends scala.Selectable: def selectDynamic(name: String): Any trait SelectableRecord extends Selectable { diff --git a/tests/run-macros/tasty-overload-secondargs/Macro_1.scala b/tests/run-macros/tasty-overload-secondargs/Macro_1.scala index 5a5b6137d5df..91c74945c92b 100644 --- a/tests/run-macros/tasty-overload-secondargs/Macro_1.scala +++ b/tests/run-macros/tasty-overload-secondargs/Macro_1.scala @@ -1,6 +1,6 @@ import scala.quoted._ -object X with +object X: def andThen[A,B](a:A)(f: A => B): B = println("totalFunction") @@ -11,7 +11,7 @@ object X with f.lift.apply(a) -object Macro with +object Macro: inline def mThen[A,B](inline x:A=>B):B = ${ mThenImpl[A,B,A=>B,B]('x) diff --git a/tests/run-macros/tasty-overload-secondargs/Test_2.scala b/tests/run-macros/tasty-overload-secondargs/Test_2.scala index 458cee275906..2584ed01346f 100644 --- a/tests/run-macros/tasty-overload-secondargs/Test_2.scala +++ b/tests/run-macros/tasty-overload-secondargs/Test_2.scala @@ -1,4 +1,4 @@ -object Test with +object Test: def main(args:Array[String]):Unit = val x1 = X.andThen(1){case x if (x%2 == 0) => x} diff --git a/tests/run-macros/tasty-tree-map/quoted_1.scala b/tests/run-macros/tasty-tree-map/quoted_1.scala index 4d7a101c5583..a4363f60b599 100644 --- a/tests/run-macros/tasty-tree-map/quoted_1.scala +++ b/tests/run-macros/tasty-tree-map/quoted_1.scala @@ -1,9 +1,9 @@ import scala.quoted._ -object Macros with +object Macros: implicit inline def identityMaped[T](x: => T): T = ${ MacrosImpl.impl('x) } -object MacrosImpl with +object MacrosImpl: def impl[T: Type](x: Expr[T])(using Quotes) : Expr[T] = { import quotes.reflect._ val identityMap = new TreeMap { } diff --git a/tests/run-staging/abstract-int-quote.scala b/tests/run-staging/abstract-int-quote.scala index f518d7372d77..c3070086104b 100644 --- a/tests/run-staging/abstract-int-quote.scala +++ b/tests/run-staging/abstract-int-quote.scala @@ -1,7 +1,7 @@ import scala.quoted._ import scala.quoted.staging._ -object Test with +object Test: given Compiler = Compiler.make(getClass.getClassLoader) diff --git a/tests/run-staging/i7897.scala b/tests/run-staging/i7897.scala index d7d0ea558846..2b0952971761 100644 --- a/tests/run-staging/i7897.scala +++ b/tests/run-staging/i7897.scala @@ -1,6 +1,6 @@ import scala.quoted._, staging._ -object Test with +object Test: given Compiler = Compiler.make(getClass.getClassLoader) val f: Array[Int] => Int = run { diff --git a/tests/run-staging/i8178.scala b/tests/run-staging/i8178.scala index bb2f95f7bdee..c0aeb545bad2 100644 --- a/tests/run-staging/i8178.scala +++ b/tests/run-staging/i8178.scala @@ -5,7 +5,7 @@ def foo(n: Int, t: Expr[Int])(using Quotes): Expr[Int] = if (n == 0) t else '{ val a = ${Expr(n)}; ${foo(n - 1, 'a)} + $t } -object Test with +object Test: def main(args: Array[String]) = { // make available the necessary toolbox for runtime code generation given Compiler = Compiler.make(getClass.getClassLoader) diff --git a/tests/run-staging/shonan-hmm-simple.scala b/tests/run-staging/shonan-hmm-simple.scala index 3cde9885bbe7..e17c998ed65e 100644 --- a/tests/run-staging/shonan-hmm-simple.scala +++ b/tests/run-staging/shonan-hmm-simple.scala @@ -1,7 +1,7 @@ import scala.quoted._ import scala.quoted.staging._ -trait Ring[T] with +trait Ring[T]: val zero: T val one: T val add: (x: T, y: T) => T @@ -9,7 +9,7 @@ trait Ring[T] with val mul: (x: T, y: T) => T end Ring -class RingInt extends Ring[Int] with +class RingInt extends Ring[Int]: val zero = 0 val one = 1 val add = (x, y) => x + y @@ -17,30 +17,30 @@ class RingInt extends Ring[Int] with val mul = (x, y) => x * y -class RingIntExpr(using Quotes) extends Ring[Expr[Int]] with +class RingIntExpr(using Quotes) extends Ring[Expr[Int]]: val zero = '{0} val one = '{1} val add = (x, y) => '{$x + $y} val sub = (x, y) => '{$x - $y} val mul = (x, y) => '{$x * $y} -class RingComplex[U](u: Ring[U]) extends Ring[Complex[U]] with +class RingComplex[U](u: Ring[U]) extends Ring[Complex[U]]: val zero = Complex(u.zero, u.zero) val one = Complex(u.one, u.zero) val add = (x, y) => Complex(u.add(x.re, y.re), u.add(x.im, y.im)) val sub = (x, y) => Complex(u.sub(x.re, y.re), u.sub(x.im, y.im)) val mul = (x, y) => Complex(u.sub(u.mul(x.re, y.re), u.mul(x.im, y.im)), u.add(u.mul(x.re, y.im), u.mul(x.im, y.re))) -sealed trait PV[T] with +sealed trait PV[T]: def expr(using ToExpr[T], Quotes): Expr[T] -case class Sta[T](x: T) extends PV[T] with +case class Sta[T](x: T) extends PV[T]: def expr(using ToExpr[T], Quotes): Expr[T] = Expr(x) -case class Dyn[T](x: Expr[T]) extends PV[T] with +case class Dyn[T](x: Expr[T]) extends PV[T]: def expr(using ToExpr[T], Quotes): Expr[T] = x -class RingPV[U: ToExpr](u: Ring[U], eu: Ring[Expr[U]])(using Quotes) extends Ring[PV[U]] with +class RingPV[U: ToExpr](u: Ring[U], eu: Ring[Expr[U]])(using Quotes) extends Ring[PV[U]]: val zero: PV[U] = Sta(u.zero) val one: PV[U] = Sta(u.one) val add = (x: PV[U], y: PV[U]) => (x, y) match @@ -62,28 +62,28 @@ class RingPV[U: ToExpr](u: Ring[U], eu: Ring[Expr[U]])(using Quotes) extends Rin case class Complex[T](re: T, im: T) -object Complex with - implicit def isToExpr[T: Type: ToExpr]: ToExpr[Complex[T]] = new ToExpr[Complex[T]] with +object Complex: + implicit def isToExpr[T: Type: ToExpr]: ToExpr[Complex[T]] = new ToExpr[Complex[T]]: def apply(comp: Complex[T])(using Quotes) = '{Complex(${Expr(comp.re)}, ${Expr(comp.im)})} -case class Vec[Idx, T](size: Idx, get: Idx => T) with +case class Vec[Idx, T](size: Idx, get: Idx => T): def map[U](f: T => U): Vec[Idx, U] = Vec(size, i => f(get(i))) def zipWith[U, V](other: Vec[Idx, U], f: (T, U) => V): Vec[Idx, V] = Vec(size, i => f(get(i), other.get(i))) -object Vec with +object Vec: def from[T](elems: T*): Vec[Int, T] = new Vec(elems.size, i => elems(i)) -trait VecOps[Idx, T] with +trait VecOps[Idx, T]: val reduce: ((T, T) => T, T, Vec[Idx, T]) => T -class StaticVecOps[T] extends VecOps[Int, T] with +class StaticVecOps[T] extends VecOps[Int, T]: val reduce: ((T, T) => T, T, Vec[Int, T]) => T = (plus, zero, vec) => var sum = zero for (i <- 0 until vec.size) sum = plus(sum, vec.get(i)) sum -class ExprVecOps[T: Type](using Quotes) extends VecOps[Expr[Int], Expr[T]] with +class ExprVecOps[T: Type](using Quotes) extends VecOps[Expr[Int], Expr[T]]: val reduce: ((Expr[T], Expr[T]) => Expr[T], Expr[T], Vec[Expr[Int], Expr[T]]) => Expr[T] = (plus, zero, vec) => '{ var sum = $zero var i = 0 @@ -93,10 +93,10 @@ class ExprVecOps[T: Type](using Quotes) extends VecOps[Expr[Int], Expr[T]] with sum } -class Blas1[Idx, T](r: Ring[T], ops: VecOps[Idx, T]) with +class Blas1[Idx, T](r: Ring[T], ops: VecOps[Idx, T]): def dot(v1: Vec[Idx, T], v2: Vec[Idx, T]): T = ops.reduce(r.add, r.zero, v1.zipWith(v2, r.mul)) -object Test with +object Test: given Compiler = Compiler.make(getClass.getClassLoader) def main(args: Array[String]): Unit = diff --git a/tests/run-staging/shonan-hmm/PV.scala b/tests/run-staging/shonan-hmm/PV.scala index bb81d2648b87..46e56b7d4ab7 100644 --- a/tests/run-staging/shonan-hmm/PV.scala +++ b/tests/run-staging/shonan-hmm/PV.scala @@ -7,7 +7,7 @@ case class Sta[T](x: T) extends PV[T] case class Dyn[T](x: Expr[T]) extends PV[T] -object Dyn with +object Dyn: def apply[T: ToExpr](x: T)(using Quotes): Dyn[T] = Dyn(Expr(x)) object Dyns { diff --git a/tests/run-with-compiler/intmaptest.scala b/tests/run-with-compiler/intmaptest.scala index c5ded14b5728..c12cb03e979d 100644 --- a/tests/run-with-compiler/intmaptest.scala +++ b/tests/run-with-compiler/intmaptest.scala @@ -1,12 +1,12 @@ -trait Generator[+T] with +trait Generator[+T]: self => def generate: T - def map[S](f: T => S) = new Generator[S] with + def map[S](f: T => S) = new Generator[S]: def generate: S = f(self.generate) - def flatMap[S](f: T => Generator[S]) = new Generator[S] with + def flatMap[S](f: T => Generator[S]) = new Generator[S]: def generate: S = f(self.generate).generate -object Generator with +object Generator: val NumLimit = 300 val Iterations = 10000 @@ -20,7 +20,7 @@ object Generator with def range(end: Int): Generator[Int] = integers.map(x => (x % end).abs) - enum Op with + enum Op: case Lookup, Update, Remove export Op._ diff --git a/tests/run-with-compiler/maptest.scala b/tests/run-with-compiler/maptest.scala index 1e1f5d0eb63f..9a4b42981d94 100644 --- a/tests/run-with-compiler/maptest.scala +++ b/tests/run-with-compiler/maptest.scala @@ -1,12 +1,12 @@ -trait Generator[+T] with +trait Generator[+T]: self => def generate: T - def map[S](f: T => S) = new Generator[S] with + def map[S](f: T => S) = new Generator[S]: def generate: S = f(self.generate) - def flatMap[S](f: T => Generator[S]) = new Generator[S] with + def flatMap[S](f: T => Generator[S]) = new Generator[S]: def generate: S = f(self.generate).generate -object Generator with +object Generator: val NumLimit = 300 val Iterations = 10000 @@ -20,7 +20,7 @@ object Generator with def range(end: Int): Generator[Int] = integers.map(x => (x % end).abs) - enum Op with + enum Op: case Lookup, Update, Remove export Op._ diff --git a/tests/run-with-compiler/settest.scala b/tests/run-with-compiler/settest.scala index c7d1e048ab9e..3a725990b840 100644 --- a/tests/run-with-compiler/settest.scala +++ b/tests/run-with-compiler/settest.scala @@ -1,12 +1,12 @@ -trait Generator[+T] with +trait Generator[+T]: self => def generate: T - def map[S](f: T => S) = new Generator[S] with + def map[S](f: T => S) = new Generator[S]: def generate: S = f(self.generate) - def flatMap[S](f: T => Generator[S]) = new Generator[S] with + def flatMap[S](f: T => Generator[S]) = new Generator[S]: def generate: S = f(self.generate).generate -object Generator with +object Generator: val NumLimit = 300 val Iterations = 10000 @@ -20,7 +20,7 @@ object Generator with def range(end: Int): Generator[Int] = integers.map(x => (x % end).abs) - enum Op with + enum Op: case Lookup, Update, Remove export Op._ diff --git a/tests/run/ConfManagement.scala b/tests/run/ConfManagement.scala index 12305a99728f..f73445b5af08 100644 --- a/tests/run/ConfManagement.scala +++ b/tests/run/ConfManagement.scala @@ -1,12 +1,12 @@ case class Person(name: String) case class Paper(title: String, authors: List[Person], body: String) -object ConfManagement with +object ConfManagement: opaque type Viewers = Set[Person] def viewers(using vs: Viewers) = vs type Viewed[T] = Viewers ?=> T - class Conference(ratings: (Paper, Int)*) with + class Conference(ratings: (Paper, Int)*): private val realScore = ratings.toMap def papers: List[Paper] = ratings.map(_._1).toList diff --git a/tests/run/LazyLists.scala b/tests/run/LazyLists.scala index 3d7ecc626af1..6cf8c8cf8e50 100644 --- a/tests/run/LazyLists.scala +++ b/tests/run/LazyLists.scala @@ -1,7 +1,7 @@ package xcollections: import annotation.unchecked.uncheckedVariance - abstract class LazyList[+T] with + abstract class LazyList[+T]: private var myHead: T = _ private var myTail: LazyList[T] = _ @@ -40,12 +40,12 @@ package xcollections: case xs: LazyList[T] @unchecked => xs case _ => LazyList.fromIterator(xs.iterator) - object LazyList with + object LazyList: val empty: LazyList[Nothing] = new: protected def force(): LazyList[Nothing] = this - object #:: with + object #:: : def unapply[T](xs: LazyList[T]): Option[(T, LazyList[T])] = if xs.isEmpty then None else Some((xs.head, xs.tail)) diff --git a/tests/run/Pouring.scala b/tests/run/Pouring.scala index e1db06c23d89..6f4611af8bfc 100644 --- a/tests/run/Pouring.scala +++ b/tests/run/Pouring.scala @@ -1,8 +1,8 @@ -class Pouring(capacity: Vector[Int]) with +class Pouring(capacity: Vector[Int]): type Glass = Int type Content = Vector[Int] - enum Move with + enum Move: def apply(content: Content): Content = this match case Empty(g) => content.updated(g, 0) case Fill(g) => content.updated(g, capacity(g)) @@ -23,7 +23,7 @@ class Pouring(capacity: Vector[Int]) with ++ (for g <- glasses yield Move.Fill(g)) ++ (for g1 <- glasses; g2 <- glasses if g1 != g2 yield Move.Pour(g1, g2)) - class Path(history: List[Move], val endContent: Content) with + class Path(history: List[Move], val endContent: Content): def extend(move: Move) = Path(move :: history, move(endContent)) override def toString = s"${history.reverse.mkString(" ")} --> $endContent" end Path diff --git a/tests/run/Signals.scala b/tests/run/Signals.scala index 33a5c929bb39..18a1947dcaf0 100644 --- a/tests/run/Signals.scala +++ b/tests/run/Signals.scala @@ -2,7 +2,7 @@ import annotation.unchecked._ package frp: - sealed class Signal[+T](expr: Signal.Caller ?=> T) with + sealed class Signal[+T](expr: Signal.Caller ?=> T): private var myExpr: Signal.Caller => T = _ private var myValue: T = _ private var observers: Set[Signal.Caller] = Set() @@ -26,19 +26,19 @@ package frp: observers = Set() obs.foreach(_.computeValue()) - object Signal with + object Signal: type Caller = Signal[?] given noCaller: Caller(???) with override def computeValue() = () end Signal - class Var[T](expr: Signal.Caller ?=> T) extends Signal[T](expr) with + class Var[T](expr: Signal.Caller ?=> T) extends Signal[T](expr): def update(expr: Signal.Caller ?=> T): Unit = changeTo(expr) end Var end frp import frp._ -class BankAccount with +class BankAccount: def balance: Signal[Int] = myBalance private var myBalance: Var[Int] = Var(0) diff --git a/tests/run/Signals1.scala b/tests/run/Signals1.scala index 178c1b276c0a..129965b4c2a5 100644 --- a/tests/run/Signals1.scala +++ b/tests/run/Signals1.scala @@ -2,12 +2,12 @@ import annotation.unchecked._ package frp: - trait Signal[+T] with + trait Signal[+T]: def apply()(using caller: Signal.Caller): T - object Signal with + object Signal: - abstract class AbstractSignal[+T] extends Signal[T] with + abstract class AbstractSignal[+T] extends Signal[T]: private var currentValue: T = _ private var observers: Set[Caller] = Set() @@ -29,11 +29,11 @@ package frp: end AbstractSignal def apply[T](expr: Caller ?=> T): Signal[T] = - new AbstractSignal[T] with + new AbstractSignal[T]: protected val eval = expr(using _) computeValue() - class Var[T](expr: Caller ?=> T) extends AbstractSignal[T] with + class Var[T](expr: Caller ?=> T) extends AbstractSignal[T]: protected var eval: Caller => T = expr(using _) computeValue() @@ -43,7 +43,7 @@ package frp: end Var opaque type Caller = AbstractSignal[?] - given noCaller: Caller = new AbstractSignal[Nothing] with + given noCaller: Caller = new AbstractSignal[Nothing]: override def eval = ??? override def computeValue() = () @@ -51,7 +51,7 @@ package frp: end frp import frp._ -class BankAccount with +class BankAccount: def balance: Signal[Int] = myBalance private val myBalance: Signal.Var[Int] = Signal.Var(0) diff --git a/tests/run/Typeable.scala b/tests/run/Typeable.scala index c2a76335c382..18bf9a4deb6a 100644 --- a/tests/run/Typeable.scala +++ b/tests/run/Typeable.scala @@ -16,15 +16,15 @@ * it's unclear whether this should expand to `C[T].unapply(x)`, (as it does now) * or to `C.unapply[T](x)` (which is what TypeLevel Scala 4 did, I believe) */ -trait Typeable[T] with +trait Typeable[T]: def cast(x: Any): Option[T] def describe: String override def toString = s"Typeable[$describe]" -object Typeable with +object Typeable: def apply[T: Typeable]: Typeable[T] = summon - class instanceOf[T: Typeable] with + class instanceOf[T: Typeable]: def unapply(x: Any): Option[T] = Typeable[T].cast(x) given int: Typeable[Int] with diff --git a/tests/run/abstract-givens.scala b/tests/run/abstract-givens.scala index 18f8a5aface1..6ff966411dde 100644 --- a/tests/run/abstract-givens.scala +++ b/tests/run/abstract-givens.scala @@ -1,9 +1,9 @@ -trait T with +trait T: given x: Int given y(using Int): String given z[T](using T): Seq[T] -object Test extends T, App with +object Test extends T, App: given x: Int = 22 override given y(using Int): String = summon[Int].toString given z[T](using T): Seq[T] with diff --git a/tests/run/context-functions.scala b/tests/run/context-functions.scala index 64da62d3de88..e71f0de10378 100644 --- a/tests/run/context-functions.scala +++ b/tests/run/context-functions.scala @@ -1,4 +1,4 @@ -trait A with +trait A: type Ctx[T] type Mega[T] @@ -14,7 +14,7 @@ trait A with def trans(x: Ctx[Int]): Ctx[Int] = x end A -object m extends A with +object m extends A: type Ctx[T] = String ?=> T type Mega[T] = (Int, Int, Int, Int, Int, @@ -36,7 +36,7 @@ object m extends A with def mega: Mega[Int] = summon[String].length end m -trait B with +trait B: type Ctx[T] @@ -45,7 +45,7 @@ trait B with def id[T](x: T): T = drop(wrap(x)) end B -object n extends B with +object n extends B: type Ctx[T] = String ?=> Int ?=> T def wrap[T](x: T): Ctx[T] = x diff --git a/tests/run/decorators/DocComment.scala b/tests/run/decorators/DocComment.scala index 5b1402fdd588..85b30fbce393 100644 --- a/tests/run/decorators/DocComment.scala +++ b/tests/run/decorators/DocComment.scala @@ -5,7 +5,7 @@ * `body` what comes before the first tagged line */ case class DocComment(body: String, tags: Map[String, List[String]]) -object DocComment with +object DocComment: def fromString(str: String): DocComment = val lines = str.linesIterator.toList def tagged(line: String): Option[(String, String)] = diff --git a/tests/run/decorators/EntryPoint.scala b/tests/run/decorators/EntryPoint.scala index 5f3c341ad5c2..f87519fabee0 100644 --- a/tests/run/decorators/EntryPoint.scala +++ b/tests/run/decorators/EntryPoint.scala @@ -1,7 +1,7 @@ import collection.mutable /** A framework for defining stackable entry point wrappers */ -object EntryPoint with +object EntryPoint: /** A base trait for wrappers of entry points. * Sub-traits: Annotation#Wrapper @@ -26,14 +26,14 @@ object EntryPoint with * * The wrapper class has this outline: * - * object with + * object : * @WrapperAnnotation def (args: ) = * ... * * Here `` and `` are obtained from an * inline call to the `wrapperName` method. */ - trait Annotation extends annotation.StaticAnnotation with + trait Annotation extends annotation.StaticAnnotation: /** The class used for argument parsing. E.g. `scala.util.FromString`, if * arguments are strings, but it could be something else. @@ -56,7 +56,7 @@ object EntryPoint with def wrapper(entryPointName: String, docComment: String): Wrapper /** Base class for descriptions of an entry point wrappers */ - abstract class Wrapper extends EntryPoint.Wrapper with + abstract class Wrapper extends EntryPoint.Wrapper: /** The type of the wrapper argument. E.g., for Java main methods: `Array[String]` */ type Argument @@ -80,7 +80,7 @@ object EntryPoint with def call(arg: Argument): Call /** A class representing a wrapper call */ - abstract class Call with + abstract class Call: /** The getter for the next argument of type `T` */ def nextArgGetter[T](argName: String, fromString: ArgumentParser[T], defaultValue: Option[T] = None): () => T @@ -124,7 +124,7 @@ object EntryPoint with * created from @logged, @transactional, and @main, respectively. * - `x` is the argument of the outer $logged$wrapper. */ - trait Adapter extends annotation.StaticAnnotation with + trait Adapter extends annotation.StaticAnnotation: /** Creates a new wrapper around `wrapped` */ def wrapper(wrapped: EntryPoint.Wrapper): Wrapper @@ -169,7 +169,7 @@ object EntryPoint with * keep the `adapt` type contract implicit (types are still checked when adapts * are generated, of course). */ - abstract class Wrapper extends EntryPoint.Wrapper with + abstract class Wrapper extends EntryPoint.Wrapper: /** The wrapper that this wrapped in turn by this wrapper */ val wrapped: EntryPoint.Wrapper diff --git a/tests/run/decorators/Test.scala b/tests/run/decorators/Test.scala index 6e840ab26bd0..1d821d2109d2 100644 --- a/tests/run/decorators/Test.scala +++ b/tests/run/decorators/Test.scala @@ -1,4 +1,4 @@ -object Test with +object Test: def main(args: Array[String]) = def testAdd(args: String) = println(s"> java add $args") diff --git a/tests/run/decorators/main.scala b/tests/run/decorators/main.scala index feb6d7a6567e..a6fecc00b6e6 100644 --- a/tests/run/decorators/main.scala +++ b/tests/run/decorators/main.scala @@ -3,7 +3,7 @@ import collection.mutable /** A sample @main entry point annotation. * Generates a main function. */ -class main extends EntryPoint.Annotation with +class main extends EntryPoint.Annotation: type ArgumentParser[T] = util.CommandLineParser.FromString[T] type EntryPointResult = Unit @@ -13,11 +13,11 @@ class main extends EntryPoint.Annotation with def wrapper(name: String, doc: String): MainWrapper = new MainWrapper(name, doc) - class MainWrapper(val entryPointName: String, val docComment: String) extends Wrapper with + class MainWrapper(val entryPointName: String, val docComment: String) extends Wrapper: type Argument = Array[String] type Result = Unit - def call(args: Array[String]) = new Call with + def call(args: Array[String]) = new Call: /** A buffer of demanded argument names, plus * "?" if it has a default diff --git a/tests/run/decorators/sample-adapters.scala b/tests/run/decorators/sample-adapters.scala index 5cb868949e17..77622261d16e 100644 --- a/tests/run/decorators/sample-adapters.scala +++ b/tests/run/decorators/sample-adapters.scala @@ -1,10 +1,10 @@ // Sample adapters: -class logged extends EntryPoint.Adapter with +class logged extends EntryPoint.Adapter: def wrapper(wrapped: EntryPoint.Wrapper): LoggedWrapper = LoggedWrapper(wrapped) - class LoggedWrapper(val wrapped: EntryPoint.Wrapper) extends Wrapper with + class LoggedWrapper(val wrapped: EntryPoint.Wrapper) extends Wrapper: def adapt[A, R](op: A => R)(args: A): R = val argsString: String = args match case args: Array[_] => args.mkString(", ") @@ -17,18 +17,18 @@ class logged extends EntryPoint.Adapter with end LoggedWrapper end logged -class split extends EntryPoint.Adapter with +class split extends EntryPoint.Adapter: def wrapper(wrapped: EntryPoint.Wrapper): SplitWrapper = SplitWrapper(wrapped) - class SplitWrapper(val wrapped: EntryPoint.Wrapper) extends Wrapper with + class SplitWrapper(val wrapped: EntryPoint.Wrapper) extends Wrapper: def adapt[R](op: Array[String] => R)(args: String): R = op(args.split(" ")) end split -class join extends EntryPoint.Adapter with +class join extends EntryPoint.Adapter: def wrapper(wrapped: EntryPoint.Wrapper): JoinWrapper = JoinWrapper(wrapped) - class JoinWrapper(val wrapped: EntryPoint.Wrapper) extends Wrapper with + class JoinWrapper(val wrapped: EntryPoint.Wrapper) extends Wrapper: def adapt[R](op: String => R)(args: Array[String]): R = op(args.mkString(" ")) end join diff --git a/tests/run/decorators/sample-program.scala b/tests/run/decorators/sample-program.scala index 7447d40981e6..1f58f4cd3260 100644 --- a/tests/run/decorators/sample-program.scala +++ b/tests/run/decorators/sample-program.scala @@ -1,4 +1,4 @@ -object myProgram with +object myProgram: /** Adds two numbers * @param num the first number @@ -15,7 +15,7 @@ end myProgram // Compiler generated code: -object add with +object add: private val $main = new main() private val $main$wrapper = $main.wrapper( "MyProgram.add", @@ -29,7 +29,7 @@ object add with cll.run(myProgram.add(arg1(), arg2())) end add -object addAll with +object addAll: private val $main = new main() private val $split = new split() private val $logged = new logged() diff --git a/tests/run/defunctionalized.scala b/tests/run/defunctionalized.scala index c48b1bb6ad9a..aa236b8d22fb 100644 --- a/tests/run/defunctionalized.scala +++ b/tests/run/defunctionalized.scala @@ -1,4 +1,4 @@ -enum Filter with +enum Filter: case IsOdd case IsPrime case LessThan(bound: Int) diff --git a/tests/run/enum-custom-toString.scala b/tests/run/enum-custom-toString.scala index 9ef9ff044679..7432bde87ff9 100644 --- a/tests/run/enum-custom-toString.scala +++ b/tests/run/enum-custom-toString.scala @@ -1,23 +1,23 @@ -enum ES with +enum ES: case A override def toString: String = "overridden" -enum EJ extends java.lang.Enum[EJ] with +enum EJ extends java.lang.Enum[EJ]: case B override def toString: String = "overridden" -trait Mixin extends reflect.Enum with +trait Mixin extends reflect.Enum: override def productPrefix: String = "noprefix" override def toString: String = "overridden" -enum EM extends Mixin with +enum EM extends Mixin: case C -enum ET[T] extends java.lang.Enum[ET[_]] with +enum ET[T] extends java.lang.Enum[ET[_]]: case D extends ET[Unit] override def toString: String = "overridden" -enum EZ with +enum EZ: case E(arg: Int) override def toString: String = "overridden" @@ -25,20 +25,20 @@ enum EC: // control case case F case G(arg: Int) -enum EO with +enum EO: case H case I(arg: Int) override def productPrefix: String = "noprefix" override def toString: String = "overridden" end EO -enum EQ with +enum EQ: case J extends EQ with Mixin case K(arg: Int) extends EQ with Mixin abstract class Tag[T] extends reflect.Enum -object Tag with - private final class IntTagImpl extends Tag[Int] with runtime.EnumValue with +object Tag: + private final class IntTagImpl extends Tag[Int] with runtime.EnumValue: def ordinal = 0 override def hashCode = 123 final val IntTag: Tag[Int] = IntTagImpl() diff --git a/tests/run/enum-nat.scala b/tests/run/enum-nat.scala index 25149c8d2b48..47bddcc665cd 100644 --- a/tests/run/enum-nat.scala +++ b/tests/run/enum-nat.scala @@ -1,11 +1,11 @@ import Nat._ import compiletime._ -enum Nat with +enum Nat: case Zero case Succ[N <: Nat.Refract](n: N) -object Nat with +object Nat: type Refract = Zero.type | Succ[_] inline def toIntTypeLevel[N <: Nat]: Int = inline erasedValue[N] match diff --git a/tests/run/enum-ordinal-java/Lib.scala b/tests/run/enum-ordinal-java/Lib.scala index 69fc8190e02e..75b9003e5553 100644 --- a/tests/run/enum-ordinal-java/Lib.scala +++ b/tests/run/enum-ordinal-java/Lib.scala @@ -1,5 +1,5 @@ -object Lib1 with +object Lib1: trait MyJavaEnum[E <: java.lang.Enum[E]] extends java.lang.Enum[E] -object Lib2 with +object Lib2: type JavaEnumAlias[E <: java.lang.Enum[E]] = java.lang.Enum[E] diff --git a/tests/run/enum-ordinal-java/Test.scala b/tests/run/enum-ordinal-java/Test.scala index 83625d581082..082ea85f7044 100644 --- a/tests/run/enum-ordinal-java/Test.scala +++ b/tests/run/enum-ordinal-java/Test.scala @@ -1,7 +1,7 @@ -enum Color1 extends Lib1.MyJavaEnum[Color1] with +enum Color1 extends Lib1.MyJavaEnum[Color1]: case Red, Green, Blue -enum Color2 extends Lib2.JavaEnumAlias[Color2] with +enum Color2 extends Lib2.JavaEnumAlias[Color2]: case Red, Green, Blue @main def Test = diff --git a/tests/run/enum-values-order.scala b/tests/run/enum-values-order.scala index 3721728fc2a0..400cdbc8aac5 100644 --- a/tests/run/enum-values-order.scala +++ b/tests/run/enum-values-order.scala @@ -5,9 +5,9 @@ enum LatinAlphabet2 extends java.lang.Enum[LatinAlphabet2] { case A, B, C, D, E, enum LatinAlphabet3[+T] extends java.lang.Enum[LatinAlphabet3[_]] { case A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z } -object Color with +object Color: trait Pretty -enum Color extends java.lang.Enum[Color] with +enum Color extends java.lang.Enum[Color]: case Red, Green, Blue case Aqua extends Color with Color.Pretty case Grey, Black, White diff --git a/tests/run/enum-values.scala b/tests/run/enum-values.scala index f858d47a6792..a7b838ba73cd 100644 --- a/tests/run/enum-values.scala +++ b/tests/run/enum-values.scala @@ -1,31 +1,31 @@ import reflect.Selectable.reflectiveSelectable import deriving.Mirror -enum Color with +enum Color: case Red, Green, Blue -enum Suits extends java.lang.Enum[Suits] with +enum Suits extends java.lang.Enum[Suits]: case Clubs, Spades, Diamonds, Hearts -enum Tag[T] with +enum Tag[T]: case Int extends Tag[Int] case OfClass[T]()(using val tag: reflect.ClassTag[T]) extends Tag[T] // mix order of class and value case String extends Tag[String] -enum Expr[-T >: Null] with +enum Expr[-T >: Null]: case EmptyTree extends Expr[Null] case AnyTree -enum ListLike[+T] with +enum ListLike[+T]: case Cons[T](head: T, tail: ListLike[T]) extends ListLike[T] case EmptyListLike -enum TypeCtorsK[F[_]] with +enum TypeCtorsK[F[_]]: case List extends TypeCtorsK[List] case Const[T]() extends TypeCtorsK[[U] =>> T] // mix order of class and value case Option extends TypeCtorsK[Option] -enum MixedParams[F[_], G[X,Y] <: collection.Map[X,Y], T] with +enum MixedParams[F[_], G[X,Y] <: collection.Map[X,Y], T]: case Foo extends MixedParams[List, collection.mutable.LinkedHashMap, Unit] enum ClassOnly: // this should still generate the `ordinal` and `fromOrdinal` companion methods diff --git a/tests/run/enums-precise.scala b/tests/run/enums-precise.scala index 59867e9f6100..1ae98ca6664f 100644 --- a/tests/run/enums-precise.scala +++ b/tests/run/enums-precise.scala @@ -1,8 +1,8 @@ -enum NonEmptyList[+T] with +enum NonEmptyList[+T]: case Many[+U](head: U, tail: NonEmptyList[U]) extends NonEmptyList[U] case One [+U](value: U) extends NonEmptyList[U] -enum Ast with +enum Ast: case Binding(name: String, tpe: String) case Lambda(args: NonEmptyList[Binding], rhs: Ast) // reference to another case of the enum case Ident(name: String) diff --git a/tests/run/enums-serialization-compat.scala b/tests/run/enums-serialization-compat.scala index dfa8a7d06ee1..940e726c05a0 100644 --- a/tests/run/enums-serialization-compat.scala +++ b/tests/run/enums-serialization-compat.scala @@ -1,22 +1,22 @@ import java.io._ import scala.util.Using -enum JColor extends java.lang.Enum[JColor] with +enum JColor extends java.lang.Enum[JColor]: case Red // java enum has magic JVM support -enum SColor with +enum SColor: case Green // simple case last -enum SColorTagged[T] with +enum SColorTagged[T]: case Blue extends SColorTagged[Unit] case Rgb(r: Byte, g: Byte, b: Byte) extends SColorTagged[(Byte, Byte, Byte)] // mixing pattern kinds case Indigo extends SColorTagged[Unit] case Cmyk(c: Byte, m: Byte, y: Byte, k: Byte) extends SColorTagged[(Byte, Byte, Byte, Byte)] // class case last -enum Nucleobase with +enum Nucleobase: case A,C,G,T // patdef last -enum MyClassTag[T](wrapped: Class[?]) with +enum MyClassTag[T](wrapped: Class[?]): case IntTag extends MyClassTag[Int](classOf[Int]) case UnitTag extends MyClassTag[Unit](classOf[Unit]) // value case last diff --git a/tests/run/erased-inline-vals.scala b/tests/run/erased-inline-vals.scala index b74d2bfe2151..57e2901a62ea 100644 --- a/tests/run/erased-inline-vals.scala +++ b/tests/run/erased-inline-vals.scala @@ -1,17 +1,17 @@ -abstract class A with +abstract class A: def x: Int val y: Int -class B extends A with +class B extends A: inline def x: Int = 1 inline val y = 2 -class C extends A with +class C extends A: final val x: Int = 3 final val y = 4 -class D with +class D: inline def x: Int = 5 inline val y = 6 diff --git a/tests/run/exports.scala b/tests/run/exports.scala index ee409f95fbc1..f68312ca54e2 100644 --- a/tests/run/exports.scala +++ b/tests/run/exports.scala @@ -48,8 +48,8 @@ final class Foo { export foo._ // nothing is exported } -class A with +class A: val x: Int = 1 -class B(a: A) with +class B(a: A): export a.x object B extends B(A()) \ No newline at end of file diff --git a/tests/run/extension-override.scala b/tests/run/extension-override.scala index e77faa18b199..00246f611391 100644 --- a/tests/run/extension-override.scala +++ b/tests/run/extension-override.scala @@ -1,8 +1,8 @@ -class A with +class A: extension (s: String) def len: Int = s.length -object B extends A with +object B extends A: extension (s: String) override def len: Int = s.length + 1 diff --git a/tests/run/fragables-extension.scala b/tests/run/fragables-extension.scala index 071cc4fd78d1..417a612a3f04 100644 --- a/tests/run/fragables-extension.scala +++ b/tests/run/fragables-extension.scala @@ -3,7 +3,7 @@ trait Frag case class IntFrag(x: Int) extends Frag case class StringFrag(x: String) extends Frag -trait Fragable[T] with +trait Fragable[T]: extension (x: T) def toFrags: List[Frag] diff --git a/tests/run/given-eta.scala b/tests/run/given-eta.scala index 07b088e0188e..1eaf6fd16c49 100644 --- a/tests/run/given-eta.scala +++ b/tests/run/given-eta.scala @@ -1,6 +1,6 @@ class C(val x: Int) -trait D with +trait D: type T def trans(other: T): T diff --git a/tests/run/given-var.scala b/tests/run/given-var.scala index 13fc9c9f8755..fa4ee45e77e6 100644 --- a/tests/run/given-var.scala +++ b/tests/run/given-var.scala @@ -1,5 +1,5 @@ // Demonstrates that monomorphic givens are cached -object a with +object a: private var x = 1 given Int = x def init(x: Int) = this.x = x diff --git a/tests/run/i10082.scala b/tests/run/i10082.scala index b3b24f1d7a6f..299083da3567 100644 --- a/tests/run/i10082.scala +++ b/tests/run/i10082.scala @@ -1,4 +1,4 @@ -object Kotlin with +object Kotlin: class Ctx[T](val x: T) extends AnyVal def fun[T, U](fn: Ctx[T] ?=> U): T => U = (x: T) => fn(using Ctx(x)) diff --git a/tests/run/i10857.scala b/tests/run/i10857.scala index 9af4f88e19a6..c8b28d04651e 100644 --- a/tests/run/i10857.scala +++ b/tests/run/i10857.scala @@ -1,6 +1,6 @@ -object Module with +object Module: - enum Foo with + enum Foo: case Value case Parameterised(i: Int) diff --git a/tests/run/i10884/Test_2.scala b/tests/run/i10884/Test_2.scala index c336613bc414..72e7fafa9674 100644 --- a/tests/run/i10884/Test_2.scala +++ b/tests/run/i10884/Test_2.scala @@ -1,4 +1,4 @@ -object Exporter with +object Exporter: export JavaExporter_1._ import Exporter._ diff --git a/tests/run/i10905.scala b/tests/run/i10905.scala index af8baafc9099..2637d69cc8a2 100644 --- a/tests/run/i10905.scala +++ b/tests/run/i10905.scala @@ -1,5 +1,5 @@ class C(val x: Int) extends TypeHelpers -abstract class TypeHelpers with +abstract class TypeHelpers: self: C => def f = x @main def Test = diff --git a/tests/run/i7359.scala b/tests/run/i7359.scala index b10967e06479..c01b9d05f274 100644 --- a/tests/run/i7359.scala +++ b/tests/run/i7359.scala @@ -1,34 +1,34 @@ -trait ObjectInterface with +trait ObjectInterface: def equals(obj: Any): Boolean def hashCode(): Int def toString(): String -trait SAMPlainWithExtends extends ObjectInterface with +trait SAMPlainWithExtends extends ObjectInterface: def first(): String -trait SAMCovariantOutExtends[+O] extends ObjectInterface with +trait SAMCovariantOutExtends[+O] extends ObjectInterface: def first(): O -trait SAMContravariantInExtends[-I] extends ObjectInterface with +trait SAMContravariantInExtends[-I] extends ObjectInterface: def first(in: I): Unit -trait SAMInvariantExtends[T] extends ObjectInterface with +trait SAMInvariantExtends[T] extends ObjectInterface: def first(in: T): T -trait SAMInOutExtends[-I, +O] extends ObjectInterface with +trait SAMInOutExtends[-I, +O] extends ObjectInterface: def first(in: I): O type CustomString = String type CustomBoolean = Boolean type CustomInt = Int -trait SAMWithCustomAliases with +trait SAMWithCustomAliases: def first(): String def equals(obj: Any): CustomBoolean def hashCode(): CustomInt def toString(): CustomString -object Test with +object Test: def main(args: Array[String]): Unit = val samPlainWithExtends : SAMPlainWithExtends = () => "o" diff --git a/tests/run/i7788.scala b/tests/run/i7788.scala index 83341f80a4c2..99d16ba1521c 100644 --- a/tests/run/i7788.scala +++ b/tests/run/i7788.scala @@ -1,4 +1,4 @@ -trait Show[-A] with +trait Show[-A]: def show(a:A): String given Show[String] = x => x diff --git a/tests/run/i8396.scala b/tests/run/i8396.scala index 602f425d29c0..3e44e3898dc5 100644 --- a/tests/run/i8396.scala +++ b/tests/run/i8396.scala @@ -1,7 +1,7 @@ -trait Show[A] with +trait Show[A]: def show(a: A): String = a.toString -object Prefix with +object Prefix: type AbstractType type UpperBoundedType <: String type FullyBoundedType >: String <: String diff --git a/tests/run/i8530-b.scala b/tests/run/i8530-b.scala index ff3a8d76943e..80171bc4d178 100644 --- a/tests/run/i8530-b.scala +++ b/tests/run/i8530-b.scala @@ -1,6 +1,6 @@ import scala.compiletime.erasedValue -class MyRegex[Pattern <: String & Singleton/*Literal constant*/] with +class MyRegex[Pattern <: String & Singleton/*Literal constant*/]: inline def unapplySeq(s: CharSequence): Option[List[String]] = inline erasedValue[Pattern] match case "foo" => if s == "foo" then Some(Nil) else None diff --git a/tests/run/i8530.scala b/tests/run/i8530.scala index 66a93344e433..bbbc52587ee0 100644 --- a/tests/run/i8530.scala +++ b/tests/run/i8530.scala @@ -1,16 +1,16 @@ -object MyBoooleanUnapply with +object MyBoooleanUnapply: inline def unapply(x: Int): Boolean = true -object MyOptionUnapply with +object MyOptionUnapply: inline def unapply(x: Int): Option[Long] = Some(x) -object MyPolyUnapply with +object MyPolyUnapply: inline def unapply[T](x: T): Option[T] = Some(x) -object MySeqUnapply with +object MySeqUnapply: inline def unapplySeq(x: Int): Seq[Int] = Seq(x, x + 1) -object MyWhiteboxUnapply with +object MyWhiteboxUnapply: transparent inline def unapply(x: Int): Option[Any] = Some(x) diff --git a/tests/run/i8931.scala b/tests/run/i8931.scala index ab1ed7f54a23..555d15d0121d 100644 --- a/tests/run/i8931.scala +++ b/tests/run/i8931.scala @@ -1,4 +1,4 @@ -object test1 with +object test1: trait Trait @@ -18,7 +18,7 @@ object test1 with } } -object test2 with +object test2: trait Trait @@ -38,16 +38,16 @@ object test2 with } } -object test3 with +object test3: trait Trait - trait Managed[T] with + trait Managed[T]: def flatMap[U](f: T => Managed[U]) = - class C with + class C: def make() = - class D with + class D: def bar(): T = ??? val t: T = ??? val u = diff --git a/tests/run/i9011.scala b/tests/run/i9011.scala index 495bd924fad0..c75871a865bb 100644 --- a/tests/run/i9011.scala +++ b/tests/run/i9011.scala @@ -1,4 +1,4 @@ -enum Opt[+T] derives Eq with +enum Opt[+T] derives Eq: case Sm[T](t: T) extends Opt[T] case Nn diff --git a/tests/run/i9068.scala b/tests/run/i9068.scala index b0dedaad21de..c66dc72dbab1 100644 --- a/tests/run/i9068.scala +++ b/tests/run/i9068.scala @@ -1,4 +1,4 @@ -case class MyClass(v1: Int, v2: Int, v3: Int, v4: Int) extends Product3[Int, Int, Int] with +case class MyClass(v1: Int, v2: Int, v3: Int, v4: Int) extends Product3[Int, Int, Int]: val _1: Int = v2 def _2: Int = v3 var _3: Int = v4 diff --git a/tests/run/i9155.scala b/tests/run/i9155.scala index d5ae94b24c2d..2f5bf086c8eb 100644 --- a/tests/run/i9155.scala +++ b/tests/run/i9155.scala @@ -1,7 +1,7 @@ -object Foo with +object Foo: @scala.annotation.targetName("w") def \/\/ = "W" -object Bar with +object Bar: export Foo._ @main def Test = diff --git a/tests/run/i9530.scala b/tests/run/i9530.scala index 0db77c1cadd3..e0262764039f 100644 --- a/tests/run/i9530.scala +++ b/tests/run/i9530.scala @@ -1,4 +1,4 @@ -trait Scope with +trait Scope: type Expr type Value def expr(x: String): Expr diff --git a/tests/run/i9928.scala b/tests/run/i9928.scala index 3dc08a8553db..3a3f818b17d3 100644 --- a/tests/run/i9928.scala +++ b/tests/run/i9928.scala @@ -1,17 +1,17 @@ -trait Magic[F] with +trait Magic[F]: extension (x: Int) def read: F -trait LowPrio with +trait LowPrio: given Magic[String] with extension(x: Int) def read: String = println("In string") s"$x" -object test1 with +object test1: object Magic extends LowPrio opaque type Foo = String - object Foo extends LowPrio with + object Foo extends LowPrio: import Magic.given def apply(s: String): Foo = s @@ -23,15 +23,15 @@ object test1 with def test: Unit = (3.read: Foo) -object test2 with - object Magic extends LowPrio with +object test2: + object Magic extends LowPrio: given Magic[Foo] with extension (x: Int) def read: Foo = println("In foo") Foo(s"$x") opaque type Foo = String - object Foo extends LowPrio with + object Foo extends LowPrio: import Magic.given def apply(s: String): Foo = s diff --git a/tests/run/ift-return.scala b/tests/run/ift-return.scala index f67028b712b7..021c73173051 100644 --- a/tests/run/ift-return.scala +++ b/tests/run/ift-return.scala @@ -1,7 +1,7 @@ -trait A with +trait A: val x: Int -trait Ctx with +trait Ctx: type T val x: T val y: T diff --git a/tests/run/inline-override.scala b/tests/run/inline-override.scala index 83a6a61424e7..a128002fc4ba 100644 --- a/tests/run/inline-override.scala +++ b/tests/run/inline-override.scala @@ -1,12 +1,12 @@ import annotation.targetName -abstract class A with +abstract class A: def f(x: Int) = s"dynamic $x" def h(x: Int): String @targetName("h2") def h1(x: Int): String inline def i(x: Int): String -class B extends A with +class B extends A: inline override def f(x: Int) = g(x) inline def g(x: Int) = s"inline $x" inline def h(x: Int) = g(x) diff --git a/tests/run/instances.scala b/tests/run/instances.scala index bbb6fc22312a..128ea0700e02 100644 --- a/tests/run/instances.scala +++ b/tests/run/instances.scala @@ -40,10 +40,10 @@ object Test extends App { assert(List(names, List("!")).flattened == names :+ "!") assert(Nil.flattened == Nil) - trait SemiGroup[T] with + trait SemiGroup[T]: extension (x: T) def combine(y: T): T - trait Monoid[T] extends SemiGroup[T] with + trait Monoid[T] extends SemiGroup[T]: def unit: T given StringMonoid: Monoid[String] with @@ -56,7 +56,7 @@ object Test extends App { println(sum(names)) - trait Ord[T] with + trait Ord[T]: extension (x: T) def compareTo(y: T): Int extension (x: T) def < (y: T) = x.compareTo(y) < 0 extension (x: T) def > (y: T) = x.compareTo(y) > 0 @@ -88,11 +88,11 @@ object Test extends App { println(max(List(1, 2, 3), List(2))) - trait Functor[F[_]] with + trait Functor[F[_]]: extension [A](x: F[A]) def map[B](f: A => B): F[B] end Functor - trait Monad[F[_]] extends Functor[F] with + trait Monad[F[_]] extends Functor[F]: extension [A](x: F[A]) def flatMap[B](f: A => F[B]): F[B] extension [A](x: F[A]) def map[B](f: A => B) = x.flatMap(f `andThen` pure) diff --git a/tests/run/lazy-impl.scala b/tests/run/lazy-impl.scala index ca7ed5852c2b..a941dc89100a 100644 --- a/tests/run/lazy-impl.scala +++ b/tests/run/lazy-impl.scala @@ -46,7 +46,7 @@ * The code makes use of the following runtime class: - class Waiting with + class Waiting: private var done = false def release(): Unit = synchronized: done = true diff --git a/tests/run/option-extract.scala b/tests/run/option-extract.scala index 588ab1c445d0..7b87ad28bc68 100644 --- a/tests/run/option-extract.scala +++ b/tests/run/option-extract.scala @@ -1,5 +1,5 @@ -enum Option[+A] with +enum Option[+A]: case Some(x: A) case None diff --git a/tests/run/outer-accessors.scala b/tests/run/outer-accessors.scala index b8378a8337cd..47d7a5b1849d 100644 --- a/tests/run/outer-accessors.scala +++ b/tests/run/outer-accessors.scala @@ -1,15 +1,15 @@ -class A with +class A: val a = 2 - class B with + class B: val b = 3 - trait T with + trait T: def t = a + b val bb = B() - class C extends bb.T with + class C extends bb.T: def result = a + t @main def Test = diff --git a/tests/run/quoted-sematics-1.scala b/tests/run/quoted-sematics-1.scala index 6f77a0ec2903..ed2d05224d73 100644 --- a/tests/run/quoted-sematics-1.scala +++ b/tests/run/quoted-sematics-1.scala @@ -25,7 +25,7 @@ object Name { } -enum Term with +enum Term: case Nat(n: Int) case Ref(name: Name) case Lambda(name: Name, tpe: Type, body: Term) @@ -37,7 +37,7 @@ enum Term with case Fix(term: Term) -enum Pattern with +enum Pattern: case PNat(n: Int) case PRef(name: Name) case PApp(fun: Pattern, arg: Pattern) @@ -46,7 +46,7 @@ enum Pattern with case PFun(name: Name) -enum Type with +enum Type: case NatType case LambdaType(arg: Type, res: Type) case BoxType(inner: Type) diff --git a/tests/run/selectable-new.scala b/tests/run/selectable-new.scala index d8cf18d228ca..e460ca631b56 100644 --- a/tests/run/selectable-new.scala +++ b/tests/run/selectable-new.scala @@ -1,10 +1,10 @@ @main def Test = val x = - class C extends reflect.Selectable with + class C extends reflect.Selectable: def name: String = "hello" new C - val y = new reflect.Selectable with + val y = new reflect.Selectable: def name: String = "hello" assert(x.name == "hello") diff --git a/tests/run/singleton-ops-flags.scala b/tests/run/singleton-ops-flags.scala index 2f316ab56a92..8e2cda6a38c7 100644 --- a/tests/run/singleton-ops-flags.scala +++ b/tests/run/singleton-ops-flags.scala @@ -3,7 +3,7 @@ package example { import compiletime.S import compiletime.ops.int.<< - object TastyFlags with + object TastyFlags: final val EmptyFlags = baseFlags final val Erased = EmptyFlags.next @@ -40,7 +40,7 @@ package example { case Open => "Open" }) mkString(" | ") - object opaques with + object opaques: opaque type FlagSet = Int opaque type EmptyFlagSet <: FlagSet = 0 diff --git a/tests/run/structural-contextual.scala b/tests/run/structural-contextual.scala index b12f6fee348b..e1d0890b73cd 100644 --- a/tests/run/structural-contextual.scala +++ b/tests/run/structural-contextual.scala @@ -1,7 +1,7 @@ -trait Resolver with +trait Resolver: def resolve(label: String): Any -class ResolvingSelectable extends Selectable with +class ResolvingSelectable extends Selectable: def selectDynamic(label: String)(using r: Resolver): Any = r.resolve(label) def applyDynamic(label: String)(args: Any*)(using r: Resolver): Any = diff --git a/tests/run/targetName.scala b/tests/run/targetName.scala index 721c614c37a9..7774922c7b12 100644 --- a/tests/run/targetName.scala +++ b/tests/run/targetName.scala @@ -1,23 +1,23 @@ import annotation.targetName -object A with +object A: def f(x: => String): Int = x.length @targetName("f2") def f(x: => Int): Int = x import A._ -trait T with +trait T: def f(x: => String): Int @targetName("f2") def f(x: => Int): Int -class C with +class C: def f(x: => String): Int = x.length @targetName("f2") def f(x: => Int): Int = x -object B1 extends C, T with +object B1 extends C, T: @targetName("f2") override def f(x: => Int): Int = x + 1 -object B2 extends C, T with +object B2 extends C, T: override def f(x: => String): Int = x.length + 1 @targetName("fooString") def foo(ps: String*) : Unit = println(s"strings: $ps") diff --git a/tests/run/typable.scala b/tests/run/typable.scala index b47cde8eb3e8..7fe253023740 100644 --- a/tests/run/typable.scala +++ b/tests/run/typable.scala @@ -1,6 +1,6 @@ import scala.reflect._ -object Test with +object Test: def main(args: Array[String]): Unit = assert(f[String]) assert(!f[Int]) diff --git a/tests/run/unambiref.scala b/tests/run/unambiref.scala index d8c74d6ed919..1dc617aefa4c 100644 --- a/tests/run/unambiref.scala +++ b/tests/run/unambiref.scala @@ -1,5 +1,5 @@ -class A(val x: Int) with - class B extends A(2) with +class A(val x: Int): + class B extends A(2): println(x) @main def Test = diff --git a/tests/semanticdb/expect/Enums.expect.scala b/tests/semanticdb/expect/Enums.expect.scala index 0a9888c07457..d74e49ccf98d 100644 --- a/tests/semanticdb/expect/Enums.expect.scala +++ b/tests/semanticdb/expect/Enums.expect.scala @@ -1,17 +1,17 @@ -object Enums/*<-_empty_::Enums.*/ with +object Enums/*<-_empty_::Enums.*/: import <:_empty_::Enums.`<:<`.*/._ - enum Colour/*<-_empty_::Enums.Colour#*/ with + enum Colour/*<-_empty_::Enums.Colour#*/: import Colour/*->_empty_::Enums.Colour.*/.Red/*->_empty_::Enums.Colour.Red.*/ case Red/*<-_empty_::Enums.Colour.Red.*/, Green/*<-_empty_::Enums.Colour.Green.*/, Blue/*<-_empty_::Enums.Colour.Blue.*/ - enum Directions/*<-_empty_::Enums.Directions#*/ with + enum Directions/*<-_empty_::Enums.Directions#*/: case North/*<-_empty_::Enums.Directions.North.*/, East/*<-_empty_::Enums.Directions.East.*/, South/*<-_empty_::Enums.Directions.South.*/, West/*<-_empty_::Enums.Directions.West.*/ - enum Suits/*<-_empty_::Enums.Suits#*/ derives /*->scala::CanEqual.derived.*/CanEqual with + enum Suits/*<-_empty_::Enums.Suits#*/ derives /*->scala::CanEqual.derived.*/CanEqual: case Hearts/*<-_empty_::Enums.Suits.Hearts.*/, Spades/*<-_empty_::Enums.Suits.Spades.*/, Clubs/*<-_empty_::Enums.Suits.Clubs.*/, Diamonds/*<-_empty_::Enums.Suits.Diamonds.*/ - object Suits/*<-_empty_::Enums.Suits.*/ with + object Suits/*<-_empty_::Enums.Suits.*/: extension (suit/*<-_empty_::Enums.Suits.isRed().(suit)*/: Suits/*->_empty_::Enums.Suits#*/) def isRed/*<-_empty_::Enums.Suits.isRed().*/: Boolean/*->scala::Boolean#*/ = suit/*->_empty_::Enums.Suits.isRed().(suit)*/ ==/*->scala::Any#`==`().*/ Hearts/*->_empty_::Enums.Suits.Hearts.*/ ||/*->scala::Boolean#`||`().*/ suit/*->_empty_::Enums.Suits.isRed().(suit)*/ ==/*->scala::Any#`==`().*/ Diamonds/*->_empty_::Enums.Suits.Diamonds.*/ @@ -19,7 +19,7 @@ object Enums/*<-_empty_::Enums.*/ with case Spades/*->_empty_::Enums.Suits.Spades.*/ | Clubs/*->_empty_::Enums.Suits.Clubs.*/ => true case _ => false - enum WeekDays/*<-_empty_::Enums.WeekDays#*/ with + enum WeekDays/*<-_empty_::Enums.WeekDays#*/: case Monday/*<-_empty_::Enums.WeekDays.Monday.*/ case Tuesday/*<-_empty_::Enums.WeekDays.Tuesday.*/ case Wednesday/*<-_empty_::Enums.WeekDays.Wednesday.*/ @@ -28,25 +28,25 @@ object Enums/*<-_empty_::Enums.*/ with case Saturday/*<-_empty_::Enums.WeekDays.Saturday.*/ case Sunday/*<-_empty_::Enums.WeekDays.Sunday.*/ - enum Coin/*<-_empty_::Enums.Coin#*/(value/*<-_empty_::Enums.Coin#value.*/: Int/*->scala::Int#*/) with + enum Coin/*<-_empty_::Enums.Coin#*/(value/*<-_empty_::Enums.Coin#value.*/: Int/*->scala::Int#*/): case Penny/*<-_empty_::Enums.Coin.Penny.*/ extends Coin/*->_empty_::Enums.Coin#*/(1)/*->scala::runtime::EnumValue#*/ case Nickel/*<-_empty_::Enums.Coin.Nickel.*/ extends Coin/*->_empty_::Enums.Coin#*/(5)/*->scala::runtime::EnumValue#*/ case Dime/*<-_empty_::Enums.Coin.Dime.*/ extends Coin/*->_empty_::Enums.Coin#*/(10)/*->scala::runtime::EnumValue#*/ case Quarter/*<-_empty_::Enums.Coin.Quarter.*/ extends Coin/*->_empty_::Enums.Coin#*/(25)/*->scala::runtime::EnumValue#*/ case Dollar/*<-_empty_::Enums.Coin.Dollar.*/ extends Coin/*->_empty_::Enums.Coin#*/(100)/*->scala::runtime::EnumValue#*/ - enum Maybe/*<-_empty_::Enums.Maybe#*/[+A/*<-_empty_::Enums.Maybe#[A]*/] with + enum Maybe/*<-_empty_::Enums.Maybe#*/[+A/*<-_empty_::Enums.Maybe#[A]*/]: case Just/*<-_empty_::Enums.Maybe.Just#*/(value/*<-_empty_::Enums.Maybe.Just#value.*/: A/*->_empty_::Enums.Maybe.Just#[A]*/) case None/*<-_empty_::Enums.Maybe.None.*//*->scala::runtime::EnumValue#*/ - enum Tag/*<-_empty_::Enums.Tag#*/[A/*<-_empty_::Enums.Tag#[A]*/] with + enum Tag/*<-_empty_::Enums.Tag#*/[A/*<-_empty_::Enums.Tag#[A]*/]: case IntTag/*<-_empty_::Enums.Tag.IntTag.*/ extends Tag/*->_empty_::Enums.Tag#*/[Int/*->scala::Int#*/]/*->scala::runtime::EnumValue#*/ case BooleanTag/*<-_empty_::Enums.Tag.BooleanTag.*/ extends Tag/*->_empty_::Enums.Tag#*/[Boolean/*->scala::Boolean#*/]/*->scala::runtime::EnumValue#*/ - enum <:_empty_::Enums.`<:<`.Refl#[C]*/ <:_empty_::Enums.`<:<`#*/ C/*->_empty_::Enums.`<:<`.Refl#[C]*/) - object <:_empty_::Enums.`<:<`.given_T().[T]*/ <:_empty_::Enums.`<:<`#*/ T/*->_empty_::Enums.`<:<`.given_T().[T]*/) = Refl/*->_empty_::Enums.`<:<`.Refl.*//*->_empty_::Enums.`<:<`.Refl.apply().*/() extension [A/*<-_empty_::Enums.unwrap().[A]*/, B/*<-_empty_::Enums.unwrap().[B]*/](opt/*<-_empty_::Enums.unwrap().(opt)*/: Option/*->scala::Option#*/[A/*->_empty_::Enums.unwrap().[A]*/]) def unwrap/*<-_empty_::Enums.unwrap().*/(using ev/*<-_empty_::Enums.unwrap().(ev)*/: A/*->_empty_::Enums.unwrap().[A]*/ <:_empty_::Enums.`<:<`#*/ Option/*->scala::Option#*/[B/*->_empty_::Enums.unwrap().[B]*/]): Option/*->scala::Option#*/[B/*->_empty_::Enums.unwrap().[B]*/] = ev/*->_empty_::Enums.unwrap().(ev)*/ match @@ -54,7 +54,7 @@ object Enums/*<-_empty_::Enums.*/ with val some1/*<-_empty_::Enums.some1.*/ = /*->_empty_::Enums.unwrap().*/Some/*->scala::Some.*//*->scala::Some.apply().*/(Some/*->scala::Some.*//*->scala::Some.apply().*/(1)).unwrap/*->_empty_::Enums.`<:<`.given_T().*/ - enum Planet/*<-_empty_::Enums.Planet#*/(mass/*<-_empty_::Enums.Planet#mass.*/: Double/*->scala::Double#*/, radius/*<-_empty_::Enums.Planet#radius.*/: Double/*->scala::Double#*/) extends Enum/*->java::lang::Enum#*/[Planet/*->_empty_::Enums.Planet#*/]/*->java::lang::Enum#``().*/ with + enum Planet/*<-_empty_::Enums.Planet#*/(mass/*<-_empty_::Enums.Planet#mass.*/: Double/*->scala::Double#*/, radius/*<-_empty_::Enums.Planet#radius.*/: Double/*->scala::Double#*/) extends Enum/*->java::lang::Enum#*/[Planet/*->_empty_::Enums.Planet#*/]/*->java::lang::Enum#``().*/: private final val G/*<-_empty_::Enums.Planet#G.*/ = 6.67300E-11 def surfaceGravity/*<-_empty_::Enums.Planet#surfaceGravity().*/ = G/*->_empty_::Enums.Planet#G.*/ */*->scala::Double#`*`(+6).*/ mass/*->_empty_::Enums.Planet#mass.*/ //*->scala::Double#`::`(+6).*/ (radius/*->_empty_::Enums.Planet#radius.*/ */*->scala::Double#`*`(+6).*/ radius/*->_empty_::Enums.Planet#radius.*/) def surfaceWeight/*<-_empty_::Enums.Planet#surfaceWeight().*/(otherMass/*<-_empty_::Enums.Planet#surfaceWeight().(otherMass)*/: Double/*->scala::Double#*/) = otherMass/*->_empty_::Enums.Planet#surfaceWeight().(otherMass)*/ */*->scala::Double#`*`(+6).*/ surfaceGravity/*->_empty_::Enums.Planet#surfaceGravity().*/ diff --git a/tests/semanticdb/expect/Enums.scala b/tests/semanticdb/expect/Enums.scala index 353b9206f905..3d666fb618a9 100644 --- a/tests/semanticdb/expect/Enums.scala +++ b/tests/semanticdb/expect/Enums.scala @@ -1,17 +1,17 @@ -object Enums with +object Enums: import <:<._ - enum Colour with + enum Colour: import Colour.Red case Red, Green, Blue - enum Directions with + enum Directions: case North, East, South, West - enum Suits derives CanEqual with + enum Suits derives CanEqual: case Hearts, Spades, Clubs, Diamonds - object Suits with + object Suits: extension (suit: Suits) def isRed: Boolean = suit == Hearts || suit == Diamonds @@ -19,7 +19,7 @@ object Enums with case Spades | Clubs => true case _ => false - enum WeekDays with + enum WeekDays: case Monday case Tuesday case Wednesday @@ -28,25 +28,25 @@ object Enums with case Saturday case Sunday - enum Coin(value: Int) with + enum Coin(value: Int): case Penny extends Coin(1) case Nickel extends Coin(5) case Dime extends Coin(10) case Quarter extends Coin(25) case Dollar extends Coin(100) - enum Maybe[+A] with + enum Maybe[+A]: case Just(value: A) case None - enum Tag[A] with + enum Tag[A]: case IntTag extends Tag[Int] case BooleanTag extends Tag[Boolean] - enum <:<[-A, B] with + enum <:<[-A, B]: case Refl[C]() extends (C <:< C) - object <:< with + object <:< : given [T]: (T <:< T) = Refl() extension [A, B](opt: Option[A]) def unwrap(using ev: A <:< Option[B]): Option[B] = ev match @@ -54,7 +54,7 @@ object Enums with val some1 = Some(Some(1)).unwrap - enum Planet(mass: Double, radius: Double) extends Enum[Planet] with + enum Planet(mass: Double, radius: Double) extends Enum[Planet]: private final val G = 6.67300E-11 def surfaceGravity = G * mass / (radius * radius) def surfaceWeight(otherMass: Double) = otherMass * surfaceGravity diff --git a/tests/semanticdb/expect/Givens.expect.scala b/tests/semanticdb/expect/Givens.expect.scala index 4089ad837ed3..126c1f8e9919 100644 --- a/tests/semanticdb/expect/Givens.expect.scala +++ b/tests/semanticdb/expect/Givens.expect.scala @@ -1,7 +1,7 @@ package a package b -object Givens/*<-a::b::Givens.*/ with +object Givens/*<-a::b::Givens.*/: extension [A/*<-a::b::Givens.sayHello().[A]*/](any/*<-a::b::Givens.sayHello().(any)*/: A/*->a::b::Givens.sayHello().[A]*/) def sayHello/*<-a::b::Givens.sayHello().*/ = s"/*->scala::StringContext.apply().*/Hello, I am $any/*->a::b::Givens.sayHello().(any)*/"/*->scala::StringContext#s().*/ @@ -14,7 +14,7 @@ object Givens/*<-a::b::Givens.*/ with val goodbye1/*<-a::b::Givens.goodbye1.*/ = /*->a::b::Givens.sayGoodbye().*/1.sayGoodbye val soLong1/*<-a::b::Givens.soLong1.*/ = /*->a::b::Givens.saySoLong().*/1.saySoLong - trait Monoid/*<-a::b::Givens.Monoid#*/[A/*<-a::b::Givens.Monoid#[A]*/] with + trait Monoid/*<-a::b::Givens.Monoid#*/[A/*<-a::b::Givens.Monoid#[A]*/]: def empty/*<-a::b::Givens.Monoid#empty().*/: A/*->a::b::Givens.Monoid#[A]*/ extension (x/*<-a::b::Givens.Monoid#combine().(x)*/: A/*->a::b::Givens.Monoid#[A]*/) def combine/*<-a::b::Givens.Monoid#combine().*/(y/*<-a::b::Givens.Monoid#combine().(y)*/: A/*->a::b::Givens.Monoid#[A]*/): A/*->a::b::Givens.Monoid#[A]*/ diff --git a/tests/semanticdb/expect/Givens.scala b/tests/semanticdb/expect/Givens.scala index 5f22df9416b6..819d70cfadca 100644 --- a/tests/semanticdb/expect/Givens.scala +++ b/tests/semanticdb/expect/Givens.scala @@ -1,7 +1,7 @@ package a package b -object Givens with +object Givens: extension [A](any: A) def sayHello = s"Hello, I am $any" @@ -14,7 +14,7 @@ object Givens with val goodbye1 = 1.sayGoodbye val soLong1 = 1.saySoLong - trait Monoid[A] with + trait Monoid[A]: def empty: A extension (x: A) def combine(y: A): A diff --git a/tests/semanticdb/expect/inlineconsume.expect.scala b/tests/semanticdb/expect/inlineconsume.expect.scala index 7126236c1205..8ffe432064d4 100644 --- a/tests/semanticdb/expect/inlineconsume.expect.scala +++ b/tests/semanticdb/expect/inlineconsume.expect.scala @@ -2,5 +2,5 @@ package inlineconsume import inlinedefs.FakePredef/*->inlinedefs::FakePredef.*/.assert/*->inlinedefs::FakePredef.assert().*/ -class Foo/*<-inlineconsume::Foo#*/ with +class Foo/*<-inlineconsume::Foo#*/: def test/*<-inlineconsume::Foo#test().*/ = assert/*->inlinedefs::FakePredef.assert().*/(3 >/*->scala::Int#`>`(+3).*/ 2) diff --git a/tests/semanticdb/expect/inlineconsume.scala b/tests/semanticdb/expect/inlineconsume.scala index 3c15686f66a9..db7130c50515 100644 --- a/tests/semanticdb/expect/inlineconsume.scala +++ b/tests/semanticdb/expect/inlineconsume.scala @@ -2,5 +2,5 @@ package inlineconsume import inlinedefs.FakePredef.assert -class Foo with +class Foo: def test = assert(3 > 2) diff --git a/tests/semanticdb/expect/inlinedefs.expect.scala b/tests/semanticdb/expect/inlinedefs.expect.scala index 9e3da263e558..c0e1a8913c0a 100644 --- a/tests/semanticdb/expect/inlinedefs.expect.scala +++ b/tests/semanticdb/expect/inlinedefs.expect.scala @@ -1,6 +1,6 @@ package inlinedefs -object FakePredef/*<-inlinedefs::FakePredef.*/ with +object FakePredef/*<-inlinedefs::FakePredef.*/: /** Super long padded documentation * Lorem ipsum dolor sit amet, consectetur adipiscing elit, diff --git a/tests/semanticdb/expect/inlinedefs.scala b/tests/semanticdb/expect/inlinedefs.scala index 0598d2dee4d0..7902a9750b4b 100644 --- a/tests/semanticdb/expect/inlinedefs.scala +++ b/tests/semanticdb/expect/inlinedefs.scala @@ -1,6 +1,6 @@ package inlinedefs -object FakePredef with +object FakePredef: /** Super long padded documentation * Lorem ipsum dolor sit amet, consectetur adipiscing elit, diff --git a/tests/sjs-junit/test/org/scalajs/testsuite/compiler/EnumTestScala3.scala b/tests/sjs-junit/test/org/scalajs/testsuite/compiler/EnumTestScala3.scala index 93b135de6576..01bdb6ccc954 100644 --- a/tests/sjs-junit/test/org/scalajs/testsuite/compiler/EnumTestScala3.scala +++ b/tests/sjs-junit/test/org/scalajs/testsuite/compiler/EnumTestScala3.scala @@ -3,7 +3,7 @@ package org.scalajs.testsuite.compiler import org.junit.Assert._ import org.junit.Test -class EnumTestScala3 with +class EnumTestScala3: import EnumTestScala3._ @Test def testColor1(): Unit = @@ -141,26 +141,26 @@ class EnumTestScala3 with end testOpt -object EnumTestScala3 with +object EnumTestScala3: - enum Color1 derives CanEqual with + enum Color1 derives CanEqual: case Red, Green, Blue - enum Color2 extends java.lang.Enum[Color2] derives CanEqual with + enum Color2 extends java.lang.Enum[Color2] derives CanEqual: case Red, Green, Blue // test "non-simple" cases with anonymous subclasses - enum Currency1(val dollarValue: Double) derives CanEqual with + enum Currency1(val dollarValue: Double) derives CanEqual: case Dollar extends Currency1(1.0) case SwissFanc extends Currency1(1.09) case Euro extends Currency1(1.18) - enum Currency2(val dollarValue: Double) extends java.lang.Enum[Currency2] derives CanEqual with + enum Currency2(val dollarValue: Double) extends java.lang.Enum[Currency2] derives CanEqual: case Dollar extends Currency2(1.0) case SwissFanc extends Currency2(1.09) case Euro extends Currency2(1.18) - enum Opt[+T] with + enum Opt[+T]: case Sm[+T1](value: T1) extends Opt[T1] case Nn extends Opt[Nothing]