Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update scalafmt-core to 3.8.1 #5320

Merged
merged 3 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading