Skip to content

Commit c76f258

Browse files
committed
Fix scala#7048: WIP
1 parent 754fa51 commit c76f258

File tree

4 files changed

+50
-4
lines changed

4 files changed

+50
-4
lines changed

compiler/src/dotty/tools/dotc/transform/PCPCheckAndHeal.scala

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,29 @@ class PCPCheckAndHeal(@constructorOnly ictx: Context) extends TreeMapWithStages(
107107
}
108108

109109
/** 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 {
111133
def apply(tp: Type): Type = reporting.trace(i"check type level $tp at $level") {
112134
tp match {
113135
case tp: TypeRef if tp.symbol.isSplice =>
@@ -119,7 +141,31 @@ class PCPCheckAndHeal(@constructorOnly ictx: Context) extends TreeMapWithStages(
119141
// Replace it with a properly encoded type splice. This is the normal for expected for type splices.
120142
tp.prefix.select(tpnme.splice)
121143
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 {
123169
case Some(tpRef) => tpRef.tpe
124170
case _ =>
125171
if (tp.symbol.is(Param)) tp
@@ -132,7 +178,7 @@ class PCPCheckAndHeal(@constructorOnly ictx: Context) extends TreeMapWithStages(
132178
mapOver(tp)
133179
}
134180
}
135-
}
181+
}}
136182

137183
/** Check reference to `sym` for phase consistency, where `tp` is the underlying type
138184
* 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(
171217
sym.isClass // reference to this in inline methods
172218
)
173219
case None =>
174-
!sym.is(Param) || levelOK(sym.owner)
220+
!(sym.is(Param) || sym.isType) || levelOK(sym.owner)
175221
}
176222

177223
/** Try to heal phase-inconsistent reference to type `T` using a local type definition.
File renamed without changes.

0 commit comments

Comments
 (0)