Skip to content

Commit dcd5bdf

Browse files
committed
Fix problem in decomposeProtoFunction
Need to strip again after dealiasing
1 parent e685926 commit dcd5bdf

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,6 +1190,10 @@ object Types {
11901190
/** Strip TypeVars and Annotation and CapturingType wrappers */
11911191
def stripped(using Context): Type = this
11921192

1193+
def strippedDealias(using Context): Type =
1194+
val tp1 = stripped.dealias
1195+
if tp1 ne this then tp1.strippedDealias else this
1196+
11931197
def rewrapAnnots(tp: Type)(using Context): Type = tp.stripTypeVar match {
11941198
case AnnotatedType(tp1, annot) => AnnotatedType(rewrapAnnots(tp1), annot)
11951199
case _ => this

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1130,7 +1130,7 @@ class Typer extends Namer
11301130
case _ => mapOver(t)
11311131
}
11321132

1133-
val pt1 = pt.stripped.dealias
1133+
val pt1 = pt.strippedDealias
11341134
if (pt1 ne pt1.dropDependentRefinement)
11351135
&& defn.isContextFunctionType(pt1.nonPrivateMember(nme.apply).info.finalResultType)
11361136
then

tests/pos-custom-args/captures/boxmap-paper.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ type Cell[+T] = [K] => (T ==> K) => K
55
def cell[T](x: T): Cell[T] =
66
[K] => (k: T ==> K) => k(x)
77

8-
def get[T](c: Cell[T]): T = c[T](identity[T]) // TODO: drop [T]
8+
def get[T](c: Cell[T]): T = c[T](identity)
99

1010
def map[A, B](c: Cell[A])(f: A ==> B): Cell[B]
1111
= c[Cell[B]]((x: A) => cell(f(x)))
@@ -32,7 +32,7 @@ def test(io: {*} IO) =
3232

3333
val r = lazyMap[{io} () => Int, Unit](c)(f => g(f))
3434
val r2 = lazyMap[{io} () => Int, Unit](c)(g)
35-
// val r3 = lazyMap(c)(g) not yet
35+
// val r3 = lazyMap(c)(g)
3636
val _ = r()
3737
val _ = r2()
3838
// val _ = r3()

0 commit comments

Comments
 (0)