File tree 3 files changed +17
-1
lines changed
compiler/src/dotty/tools/dotc/transform
3 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -282,6 +282,10 @@ object ExplicitOuter {
282
282
case TypeRef (prefix, _) => isOuterRef(prefix)
283
283
case _ => false
284
284
}
285
+ def containsOuterRefs (tp : Type ): Boolean = tp match
286
+ case tp : SingletonType => isOuterRef(tp)
287
+ case tp : AndOrType => containsOuterRefs(tp.tp1) || containsOuterRefs(tp.tp2)
288
+ case _ => false
285
289
tree match {
286
290
case _ : This | _ : Ident => isOuterRef(tree.tpe)
287
291
case nw : New =>
@@ -292,6 +296,9 @@ object ExplicitOuter {
292
296
// newCls might get proxies for free variables. If current class is
293
297
// properly contained in newCls, it needs an outer path to newCls access the
294
298
// proxies and forward them to the new instance.
299
+ case app : TypeApply if app.symbol.isTypeTest =>
300
+ // Type tests of singletons translate to `eq` tests with references, which might require outer pointers
301
+ containsOuterRefs(app.args.head.tpe)
295
302
case _ =>
296
303
false
297
304
}
Original file line number Diff line number Diff line change @@ -295,7 +295,7 @@ object TypeTestsCasts {
295
295
derivedTree(expr, defn.Any_asInstanceOf , testType)
296
296
}
297
297
298
- /** Transform isInstanceOf OrType
298
+ /** Transform isInstanceOf
299
299
*
300
300
* expr.isInstanceOf[A | B] ~~> expr.isInstanceOf[A] | expr.isInstanceOf[B]
301
301
* expr.isInstanceOf[A & B] ~~> expr.isInstanceOf[A] & expr.isInstanceOf[B]
Original file line number Diff line number Diff line change
1
+ class Foo :
2
+
3
+ // object Bar
4
+ val Bar = 22
5
+
6
+ object Baz :
7
+ def f (x : Any ): Unit =
8
+ x match
9
+ case s : (Bar .type & x.type ) =>
You can’t perform that action at this time.
0 commit comments