Skip to content

Commit 8e4b919

Browse files
authored
Merge pull request #6172 from milessabin/topic/i6157
Pattern-bound type refs should have Case flag set
2 parents 7bcaa97 + 07c4b8d commit 8e4b919

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,9 @@ object Flags {
290290
final val PackageVal: FlagSet = Package.toTermFlags
291291
final val PackageClass: FlagSet = Package.toTypeFlags
292292

293-
/** A case class or its companion object */
293+
/** A case class or its companion object
294+
* Note: Case is also used to indicate that a symbol is bound by a pattern.
295+
*/
294296
final val Case: FlagSet = commonFlag(17, "case")
295297
final val CaseClass: FlagSet = Case.toTypeFlags
296298
final val CaseVal: FlagSet = Case.toTermFlags

compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ class TreeUnpickler(reader: TastyReader,
513513
def complete(denot: SymDenotation)(implicit ctx: Context) =
514514
denot.info = typeReader.readType()
515515
}
516-
val sym = ctx.newSymbol(ctx.owner, name, EmptyFlags, completer, coord = coordAt(start))
516+
val sym = ctx.newSymbol(ctx.owner, name, Flags.Case, completer, coord = coordAt(start))
517517
registerSym(start, sym)
518518
sym
519519
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
object Utils {
2+
class Box[T]
3+
inline def foo[T](t: T) <: Any = inline t match {
4+
case _: Box[a] => scala.compiletime.constValue[a]
5+
}
6+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import Utils._
2+
3+
object Test {
4+
val a = foo(new Box["a"])
5+
}

0 commit comments

Comments
 (0)