| CODENOTIFIER | HelpYou are not signed inSign in |
Project: Scala
Revision: 16033
Author: odersky
Date: 05 Sep 2008 09:07:08
Diff at Trac: https://lampsvn.epfl.ch/trac/scala/changeset/16033
Changes:fixed problem with volatile types. hopefully plugin will build now.
Files:| ... | ...@@ -377,6 +377,10 @@ | |
| 377 | 377 | def implicitMembers: List[Symbol] = |
| 378 | 378 | findMember(nme.ANYNAME, BRIDGE, IMPLICIT, false)(NoSymbol).alternatives |
| 379 | 379 | |
| 380 | /** A list of all deferred symbols of this type (defined or inherited) */ | |
| 381 | def deferredMembers: List[Symbol] = | |
| 382 | findMember(nme.ANYNAME, BRIDGE, DEFERRED, false)(NoSymbol).alternatives | |
| 383 | ||
| 380 | 384 | /** The member with given name, |
| 381 | 385 | * an OverloadedSymbol if several exist, NoSymbol if none exist */ |
| 382 | 386 | def member(name: Name): Symbol = findMember(name, BRIDGE, 0, false)(NoSymbol) |
| ... | ...@@ -849,7 +853,7 @@ | |
| 849 | 853 | abstract class SingletonType extends SubType with SimpleTypeProxy { |
| 850 | 854 | def supertype = underlying |
| 851 | 855 | override def isTrivial = false |
| 852 | override def isStable = !underlying.isVolatile | |
| 856 | override def isStable = true | |
| 853 | 857 | override def isVolatile = underlying.isVolatile |
| 854 | 858 | override def widen: Type = underlying.widen |
| 855 | 859 | override def baseTypeSeq: BaseTypeSeq = { |
| ... | ...@@ -970,6 +974,8 @@ | |
| 970 | 974 | assert(underlyingCache ne this, this) |
| 971 | 975 | underlyingCache |
| 972 | 976 | } |
| 977 | ||
| 978 | override def isStable = !underlying.isVolatile | |
| 973 | 979 | /* |
| 974 | 980 | override def narrow: Type = { |
| 975 | 981 | if (phase.erasedTypes) this |
| ... | ...@@ -1159,12 +1165,28 @@ | |
| 1159 | 1165 | decls)) |
| 1160 | 1166 | else super.normalize |
| 1161 | 1167 | |
| 1162 | override def isVolatile = false // for now; this should really be: | |
| 1163 | /* | |
| 1164 | !parents.isEmpty && | |
| 1165 | (!parents.tail.isEmpty || !decls.isEmpty) && | |
| 1166 | (parents exists (_.typeSymbol.isAbstractType)) | |
| 1167 | */ | |
| 1168 | /** A refined type P1 with ... with Pn { decls } is volatile if | |
| 1169 | * one of the parent types Pi is an abstract type, and either decls | |
| 1170 | * or a following parent Pj, j > i, contributes an abstract member. | |
| 1171 | * A type contributes an abstract member if it has an abstract member which | |
| 1172 | * is also a member of the whole refined type. A scope `decls' contributes | |
| 1173 | * an abstract member if it has an abstract definition which is also | |
| 1174 | * a member of the whole type. | |
| 1175 | */ | |
| 1176 | override def isVolatile = { | |
| 1177 | def isVisible(m: Symbol) = | |
| 1178 | this.nonPrivateMember(m.name).alternatives contains m | |
| 1179 | def contributesAbstractMembers(p: Type) = | |
| 1180 | p.deferredMembers exists isVisible | |
| 1181 | ||
| 1182 | parents dropWhile (! _.typeSymbol.isAbstractType) match { | |
| 1183 | case _ :: ps => | |
| 1184 | (ps exists contributesAbstractMembers) || | |
| 1185 | (decls.elements exists (m => m.isDeferred && isVisible(m))) | |
| 1186 | case _ => | |
| 1187 | false | |
| 1188 | } | |
| 1189 | } | |
| 1168 | 1190 | |
| 1169 | 1191 | override def kind = "RefinedType" |
| 1170 | 1192 | } |
| ... | ...@@ -2671,7 +2693,8 @@ | |
| 2671 | 2693 | if (!(pre1.isStable || |
| 2672 | 2694 | pre1.typeSymbol.isPackageClass || |
| 2673 | 2695 | pre1.typeSymbol.isModuleClass && pre1.typeSymbol.isStatic)) { |
| 2674 | // throw new MalformedType("non-stable type "+pre1+" replacing a stable reference "+tp) | |
| 2696 | if (pre1.isVolatile) | |
| 2697 | throw new MalformedType("non-stable type "+pre1+" replacing a stable reference "+tp) | |
| 2675 | 2698 | stabilize(pre1, sym) |
| 2676 | 2699 | } else { |
| 2677 | 2700 | pre1 |
| ... | ...@@ -0,0 +1,5 @@ | |
| 1 | null-unsoundness.scala:8: error: stable identifier required, but A.this.x found. | |
| 2 | Note that value x is not stable because its type, A.this.D with A.this.A, is volatile. | |
| 3 | var y: x.T = new C("abc") | |
| 4 | ^ | |
| 5 | one error found |
| ... | ...@@ -0,0 +1,15 @@ | |
| 1 | class B | |
| 2 | class C(x: String) extends B | |
| 3 | ||
| 4 | class A { | |
| 5 | type A >: Null | |
| 6 | class D { type T >: C <: B } | |
| 7 | val x: D with A = null | |
| 8 | var y: x.T = new C("abc") | |
| 9 | } | |
| 10 | object Test extends A with Application { | |
| 11 | class C { type T = Int; val x = 1 } | |
| 12 | type A = C | |
| 13 | y = 42 | |
| 14 | } | |
| 15 |