Prohibit adapted reference resolve against reflective types
There are design questions about reflection for adapted references, so the current proposal is to prohibit reflection on them and support it properly later #KT-40406 Fixed
This commit is contained in:
@@ -810,6 +810,8 @@ public interface Errors {
|
||||
|
||||
DiagnosticFactory0<PsiElement> CALLABLE_REFERENCE_TO_JAVA_SYNTHETIC_PROPERTY = DiagnosticFactory0.create(WARNING);
|
||||
|
||||
DiagnosticFactory0<PsiElement> ADAPTED_CALLABLE_REFERENCE_AGAINST_REFLECTION_TYPE = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
// Destructuring-declarations
|
||||
|
||||
DiagnosticFactory0<KtDestructuringDeclaration> INITIALIZER_REQUIRED_FOR_DESTRUCTURING_DECLARATION = DiagnosticFactory0.create(ERROR, DEFAULT);
|
||||
|
||||
+2
@@ -990,6 +990,8 @@ public class DefaultErrorMessages {
|
||||
|
||||
MAP.put(CALLABLE_REFERENCE_TO_JAVA_SYNTHETIC_PROPERTY, "References to the synthetic extension properties for a Java get/set methods aren't supported fully, please use reference to a method");
|
||||
|
||||
MAP.put(ADAPTED_CALLABLE_REFERENCE_AGAINST_REFLECTION_TYPE, "Adapted callable reference cannot be resolved against reflective types");
|
||||
|
||||
//Inline
|
||||
MAP.put(NON_PUBLIC_CALL_FROM_PUBLIC_INLINE, "Public-API inline function cannot access non-public-API ''{0}''", SHORT_NAMES_IN_TYPES, SHORT_NAMES_IN_TYPES);
|
||||
MAP.put(PRIVATE_CLASS_MEMBER_FROM_INLINE, "Non-private inline function cannot access members of private classes: ''{0}''", SHORT_NAMES_IN_TYPES, SHORT_NAMES_IN_TYPES);
|
||||
|
||||
+8
@@ -236,6 +236,14 @@ class DiagnosticReporterByTrackingStrategy(
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
AdaptedCallableReferenceIsUsedWithReflection::class.java -> {
|
||||
trace.report(
|
||||
ADAPTED_CALLABLE_REFERENCE_AGAINST_REFLECTION_TYPE.on(
|
||||
callArgument.psiCallArgument.valueArgument.asElement()
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user