Skip to content

Commit

Permalink
Compute ClassSymbol's arity directly from the tree
Browse files Browse the repository at this point in the history
  • Loading branch information
chengluyu authored and LPTK committed Nov 15, 2024
1 parent bddb9d5 commit 1cf5a60
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions hkmc2/shared/src/main/scala/hkmc2/semantics/Symbol.scala
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,7 @@ class ClassSymbol(val tree: Tree.TypeDef, val id: Tree.Ident)
def toLoc: Option[Loc] = id.toLoc // TODO track source tree of classe here
override def toString: Str = s"class:$nme"
/** Compute the arity. */
def arity: Int = defn match
case S(d) => d.paramsOpt.fold(0)(_.length)
case N => tree.paramLists.headOption.fold(0)(_.fields.length)
def arity: Int = tree.paramLists.headOption.fold(0)(_.fields.length)

class ModuleSymbol(val tree: Tree.TypeDef, val id: Tree.Ident)
extends MemberSymbol[ModuleDef] with CtorSymbol with InnerSymbol:
Expand Down

0 comments on commit 1cf5a60

Please sign in to comment.