Skip to content

Commit 250599b

Browse files
committed
scalafmtAll
1 parent 12801ec commit 250599b

File tree

3 files changed

+28
-26
lines changed

3 files changed

+28
-26
lines changed

analyzer/src/main/scala/com/avsystem/commons/analyzer/ExplicitGenerics.scala

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ class ExplicitGenerics(g: Global) extends AnalyzerRule(g, "explicitGenerics") {
99

1010
lazy val explicitGenericsAnnotTpe = classType("com.avsystem.commons.annotation.explicitGenerics")
1111

12-
1312
private def fail(pos: Position, symbol: Symbol): Unit =
1413
report(pos, s"$symbol requires that its type arguments are explicit (not inferred)")
1514

@@ -30,7 +29,9 @@ class ExplicitGenerics(g: Global) extends AnalyzerRule(g, "explicitGenerics") {
3029
def analyzeTree(tree: Tree): Unit = analyzer.macroExpandee(tree) match {
3130
case `tree` | EmptyTree =>
3231
tree match {
33-
case t@TypeApply(pre, args) if requiresExplicitGenerics(pre.symbol) || applyOfAnnotatedCompanion(pre.symbol) =>
32+
case t @ TypeApply(pre, args)
33+
if requiresExplicitGenerics(pre.symbol) || applyOfAnnotatedCompanion(pre.symbol) =>
34+
3435
val inferredTypeParams = args.forall {
3536
case tt: TypeTree => tt.original == null || tt.original == EmptyTree
3637
case _ => false
@@ -40,12 +41,13 @@ class ExplicitGenerics(g: Global) extends AnalyzerRule(g, "explicitGenerics") {
4041
val targetSym = if (applyOfAnnotatedCompanion(pre.symbol)) pre.symbol.owner.companionClass else pre.symbol
4142
fail(t.pos, targetSym)
4243
}
43-
case n@New(tpt) if requiresExplicitGenerics(tpt.tpe.typeSymbol) =>
44+
case n @ New(tpt) if requiresExplicitGenerics(tpt.tpe.typeSymbol) =>
4445
val explicitTypeArgsProvided = tpt match {
45-
case tt: TypeTree => tt.original match {
46-
case AppliedTypeTree(_, args) if args.nonEmpty => true
47-
case _ => false
48-
}
46+
case tt: TypeTree =>
47+
tt.original match {
48+
case AppliedTypeTree(_, args) if args.nonEmpty => true
49+
case _ => false
50+
}
4951
case _ => false
5052
}
5153
if (!explicitTypeArgsProvided) {

analyzer/src/test/scala/com/avsystem/commons/analyzer/ExplicitGenericsTest.scala

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,37 +43,38 @@ final class ExplicitGenericsTest extends AnyFunSuite with AnalyzerTest {
4343
}
4444

4545
test("inferred in constructor should be rejected") {
46-
assertErrors(2,
46+
assertErrors(
47+
2,
4748
scala"""
4849
|import com.avsystem.commons.analyzer.TestUtils
4950
|
5051
|val x = new TestUtils.GenericClass()
5152
|val y = new TestUtils.GenericCaseClass(123)
52-
|""".stripMargin)
53+
|""".stripMargin,
54+
)
5355
}
5456

55-
5657
test("inferred in apply when constructor marked should be rejected") {
57-
assertErrors(1,
58+
assertErrors(
59+
1,
5860
scala"""
5961
|import com.avsystem.commons.analyzer.TestUtils
6062
|
6163
|val x = TestUtils.GenericCaseClass(123)
62-
|""".stripMargin)
64+
|""".stripMargin,
65+
)
6366
}
6467

6568
test("explicit in constructor should not be rejected") {
66-
assertNoErrors(
67-
scala"""
69+
assertNoErrors(scala"""
6870
|import com.avsystem.commons.analyzer.TestUtils
6971
|
7072
|val x = new TestUtils.GenericClass[Int]()
7173
|""".stripMargin)
7274
}
7375

7476
test("not marked should not be rejected") {
75-
assertNoErrors(
76-
scala"""
77+
assertNoErrors(scala"""
7778
|def method[T](e: T) = e
7879
|class NotMarkedGenericClass[T]
7980
|final case class NotMarkedGenericCaseClass[T](arg: T)

analyzer/src/test/scala/com/avsystem/commons/analyzer/ImplicitValueClassesTest.scala

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ final class ImplicitValueClassesSuite extends AnyFunSuite with AnalyzerTest {
1010
|implicit final class GoodImplicitClass(val x: Int) extends AnyVal {
1111
| def double: Int = x * 2
1212
|}
13-
|""".stripMargin,
13+
|""".stripMargin
1414
)
1515
}
1616

@@ -42,7 +42,7 @@ final class ImplicitValueClassesSuite extends AnyFunSuite with AnalyzerTest {
4242
|class RegularClass(val x: Int) {
4343
| def double: Int = x * 2
4444
|}
45-
|""".stripMargin,
45+
|""".stripMargin
4646
)
4747
}
4848

@@ -52,7 +52,7 @@ final class ImplicitValueClassesSuite extends AnyFunSuite with AnalyzerTest {
5252
|implicit final class ImplicitClassWithImplicitParameter(val x: Int)(implicit dummy: DummyImplicit) {
5353
| def double: Int = x * 2
5454
|}
55-
|""".stripMargin,
55+
|""".stripMargin
5656
)
5757
}
5858

@@ -69,7 +69,7 @@ final class ImplicitValueClassesSuite extends AnyFunSuite with AnalyzerTest {
6969
|implicit final class GoodImplicitClass2(val x: Int) extends SomeTrait {
7070
| def double: Int = x * 2
7171
|}
72-
|""".stripMargin,
72+
|""".stripMargin
7373
)
7474
}
7575

@@ -89,8 +89,7 @@ final class ImplicitValueClassesSuite extends AnyFunSuite with AnalyzerTest {
8989
}
9090

9191
test("nested implicit class not extending AnyVal should pass") {
92-
assertNoErrors(
93-
scala"""
92+
assertNoErrors(scala"""
9493
|class Outer {
9594
| implicit final class NestedImplicitClass(val x: Int) {
9695
| def double: Int = x * 2
@@ -105,7 +104,7 @@ final class ImplicitValueClassesSuite extends AnyFunSuite with AnalyzerTest {
105104
|implicit final class ValueClass(x: com.avsystem.commons.misc.Timestamp) {
106105
| def sth: Long = x.millis
107106
|}
108-
|""".stripMargin,
107+
|""".stripMargin
109108
)
110109
}
111110

@@ -116,7 +115,7 @@ final class ImplicitValueClassesSuite extends AnyFunSuite with AnalyzerTest {
116115
|implicit final class LazyValueClassOps(lvc: => ValueClass) {
117116
| def someOp: Int = lvc.underlying
118117
|}
119-
|""".stripMargin,
118+
|""".stripMargin
120119
)
121120
}
122121

@@ -194,7 +193,7 @@ final class NestedImplicitValueClassesSuite extends AnyFunSuite with AnalyzerTes
194193
|class RegularClass(val x: Int) {
195194
| def double: Int = x * 2
196195
|}
197-
|""".stripMargin,
196+
|""".stripMargin
198197
)
199198
}
200199

@@ -213,7 +212,7 @@ final class NestedImplicitValueClassesSuite extends AnyFunSuite with AnalyzerTes
213212
| def double: Int = x * 2
214213
| }
215214
|}
216-
|""".stripMargin,
215+
|""".stripMargin
217216
)
218217
}
219218

0 commit comments

Comments
 (0)