|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2023 the original author or authors. |
| 2 | + * Copyright 2002-2025 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
@@ -41,36 +41,34 @@ public class KotlinReflectionParameterNameDiscoverer implements ParameterNameDis
|
41 | 41 |
|
42 | 42 | @Override
|
43 | 43 | public @Nullable String @Nullable [] getParameterNames(Method method) {
|
44 |
| - if (!KotlinDetector.isKotlinType(method.getDeclaringClass())) { |
45 |
| - return null; |
46 |
| - } |
47 |
| - |
48 |
| - try { |
49 |
| - KFunction<?> function = ReflectJvmMapping.getKotlinFunction(method); |
50 |
| - return (function != null ? getParameterNames(function.getParameters()) : null); |
51 |
| - } |
52 |
| - catch (UnsupportedOperationException ex) { |
53 |
| - return null; |
| 44 | + if (KotlinDetector.isKotlinType(method.getDeclaringClass())) { |
| 45 | + try { |
| 46 | + KFunction<?> function = ReflectJvmMapping.getKotlinFunction(method); |
| 47 | + return (function != null ? getParameterNames(function.getParameters()) : null); |
| 48 | + } |
| 49 | + catch (UnsupportedOperationException ignored) { |
| 50 | + } |
54 | 51 | }
|
| 52 | + return null; |
55 | 53 | }
|
56 | 54 |
|
57 | 55 | @Override
|
58 | 56 | public @Nullable String @Nullable [] getParameterNames(Constructor<?> ctor) {
|
59 |
| - if (ctor.getDeclaringClass().isEnum() || !KotlinDetector.isKotlinType(ctor.getDeclaringClass())) { |
60 |
| - return null; |
61 |
| - } |
62 |
| - |
63 |
| - try { |
64 |
| - KFunction<?> function = ReflectJvmMapping.getKotlinFunction(ctor); |
65 |
| - return (function != null ? getParameterNames(function.getParameters()) : null); |
66 |
| - } |
67 |
| - catch (UnsupportedOperationException ex) { |
68 |
| - return null; |
| 57 | + if (!ctor.getDeclaringClass().isEnum() && KotlinDetector.isKotlinType(ctor.getDeclaringClass())) { |
| 58 | + try { |
| 59 | + KFunction<?> function = ReflectJvmMapping.getKotlinFunction(ctor); |
| 60 | + if (function != null) { |
| 61 | + return getParameterNames(function.getParameters()); |
| 62 | + } |
| 63 | + } |
| 64 | + catch (UnsupportedOperationException ignored) { |
| 65 | + } |
69 | 66 | }
|
| 67 | + return null; |
70 | 68 | }
|
71 | 69 |
|
72 | 70 | private @Nullable String @Nullable [] getParameterNames(List<KParameter> parameters) {
|
73 |
| - String[] parameterNames = parameters.stream() |
| 71 | + @Nullable String[] parameterNames = parameters.stream() |
74 | 72 | // Extension receivers of extension methods must be included as they appear as normal method parameters in Java
|
75 | 73 | .filter(p -> KParameter.Kind.VALUE.equals(p.getKind()) || KParameter.Kind.EXTENSION_RECEIVER.equals(p.getKind()))
|
76 | 74 | // extension receivers are not explicitly named, but require a name for Java interoperability
|
|
0 commit comments