File tree 3 files changed +11
-2
lines changed
compiler/src/dotty/tools/dotc/typer
3 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -1106,12 +1106,13 @@ trait Applications extends Compatibility {
1106
1106
}
1107
1107
app
1108
1108
}
1109
- app1 match {
1109
+ val app2 = app1 match {
1110
1110
case Apply (Block (stats, fn), args) =>
1111
1111
tpd.cpy.Block (app1)(stats, tpd.cpy.Apply (app1)(fn, args))
1112
1112
case _ =>
1113
1113
app1
1114
1114
}
1115
+ ConstFold (app2)
1115
1116
}
1116
1117
1117
1118
/** Typecheck an Apply node with a typed function and possibly-typed arguments coming from `proto` */
Original file line number Diff line number Diff line change @@ -4129,7 +4129,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
4129
4129
4130
4130
def adaptToSubType (wtp : Type ): Tree =
4131
4131
// try converting a constant to the target type
4132
- ConstFold ( tree) .tpe.widenTermRefExpr.normalized match
4132
+ tree.tpe.widenTermRefExpr.normalized match
4133
4133
case ConstantType (x) =>
4134
4134
val converted = x.convertTo(pt)
4135
4135
if converted != null && (converted ne x) then
Original file line number Diff line number Diff line change @@ -15,4 +15,12 @@ object Test extends App {
15
15
Console .println(A .y);
16
16
Console .println(A .z);
17
17
Console .println(A .s);
18
+
19
+ def f (x : 12 ): Int = 1
20
+ def f (x : Int ): Double = 2
21
+ val x = f(12 )
22
+ val _: Int = x
23
+ val y = f(2 * 6 )
24
+ val _: Int = x
25
+
18
26
}
You can’t perform that action at this time.
0 commit comments