File tree 3 files changed +14
-4
lines changed
3 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -544,6 +544,9 @@ object Flags {
544
544
/** An inline method */
545
545
final val InlineMethod = allOf(Inline , Method )
546
546
547
+ /** An inline parameter */
548
+ final val InlineParam = allOf(Inline , Param )
549
+
547
550
/** A parameter or parameter accessor */
548
551
final val ParamOrAccessor = Param | ParamAccessor
549
552
Original file line number Diff line number Diff line change @@ -482,10 +482,13 @@ trait Checking {
482
482
483
483
/** Check that `tree` is a pure expression of constant type */
484
484
def checkInlineConformant (tree : Tree , what : => String )(implicit ctx : Context ): Unit =
485
- tree.tpe.widenTermRefExpr match {
486
- case tp : ConstantType if isPureExpr(tree) => // ok
487
- case tp if defn.isFunctionType(tp) && isPureExpr(tree) => // ok
488
- case _ => ctx.error(em " $what must be a constant expression or a function " , tree.pos)
485
+ tree.tpe match {
486
+ case tp : TermRef if tp.symbol.is(InlineParam ) => // ok
487
+ case tp => tp.widenTermRefExpr match {
488
+ case tp : ConstantType if isPureExpr(tree) => // ok
489
+ case tp if defn.isFunctionType(tp) && isPureExpr(tree) => // ok
490
+ case _ => ctx.error(em " $what must be a constant expression or a function " , tree.pos)
491
+ }
489
492
}
490
493
491
494
/** Check that class does not define same symbol twice */
Original file line number Diff line number Diff line change
1
+ object Test {
2
+ inline def foo (inline n : Int ) = bar(n)
3
+ inline def bar (inline n : Int ) = n
4
+ }
You can’t perform that action at this time.
0 commit comments