From f560001ce8a0702977240f60e48aae0d6a4b70af Mon Sep 17 00:00:00 2001 From: Rikard Pavelic Date: Sun, 23 Jul 2023 14:12:45 +0200 Subject: [PATCH] Minor tweaks Improved guard/conversion for generics --- .../com/dslplatform/json/processor/Analysis.java | 16 +++++++++++----- scala/build.sbt | 4 ++-- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/library/src/main/java/com/dslplatform/json/processor/Analysis.java b/library/src/main/java/com/dslplatform/json/processor/Analysis.java index 45cdeeac..d7a6f09a 100644 --- a/library/src/main/java/com/dslplatform/json/processor/Analysis.java +++ b/library/src/main/java/com/dslplatform/json/processor/Analysis.java @@ -1121,12 +1121,18 @@ static TypeMirror unpackType(TypeMirror type, Types types) { } if (type instanceof DeclaredType) { DeclaredType dt = (DeclaredType) type; - List args = new ArrayList<>(2); - for (TypeMirror a : dt.getTypeArguments()) { - args.add(unpackType(a, types)); + TypeElement te = type instanceof TypeElement + ? (TypeElement) type + : dt.asElement() instanceof TypeElement + ? (TypeElement) dt.asElement() + : null; + if (te != null) { + List args = new ArrayList<>(2); + for (TypeMirror a : dt.getTypeArguments()) { + args.add(unpackType(a, types)); + } + return types.getDeclaredType(te, args.toArray(new TypeMirror[0])); } - TypeElement te = (TypeElement) dt.asElement(); - return types.getDeclaredType(te, args.toArray(new TypeMirror[0])); } Element el = types.asElement(type); if (el != null) { diff --git a/scala/build.sbt b/scala/build.sbt index b27b29aa..de749357 100644 --- a/scala/build.sbt +++ b/scala/build.sbt @@ -1,9 +1,9 @@ lazy val root = (project in file(".") settings (commonSettings ++ publishSettings) settings( - version := "2.0.1", + version := "2.0.2", libraryDependencies ++= Seq( - "com.dslplatform" % "dsl-json" % "2.0.1", + "com.dslplatform" % "dsl-json" % "2.0.2", "org.scala-lang" % "scala-reflect" % scalaVersion.value, "org.specs2" %% "specs2-scalacheck" % "4.5.1" % Test, "javax.json.bind" % "javax.json.bind-api" % "1.0" % Test