Skip to content

Commit 80321e5

Browse files
committed
refactor: replace any with interface{} in class implementation
Update type annotations in class-related files to use `interface{}` instead of `any`, maintaining consistent type handling across the implementation
1 parent d00bfe7 commit 80321e5

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

internal/lox/class.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ func (c *UserClass) String() string {
1717
}
1818

1919
// Call is the operation that executes a class constructor
20-
func (c *UserClass) Call(arguments []any, globalEnv *Environment, stdout io.Writer, stderr io.Writer) (any, error) {
21-
instance := &UserClassInstance{Class: c, fields: make(map[string]any)}
20+
func (c *UserClass) Call(arguments []interface{}, globalEnv *Environment, stdout io.Writer, stderr io.Writer) (interface{}, error) {
21+
instance := &UserClassInstance{Class: c, fields: make(map[string]interface{})}
2222
if initializer, ok := c.Methods["init"]; ok {
2323
_, err := initializer.Bind(instance).Call(arguments, globalEnv, stdout, stderr)
2424
if err != nil {
@@ -41,15 +41,15 @@ func (c *UserClass) Arity() int {
4141
// UserClassInstance is a user defined class instance
4242
type UserClassInstance struct {
4343
Class *UserClass
44-
fields map[string]any
44+
fields map[string]interface{}
4545
}
4646

4747
func (c *UserClassInstance) String() string {
4848
return fmt.Sprintf("%s instance", c.Class.Name)
4949
}
5050

5151
// Get accesses the property
52-
func (c *UserClassInstance) Get(name Token) (any, error) {
52+
func (c *UserClassInstance) Get(name Token) (interface{}, error) {
5353
if v, ok := c.fields[name.Lexeme]; ok {
5454
return v, nil
5555
}
@@ -61,7 +61,7 @@ func (c *UserClassInstance) Get(name Token) (any, error) {
6161
}
6262

6363
// Set accesses the property
64-
func (c *UserClassInstance) Set(name Token, value any) (any, error) {
64+
func (c *UserClassInstance) Set(name Token, value interface{}) (interface{}, error) {
6565
c.fields[name.Lexeme] = value
6666
return nil, nil
6767
}

0 commit comments

Comments
 (0)