Skip to content

Commit 8fffa3f

Browse files
author
Oron Port
committed
limit design paramter generation only for designs
1 parent caf4b6e commit 8fffa3f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

plugin/src/main/scala/plugin/MetaContextPlacerPhase.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class MetaContextPlacerPhase(setting: Setting) extends CommonPhase:
4343
var dfSpecTpe: Type = uninitialized
4444
var hasClsMetaArgsTpe: TypeRef = uninitialized
4545
var clsMetaArgsTpe: TypeRef = uninitialized
46+
var designTpe: TypeRef = uninitialized
4647
var topAnnotSym: ClassSymbol = uninitialized
4748
var appTpe: TypeRef = uninitialized
4849
var noTopAnnotIsRequired: TypeRef = uninitialized
@@ -143,12 +144,12 @@ class MetaContextPlacerPhase(setting: Setting) extends CommonPhase:
143144
}
144145
val nonParamBody = template.body.drop(paramBody.length)
145146
val (updatedBody, designParamGenValDefs) = dfcArgOpt match
146-
case Some(dfcTree) =>
147+
case Some(dfcTree) if clsTpe <:< designTpe =>
147148
val defaults = defaultParamMap.getOrElse(clsSym, Map.empty)
148149
genDesignBodyParams(nonParamBody, paramBody, defaults, dfcTree)(using
149150
ctx.withOwner(clsSym.primaryConstructor)
150151
)
151-
case None => (nonParamBody, Nil)
152+
case _ => (nonParamBody, Nil)
152153
// TODO: The override does not seem to be actually used by the runtime,
153154
// probably because it's selected during the typer stage and needs to be
154155
// changed somehow to reference the new overridden tree symbol.
@@ -298,6 +299,7 @@ class MetaContextPlacerPhase(setting: Setting) extends CommonPhase:
298299
dfSpecTpe = requiredClassRef("dfhdl.DFSpec")
299300
hasClsMetaArgsTpe = requiredClassRef("dfhdl.internals.HasClsMetaArgs")
300301
clsMetaArgsTpe = requiredClassRef("dfhdl.internals.ClsMetaArgs")
302+
designTpe = requiredClassRef("dfhdl.core.Design")
301303
topAnnotSym = requiredClass("dfhdl.top")
302304
appTpe = requiredClassRef("dfhdl.app.DFApp")
303305
noTopAnnotIsRequired = requiredClassRef("dfhdl.internals.NoTopAnnotIsRequired")

0 commit comments

Comments
 (0)