diff options
author | Martin Odersky <odersky@gmail.com> | 2013-08-08 17:02:57 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2013-08-08 17:02:57 +0200 |
commit | db9f555e2f02ac345945cb3982b0bf872f44a880 (patch) | |
tree | e129eff7ee58520fc0072711a9db2b8ab00dafbd /src/dotty/tools/dotc/core/Symbols.scala | |
parent | 2985d1806b66d4bf59807f35a6427b81ef66961e (diff) | |
download | dotty-db9f555e2f02ac345945cb3982b0bf872f44a880.tar.gz dotty-db9f555e2f02ac345945cb3982b0bf872f44a880.tar.bz2 dotty-db9f555e2f02ac345945cb3982b0bf872f44a880.zip |
Implementation of match/case def including GADT pattern matching.
Diffstat (limited to 'src/dotty/tools/dotc/core/Symbols.scala')
-rw-r--r-- | src/dotty/tools/dotc/core/Symbols.scala | 27 |
1 files changed, 27 insertions, 0 deletions
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" |