Skip to content

Commit

Permalink
Merge pull request #15894 from dotty-staging/fix-15845
Browse files Browse the repository at this point in the history
Fix swapKey
  • Loading branch information
odersky authored Aug 23, 2022
2 parents e52afc7 + 6a74d4d commit 3ad97df
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
4 changes: 3 additions & 1 deletion compiler/src/dotty/tools/dotc/core/OrderingConstraint.scala
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,9 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
(this.typeVarOfParam(tl.paramRefs(0)) ne that.typeVarOfParam(tl.paramRefs(0)))

def subst(from: TypeLambda, to: TypeLambda)(using Context): OrderingConstraint =
def swapKey[T](m: ArrayValuedMap[T]) = m.remove(from).updated(to, m(from).nn)
def swapKey[T](m: ArrayValuedMap[T]) =
val info = m(from)
if info == null then m else m.remove(from).updated(to, info)
var current = newConstraint(swapKey(boundsMap), swapKey(lowerMap), swapKey(upperMap))
def subst[T <: Type](x: T): T = x.subst(from, to).asInstanceOf[T]
current.foreachParam {(p, i) =>
Expand Down
11 changes: 11 additions & 0 deletions tests/pos/i15845/config/State.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package config

import state._

object State {

object Info {
def apply(): Info = Info(Config(), Seq.empty)
}
case class Info(cfg: AnyRef, allTypes: Seq[AnyRef])
}
4 changes: 4 additions & 0 deletions tests/pos/i15845/config/state/Config.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package config
package state

case class Config(simulations: Seq[(String, Any)] = Seq.empty)

0 comments on commit 3ad97df

Please sign in to comment.