Skip to content

Commit abf2cde

Browse files
committed
Add tparams to constructors
1 parent 2da8a22 commit abf2cde

File tree

5 files changed

+6
-5
lines changed

5 files changed

+6
-5
lines changed

effekt/shared/src/main/scala/effekt/core/Parser.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,8 @@ class CoreParsers(names: Names) extends EffektLexers {
267267
`interface` ~> id ~ maybeTypeParams ~ (`{` ~/> many(property) <~ `}`) ^^ Declaration.Interface.apply
268268

269269
lazy val constructor: P[Constructor] =
270-
id ~ valueParams ^^ { case id ~ params => Constructor(id, params.map(p => Field(p.id, p.tpe))) }
270+
// FIXME: This should have tparams as well
271+
id ~ valueParams ^^ { case id ~ params => Constructor(id, params.map(p => Field(p.id, p.tpe)), List.empty) }
271272

272273
lazy val property: P[Property] =
273274
id ~ (`:` ~> blockType) ^^ Property.apply

effekt/shared/src/main/scala/effekt/core/PolymorphismBoxing.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ object PolymorphismBoxing extends Phase[CoreTransformed, CoreTransformed] {
9494
}
9595

9696
def transform(constructor: Constructor)(using Context, DeclarationContext): Constructor = constructor match {
97-
case Constructor(id, fields) => Constructor(id, fields map transform)
97+
case Constructor(id, fields, tparams) => Constructor(id, fields map transform, tparams)
9898
}
9999

100100
def transform(property: Property)(using Context, DeclarationContext): Property = property match {

effekt/shared/src/main/scala/effekt/core/PrettyPrinter.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ object PrettyPrinter extends ParenPrettyPrinter {
145145
}
146146

147147
def toDoc(c: Constructor): Doc = c match {
148-
case Constructor(id, fields) => toDoc(id) <> parens(fields.map(toDoc))
148+
case Constructor(id, fields, tparams) => toDoc(id) <> brackets(tparams.map(toDoc)) <> parens(fields.map(toDoc))
149149
}
150150
def toDoc(f: Field): Doc = f match {
151151
case Field(name, tpe) => toDoc(name) <> ":" <+> toDoc(tpe)

effekt/shared/src/main/scala/effekt/core/Transformer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ object Transformer extends Phase[Typechecked, CoreTransformed] {
144144
}.toList ++ exports.namespaces.values.flatMap(transform)
145145

146146
def transform(c: symbols.Constructor)(using Context): core.Constructor =
147-
core.Constructor(c, c.fields.map(f => core.Field(f, transform(f.returnType))))
147+
core.Constructor(c, c.fields.map(f => core.Field(f, transform(f.returnType))), c.tparams)
148148

149149
def transform(tree: source.Stmt)(using Context): Stmt = tree match {
150150
// { e; stmt } --> { let _ = e; stmt }

effekt/shared/src/main/scala/effekt/core/Tree.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ enum Declaration extends Tree {
123123
}
124124
export Declaration.*
125125

126-
case class Constructor(id: Id, fields: List[Field]) extends Tree
126+
case class Constructor(id: Id, fields: List[Field], tparams: List[Id]) extends Tree
127127
case class Field(id: Id, tpe: ValueType) extends Tree
128128
case class Property(id: Id, tpe: BlockType) extends Tree
129129

0 commit comments

Comments
 (0)