diff --git a/jsoniter-scala-macros/shared/src/main/scala-2/com/github/plokhotnyuk/jsoniter_scala/macros/JsonCodecMaker.scala b/jsoniter-scala-macros/shared/src/main/scala-2/com/github/plokhotnyuk/jsoniter_scala/macros/JsonCodecMaker.scala index c665ea3bf..66cf43f6a 100644 --- a/jsoniter-scala-macros/shared/src/main/scala-2/com/github/plokhotnyuk/jsoniter_scala/macros/JsonCodecMaker.scala +++ b/jsoniter-scala-macros/shared/src/main/scala-2/com/github/plokhotnyuk/jsoniter_scala/macros/JsonCodecMaker.scala @@ -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 { diff --git a/jsoniter-scala-macros/shared/src/main/scala-3/com/github/plokhotnyuk/jsoniter_scala/macros/JsonCodecMaker.scala b/jsoniter-scala-macros/shared/src/main/scala-3/com/github/plokhotnyuk/jsoniter_scala/macros/JsonCodecMaker.scala index 7f793d58c..8eedea456 100644 --- a/jsoniter-scala-macros/shared/src/main/scala-3/com/github/plokhotnyuk/jsoniter_scala/macros/JsonCodecMaker.scala +++ b/jsoniter-scala-macros/shared/src/main/scala-3/com/github/plokhotnyuk/jsoniter_scala/macros/JsonCodecMaker.scala @@ -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