Skip to content

Commit 46c63e5

Browse files
committed
Fix #9404: Make sure to keep arguments of structural calls typed
The arguments lost their types previously, which made a TypeTree with type Int regress to a TypeTree without type.
1 parent 89f42f4 commit 46c63e5

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

compiler/src/dotty/tools/dotc/report.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ object report:
9393
*/
9494
def log(msg: => String, pos: SourcePosition = NoSourcePosition)(using Context): Unit =
9595
if (ctx.settings.Ylog.value.containsPhase(ctx.phase))
96-
echo(s"[log $ctx.phase] $msg", pos)
96+
echo(s"[log ${ctx.phase}] $msg", pos)
9797

9898
def debuglog(msg: => String)(using Context): Unit =
9999
if (ctx.debug) log(msg)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ trait Dynamic {
168168

169169
val scall =
170170
if (vargss.isEmpty) base
171-
else untpd.Apply(base, vargss.flatten)
171+
else untpd.Apply(base, vargss.flatten.map(untpd.TypedSplice(_)))
172172

173173
// If function is an `applyDynamic` that takes a ClassTag* parameter,
174174
// add `ctags`.

tests/run/i9404.scala

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import scala.reflect.Selectable.reflectiveSelectable
2+
3+
object Test {
4+
def main(args: Array[String]): Unit = {
5+
class Foo {
6+
def makeInt: Int = 5
7+
def testInt(x: Int): Unit = assert(5 == x)
8+
9+
def makeRef: Option[String] = Some("hi")
10+
def testRef(x: Option[String]): Unit = assert(Some("hi") == x)
11+
}
12+
13+
def test(foo: {
14+
def makeInt: Int
15+
def testInt(x: Int): Unit
16+
def makeRef: Option[String]
17+
def testRef(x: Option[String]): Unit
18+
}): Unit = {
19+
foo.testInt(foo.makeInt)
20+
// ^
21+
// cannot infer type; expected type <?> is not fully defined
22+
foo.testRef(foo.makeRef)
23+
// ^
24+
// cannot infer type; expected type <?> is not fully defined
25+
}
26+
27+
test(new Foo)
28+
}
29+
}

0 commit comments

Comments
 (0)