File tree Expand file tree Collapse file tree 3 files changed +17
-5
lines changed
compiler/src/dotty/tools/dotc/transform/init Expand file tree Collapse file tree 3 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -44,13 +44,17 @@ object Effects {
4444
4545 /** Field access, `a.f` */
4646 case class FieldAccess (potential : Potential , field : Symbol )(val source : Tree ) extends Effect {
47+ assert(field != NoSymbol )
48+
4749 def size : Int = potential.size
4850 def show (implicit ctx : Context ): String =
4951 potential.show + " ." + field.name.show + " !"
5052 }
5153
5254 /** Method call, `a.m()` */
5355 case class MethodCall (potential : Potential , method : Symbol )(val source : Tree ) extends Effect {
56+ assert(method != NoSymbol )
57+
5458 def size : Int = potential.size
5559 def show (implicit ctx : Context ): String = potential.show + " ." + method.name.show + " !"
5660 }
Original file line number Diff line number Diff line change @@ -118,14 +118,18 @@ object Potentials {
118118
119119 /** The object pointed by `this.f` */
120120 case class FieldReturn (potential : Potential , field : Symbol )(val source : Tree ) extends Potential {
121+ assert(field != NoSymbol )
122+
121123 def size : Int = potential.size + 1
122124 def show (implicit ctx : Context ): String = potential.show + " ." + field.name.show
123125 }
124126
125127 /** The object returned by `this.m()` */
126- case class MethodReturn (potential : Potential , symbol : Symbol )(val source : Tree ) extends Potential {
128+ case class MethodReturn (potential : Potential , method : Symbol )(val source : Tree ) extends Potential {
129+ assert(method != NoSymbol )
130+
127131 def size : Int = potential.size + 1
128- def show (implicit ctx : Context ): String = potential.show + " ." + symbol .name.show
132+ def show (implicit ctx : Context ): String = potential.show + " ." + method .name.show
129133 }
130134
131135 /** The object whose initialization status is unknown */
Original file line number Diff line number Diff line change @@ -288,9 +288,13 @@ object Summarization {
288288
289289 case ref =>
290290 val tref : TypeRef = ref.tpe.typeConstructor.asInstanceOf
291- val ctor = tref.classSymbol.asClass.primaryConstructor
292- Summarization .analyze(tref.prefix, ref)._2 +
293- MethodCall (ThisRef (cls)(ref), ctor)(ref)
291+ val cls = tref.classSymbol.asClass
292+ if (cls == defn.AnyClass || cls == defn.AnyValClass ) Effects .empty
293+ else {
294+ val ctor = cls.primaryConstructor
295+ Summarization .analyze(tref.prefix, ref)._2 +
296+ MethodCall (ThisRef (cls)(ref), ctor)(ref)
297+ }
294298 })
295299 }
296300
You can’t perform that action at this time.
0 commit comments