summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2013-08-29 07:10:00 -0700
committerJason Zaugg <jzaugg@gmail.com>2013-08-29 07:10:00 -0700
commit8679c217766326797bc13faf480f05064eb3df15 (patch)
tree009570e9b12b27c2563237c3317f5dde76bc5011 /src
parent996a95dac9cff30313316cc6b2448ec381852042 (diff)
parent3eebc99432075fdffabf8859df3dc8b2ded8df9c (diff)
downloadscala-8679c217766326797bc13faf480f05064eb3df15.tar.gz
scala-8679c217766326797bc13faf480f05064eb3df15.tar.bz2
scala-8679c217766326797bc13faf480f05064eb3df15.zip
Merge pull request #2879 from retronym/ticket/7785
SI-7785 Preserve TypeVar suspension through TypeMaps
Diffstat (limited to 'src')
-rw-r--r--src/reflect/scala/reflect/internal/Types.scala15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/reflect/scala/reflect/internal/Types.scala b/src/reflect/scala/reflect/internal/Types.scala
index 49b5dae0ea..e2157a6063 100644
--- a/src/reflect/scala/reflect/internal/Types.scala
+++ b/src/reflect/scala/reflect/internal/Types.scala
@@ -2842,6 +2842,9 @@ trait Types
// but pattern-matching returned the original constr0 (a bug)
// now, pattern-matching returns the most recent constr
object TypeVar {
+ private val ConstantTrue = ConstantType(Constant(true))
+ private val ConstantFalse = ConstantType(Constant(false))
+
@inline final def trace[T](action: String, msg: => String)(value: T): T = {
if (traceTypeVars) {
val s = msg match {
@@ -3000,6 +3003,7 @@ trait Types
this
else if (newArgs.size == params.size) {
val tv = TypeVar(origin, constr, newArgs, params)
+ tv.linkSuspended(this)
TypeVar.trace("applyArgs", "In " + originLocation + ", apply args " + newArgs.mkString(", ") + " to " + originName)(tv)
}
else
@@ -3061,7 +3065,16 @@ trait Types
// </region>
// ignore subtyping&equality checks while true -- see findMember
- private[Types] var suspended = false
+ // OPT: This could be Either[TypeVar, Boolean], but this encoding was chosen instead to save allocations.
+ private var _suspended: Type = TypeVar.ConstantFalse
+ private[Types] def suspended: Boolean = (_suspended: @unchecked) match {
+ case TypeVar.ConstantFalse => false
+ case TypeVar.ConstantTrue => true
+ case tv: TypeVar => tv.suspended
+ }
+ private[Types] def suspended_=(b: Boolean): Unit = _suspended = if (b) TypeVar.ConstantTrue else TypeVar.ConstantFalse
+ // SI-7785 Link the suspended attribute of a TypeVar created in, say, a TypeMap (e.g. AsSeenFrom) to its originator
+ private[Types] def linkSuspended(origin: TypeVar): Unit = _suspended = origin
/** Called when a TypeVar is involved in a subtyping check. Result is whether
* this TypeVar could plausibly be a [super/sub]type of argument `tp` and if so,