@@ -1079,15 +1079,24 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
10791079    }
10801080  }
10811081
1082+   // inlineContext, enclosingInlineds, sourceFile and Decorators.sourcePos work closely together.
1083+ 
10821084  /**  A key to be used in a context property that tracks enclosing inlined calls */  
10831085  private  val  InlinedCalls  =  new  Property .Key [List [Tree ]]
10841086
1085-   /**  Record an enclosing inlined call. 
1086-     * EmptyTree calls (for parameters) cancel the next-enclosing call in the list instead of being added to it. 
1087-     * We assume parameters are never nested inside parameters. 
1087+   /**  Record an enclosing inlined call in enclosingInlineds, and produces the context for visiting 
1088+     * Inlined(call, ...). 
1089+     * 
1090+     * Invariants: 
1091+     * - enclosingInlineds never contains EmptyTree nodes. 
1092+     * - if enclosingInlineds.nonEmpty, the current tree comes from the file *defining* enclosingInlineds.head.symbol; 
1093+     *   this is exploited in e.g. Decorators.sourcePos. 
1094+     * 
1095+     * Arguments of inlined calls (enclosed in Inlined(EmptyTree, ...)) come instead from the call-site, so 
1096+     * inlineContext(EmptyTree) pops the enclosing call. 
10881097    */  
10891098  override  def  inlineContext (call : Tree )(implicit  ctx : Context ):  Context  =  {
1090-     //  We assume  enclosingInlineds is already normalized, and  only process the new call with the head.
1099+     //  enclosingInlineds is already normalized, so we  only process the new call with the head.
10911100    val  oldIC  =  enclosingInlineds
10921101    val  newIC  =  (call, oldIC) match  {
10931102      case  (t, t1 ::  ts2) if  t.isEmpty => 
@@ -1106,7 +1115,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
11061115  /**  The source file where the symbol of the `inline` method referred to by `call` 
11071116   *  is defined 
11081117   */  
1109-   def  sourceFile (call : Tree )(implicit  ctx : Context ) =  {
1118+   def  sourceFile (call : Tree )(implicit  ctx : Context ):   SourceFile  =  {
11101119    val  file  =  call.symbol.sourceFile
11111120    val  encoding  =  ctx.settings.encoding.value
11121121    if  (file !=  null  &&  file.exists) new  SourceFile (file, Codec (encoding)) else  NoSource 
0 commit comments