@@ -184,6 +184,8 @@ object Objects:
184
184
185
185
def level : Int
186
186
187
+ def show (using Context ): String
188
+
187
189
/** Local environments can be deeply nested, therefore we need `outer`. */
188
190
private case class LocalEnv (private [Env ] val params : Map [Symbol , Value ], owner : Symbol , outer : Data )(using Context ) extends Data :
189
191
val level = outer.level + 1
@@ -203,10 +205,11 @@ object Objects:
203
205
def widen (height : Int )(using Context ): Data =
204
206
new LocalEnv (params.map(_ -> _.widen(height)), owner, outer.widen(height))
205
207
206
- override def toString () =
207
- " params: " + params + " \n " +
208
- " locals: " + locals + " \n " +
209
- " outer {\n " + outer + " \n }"
208
+ def show (using Context ) =
209
+ " owner: " + owner.show + " \n " +
210
+ " params: " + params.map(_.show + " ->" + _.show).mkString(" {" , " , " , " }" ) + " \n " +
211
+ " locals: " + locals.map(_.show + " ->" + _.show).mkString(" {" , " , " , " }" ) + " \n " +
212
+ " outer = {\n " + outer.show + " \n }"
210
213
211
214
end LocalEnv
212
215
@@ -220,6 +223,8 @@ object Objects:
220
223
throw new RuntimeException (" Invalid usage of non-existent env" )
221
224
222
225
def widen (height : Int )(using Context ): Data = this
226
+
227
+ def show (using Context ): String = " NoEnv"
223
228
end NoEnv
224
229
225
230
/** An empty environment can be used for non-method environments, e.g., field initializers.
@@ -614,7 +619,11 @@ object Objects:
614
619
Cold
615
620
else
616
621
given Env .Data = env
617
- Env (sym)
622
+ try
623
+ Env (sym)
624
+ catch ex =>
625
+ report.warning(" [Internal error] Not found " + sym.show + " \n env = " + env.show + " . Calling trace:\n " + Trace .show, Trace .position)
626
+ Bottom
618
627
619
628
case _ => Cold
620
629
}
@@ -916,8 +925,18 @@ object Objects:
916
925
917
926
case tmref : TermRef if tmref.prefix == NoPrefix =>
918
927
val sym = tmref.symbol
919
- if sym.is(Flags .Package ) then Bottom
920
- else readLocal(thisV, sym)
928
+ if sym.is(Flags .Package ) then
929
+ Bottom
930
+ else if sym.owner.isClass then
931
+ // The typer incorrectly assigns a TermRef with NoPrefix for `config`,
932
+ // while the actual denotation points to the symbol of the class member
933
+ // instead of the parameter symbol for the primary constructor.
934
+ //
935
+ // abstract class Base(implicit config: Int)
936
+ // case class A(x: Int)(implicit config: Int) extends Base
937
+ evalType(sym.termRef, thisV, klass, elideObjectAccess)
938
+ else
939
+ readLocal(thisV, sym)
921
940
922
941
case tmref : TermRef =>
923
942
val sym = tmref.symbol
0 commit comments