Skip to content

Fix codegen of extending modules#235

Merged
HT154 merged 1 commit intoapple:mainfrom
HT154:gen-fixes-prom
Apr 14, 2026
Merged

Fix codegen of extending modules#235
HT154 merged 1 commit intoapple:mainfrom
HT154:gen-fixes-prom

Conversation

@HT154
Copy link
Copy Markdown
Contributor

@HT154 HT154 commented Apr 14, 2026

  • Fix generation of properties that are hidden by a parent module but amended without modifier in a sub-module.
  • Fix generation of types defined in extending modules only reachable via a typealias.

Resolves #233
Resolves #234

Comment on lines +23 to +25
output {
text = foo
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This triggers #233

// ===----------------------------------------------------------------------===//
@go.Package { name = "github.com/apple/pkl-go/codegen/snippet-tests/output/union" }
module union
extends "support/OpenModule.pkl"
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This triggers #234

Comment thread codegen/src/Generator.pkl

/// Generates Go sources from Pkl
@ModuleInfo { minPklVersion = "0.29.0" }
@ModuleInfo { minPklVersion = "0.30.0" }
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is required because allModifiers was introduced in Pkl 0.30

Comment on lines +49 to +51
seen.add(decl)
|> gatherTypeArguments(decl)
|> (_seen) -> gatherTypeDeclarationsFromType(decl.referent, decl, _seen)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes #234

function gatherPropertiesDeclarations(clazz: reflect.Class) = (seen: List<reflect.TypeDeclaration>) ->
clazz.properties.values
.filter((p) -> !p.modifiers.contains("hidden"))
.filter((p) -> !p.allModifiers.contains("hidden"))
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes #233

* Fix generation of properties that are hidden by a parent module but amended without modifier in a sub-module.
* Fix generation of types defined in extending modules only reachable via a typealias.
Copy link
Copy Markdown
Member

@bioball bioball left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, good fixes!

@HT154 HT154 merged commit a54af10 into apple:main Apr 14, 2026
8 checks passed
@HT154 HT154 deleted the gen-fixes-prom branch April 14, 2026 18:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Complex union types erased to any during codegen are not emitted during codegen Hidden property in parent module is generated into child types

2 participants