Community
Participate
Working Groups
(In reply to Greg Woolsey from bug 484467 comment #3) > [...] > Note that the same error happens when the Test class is moved to its own > source file in the same package. In that case, it appears the Eclipse > compiler is confusing the enum with the same name vs. the class with that > name. However, the ::new reference must be to a type, not an Enum instance, > which is how javac knows which one to reference. > > A workaround is to reference the class in the ::new constructor argument > with its fully qualified class name. Then the Eclipse compiler understands > which "Test" is being referenced. However, javac shows this is not > required, and that the source ordering used by Eclipse is not flexible > enough to handle this case and the original case for this bug. > > public enum EclipseCompileBug { > /* > * Next line fails with these errors in Eclipse, works with javac: > * <li>Test cannot be resolved to a type > * <li>Cannot reference a field before it is defined > */ > Test(Test::new); > > @FunctionalInterface > public interface IConstructor<T extends Object> { > T apply(); > } > > private final IConstructor<?> constructor; > private EclipseCompileBug (IConstructor<?> newObj) { > constructor = newObj; > } > > public static class Test { > > } > }
New Gerrit change created: https://git.eclipse.org/r/131673
(In reply to Eclipse Genie from comment #1) > New Gerrit change created: https://git.eclipse.org/r/131673 Your analysis was correct: in Name::new we should never even try to resolve Name to a variable. The parser just needs to delete one bit and all should be fine. To wit, the relevant part of the grammar in JLS ยง15.13 is: MethodReference: [...] ClassType :: [TypeArguments] new ArrayType :: new
Gerrit change https://git.eclipse.org/r/131673 was merged to [master]. Commit: http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=1d1468f56bf9e54149c9b9759e0d4e70fd0d999b
(In reply to Eclipse Genie from comment #3) > Gerrit change https://git.eclipse.org/r/131673 was merged to [master]. > Commit: > http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/ > ?id=1d1468f56bf9e54149c9b9759e0d4e70fd0d999b Released for 4.10 M3
New Gerrit change created: https://git.eclipse.org/r/132245
Verified for 4.10 M3 with build id I20181120-1800