@@ -107,7 +107,29 @@ class PCPCheckAndHeal(@constructorOnly ictx: Context) extends TreeMapWithStages(
107
107
}
108
108
109
109
/** Check and heal all named types and this-types in a given type for phase consistency. */
110
- private def checkType (pos : SourcePosition )(implicit ctx : Context ): TypeMap = new TypeMap {
110
+ private def checkType (pos : SourcePosition )(implicit ctx : Context ): TypeMap = {
111
+ // tests/pos/i5954.scala failed
112
+ // tests/pos/i5954.scala failed
113
+ // tests/pos/i5954b.scala failed
114
+ // tests/pos/i5954b.scala failed
115
+ // tests/pos/i5954c.scala failed
116
+ // tests/pos/i5954c.scala failed
117
+ // tests/pos/i5954d.scala failed
118
+ // tests/pos/i5954d.scala failed
119
+
120
+ // tests/pos/i7048c.scala failed
121
+ // tests/pos/i7048c.scala failed
122
+ // tests/pos/i7048d.scala failed
123
+ // tests/pos/i7048d.scala failed
124
+
125
+ // tests/run-macros/i7048
126
+ // tests/run-staging/i6281.scala
127
+
128
+ // println()
129
+ // println("+++++++++++++++++++++++++=")
130
+ // println()
131
+ // println()
132
+ new TypeMap {
111
133
def apply (tp : Type ): Type = reporting.trace(i " check type level $tp at $level" ) {
112
134
tp match {
113
135
case tp : TypeRef if tp.symbol.isSplice =>
@@ -119,7 +141,31 @@ class PCPCheckAndHeal(@constructorOnly ictx: Context) extends TreeMapWithStages(
119
141
// Replace it with a properly encoded type splice. This is the normal for expected for type splices.
120
142
tp.prefix.select(tpnme.splice)
121
143
case tp : NamedType =>
122
- checkSymLevel(tp.symbol, tp, pos) match {
144
+
145
+ def isPathOK (tp1 : Type ): Boolean = {
146
+
147
+ // println("> " + tp1)
148
+
149
+ tp1 match {
150
+ case tp : TermRef => tp.symbol.isStaticOwner || isPathOK(tp.prefix)
151
+ case tp : TypeRef => tp.symbol.is(Package ) || isPathOK(tp.prefix)
152
+ case ThisType (tref) => isPathOK(tref)
153
+ case _ : SkolemType => true
154
+ case _ => false
155
+ }}
156
+
157
+ // println("++++++++++++++++++++++++")
158
+ // println(tp.show)
159
+ // println(tp)
160
+ // println(level)
161
+ // println(levelOK(tp.symbol))
162
+ // println(levelOf(tp.symbol))
163
+ // println(isPathOK(tp))
164
+ // println()
165
+ // println()
166
+ // }
167
+ if (isPathOK(tp)) tp
168
+ else checkSymLevel(tp.symbol, tp, pos) match {
123
169
case Some (tpRef) => tpRef.tpe
124
170
case _ =>
125
171
if (tp.symbol.is(Param )) tp
@@ -132,7 +178,7 @@ class PCPCheckAndHeal(@constructorOnly ictx: Context) extends TreeMapWithStages(
132
178
mapOver(tp)
133
179
}
134
180
}
135
- }
181
+ }}
136
182
137
183
/** Check reference to `sym` for phase consistency, where `tp` is the underlying type
138
184
* by which we refer to `sym`. If it is an inconsistent type try construct a healed type for it.
@@ -171,7 +217,7 @@ class PCPCheckAndHeal(@constructorOnly ictx: Context) extends TreeMapWithStages(
171
217
sym.isClass // reference to this in inline methods
172
218
)
173
219
case None =>
174
- ! sym.is(Param ) || levelOK(sym.owner)
220
+ ! ( sym.is(Param ) || sym.isType ) || levelOK(sym.owner)
175
221
}
176
222
177
223
/** Try to heal phase-inconsistent reference to type `T` using a local type definition.
0 commit comments