Prohibit callable references to object members
To be able to make them more useful in the future, i.e. bound to the object instance
This commit is contained in:
@@ -501,6 +501,7 @@ public interface Errors {
|
||||
DiagnosticFactory1<JetExpression, CallableMemberDescriptor> EXTENSION_IN_CLASS_REFERENCE_NOT_ALLOWED = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory0<JetExpression> CALLABLE_REFERENCE_LHS_NOT_A_CLASS = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetExpression> CALLABLE_REFERENCE_TO_MEMBER_OR_EXTENSION_WITH_EMPTY_LHS = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetExpression> CALLABLE_REFERENCE_TO_OBJECT_MEMBER = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<JetExpression> CLASS_LITERAL_LHS_NOT_A_CLASS = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetExpression> ARRAY_CLASS_LITERAL_REQUIRES_ARGUMENT = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
+1
@@ -675,6 +675,7 @@ public class DefaultErrorMessages {
|
||||
MAP.put(CALLABLE_REFERENCE_TO_MEMBER_OR_EXTENSION_WITH_EMPTY_LHS,
|
||||
"Left-hand side of a callable reference with a receiver parameter cannot be empty. " +
|
||||
"Please specify the type of the receiver before '::' explicitly");
|
||||
MAP.put(CALLABLE_REFERENCE_TO_OBJECT_MEMBER, "Callable references to object members are not supported");
|
||||
|
||||
MAP.put(CLASS_LITERAL_LHS_NOT_A_CLASS, "Only classes are allowed on the left hand side of a class literal");
|
||||
MAP.put(ARRAY_CLASS_LITERAL_REQUIRES_ARGUMENT, "kotlin.Array class literal requires a type argument, please specify one in angle brackets");
|
||||
|
||||
+4
@@ -696,6 +696,10 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
context.trace.report(CALLABLE_REFERENCE_TO_MEMBER_OR_EXTENSION_WITH_EMPTY_LHS.on(reference));
|
||||
}
|
||||
|
||||
if (DescriptorUtils.isObject(descriptor.getContainingDeclaration())) {
|
||||
context.trace.report(CALLABLE_REFERENCE_TO_OBJECT_MEMBER.on(reference));
|
||||
}
|
||||
|
||||
return CallableReferencesPackage.createReflectionTypeForResolvedCallableReference(expression, descriptor, context, components.reflectionTypes);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user