File tree 4 files changed +18
-4
lines changed
compiler/src/dotty/tools/dotc/transform
4 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -153,7 +153,21 @@ class PCPCheckAndHeal(@constructorOnly ictx: Context) extends TreeMapWithStages(
153
153
/** Is a reference to a class but not `this.type` */
154
154
def isClassRef = sym.isClass && ! tp.isInstanceOf [ThisType ]
155
155
156
- if (! sym.exists || levelOK(sym))
156
+ /** Is this a static path or a type porjection with a static prefix */
157
+ def isStaticPathOK (tp1 : Type ): Boolean =
158
+ tp1.stripTypeVar match
159
+ case tp1 : TypeRef => tp1.symbol.is(Package ) || isStaticPathOK(tp1.prefix)
160
+ case tp1 : TermRef =>
161
+ def isStaticTermPathOK (sym : Symbol ): Boolean =
162
+ (sym.is(Module ) && sym.isStatic) ||
163
+ (sym.isStableMember && isStaticTermPathOK(sym.owner))
164
+ isStaticTermPathOK(tp1.symbol)
165
+ case tp1 : ThisType => tp1.cls.isStaticOwner
166
+ case tp1 : AppliedType => isStaticPathOK(tp1.tycon)
167
+ case tp1 : SkolemType => isStaticPathOK(tp1.info)
168
+ case _ => false
169
+
170
+ if (! sym.exists || levelOK(sym) || isStaticPathOK(tp))
157
171
None
158
172
else if (! sym.isStaticOwner && ! isClassRef)
159
173
tryHeal(sym, tp, pos)
@@ -180,7 +194,7 @@ class PCPCheckAndHeal(@constructorOnly ictx: Context) extends TreeMapWithStages(
180
194
sym.isClass // reference to this in inline methods
181
195
)
182
196
case None =>
183
- ! sym.is(Param ) || levelOK(sym.owner)
197
+ sym.is(Package ) || sym.owner.isStaticOwner || levelOK(sym.owner)
184
198
}
185
199
186
200
/** Try to heal phase-inconsistent reference to type `T` using a local type definition.
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ trait IsExpr[T] {
7
7
8
8
def f (x : Any ): String = x.toString
9
9
10
- def g [T ](given e : IsExpr [T ], tu : Type [e.Underlying ]): (given QuoteContext ) => Expr [String ] = {
10
+ def g [T ](given e : IsExpr [T ], tu : TypeTag [e.Underlying ]): (given QuoteContext ) => Expr [String ] = {
11
11
val underlying : Expr [e.Underlying ] = e.expr
12
12
' {f($underlying)}
13
13
}
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ given [U] : IsExpr[Expr[U]] = new IsExpr[Expr[U]] {
12
12
13
13
def f (x : Any ): String = x.toString
14
14
15
- def g [T ](x : T )(given e : IsExpr [T ], tu : Type [e.Underlying ]): (given QuoteContext ) => Expr [String ] = {
15
+ def g [T ](x : T )(given e : IsExpr [T ], tu : TypeTag [e.Underlying ]): (given QuoteContext ) => Expr [String ] = {
16
16
val underlying : Expr [e.Underlying ] = e.toExpr(x)
17
17
' {f($underlying)}
18
18
}
File renamed without changes.
You can’t perform that action at this time.
0 commit comments