@@ -1235,17 +1235,17 @@ object DFVal extends DFValLP:
12351235 transparent inline def as (inline aliasType : DFType .Supported )(using DFCG ): DFValAny =
12361236 exactOp2[" as" , DFC , DFValAny ](lhs, aliasType)
12371237 end extension
1238- extension (inline lhs : Any )
1239- transparent inline def <~> (inline rhs : Any )(using DFC ): Any =
1238+ extension [ L ] (inline lhs : L )
1239+ transparent inline def <~> [ R ] (inline rhs : R )(using DFC ): Any =
12401240 // operator `<>` as a constructor is unidirectional
12411241 // operator `<>` as a connection is bidirectional and commutative
12421242 // TODO: possibly use match on lhs and rhs together fixing scalac issue
12431243 // https://github.com/scala/scala3/issues/24076
12441244 inline lhs match
1245- case lhs : DFVal [lt, lm] => rhs match
1245+ case lhs : DFValAny => rhs match
12461246 // if both LHS and RHS are DFVals, we call `specialConnect` to handle possible
12471247 // connection in either direction where both implicit directions are available
1248- case rhs : DFVal [rt, rm] => ConnectOps .specialConnect(lhs, rhs)
1248+ case rhs : DFValAny => ConnectOps .specialConnect(lhs, rhs)
12491249 // otherwise, we invoke the implicit given operation in both directions by turning
12501250 // on the bothWays flag for all other cases
12511251 case _ => exactOp2[" <>" , DFC , Any ](lhs, rhs, bothWays = true )
@@ -1536,50 +1536,52 @@ object ConnectOps:
15361536 ]
15371537 protected type ConnectableModifier [M <: ModifierAny ] =
15381538 M <:< Modifier [Any , Modifier .Connectable , Any , Any ]
1539- protected trait TC_Connect [CT <: DFTypeAny , CM <: ModifierAny , Producer <: DFValAny ]:
1540- def connect (consumer : DFVal [ CT , CM ] , producer : Producer )(using DFC ): Unit
1539+ protected trait TC_Connect [Consumer <: DFValAny , Producer <: DFValAny ]:
1540+ def connect (consumer : Consumer , producer : Producer )(using DFC ): Unit
15411541 protected object TC_Connect :
1542- given [CT <: DFTypeAny , CM <: ModifierAny , Producer <: DFValAny ](using
1542+ given [
1543+ CT <: DFTypeAny ,
1544+ CM <: ModifierAny ,
1545+ Consumer <: DFVal [CT , CM ],
1546+ Producer <: DFValAny
1547+ ](using
15431548 ConnectableModifier [CM ]
1544- )(using tc : DFVal .TC [CT , Producer ]): TC_Connect [CT , CM , Producer ] with
1545- def connect (consumer : DFVal [ CT , CM ] , producer : Producer )(using DFC ): Unit =
1549+ )(using tc : DFVal .TC [CT , Producer ]): TC_Connect [Consumer , Producer ] with
1550+ def connect (consumer : Consumer , producer : Producer )(using DFC ): Unit =
15461551 consumer.connect(tc(consumer.dfType, producer))
15471552
15481553 private [core] transparent inline def specialConnect [
1549- LT <: DFTypeAny ,
1550- LM <: ModifierAny ,
1551- RT <: DFTypeAny ,
1552- RM <: ModifierAny ,
1553- L <: DFVal [LT , LM ],
1554- R <: DFVal [RT , RM ]
1554+ L <: DFValAny ,
1555+ R <: DFValAny
15551556 ](
15561557 inline lhs : L ,
15571558 inline rhs : R
15581559 )(using DFC ): Unit =
1559- inline val connectableL = inline (compiletime.erasedValue[ LM ]) match
1560- case _ : Modifier [Any , Modifier .Connectable , Any , Any ] => true
1561- case _ => false
1562- inline val connectableR = inline (compiletime.erasedValue[ RM ]) match
1563- case _ : Modifier [Any , Modifier .Connectable , Any , Any ] => true
1564- case _ => false
1560+ inline val connectableL = inline lhs match
1561+ case _ : DFVal [ DFTypeAny , Modifier [Any , Modifier .Connectable , Any , Any ] ] => true
1562+ case _ => false
1563+ inline val connectableR = inline rhs match
1564+ case _ : DFVal [ DFTypeAny , Modifier [Any , Modifier .Connectable , Any , Any ] ] => true
1565+ case _ => false
15651566 inline if (connectableL || connectableR)
1566- inline if (IsGiven [TC_Connect [LT , LM , R ]])
1567- val tcL = compiletime.summonInline[TC_Connect [LT , LM , R ]]
1568- inline if (IsGiven [TC_Connect [RT , RM , L ]])
1569- val tcR = compiletime.summonInline[TC_Connect [RT , RM , L ]]
1567+ inline if (IsGiven [TC_Connect [L , R ]])
1568+ val tcL = compiletime.summonInline[TC_Connect [L , R ]]
1569+ inline if (IsGiven [TC_Connect [R , L ]])
1570+ val tcR = compiletime.summonInline[TC_Connect [R , L ]]
15701571 // since we have both candidates, we try the RHS first, so if both fail at runtime,
15711572 // the error message will be from the LHS as fallback.
15721573 try tcR.connect(rhs, lhs)
15731574 catch case e : Throwable => tcL.connect(lhs, rhs)
15741575 else tcL.connect(lhs, rhs)
1575- else if (IsGiven [TC_Connect [RT , RM , L ]])
1576- compiletime.summonInline[TC_Connect [RT , RM , L ]].connect(rhs, lhs)
1576+ else if (IsGiven [TC_Connect [R , L ]])
1577+ compiletime.summonInline[TC_Connect [R , L ]].connect(rhs, lhs)
15771578 else
15781579 // forcing the error message from the LHS case
1579- compiletime.summonInline[TC_Connect [LT , LM , R ]]
1580+ compiletime.summonInline[TC_Connect [L , R ]]
15801581 else compiletime.error(
15811582 " At least one of the connection arguments must be a connectable DFHDL value (var/port)."
15821583 )
1584+ end if
15831585 end specialConnect
15841586
15851587 given evConnectPort [
0 commit comments