File tree 2 files changed +20
-15
lines changed
src/dotty/tools/dotc/typer
2 files changed +20
-15
lines changed Original file line number Diff line number Diff line change @@ -42,22 +42,19 @@ trait TypeAssigner {
42
42
def avoid (tp : Type , symsToAvoid : => List [Symbol ])(implicit ctx : Context ): Type = {
43
43
val widenMap = new TypeMap {
44
44
lazy val forbidden = symsToAvoid.toSet
45
- def toAvoid (tp : Type ): Boolean = tp match {
46
- case tp : TermRef =>
47
- val sym = tp.symbol
48
- sym.exists && (
49
- sym.owner.isTerm && (forbidden contains sym)
50
- || ! (sym.owner is Package ) && toAvoid(tp.prefix)
51
- )
52
- case tp : TypeRef =>
53
- forbidden contains tp.symbol
54
- case _ =>
55
- false
56
- }
45
+ def toAvoid (tp : Type ): Boolean =
46
+ // TODO: measure the cost of using `existsPart`, and if necessary replace it
47
+ // by a `TypeAccumulator` where we have set `stopAtStatic = true`.
48
+ tp existsPart {
49
+ case tp : NamedType =>
50
+ forbidden contains tp.symbol
51
+ case _ =>
52
+ false
53
+ }
57
54
def apply (tp : Type ): Type = tp match {
58
55
case tp : TermRef if toAvoid(tp) && variance > 0 =>
59
56
apply(tp.info.widenExpr)
60
- case tp : TypeRef if (forbidden contains tp.symbol) || toAvoid(tp.prefix ) =>
57
+ case tp : TypeRef if toAvoid(tp) =>
61
58
tp.info match {
62
59
case TypeAlias (ref) =>
63
60
apply(ref)
@@ -92,7 +89,7 @@ trait TypeAssigner {
92
89
}
93
90
case tp : RefinedType =>
94
91
val tp1 @ RefinedType (parent1, _) = mapOver(tp)
95
- if (tp1.refinedInfo.existsPart(toAvoid ) && variance > 0 ) {
92
+ if (toAvoid( tp1.refinedInfo) && variance > 0 ) {
96
93
typr.println(s " dropping refinement from $tp1" )
97
94
parent1
98
95
}
Original file line number Diff line number Diff line change 1
1
class Outer {
2
- class Inner
2
+ class Inner {
3
+ class Inner2
4
+ }
3
5
}
4
6
5
7
object Test {
@@ -8,5 +10,11 @@ object Test {
8
10
val o = new Outer
9
11
new o.Inner
10
12
}
13
+
14
+ val b : Outer # Inner # Inner2 = {
15
+ val o = new Outer
16
+ val i = new o.Inner
17
+ new i.Inner2
18
+ }
11
19
}
12
20
}
You can’t perform that action at this time.
0 commit comments