@@ -73,6 +73,22 @@ object RefChecks {
73
73
}
74
74
}
75
75
76
+ /** The this-type of `cls` which should be used when looking at the types of
77
+ * inherited members. If `cls` has a non-trivial self type, this returns a skolem
78
+ * with the class type instead of the `this-type` of the class as usual.
79
+ * This is done because otherwise we want to understand inherited infos
80
+ * as they are written, whereas with the this-type they could be
81
+ * more special. A test where this makes a difference is pos/i1401.scala.
82
+ * This one used to succeed only if forwarding parameters is on.
83
+ * (Forwarding tends to hide problems by binding parameter names).
84
+ */
85
+ private def upwardsThisType (cls : Symbol )(implicit ctx : Context ) = cls.info match {
86
+ case ClassInfo (_, _, _, _, tp : Type ) if (tp ne cls.typeRef) && ! cls.is(ModuleOrFinal ) =>
87
+ SkolemType (cls.typeRef).withName(nme.this_)
88
+ case _ =>
89
+ cls.thisType
90
+ }
91
+
76
92
/** Check that self type of this class conforms to self types of parents.
77
93
* and required classes.
78
94
*/
@@ -134,20 +150,7 @@ object RefChecks {
134
150
* before, but it looks too complicated and method bodies are far too large.
135
151
*/
136
152
private def checkAllOverrides (clazz : Symbol )(implicit ctx : Context ): Unit = {
137
- val self = clazz.info match {
138
- case ClassInfo (_, _, _, _, tp : Type )
139
- if (tp ne clazz.typeRef) && ! clazz.is(ModuleOrFinal ) =>
140
- // If class has a non-trivial self type, use a skolem with the class type
141
- // as `self` reference, instead of the `this-type` of the class as usual.
142
- // This is done because otherwise we want to understand inherited infos
143
- // as they are written, whereas with the this-type they could be
144
- // more special. A test where this makes a difference is pos/i1401.scala.
145
- // This one used to succeed only if forwarding parameters is on.
146
- // (Forwarding tends to hide problems by binding parameter names).
147
- SkolemType (clazz.typeRef).withName(nme.this_)
148
- case _ =>
149
- clazz.thisType
150
- }
153
+ val self = upwardsThisType(clazz)
151
154
var hasErrors = false
152
155
153
156
case class MixinOverrideError (member : Symbol , msg : String )
0 commit comments