Skip to content

Commit

Permalink
Pick right type parameters in TreeUnpickler
Browse files Browse the repository at this point in the history
  • Loading branch information
odersky committed Jul 29, 2021
1 parent d958644 commit 73d6e1e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
5 changes: 4 additions & 1 deletion compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -864,9 +864,12 @@ class TreeUnpickler(reader: TastyReader,
override def completerTypeParams(sym: Symbol)(using Context) =
rhs.tpe.typeParams
}
val tparamSyms = rhs match
case LambdaTypeTree(tparams, body) => tparams.map(_.symbol.asType)
case _ => Nil
sym.info = sym.opaqueToBounds(
checkNonCyclic(sym, rhs.tpe.toBounds, reportErrors = false),
rhs, rhs.tpe.typeParams)
rhs, tparamSyms)
if sym.isOpaqueAlias then sym.typeRef.recomputeDenot() // make sure we see the new bounds from now on
sym.resetFlag(Provisional)
TypeDef(rhs)
Expand Down
3 changes: 3 additions & 0 deletions tests/pos/i13190/A_1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
object Opaque {
opaque type FieldType[K, +V] <: V = V
}
15 changes: 15 additions & 0 deletions tests/pos/i13190/B_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import Opaque.*

object Test {
type FindField[R <: scala.Tuple, K] = R match {
case FieldType[K, f] *: t => f
case _ *: t => FindField[t, K]
}

val f: FieldType["A", Int] = ???
val f1: Int = f
//val f2: Int = f

type R = FieldType["A", Int] *: FieldType["B", Double] *: FieldType["C", String] *: FieldType["D", Boolean] *: EmptyTuple
summon[FindField[R, "B"] =:= Double]
}

0 comments on commit 73d6e1e

Please # to comment.