Skip to content

Commit 3ad97df

Browse files
authored
Merge pull request #15894 from dotty-staging/fix-15845
Fix swapKey
2 parents e52afc7 + 6a74d4d commit 3ad97df

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

compiler/src/dotty/tools/dotc/core/OrderingConstraint.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,9 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
498498
(this.typeVarOfParam(tl.paramRefs(0)) ne that.typeVarOfParam(tl.paramRefs(0)))
499499

500500
def subst(from: TypeLambda, to: TypeLambda)(using Context): OrderingConstraint =
501-
def swapKey[T](m: ArrayValuedMap[T]) = m.remove(from).updated(to, m(from).nn)
501+
def swapKey[T](m: ArrayValuedMap[T]) =
502+
val info = m(from)
503+
if info == null then m else m.remove(from).updated(to, info)
502504
var current = newConstraint(swapKey(boundsMap), swapKey(lowerMap), swapKey(upperMap))
503505
def subst[T <: Type](x: T): T = x.subst(from, to).asInstanceOf[T]
504506
current.foreachParam {(p, i) =>

tests/pos/i15845/config/State.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package config
2+
3+
import state._
4+
5+
object State {
6+
7+
object Info {
8+
def apply(): Info = Info(Config(), Seq.empty)
9+
}
10+
case class Info(cfg: AnyRef, allTypes: Seq[AnyRef])
11+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package config
2+
package state
3+
4+
case class Config(simulations: Seq[(String, Any)] = Seq.empty)

0 commit comments

Comments
 (0)