Skip to content

Commit c496989

Browse files
authored
Merge pull request #394 from scala/backport-lts-3.3-23060
Backport "Tighten condition to preserve denotation in IntegrateMap" to 3.3 LTS
2 parents f5f9d0f + 0fe8340 commit c496989

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

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

+6-2
Original file line numberDiff line numberDiff line change
@@ -3768,8 +3768,12 @@ object Types extends TypeUtils {
37683768

37693769
override final def derivedSelect(tp: NamedType, pre: Type): Type =
37703770
if tp.prefix eq pre then tp
3771-
else if tp.symbol.exists then NamedType(pre, tp.name, tp.denot.asSeenFrom(pre))
3772-
else NamedType(pre, tp.name)
3771+
else
3772+
pre match
3773+
case ref: ParamRef if (ref.binder eq self) && tp.symbol.exists =>
3774+
NamedType(pre, tp.name, tp.denot.asSeenFrom(pre))
3775+
case _ =>
3776+
tp.derivedSelect(pre)
37733777

37743778
final def derivedLambdaType(paramNames: List[ThisName] = this.paramNames,
37753779
paramInfos: List[PInfo] = this.paramInfos,

tests/pos/23056.scala

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
def Test = {
2+
val ops: CompileOps[Option, Option, Any] = ???
3+
ops.to(List).map(_.reverse) // error
4+
}
5+
6+
trait CompileOps[F[_], G[_], O]:
7+
def to(collector: Collector[O]): G[collector.Out]
8+
trait Collector[-A] {
9+
type Out
10+
}
11+
12+
object Collector:
13+
type Aux[A, X] = Collector[A] { type Out = X }
14+
15+
given [A, C[_]]: Conversion[
16+
scala.collection.IterableFactory[C],
17+
Collector.Aux[A, C[A]]
18+
] = ???

0 commit comments

Comments
 (0)