Skip to content

Commit

Permalink
Update a few comments
Browse files Browse the repository at this point in the history
  • Loading branch information
K-Phoen committed Sep 19, 2023
1 parent c7b2fd9 commit 0d72d26
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion internal/ast/compiler/disjunctions.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func (pass *DisjunctionToType) processDisjunction(file *ast.File, def ast.Disjun
return ast.Type{}, err
}

structType.Struct.Hint[ast.HintDiscriminatedDisjunctionOfStructs] = newDisjunctionDef
structType.Struct.Hint[ast.HintDiscriminatedDisjunctionOfRefs] = newDisjunctionDef
}

pass.newObjects[newTypeName] = ast.Object{
Expand Down
6 changes: 3 additions & 3 deletions internal/ast/compiler/disjunctions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ func TestDisjunctionToType_WithDisjunctionOfRefs_AsAnObject_NoDiscriminatorMetad
"OtherStruct": "other-struct",
"SomeStruct": "some-struct",
}
disjunctionStructType.Struct.Hint[ast.HintDiscriminatedDisjunctionOfStructs] = disjunctionTypeWithDiscriminatorMeta
disjunctionStructType.Struct.Hint[ast.HintDiscriminatedDisjunctionOfRefs] = disjunctionTypeWithDiscriminatorMeta

expectedObjects := []ast.Object{
ast.NewObject("ADisjunctionOfRefs", ast.NewRef("SomeStructOrOtherStruct")),
Expand Down Expand Up @@ -330,7 +330,7 @@ func TestDisjunctionToType_WithDisjunctionOfRefs_AsAnObject_WithDiscriminatorFie
"OtherStruct": "other-kind",
"SomeStruct": "some-kind",
}
disjunctionStructType.Struct.Hint[ast.HintDiscriminatedDisjunctionOfStructs] = disjunctionTypeWithDiscriminatorMeta
disjunctionStructType.Struct.Hint[ast.HintDiscriminatedDisjunctionOfRefs] = disjunctionTypeWithDiscriminatorMeta

expectedObjects := []ast.Object{
ast.NewObject("ADisjunctionOfRefs", ast.NewRef("SomeStructOrOtherStruct")),
Expand Down Expand Up @@ -385,7 +385,7 @@ func TestDisjunctionToType_WithDisjunctionOfRefs_AsAnObject_WithDiscriminatorFie
"OtherStruct": "other-kind",
"SomeStruct": "some-kind",
}
disjunctionStructType.Struct.Hint[ast.HintDiscriminatedDisjunctionOfStructs] = disjunctionTypeWithDiscriminatorMeta
disjunctionStructType.Struct.Hint[ast.HintDiscriminatedDisjunctionOfRefs] = disjunctionTypeWithDiscriminatorMeta

expectedObjects := []ast.Object{
ast.NewObject("ADisjunctionOfRefs", ast.NewRef("SomeStructOrOtherStruct")),
Expand Down
4 changes: 2 additions & 2 deletions internal/ast/hints.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ const (
// original definition of which is associated to this hint.
HintDisjunctionOfScalars JennyHint = "disjunction_of_scalars"

// HintDiscriminatedDisjunctionOfStructs indicates that the struct was
// HintDiscriminatedDisjunctionOfRefs indicates that the struct was
// previously represented in the IR by a disjunction of a fixed list of
// references to structs, the original definition of which is associated
// to this hint.
HintDiscriminatedDisjunctionOfStructs JennyHint = "disjunction_of_structs"
HintDiscriminatedDisjunctionOfRefs JennyHint = "disjunction_of_refs"
)
6 changes: 3 additions & 3 deletions internal/ast/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,9 @@ func (types Types) NonNullTypes() Types {
type DisjunctionType struct {
Branches Types

// If the branches are structs, some languages will need extra context to
// be able to distinguish between them. Golang, for example, doesn't support
// sum types (disjunctions of fixed types).
// If the branches are references to structs, some languages will need
// extra context to be able to distinguish between them. Golang, for
// example, doesn't support sum types (disjunctions of fixed types).
// To emulate sum types for these languages, we need a way to
// discriminate against every possible type.
//
Expand Down
4 changes: 2 additions & 2 deletions internal/jennies/golang/rawtypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ func (jenny RawTypes) jsonMarshalVeneer(def ast.Object) (string, error) {
})
}

if hintVal, ok := structType.Hint[ast.HintDiscriminatedDisjunctionOfStructs]; ok {
return jenny.renderVeneerTemplate("disjunction_of_structs.types.json_marshal.go.tmpl", map[string]any{
if hintVal, ok := structType.Hint[ast.HintDiscriminatedDisjunctionOfRefs]; ok {
return jenny.renderVeneerTemplate("disjunction_of_refs.types.json_marshal.go.tmpl", map[string]any{
"def": def,
"hint": hintVal,
})
Expand Down

0 comments on commit 0d72d26

Please sign in to comment.