Skip to content
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

Merged
merged 1 commit into from
Jan 1, 2024

Conversation

LorenzoBettini
Copy link
Contributor

Closes #2877

@LorenzoBettini LorenzoBettini added this to the Release_2.34 milestone Dec 20, 2023
@LorenzoBettini
Copy link
Contributor Author

Of course, it fails until #2878 is merged

@LorenzoBettini
Copy link
Contributor Author

@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(),
Copy link
Contributor

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 ...

Copy link
Contributor Author

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?

@LorenzoBettini
Copy link
Contributor Author

@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:

image

So, shall I leave it like that?

@LorenzoBettini LorenzoBettini merged commit da2e5b8 into main Jan 1, 2024
9 checks passed
@LorenzoBettini LorenzoBettini deleted the lb_2877 branch January 1, 2024 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Xtend: Strange error message for void as a field type
2 participants