summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2008-09-06 11:41:37 +0000
committerMartin Odersky <odersky@gmail.com>2008-09-06 11:41:37 +0000
commit7369338a6e9cbd43e547e4c4cb2123c34b60f6c6 (patch)
tree3be5e30fd360cc4844e20556863133637a6c60a5 /src
parent4334d8c9915c976ff083621e0df44bb7d2321064 (diff)
downloadscala-7369338a6e9cbd43e547e4c4cb2123c34b60f6c6.tar.gz
scala-7369338a6e9cbd43e547e4c4cb2123c34b60f6c6.tar.bz2
scala-7369338a6e9cbd43e547e4c4cb2123c34b60f6c6.zip
One more attempt to be sound and at the same ti...
One more attempt to be sound and at the same time let the plugin build go through.
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Definitions.scala2
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Symbols.scala5
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Types.scala18
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala5
-rw-r--r--src/library/scala/Predef.scala3
-rw-r--r--src/library/scala/_$Stable.scala13
-rwxr-xr-xsrc/library/scala/uncheckedStable.scala (renamed from src/library/scala/UncheckedStable.scala)5
7 files changed, 16 insertions, 35 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/Definitions.scala b/src/compiler/scala/tools/nsc/symtab/Definitions.scala
index cd24f34097..3e9230ca68 100644
--- a/src/compiler/scala/tools/nsc/symtab/Definitions.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Definitions.scala
@@ -44,7 +44,7 @@ trait Definitions {
var NullClass: Symbol = _
var NothingClass: Symbol = _
var SingletonClass: Symbol = _
- lazy val UncheckedStableClass = getClass("scala.UncheckedStable")
+ lazy val uncheckedStableClass = getClass("scala.uncheckedStable")
lazy val ClassClass: Symbol = getClass(sn.Class)
lazy val StringClass: Symbol = getClass(sn.String)
diff --git a/src/compiler/scala/tools/nsc/symtab/Symbols.scala b/src/compiler/scala/tools/nsc/symtab/Symbols.scala
index 7d0bd9476d..5ef82e4db7 100644
--- a/src/compiler/scala/tools/nsc/symtab/Symbols.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Symbols.scala
@@ -312,7 +312,10 @@ trait Symbols {
/** Does this symbol denote a stable value? */
final def isStable =
- isTerm && !hasFlag(MUTABLE) && (!hasFlag(METHOD | BYNAMEPARAM) || hasFlag(STABLE)) && !tpe.isVolatile
+ isTerm &&
+ !hasFlag(MUTABLE) &&
+ (!hasFlag(METHOD | BYNAMEPARAM) || hasFlag(STABLE)) &&
+ !(tpe.isVolatile && getAttributes(uncheckedStableClass).isEmpty)
def isDeferred =
hasFlag(DEFERRED) && !isClass
diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala
index 2d83924226..342d931eeb 100644
--- a/src/compiler/scala/tools/nsc/symtab/Types.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Types.scala
@@ -975,7 +975,6 @@ trait Types {
underlyingCache
}
- override def isStable = !underlying.isVolatile
/*
override def narrow: Type = {
if (phase.erasedTypes) this
@@ -1180,21 +1179,17 @@ trait Types {
def contributesAbstractMembers(p: Type) =
p.deferredMembers exists isVisible
- ((parents exists (_.isVolatile)) ||
- (parents dropWhile (! _.typeSymbol.isAbstractType) match {
+ (parents exists (_.isVolatile)) ||
+ (parents dropWhile (! _.typeSymbol.isAbstractType) match {
case ps @ (_ :: ps1) =>
(ps ne parents) ||
(ps1 exists contributesAbstractMembers) ||
(decls.elements exists (m => m.isDeferred && isVisible(m)))
case _ =>
false
- })) &&
- !(typeSymbol isNonBottomSubClass UncheckedStableClass) // escape hatch!
+ })
}
- override def isStable =
- (parents exists (_.isStable)) && !isVolatile
-
override def kind = "RefinedType"
}
@@ -1381,9 +1376,8 @@ trait Types {
override def isStable: Boolean = {
sym == SingletonClass ||
- sym == UncheckedStableClass ||
sym.isAliasType && normalize.isStable ||
- sym.isAbstractType && bounds.hi.isStable
+ sym.isAbstractType && (bounds.hi.typeSymbol isSubClass SingletonClass)
}
override def isVolatile: Boolean =
@@ -2622,8 +2616,6 @@ A type's typeSymbol should never be inspected directly.
}
def singletonBounds(hi: Type) = {
- if (hi.isVolatile)
- throw new MalformedType("cannot abstract over singleton with volatile type "+hi)
mkTypeBounds(NothingClass.tpe, intersectionType(List(hi, SingletonClass.tpe)))
}
@@ -2702,8 +2694,6 @@ A type's typeSymbol should never be inspected directly.
if (!(pre1.isStable ||
pre1.typeSymbol.isPackageClass ||
pre1.typeSymbol.isModuleClass && pre1.typeSymbol.isStatic)) {
- if (pre1.isVolatile)
- throw new MalformedType("non-stable type "+pre1+" replacing a stable reference "+tp)
stabilize(pre1, sym)
} else {
pre1
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 592d95fd2e..798a0f91af 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -2240,6 +2240,9 @@ trait Typers { self: Analyzer =>
if (wc.symbol == NoSymbol) { namer.enterSym(wc); wc.symbol setFlag EXISTENTIAL }
else context.scope enter wc.symbol
val whereClauses1 = typedStats(tree.whereClauses, context.owner)
+ for (vd @ ValDef(_, _, _, _) <- tree.whereClauses)
+ if (vd.symbol.tpe.isVolatile)
+ error(vd.pos, "illegal abstraction from value with volatile type "+vd.symbol.tpe)
val tpt1 = typedType(tree.tpt, mode)
val (typeParams, tpe) = existentialTransform(tree.whereClauses map (_.symbol), tpt1.tpe)
//println(tpe + ": " + tpe.getClass )
@@ -3424,7 +3427,7 @@ trait Typers { self: Analyzer =>
/** Types a higher-kinded type tree -- pt denotes the expected kind*/
def typedHigherKindedType(tree: Tree, mode: Int, pt: Type): Tree =
if (pt.typeParams.isEmpty) typedType(tree, mode) // kind is known and it's *
- else typed(tree, HKmode, pt)//!!!
+ else typed(tree, HKmode, pt)
def typedHigherKindedType(tree: Tree, mode: Int): Tree =
typed(tree, HKmode, WildcardType)
diff --git a/src/library/scala/Predef.scala b/src/library/scala/Predef.scala
index ce3b05771c..f1bff1f990 100644
--- a/src/library/scala/Predef.scala
+++ b/src/library/scala/Predef.scala
@@ -114,9 +114,6 @@ object Predef {
// tupling ------------------------------------------------------------
- def uncheckedStable[A](x: A): A with UncheckedStable =
- x.asInstanceOf[A with UncheckedStable]
-
type Pair[+A, +B] = Tuple2[A, B]
object Pair {
def apply[A, B](x: A, y: B) = Tuple2(x, y)
diff --git a/src/library/scala/_$Stable.scala b/src/library/scala/_$Stable.scala
deleted file mode 100644
index d98cbaec7b..0000000000
--- a/src/library/scala/_$Stable.scala
+++ /dev/null
@@ -1,13 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-package scala
-
-/** A marker thread for types that are assumed to be stable
- * todo: internalize in Definitions
- */
-trait _$Stable {}
diff --git a/src/library/scala/UncheckedStable.scala b/src/library/scala/uncheckedStable.scala
index fab43b48a7..8d423c10bc 100755
--- a/src/library/scala/UncheckedStable.scala
+++ b/src/library/scala/uncheckedStable.scala
@@ -7,6 +7,7 @@
\* */
package scala
-/** A marker class for types that are assumed to be stable
+/** An annotation for values that are assumed to be stable even though their
+ * types are volatile.
*/
-abstract final class UncheckedStable {}
+final class uncheckedStable extends StaticAnnotation {}