Skip to content

Commit 60458e2

Browse files
committed
wip
1 parent 1b03476 commit 60458e2

File tree

3 files changed

+26
-9
lines changed

3 files changed

+26
-9
lines changed

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

+18-5
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,26 @@ class PCPCheckAndHeal(@constructorOnly ictx: Context) extends TreeMapWithStages(
148148
*/
149149
private def checkSymLevel(sym: Symbol, tp: Type, pos: SourcePosition)(implicit ctx: Context): Option[Tree] = {
150150
val isThis = tp.isInstanceOf[ThisType]
151-
val shouldTryHealable = {
151+
def couldBeHealed = {
152152
// TODO move logic to levelOK
153-
tp.isInstanceOf[ThisType] ||
154-
sym.is(Param) ||
155-
!sym.maybeOwner.isType
153+
val a = //tp.isInstanceOf[ThisType] ||
154+
tp.isInstanceOf[ThisType] || // heal references to `this.type`
155+
(sym.isType && sym.is(Param)) // heal references of type parameters
156+
// !sym.maybeOwner.isType
157+
// println("===============")
158+
// println(a)
159+
// println()
160+
// println(sym)
161+
// println(sym.isType)
162+
// println(sym.flags)
163+
// println()
164+
// println(tp)
165+
// println()
166+
// println()
167+
// println()
168+
a
156169
}
157-
if (sym.exists && !sym.isStaticOwner && !levelOK(sym) && shouldTryHealable)
170+
if (sym.exists && !sym.isStaticOwner && !levelOK(sym) && couldBeHealed)
158171
tryHeal(sym, tp, pos)
159172
else
160173
None

tests/neg/quote-this.scala

-4
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ class Foo {
1515
'this // error
1616
}) }
1717

18-
inline def j(that: Foo): Unit = ${ Foo.impl[Any]('{
19-
'that // error
20-
}) }
21-
2218
}
2319

2420
object Foo {

tests/pos/quote-this.scala

+8
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ class Foo {
2121
inline def h(): Unit = ${ Foo.impl[Any]('this) }
2222
inline def i(that: Foo): Unit = ${ Foo.impl[that.type](1) }
2323

24+
inline def j(that: Foo): Unit = ${ Foo.impl[Any]('{
25+
'that
26+
}) }
27+
28+
inline def k(that: Foo): Unit = ${ Foo.impl[that.type]('{
29+
'that
30+
}) }
31+
2432
}
2533

2634
object Foo {

0 commit comments

Comments
 (0)