Skip to content

Commit dd65812

Browse files
Make generated Kotlin classes internal
There are two reasons for this. The first is that there's no reason for these to be public. They are consumed entirely in the current compilation unit, and there's no reason for external code to ever reference these. This comes up when working in a large Spring/Micronaut project where smaller modules act as libraries to a final aggregate. The other reason to do this is that by making this classes public, it prevents them from being used with data classes that the developer declared as internal. The compiler will complain that the generated code exposes an internal class in a public API.
1 parent e8d474c commit dd65812

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

jte-kotlin/src/main/java/gg/jte/compiler/kotlin/KotlinCodeGenerator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public void onParam(String parameter) {
8787

8888
private void writeClass() {
8989
kotlinCode.append("@Suppress(\"UNCHECKED_CAST\", \"UNUSED_PARAMETER\")").append('\n');
90-
kotlinCode.append("class ").append(classInfo.className).append(" {\n");
90+
kotlinCode.append("internal class ").append(classInfo.className).append(" {\n");
9191
kotlinCode.append("companion object {\n");
9292
fieldsMarker = kotlinCode.getMarkerOfCurrentPosition();
9393
kotlinCode.append("\t@JvmStatic fun render(");

0 commit comments

Comments
 (0)