aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGuillaume Martres <smarter@ubuntu.com>2016-10-25 17:54:27 +0200
committerGitHub <noreply@github.com>2016-10-25 17:54:27 +0200
commitf1284b48d48ec16840e3e018e060edc50d4d1bb7 (patch)
tree94a7cb92bfc0d55927699447a577421851409f52 /src
parent0cd907da01671c510025a610cea9ab117c8f1ae4 (diff)
parent652cce0b0ad1b8b54f54a5d78a6c4defbd599124 (diff)
downloaddotty-f1284b48d48ec16840e3e018e060edc50d4d1bb7.tar.gz
dotty-f1284b48d48ec16840e3e018e060edc50d4d1bb7.tar.bz2
dotty-f1284b48d48ec16840e3e018e060edc50d4d1bb7.zip
Merge pull request #1599 from dotty-staging/fix-#1570
Fix #1570: Allow inline parameters as inline args
Diffstat (limited to 'src')
-rw-r--r--src/dotty/tools/dotc/core/Flags.scala3
-rw-r--r--src/dotty/tools/dotc/typer/Checking.scala11
2 files changed, 10 insertions, 4 deletions
diff --git a/src/dotty/tools/dotc/core/Flags.scala b/src/dotty/tools/dotc/core/Flags.scala
index 3f4433708..63fbc98dc 100644
--- a/src/dotty/tools/dotc/core/Flags.scala
+++ b/src/dotty/tools/dotc/core/Flags.scala
@@ -544,6 +544,9 @@ object Flags {
/** An inline method */
final val InlineMethod = allOf(Inline, Method)
+ /** An inline parameter */
+ final val InlineParam = allOf(Inline, Param)
+
/** A parameter or parameter accessor */
final val ParamOrAccessor = Param | ParamAccessor
diff --git a/src/dotty/tools/dotc/typer/Checking.scala b/src/dotty/tools/dotc/typer/Checking.scala
index 7899174f5..3ebae733f 100644
--- a/src/dotty/tools/dotc/typer/Checking.scala
+++ b/src/dotty/tools/dotc/typer/Checking.scala
@@ -482,10 +482,13 @@ trait Checking {
/** Check that `tree` is a pure expression of constant type */
def checkInlineConformant(tree: Tree, what: => String)(implicit ctx: Context): Unit =
- tree.tpe.widenTermRefExpr match {
- case tp: ConstantType if isPureExpr(tree) => // ok
- case tp if defn.isFunctionType(tp) && isPureExpr(tree) => // ok
- case _ => ctx.error(em"$what must be a constant expression or a function", tree.pos)
+ tree.tpe match {
+ case tp: TermRef if tp.symbol.is(InlineParam) => // ok
+ case tp => tp.widenTermRefExpr match {
+ case tp: ConstantType if isPureExpr(tree) => // ok
+ case tp if defn.isFunctionType(tp) && isPureExpr(tree) => // ok
+ case _ => ctx.error(em"$what must be a constant expression or a function", tree.pos)
+ }
}
/** Check that class does not define same symbol twice */