Skip to content

Commit

Permalink
Update scalafmt-core to 3.8.1 (#5320)
Browse files Browse the repository at this point in the history
  • Loading branch information
scala-steward authored Apr 2, 2024
1 parent 670ff32 commit 3a3df03
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ bfe19393b17710f92b61ea80e6e5f4e026ea2676

# Scala Steward: Reformat with scalafmt 3.8.0
e339d7d594db19fcb7f8909a7c1754269ccaae00

# Scala Steward: Reformat with scalafmt 3.8.1
58ff23b36468049356b0bcbcacb412c7cf149255
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "3.8.0"
version = "3.8.1"
runner.dialect = scala213

fileOverride {
Expand Down
28 changes: 20 additions & 8 deletions scalafix/rules/src/main/scala/fix/v0_14_0/FixAvroCoder.scala
Original file line number Diff line number Diff line change
Expand Up @@ -135,25 +135,36 @@ object FixAvroCoder {
def isAvroType(sym: Symbol)(implicit sd: SemanticDocument): Boolean =
AvroMatcher.matches(sym) || hasParentClass(sym, AvroMatcher)

def hasAvroTypeSignature(tree: Tree, checkLiftedType: Boolean)(implicit doc: SemanticDocument): Boolean =
def hasAvroTypeSignature(tree: Tree, checkLiftedType: Boolean)(implicit
doc: SemanticDocument
): Boolean =
tree.symbol.info.map(_.signature).exists {
case MethodSignature(_, _, TypeRef(_, returnType, _)) if !checkLiftedType && isAvroType(returnType) =>
case MethodSignature(_, _, TypeRef(_, returnType, _))
if !checkLiftedType && isAvroType(returnType) =>
true
case MethodSignature(_, _, TypeRef(_, _, List(TypeRef(_, returnType, _)))) if checkLiftedType && isAvroType(returnType) =>
case MethodSignature(_, _, TypeRef(_, _, List(TypeRef(_, returnType, _))))
if checkLiftedType && isAvroType(returnType) =>
true
case _ =>
false
}

def methodHasAvroCoderTypeBound(expr: Term)(implicit doc: SemanticDocument): Boolean =
expr.symbol.info.map(_.signature)
expr.symbol.info
.map(_.signature)
.toList
.collect { case MethodSignature(_, parameterLists, _) => parameterLists }
.flatMap(_.flatten)
.flatMap(_.symbol.info.map(_.signature).toList)
.collect { case ValueSignature(TypeRef(_, symbol, List(TypeRef(_, coderT, _)))) if CoderMatcher.matches(symbol) => coderT }
.collect {
case ValueSignature(TypeRef(_, symbol, List(TypeRef(_, coderT, _))))
if CoderMatcher.matches(symbol) =>
coderT
}
.flatMap(_.info.map(_.signature).toList)
.exists { case TypeSignature(_, _, TypeRef(_, maybeAvroType, _)) => AvroMatcher.matches(maybeAvroType) }
.exists { case TypeSignature(_, _, TypeRef(_, maybeAvroType, _)) =>
AvroMatcher.matches(maybeAvroType)
}
}

class FixAvroCoder extends SemanticRule("FixAvroCoder") {
Expand All @@ -178,8 +189,9 @@ class FixAvroCoder extends SemanticRule("FixAvroCoder") {
case q"$fn(..$args)" if ParallelizeMatcher.matches(fn) =>
args.headOption exists {
case expr if hasAvroTypeSignature(expr, true) => true
case q"$seqLike($elem)" if seqLike.symbol.value.startsWith("scala/collection/") &&
(isAvroType(elem.symbol) || hasAvroTypeSignature(elem, false)) =>
case q"$seqLike($elem)"
if seqLike.symbol.value.startsWith("scala/collection/") &&
(isAvroType(elem.symbol) || hasAvroTypeSignature(elem, false)) =>
true
case _ => false
}
Expand Down

0 comments on commit 3a3df03

Please sign in to comment.