Skip to content

Commit bfc8a0d

Browse files
authored
Make parameter types of context functions inferred type trees (#20155)
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
2 parents ff52a47 + c34ac1c commit bfc8a0d

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

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

+1-1
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

+11
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)