@@ -208,7 +208,8 @@ object Inliner {
208208 }
209209
210210 val Apply (_, codeArg :: Nil ) = tree
211- ConstFold (stripTyped(codeArg.underlyingArgument)).tpe.widenTermRefExpr match {
211+ val underlyingCodeArg = stripTyped(codeArg.underlying)
212+ ConstFold (underlyingCodeArg).tpe.widenTermRefExpr match {
212213 case ConstantType (Constant (code : String )) =>
213214 val source2 = SourceFile .virtual(" tasty-reflect" , code)
214215 val ctx2 = ctx.fresh.setNewTyperState().setTyper(new Typer ).setSource(source2)
@@ -223,7 +224,7 @@ object Inliner {
223224 res ++= typerErrors.map(e => ErrorKind .Typer -> e)
224225 res.toList
225226 case t =>
226- assert( ctx.reporter.hasErrors) // at least: argument to inline parameter must be a known value
227+ ctx.error( " argument to compileError must be a statically known String " , underlyingCodeArg.sourcePos)
227228 Nil
228229 }
229230
@@ -333,9 +334,10 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
333334 val argtpe = arg.tpe.dealiasKeepAnnots
334335 val isByName = paramtp.dealias.isInstanceOf [ExprType ]
335336 var inlineFlags : FlagSet = InlineProxy
336- if (paramtp.hasAnnotation(defn.InlineParamAnnot )) inlineFlags |= Inline
337+ if (paramtp.widenExpr.hasAnnotation(defn.InlineParamAnnot )) inlineFlags |= Inline
338+ if (isByName) inlineFlags |= Method
337339 val (bindingFlags, bindingType) =
338- if (isByName) (InlineByNameProxy .toTermFlags , ExprType (argtpe.widen))
340+ if (isByName) (inlineFlags , ExprType (argtpe.widen))
339341 else (inlineFlags, argtpe.widen)
340342 val boundSym = newSym(name, bindingFlags, bindingType).asTerm
341343 val binding = {
@@ -765,10 +767,8 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
765767 def search (buf : mutable.ListBuffer [ValOrDefDef ]) = buf.find(_.name == tree.name)
766768 if (paramProxies.contains(tree.typeOpt))
767769 search(bindingsBuf) match {
768- case Some (vdef : ValDef ) if vdef.symbol.is(Inline ) =>
769- Some (integrate(vdef.rhs, vdef.symbol))
770- case Some (ddef : DefDef ) =>
771- Some (integrate(ddef.rhs, ddef.symbol))
770+ case Some (bind : ValOrDefDef ) if bind.symbol.is(Inline ) =>
771+ Some (integrate(bind.rhs, bind.symbol))
772772 case _ => None
773773 }
774774 else None
@@ -1198,7 +1198,7 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
11981198 val bindingOfSym = newMutableSymbolMap[MemberDef ]
11991199
12001200 def isInlineable (binding : MemberDef ) = binding match {
1201- case DefDef (_, Nil , Nil , _, _) => true
1201+ case ddef @ DefDef (_, Nil , Nil , _, _) => isPureExpr(ddef.rhs)
12021202 case vdef @ ValDef (_, _, _) => isPureExpr(vdef.rhs)
12031203 case _ => false
12041204 }
@@ -1236,7 +1236,7 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
12361236 case Some (x) => x > 1 || x == 1 && ! boundSym.is(Method )
12371237 case none => true
12381238 }
1239- } && ! ( boundSym.isAllOf( InlineMethod ) && boundSym.isOneOf( GivenOrImplicit ) )
1239+ } && ! boundSym.is( Inline )
12401240
12411241 val inlineBindings = new TreeMap {
12421242 override def transform (t : Tree )(implicit ctx : Context ) = t match {
0 commit comments