You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
a single-type import of a differentFoo (other.Foo),
Spoon resolves the simple name Foo in implements Foo to the same-package class, not to the imported type.
This contradicts JLS 6.4.1: a single-type-import of n shadows a top-level type named n declared in another compilation unit of the same package.
We hit this in noclasspath mode (Spoon 11.5.1-beta-5). The imported interface is often not in the model (external jar). Spoon still binds implements Foo to the same-package class, so getTypeDeclaration() is non-null and looks like a successful resolve.
Related: Problem with qualified names of CtTypeReference when using setNoClasspath(true) #465 (noclasspath implements / parameters not tied to imports). This case is sharper: a same-package class steals the binding, so callers cannot tell the resolve failed.
Spoon: 11.5.1-beta-5 (fr.inria.gforge.spoon:spoon-core)
Mode: setNoClasspath(true), empty sourceClasspath, setShouldCompile(false)
JDK used to run Spoon: 17+ (sources under analysis are Java 8)
Describe the bug
When a compilation unit has:
Foo, andFoo(other.Foo),Spoon resolves the simple name
Fooinimplements Footo the same-package class, not to the imported type.This contradicts JLS 6.4.1: a single-type-import of
nshadows a top-level type namedndeclared in another compilation unit of the same package.We hit this in
noclasspathmode (Spoon11.5.1-beta-5). The imported interface is often not in the model (external jar). Spoon still bindsimplements Footo the same-package class, sogetTypeDeclaration()is non-null and looks like a successful resolve.Related: Problem with qualified names of CtTypeReference when using setNoClasspath(true) #465 (noclasspath
implements/ parameters not tied to imports). This case is sharper: a same-package class steals the binding, so callers cannot tell the resolve failed.Source code you are trying to analyze/transform
Source code for your Spoon processing
Actual output
Expected output
Spoon Version
Spoon: 11.5.1-beta-5 (fr.inria.gforge.spoon:spoon-core)
Mode: setNoClasspath(true), empty sourceClasspath, setShouldCompile(false)
JDK used to run Spoon: 17+ (sources under analysis are Java 8)
JVM Version
17
What operating system are you using?
macOS