From c2c55822441a05d2c33d1f3bbbf9d86c48e0ddc2 Mon Sep 17 00:00:00 2001 From: Albert Meltzer <7529386+kitbellew@users.noreply.github.com> Date: Thu, 26 Sep 2024 20:08:17 -0700 Subject: [PATCH 1/2] Test very long one-liner with chain of infixes --- .../resources/newlines/source_classic.stat | 289 ++++++++++++++++++ .../test/resources/newlines/source_fold.stat | 266 ++++++++++++++++ .../test/resources/newlines/source_keep.stat | 38 +++ .../resources/newlines/source_unfold.stat | 268 ++++++++++++++++ 4 files changed, 861 insertions(+) diff --git a/scalafmt-tests/shared/src/test/resources/newlines/source_classic.stat b/scalafmt-tests/shared/src/test/resources/newlines/source_classic.stat index fdc041463b..07a6bbb51b 100644 --- a/scalafmt-tests/shared/src/test/resources/newlines/source_classic.stat +++ b/scalafmt-tests/shared/src/test/resources/newlines/source_classic.stat @@ -9343,3 +9343,292 @@ trait Infer { } } } +<<< #4133 very long one-liner with chain of infixes, full method +class UDFRegistration private[sql] (functionRegistry: FunctionRegistry) extends Logging { + def register[RT: TypeTag, A1: TypeTag, A2: TypeTag, A3: TypeTag, A4: TypeTag, A5: TypeTag, A6: TypeTag, A7: TypeTag, A8: TypeTag, A9: TypeTag, A10: TypeTag, A11: TypeTag, A12: TypeTag, A13: TypeTag, A14: TypeTag, A15: TypeTag, A16: TypeTag, A17: TypeTag, A18: TypeTag, A19: TypeTag, A20: TypeTag, A21: TypeTag, A22: TypeTag](name: String, func: Function22[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22, RT]): UserDefinedFunction = { + val inputEncoders: Seq[Option[ExpressionEncoder[_]]] = Try(ExpressionEncoder[A1]()).toOption :: Try(ExpressionEncoder[A2]()).toOption :: Try(ExpressionEncoder[A3]()).toOption :: Try(ExpressionEncoder[A4]()).toOption :: Try(ExpressionEncoder[A5]()).toOption :: Try(ExpressionEncoder[A6]()).toOption :: Try(ExpressionEncoder[A7]()).toOption :: Try(ExpressionEncoder[A8]()).toOption :: Try(ExpressionEncoder[A9]()).toOption :: Try(ExpressionEncoder[A10]()).toOption :: Try(ExpressionEncoder[A11]()).toOption :: Try(ExpressionEncoder[A12]()).toOption :: Try(ExpressionEncoder[A13]()).toOption :: Try(ExpressionEncoder[A14]()).toOption :: Try(ExpressionEncoder[A15]()).toOption :: Try(ExpressionEncoder[A16]()).toOption :: Try(ExpressionEncoder[A17]()).toOption :: Try(ExpressionEncoder[A18]()).toOption :: Try(ExpressionEncoder[A19]()).toOption :: Try(ExpressionEncoder[A20]()).toOption :: Try(ExpressionEncoder[A21]()).toOption :: Try(ExpressionEncoder[A22]()).toOption :: Nil + } +} +>>> +class UDFRegistration private[sql] ( + functionRegistry: FunctionRegistry +) extends Logging { + def register[ + RT: TypeTag, + A1: TypeTag, + A2: TypeTag, + A3: TypeTag, + A4: TypeTag, + A5: TypeTag, + A6: TypeTag, + A7: TypeTag, + A8: TypeTag, + A9: TypeTag, + A10: TypeTag, + A11: TypeTag, + A12: TypeTag, + A13: TypeTag, + A14: TypeTag, + A15: TypeTag, + A16: TypeTag, + A17: TypeTag, + A18: TypeTag, + A19: TypeTag, + A20: TypeTag, + A21: TypeTag, + A22: TypeTag + ]( + name: String, + func: Function22[ + A1, + A2, + A3, + A4, + A5, + A6, + A7, + A8, + A9, + A10, + A11, + A12, + A13, + A14, + A15, + A16, + A17, + A18, + A19, + A20, + A21, + A22, + RT + ] + ): UserDefinedFunction = { + val inputEncoders: Seq[ + Option[ExpressionEncoder[_]] + ] = Try( + ExpressionEncoder[A1]() + ).toOption :: Try( + ExpressionEncoder[A2]() + ).toOption :: Try( + ExpressionEncoder[A3]() + ).toOption :: Try( + ExpressionEncoder[A4]() + ).toOption :: Try( + ExpressionEncoder[A5]() + ).toOption :: Try( + ExpressionEncoder[A6]() + ).toOption :: Try( + ExpressionEncoder[A7]() + ).toOption :: Try( + ExpressionEncoder[A8]() + ).toOption :: Try( + ExpressionEncoder[A9]() + ).toOption :: Try( + ExpressionEncoder[A10]() + ).toOption :: Try( + ExpressionEncoder[A11]() + ).toOption :: Try( + ExpressionEncoder[A12]() + ).toOption :: Try( + ExpressionEncoder[A13]() + ).toOption :: Try( + ExpressionEncoder[A14]() + ).toOption :: Try( + ExpressionEncoder[A15]() + ).toOption :: Try( + ExpressionEncoder[A16]() + ).toOption :: Try( + ExpressionEncoder[A17]() + ).toOption :: Try( + ExpressionEncoder[A18]() + ).toOption :: Try( + ExpressionEncoder[A19]() + ).toOption :: Try( + ExpressionEncoder[A20]() + ).toOption :: Try( + ExpressionEncoder[A21]() + ).toOption :: Try( + ExpressionEncoder[A22]() + ).toOption :: Nil + } +} +<<< #4133 very long one-liner with chain of infixes +runner.maxStateVisits = 1000 +=== +class UDFRegistration { + def foo = { + val inputEncoders: Seq_Option_ExpressionEncoder_____ = Try(ExpressionEncoder_A1_) :: Try(ExpressionEncoder_A2_) :: Try(ExpressionEncoder_A3_) :: Try(ExpressionEncoder_A4_) :: Try(ExpressionEncoder_A5_) :: Try(ExpressionEncoder_A6_) :: Try(ExpressionEncoder_A7_) :: Try(ExpressionEncoder_A8_) :: Try(ExpressionEncoder_A9_) :: Try(ExpressionEncoder_A10_) :: Try(ExpressionEncoder_A11_) :: Try(ExpressionEncoder_A12_) :: Try(ExpressionEncoder_A13_) :: Try(ExpressionEncoder_A14_) :: Try(ExpressionEncoder_A15_) :: Try(ExpressionEncoder_A16_) :: Try(ExpressionEncoder_A17_) :: Try(ExpressionEncoder_A18_) :: Try(ExpressionEncoder_A19_) :: Try(ExpressionEncoder_A20_) :: Try(ExpressionEncoder_A21_) :: Try(ExpressionEncoder_A22_) :: Nil + } +} +>>> +class UDFRegistration { + def foo = { + val inputEncoders + : Seq_Option_ExpressionEncoder_____ = + Try(ExpressionEncoder_A1_) :: Try( + ExpressionEncoder_A2_ + ) :: Try( + ExpressionEncoder_A3_ + ) :: Try( + ExpressionEncoder_A4_ + ) :: Try( + ExpressionEncoder_A5_ + ) :: Try( + ExpressionEncoder_A6_ + ) :: Try( + ExpressionEncoder_A7_ + ) :: Try( + ExpressionEncoder_A8_ + ) :: Try( + ExpressionEncoder_A9_ + ) :: Try( + ExpressionEncoder_A10_ + ) :: Try( + ExpressionEncoder_A11_ + ) :: Try( + ExpressionEncoder_A12_ + ) :: Try( + ExpressionEncoder_A13_ + ) :: Try( + ExpressionEncoder_A14_ + ) :: Try( + ExpressionEncoder_A15_ + ) :: Try( + ExpressionEncoder_A16_ + ) :: Try( + ExpressionEncoder_A17_ + ) :: Try( + ExpressionEncoder_A18_ + ) :: Try( + ExpressionEncoder_A19_ + ) :: Try( + ExpressionEncoder_A20_ + ) :: Try( + ExpressionEncoder_A21_ + ) :: Try( + ExpressionEncoder_A22_ + ) :: Nil + } +} +<<< #4133 very long one-liner with chain of infixes, with selects +runner.maxStateVisits = 5000 +=== +class UDFRegistration { + def foo = { + val inputEncoders: Seq_Option_ExpressionEncoder_____ = Try(ExpressionEncoder_A1_).toOption :: Try(ExpressionEncoder_A2_).toOption :: Try(ExpressionEncoder_A3_).toOption :: Try(ExpressionEncoder_A4_).toOption :: Try(ExpressionEncoder_A5_).toOption :: Try(ExpressionEncoder_A6_).toOption :: Try(ExpressionEncoder_A7_).toOption :: Try(ExpressionEncoder_A8_).toOption :: Try(ExpressionEncoder_A9_).toOption :: Try(ExpressionEncoder_A10_).toOption :: Try(ExpressionEncoder_A11_).toOption :: Try(ExpressionEncoder_A12_).toOption :: Try(ExpressionEncoder_A13_).toOption :: Try(ExpressionEncoder_A14_).toOption :: Try(ExpressionEncoder_A15_).toOption :: Try(ExpressionEncoder_A16_).toOption :: Try(ExpressionEncoder_A17_).toOption :: Try(ExpressionEncoder_A18_).toOption :: Try(ExpressionEncoder_A19_).toOption :: Try(ExpressionEncoder_A20_).toOption :: Try(ExpressionEncoder_A21_).toOption :: Try(ExpressionEncoder_A22_).toOption :: Nil + } +} +>>> +class UDFRegistration { + def foo = { + val inputEncoders + : Seq_Option_ExpressionEncoder_____ = + Try( + ExpressionEncoder_A1_ + ).toOption :: Try( + ExpressionEncoder_A2_ + ).toOption :: Try( + ExpressionEncoder_A3_ + ).toOption :: Try( + ExpressionEncoder_A4_ + ).toOption :: Try( + ExpressionEncoder_A5_ + ).toOption :: Try( + ExpressionEncoder_A6_ + ).toOption :: Try( + ExpressionEncoder_A7_ + ).toOption :: Try( + ExpressionEncoder_A8_ + ).toOption :: Try( + ExpressionEncoder_A9_ + ).toOption :: Try( + ExpressionEncoder_A10_ + ).toOption :: Try( + ExpressionEncoder_A11_ + ).toOption :: Try( + ExpressionEncoder_A12_ + ).toOption :: Try( + ExpressionEncoder_A13_ + ).toOption :: Try( + ExpressionEncoder_A14_ + ).toOption :: Try( + ExpressionEncoder_A15_ + ).toOption :: Try( + ExpressionEncoder_A16_ + ).toOption :: Try( + ExpressionEncoder_A17_ + ).toOption :: Try( + ExpressionEncoder_A18_ + ).toOption :: Try( + ExpressionEncoder_A19_ + ).toOption :: Try( + ExpressionEncoder_A20_ + ).toOption :: Try( + ExpressionEncoder_A21_ + ).toOption :: Try( + ExpressionEncoder_A22_ + ).toOption :: Nil + } +} +<<< #4133 very long one-liner with chain of infixes, with select and types +runner.maxStateVisits = 100000 +=== +class UDFRegistration { + def foo = { + val inputEncoders: Seq[Option[ExpressionEncoder[_]]] = Try(ExpressionEncoder[A1]).toOption :: Try(ExpressionEncoder[A2]).toOption :: Try(ExpressionEncoder[A3]).toOption :: Try(ExpressionEncoder[A4]).toOption :: Try(ExpressionEncoder[A5]).toOption :: Try(ExpressionEncoder[A6]).toOption :: Try(ExpressionEncoder[A7]).toOption :: Try(ExpressionEncoder[A8]).toOption :: Try(ExpressionEncoder[A9]).toOption :: Try(ExpressionEncoder[A10]).toOption :: Try(ExpressionEncoder[A11]).toOption :: Try(ExpressionEncoder[A12]).toOption :: Try(ExpressionEncoder[A13]).toOption :: Try(ExpressionEncoder[A14]).toOption :: Try(ExpressionEncoder[A15]).toOption :: Try(ExpressionEncoder[A16]).toOption :: Try(ExpressionEncoder[A17]).toOption :: Try(ExpressionEncoder[A18]).toOption :: Try(ExpressionEncoder[A19]).toOption :: Try(ExpressionEncoder[A20]).toOption :: Try(ExpressionEncoder[A21]).toOption :: Try(ExpressionEncoder[A22]).toOption :: Nil + } +} +>>> +class UDFRegistration { + def foo = { + val inputEncoders: Seq[ + Option[ExpressionEncoder[_]] + ] = Try( + ExpressionEncoder[A1] + ).toOption :: Try( + ExpressionEncoder[A2] + ).toOption :: Try( + ExpressionEncoder[A3] + ).toOption :: Try( + ExpressionEncoder[A4] + ).toOption :: Try( + ExpressionEncoder[A5] + ).toOption :: Try( + ExpressionEncoder[A6] + ).toOption :: Try( + ExpressionEncoder[A7] + ).toOption :: Try( + ExpressionEncoder[A8] + ).toOption :: Try( + ExpressionEncoder[A9] + ).toOption :: Try( + ExpressionEncoder[A10] + ).toOption :: Try( + ExpressionEncoder[A11] + ).toOption :: Try( + ExpressionEncoder[A12] + ).toOption :: Try( + ExpressionEncoder[A13] + ).toOption :: Try( + ExpressionEncoder[A14] + ).toOption :: Try( + ExpressionEncoder[A15] + ).toOption :: Try( + ExpressionEncoder[A16] + ).toOption :: Try( + ExpressionEncoder[A17] + ).toOption :: Try( + ExpressionEncoder[A18] + ).toOption :: Try( + ExpressionEncoder[A19] + ).toOption :: Try( + ExpressionEncoder[A20] + ).toOption :: Try( + ExpressionEncoder[A21] + ).toOption :: Try( + ExpressionEncoder[A22] + ).toOption :: Nil + } +} diff --git a/scalafmt-tests/shared/src/test/resources/newlines/source_fold.stat b/scalafmt-tests/shared/src/test/resources/newlines/source_fold.stat index 8badc3d13b..a0418af38e 100644 --- a/scalafmt-tests/shared/src/test/resources/newlines/source_fold.stat +++ b/scalafmt-tests/shared/src/test/resources/newlines/source_fold.stat @@ -8769,3 +8769,269 @@ trait Infer { } } } +<<< #4133 very long one-liner with chain of infixes, full method +class UDFRegistration private[sql] (functionRegistry: FunctionRegistry) extends Logging { + def register[RT: TypeTag, A1: TypeTag, A2: TypeTag, A3: TypeTag, A4: TypeTag, A5: TypeTag, A6: TypeTag, A7: TypeTag, A8: TypeTag, A9: TypeTag, A10: TypeTag, A11: TypeTag, A12: TypeTag, A13: TypeTag, A14: TypeTag, A15: TypeTag, A16: TypeTag, A17: TypeTag, A18: TypeTag, A19: TypeTag, A20: TypeTag, A21: TypeTag, A22: TypeTag](name: String, func: Function22[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22, RT]): UserDefinedFunction = { + val inputEncoders: Seq[Option[ExpressionEncoder[_]]] = Try(ExpressionEncoder[A1]()).toOption :: Try(ExpressionEncoder[A2]()).toOption :: Try(ExpressionEncoder[A3]()).toOption :: Try(ExpressionEncoder[A4]()).toOption :: Try(ExpressionEncoder[A5]()).toOption :: Try(ExpressionEncoder[A6]()).toOption :: Try(ExpressionEncoder[A7]()).toOption :: Try(ExpressionEncoder[A8]()).toOption :: Try(ExpressionEncoder[A9]()).toOption :: Try(ExpressionEncoder[A10]()).toOption :: Try(ExpressionEncoder[A11]()).toOption :: Try(ExpressionEncoder[A12]()).toOption :: Try(ExpressionEncoder[A13]()).toOption :: Try(ExpressionEncoder[A14]()).toOption :: Try(ExpressionEncoder[A15]()).toOption :: Try(ExpressionEncoder[A16]()).toOption :: Try(ExpressionEncoder[A17]()).toOption :: Try(ExpressionEncoder[A18]()).toOption :: Try(ExpressionEncoder[A19]()).toOption :: Try(ExpressionEncoder[A20]()).toOption :: Try(ExpressionEncoder[A21]()).toOption :: Try(ExpressionEncoder[A22]()).toOption :: Nil + } +} +>>> +class UDFRegistration private[sql] ( + functionRegistry: FunctionRegistry +) extends Logging { + def register[ + RT: TypeTag, + A1: TypeTag, + A2: TypeTag, + A3: TypeTag, + A4: TypeTag, + A5: TypeTag, + A6: TypeTag, + A7: TypeTag, + A8: TypeTag, + A9: TypeTag, + A10: TypeTag, + A11: TypeTag, + A12: TypeTag, + A13: TypeTag, + A14: TypeTag, + A15: TypeTag, + A16: TypeTag, + A17: TypeTag, + A18: TypeTag, + A19: TypeTag, + A20: TypeTag, + A21: TypeTag, + A22: TypeTag + ]( + name: String, + func: Function22[ + A1, + A2, + A3, + A4, + A5, + A6, + A7, + A8, + A9, + A10, + A11, + A12, + A13, + A14, + A15, + A16, + A17, + A18, + A19, + A20, + A21, + A22, + RT + ] + ): UserDefinedFunction = { + val inputEncoders: Seq[ + Option[ExpressionEncoder[_]] + ] = Try(ExpressionEncoder[A1]()) + .toOption :: + Try(ExpressionEncoder[A2]()) + .toOption :: + Try(ExpressionEncoder[A3]()) + .toOption :: + Try(ExpressionEncoder[A4]()) + .toOption :: + Try(ExpressionEncoder[A5]()) + .toOption :: + Try(ExpressionEncoder[A6]()) + .toOption :: + Try(ExpressionEncoder[A7]()) + .toOption :: + Try(ExpressionEncoder[A8]()) + .toOption :: + Try(ExpressionEncoder[A9]()) + .toOption :: + Try(ExpressionEncoder[A10]()) + .toOption :: + Try(ExpressionEncoder[A11]()) + .toOption :: + Try(ExpressionEncoder[A12]()) + .toOption :: + Try(ExpressionEncoder[A13]()) + .toOption :: + Try(ExpressionEncoder[A14]()) + .toOption :: + Try(ExpressionEncoder[A15]()) + .toOption :: + Try(ExpressionEncoder[A16]()) + .toOption :: + Try(ExpressionEncoder[A17]()) + .toOption :: + Try(ExpressionEncoder[A18]()) + .toOption :: + Try(ExpressionEncoder[A19]()) + .toOption :: + Try(ExpressionEncoder[A20]()) + .toOption :: + Try(ExpressionEncoder[A21]()) + .toOption :: + Try(ExpressionEncoder[A22]()) + .toOption :: Nil + } +} +<<< #4133 very long one-liner with chain of infixes +runner.maxStateVisits = 1000 +=== +class UDFRegistration { + def foo = { + val inputEncoders: Seq_Option_ExpressionEncoder_____ = Try(ExpressionEncoder_A1_) :: Try(ExpressionEncoder_A2_) :: Try(ExpressionEncoder_A3_) :: Try(ExpressionEncoder_A4_) :: Try(ExpressionEncoder_A5_) :: Try(ExpressionEncoder_A6_) :: Try(ExpressionEncoder_A7_) :: Try(ExpressionEncoder_A8_) :: Try(ExpressionEncoder_A9_) :: Try(ExpressionEncoder_A10_) :: Try(ExpressionEncoder_A11_) :: Try(ExpressionEncoder_A12_) :: Try(ExpressionEncoder_A13_) :: Try(ExpressionEncoder_A14_) :: Try(ExpressionEncoder_A15_) :: Try(ExpressionEncoder_A16_) :: Try(ExpressionEncoder_A17_) :: Try(ExpressionEncoder_A18_) :: Try(ExpressionEncoder_A19_) :: Try(ExpressionEncoder_A20_) :: Try(ExpressionEncoder_A21_) :: Try(ExpressionEncoder_A22_) :: Nil + } +} +>>> +class UDFRegistration { + def foo = { + val inputEncoders + : Seq_Option_ExpressionEncoder_____ = + Try(ExpressionEncoder_A1_) :: + Try(ExpressionEncoder_A2_) :: + Try(ExpressionEncoder_A3_) :: + Try(ExpressionEncoder_A4_) :: + Try(ExpressionEncoder_A5_) :: + Try(ExpressionEncoder_A6_) :: + Try(ExpressionEncoder_A7_) :: + Try(ExpressionEncoder_A8_) :: + Try(ExpressionEncoder_A9_) :: + Try(ExpressionEncoder_A10_) :: + Try(ExpressionEncoder_A11_) :: + Try(ExpressionEncoder_A12_) :: + Try(ExpressionEncoder_A13_) :: + Try(ExpressionEncoder_A14_) :: + Try(ExpressionEncoder_A15_) :: + Try(ExpressionEncoder_A16_) :: + Try(ExpressionEncoder_A17_) :: + Try(ExpressionEncoder_A18_) :: + Try(ExpressionEncoder_A19_) :: + Try(ExpressionEncoder_A20_) :: + Try(ExpressionEncoder_A21_) :: + Try(ExpressionEncoder_A22_) :: + Nil + } +} +<<< #4133 very long one-liner with chain of infixes, with selects +runner.maxStateVisits = 5000 +=== +class UDFRegistration { + def foo = { + val inputEncoders: Seq_Option_ExpressionEncoder_____ = Try(ExpressionEncoder_A1_).toOption :: Try(ExpressionEncoder_A2_).toOption :: Try(ExpressionEncoder_A3_).toOption :: Try(ExpressionEncoder_A4_).toOption :: Try(ExpressionEncoder_A5_).toOption :: Try(ExpressionEncoder_A6_).toOption :: Try(ExpressionEncoder_A7_).toOption :: Try(ExpressionEncoder_A8_).toOption :: Try(ExpressionEncoder_A9_).toOption :: Try(ExpressionEncoder_A10_).toOption :: Try(ExpressionEncoder_A11_).toOption :: Try(ExpressionEncoder_A12_).toOption :: Try(ExpressionEncoder_A13_).toOption :: Try(ExpressionEncoder_A14_).toOption :: Try(ExpressionEncoder_A15_).toOption :: Try(ExpressionEncoder_A16_).toOption :: Try(ExpressionEncoder_A17_).toOption :: Try(ExpressionEncoder_A18_).toOption :: Try(ExpressionEncoder_A19_).toOption :: Try(ExpressionEncoder_A20_).toOption :: Try(ExpressionEncoder_A21_).toOption :: Try(ExpressionEncoder_A22_).toOption :: Nil + } +} +>>> +class UDFRegistration { + def foo = { + val inputEncoders + : Seq_Option_ExpressionEncoder_____ = + Try(ExpressionEncoder_A1_) + .toOption :: + Try(ExpressionEncoder_A2_) + .toOption :: + Try(ExpressionEncoder_A3_) + .toOption :: + Try(ExpressionEncoder_A4_) + .toOption :: + Try(ExpressionEncoder_A5_) + .toOption :: + Try(ExpressionEncoder_A6_) + .toOption :: + Try(ExpressionEncoder_A7_) + .toOption :: + Try(ExpressionEncoder_A8_) + .toOption :: + Try(ExpressionEncoder_A9_) + .toOption :: + Try(ExpressionEncoder_A10_) + .toOption :: + Try(ExpressionEncoder_A11_) + .toOption :: + Try(ExpressionEncoder_A12_) + .toOption :: + Try(ExpressionEncoder_A13_) + .toOption :: + Try(ExpressionEncoder_A14_) + .toOption :: + Try(ExpressionEncoder_A15_) + .toOption :: + Try(ExpressionEncoder_A16_) + .toOption :: + Try(ExpressionEncoder_A17_) + .toOption :: + Try(ExpressionEncoder_A18_) + .toOption :: + Try(ExpressionEncoder_A19_) + .toOption :: + Try(ExpressionEncoder_A20_) + .toOption :: + Try(ExpressionEncoder_A21_) + .toOption :: + Try(ExpressionEncoder_A22_) + .toOption :: Nil + } +} +<<< #4133 very long one-liner with chain of infixes, with select and types +runner.maxStateVisits = 100000 +=== +class UDFRegistration { + def foo = { + val inputEncoders: Seq[Option[ExpressionEncoder[_]]] = Try(ExpressionEncoder[A1]).toOption :: Try(ExpressionEncoder[A2]).toOption :: Try(ExpressionEncoder[A3]).toOption :: Try(ExpressionEncoder[A4]).toOption :: Try(ExpressionEncoder[A5]).toOption :: Try(ExpressionEncoder[A6]).toOption :: Try(ExpressionEncoder[A7]).toOption :: Try(ExpressionEncoder[A8]).toOption :: Try(ExpressionEncoder[A9]).toOption :: Try(ExpressionEncoder[A10]).toOption :: Try(ExpressionEncoder[A11]).toOption :: Try(ExpressionEncoder[A12]).toOption :: Try(ExpressionEncoder[A13]).toOption :: Try(ExpressionEncoder[A14]).toOption :: Try(ExpressionEncoder[A15]).toOption :: Try(ExpressionEncoder[A16]).toOption :: Try(ExpressionEncoder[A17]).toOption :: Try(ExpressionEncoder[A18]).toOption :: Try(ExpressionEncoder[A19]).toOption :: Try(ExpressionEncoder[A20]).toOption :: Try(ExpressionEncoder[A21]).toOption :: Try(ExpressionEncoder[A22]).toOption :: Nil + } +} +>>> +class UDFRegistration { + def foo = { + val inputEncoders: Seq[ + Option[ExpressionEncoder[_]] + ] = Try(ExpressionEncoder[A1]) + .toOption :: + Try(ExpressionEncoder[A2]) + .toOption :: + Try(ExpressionEncoder[A3]) + .toOption :: + Try(ExpressionEncoder[A4]) + .toOption :: + Try(ExpressionEncoder[A5]) + .toOption :: + Try(ExpressionEncoder[A6]) + .toOption :: + Try(ExpressionEncoder[A7]) + .toOption :: + Try(ExpressionEncoder[A8]) + .toOption :: + Try(ExpressionEncoder[A9]) + .toOption :: + Try(ExpressionEncoder[A10]) + .toOption :: + Try(ExpressionEncoder[A11]) + .toOption :: + Try(ExpressionEncoder[A12]) + .toOption :: + Try(ExpressionEncoder[A13]) + .toOption :: + Try(ExpressionEncoder[A14]) + .toOption :: + Try(ExpressionEncoder[A15]) + .toOption :: + Try(ExpressionEncoder[A16]) + .toOption :: + Try(ExpressionEncoder[A17]) + .toOption :: + Try(ExpressionEncoder[A18]) + .toOption :: + Try(ExpressionEncoder[A19]) + .toOption :: + Try(ExpressionEncoder[A20]) + .toOption :: + Try(ExpressionEncoder[A21]) + .toOption :: + Try(ExpressionEncoder[A22]) + .toOption :: Nil + } +} diff --git a/scalafmt-tests/shared/src/test/resources/newlines/source_keep.stat b/scalafmt-tests/shared/src/test/resources/newlines/source_keep.stat index 359c76204b..388268fcb9 100644 --- a/scalafmt-tests/shared/src/test/resources/newlines/source_keep.stat +++ b/scalafmt-tests/shared/src/test/resources/newlines/source_keep.stat @@ -9140,3 +9140,41 @@ trait Infer { } } } +<<< SKIP #4133 very long one-liner with chain of infixes, full method +class UDFRegistration private[sql] (functionRegistry: FunctionRegistry) extends Logging { + def register[RT: TypeTag, A1: TypeTag, A2: TypeTag, A3: TypeTag, A4: TypeTag, A5: TypeTag, A6: TypeTag, A7: TypeTag, A8: TypeTag, A9: TypeTag, A10: TypeTag, A11: TypeTag, A12: TypeTag, A13: TypeTag, A14: TypeTag, A15: TypeTag, A16: TypeTag, A17: TypeTag, A18: TypeTag, A19: TypeTag, A20: TypeTag, A21: TypeTag, A22: TypeTag](name: String, func: Function22[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22, RT]): UserDefinedFunction = { + val inputEncoders: Seq[Option[ExpressionEncoder[_]]] = Try(ExpressionEncoder[A1]()).toOption :: Try(ExpressionEncoder[A2]()).toOption :: Try(ExpressionEncoder[A3]()).toOption :: Try(ExpressionEncoder[A4]()).toOption :: Try(ExpressionEncoder[A5]()).toOption :: Try(ExpressionEncoder[A6]()).toOption :: Try(ExpressionEncoder[A7]()).toOption :: Try(ExpressionEncoder[A8]()).toOption :: Try(ExpressionEncoder[A9]()).toOption :: Try(ExpressionEncoder[A10]()).toOption :: Try(ExpressionEncoder[A11]()).toOption :: Try(ExpressionEncoder[A12]()).toOption :: Try(ExpressionEncoder[A13]()).toOption :: Try(ExpressionEncoder[A14]()).toOption :: Try(ExpressionEncoder[A15]()).toOption :: Try(ExpressionEncoder[A16]()).toOption :: Try(ExpressionEncoder[A17]()).toOption :: Try(ExpressionEncoder[A18]()).toOption :: Try(ExpressionEncoder[A19]()).toOption :: Try(ExpressionEncoder[A20]()).toOption :: Try(ExpressionEncoder[A21]()).toOption :: Try(ExpressionEncoder[A22]()).toOption :: Nil + } +} +>>> +FormatTests:54 [e]: org.scalafmt.Error$SearchStateExploded: Search state exploded on '[276] )∙.: RightParen [952..953) [] Dot [953..954)', line 3: exceeded `runner.maxStateVisits`=150000 [see https://scalameta.org/scalafmt/docs/configuration.html#search-state-exploded] +<<< SKIP #4133 very long one-liner with chain of infixes +runner.maxStateVisits = 1000 +=== +class UDFRegistration { + def foo = { + val inputEncoders: Seq_Option_ExpressionEncoder_____ = Try(ExpressionEncoder_A1_) :: Try(ExpressionEncoder_A2_) :: Try(ExpressionEncoder_A3_) :: Try(ExpressionEncoder_A4_) :: Try(ExpressionEncoder_A5_) :: Try(ExpressionEncoder_A6_) :: Try(ExpressionEncoder_A7_) :: Try(ExpressionEncoder_A8_) :: Try(ExpressionEncoder_A9_) :: Try(ExpressionEncoder_A10_) :: Try(ExpressionEncoder_A11_) :: Try(ExpressionEncoder_A12_) :: Try(ExpressionEncoder_A13_) :: Try(ExpressionEncoder_A14_) :: Try(ExpressionEncoder_A15_) :: Try(ExpressionEncoder_A16_) :: Try(ExpressionEncoder_A17_) :: Try(ExpressionEncoder_A18_) :: Try(ExpressionEncoder_A19_) :: Try(ExpressionEncoder_A20_) :: Try(ExpressionEncoder_A21_) :: Try(ExpressionEncoder_A22_) :: Nil + } +} +>>> +FormatTests:54 [e]: org.scalafmt.Error$SearchStateExploded: Search state exploded on '[43] Try∙(: Ident(Try) [277..280) [] LeftParen [280..281)', line 3: exceeded `runner.maxStateVisits`=1000 [see https://scalameta.org/scalafmt/docs/configuration.html#search-state-exploded] +<<< SKIP #4133 very long one-liner with chain of infixes, with selects +runner.maxStateVisits = 5000 +=== +class UDFRegistration { + def foo = { + val inputEncoders: Seq_Option_ExpressionEncoder_____ = Try(ExpressionEncoder_A1_).toOption :: Try(ExpressionEncoder_A2_).toOption :: Try(ExpressionEncoder_A3_).toOption :: Try(ExpressionEncoder_A4_).toOption :: Try(ExpressionEncoder_A5_).toOption :: Try(ExpressionEncoder_A6_).toOption :: Try(ExpressionEncoder_A7_).toOption :: Try(ExpressionEncoder_A8_).toOption :: Try(ExpressionEncoder_A9_).toOption :: Try(ExpressionEncoder_A10_).toOption :: Try(ExpressionEncoder_A11_).toOption :: Try(ExpressionEncoder_A12_).toOption :: Try(ExpressionEncoder_A13_).toOption :: Try(ExpressionEncoder_A14_).toOption :: Try(ExpressionEncoder_A15_).toOption :: Try(ExpressionEncoder_A16_).toOption :: Try(ExpressionEncoder_A17_).toOption :: Try(ExpressionEncoder_A18_).toOption :: Try(ExpressionEncoder_A19_).toOption :: Try(ExpressionEncoder_A20_).toOption :: Try(ExpressionEncoder_A21_).toOption :: Try(ExpressionEncoder_A22_).toOption :: Nil + } +} +>>> +FormatTests:54 [e]: org.scalafmt.Error$SearchStateExploded: Search state exploded on '[77] (∙ExpressionEncoder_A10_: LeftParen [451..452) [] Ident(ExpressionEncoder_A10_) [452..474)', line 3: exceeded `runner.maxStateVisits`=5000 [see https://scalameta.org/scalafmt/docs/configuration.html#search-state-exploded] +<<< SKIP #4133 very long one-liner with chain of infixes, with select and types +runner.maxStateVisits = 100000 +=== +class UDFRegistration { + def foo = { + val inputEncoders: Seq[Option[ExpressionEncoder[_]]] = Try(ExpressionEncoder[A1]).toOption :: Try(ExpressionEncoder[A2]).toOption :: Try(ExpressionEncoder[A3]).toOption :: Try(ExpressionEncoder[A4]).toOption :: Try(ExpressionEncoder[A5]).toOption :: Try(ExpressionEncoder[A6]).toOption :: Try(ExpressionEncoder[A7]).toOption :: Try(ExpressionEncoder[A8]).toOption :: Try(ExpressionEncoder[A9]).toOption :: Try(ExpressionEncoder[A10]).toOption :: Try(ExpressionEncoder[A11]).toOption :: Try(ExpressionEncoder[A12]).toOption :: Try(ExpressionEncoder[A13]).toOption :: Try(ExpressionEncoder[A14]).toOption :: Try(ExpressionEncoder[A15]).toOption :: Try(ExpressionEncoder[A16]).toOption :: Try(ExpressionEncoder[A17]).toOption :: Try(ExpressionEncoder[A18]).toOption :: Try(ExpressionEncoder[A19]).toOption :: Try(ExpressionEncoder[A20]).toOption :: Try(ExpressionEncoder[A21]).toOption :: Try(ExpressionEncoder[A22]).toOption :: Nil + } +} +>>> +FormatTests:54 [e]: org.scalafmt.Error$SearchStateExploded: Search state exploded on '[121] ::∙Try: Ident(::) [485..487) [ ] Ident(Try) [488..491)', line 3: exceeded `runner.maxStateVisits`=100000 [see https://scalameta.org/scalafmt/docs/configuration.html#search-state-exploded] diff --git a/scalafmt-tests/shared/src/test/resources/newlines/source_unfold.stat b/scalafmt-tests/shared/src/test/resources/newlines/source_unfold.stat index 1627ebf36f..4b36672c1a 100644 --- a/scalafmt-tests/shared/src/test/resources/newlines/source_unfold.stat +++ b/scalafmt-tests/shared/src/test/resources/newlines/source_unfold.stat @@ -9442,3 +9442,271 @@ trait Infer { } } } +<<< #4133 very long one-liner with chain of infixes, full method +class UDFRegistration private[sql] (functionRegistry: FunctionRegistry) extends Logging { + def register[RT: TypeTag, A1: TypeTag, A2: TypeTag, A3: TypeTag, A4: TypeTag, A5: TypeTag, A6: TypeTag, A7: TypeTag, A8: TypeTag, A9: TypeTag, A10: TypeTag, A11: TypeTag, A12: TypeTag, A13: TypeTag, A14: TypeTag, A15: TypeTag, A16: TypeTag, A17: TypeTag, A18: TypeTag, A19: TypeTag, A20: TypeTag, A21: TypeTag, A22: TypeTag](name: String, func: Function22[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22, RT]): UserDefinedFunction = { + val inputEncoders: Seq[Option[ExpressionEncoder[_]]] = Try(ExpressionEncoder[A1]()).toOption :: Try(ExpressionEncoder[A2]()).toOption :: Try(ExpressionEncoder[A3]()).toOption :: Try(ExpressionEncoder[A4]()).toOption :: Try(ExpressionEncoder[A5]()).toOption :: Try(ExpressionEncoder[A6]()).toOption :: Try(ExpressionEncoder[A7]()).toOption :: Try(ExpressionEncoder[A8]()).toOption :: Try(ExpressionEncoder[A9]()).toOption :: Try(ExpressionEncoder[A10]()).toOption :: Try(ExpressionEncoder[A11]()).toOption :: Try(ExpressionEncoder[A12]()).toOption :: Try(ExpressionEncoder[A13]()).toOption :: Try(ExpressionEncoder[A14]()).toOption :: Try(ExpressionEncoder[A15]()).toOption :: Try(ExpressionEncoder[A16]()).toOption :: Try(ExpressionEncoder[A17]()).toOption :: Try(ExpressionEncoder[A18]()).toOption :: Try(ExpressionEncoder[A19]()).toOption :: Try(ExpressionEncoder[A20]()).toOption :: Try(ExpressionEncoder[A21]()).toOption :: Try(ExpressionEncoder[A22]()).toOption :: Nil + } +} +>>> +class UDFRegistration private[sql] ( + functionRegistry: FunctionRegistry +) extends Logging { + def register[ + RT: TypeTag, + A1: TypeTag, + A2: TypeTag, + A3: TypeTag, + A4: TypeTag, + A5: TypeTag, + A6: TypeTag, + A7: TypeTag, + A8: TypeTag, + A9: TypeTag, + A10: TypeTag, + A11: TypeTag, + A12: TypeTag, + A13: TypeTag, + A14: TypeTag, + A15: TypeTag, + A16: TypeTag, + A17: TypeTag, + A18: TypeTag, + A19: TypeTag, + A20: TypeTag, + A21: TypeTag, + A22: TypeTag + ]( + name: String, + func: Function22[ + A1, + A2, + A3, + A4, + A5, + A6, + A7, + A8, + A9, + A10, + A11, + A12, + A13, + A14, + A15, + A16, + A17, + A18, + A19, + A20, + A21, + A22, + RT + ] + ): UserDefinedFunction = { + val inputEncoders: Seq[ + Option[ExpressionEncoder[_]] + ] = + Try(ExpressionEncoder[A1]()) + .toOption :: + Try(ExpressionEncoder[A2]()) + .toOption :: + Try(ExpressionEncoder[A3]()) + .toOption :: + Try(ExpressionEncoder[A4]()) + .toOption :: + Try(ExpressionEncoder[A5]()) + .toOption :: + Try(ExpressionEncoder[A6]()) + .toOption :: + Try(ExpressionEncoder[A7]()) + .toOption :: + Try(ExpressionEncoder[A8]()) + .toOption :: + Try(ExpressionEncoder[A9]()) + .toOption :: + Try(ExpressionEncoder[A10]()) + .toOption :: + Try(ExpressionEncoder[A11]()) + .toOption :: + Try(ExpressionEncoder[A12]()) + .toOption :: + Try(ExpressionEncoder[A13]()) + .toOption :: + Try(ExpressionEncoder[A14]()) + .toOption :: + Try(ExpressionEncoder[A15]()) + .toOption :: + Try(ExpressionEncoder[A16]()) + .toOption :: + Try(ExpressionEncoder[A17]()) + .toOption :: + Try(ExpressionEncoder[A18]()) + .toOption :: + Try(ExpressionEncoder[A19]()) + .toOption :: + Try(ExpressionEncoder[A20]()) + .toOption :: + Try(ExpressionEncoder[A21]()) + .toOption :: + Try(ExpressionEncoder[A22]()) + .toOption :: Nil + } +} +<<< #4133 very long one-liner with chain of infixes +runner.maxStateVisits = 1000 +=== +class UDFRegistration { + def foo = { + val inputEncoders: Seq_Option_ExpressionEncoder_____ = Try(ExpressionEncoder_A1_) :: Try(ExpressionEncoder_A2_) :: Try(ExpressionEncoder_A3_) :: Try(ExpressionEncoder_A4_) :: Try(ExpressionEncoder_A5_) :: Try(ExpressionEncoder_A6_) :: Try(ExpressionEncoder_A7_) :: Try(ExpressionEncoder_A8_) :: Try(ExpressionEncoder_A9_) :: Try(ExpressionEncoder_A10_) :: Try(ExpressionEncoder_A11_) :: Try(ExpressionEncoder_A12_) :: Try(ExpressionEncoder_A13_) :: Try(ExpressionEncoder_A14_) :: Try(ExpressionEncoder_A15_) :: Try(ExpressionEncoder_A16_) :: Try(ExpressionEncoder_A17_) :: Try(ExpressionEncoder_A18_) :: Try(ExpressionEncoder_A19_) :: Try(ExpressionEncoder_A20_) :: Try(ExpressionEncoder_A21_) :: Try(ExpressionEncoder_A22_) :: Nil + } +} +>>> +class UDFRegistration { + def foo = { + val inputEncoders + : Seq_Option_ExpressionEncoder_____ = + Try(ExpressionEncoder_A1_) :: + Try(ExpressionEncoder_A2_) :: + Try(ExpressionEncoder_A3_) :: + Try(ExpressionEncoder_A4_) :: + Try(ExpressionEncoder_A5_) :: + Try(ExpressionEncoder_A6_) :: + Try(ExpressionEncoder_A7_) :: + Try(ExpressionEncoder_A8_) :: + Try(ExpressionEncoder_A9_) :: + Try(ExpressionEncoder_A10_) :: + Try(ExpressionEncoder_A11_) :: + Try(ExpressionEncoder_A12_) :: + Try(ExpressionEncoder_A13_) :: + Try(ExpressionEncoder_A14_) :: + Try(ExpressionEncoder_A15_) :: + Try(ExpressionEncoder_A16_) :: + Try(ExpressionEncoder_A17_) :: + Try(ExpressionEncoder_A18_) :: + Try(ExpressionEncoder_A19_) :: + Try(ExpressionEncoder_A20_) :: + Try(ExpressionEncoder_A21_) :: + Try(ExpressionEncoder_A22_) :: + Nil + } +} +<<< #4133 very long one-liner with chain of infixes, with selects +runner.maxStateVisits = 5000 +=== +class UDFRegistration { + def foo = { + val inputEncoders: Seq_Option_ExpressionEncoder_____ = Try(ExpressionEncoder_A1_).toOption :: Try(ExpressionEncoder_A2_).toOption :: Try(ExpressionEncoder_A3_).toOption :: Try(ExpressionEncoder_A4_).toOption :: Try(ExpressionEncoder_A5_).toOption :: Try(ExpressionEncoder_A6_).toOption :: Try(ExpressionEncoder_A7_).toOption :: Try(ExpressionEncoder_A8_).toOption :: Try(ExpressionEncoder_A9_).toOption :: Try(ExpressionEncoder_A10_).toOption :: Try(ExpressionEncoder_A11_).toOption :: Try(ExpressionEncoder_A12_).toOption :: Try(ExpressionEncoder_A13_).toOption :: Try(ExpressionEncoder_A14_).toOption :: Try(ExpressionEncoder_A15_).toOption :: Try(ExpressionEncoder_A16_).toOption :: Try(ExpressionEncoder_A17_).toOption :: Try(ExpressionEncoder_A18_).toOption :: Try(ExpressionEncoder_A19_).toOption :: Try(ExpressionEncoder_A20_).toOption :: Try(ExpressionEncoder_A21_).toOption :: Try(ExpressionEncoder_A22_).toOption :: Nil + } +} +>>> +class UDFRegistration { + def foo = { + val inputEncoders + : Seq_Option_ExpressionEncoder_____ = + Try(ExpressionEncoder_A1_) + .toOption :: + Try(ExpressionEncoder_A2_) + .toOption :: + Try(ExpressionEncoder_A3_) + .toOption :: + Try(ExpressionEncoder_A4_) + .toOption :: + Try(ExpressionEncoder_A5_) + .toOption :: + Try(ExpressionEncoder_A6_) + .toOption :: + Try(ExpressionEncoder_A7_) + .toOption :: + Try(ExpressionEncoder_A8_) + .toOption :: + Try(ExpressionEncoder_A9_) + .toOption :: + Try(ExpressionEncoder_A10_) + .toOption :: + Try(ExpressionEncoder_A11_) + .toOption :: + Try(ExpressionEncoder_A12_) + .toOption :: + Try(ExpressionEncoder_A13_) + .toOption :: + Try(ExpressionEncoder_A14_) + .toOption :: + Try(ExpressionEncoder_A15_) + .toOption :: + Try(ExpressionEncoder_A16_) + .toOption :: + Try(ExpressionEncoder_A17_) + .toOption :: + Try(ExpressionEncoder_A18_) + .toOption :: + Try(ExpressionEncoder_A19_) + .toOption :: + Try(ExpressionEncoder_A20_) + .toOption :: + Try(ExpressionEncoder_A21_) + .toOption :: + Try(ExpressionEncoder_A22_) + .toOption :: Nil + } +} +<<< #4133 very long one-liner with chain of infixes, with select and types +runner.maxStateVisits = 100000 +=== +class UDFRegistration { + def foo = { + val inputEncoders: Seq[Option[ExpressionEncoder[_]]] = Try(ExpressionEncoder[A1]).toOption :: Try(ExpressionEncoder[A2]).toOption :: Try(ExpressionEncoder[A3]).toOption :: Try(ExpressionEncoder[A4]).toOption :: Try(ExpressionEncoder[A5]).toOption :: Try(ExpressionEncoder[A6]).toOption :: Try(ExpressionEncoder[A7]).toOption :: Try(ExpressionEncoder[A8]).toOption :: Try(ExpressionEncoder[A9]).toOption :: Try(ExpressionEncoder[A10]).toOption :: Try(ExpressionEncoder[A11]).toOption :: Try(ExpressionEncoder[A12]).toOption :: Try(ExpressionEncoder[A13]).toOption :: Try(ExpressionEncoder[A14]).toOption :: Try(ExpressionEncoder[A15]).toOption :: Try(ExpressionEncoder[A16]).toOption :: Try(ExpressionEncoder[A17]).toOption :: Try(ExpressionEncoder[A18]).toOption :: Try(ExpressionEncoder[A19]).toOption :: Try(ExpressionEncoder[A20]).toOption :: Try(ExpressionEncoder[A21]).toOption :: Try(ExpressionEncoder[A22]).toOption :: Nil + } +} +>>> +class UDFRegistration { + def foo = { + val inputEncoders: Seq[ + Option[ExpressionEncoder[_]] + ] = + Try(ExpressionEncoder[A1]) + .toOption :: + Try(ExpressionEncoder[A2]) + .toOption :: + Try(ExpressionEncoder[A3]) + .toOption :: + Try(ExpressionEncoder[A4]) + .toOption :: + Try(ExpressionEncoder[A5]) + .toOption :: + Try(ExpressionEncoder[A6]) + .toOption :: + Try(ExpressionEncoder[A7]) + .toOption :: + Try(ExpressionEncoder[A8]) + .toOption :: + Try(ExpressionEncoder[A9]) + .toOption :: + Try(ExpressionEncoder[A10]) + .toOption :: + Try(ExpressionEncoder[A11]) + .toOption :: + Try(ExpressionEncoder[A12]) + .toOption :: + Try(ExpressionEncoder[A13]) + .toOption :: + Try(ExpressionEncoder[A14]) + .toOption :: + Try(ExpressionEncoder[A15]) + .toOption :: + Try(ExpressionEncoder[A16]) + .toOption :: + Try(ExpressionEncoder[A17]) + .toOption :: + Try(ExpressionEncoder[A18]) + .toOption :: + Try(ExpressionEncoder[A19]) + .toOption :: + Try(ExpressionEncoder[A20]) + .toOption :: + Try(ExpressionEncoder[A21]) + .toOption :: + Try(ExpressionEncoder[A22]) + .toOption :: Nil + } +} From b79ad8a6e29c10467d614408fc5f59afca232bfd Mon Sep 17 00:00:00 2001 From: Albert Meltzer <7529386+kitbellew@users.noreply.github.com> Date: Fri, 27 Sep 2024 14:37:12 -0700 Subject: [PATCH 2/2] BestFirstSearch: arg clause an opt-zone for keep --- .../scalafmt/internal/BestFirstSearch.scala | 6 +- .../test/resources/newlines/source_keep.stat | 273 +++++++++++++++++- .../resources/scala3/OptionalBraces_keep.stat | 23 +- 3 files changed, 278 insertions(+), 24 deletions(-) diff --git a/scalafmt-core/shared/src/main/scala/org/scalafmt/internal/BestFirstSearch.scala b/scalafmt-core/shared/src/main/scala/org/scalafmt/internal/BestFirstSearch.scala index 8fd35b3027..4be4af038a 100644 --- a/scalafmt-core/shared/src/main/scala/org/scalafmt/internal/BestFirstSearch.scala +++ b/scalafmt-core/shared/src/main/scala/org/scalafmt/internal/BestFirstSearch.scala @@ -332,15 +332,15 @@ object BestFirstSearch { private def hasSlbAfter(state: State)(ft: FormatToken): Boolean = state.policy .exists(_.appliesUntil(ft)(_.isInstanceOf[PolicyOps.SingleLineBlock])) - private def getNoOptZones(tokens: FormatTokens) = { + private def getNoOptZones(tokens: FormatTokens)(implicit styleMap: StyleMap) = { val result = Set.newBuilder[Token] var expire: Token = null tokens.foreach { case FormatToken(x, _, _) if expire ne null => if (x eq expire) expire = null else result += x case FormatToken(t: Token.LeftParen, _, m) if (m.leftOwner match { - // TODO(olafur) https://github.com/scalameta/scalameta/issues/345 - case lo: Term.ArgClause => !lo.parent.is[Term.ApplyInfix] + case lo: Term.ArgClause => !lo.parent.is[Term.ApplyInfix] && + !styleMap.at(t).newlines.keep case _: Term.Apply => true // legacy: when enclosed in parens case _ => false }) => expire = tokens.matching(t) diff --git a/scalafmt-tests/shared/src/test/resources/newlines/source_keep.stat b/scalafmt-tests/shared/src/test/resources/newlines/source_keep.stat index 388268fcb9..ef7b022397 100644 --- a/scalafmt-tests/shared/src/test/resources/newlines/source_keep.stat +++ b/scalafmt-tests/shared/src/test/resources/newlines/source_keep.stat @@ -2239,9 +2239,9 @@ val a = b match { ) :: JField( "env", - Extraction.decompose( - i.env - )(DefaultFormats) + Extraction.decompose(i.env)( + DefaultFormats + ) ) :: JField( "sparkConf", @@ -9140,15 +9140,118 @@ trait Infer { } } } -<<< SKIP #4133 very long one-liner with chain of infixes, full method +<<< #4133 very long one-liner with chain of infixes, full method class UDFRegistration private[sql] (functionRegistry: FunctionRegistry) extends Logging { def register[RT: TypeTag, A1: TypeTag, A2: TypeTag, A3: TypeTag, A4: TypeTag, A5: TypeTag, A6: TypeTag, A7: TypeTag, A8: TypeTag, A9: TypeTag, A10: TypeTag, A11: TypeTag, A12: TypeTag, A13: TypeTag, A14: TypeTag, A15: TypeTag, A16: TypeTag, A17: TypeTag, A18: TypeTag, A19: TypeTag, A20: TypeTag, A21: TypeTag, A22: TypeTag](name: String, func: Function22[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22, RT]): UserDefinedFunction = { val inputEncoders: Seq[Option[ExpressionEncoder[_]]] = Try(ExpressionEncoder[A1]()).toOption :: Try(ExpressionEncoder[A2]()).toOption :: Try(ExpressionEncoder[A3]()).toOption :: Try(ExpressionEncoder[A4]()).toOption :: Try(ExpressionEncoder[A5]()).toOption :: Try(ExpressionEncoder[A6]()).toOption :: Try(ExpressionEncoder[A7]()).toOption :: Try(ExpressionEncoder[A8]()).toOption :: Try(ExpressionEncoder[A9]()).toOption :: Try(ExpressionEncoder[A10]()).toOption :: Try(ExpressionEncoder[A11]()).toOption :: Try(ExpressionEncoder[A12]()).toOption :: Try(ExpressionEncoder[A13]()).toOption :: Try(ExpressionEncoder[A14]()).toOption :: Try(ExpressionEncoder[A15]()).toOption :: Try(ExpressionEncoder[A16]()).toOption :: Try(ExpressionEncoder[A17]()).toOption :: Try(ExpressionEncoder[A18]()).toOption :: Try(ExpressionEncoder[A19]()).toOption :: Try(ExpressionEncoder[A20]()).toOption :: Try(ExpressionEncoder[A21]()).toOption :: Try(ExpressionEncoder[A22]()).toOption :: Nil } } >>> -FormatTests:54 [e]: org.scalafmt.Error$SearchStateExploded: Search state exploded on '[276] )∙.: RightParen [952..953) [] Dot [953..954)', line 3: exceeded `runner.maxStateVisits`=150000 [see https://scalameta.org/scalafmt/docs/configuration.html#search-state-exploded] -<<< SKIP #4133 very long one-liner with chain of infixes +class UDFRegistration private[sql] ( + functionRegistry: FunctionRegistry +) extends Logging { + def register[ + RT: TypeTag, + A1: TypeTag, + A2: TypeTag, + A3: TypeTag, + A4: TypeTag, + A5: TypeTag, + A6: TypeTag, + A7: TypeTag, + A8: TypeTag, + A9: TypeTag, + A10: TypeTag, + A11: TypeTag, + A12: TypeTag, + A13: TypeTag, + A14: TypeTag, + A15: TypeTag, + A16: TypeTag, + A17: TypeTag, + A18: TypeTag, + A19: TypeTag, + A20: TypeTag, + A21: TypeTag, + A22: TypeTag + ]( + name: String, + func: Function22[ + A1, + A2, + A3, + A4, + A5, + A6, + A7, + A8, + A9, + A10, + A11, + A12, + A13, + A14, + A15, + A16, + A17, + A18, + A19, + A20, + A21, + A22, + RT + ] + ): UserDefinedFunction = { + val inputEncoders: Seq[ + Option[ExpressionEncoder[_]] + ] = Try( + ExpressionEncoder[A1]() + ).toOption :: Try( + ExpressionEncoder[A2]() + ).toOption :: Try( + ExpressionEncoder[A3]() + ).toOption :: Try( + ExpressionEncoder[A4]() + ).toOption :: Try( + ExpressionEncoder[A5]() + ).toOption :: Try( + ExpressionEncoder[A6]() + ).toOption :: Try( + ExpressionEncoder[A7]() + ).toOption :: Try( + ExpressionEncoder[A8]() + ).toOption :: Try( + ExpressionEncoder[A9]() + ).toOption :: Try( + ExpressionEncoder[A10]() + ).toOption :: Try( + ExpressionEncoder[A11]() + ).toOption :: Try( + ExpressionEncoder[A12]() + ).toOption :: Try( + ExpressionEncoder[A13]() + ).toOption :: Try( + ExpressionEncoder[A14]() + ).toOption :: Try( + ExpressionEncoder[A15]() + ).toOption :: Try( + ExpressionEncoder[A16]() + ).toOption :: Try( + ExpressionEncoder[A17]() + ).toOption :: Try( + ExpressionEncoder[A18]() + ).toOption :: Try( + ExpressionEncoder[A19]() + ).toOption :: Try( + ExpressionEncoder[A20]() + ).toOption :: Try( + ExpressionEncoder[A21]() + ).toOption :: Try( + ExpressionEncoder[A22]() + ).toOption :: Nil + } +} +<<< #4133 very long one-liner with chain of infixes runner.maxStateVisits = 1000 === class UDFRegistration { @@ -9157,8 +9260,56 @@ class UDFRegistration { } } >>> -FormatTests:54 [e]: org.scalafmt.Error$SearchStateExploded: Search state exploded on '[43] Try∙(: Ident(Try) [277..280) [] LeftParen [280..281)', line 3: exceeded `runner.maxStateVisits`=1000 [see https://scalameta.org/scalafmt/docs/configuration.html#search-state-exploded] -<<< SKIP #4133 very long one-liner with chain of infixes, with selects +class UDFRegistration { + def foo = { + val inputEncoders + : Seq_Option_ExpressionEncoder_____ = + Try(ExpressionEncoder_A1_) :: Try( + ExpressionEncoder_A2_ + ) :: Try( + ExpressionEncoder_A3_ + ) :: Try( + ExpressionEncoder_A4_ + ) :: Try( + ExpressionEncoder_A5_ + ) :: Try( + ExpressionEncoder_A6_ + ) :: Try( + ExpressionEncoder_A7_ + ) :: Try( + ExpressionEncoder_A8_ + ) :: Try( + ExpressionEncoder_A9_ + ) :: Try( + ExpressionEncoder_A10_ + ) :: Try( + ExpressionEncoder_A11_ + ) :: Try( + ExpressionEncoder_A12_ + ) :: Try( + ExpressionEncoder_A13_ + ) :: Try( + ExpressionEncoder_A14_ + ) :: Try( + ExpressionEncoder_A15_ + ) :: Try( + ExpressionEncoder_A16_ + ) :: Try( + ExpressionEncoder_A17_ + ) :: Try( + ExpressionEncoder_A18_ + ) :: Try( + ExpressionEncoder_A19_ + ) :: Try( + ExpressionEncoder_A20_ + ) :: Try( + ExpressionEncoder_A21_ + ) :: Try( + ExpressionEncoder_A22_ + ) :: Nil + } +} +<<< #4133 very long one-liner with chain of infixes, with selects runner.maxStateVisits = 5000 === class UDFRegistration { @@ -9167,8 +9318,58 @@ class UDFRegistration { } } >>> -FormatTests:54 [e]: org.scalafmt.Error$SearchStateExploded: Search state exploded on '[77] (∙ExpressionEncoder_A10_: LeftParen [451..452) [] Ident(ExpressionEncoder_A10_) [452..474)', line 3: exceeded `runner.maxStateVisits`=5000 [see https://scalameta.org/scalafmt/docs/configuration.html#search-state-exploded] -<<< SKIP #4133 very long one-liner with chain of infixes, with select and types +class UDFRegistration { + def foo = { + val inputEncoders + : Seq_Option_ExpressionEncoder_____ = + Try( + ExpressionEncoder_A1_ + ).toOption :: Try( + ExpressionEncoder_A2_ + ).toOption :: Try( + ExpressionEncoder_A3_ + ).toOption :: Try( + ExpressionEncoder_A4_ + ).toOption :: Try( + ExpressionEncoder_A5_ + ).toOption :: Try( + ExpressionEncoder_A6_ + ).toOption :: Try( + ExpressionEncoder_A7_ + ).toOption :: Try( + ExpressionEncoder_A8_ + ).toOption :: Try( + ExpressionEncoder_A9_ + ).toOption :: Try( + ExpressionEncoder_A10_ + ).toOption :: Try( + ExpressionEncoder_A11_ + ).toOption :: Try( + ExpressionEncoder_A12_ + ).toOption :: Try( + ExpressionEncoder_A13_ + ).toOption :: Try( + ExpressionEncoder_A14_ + ).toOption :: Try( + ExpressionEncoder_A15_ + ).toOption :: Try( + ExpressionEncoder_A16_ + ).toOption :: Try( + ExpressionEncoder_A17_ + ).toOption :: Try( + ExpressionEncoder_A18_ + ).toOption :: Try( + ExpressionEncoder_A19_ + ).toOption :: Try( + ExpressionEncoder_A20_ + ).toOption :: Try( + ExpressionEncoder_A21_ + ).toOption :: Try( + ExpressionEncoder_A22_ + ).toOption :: Nil + } +} +<<< #4133 very long one-liner with chain of infixes, with select and types runner.maxStateVisits = 100000 === class UDFRegistration { @@ -9177,4 +9378,54 @@ class UDFRegistration { } } >>> -FormatTests:54 [e]: org.scalafmt.Error$SearchStateExploded: Search state exploded on '[121] ::∙Try: Ident(::) [485..487) [ ] Ident(Try) [488..491)', line 3: exceeded `runner.maxStateVisits`=100000 [see https://scalameta.org/scalafmt/docs/configuration.html#search-state-exploded] +class UDFRegistration { + def foo = { + val inputEncoders: Seq[ + Option[ExpressionEncoder[_]] + ] = Try( + ExpressionEncoder[A1] + ).toOption :: Try( + ExpressionEncoder[A2] + ).toOption :: Try( + ExpressionEncoder[A3] + ).toOption :: Try( + ExpressionEncoder[A4] + ).toOption :: Try( + ExpressionEncoder[A5] + ).toOption :: Try( + ExpressionEncoder[A6] + ).toOption :: Try( + ExpressionEncoder[A7] + ).toOption :: Try( + ExpressionEncoder[A8] + ).toOption :: Try( + ExpressionEncoder[A9] + ).toOption :: Try( + ExpressionEncoder[A10] + ).toOption :: Try( + ExpressionEncoder[A11] + ).toOption :: Try( + ExpressionEncoder[A12] + ).toOption :: Try( + ExpressionEncoder[A13] + ).toOption :: Try( + ExpressionEncoder[A14] + ).toOption :: Try( + ExpressionEncoder[A15] + ).toOption :: Try( + ExpressionEncoder[A16] + ).toOption :: Try( + ExpressionEncoder[A17] + ).toOption :: Try( + ExpressionEncoder[A18] + ).toOption :: Try( + ExpressionEncoder[A19] + ).toOption :: Try( + ExpressionEncoder[A20] + ).toOption :: Try( + ExpressionEncoder[A21] + ).toOption :: Try( + ExpressionEncoder[A22] + ).toOption :: Nil + } +} diff --git a/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces_keep.stat b/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces_keep.stat index b89fe25e00..a03f984064 100644 --- a/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces_keep.stat +++ b/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces_keep.stat @@ -6268,14 +6268,17 @@ object a: >>> object a: rootsForRelease_foreach(root => - Files.walkingIterator().useScalaFilter( - Files__Is__Directory - ).foreach { p => - val_moduleNamePathElementCount_е_0 - if (p_getNameCount_g_root_getNameCount_p_moduleNamePathElementCount) { - val_packageDotted_e_p_subpath_moduleNamePathElementCountFooRoot__p__toString_replace - index_getOrElseUpdate(packageDotted__new_collectionMutableListBuffer) - } + Files.walkingIterator().useScalaFilter(Files__Is__Directory).foreach { + p => + val_moduleNamePathElementCount_е_0 + if ( + p_getNameCount_g_root_getNameCount_p_moduleNamePathElementCount + ) { + val_packageDotted_e_p_subpath_moduleNamePathElementCountFooRoot__p__toString_replace + index_getOrElseUpdate( + packageDotted__new_collectionMutableListBuffer + ) + } } ) <<< braces to parens in one-line apply: overflow with braces, fit with parens @@ -7030,8 +7033,8 @@ object a { x14: Any, x15: Any, x16: Any, x17: Any, x18: Any) => g.asInstanceOf[Tuple18[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _] => Any].apply((x1, x2, x3, x4, x5, x6, x7, x8, x9, - x10, x11, x12, x13, x14, x15, x16, x17, x18))).asInstanceOf[ - F] + x10, x11, x12, x13, x14, x15, x16, x17, + x18))).asInstanceOf[F] ) } <<< #4133 binpack overflow assignment with selects, attributes, !dangling