Skip to content

Commit 325aff6

Browse files
committed
GROOVY-11676: object expression type in MethodClosure error message
1 parent 2e2e407 commit 325aff6

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

src/main/java/groovy/lang/MetaClassImpl.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1062,7 +1062,13 @@ private Object invokeMethodClosure(final MethodClosure closure, final Object[] a
10621062
} catch (MissingMethodException ignore) {}
10631063
}
10641064

1065-
return invokeMissingMethod(closure, method, arguments);
1065+
try {
1066+
return invokeMissingMethod(closure, method, arguments);
1067+
} catch (MissingMethodException mme) { // GROOVY-11676: owner class
1068+
mme = new MissingMethodException(method, ownerClass, arguments);
1069+
mme.addSuppressed(e);
1070+
throw mme;
1071+
}
10661072
}
10671073
}
10681074
}

src/test/groovy/bugs/MethodClosureTest.groovy

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ final class MethodClosureTest {
8181
'''
8282
}
8383

84-
// GROOVY-9140
84+
// GROOVY-9140, GROOVY-11676
8585
@Test
8686
void testMethodClosureWithoutThis() {
8787
String base = '''
@@ -96,13 +96,15 @@ final class MethodClosureTest {
9696
assert result == 11
9797
'''
9898

99-
shouldFail MissingMethodException, base + '''
99+
def err = shouldFail MissingMethodException, base + '''
100100
closure()
101101
'''
102+
assert err =~ /No signature of method: m for class: C is applicable for argument types: \(\) values: \[\]/
102103

103-
shouldFail MissingMethodException, base + '''
104+
/**/err = shouldFail MissingMethodException, base + '''
104105
closure("")
105106
'''
107+
assert err =~ /No signature of method: m for class: C is applicable for argument types: \(String\) values: \[\]/
106108
}
107109

108110
@Test

0 commit comments

Comments
 (0)