@@ -631,19 +631,21 @@ public J.Binary visitBinary(J.Binary binary, AtomicBoolean b) {
631631
632632 @ CsvSource (value = {
633633 // Method type on overload with no named arguments.
634- "foo(\" \" , 1, true)~openRewriteFile0Kt{name=foo,return=kotlin.Unit,parameters=[kotlin.String,kotlin.Int,kotlin.Boolean]}" ,
634+ "foo(\" \" , 1, true)~org.example. openRewriteFile0Kt{name=foo,return=kotlin.Unit,parameters=[kotlin.String,kotlin.Int,kotlin.Boolean]}" ,
635635 // Method type on overload with named arguments.
636- "foo(b = 1)~openRewriteFile0Kt{name=foo,return=kotlin.Unit,parameters=[kotlin.Int,kotlin.Boolean]}" ,
636+ "foo(b = 1)~org.example. openRewriteFile0Kt{name=foo,return=kotlin.Unit,parameters=[kotlin.Int,kotlin.Boolean]}" ,
637637 // Method type when named arguments are declared out of order.
638- "foo(trailingLambda = {}, noDefault = true, c = true, b = 1)~openRewriteFile0Kt{name=foo,return=kotlin.Unit,parameters=[kotlin.String,kotlin.Int,kotlin.Boolean,kotlin.Boolean,kotlin.Function0<kotlin.Unit>]}" ,
638+ "foo(trailingLambda = {}, noDefault = true, c = true, b = 1)~org.example. openRewriteFile0Kt{name=foo,return=kotlin.Unit,parameters=[kotlin.String,kotlin.Int,kotlin.Boolean,kotlin.Boolean,kotlin.Function0<kotlin.Unit>]}" ,
639639 // Method type with trailing lambda
640- "foo(b = 1, noDefault = true) {}~openRewriteFile0Kt{name=foo,return=kotlin.Unit,parameters=[kotlin.String,kotlin.Int,kotlin.Boolean,kotlin.Boolean,kotlin.Function0<kotlin.Unit>]}"
640+ "foo(b = 1, noDefault = true) {}~org.example. openRewriteFile0Kt{name=foo,return=kotlin.Unit,parameters=[kotlin.String,kotlin.Int,kotlin.Boolean,kotlin.Boolean,kotlin.Function0<kotlin.Unit>]}"
641641 }, delimiter = '~' )
642642 @ ParameterizedTest
643643 void methodInvocationWithDefaults (String invocation , String methodType ) {
644644 rewriteRun (
645645 kotlin (
646646 """
647+ package org.example
648+
647649 fun <T> foo(b: T, c: Boolean = true) {
648650 foo("", b, true, c) {}
649651 }
@@ -656,7 +658,7 @@ fun m() {
656658 %s
657659 }
658660 """ .formatted (invocation ), spec -> spec .afterRecipe (cu -> {
659- MethodMatcher matcher = new MethodMatcher ("* foo(..)" );
661+ MethodMatcher matcher = new MethodMatcher ("*..* foo(..)" );
660662 AtomicBoolean methodFound = new AtomicBoolean (false );
661663 new KotlinIsoVisitor <AtomicBoolean >() {
662664 @ Override
@@ -670,7 +672,14 @@ public J.MethodDeclaration visitMethodDeclaration(J.MethodDeclaration method, At
670672 @ Override
671673 public J .MethodInvocation visitMethodInvocation (J .MethodInvocation method , AtomicBoolean found ) {
672674 if (matcher .matches (method )) {
673- assertThat (method .getMethodType ().toString ()).isEqualTo (methodType );
675+ assertThat (method .getMethodType ()).satisfies (m -> {
676+ assertThat (m .toString ()).isEqualTo (methodType );
677+ assertThat (m .getDeclaringType ())
678+ .satisfies (it -> {
679+ assertThat (it .getFullyQualifiedName ()).isEqualTo ("org.example.openRewriteFile0Kt" );
680+ assertThat (it .getMethods ()).extracting (JavaType .Method ::getName ).containsExactlyInAnyOrder ("foo" , "foo" , "foo" , "m" );
681+ });
682+ });
674683 found .set (true );
675684 }
676685 return super .visitMethodInvocation (method , found );
0 commit comments