Skip to content

Commit 149d4de

Browse files
committed
Fix scala#10085: check if enum case confirms to scrutinee type
1 parent a5f8e2b commit 149d4de

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

compiler/src/dotty/tools/dotc/core/TypeOps.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -633,8 +633,6 @@ object TypeOps:
633633
* returned. Otherwise, `NoType` is returned.
634634
*/
635635
def refineUsingParent(parent: Type, child: Symbol)(using Context): Type = {
636-
if (child.isTerm && child.is(Case, butNot = Module)) return child.termRef // enum vals always match
637-
638636
// <local child> is a place holder from Scalac, it is hopeless to instantiate it.
639637
//
640638
// Quote from scalac (from nsc/symtab/classfile/Pickler.scala):

tests/patmat/i10085.scala

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
enum Bool:
2+
case True
3+
case False
4+
5+
import Bool._
6+
7+
enum SBool[B <: Bool]:
8+
case STrue extends SBool[True.type]
9+
case SFalse extends SBool[False.type]
10+
11+
import SBool._
12+
13+
def f(b: SBool[True.type]): Unit = b match
14+
case STrue => ()

0 commit comments

Comments
 (0)