File tree Expand file tree Collapse file tree 2 files changed +18
-15
lines changed
src/dotty/tools/dotc/typer Expand file tree Collapse file tree 2 files changed +18
-15
lines changed Original file line number Diff line number Diff line change @@ -40,22 +40,17 @@ trait TypeAssigner {
40
40
def avoid (tp : Type , symsToAvoid : => List [Symbol ])(implicit ctx : Context ): Type = {
41
41
val widenMap = new TypeMap {
42
42
lazy val forbidden = symsToAvoid.toSet
43
- def toAvoid (tp : Type ): Boolean = tp match {
44
- case tp : TermRef =>
45
- val sym = tp.symbol
46
- sym.exists && (
47
- sym.owner.isTerm && (forbidden contains sym)
48
- || ! (sym.owner is Package ) && toAvoid(tp.prefix)
49
- )
50
- case tp : TypeRef =>
51
- forbidden contains tp.symbol
52
- case _ =>
53
- false
54
- }
43
+ def toAvoid (tp : Type ): Boolean =
44
+ tp existsPart {
45
+ case tp : NamedType =>
46
+ forbidden contains tp.symbol
47
+ case _ =>
48
+ false
49
+ }
55
50
def apply (tp : Type ): Type = tp match {
56
51
case tp : TermRef if toAvoid(tp) && variance > 0 =>
57
52
apply(tp.info.widenExpr)
58
- case tp : TypeRef if (forbidden contains tp.symbol) || toAvoid(tp.prefix ) =>
53
+ case tp : TypeRef if toAvoid(tp) =>
59
54
tp.info match {
60
55
case TypeAlias (ref) =>
61
56
apply(ref)
@@ -90,7 +85,7 @@ trait TypeAssigner {
90
85
}
91
86
case tp : RefinedType =>
92
87
val tp1 @ RefinedType (parent1, _) = mapOver(tp)
93
- if (tp1.refinedInfo.existsPart(toAvoid ) && variance > 0 ) {
88
+ if (toAvoid( tp1.refinedInfo) && variance > 0 ) {
94
89
typr.println(s " dropping refinement from $tp1" )
95
90
parent1
96
91
}
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