Skip to content

Commit

Permalink
Update the Groovy plugin to 4.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-milles committed Jan 27, 2022
1 parent 1a102a2 commit 4b06544
Show file tree
Hide file tree
Showing 48 changed files with 278 additions and 1,649 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ public void testTypeChecked21() {
"}\n" +
"@groovy.transform.TypeChecked\n" +
"void test() {\n" +
" this.m { Number n ->\n" +
" this." + (isAtLeastGroovy(40) ? "<Number>" : "" ) + "m { Number n ->\n" + // TODO: GROOVY-10436
" n?.toBigInteger()\n" +
" }\n" +
"}\n" +
Expand Down
3 changes: 1 addition & 2 deletions base/org.codehaus.groovy40/.checkstyle
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<file-match-pattern match-pattern="groovy/ast/expr/RangeExpression.java" include-pattern="false" />
<file-match-pattern match-pattern="groovy/ast/expr/(Static)?MethodCallExpression.java" include-pattern="false" />
<file-match-pattern match-pattern="groovy/ast/tools/(Expression|Generics)Utils.java" include-pattern="false" />
<file-match-pattern match-pattern="groovy/classgen/(Annotation|Enum|InnerClass|VariableScope)Visitor.java" include-pattern="false" />
<file-match-pattern match-pattern="groovy/classgen/(Annotation|Enum)Visitor.java" include-pattern="false" />
<file-match-pattern match-pattern="groovy/classgen/(Extended)?Verifier.java" include-pattern="false" />
<file-match-pattern match-pattern="groovy/classgen/asm/WriterController.java" include-pattern="false" />
<file-match-pattern match-pattern="groovy/classgen/asm/sc/StaticInvocationWriter.java" include-pattern="false" />
Expand All @@ -56,7 +56,6 @@
<file-match-pattern match-pattern="groovy/transform/ASTTransformationVisitor.java" include-pattern="false" />
<file-match-pattern match-pattern="groovy/transform/(Category|Field|Log|NullCheck|RecordType|Sealed|TupleConstructor)ASTTransformation.java" include-pattern="false" />
<file-match-pattern match-pattern="groovy/transform/NotYetImplemented.java" include-pattern="false" />
<file-match-pattern match-pattern="groovy/transform/sc/StaticCompilationVisitor.java" include-pattern="false" />
<file-match-pattern match-pattern="groovy/transform/sc/transformers/(Binary|MethodCall)ExpressionTransformer.java" include-pattern="false" />
<file-match-pattern match-pattern="groovy/transform/stc/StaticTypeCheckingSupport.java" include-pattern="false" />
<file-match-pattern match-pattern="groovy/transform/stc/StaticTypeCheckingVisitor.java" include-pattern="false" />
Expand Down
1 change: 1 addition & 0 deletions base/org.codehaus.groovy40/VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
2021-11-06: GROOVY_4_0_0_BETA_2
2021-11-27: GROOVY_4_0_0_RC_1
2021-12-24: GROOVY_4_0_0_RC_2
2022-01-27: GROOVY_4_0_0
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified base/org.codehaus.groovy40/lib/groovy-4.0.0-javadoc.jar
Binary file not shown.
Binary file modified base/org.codehaus.groovy40/lib/groovy-4.0.0-sources.jar
Binary file not shown.
Binary file modified base/org.codehaus.groovy40/lib/groovy-4.0.0.jar
Binary file not shown.
Binary file modified base/org.codehaus.groovy40/lib/groovy-test-4.0.0-javadoc.jar
Binary file not shown.
Binary file modified base/org.codehaus.groovy40/lib/groovy-test-4.0.0-sources.jar
Binary file not shown.
Binary file modified base/org.codehaus.groovy40/lib/groovy-test-4.0.0.jar
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -1599,6 +1599,8 @@ public ClassNode visitClassDeclaration(final ClassDeclarationContext ctx) {
.map(ClassExpression::new)
.collect(Collectors.toList()));
sealedAnnotationNode.setMember("permittedSubclasses", permittedSubclassesListExpression);
configureAST(sealedAnnotationNode, ctx.PERMITS());
sealedAnnotationNode.setNodeMetaData("permits", true);
}
classNode.addAnnotation(sealedAnnotationNode);
} else if (isNonSealed) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.codehaus.groovy.ast;

import org.apache.groovy.ast.tools.ClassNodeUtils;
import org.apache.groovy.lang.annotation.Incubating;
import org.codehaus.groovy.GroovyBugError;
import org.codehaus.groovy.ast.expr.BinaryExpression;
import org.codehaus.groovy.ast.expr.Expression;
Expand All @@ -27,7 +28,6 @@
import org.codehaus.groovy.ast.stmt.BlockStatement;
import org.codehaus.groovy.ast.stmt.ExpressionStatement;
import org.codehaus.groovy.ast.stmt.Statement;
import org.codehaus.groovy.ast.tools.ParameterUtils;
import org.codehaus.groovy.control.CompilePhase;
import org.codehaus.groovy.transform.ASTTransformation;
import org.codehaus.groovy.transform.GroovyASTTransformation;
Expand All @@ -54,6 +54,8 @@
import static org.codehaus.groovy.ast.ClassHelper.isObjectType;
import static org.codehaus.groovy.ast.ClassHelper.isPrimitiveBoolean;
import static org.codehaus.groovy.ast.ClassHelper.isPrimitiveVoid;
import static org.codehaus.groovy.ast.tools.ParameterUtils.parametersEqual;
import static org.codehaus.groovy.transform.RecordTypeASTTransformation.recordNative;
import static groovyjarjarasm.asm.Opcodes.ACC_ABSTRACT;
import static groovyjarjarasm.asm.Opcodes.ACC_ANNOTATION;
import static groovyjarjarasm.asm.Opcodes.ACC_ENUM;
Expand Down Expand Up @@ -441,15 +443,17 @@ public void setInterfaces(ClassNode[] interfaces) {
}

/**
* @return permitted subclasses of sealed type
* @return permitted subclasses of sealed type, may initially be empty in early compiler phases
*/
@Incubating
public List<ClassNode> getPermittedSubclasses() {
if (redirect != null)
return redirect.getPermittedSubclasses();
lazyClassInit();
return permittedSubclasses;
}

@Incubating
public void setPermittedSubclasses(List<ClassNode> permittedSubclasses) {
if (redirect != null) {
redirect.setPermittedSubclasses(permittedSubclasses);
Expand Down Expand Up @@ -1150,11 +1154,6 @@ protected void setCompileUnit(CompileUnit cu) {
if (compileUnit != null) compileUnit = cu;
}

@Deprecated
protected boolean parametersEqual(Parameter[] a, Parameter[] b) {
return ParameterUtils.parametersEqual(a, b);
}

public String getPackageName() {
int idx = getName().lastIndexOf('.');
if (idx > 0) {
Expand Down Expand Up @@ -1430,14 +1429,16 @@ public boolean isInterface() {

/**
* Checks if the {@link ClassNode} instance represents a native {@code record}.
* Check instead for the {@code RecordType} annotation if looking for records and record-like classes.
* Check instead for the {@code RecordBase} annotation if looking for records and
* record-like classes currently being compiled.
*
* @return {@code true} if the instance represents a native {@code record}
*
* @since 4.0.0
*/
@Incubating
public boolean isRecord() {
return getUnresolvedSuperClass() != null && "java.lang.Record".equals(getUnresolvedSuperClass().getName());
return recordNative(this);
}

/**
Expand All @@ -1447,23 +1448,20 @@ public boolean isRecord() {
*
* @since 4.0.0
*/
@Incubating
public List<RecordComponentNode> getRecordComponents() {
if (redirect != null)
return redirect.getRecordComponents();
lazyClassInit();
return recordComponents;
}

@Deprecated
public List<RecordComponentNode> getRecordComponentNodes() {
return getRecordComponents();
}

/**
* Sets the record components for record type.
*
* @since 4.0.0
*/
@Incubating
public void setRecordComponents(List<RecordComponentNode> recordComponents) {
if (redirect != null) {
redirect.setRecordComponents(recordComponents);
Expand All @@ -1472,16 +1470,19 @@ public void setRecordComponents(List<RecordComponentNode> recordComponents) {
}
}

@Deprecated
public void setRecordComponentNodes(List<RecordComponentNode> recordComponentNodes) {
setRecordComponents(recordComponentNodes);
}

public boolean isAbstract() {
return (getModifiers() & ACC_ABSTRACT) != 0;
}

/**
* @return {@code true} for native and emulated (annotation based) sealed classes
*
* @since 4.0.0
*/
@Incubating
public boolean isSealed() {
if (redirect != null) return redirect.isSealed();
lazyClassInit();
return !getAnnotations(SEALED_TYPE).isEmpty() || !getPermittedSubclasses().isEmpty();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public void setNameStart2(int i) {}
public void setPermittedSubclasses(List<ClassNode> l) {}

@Override
public void setRecordComponentNodes(List<RecordComponentNode> l) {}
public void setRecordComponents(List<RecordComponentNode> l) {}

//public void setRedirect(ClassNode cn) {}

Expand Down
Loading

0 comments on commit 4b06544

Please sign in to comment.