>
* return `tp with x.type' else return `tp'.
*/
def narrowRhs(tp: Type) = {
var sym = context.tree.symbol
- if (sym != null && sym != NoSymbol && sym.owner.isClass && sym.getter(sym.owner) != NoSymbol)
- sym = sym.getter(sym.owner)
+ if (sym != null && sym != NoSymbol)
+ if (sym.owner.isClass) {
+ if (sym.getter(sym.owner) != NoSymbol) sym = sym.getter(sym.owner)
+ } else if (sym hasFlag LAZY) {
+ if (sym.lazyAccessor != NoSymbol) sym = sym.lazyAccessor
+ }
context.tree match {
case ValDef(mods, _, _, Apply(Select(`tree`, _), _)) if !(mods hasFlag MUTABLE) =>
val pre = if (sym.owner.isClass) sym.owner.thisType else NoPrefix
diff --git a/src/library/scala/package.scala b/src/library/scala/package.scala
index 8aed92949..f62efb08d 100644
--- a/src/library/scala/package.scala
+++ b/src/library/scala/package.scala
@@ -11,7 +11,7 @@
package object scala {
- type Travarsable[+A] = scala.collection.Traversable[A]
+ type Traversable[+A] = scala.collection.Traversable[A]
val Traversable = scala.collection.Traversable
type Iterable[+A] = scala.collection.Iterable[A]
diff --git a/src/library/scala/util/control/Breaks.scala b/src/library/scala/util/control/Breaks.scala
index 3ceca71e7..7e658a434 100644
--- a/src/library/scala/util/control/Breaks.scala
+++ b/src/library/scala/util/control/Breaks.scala
@@ -11,10 +11,11 @@
package scala.util.control
-/** An object that can be used for the break control abstraction.
+/** A class that can be instantiated for the break control abstraction.
* Example usage:
*
- * import Breaks.{break, breakable}
+ * val mybreaks = new Breaks
+ * import mybreaks.{break, breakable}
*
* breakable {
* for (...) {
@@ -22,6 +23,8 @@ package scala.util.control
* }
* }
*
+ * Calls to break from one instantiation of Breaks will never
+ * target breakable objects of some other instantion.
*/
class Breaks {
@@ -37,11 +40,25 @@ class Breaks {
}
}
- /* Break from closest enclosing breakable block */
+ /* Break from dynamically closest enclosing breakable block
+ * @note this might be different than the statically closest enclosing
+ * block!
+ */
def break { throw breakException }
}
-/** A singleton object providing the Break functionality */
+/** An object that can be used for the break control abstraction.
+ * Example usage:
+ *
+ * import Breaks.{break, breakable}
+ *
+ * breakable {
+ * for (...) {
+ * if (...) break
+ * }
+ * }
+ *
+ */
object Breaks extends Breaks
private class BreakException extends RuntimeException with ControlException
diff --git a/test/files/pos/t2545.scala b/test/files/pos/t2545.scala
new file mode 100755
index 000000000..b4238fb71
--- /dev/null
+++ b/test/files/pos/t2545.scala
@@ -0,0 +1,10 @@
+trait Frog[T] {
+ def hello: T
+ def size: Int
+ }
+
+ trait OnlyWithFrogs {
+ self: Frog[_] =>
+
+ def sizeStr = size.toString
+ }