File tree Expand file tree Collapse file tree 2 files changed +11
-5
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -1180,7 +1180,7 @@ trait Checking {
1180
1180
*/
1181
1181
def checkEnumCaseRefsLegal (cdef : TypeDef , enumCtx : Context )(using Context ): Unit = {
1182
1182
1183
- def checkCaseOrDefault (stat : Tree , caseCtx : Context ) = {
1183
+ def checkEnumCaseOrDefault (stat : Tree , caseCtx : Context ) = {
1184
1184
1185
1185
def check (tree : Tree ) = {
1186
1186
// allow access to `sym` if a typedIdent just outside the enclosing enum
@@ -1219,16 +1219,16 @@ trait Checking {
1219
1219
1220
1220
cdef.rhs match {
1221
1221
case impl : Template =>
1222
- def isCase (stat : Tree ) = stat match {
1223
- case _ : ValDef | _ : TypeDef => stat.symbol.is( Case )
1222
+ def isEnumCase (stat : Tree ) = stat match {
1223
+ case _ : ValDef | _ : TypeDef => stat.symbol.isAllOf( EnumCase )
1224
1224
case _ => false
1225
1225
}
1226
1226
val cases =
1227
- for (stat <- impl.body if isCase (stat))
1227
+ for (stat <- impl.body if isEnumCase (stat))
1228
1228
yield untpd.ImportSelector (untpd.Ident (stat.symbol.name.toTermName))
1229
1229
val caseImport : Import = Import (ref(cdef.symbol), cases)
1230
1230
val caseCtx = enumCtx.importContext(caseImport, caseImport.symbol)
1231
- for (stat <- impl.body) checkCaseOrDefault (stat, caseCtx)
1231
+ for (stat <- impl.body) checkEnumCaseOrDefault (stat, caseCtx)
1232
1232
case _ =>
1233
1233
}
1234
1234
}
Original file line number Diff line number Diff line change
1
+ enum Outer :
2
+ case Foo (u : Unavailable ) // error
3
+ case Bar (u : DefinitelyNotAvailable ) // error
4
+ object Outer :
5
+ class Unavailable (i : Int )
6
+ case class DefinitelyNotAvailable ()
You can’t perform that action at this time.
0 commit comments