Skip to content

Commit c34ac1c

Browse files
committed
Make parameter types of synthesized context functions inferred type trees
A non-sensical capture reference appeared in the type of a synthesized context function literal. We do clean out @retains annotations that can contain such references, but only for inferred type trees. The problem was that context function parameters were treated like explicitly given types before. Fixes #20135
1 parent 9d990fb commit c34ac1c

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3271,7 +3271,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
32713271
val paramTypes = {
32723272
val hasWildcard = formals.exists(_.existsPart(_.isInstanceOf[WildcardType], StopAt.Static))
32733273
if hasWildcard then formals.map(_ => untpd.TypeTree())
3274-
else formals.map(formal => untpd.TypeTree(formal.loBound)) // about loBound, see tests/pos/i18649.scala
3274+
else formals.map(formal => untpd.InferredTypeTree(formal.loBound)) // about loBound, see tests/pos/i18649.scala
32753275
}
32763276

32773277
val erasedParams = pt match {

tests/pos/i20135.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import language.experimental.captureChecking
2+
3+
class Network
4+
5+
class Page(using nw: Network^):
6+
def render(client: Page^{nw} ?-> Unit) = client(using this)
7+
8+
def main(net: Network^) =
9+
var page = Page(using net)
10+
page.render(())
11+

0 commit comments

Comments
 (0)