Skip to content

Commit cd3e7e3

Browse files
committed
Bump Tasty version
Also, polishing and new test
1 parent 8800d74 commit cd3e7e3

File tree

3 files changed

+39
-2
lines changed

3 files changed

+39
-2
lines changed

compiler/src/dotty/tools/dotc/core/tasty/TastyFormat.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ Standard Section: "Positions" Assoc*
226226
object TastyFormat {
227227

228228
final val header = Array(0x5C, 0xA1, 0xAB, 0x1F)
229-
val MajorVersion = 8
229+
val MajorVersion = 9
230230
val MinorVersion = 0
231231

232232
/** Tags used to serialize names */

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ class Inliner(call: tpd.Tree, rhs: tpd.Tree)(implicit ctx: Context) {
230230
private def paramBindingDef(name: Name, paramtp: Type, arg: Tree,
231231
bindingsBuf: mutable.ListBuffer[ValOrDefDef]): ValOrDefDef = {
232232
val argtpe = arg.tpe.dealias
233-
def isByName = paramtp.dealias.isInstanceOf[ExprType]
233+
val isByName = paramtp.dealias.isInstanceOf[ExprType]
234234
val inlineFlag = if (paramtp.hasAnnotation(defn.InlineParamAnnot)) Inline else EmptyFlags
235235
val (bindingFlags, bindingType) =
236236
if (isByName) (Method, ExprType(argtpe.widen))

tests/run/inlineByName.scala

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
object Test {
2+
3+
class Range(from: Int, end: Int) {
4+
inline def foreach(op: => Int => Unit): Unit = {
5+
var i = from
6+
while (i < end) {
7+
op(i)
8+
i += 1
9+
}
10+
}
11+
}
12+
inline def twice(op: => Int => Unit): Unit = {
13+
op(1)
14+
op(2)
15+
}
16+
inline def thrice(op: => Unit): Unit = {
17+
op
18+
op
19+
op
20+
}
21+
22+
def main(args: Array[String]) = {
23+
var j = 0
24+
new Range(1, 10).foreach(j += _)
25+
assert(j == 45, j)
26+
twice { x => j = j - x }
27+
thrice { j = j + 1 }
28+
val f = new Range(1, 10).foreach
29+
f(j -= _)
30+
assert(j == 0, j)
31+
new Range(1, 10).foreach { i1 =>
32+
new Range(2, 11).foreach { i2 =>
33+
j += i1 * i2
34+
}
35+
}
36+
}
37+
}

0 commit comments

Comments
 (0)