-
Notifications
You must be signed in to change notification settings - Fork 320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Xtend: fixed strange error message for void
as a field type
#2879
Conversation
Of course, it fails until #2878 is merged |
dbb6705
to
c457611
Compare
@szarnekow I rebased the PR, which is now ready to review |
if (isPrimitiveVoid(declaredFieldType)) { | ||
error("Primitive void cannot be a dependency.", dep.getType(), null, INVALID_USE_OF_TYPE); | ||
error("void is an invalid type for the field " + field.getName(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that the message was take from JDT. In Xbase, we use
@Check
public void checkTypeReferenceIsNotVoid(XExpression expression) {
for (EObject eObject : expression.eContents()) {
if (eObject instanceof JvmTypeReference) {
JvmTypeReference typeRef = (JvmTypeReference) eObject;
if (isPrimitiveVoid(typeRef)) {
if (typeRef.eClass() == TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE) {
if (!((JvmParameterizedTypeReference) typeRef).getArguments().isEmpty()) {
continue;
}
}
error("Primitive void cannot be used here.", typeRef, null, INVALID_USE_OF_TYPE);
}
}
}
}
and in common.types
protected void checkNotPrimitive(JvmTypeReference jvmTypeReference) {
if (primitives.isPrimitive(jvmTypeReference)) {
error("The primitive '"+jvmTypeReference.getQualifiedName('.')+"' cannot be a type argument", jvmTypeReference, null, IssueCodes.INVALID_USE_OF_TYPE);
}
}
All not super aligned with each other. Maybe keep it somewhat consistent and use Primitive void is an invalid type for the field ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@szarnekow OK, I'll change it to Primitive void is an invalid type for the field
and then merge it, OK?
@szarnekow , I checked other points in the XtendValidator: @Check
public void checkXtendParameterNotPrimitiveVoid(XtendParameter param) {
if (isPrimitiveVoid(param.getParameterType())) {
XtendFunction function = (XtendFunction) (param.eContainer() instanceof XtendFunction ? param.eContainer()
: null);
if (function != null)
error("void is an invalid type for the parameter " + param.getName() + " of the method "
+ function.getName(), param.getParameterType(), null, INVALID_USE_OF_TYPE);
else
error("void is an invalid type for the parameter " + param.getName(), param.getParameterType(), null,
INVALID_USE_OF_TYPE);
}
} we always use that form "void is an invalid type for..." also in other parts: So, shall I leave it like that? |
Closes #2877