Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix swapKey #15894

Merged
merged 2 commits into from
Aug 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)