Skip to content

Commit

Permalink
Do not include function-type properties in codegen
Browse files Browse the repository at this point in the history
  • Loading branch information
jasongwartz committed Apr 14, 2024
1 parent cafb579 commit 2d043e3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions codegen/snippet-tests/input/04-withClass.pkl
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
class MyCustomClass {
x: String
y: Int

// Function type properties should not be included in codegen
funcType: (String) -> (String)
}

value: MyCustomClass
Expand Down
4 changes: 2 additions & 2 deletions codegen/src/internal/ClassGen.pkl
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ function getFields(
clazz.properties
.filter((propName, prop: reflect.Property) ->
let (superProp = superProperties.findOrNull((it) -> it.name == prop.name))
// don't render hidden members
if (prop.modifiers.contains("hidden")) false
// don't render hidden members or functions
if (prop.modifiers.contains("hidden") || prop.type is reflect.FunctionType) false
// Okay if there is no property override, or if the super property has the same type.
else if (superProp == null || isSameType(superProp.type, prop.type) || isCompatibleType(superProp.type, prop.type)) true
// Okay if the property is overridden but does not define a type, but don't render as its own field.
Expand Down

0 comments on commit 2d043e3

Please sign in to comment.