File tree Expand file tree Collapse file tree 3 files changed +31
-17
lines changed
compiler/src/dotty/tools/dotc
tests/pos-special/fatal-warnings Expand file tree Collapse file tree 3 files changed +31
-17
lines changed Original file line number Diff line number Diff line change @@ -179,12 +179,14 @@ class SymUtils(val self: Symbol) extends AnyVal {
179
179
* it cannot be seen from parent class `cls`?
180
180
*/
181
181
def isInaccessibleChildOf (cls : Symbol )(given Context ): Boolean =
182
- def isAccessible (sym : Symbol ): Boolean =
183
- sym == cls
184
- || sym == cls.owner
185
- || sym.is(Package )
186
- || sym.isType && isAccessible(sym.owner)
187
- ! isAccessible(self.owner)
182
+ def isAccessible (sym : Symbol , cls : Symbol ): Boolean =
183
+ if cls.isType && ! cls.is(Package ) then
184
+ isAccessible(sym, cls.owner)
185
+ else
186
+ sym == cls
187
+ || sym.is(Package )
188
+ || sym.isType && isAccessible(sym.owner, cls)
189
+ ! isAccessible(self.owner, cls)
188
190
189
191
/** If this is a sealed class, its known children in the order of textual occurrence */
190
192
def children (implicit ctx : Context ): List [Symbol ] = {
Original file line number Diff line number Diff line change @@ -2103,17 +2103,19 @@ class Typer extends Namer
2103
2103
}
2104
2104
2105
2105
val ifpt = defn.asImplicitFunctionType(pt)
2106
- val result = if (ifpt.exists &&
2107
- xtree.isTerm &&
2108
- ! untpd.isContextualClosure(xtree) &&
2109
- ! ctx.mode.is(Mode .Pattern ) &&
2110
- ! ctx.isAfterTyper &&
2111
- ! ctx.isInlineContext)
2112
- makeContextualFunction(xtree, ifpt)
2113
- else xtree match {
2114
- case xtree : untpd.NameTree => typedNamed(xtree, pt)
2115
- case xtree => typedUnnamed(xtree)
2116
- }
2106
+ val result =
2107
+ if ifpt.exists
2108
+ && xtree.isTerm
2109
+ && ! untpd.isContextualClosure(xtree)
2110
+ && ! ctx.mode.is(Mode .Pattern )
2111
+ && ! ctx.isAfterTyper
2112
+ && ! ctx.isInlineContext
2113
+ then
2114
+ makeContextualFunction(xtree, ifpt)
2115
+ else xtree match
2116
+ case xtree : untpd.NameTree => typedNamed(xtree, pt)
2117
+ case xtree => typedUnnamed(xtree)
2118
+
2117
2119
simplify(result, pt, locked)
2118
2120
}
2119
2121
}
Original file line number Diff line number Diff line change
1
+ def foo : Unit =
2
+ object O
3
+ sealed abstract class A
4
+ class B extends O .A
5
+ class C extends O .A
6
+
7
+ val x : O .A = ???
8
+ x match
9
+ case x : B => ???
10
+ case x : C => ???
You can’t perform that action at this time.
0 commit comments