File tree Expand file tree Collapse file tree 3 files changed +45
-1
lines changed 
src/main/kotlin/com/squareup/kotlinpoet/ksp 
test-processor/src/test/kotlin/com/squareup/kotlinpoet/ksp/test/processor Expand file tree Collapse file tree 3 files changed +45
-1
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ Change Log
55
66*  ** Fix** : Don't expand typealiases of function types to ` LambdaTypeName ` s in ` KSTypeReference.toTypeName() ` .
77*  ** Fix** : Small double and float values were set to 0.0 in %L translation (#1919  )
8+ *  ** Fix** : Fix typealias type argument resolution in KSP2.
89*  ** Enhancement** : Make enum entry references in ` KSAnnotation.toAnnotationSpec() `  and ` KSClassDeclaration.toClassName() `  more robust.
910*  Migrate ` kotlinpoet-metadata `  to stable ` org.jetbrains.kotlin:kotlin-metadata-jvm `  artifact for Metadata parsing.
1011*  Promote ` kotlinpoet-metadata `  out of preview to stable.
Original file line number Diff line number Diff line change @@ -199,6 +199,6 @@ public fun KSTypeReference.toTypeName(
199199 returnType =  elem.returnType.toTypeName(typeParamResolver),
200200 ).copy(nullable =  type.isMarkedNullable, suspending =  type.isSuspendFunctionType)
201201 } else  {
202-  type.toTypeName(typeParamResolver, element?.typeArguments.orEmpty() )
202+  type.toTypeName(typeParamResolver, type.arguments )
203203 }
204204}
Original file line number Diff line number Diff line change @@ -911,6 +911,49 @@ class TestProcessorTest(private val useKsp2: Boolean) {
911911 )
912912 }
913913
914+  @Test
915+  fun  complexAliasing () {
916+  val  compilation =  prepareCompilation(
917+  kotlin(
918+  " Example.kt"  ,
919+  """ 
920+  package test 
921+ 
922+  import javax.inject.Provider 
923+  import com.squareup.kotlinpoet.ksp.test.processor.ExampleAnnotation 
924+ 
925+  typealias DaggerProvider<T> = @JvmSuppressWildcards Provider<T> 
926+  interface SelectOptions 
927+  interface SelectHandler<T> 
928+ 
929+  @ExampleAnnotation 
930+  class Example( 
931+  private val handlers: Map<Class<out SelectOptions>, DaggerProvider<SelectHandler<*>>>, 
932+  ) 
933+  """  ,
934+  ),
935+  )
936+ 
937+  val  result =  compilation.compile()
938+  assertThat(result.exitCode).isEqualTo(KotlinCompilation .ExitCode .OK )
939+  val  generatedFileText =  File (compilation.kspSourcesDir, " kotlin/test/TestExample.kt"  )
940+  .readText()
941+ 
942+  assertThat(generatedFileText).isEqualTo(
943+  """ 
944+  package test 
945+ 
946+  import java.lang.Class 
947+  import kotlin.collections.Map 
948+ 
949+  public class TestExample { 
950+  private val handlers: Map<Class<out SelectOptions>, DaggerProvider<SelectHandler<*>>> = TODO() 
951+  } 
952+ 
953+  """  .trimIndent(),
954+  )
955+  }
956+ 
914957 private  fun  prepareCompilation (vararg  sourceFiles :  SourceFile ): KotlinCompilation  {
915958 return  KotlinCompilation ()
916959 .apply  {
                                 You can’t perform that action at this time. 
               
                  
0 commit comments