Skip to content

Commit a24f1c7

Browse files
committed
GROOVY-11998: Better support of intersection types (copilot review)
1 parent 9d5fd19 commit a24f1c7

18 files changed

Lines changed: 33 additions & 35 deletions

File tree

ARCHITECTURE.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,17 @@ and exposed as the
6363
[`CompilePhase`](src/main/java/org/codehaus/groovy/control/CompilePhase.java)
6464
enum that AST transformations and customizers attach to:
6565

66-
| # | Phase | What happens | Driver classes |
67-
|---|---|---|---|
68-
| 1 | `INITIALIZATION` | Source files opened, `CompilationUnit` configured, customizers applied | `CompilationUnit`, `CompilerConfiguration` |
69-
| 2 | `PARSING` | ANTLR4 lexer + parser produce a CST (parse tree) | `Antlr4ParserPlugin`, `GroovyLangLexer`, `GroovyLangParser` |
70-
| 3 | `CONVERSION` | CST → AST (`ModuleNode` / `ClassNode` / `MethodNode` / ...) | `AstBuilder` |
71-
| 4 | `SEMANTIC_ANALYSIS` | Class resolution, import handling, validity checks the grammar can't catch | `ResolveVisitor`, `StaticImportVisitor`, `AnnotationConstantsVisitor` |
72-
| 5 | `CANONICALIZATION` | Fill in the AST: synthesised members, generic types, most local AST transforms run here | `ASTTransformationVisitor`, `GenericsVisitor` |
66+
| # | Phase | What happens | Driver classes |
67+
|---|---|-----------------------------------------------------------------------------------------|---|
68+
| 1 | `INITIALIZATION` | Source files opened, `CompilationUnit` configured, customizers applied | `CompilationUnit`, `CompilerConfiguration` |
69+
| 2 | `PARSING` | ANTLR4 lexer + parser produce a CST (parse tree) | `Antlr4ParserPlugin`, `GroovyLangLexer`, `GroovyLangParser` |
70+
| 3 | `CONVERSION` | CST → AST (`ModuleNode` / `ClassNode` / `MethodNode` / ...) | `AstBuilder` |
71+
| 4 | `SEMANTIC_ANALYSIS` | Class resolution, import handling, validity checks the grammar can't catch | `ResolveVisitor`, `StaticImportVisitor`, `AnnotationConstantsVisitor` |
72+
| 5 | `CANONICALIZATION` | Fill in the AST: synthesized members, generic types, most local AST transforms run here | `ASTTransformationVisitor`, `GenericsVisitor` |
7373
| 6 | `INSTRUCTION_SELECTION` | Optimisations and instruction-set selection; `@CompileStatic` / `@TypeChecked` run here | `OptimizerVisitor`, `StaticTypeCheckingVisitor` |
74-
| 7 | `CLASS_GENERATION` | AST → bytecode in memory | `AsmClassGenerator`, `Verifier`, classes under `classgen/asm/` |
75-
| 8 | `OUTPUT` | Write generated `.class` files | `CompilationUnit` output stage |
76-
| 9 | `FINALIZATION` | Cleanup, `Janitor` callbacks | `CompilationUnit`, `Janitor` |
74+
| 7 | `CLASS_GENERATION` | AST → bytecode in memory | `AsmClassGenerator`, `Verifier`, classes under `classgen/asm/` |
75+
| 8 | `OUTPUT` | Write generated `.class` files | `CompilationUnit` output stage |
76+
| 9 | `FINALIZATION` | Cleanup, `Janitor` callbacks | `CompilationUnit`, `Janitor` |
7777

7878
Each phase iterates over all `SourceUnit`s before the next phase
7979
begins. AST transformations declare which phase they run in; the
@@ -140,7 +140,7 @@ verbatim keeps the reference precise; paraphrasing tends to drift.
140140

141141
- `org.codehaus.groovy.classgen.AsmClassGenerator` walks the AST and
142142
emits bytecode via ASM. Supporting visitors run here too:
143-
`Verifier` (synthesises bridge methods, accessors, default
143+
`Verifier` (synthesizes bridge methods, accessors, default
144144
constructors), `EnumVisitor`, `EnumCompletionVisitor`,
145145
`InnerClassVisitor`, `InnerClassCompletionVisitor`,
146146
`VariableScopeVisitor`, `ReturnAdder`.

src/main/java/org/codehaus/groovy/ast/IntersectionTypeClassNode.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
*
3636
* <p>Distinct from the implicit lowest-upper-bound nodes that
3737
* {@link org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor}
38-
* synthesises during inference: an instance of this class records the ordered
38+
* synthesizes during inference: an instance of this class records the ordered
3939
* list of components exactly as written by the user. That ordering is needed
4040
* for cast-conversion checks, error messages and (in later phases) bytecode
4141
* generation via {@code LambdaMetafactory.altMetafactory} markers.
@@ -48,7 +48,7 @@
4848
* interfaces array contains only interface components and the superclass is
4949
* the (at most one) class component.
5050
*
51-
* @since 5.0.0
51+
* @since 6.0.0
5252
*/
5353
public final class IntersectionTypeClassNode extends ClassNode {
5454

src/main/java/org/codehaus/groovy/classgen/asm/sc/AbstractFunctionalInterfaceWriter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ default void writeFunctionalInterfaceIndy(final MethodVisitor methodVisitor,
9090
* {@code LambdaMetafactory.altMetafactory} via {@code FLAG_MARKERS} so the
9191
* generated lambda implements every component interface at runtime.
9292
*
93-
* @since 5.0.0
93+
* @since 6.0.0
9494
*/
9595
default void writeFunctionalInterfaceIndy(final MethodVisitor methodVisitor,
9696
final String samMethodName, final String invokedTypeDescriptor,

src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesClosureWriter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ private static void addIntersectionMarkers(final ClassNode closureClass, final C
9090
if (closureClass.implementsInterface(marker)) continue;
9191
// Only add interfaces with no abstract methods (true markers). For
9292
// interfaces that declare unimplemented abstract methods, we'd
93-
// have to synthesise method bodies — out of scope here, fall back
93+
// have to synthesize method bodies — out of scope here, fall back
9494
// to the runtime proxy path in IntersectionCastSupport.asType.
9595
if (hasAbstractMethods(marker)) continue;
9696
closureClass.addInterface(marker);

src/main/java/org/codehaus/groovy/runtime/IntersectionCastSupport.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
* reference (those cases are handled at compile time via
3636
* {@code LambdaMetafactory.altMetafactory} markers).
3737
*
38-
* @since 5.0.0
38+
* @since 6.0.0
3939
*/
4040
public final class IntersectionCastSupport {
4141

src/main/java/org/codehaus/groovy/tools/javac/JavaStubGenerator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ private void printField(final PrintWriter out, final FieldNode field, final bool
542542
}
543543

544544
private void printMethods(final PrintWriter out, final ClassNode classNode, final boolean isEnum, final boolean isRecordStub) {
545-
// For native record stubs, let javac auto-synthesise the canonical
545+
// For native record stubs, let javac auto-synthesize the canonical
546546
// constructor; we cannot reliably emit a placeholder body that
547547
// satisfies record component definite-assignment rules. Non-canonical
548548
// user-declared constructors are not visible in the stub (known

src/main/java/org/codehaus/groovy/transform/RecordBaseASTStubber.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
* <p><b>Native records.</b> When the class would compile as a native JVM
9595
* record (target {@code >= JDK16} and {@code mode != EMULATE}), the stub
9696
* generator already renders {@code record Foo(...)} syntax via the
97-
* back-channel introduced by GROOVY-11974, and {@code javac} synthesises
97+
* back-channel introduced by GROOVY-11974, and {@code javac} synthesizes
9898
* the canonical constructor and component accessors itself. This stubber
9999
* detects that case via
100100
* {@link RecordTypeASTTransformation#wouldBeNativeRecord} and bails out;

src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1628,7 +1628,7 @@ private boolean checkRestAssignability(final Expression restExpr, final ClassNod
16281628
}
16291629

16301630
/**
1631-
* Build a synthesised ListExpression of {@code rhs.getAt(i)} accesses, one per LHS slot,
1631+
* Build a synthesized ListExpression of {@code rhs.getAt(i)} accesses, one per LHS slot,
16321632
* tagged with the inferred element type. Used by {@link #typeCheckMultipleAssignmentPositional}
16331633
* when the RHS isn't a literal list/range/Tuple-typed expression. Returns the original
16341634
* RHS unchanged if its static type doesn't support {@code getAt(int)}.

src/spec/doc/core-differences-java.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ or other marker interfaces, just like in Java:
244244
245245
[source,groovy]
246246
----
247-
Runnable r = (Runnable & Serializable) () -> println('hi') // serialisable lambda
247+
Runnable r = (Runnable & Serializable) () -> println('hi') // serializable lambda
248248
----
249249
250250
Groovy additionally accepts the `as` form, where parentheses are required around

src/spec/doc/core-semantics.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,7 @@ include::../test/CoercionTest.groovy[tags=intersection_as_coercion_marker,indent
793793
----
794794
795795
For closure literals and maps, `as` builds a
796-
{@link groovy.util.ProxyGenerator} aggregate that implements every interface
796+
`groovy.util.ProxyGenerator` aggregate that implements every interface
797797
component:
798798
799799
[source,groovy]

0 commit comments

Comments
 (0)