Skip to content

Commit

Permalink
Eclipse 4.33 (RC1) JDT Patch for Groovy-Eclipse
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-milles committed Aug 28, 2024
1 parent 5fe06aa commit bbeb404
Show file tree
Hide file tree
Showing 9 changed files with 114 additions and 8 deletions.
2 changes: 1 addition & 1 deletion groovy-eclipse.setup
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@
<repository
url="https://download.eclipse.org/eclipse/updates/4.33"/>
<repository
url="https://download.eclipse.org/eclipse/updates/4.33-I-builds/I20240815-1810"/>
url="https://download.eclipse.org/eclipse/updates/4.33-I-builds/I20240822-0100"/>
</repositoryList>
<repositoryList
name="2024-06">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</license>

<requires>
<import feature="org.eclipse.jdt" version="3.19.600.v20240815-2038" patch="true"/>
<import feature="org.eclipse.jdt" version="3.19.600.v20240822-0459" patch="true"/>
</requires>

<plugin
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*******************************************************************************
* Copyright (c) 2024 Kamil Krzywanski and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Kamil Krzywanski - initial creation if Interesection type and Implementation
*******************************************************************************/

package org.eclipse.jdt.internal.compiler.apt.model;

import org.eclipse.jdt.internal.compiler.apt.dispatch.BaseProcessingEnvImpl;
import org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding;

import javax.lang.model.type.IntersectionType;
import javax.lang.model.type.TypeKind;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.type.TypeVisitor;
import java.util.Arrays;
import java.util.List;

/**
* Implementation of the WildcardType
*/
public class IntersectionTypeImpl extends TypeMirrorImpl implements IntersectionType {
private final List<? extends TypeMirror> bounds;

IntersectionTypeImpl(BaseProcessingEnvImpl env, TypeVariableBinding binding) {
super(env, binding);
this.bounds = Arrays.stream(binding.superInterfaces).map(referenceBinding -> this._env.getFactory().newTypeMirror(referenceBinding)).toList();
}

/* (non-Javadoc)
* @see javax.lang.model.type.TypeMirror#getKind()
*/
@Override
public TypeKind getKind() {
return TypeKind.INTERSECTION;
}
/* (non-Javadoc)
* @see javax.lang.model.type.WildcardType#getSuperBound()
*/
@Override
public <R, P> R accept(TypeVisitor<R, P> v, P p) {
return v.visitIntersection(this, p);
}

/* (non-Javadoc)
* @see javax.lang.model.type.IntersectionType#getBounds()
*/
@Override
public List<? extends TypeMirror> getBounds() {
return this.bounds;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ public TypeMirror getUpperBound() {
// only one bound that is an interface
return this._env.getFactory().newTypeMirror(typeVariableBinding.upperBound());
}
if (superInterfaces.length > 1) {
return new IntersectionTypeImpl(this._env, typeVariableBinding);
}

return this._env.getFactory().newTypeMirror(this._binding);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -541,9 +541,10 @@ public TypeBinding resolveType(BlockScope scope) {

protected boolean isMissingTypeRelevant() {
if (this.binding != null && this.binding.isVarargs()) {
if (this.arguments.length < this.binding.parameters.length) {
int argLen = this.arguments != null ? this.arguments.length : 0;
if (argLen < this.binding.parameters.length) {
// are all but the irrelevant varargs type present?
for (int i = 0; i < this.arguments.length; i++) {
for (int i = 0; i < argLen; i++) {
if ((this.binding.parameters[i].tagBits & TagBits.HasMissingType) != 0)
return true; // this one *is* relevant - actually this case is already detected during findConstructorBinding()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1119,9 +1119,10 @@ protected boolean isMissingTypeRelevant() {
}
if ((this.binding.returnType.tagBits & TagBits.HasMissingType) == 0
&& this.binding.isVarargs()) {
if (this.arguments.length < this.binding.parameters.length) {
int argLen = this.arguments != null ? this.arguments.length : 0;
if (argLen < this.binding.parameters.length) {
// are all but the irrelevant varargs type present?
for (int i = 0; i < this.arguments.length; i++) {
for (int i = 0; i < argLen; i++) {
if ((this.binding.parameters[i].tagBits & TagBits.HasMissingType) != 0)
return true; // this one *is* relevant - actually this case is already detected during findMethodBinding()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ public void test007() {
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=123096"
*/
public void test008() {
this.sourceLevel = CompilerOptions.VERSION_1_3;
this.sourceLevel = CompilerOptions.getFirstSupportedJavaVersion();
String source = "package javadoc;\n" +
"/**\n" +
" * Completion on empty tag name:\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9702,6 +9702,46 @@ The constructor B(A, String...) refers to the missing type A
""";
runner.runNegativeTest();
}
public void testMissingClass_varargs4_noArg() {
// missing type in non-varargs position
if (this.complianceLevel < ClassFileConstants.JDK1_8) return; // ignore different outcome below 1.8 since PR 2543
Runner runner = new Runner();
runner.testFiles = new String[] {
"p1/A.java",
"""
package p1;
public class A {}
""",
"p1/B.java",
"""
package p1;
public class B {
public B(A... a) {}
public void m(A... a) {}
}
"""
};
runner.runConformTest();

// delete binary file A (i.e. simulate removing it from classpath for subsequent compile)
Util.delete(new File(OUTPUT_DIR, "p1" + File.separator + "A.class"));
runner.shouldFlushOutputDirectory = false;

runner.testFiles = new String[] {
"p2/C.java",
"""
package p2;
import p1.B;
public class C {
void test(B b) {
new B();
b.m();
}
}
"""
};
runner.runConformTest();
}
public void testMissingClass_returnType_OK() {
if (this.complianceLevel < ClassFileConstants.JDK1_8) return; // ignore different outcome below 1.8 since PR 2543
Runner runner = new Runner();
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
<repository>
<id>milestone</id>
<layout>p2</layout>
<url>https://download.eclipse.org/eclipse/updates/4.33-I-builds/I20240815-1810</url>
<url>https://download.eclipse.org/eclipse/updates/4.33-I-builds/I20240822-0100</url>
</repository>
</repositories>
<modules>
Expand Down

0 comments on commit bbeb404

Please sign in to comment.