From db9f555e2f02ac345945cb3982b0bf872f44a880 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Thu, 8 Aug 2013 17:02:57 +0200 Subject: Implementation of match/case def including GADT pattern matching. --- src/dotty/tools/dotc/core/Symbols.scala | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/dotty/tools/dotc/core/Symbols.scala') diff --git a/src/dotty/tools/dotc/core/Symbols.scala b/src/dotty/tools/dotc/core/Symbols.scala index 634be7cb7..6edc5c973 100644 --- a/src/dotty/tools/dotc/core/Symbols.scala +++ b/src/dotty/tools/dotc/core/Symbols.scala @@ -382,6 +382,33 @@ object Symbols { */ def pos: Position = if (coord.isPosition) coord.toPosition else NoPosition +// -------- GADT handling ----------------------------------------------- + + /** Perform given operation `op` where this symbol allows tightening of + * its type bounds. + */ + private[dotc] def withGADTFlexType[T](op: () => T)(implicit ctx: Context): () => T = { () => + assert((denot is TypeParam) && denot.owner.isTerm) + val saved = denot + denot = denot.copySymDenotation(initFlags = denot.flags | GADTFlexType) + try op() + finally denot = saved + } + + /** Disallow tightening of type bounds for this symbol from now on */ + private[dotc] def resetGADTFlexType()(implicit ctx: Context): Unit = { + assert(denot is GADTFlexType) + denot = denot.copySymDenotation(initFlags = denot.flags &~ GADTFlexType) + } + + /** Change info of this symbol to new, tightened type bounds */ + private[core] def changeGADTInfo(bounds: TypeBounds)(implicit ctx: Context): Unit = { + assert(denot is GADTFlexType) + denot = denot.copySymDenotation(info = bounds) + } + +// -------- Printing -------------------------------------------------------- + /** The prefix string to be used when displaying this symbol without denotation */ protected def prefixString = "Symbol" -- cgit v1.2.3