Skip to content

Pattern-bound type refs should have Case flag set #6172

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion compiler/src/dotty/tools/dotc/core/Flags.scala
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,9 @@ object Flags {
final val PackageVal: FlagSet = Package.toTermFlags
final val PackageClass: FlagSet = Package.toTypeFlags

/** A case class or its companion object */
/** A case class or its companion object
* Note: Case is also used to indicate that a symbol is bound by a pattern.
*/
final val Case: FlagSet = commonFlag(17, "case")
final val CaseClass: FlagSet = Case.toTypeFlags
final val CaseVal: FlagSet = Case.toTermFlags
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ class TreeUnpickler(reader: TastyReader,
def complete(denot: SymDenotation)(implicit ctx: Context) =
denot.info = typeReader.readType()
}
val sym = ctx.newSymbol(ctx.owner, name, EmptyFlags, completer, coord = coordAt(start))
val sym = ctx.newSymbol(ctx.owner, name, Flags.Case, completer, coord = coordAt(start))
registerSym(start, sym)
sym
}
Expand Down
6 changes: 6 additions & 0 deletions tests/pos/inline-match-separate/inline-match-separate_1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
object Utils {
class Box[T]
inline def foo[T](t: T) <: Any = inline t match {
case _: Box[a] => scala.compiletime.constValue[a]
}
}
5 changes: 5 additions & 0 deletions tests/pos/inline-match-separate/inline-match-separate_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Utils._

object Test {
val a = foo(new Box["a"])
}