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 {
44
44
45
45
/** Field access, `a.f` */
46
46
case class FieldAccess (potential : Potential , field : Symbol )(val source : Tree ) extends Effect {
47
+ assert(field != NoSymbol )
48
+
47
49
def size : Int = potential.size
48
50
def show (implicit ctx : Context ): String =
49
51
potential.show + " ." + field.name.show + " !"
50
52
}
51
53
52
54
/** Method call, `a.m()` */
53
55
case class MethodCall (potential : Potential , method : Symbol )(val source : Tree ) extends Effect {
56
+ assert(method != NoSymbol )
57
+
54
58
def size : Int = potential.size
55
59
def show (implicit ctx : Context ): String = potential.show + " ." + method.name.show + " !"
56
60
}
Original file line number Diff line number Diff line change @@ -118,14 +118,18 @@ object Potentials {
118
118
119
119
/** The object pointed by `this.f` */
120
120
case class FieldReturn (potential : Potential , field : Symbol )(val source : Tree ) extends Potential {
121
+ assert(field != NoSymbol )
122
+
121
123
def size : Int = potential.size + 1
122
124
def show (implicit ctx : Context ): String = potential.show + " ." + field.name.show
123
125
}
124
126
125
127
/** 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
+
127
131
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
129
133
}
130
134
131
135
/** The object whose initialization status is unknown */
Original file line number Diff line number Diff line change @@ -288,9 +288,13 @@ object Summarization {
288
288
289
289
case ref =>
290
290
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
+ }
294
298
})
295
299
}
296
300
You can’t perform that action at this time.
0 commit comments