Skip to content

Commit 334dffd

Browse files
committed
Properly type bounds of wildcards in hk positions
Typing a TypeBoundsTree(Empty, Empty) leads to a TypeBoundsTree(Nothing, Any), if this tree appears in a higher-kinded position, we manually set its type, but we don't change the upper bound which is still "Any" and ends up being pickled. To avoid this issue this commit simply replaces the TypeBoundsTree with a synthetic TypeTree with the proper type and position, which is all that we need.
1 parent 8ac046d commit 334dffd

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,7 +1290,6 @@ class Typer extends Namer
12901290
case _ =>
12911291
}
12921292
if (desugaredArg.isType) {
1293-
var res = typed(desugaredArg, argPt)
12941293
arg match {
12951294
case TypeBoundsTree(EmptyTree, EmptyTree)
12961295
if tparam.paramInfo.isLambdaSub &&
@@ -1302,10 +1301,10 @@ class Typer extends Namer
13021301
// type parameter in `C`.
13031302
// The transform does not apply for patterns, where empty bounds translate to
13041303
// wildcard identifiers `_` instead.
1305-
res = res.withType(tparamBounds)
1304+
TypeTree(tparamBounds).withPos(arg.pos)
13061305
case _ =>
1306+
typed(desugaredArg, argPt)
13071307
}
1308-
res
13091308
}
13101309
else desugaredArg.withType(UnspecifiedErrorType)
13111310
}

compiler/test/dotc/pos-test-pickling.blacklist

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ i1867.scala
55
i3067.scala
66
i3149.scala
77
i3692.scala
8-
i3976.scala
98
i4125.scala
109
implicit-dep.scala
1110
inline-access-levels

0 commit comments

Comments
 (0)