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

Ensure CompilationUnitResolver.accept(...) uses right module #2300

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mickaelistria
Copy link
Contributor

Without this change, addType was always performed against the unnamed module (and some new package bindings & types were created) while it should look up on the current context module.

What it does

Fix CompilationUnitResolver so it properly resolve packages from the visible modules

How to test

I plan to provide a unit test reproducing it in a near future. Basically start from the same structure as ModuleBuilderTests.testAutoModule3 , but instead of calling getWorkingCopy("/mod.one/src/q/X.java", srcX, true), try calling ASTParser to generate the DOM CompilationUnit and check its getProblems().

Author checklist

Without this change, addType was always performed against the unnamed
module (and some new package bindings & types were created) while it
should look up on the current context module.
@mickaelistria
Copy link
Contributor Author

Marking as draft as this PR can cause some StackOverflowError on LookupEnvironment.getResolvedType()

@mickaelistria
Copy link
Contributor Author

This was an attempt to fix #2301 , which causes a StackOverflowError with the variation of ResolveTests9 as described on the issue

	public void testModuleInfo_ASTParser() throws CoreException {
		IFile providesFile = createFile("/Resolve/src/provides.java", "public class provides {}");
		IFile modInfo = null;
		try {
			getWorkingCopy(
					"/Resolve/src/test/ITest.java",
					"public interface ITest {}\n");
			getWorkingCopy(
					"/Resolve/src/test/TestClass.java",
					"public class TestClass implements ITest {}\n");

			this.wc = getWorkingCopy(
					"/Resolve/src/module-info.java",
					"module com.test {\n" +
					"  provides p1.Y with ResolveInterface;\n" +
					"}\n");

			ASTParser parser = ASTParser.newParser(AST.getJLSLatest());
			parser.setResolveBindings(true);
			parser.setProject(this.currentProject);
			parser.setSource(this.wc);
			CompilationUnit unit = (CompilationUnit) parser.createAST(null);
			assertArrayEquals(new IProblem[0], unit.getProblems());
		} finally {
			deleteResource(providesFile);
			if (modInfo != null)
				deleteResource(modInfo);
		}
	}

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.

None yet

1 participant