File tree 3 files changed +16
-1
lines changed
compiler/src/dotty/tools/dotc/transform
3 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -282,6 +282,9 @@ 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)
285
288
tree match {
286
289
case _ : This | _ : Ident => isOuterRef(tree.tpe)
287
290
case nw : New =>
@@ -292,6 +295,9 @@ object ExplicitOuter {
292
295
// newCls might get proxies for free variables. If current class is
293
296
// properly contained in newCls, it needs an outer path to newCls access the
294
297
// proxies and forward them to the new instance.
298
+ case app : TypeApply if app.symbol.isTypeTest =>
299
+ // Type tests of singletons translate to `eq` tests with references, which might require outer pointers
300
+ containsOuterRefs(app.args.head.tpe)
295
301
case _ =>
296
302
false
297
303
}
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