Skip to content

Commit

Permalink
Code clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
plokhotnyuk committed Jun 1, 2024
1 parent 753efb9 commit de9bb01
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -624,14 +624,9 @@ object JsonCodecMaker {

def isSealedClass(tpe: Type): Boolean = tpe.typeSymbol.isClass && tpe.typeSymbol.asClass.isSealed

def hasSealedParent(tpe: Type): Boolean = {
if (!tpe.typeSymbol.isClass) false
else {
val classSymbol = tpe.typeSymbol.asClass
classSymbol.isSealed || classSymbol.baseClasses.exists { baseClassSymbol =>
baseClassSymbol.isClass && baseClassSymbol.asClass.isSealed
}
}
def hasSealedParent(tpe: Type): Boolean = tpe.typeSymbol.isClass && {
val classSymbol = tpe.typeSymbol.asClass
classSymbol.isSealed || classSymbol.baseClasses.exists(s => s.isClass && s.asClass.isSealed)
}

def isConstType(tpe: Type): Boolean = tpe match {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -764,14 +764,8 @@ object JsonCodecMaker {

def isSealedClass(tpe: TypeRepr): Boolean = tpe.typeSymbol.flags.is(Flags.Sealed)

def hasSealedParent(tpe: TypeRepr): Boolean = {
if (isSealedClass(tpe)) true
else {
tpe.baseClasses.exists { baseClassSymbol =>
baseClassSymbol.flags.is(Flags.Sealed)
}
}
}
def hasSealedParent(tpe: TypeRepr): Boolean =
isSealedClass(tpe) || tpe.baseClasses.exists(_.flags.is(Flags.Sealed))

def isConstType(tpe: TypeRepr): Boolean = tpe match
case ConstantType(_) => true
Expand Down

0 comments on commit de9bb01

Please sign in to comment.