File tree Expand file tree Collapse file tree 3 files changed +22
-1
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 3 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -279,6 +279,7 @@ class TreeChecker extends Phase with SymTransformer {
279
279
case _ if tree.isType =>
280
280
promote(tree)
281
281
case _ =>
282
+ checkApplyNonBlock(tree)
282
283
val tree1 = super .typedUnadapted(tree, pt, locked)
283
284
def isSubType (tp1 : Type , tp2 : Type ) =
284
285
(tp1 eq tp2) || // accept NoType / NoType
@@ -300,6 +301,12 @@ class TreeChecker extends Phase with SymTransformer {
300
301
res
301
302
}
302
303
304
+ def checkApplyNonBlock (tree : untpd.Tree )(implicit ctx : Context ) = tree match {
305
+ case tree : untpd.Apply => assert(! tree.fun.isInstanceOf [untpd.Block ])
306
+ case tree : untpd.UnApply => assert(! tree.fun.isInstanceOf [untpd.Block ])
307
+ case _ =>
308
+ }
309
+
303
310
def checkNotRepeated (tree : Tree )(implicit ctx : Context ): tree.type = {
304
311
def allowedRepeated = tree.tpe.widen.isRepeatedParam
305
312
Original file line number Diff line number Diff line change @@ -2378,7 +2378,12 @@ class Typer extends Namer
2378
2378
}
2379
2379
} else issueErrors()
2380
2380
}
2381
- else readaptSimplified(tpd.Apply (tree, args))
2381
+ else tree match {
2382
+ case tree : Block =>
2383
+ readaptSimplified(tpd.Block (tree.stats, tpd.Apply (tree.expr, args)))
2384
+ case _ =>
2385
+ readaptSimplified(tpd.Apply (tree, args))
2386
+ }
2382
2387
}
2383
2388
addImplicitArgs(argCtx(tree))
2384
2389
}
Original file line number Diff line number Diff line change
1
+ class Test {
2
+ inline def foo (x : Int = 5 )(implicit y : Int ): Int =
3
+ if (x > 0 ) y * y
4
+ else y + y
5
+
6
+ implicit val m : Int = 7
7
+
8
+ (new Test ).foo()
9
+ }
You can’t perform that action at this time.
0 commit comments