From 416abb70256267ccb80b7f5b6d205c9f384a14e0 Mon Sep 17 00:00:00 2001 From: Iulian Dragos Date: Mon, 30 Apr 2012 11:46:33 +0200 Subject: Fixed `Setting.enabling` to properly disable dependent settings when the original setting is set to `false`. This can be witnessed in the IDE, when explicitly setting the `-optimize` flag to false leads to setting all the dependent flags to true (`-Yinline`, `-Ydce`, `-Ycloselim`). --- src/compiler/scala/tools/nsc/settings/ScalaSettings.scala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala index 91e31cae97..0a9d25af7e 100644 --- a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala @@ -41,11 +41,11 @@ trait ScalaSettings extends AbsScalaSettings protected def optimiseSettings = List[BooleanSetting](inline, inlineHandlers, Xcloselim, Xdce) /** Internal use - syntax enhancements. */ - private class EnableSettings[T <: Setting](val s: T) { - def enabling(toEnable: List[BooleanSetting]): s.type = s withPostSetHook (_ => toEnable foreach (_.value = true)) + private class EnableSettings[T <: BooleanSetting](val s: T) { + def enabling(toEnable: List[BooleanSetting]): s.type = s withPostSetHook (_ => toEnable foreach (_.value = s.value)) def andThen(f: s.T => Unit): s.type = s withPostSetHook (setting => f(setting.value)) } - private implicit def installEnableSettings[T <: Setting](s: T) = new EnableSettings(s) + private implicit def installEnableSettings[T <: BooleanSetting](s: T) = new EnableSettings(s) /** Disable a setting */ def disable(s: Setting) = allSettings -= s -- cgit v1.2.3 From b72f52bbd59602ec9e09900381d5ff19752fa961 Mon Sep 17 00:00:00 2001 From: Iulian Dragos Date: Mon, 30 Apr 2012 11:53:41 +0200 Subject: Presentation Compiler tests for visibility of members. Removed some unneeded indirection in the testing framework. --- .../nsc/interactive/tests/core/CoreTestDefs.scala | 20 +- .../tests/core/PresentationCompilerTestDef.scala | 4 - test/files/presentation/callcc-interpreter.check | 120 +++++------ test/files/presentation/ide-bug-1000349.check | 68 +++--- test/files/presentation/ide-bug-1000475.check | 192 ++++++++--------- test/files/presentation/ide-bug-1000531.check | 238 ++++++++++----------- test/files/presentation/implicit-member.check | 70 +++--- test/files/presentation/ping-pong.check | 142 ++++++------ test/files/presentation/visibility.check | 221 +++++++++++++++++++ test/files/presentation/visibility/Test.scala | 5 + .../presentation/visibility/src/Completions.scala | 40 ++++ 11 files changed, 687 insertions(+), 433 deletions(-) create mode 100644 test/files/presentation/visibility.check create mode 100644 test/files/presentation/visibility/Test.scala create mode 100644 test/files/presentation/visibility/src/Completions.scala (limited to 'src') diff --git a/src/compiler/scala/tools/nsc/interactive/tests/core/CoreTestDefs.scala b/src/compiler/scala/tools/nsc/interactive/tests/core/CoreTestDefs.scala index 9646ee1cf0..d6102734ab 100644 --- a/src/compiler/scala/tools/nsc/interactive/tests/core/CoreTestDefs.scala +++ b/src/compiler/scala/tools/nsc/interactive/tests/core/CoreTestDefs.scala @@ -17,15 +17,11 @@ private[tests] trait CoreTestDefs extends PresentationCompilerTestDef with AskCompletionAt { - object MemberPrinter { - def apply(member: compiler.Member): String = - "`" + (member.sym.toString() + member.tpe.toString()).trim() + "`" - } - - protected val marker = CompletionMarker + def memberPrinter(member: compiler.Member): String = + "[accessible: %5s] ".format(member.accessible) + "`" + (member.sym.toString() + member.tpe.toString()).trim() + "`" override def runTest() { - askAllSources(marker) { pos => + askAllSources(CompletionMarker) { pos => askCompletionAt(pos) } { (pos, members) => withResponseDelimiter { @@ -35,7 +31,7 @@ private[tests] trait CoreTestDefs reporter.println("retrieved %d members".format(members.size)) compiler ask { () => val filtered = members.filterNot(member => member.sym.name.toString == "getClass" || member.sym.isConstructor) - reporter.println(filtered.map(MemberPrinter(_)).sortBy(_.toString()).mkString("\n")) + reporter.println(filtered.map(memberPrinter).sortBy(_.toString()).mkString("\n")) } } } @@ -48,10 +44,8 @@ private[tests] trait CoreTestDefs extends PresentationCompilerTestDef with AskTypeAt { - protected val marker = TypeMarker - override def runTest() { - askAllSources(marker) { pos => + askAllSources(TypeMarker) { pos => askTypeAt(pos) } { (pos, tree) => withResponseDelimiter { @@ -69,10 +63,8 @@ private[tests] trait CoreTestDefs with AskTypeAt with AskCompletionAt { - protected val marker = HyperlinkMarker - override def runTest() { - askAllSources(marker) { pos => + askAllSources(HyperlinkMarker) { pos => askTypeAt(pos)(NullReporter) } { (pos, tree) => if(tree.symbol == compiler.NoSymbol) { diff --git a/src/compiler/scala/tools/nsc/interactive/tests/core/PresentationCompilerTestDef.scala b/src/compiler/scala/tools/nsc/interactive/tests/core/PresentationCompilerTestDef.scala index 390363eca8..8b8be697cc 100644 --- a/src/compiler/scala/tools/nsc/interactive/tests/core/PresentationCompilerTestDef.scala +++ b/src/compiler/scala/tools/nsc/interactive/tests/core/PresentationCompilerTestDef.scala @@ -5,10 +5,6 @@ import scala.tools.nsc.util.Position trait PresentationCompilerTestDef { - def compiler: Global - - protected val marker: TestMarker - private[tests] def runTest(): Unit protected def withResponseDelimiter(block: => Unit)(implicit reporter: Reporter) { diff --git a/test/files/presentation/callcc-interpreter.check b/test/files/presentation/callcc-interpreter.check index c50e171b4e..68ac904b18 100644 --- a/test/files/presentation/callcc-interpreter.check +++ b/test/files/presentation/callcc-interpreter.check @@ -4,66 +4,66 @@ askTypeCompletion at CallccInterpreter.scala(51,38) ================================================================================ [response] aksTypeCompletion at (51,38) retrieved 64 members -`class AddcallccInterpreter.Add` -`class AppcallccInterpreter.App` -`class CcccallccInterpreter.Ccc` -`class ConcallccInterpreter.Con` -`class FuncallccInterpreter.Fun` -`class LamcallccInterpreter.Lam` -`class McallccInterpreter.M` -`class NumcallccInterpreter.Num` -`class VarcallccInterpreter.Var` -`method !=(x$1: Any)Boolean` -`method !=(x$1: AnyRef)Boolean` -`method ##()Int` -`method +(other: String)String` -`method ->[B](y: B)(callccInterpreter.type, B)` -`method ==(x$1: Any)Boolean` -`method ==(x$1: AnyRef)Boolean` -`method add(a: callccInterpreter.Value, b: callccInterpreter.Value)callccInterpreter.M[_ >: callccInterpreter.Num with callccInterpreter.Wrong.type <: Product with Serializable with callccInterpreter.Value]` -`method apply(a: callccInterpreter.Value, b: callccInterpreter.Value)callccInterpreter.M[callccInterpreter.Value]` -`method asInstanceOf[T0]=> T0` -`method callCC[A](h: (A => callccInterpreter.M[A]) => callccInterpreter.M[A])callccInterpreter.M[A]` -`method clone()Object` -`method ensuring(cond: Boolean)callccInterpreter.type` -`method ensuring(cond: Boolean, msg: => Any)callccInterpreter.type` -`method ensuring(cond: callccInterpreter.type => Boolean)callccInterpreter.type` -`method ensuring(cond: callccInterpreter.type => Boolean, msg: => Any)callccInterpreter.type` -`method eq(x$1: AnyRef)Boolean` -`method equals(x$1: Any)Boolean` -`method finalize()Unit` -`method formatted(fmtstr: String)String` -`method hashCode()Int` -`method id[A]=> A => A` -`method interp(t: callccInterpreter.Term, e: callccInterpreter.Environment)callccInterpreter.M[callccInterpreter.Value]` -`method isInstanceOf[T0]=> Boolean` -`method lookup(x: callccInterpreter.Name, e: callccInterpreter.Environment)callccInterpreter.M[callccInterpreter.Value]` -`method main(args: Array[String])Unit` -`method ne(x$1: AnyRef)Boolean` -`method notify()Unit` -`method notifyAll()Unit` -`method showM(m: callccInterpreter.M[callccInterpreter.Value])String` -`method synchronized[T0](x$1: T0)T0` -`method test(t: callccInterpreter.Term)String` -`method toString()String` -`method unitM[A](a: A)callccInterpreter.M[A]` -`method wait()Unit` -`method wait(x$1: Long)Unit` -`method wait(x$1: Long, x$2: Int)Unit` -`method x=> callccInterpreter.type` -`method →[B](y: B)(callccInterpreter.type, B)` -`object WrongcallccInterpreter.Wrong.type` -`trait TermcallccInterpreter.Term` -`trait ValuecallccInterpreter.Value` -`type AnswercallccInterpreter.Answer` -`type EnvironmentcallccInterpreter.Environment` -`type NamecallccInterpreter.Name` -`value __leftOfArrowcallccInterpreter.type` -`value __resultOfEnsuringcallccInterpreter.type` -`value selfAny` -`value term0callccInterpreter.App` -`value term1callccInterpreter.App` -`value term2callccInterpreter.Add` +[accessible: true] `class AddcallccInterpreter.Add` +[accessible: true] `class AppcallccInterpreter.App` +[accessible: true] `class CcccallccInterpreter.Ccc` +[accessible: true] `class ConcallccInterpreter.Con` +[accessible: true] `class FuncallccInterpreter.Fun` +[accessible: true] `class LamcallccInterpreter.Lam` +[accessible: true] `class McallccInterpreter.M` +[accessible: true] `class NumcallccInterpreter.Num` +[accessible: true] `class VarcallccInterpreter.Var` +[accessible: true] `method !=(x$1: Any)Boolean` +[accessible: true] `method !=(x$1: AnyRef)Boolean` +[accessible: true] `method ##()Int` +[accessible: true] `method +(other: String)String` +[accessible: true] `method ->[B](y: B)(callccInterpreter.type, B)` +[accessible: true] `method ==(x$1: Any)Boolean` +[accessible: true] `method ==(x$1: AnyRef)Boolean` +[accessible: true] `method add(a: callccInterpreter.Value, b: callccInterpreter.Value)callccInterpreter.M[_ >: callccInterpreter.Num with callccInterpreter.Wrong.type <: Product with Serializable with callccInterpreter.Value]` +[accessible: true] `method apply(a: callccInterpreter.Value, b: callccInterpreter.Value)callccInterpreter.M[callccInterpreter.Value]` +[accessible: true] `method asInstanceOf[T0]=> T0` +[accessible: true] `method callCC[A](h: (A => callccInterpreter.M[A]) => callccInterpreter.M[A])callccInterpreter.M[A]` +[accessible: true] `method clone()Object` +[accessible: true] `method ensuring(cond: Boolean)callccInterpreter.type` +[accessible: true] `method ensuring(cond: Boolean, msg: => Any)callccInterpreter.type` +[accessible: true] `method ensuring(cond: callccInterpreter.type => Boolean)callccInterpreter.type` +[accessible: true] `method ensuring(cond: callccInterpreter.type => Boolean, msg: => Any)callccInterpreter.type` +[accessible: true] `method eq(x$1: AnyRef)Boolean` +[accessible: true] `method equals(x$1: Any)Boolean` +[accessible: true] `method finalize()Unit` +[accessible: true] `method formatted(fmtstr: String)String` +[accessible: true] `method hashCode()Int` +[accessible: true] `method id[A]=> A => A` +[accessible: true] `method interp(t: callccInterpreter.Term, e: callccInterpreter.Environment)callccInterpreter.M[callccInterpreter.Value]` +[accessible: true] `method isInstanceOf[T0]=> Boolean` +[accessible: true] `method lookup(x: callccInterpreter.Name, e: callccInterpreter.Environment)callccInterpreter.M[callccInterpreter.Value]` +[accessible: true] `method main(args: Array[String])Unit` +[accessible: true] `method ne(x$1: AnyRef)Boolean` +[accessible: true] `method notify()Unit` +[accessible: true] `method notifyAll()Unit` +[accessible: true] `method showM(m: callccInterpreter.M[callccInterpreter.Value])String` +[accessible: true] `method synchronized[T0](x$1: T0)T0` +[accessible: true] `method test(t: callccInterpreter.Term)String` +[accessible: true] `method toString()String` +[accessible: true] `method unitM[A](a: A)callccInterpreter.M[A]` +[accessible: true] `method wait()Unit` +[accessible: true] `method wait(x$1: Long)Unit` +[accessible: true] `method wait(x$1: Long, x$2: Int)Unit` +[accessible: true] `method x=> callccInterpreter.type` +[accessible: true] `method →[B](y: B)(callccInterpreter.type, B)` +[accessible: true] `object WrongcallccInterpreter.Wrong.type` +[accessible: true] `trait TermcallccInterpreter.Term` +[accessible: true] `trait ValuecallccInterpreter.Value` +[accessible: true] `type AnswercallccInterpreter.Answer` +[accessible: true] `type EnvironmentcallccInterpreter.Environment` +[accessible: true] `type NamecallccInterpreter.Name` +[accessible: true] `value term0callccInterpreter.App` +[accessible: true] `value term1callccInterpreter.App` +[accessible: true] `value term2callccInterpreter.Add` +[accessible: false] `value __leftOfArrowcallccInterpreter.type` +[accessible: false] `value __resultOfEnsuringcallccInterpreter.type` +[accessible: false] `value selfAny` ================================================================================ askType at CallccInterpreter.scala(14,21) diff --git a/test/files/presentation/ide-bug-1000349.check b/test/files/presentation/ide-bug-1000349.check index 9c070ef24e..d643f82a25 100644 --- a/test/files/presentation/ide-bug-1000349.check +++ b/test/files/presentation/ide-bug-1000349.check @@ -4,37 +4,37 @@ askTypeCompletion at CompletionOnEmptyArgMethod.scala(2,17) ================================================================================ [response] aksTypeCompletion at (2,17) retrieved 37 members -`method !=(x$1: Any)Boolean` -`method !=(x$1: AnyRef)Boolean` -`method ##()Int` -`method +(other: String)String` -`method ->[B](y: B)(Foo, B)` -`method ==(x$1: Any)Boolean` -`method ==(x$1: AnyRef)Boolean` -`method asInstanceOf[T0]=> T0` -`method clone()Object` -`method ensuring(cond: Boolean)Foo` -`method ensuring(cond: Boolean, msg: => Any)Foo` -`method ensuring(cond: Foo => Boolean)Foo` -`method ensuring(cond: Foo => Boolean, msg: => Any)Foo` -`method eq(x$1: AnyRef)Boolean` -`method equals(x$1: Any)Boolean` -`method finalize()Unit` -`method foo=> Foo` -`method formatted(fmtstr: String)String` -`method hashCode()Int` -`method isInstanceOf[T0]=> Boolean` -`method ne(x$1: AnyRef)Boolean` -`method notify()Unit` -`method notifyAll()Unit` -`method synchronized[T0](x$1: T0)T0` -`method toString()String` -`method wait()Unit` -`method wait(x$1: Long)Unit` -`method wait(x$1: Long, x$2: Int)Unit` -`method x=> Foo` -`method →[B](y: B)(Foo, B)` -`value __leftOfArrowFoo` -`value __resultOfEnsuringFoo` -`value selfAny` -================================================================================ \ No newline at end of file +[accessible: true] `method !=(x$1: Any)Boolean` +[accessible: true] `method !=(x$1: AnyRef)Boolean` +[accessible: true] `method ##()Int` +[accessible: true] `method +(other: String)String` +[accessible: true] `method ->[B](y: B)(Foo, B)` +[accessible: true] `method ==(x$1: Any)Boolean` +[accessible: true] `method ==(x$1: AnyRef)Boolean` +[accessible: true] `method asInstanceOf[T0]=> T0` +[accessible: true] `method clone()Object` +[accessible: true] `method ensuring(cond: Boolean)Foo` +[accessible: true] `method ensuring(cond: Boolean, msg: => Any)Foo` +[accessible: true] `method ensuring(cond: Foo => Boolean)Foo` +[accessible: true] `method ensuring(cond: Foo => Boolean, msg: => Any)Foo` +[accessible: true] `method eq(x$1: AnyRef)Boolean` +[accessible: true] `method equals(x$1: Any)Boolean` +[accessible: true] `method finalize()Unit` +[accessible: true] `method foo=> Foo` +[accessible: true] `method formatted(fmtstr: String)String` +[accessible: true] `method hashCode()Int` +[accessible: true] `method isInstanceOf[T0]=> Boolean` +[accessible: true] `method ne(x$1: AnyRef)Boolean` +[accessible: true] `method notify()Unit` +[accessible: true] `method notifyAll()Unit` +[accessible: true] `method synchronized[T0](x$1: T0)T0` +[accessible: true] `method toString()String` +[accessible: true] `method wait()Unit` +[accessible: true] `method wait(x$1: Long)Unit` +[accessible: true] `method wait(x$1: Long, x$2: Int)Unit` +[accessible: true] `method x=> Foo` +[accessible: true] `method →[B](y: B)(Foo, B)` +[accessible: false] `value __leftOfArrowFoo` +[accessible: false] `value __resultOfEnsuringFoo` +[accessible: false] `value selfAny` +================================================================================ diff --git a/test/files/presentation/ide-bug-1000475.check b/test/files/presentation/ide-bug-1000475.check index 1718119385..2410ebf71d 100644 --- a/test/files/presentation/ide-bug-1000475.check +++ b/test/files/presentation/ide-bug-1000475.check @@ -4,112 +4,112 @@ askTypeCompletion at Foo.scala(3,7) ================================================================================ [response] aksTypeCompletion at (3,7) retrieved 36 members -`method !=(x$1: Any)Boolean` -`method !=(x$1: AnyRef)Boolean` -`method ##()Int` -`method +(other: String)String` -`method ->[B](y: B)(Object, B)` -`method ==(x$1: Any)Boolean` -`method ==(x$1: AnyRef)Boolean` -`method asInstanceOf[T0]=> T0` -`method clone()Object` -`method ensuring(cond: Boolean)Object` -`method ensuring(cond: Boolean, msg: => Any)Object` -`method ensuring(cond: Object => Boolean)Object` -`method ensuring(cond: Object => Boolean, msg: => Any)Object` -`method eq(x$1: AnyRef)Boolean` -`method equals(x$1: Any)Boolean` -`method finalize()Unit` -`method formatted(fmtstr: String)String` -`method hashCode()Int` -`method isInstanceOf[T0]=> Boolean` -`method ne(x$1: AnyRef)Boolean` -`method notify()Unit` -`method notifyAll()Unit` -`method synchronized[T0](x$1: T0)T0` -`method toString()String` -`method wait()Unit` -`method wait(x$1: Long)Unit` -`method wait(x$1: Long, x$2: Int)Unit` -`method x=> Object` -`method →[B](y: B)(Object, B)` -`value __leftOfArrowObject` -`value __resultOfEnsuringObject` -`value selfAny` +[accessible: true] `method !=(x$1: Any)Boolean` +[accessible: true] `method !=(x$1: AnyRef)Boolean` +[accessible: true] `method ##()Int` +[accessible: true] `method +(other: String)String` +[accessible: true] `method ->[B](y: B)(Object, B)` +[accessible: true] `method ==(x$1: Any)Boolean` +[accessible: true] `method ==(x$1: AnyRef)Boolean` +[accessible: true] `method asInstanceOf[T0]=> T0` +[accessible: true] `method ensuring(cond: Boolean)Object` +[accessible: true] `method ensuring(cond: Boolean, msg: => Any)Object` +[accessible: true] `method ensuring(cond: Object => Boolean)Object` +[accessible: true] `method ensuring(cond: Object => Boolean, msg: => Any)Object` +[accessible: true] `method eq(x$1: AnyRef)Boolean` +[accessible: true] `method equals(x$1: Any)Boolean` +[accessible: true] `method formatted(fmtstr: String)String` +[accessible: true] `method hashCode()Int` +[accessible: true] `method isInstanceOf[T0]=> Boolean` +[accessible: true] `method ne(x$1: AnyRef)Boolean` +[accessible: true] `method notify()Unit` +[accessible: true] `method notifyAll()Unit` +[accessible: true] `method synchronized[T0](x$1: T0)T0` +[accessible: true] `method toString()String` +[accessible: true] `method wait()Unit` +[accessible: true] `method wait(x$1: Long)Unit` +[accessible: true] `method wait(x$1: Long, x$2: Int)Unit` +[accessible: true] `method x=> Object` +[accessible: true] `method →[B](y: B)(Object, B)` +[accessible: false] `method clone()Object` +[accessible: false] `method finalize()Unit` +[accessible: false] `value __leftOfArrowObject` +[accessible: false] `value __resultOfEnsuringObject` +[accessible: false] `value selfAny` ================================================================================ askTypeCompletion at Foo.scala(6,10) ================================================================================ [response] aksTypeCompletion at (6,10) retrieved 36 members -`method !=(x$1: Any)Boolean` -`method !=(x$1: AnyRef)Boolean` -`method ##()Int` -`method +(other: String)String` -`method ->[B](y: B)(Object, B)` -`method ==(x$1: Any)Boolean` -`method ==(x$1: AnyRef)Boolean` -`method asInstanceOf[T0]=> T0` -`method clone()Object` -`method ensuring(cond: Boolean)Object` -`method ensuring(cond: Boolean, msg: => Any)Object` -`method ensuring(cond: Object => Boolean)Object` -`method ensuring(cond: Object => Boolean, msg: => Any)Object` -`method eq(x$1: AnyRef)Boolean` -`method equals(x$1: Any)Boolean` -`method finalize()Unit` -`method formatted(fmtstr: String)String` -`method hashCode()Int` -`method isInstanceOf[T0]=> Boolean` -`method ne(x$1: AnyRef)Boolean` -`method notify()Unit` -`method notifyAll()Unit` -`method synchronized[T0](x$1: T0)T0` -`method toString()String` -`method wait()Unit` -`method wait(x$1: Long)Unit` -`method wait(x$1: Long, x$2: Int)Unit` -`method x=> Object` -`method →[B](y: B)(Object, B)` -`value __leftOfArrowObject` -`value __resultOfEnsuringObject` -`value selfAny` +[accessible: true] `method !=(x$1: Any)Boolean` +[accessible: true] `method !=(x$1: AnyRef)Boolean` +[accessible: true] `method ##()Int` +[accessible: true] `method +(other: String)String` +[accessible: true] `method ->[B](y: B)(Object, B)` +[accessible: true] `method ==(x$1: Any)Boolean` +[accessible: true] `method ==(x$1: AnyRef)Boolean` +[accessible: true] `method asInstanceOf[T0]=> T0` +[accessible: true] `method ensuring(cond: Boolean)Object` +[accessible: true] `method ensuring(cond: Boolean, msg: => Any)Object` +[accessible: true] `method ensuring(cond: Object => Boolean)Object` +[accessible: true] `method ensuring(cond: Object => Boolean, msg: => Any)Object` +[accessible: true] `method eq(x$1: AnyRef)Boolean` +[accessible: true] `method equals(x$1: Any)Boolean` +[accessible: true] `method formatted(fmtstr: String)String` +[accessible: true] `method hashCode()Int` +[accessible: true] `method isInstanceOf[T0]=> Boolean` +[accessible: true] `method ne(x$1: AnyRef)Boolean` +[accessible: true] `method notify()Unit` +[accessible: true] `method notifyAll()Unit` +[accessible: true] `method synchronized[T0](x$1: T0)T0` +[accessible: true] `method toString()String` +[accessible: true] `method wait()Unit` +[accessible: true] `method wait(x$1: Long)Unit` +[accessible: true] `method wait(x$1: Long, x$2: Int)Unit` +[accessible: true] `method x=> Object` +[accessible: true] `method →[B](y: B)(Object, B)` +[accessible: false] `method clone()Object` +[accessible: false] `method finalize()Unit` +[accessible: false] `value __leftOfArrowObject` +[accessible: false] `value __resultOfEnsuringObject` +[accessible: false] `value selfAny` ================================================================================ askTypeCompletion at Foo.scala(7,7) ================================================================================ [response] aksTypeCompletion at (7,7) retrieved 36 members -`method !=(x$1: Any)Boolean` -`method !=(x$1: AnyRef)Boolean` -`method ##()Int` -`method +(other: String)String` -`method ->[B](y: B)(Object, B)` -`method ==(x$1: Any)Boolean` -`method ==(x$1: AnyRef)Boolean` -`method asInstanceOf[T0]=> T0` -`method clone()Object` -`method ensuring(cond: Boolean)Object` -`method ensuring(cond: Boolean, msg: => Any)Object` -`method ensuring(cond: Object => Boolean)Object` -`method ensuring(cond: Object => Boolean, msg: => Any)Object` -`method eq(x$1: AnyRef)Boolean` -`method equals(x$1: Any)Boolean` -`method finalize()Unit` -`method formatted(fmtstr: String)String` -`method hashCode()Int` -`method isInstanceOf[T0]=> Boolean` -`method ne(x$1: AnyRef)Boolean` -`method notify()Unit` -`method notifyAll()Unit` -`method synchronized[T0](x$1: T0)T0` -`method toString()String` -`method wait()Unit` -`method wait(x$1: Long)Unit` -`method wait(x$1: Long, x$2: Int)Unit` -`method x=> Object` -`method →[B](y: B)(Object, B)` -`value __leftOfArrowObject` -`value __resultOfEnsuringObject` -`value selfAny` +[accessible: true] `method !=(x$1: Any)Boolean` +[accessible: true] `method !=(x$1: AnyRef)Boolean` +[accessible: true] `method ##()Int` +[accessible: true] `method +(other: String)String` +[accessible: true] `method ->[B](y: B)(Object, B)` +[accessible: true] `method ==(x$1: Any)Boolean` +[accessible: true] `method ==(x$1: AnyRef)Boolean` +[accessible: true] `method asInstanceOf[T0]=> T0` +[accessible: true] `method ensuring(cond: Boolean)Object` +[accessible: true] `method ensuring(cond: Boolean, msg: => Any)Object` +[accessible: true] `method ensuring(cond: Object => Boolean)Object` +[accessible: true] `method ensuring(cond: Object => Boolean, msg: => Any)Object` +[accessible: true] `method eq(x$1: AnyRef)Boolean` +[accessible: true] `method equals(x$1: Any)Boolean` +[accessible: true] `method formatted(fmtstr: String)String` +[accessible: true] `method hashCode()Int` +[accessible: true] `method isInstanceOf[T0]=> Boolean` +[accessible: true] `method ne(x$1: AnyRef)Boolean` +[accessible: true] `method notify()Unit` +[accessible: true] `method notifyAll()Unit` +[accessible: true] `method synchronized[T0](x$1: T0)T0` +[accessible: true] `method toString()String` +[accessible: true] `method wait()Unit` +[accessible: true] `method wait(x$1: Long)Unit` +[accessible: true] `method wait(x$1: Long, x$2: Int)Unit` +[accessible: true] `method x=> Object` +[accessible: true] `method →[B](y: B)(Object, B)` +[accessible: false] `method clone()Object` +[accessible: false] `method finalize()Unit` +[accessible: false] `value __leftOfArrowObject` +[accessible: false] `value __resultOfEnsuringObject` +[accessible: false] `value selfAny` ================================================================================ diff --git a/test/files/presentation/ide-bug-1000531.check b/test/files/presentation/ide-bug-1000531.check index 2b48a80d38..d9109bcc6a 100644 --- a/test/files/presentation/ide-bug-1000531.check +++ b/test/files/presentation/ide-bug-1000531.check @@ -4,123 +4,123 @@ askTypeCompletion at CrashOnLoad.scala(6,12) ================================================================================ [response] aksTypeCompletion at (6,12) retrieved 123 members -`class GroupedIteratorIterator[B]#GroupedIterator` -`method !=(x$1: Any)Boolean` -`method !=(x$1: AnyRef)Boolean` -`method ##()Int` -`method +(other: String)String` -`method ++[B >: B](that: => scala.collection.GenTraversableOnce[B])Iterator[B]` -`method ->[B](y: B)(java.util.Iterator[B], B)` -`method /:[B](z: B)(op: (B, B) => B)B` -`method /:\[A1 >: B](z: A1)(op: (A1, A1) => A1)A1` -`method :\[B](z: B)(op: (B, B) => B)B` -`method ==(x$1: Any)Boolean` -`method ==(x$1: AnyRef)Boolean` -`method addString(b: StringBuilder)StringBuilder` -`method addString(b: StringBuilder, sep: String)StringBuilder` -`method addString(b: StringBuilder, start: String, sep: String, end: String)StringBuilder` -`method aggregate[B](z: B)(seqop: (B, B) => B, combop: (B, B) => B)B` -`method asInstanceOf[T0]=> T0` -`method buffered=> scala.collection.BufferedIterator[B]` -`method clone()Object` -`method collectFirst[B](pf: PartialFunction[B,B])Option[B]` -`method collect[B](pf: PartialFunction[B,B])Iterator[B]` -`method contains(elem: Any)Boolean` -`method copyToArray[B >: B](xs: Array[B])Unit` -`method copyToArray[B >: B](xs: Array[B], start: Int)Unit` -`method copyToArray[B >: B](xs: Array[B], start: Int, len: Int)Unit` -`method copyToBuffer[B >: B](dest: scala.collection.mutable.Buffer[B])Unit` -`method count(p: B => Boolean)Int` -`method drop(n: Int)Iterator[B]` -`method dropWhile(p: B => Boolean)Iterator[B]` -`method duplicate=> (Iterator[B], Iterator[B])` -`method ensuring(cond: Boolean)java.util.Iterator[B]` -`method ensuring(cond: Boolean, msg: => Any)java.util.Iterator[B]` -`method ensuring(cond: java.util.Iterator[B] => Boolean)java.util.Iterator[B]` -`method ensuring(cond: java.util.Iterator[B] => Boolean, msg: => Any)java.util.Iterator[B]` -`method eq(x$1: AnyRef)Boolean` -`method equals(x$1: Any)Boolean` -`method exists(p: B => Boolean)Boolean` -`method filter(p: B => Boolean)Iterator[B]` -`method filterNot(p: B => Boolean)Iterator[B]` -`method finalize()Unit` -`method find(p: B => Boolean)Option[B]` -`method flatMap[B](f: B => scala.collection.GenTraversableOnce[B])Iterator[B]` -`method foldLeft[B](z: B)(op: (B, B) => B)B` -`method foldRight[B](z: B)(op: (B, B) => B)B` -`method fold[A1 >: B](z: A1)(op: (A1, A1) => A1)A1` -`method forall(p: B => Boolean)Boolean` -`method foreach[U](f: B => U)Unit` -`method formatted(fmtstr: String)String` -`method grouped[B >: B](size: Int)Iterator[B]#GroupedIterator[B]` -`method hasDefiniteSize=> Boolean` -`method hasNext()Boolean` -`method hashCode()Int` -`method indexOf[B >: B](elem: B)Int` -`method indexWhere(p: B => Boolean)Int` -`method isEmpty=> Boolean` -`method isInstanceOf[T0]=> Boolean` -`method isTraversableAgain=> Boolean` -`method length=> Int` -`method map[B](f: B => B)Iterator[B]` -`method maxBy[B](f: B => B)(implicit cmp: Ordering[B])B` -`method max[B >: B](implicit cmp: Ordering[B])B` -`method minBy[B](f: B => B)(implicit cmp: Ordering[B])B` -`method min[B >: B](implicit cmp: Ordering[B])B` -`method mkString(sep: String)String` -`method mkString(start: String, sep: String, end: String)String` -`method mkString=> String` -`method ne(x$1: AnyRef)Boolean` -`method next()B` -`method nonEmpty=> Boolean` -`method notify()Unit` -`method notifyAll()Unit` -`method padTo[A1 >: B](len: Int, elem: A1)Iterator[A1]` -`method partition(p: B => Boolean)(Iterator[B], Iterator[B])` -`method patch[B >: B](from: Int, patchElems: Iterator[B], replaced: Int)Iterator[B]` -`method product[B >: B](implicit num: Numeric[B])B` -`method reduceLeftOption[B >: B](op: (B, B) => B)Option[B]` -`method reduceLeft[B >: B](op: (B, B) => B)B` -`method reduceOption[A1 >: B](op: (A1, A1) => A1)Option[A1]` -`method reduceRightOption[B >: B](op: (B, B) => B)Option[B]` -`method reduceRight[B >: B](op: (B, B) => B)B` -`method reduce[A1 >: B](op: (A1, A1) => A1)A1` -`method remove()Unit` -`method reversed=> List[B]` -`method sameElements(that: Iterator[_])Boolean` -`method scanLeft[B](z: B)(op: (B, B) => B)Iterator[B]` -`method scanRight[B](z: B)(op: (B, B) => B)Iterator[B]` -`method seq=> Iterator[B]` -`method size=> Int` -`method slice(from: Int, until: Int)Iterator[B]` -`method sliding[B >: B](size: Int, step: Int)Iterator[B]#GroupedIterator[B]` -`method span(p: B => Boolean)(Iterator[B], Iterator[B])` -`method sum[B >: B](implicit num: Numeric[B])B` -`method synchronized[T0](x$1: T0)T0` -`method take(n: Int)Iterator[B]` -`method takeWhile(p: B => Boolean)Iterator[B]` -`method toArray[B >: B](implicit evidence$1: ArrayTag[B])Array[B]` -`method toBuffer[B >: B]=> scala.collection.mutable.Buffer[B]` -`method toIndexedSeq=> scala.collection.immutable.IndexedSeq[B]` -`method toIterable=> Iterable[B]` -`method toIterator=> Iterator[B]` -`method toList=> List[B]` -`method toMap[T, U](implicit ev: <:<[B,(T, U)])scala.collection.immutable.Map[T,U]` -`method toSeq=> Seq[B]` -`method toSet[B >: B]=> scala.collection.immutable.Set[B]` -`method toStream=> scala.collection.immutable.Stream[B]` -`method toString()String` -`method toTraversable=> Traversable[B]` -`method wait()Unit` -`method wait(x$1: Long)Unit` -`method wait(x$1: Long, x$2: Int)Unit` -`method withFilter(p: B => Boolean)Iterator[B]` -`method x=> java.util.Iterator[B]` -`method zipAll[B, A1 >: B, B1 >: B](that: Iterator[B], thisElem: A1, thatElem: B1)Iterator[(A1, B1)]` -`method zipWithIndex=> Iterator[(B, Int)]` -`method zip[B](that: Iterator[B])Iterator[(B, B)]` -`method →[B](y: B)(java.util.Iterator[B], B)` -`value __leftOfArrowjava.util.Iterator[B]` -`value __resultOfEnsuringjava.util.Iterator[B]` -`value selfAny` +[accessible: true] `class GroupedIteratorIterator[B]#GroupedIterator` +[accessible: true] `method !=(x$1: Any)Boolean` +[accessible: true] `method !=(x$1: AnyRef)Boolean` +[accessible: true] `method ##()Int` +[accessible: true] `method +(other: String)String` +[accessible: true] `method ++[B >: B](that: => scala.collection.GenTraversableOnce[B])Iterator[B]` +[accessible: true] `method ->[B](y: B)(java.util.Iterator[B], B)` +[accessible: true] `method /:[B](z: B)(op: (B, B) => B)B` +[accessible: true] `method /:\[A1 >: B](z: A1)(op: (A1, A1) => A1)A1` +[accessible: true] `method :\[B](z: B)(op: (B, B) => B)B` +[accessible: true] `method ==(x$1: Any)Boolean` +[accessible: true] `method ==(x$1: AnyRef)Boolean` +[accessible: true] `method addString(b: StringBuilder)StringBuilder` +[accessible: true] `method addString(b: StringBuilder, sep: String)StringBuilder` +[accessible: true] `method addString(b: StringBuilder, start: String, sep: String, end: String)StringBuilder` +[accessible: true] `method aggregate[B](z: B)(seqop: (B, B) => B, combop: (B, B) => B)B` +[accessible: true] `method asInstanceOf[T0]=> T0` +[accessible: true] `method buffered=> scala.collection.BufferedIterator[B]` +[accessible: true] `method collectFirst[B](pf: PartialFunction[B,B])Option[B]` +[accessible: true] `method collect[B](pf: PartialFunction[B,B])Iterator[B]` +[accessible: true] `method contains(elem: Any)Boolean` +[accessible: true] `method copyToArray[B >: B](xs: Array[B])Unit` +[accessible: true] `method copyToArray[B >: B](xs: Array[B], start: Int)Unit` +[accessible: true] `method copyToArray[B >: B](xs: Array[B], start: Int, len: Int)Unit` +[accessible: true] `method copyToBuffer[B >: B](dest: scala.collection.mutable.Buffer[B])Unit` +[accessible: true] `method count(p: B => Boolean)Int` +[accessible: true] `method drop(n: Int)Iterator[B]` +[accessible: true] `method dropWhile(p: B => Boolean)Iterator[B]` +[accessible: true] `method duplicate=> (Iterator[B], Iterator[B])` +[accessible: true] `method ensuring(cond: Boolean)java.util.Iterator[B]` +[accessible: true] `method ensuring(cond: Boolean, msg: => Any)java.util.Iterator[B]` +[accessible: true] `method ensuring(cond: java.util.Iterator[B] => Boolean)java.util.Iterator[B]` +[accessible: true] `method ensuring(cond: java.util.Iterator[B] => Boolean, msg: => Any)java.util.Iterator[B]` +[accessible: true] `method eq(x$1: AnyRef)Boolean` +[accessible: true] `method equals(x$1: Any)Boolean` +[accessible: true] `method exists(p: B => Boolean)Boolean` +[accessible: true] `method filter(p: B => Boolean)Iterator[B]` +[accessible: true] `method filterNot(p: B => Boolean)Iterator[B]` +[accessible: true] `method find(p: B => Boolean)Option[B]` +[accessible: true] `method flatMap[B](f: B => scala.collection.GenTraversableOnce[B])Iterator[B]` +[accessible: true] `method foldLeft[B](z: B)(op: (B, B) => B)B` +[accessible: true] `method foldRight[B](z: B)(op: (B, B) => B)B` +[accessible: true] `method fold[A1 >: B](z: A1)(op: (A1, A1) => A1)A1` +[accessible: true] `method forall(p: B => Boolean)Boolean` +[accessible: true] `method foreach[U](f: B => U)Unit` +[accessible: true] `method formatted(fmtstr: String)String` +[accessible: true] `method grouped[B >: B](size: Int)Iterator[B]#GroupedIterator[B]` +[accessible: true] `method hasDefiniteSize=> Boolean` +[accessible: true] `method hasNext()Boolean` +[accessible: true] `method hashCode()Int` +[accessible: true] `method indexOf[B >: B](elem: B)Int` +[accessible: true] `method indexWhere(p: B => Boolean)Int` +[accessible: true] `method isEmpty=> Boolean` +[accessible: true] `method isInstanceOf[T0]=> Boolean` +[accessible: true] `method isTraversableAgain=> Boolean` +[accessible: true] `method length=> Int` +[accessible: true] `method map[B](f: B => B)Iterator[B]` +[accessible: true] `method maxBy[B](f: B => B)(implicit cmp: Ordering[B])B` +[accessible: true] `method max[B >: B](implicit cmp: Ordering[B])B` +[accessible: true] `method minBy[B](f: B => B)(implicit cmp: Ordering[B])B` +[accessible: true] `method min[B >: B](implicit cmp: Ordering[B])B` +[accessible: true] `method mkString(sep: String)String` +[accessible: true] `method mkString(start: String, sep: String, end: String)String` +[accessible: true] `method mkString=> String` +[accessible: true] `method ne(x$1: AnyRef)Boolean` +[accessible: true] `method next()B` +[accessible: true] `method nonEmpty=> Boolean` +[accessible: true] `method notify()Unit` +[accessible: true] `method notifyAll()Unit` +[accessible: true] `method padTo[A1 >: B](len: Int, elem: A1)Iterator[A1]` +[accessible: true] `method partition(p: B => Boolean)(Iterator[B], Iterator[B])` +[accessible: true] `method patch[B >: B](from: Int, patchElems: Iterator[B], replaced: Int)Iterator[B]` +[accessible: true] `method product[B >: B](implicit num: Numeric[B])B` +[accessible: true] `method reduceLeftOption[B >: B](op: (B, B) => B)Option[B]` +[accessible: true] `method reduceLeft[B >: B](op: (B, B) => B)B` +[accessible: true] `method reduceOption[A1 >: B](op: (A1, A1) => A1)Option[A1]` +[accessible: true] `method reduceRightOption[B >: B](op: (B, B) => B)Option[B]` +[accessible: true] `method reduceRight[B >: B](op: (B, B) => B)B` +[accessible: true] `method reduce[A1 >: B](op: (A1, A1) => A1)A1` +[accessible: true] `method remove()Unit` +[accessible: true] `method sameElements(that: Iterator[_])Boolean` +[accessible: true] `method scanLeft[B](z: B)(op: (B, B) => B)Iterator[B]` +[accessible: true] `method scanRight[B](z: B)(op: (B, B) => B)Iterator[B]` +[accessible: true] `method seq=> Iterator[B]` +[accessible: true] `method size=> Int` +[accessible: true] `method slice(from: Int, until: Int)Iterator[B]` +[accessible: true] `method sliding[B >: B](size: Int, step: Int)Iterator[B]#GroupedIterator[B]` +[accessible: true] `method span(p: B => Boolean)(Iterator[B], Iterator[B])` +[accessible: true] `method sum[B >: B](implicit num: Numeric[B])B` +[accessible: true] `method synchronized[T0](x$1: T0)T0` +[accessible: true] `method take(n: Int)Iterator[B]` +[accessible: true] `method takeWhile(p: B => Boolean)Iterator[B]` +[accessible: true] `method toArray[B >: B](implicit evidence$1: ArrayTag[B])Array[B]` +[accessible: true] `method toBuffer[B >: B]=> scala.collection.mutable.Buffer[B]` +[accessible: true] `method toIndexedSeq=> scala.collection.immutable.IndexedSeq[B]` +[accessible: true] `method toIterable=> Iterable[B]` +[accessible: true] `method toIterator=> Iterator[B]` +[accessible: true] `method toList=> List[B]` +[accessible: true] `method toMap[T, U](implicit ev: <:<[B,(T, U)])scala.collection.immutable.Map[T,U]` +[accessible: true] `method toSeq=> Seq[B]` +[accessible: true] `method toSet[B >: B]=> scala.collection.immutable.Set[B]` +[accessible: true] `method toStream=> scala.collection.immutable.Stream[B]` +[accessible: true] `method toString()String` +[accessible: true] `method toTraversable=> Traversable[B]` +[accessible: true] `method wait()Unit` +[accessible: true] `method wait(x$1: Long)Unit` +[accessible: true] `method wait(x$1: Long, x$2: Int)Unit` +[accessible: true] `method withFilter(p: B => Boolean)Iterator[B]` +[accessible: true] `method x=> java.util.Iterator[B]` +[accessible: true] `method zipAll[B, A1 >: B, B1 >: B](that: Iterator[B], thisElem: A1, thatElem: B1)Iterator[(A1, B1)]` +[accessible: true] `method zipWithIndex=> Iterator[(B, Int)]` +[accessible: true] `method zip[B](that: Iterator[B])Iterator[(B, B)]` +[accessible: true] `method →[B](y: B)(java.util.Iterator[B], B)` +[accessible: false] `method clone()Object` +[accessible: false] `method finalize()Unit` +[accessible: false] `method reversed=> List[B]` +[accessible: false] `value __leftOfArrowjava.util.Iterator[B]` +[accessible: false] `value __resultOfEnsuringjava.util.Iterator[B]` +[accessible: false] `value selfAny` ================================================================================ diff --git a/test/files/presentation/implicit-member.check b/test/files/presentation/implicit-member.check index e8e656f12a..ce21293ae5 100644 --- a/test/files/presentation/implicit-member.check +++ b/test/files/presentation/implicit-member.check @@ -4,39 +4,39 @@ askTypeCompletion at ImplicitMember.scala(7,7) ================================================================================ [response] aksTypeCompletion at (7,7) retrieved 39 members -`class AppliedImplicitImplicit.AppliedImplicit` -`method !=(x$1: Any)Boolean` -`method !=(x$1: AnyRef)Boolean` -`method ##()Int` -`method +(other: String)String` -`method ->[B](y: B)(Implicit.type, B)` -`method ==(x$1: Any)Boolean` -`method ==(x$1: AnyRef)Boolean` -`method AppliedImplicit[A](x: A)Implicit.AppliedImplicit[A]` -`method asInstanceOf[T0]=> T0` -`method clone()Object` -`method ensuring(cond: Boolean)Implicit.type` -`method ensuring(cond: Boolean, msg: => Any)Implicit.type` -`method ensuring(cond: Implicit.type => Boolean)Implicit.type` -`method ensuring(cond: Implicit.type => Boolean, msg: => Any)Implicit.type` -`method eq(x$1: AnyRef)Boolean` -`method equals(x$1: Any)Boolean` -`method finalize()Unit` -`method formatted(fmtstr: String)String` -`method hashCode()Int` -`method isInstanceOf[T0]=> Boolean` -`method ne(x$1: AnyRef)Boolean` -`method notify()Unit` -`method notifyAll()Unit` -`method synchronized[T0](x$1: T0)T0` -`method toString()String` -`method wait()Unit` -`method wait(x$1: Long)Unit` -`method wait(x$1: Long, x$2: Int)Unit` -`method x=> Implicit.type` -`method →[B](y: B)(Implicit.type, B)` -`value __leftOfArrowImplicit.type` -`value __resultOfEnsuringImplicit.type` -`value selfAny` -`value xImplicit.type` +[accessible: true] `class AppliedImplicitImplicit.AppliedImplicit` +[accessible: true] `method !=(x$1: Any)Boolean` +[accessible: true] `method !=(x$1: AnyRef)Boolean` +[accessible: true] `method ##()Int` +[accessible: true] `method +(other: String)String` +[accessible: true] `method ->[B](y: B)(Implicit.type, B)` +[accessible: true] `method ==(x$1: Any)Boolean` +[accessible: true] `method ==(x$1: AnyRef)Boolean` +[accessible: true] `method AppliedImplicit[A](x: A)Implicit.AppliedImplicit[A]` +[accessible: true] `method asInstanceOf[T0]=> T0` +[accessible: true] `method clone()Object` +[accessible: true] `method ensuring(cond: Boolean)Implicit.type` +[accessible: true] `method ensuring(cond: Boolean, msg: => Any)Implicit.type` +[accessible: true] `method ensuring(cond: Implicit.type => Boolean)Implicit.type` +[accessible: true] `method ensuring(cond: Implicit.type => Boolean, msg: => Any)Implicit.type` +[accessible: true] `method eq(x$1: AnyRef)Boolean` +[accessible: true] `method equals(x$1: Any)Boolean` +[accessible: true] `method finalize()Unit` +[accessible: true] `method formatted(fmtstr: String)String` +[accessible: true] `method hashCode()Int` +[accessible: true] `method isInstanceOf[T0]=> Boolean` +[accessible: true] `method ne(x$1: AnyRef)Boolean` +[accessible: true] `method notify()Unit` +[accessible: true] `method notifyAll()Unit` +[accessible: true] `method synchronized[T0](x$1: T0)T0` +[accessible: true] `method toString()String` +[accessible: true] `method wait()Unit` +[accessible: true] `method wait(x$1: Long)Unit` +[accessible: true] `method wait(x$1: Long, x$2: Int)Unit` +[accessible: true] `method x=> Implicit.type` +[accessible: true] `method →[B](y: B)(Implicit.type, B)` +[accessible: false] `value __leftOfArrowImplicit.type` +[accessible: false] `value __resultOfEnsuringImplicit.type` +[accessible: false] `value selfAny` +[accessible: false] `value xImplicit.type` ================================================================================ diff --git a/test/files/presentation/ping-pong.check b/test/files/presentation/ping-pong.check index 38040bdacf..1f02274736 100644 --- a/test/files/presentation/ping-pong.check +++ b/test/files/presentation/ping-pong.check @@ -4,83 +4,83 @@ askTypeCompletion at PingPong.scala(10,23) ================================================================================ [response] aksTypeCompletion at (10,23) retrieved 40 members -`method !=(x$1: Any)Boolean` -`method !=(x$1: AnyRef)Boolean` -`method ##()Int` -`method +(other: String)String` -`method ->[B](y: B)(Pong, B)` -`method ==(x$1: Any)Boolean` -`method ==(x$1: AnyRef)Boolean` -`method asInstanceOf[T0]=> T0` -`method clone()Object` -`method ensuring(cond: Boolean)Pong` -`method ensuring(cond: Boolean, msg: => Any)Pong` -`method ensuring(cond: Pong => Boolean)Pong` -`method ensuring(cond: Pong => Boolean, msg: => Any)Pong` -`method eq(x$1: AnyRef)Boolean` -`method equals(x$1: Any)Boolean` -`method finalize()Unit` -`method formatted(fmtstr: String)String` -`method hashCode()Int` -`method isInstanceOf[T0]=> Boolean` -`method ne(x$1: AnyRef)Boolean` -`method notify()Unit` -`method notifyAll()Unit` -`method poke()Unit` -`method synchronized[T0](x$1: T0)T0` -`method toString()String` -`method wait()Unit` -`method wait(x$1: Long)Unit` -`method wait(x$1: Long, x$2: Int)Unit` -`method x=> Pong` -`method →[B](y: B)(Pong, B)` -`value __leftOfArrowPong` -`value __resultOfEnsuringPong` -`value nameString` -`value pingPing` -`value selfAny` +[accessible: true] `method !=(x$1: Any)Boolean` +[accessible: true] `method !=(x$1: AnyRef)Boolean` +[accessible: true] `method ##()Int` +[accessible: true] `method +(other: String)String` +[accessible: true] `method ->[B](y: B)(Pong, B)` +[accessible: true] `method ==(x$1: Any)Boolean` +[accessible: true] `method ==(x$1: AnyRef)Boolean` +[accessible: true] `method asInstanceOf[T0]=> T0` +[accessible: true] `method ensuring(cond: Boolean)Pong` +[accessible: true] `method ensuring(cond: Boolean, msg: => Any)Pong` +[accessible: true] `method ensuring(cond: Pong => Boolean)Pong` +[accessible: true] `method ensuring(cond: Pong => Boolean, msg: => Any)Pong` +[accessible: true] `method eq(x$1: AnyRef)Boolean` +[accessible: true] `method equals(x$1: Any)Boolean` +[accessible: true] `method formatted(fmtstr: String)String` +[accessible: true] `method hashCode()Int` +[accessible: true] `method isInstanceOf[T0]=> Boolean` +[accessible: true] `method ne(x$1: AnyRef)Boolean` +[accessible: true] `method notify()Unit` +[accessible: true] `method notifyAll()Unit` +[accessible: true] `method poke()Unit` +[accessible: true] `method synchronized[T0](x$1: T0)T0` +[accessible: true] `method toString()String` +[accessible: true] `method wait()Unit` +[accessible: true] `method wait(x$1: Long)Unit` +[accessible: true] `method wait(x$1: Long, x$2: Int)Unit` +[accessible: true] `method x=> Pong` +[accessible: true] `method →[B](y: B)(Pong, B)` +[accessible: false] `method clone()Object` +[accessible: false] `method finalize()Unit` +[accessible: false] `value __leftOfArrowPong` +[accessible: false] `value __resultOfEnsuringPong` +[accessible: false] `value nameString` +[accessible: false] `value pingPing` +[accessible: false] `value selfAny` ================================================================================ askTypeCompletion at PingPong.scala(19,20) ================================================================================ [response] aksTypeCompletion at (19,20) retrieved 40 members -`method !=(x$1: Any)Boolean` -`method !=(x$1: AnyRef)Boolean` -`method ##()Int` -`method +(other: String)String` -`method ->[B](y: B)(Ping, B)` -`method ==(x$1: Any)Boolean` -`method ==(x$1: AnyRef)Boolean` -`method asInstanceOf[T0]=> T0` -`method clone()Object` -`method ensuring(cond: Boolean)Ping` -`method ensuring(cond: Boolean, msg: => Any)Ping` -`method ensuring(cond: Ping => Boolean)Ping` -`method ensuring(cond: Ping => Boolean, msg: => Any)Ping` -`method eq(x$1: AnyRef)Boolean` -`method equals(x$1: Any)Boolean` -`method finalize()Unit` -`method formatted(fmtstr: String)String` -`method hashCode()Int` -`method isInstanceOf[T0]=> Boolean` -`method loop=> Unit` -`method name=> String` -`method ne(x$1: AnyRef)Boolean` -`method notify()Unit` -`method notifyAll()Unit` -`method poke=> Unit` -`method synchronized[T0](x$1: T0)T0` -`method toString()String` -`method wait()Unit` -`method wait(x$1: Long)Unit` -`method wait(x$1: Long, x$2: Int)Unit` -`method x=> Ping` -`method →[B](y: B)(Ping, B)` -`value __leftOfArrowPing` -`value __resultOfEnsuringPing` -`value pongPong` -`value selfAny` +[accessible: true] `method !=(x$1: Any)Boolean` +[accessible: true] `method !=(x$1: AnyRef)Boolean` +[accessible: true] `method ##()Int` +[accessible: true] `method +(other: String)String` +[accessible: true] `method ->[B](y: B)(Ping, B)` +[accessible: true] `method ==(x$1: Any)Boolean` +[accessible: true] `method ==(x$1: AnyRef)Boolean` +[accessible: true] `method asInstanceOf[T0]=> T0` +[accessible: true] `method ensuring(cond: Boolean)Ping` +[accessible: true] `method ensuring(cond: Boolean, msg: => Any)Ping` +[accessible: true] `method ensuring(cond: Ping => Boolean)Ping` +[accessible: true] `method ensuring(cond: Ping => Boolean, msg: => Any)Ping` +[accessible: true] `method eq(x$1: AnyRef)Boolean` +[accessible: true] `method equals(x$1: Any)Boolean` +[accessible: true] `method formatted(fmtstr: String)String` +[accessible: true] `method hashCode()Int` +[accessible: true] `method isInstanceOf[T0]=> Boolean` +[accessible: true] `method loop=> Unit` +[accessible: true] `method name=> String` +[accessible: true] `method ne(x$1: AnyRef)Boolean` +[accessible: true] `method notify()Unit` +[accessible: true] `method notifyAll()Unit` +[accessible: true] `method poke=> Unit` +[accessible: true] `method synchronized[T0](x$1: T0)T0` +[accessible: true] `method toString()String` +[accessible: true] `method wait()Unit` +[accessible: true] `method wait(x$1: Long)Unit` +[accessible: true] `method wait(x$1: Long, x$2: Int)Unit` +[accessible: true] `method x=> Ping` +[accessible: true] `method →[B](y: B)(Ping, B)` +[accessible: false] `method clone()Object` +[accessible: false] `method finalize()Unit` +[accessible: false] `value __leftOfArrowPing` +[accessible: false] `value __resultOfEnsuringPing` +[accessible: false] `value pongPong` +[accessible: false] `value selfAny` ================================================================================ askType at PingPong.scala(8,10) diff --git a/test/files/presentation/visibility.check b/test/files/presentation/visibility.check new file mode 100644 index 0000000000..290a5ac381 --- /dev/null +++ b/test/files/presentation/visibility.check @@ -0,0 +1,221 @@ +reload: Completions.scala + +askTypeCompletion at Completions.scala(14,12) +================================================================================ +[response] aksTypeCompletion at (14,12) +retrieved 42 members +[accessible: true] `method !=(x$1: Any)Boolean` +[accessible: true] `method !=(x$1: AnyRef)Boolean` +[accessible: true] `method ##()Int` +[accessible: true] `method +(other: String)String` +[accessible: true] `method ->[B](y: B)(accessibility.Foo, B)` +[accessible: true] `method ==(x$1: Any)Boolean` +[accessible: true] `method ==(x$1: AnyRef)Boolean` +[accessible: true] `method asInstanceOf[T0]=> T0` +[accessible: true] `method clone()Object` +[accessible: true] `method ensuring(cond: Boolean)accessibility.Foo` +[accessible: true] `method ensuring(cond: Boolean, msg: => Any)accessibility.Foo` +[accessible: true] `method ensuring(cond: accessibility.Foo => Boolean)accessibility.Foo` +[accessible: true] `method ensuring(cond: accessibility.Foo => Boolean, msg: => Any)accessibility.Foo` +[accessible: true] `method eq(x$1: AnyRef)Boolean` +[accessible: true] `method equals(x$1: Any)Boolean` +[accessible: true] `method finalize()Unit` +[accessible: true] `method formatted(fmtstr: String)String` +[accessible: true] `method hashCode()Int` +[accessible: true] `method isInstanceOf[T0]=> Boolean` +[accessible: true] `method ne(x$1: AnyRef)Boolean` +[accessible: true] `method notify()Unit` +[accessible: true] `method notifyAll()Unit` +[accessible: true] `method secretPrivate()Unit` +[accessible: true] `method secretProtected()Unit` +[accessible: true] `method secretProtectedInPackage()Unit` +[accessible: true] `method secretPublic()Unit` +[accessible: true] `method someTests(other: accessibility.Foo)Unit` +[accessible: true] `method synchronized[T0](x$1: T0)T0` +[accessible: true] `method toString()String` +[accessible: true] `method wait()Unit` +[accessible: true] `method wait(x$1: Long)Unit` +[accessible: true] `method wait(x$1: Long, x$2: Int)Unit` +[accessible: true] `method x=> accessibility.Foo` +[accessible: true] `method →[B](y: B)(accessibility.Foo, B)` +[accessible: false] `method secretPrivateThis()Unit` +[accessible: false] `value __leftOfArrowaccessibility.Foo` +[accessible: false] `value __resultOfEnsuringaccessibility.Foo` +[accessible: false] `value selfAny` +================================================================================ + +askTypeCompletion at Completions.scala(16,11) +================================================================================ +[response] aksTypeCompletion at (16,11) +retrieved 42 members +[accessible: true] `method !=(x$1: Any)Boolean` +[accessible: true] `method !=(x$1: AnyRef)Boolean` +[accessible: true] `method ##()Int` +[accessible: true] `method +(other: String)String` +[accessible: true] `method ->[B](y: B)(accessibility.Foo, B)` +[accessible: true] `method ==(x$1: Any)Boolean` +[accessible: true] `method ==(x$1: AnyRef)Boolean` +[accessible: true] `method asInstanceOf[T0]=> T0` +[accessible: true] `method clone()Object` +[accessible: true] `method ensuring(cond: Boolean)accessibility.Foo` +[accessible: true] `method ensuring(cond: Boolean, msg: => Any)accessibility.Foo` +[accessible: true] `method ensuring(cond: accessibility.Foo => Boolean)accessibility.Foo` +[accessible: true] `method ensuring(cond: accessibility.Foo => Boolean, msg: => Any)accessibility.Foo` +[accessible: true] `method eq(x$1: AnyRef)Boolean` +[accessible: true] `method equals(x$1: Any)Boolean` +[accessible: true] `method finalize()Unit` +[accessible: true] `method formatted(fmtstr: String)String` +[accessible: true] `method hashCode()Int` +[accessible: true] `method isInstanceOf[T0]=> Boolean` +[accessible: true] `method ne(x$1: AnyRef)Boolean` +[accessible: true] `method notify()Unit` +[accessible: true] `method notifyAll()Unit` +[accessible: true] `method secretPrivate()Unit` +[accessible: true] `method secretPrivateThis()Unit` +[accessible: true] `method secretProtected()Unit` +[accessible: true] `method secretProtectedInPackage()Unit` +[accessible: true] `method secretPublic()Unit` +[accessible: true] `method someTests(other: accessibility.Foo)Unit` +[accessible: true] `method synchronized[T0](x$1: T0)T0` +[accessible: true] `method toString()String` +[accessible: true] `method wait()Unit` +[accessible: true] `method wait(x$1: Long)Unit` +[accessible: true] `method wait(x$1: Long, x$2: Int)Unit` +[accessible: true] `method x=> accessibility.Foo` +[accessible: true] `method →[B](y: B)(accessibility.Foo, B)` +[accessible: false] `value __leftOfArrowaccessibility.Foo` +[accessible: false] `value __resultOfEnsuringaccessibility.Foo` +[accessible: false] `value selfAny` +================================================================================ + +askTypeCompletion at Completions.scala(22,11) +================================================================================ +[response] aksTypeCompletion at (22,11) +retrieved 42 members +[accessible: true] `method !=(x$1: Any)Boolean` +[accessible: true] `method !=(x$1: AnyRef)Boolean` +[accessible: true] `method ##()Int` +[accessible: true] `method +(other: String)String` +[accessible: true] `method ->[B](y: B)(accessibility.AccessibilityChecks, B)` +[accessible: true] `method ==(x$1: Any)Boolean` +[accessible: true] `method ==(x$1: AnyRef)Boolean` +[accessible: true] `method asInstanceOf[T0]=> T0` +[accessible: true] `method clone()Object` +[accessible: true] `method ensuring(cond: Boolean)accessibility.AccessibilityChecks` +[accessible: true] `method ensuring(cond: Boolean, msg: => Any)accessibility.AccessibilityChecks` +[accessible: true] `method ensuring(cond: accessibility.AccessibilityChecks => Boolean)accessibility.AccessibilityChecks` +[accessible: true] `method ensuring(cond: accessibility.AccessibilityChecks => Boolean, msg: => Any)accessibility.AccessibilityChecks` +[accessible: true] `method eq(x$1: AnyRef)Boolean` +[accessible: true] `method equals(x$1: Any)Boolean` +[accessible: true] `method finalize()Unit` +[accessible: true] `method formatted(fmtstr: String)String` +[accessible: true] `method hashCode()Int` +[accessible: true] `method isInstanceOf[T0]=> Boolean` +[accessible: true] `method ne(x$1: AnyRef)Boolean` +[accessible: true] `method notify()Unit` +[accessible: true] `method notifyAll()Unit` +[accessible: true] `method secretProtected()Unit` +[accessible: true] `method secretProtectedInPackage()Unit` +[accessible: true] `method secretPublic()Unit` +[accessible: true] `method someTests(other: accessibility.Foo)Unit` +[accessible: true] `method someTests=> Unit` +[accessible: true] `method synchronized[T0](x$1: T0)T0` +[accessible: true] `method toString()String` +[accessible: true] `method wait()Unit` +[accessible: true] `method wait(x$1: Long)Unit` +[accessible: true] `method wait(x$1: Long, x$2: Int)Unit` +[accessible: true] `method x=> accessibility.AccessibilityChecks` +[accessible: true] `method →[B](y: B)(accessibility.AccessibilityChecks, B)` +[accessible: false] `method secretPrivate()Unit` +[accessible: false] `value __leftOfArrowaccessibility.AccessibilityChecks` +[accessible: false] `value __resultOfEnsuringaccessibility.AccessibilityChecks` +[accessible: false] `value selfAny` +================================================================================ + +askTypeCompletion at Completions.scala(28,10) +================================================================================ +[response] aksTypeCompletion at (28,10) +retrieved 42 members +[accessible: true] `method !=(x$1: Any)Boolean` +[accessible: true] `method !=(x$1: AnyRef)Boolean` +[accessible: true] `method ##()Int` +[accessible: true] `method +(other: String)String` +[accessible: true] `method ->[B](y: B)(accessibility.Foo, B)` +[accessible: true] `method ==(x$1: Any)Boolean` +[accessible: true] `method ==(x$1: AnyRef)Boolean` +[accessible: true] `method asInstanceOf[T0]=> T0` +[accessible: true] `method ensuring(cond: Boolean)accessibility.Foo` +[accessible: true] `method ensuring(cond: Boolean, msg: => Any)accessibility.Foo` +[accessible: true] `method ensuring(cond: accessibility.Foo => Boolean)accessibility.Foo` +[accessible: true] `method ensuring(cond: accessibility.Foo => Boolean, msg: => Any)accessibility.Foo` +[accessible: true] `method eq(x$1: AnyRef)Boolean` +[accessible: true] `method equals(x$1: Any)Boolean` +[accessible: true] `method formatted(fmtstr: String)String` +[accessible: true] `method hashCode()Int` +[accessible: true] `method isInstanceOf[T0]=> Boolean` +[accessible: true] `method ne(x$1: AnyRef)Boolean` +[accessible: true] `method notify()Unit` +[accessible: true] `method notifyAll()Unit` +[accessible: true] `method secretProtectedInPackage()Unit` +[accessible: true] `method secretPublic()Unit` +[accessible: true] `method someTests(other: accessibility.Foo)Unit` +[accessible: true] `method synchronized[T0](x$1: T0)T0` +[accessible: true] `method toString()String` +[accessible: true] `method wait()Unit` +[accessible: true] `method wait(x$1: Long)Unit` +[accessible: true] `method wait(x$1: Long, x$2: Int)Unit` +[accessible: true] `method x=> accessibility.Foo` +[accessible: true] `method →[B](y: B)(accessibility.Foo, B)` +[accessible: false] `method clone()Object` +[accessible: false] `method finalize()Unit` +[accessible: false] `method secretPrivate()Unit` +[accessible: false] `method secretPrivateThis()Unit` +[accessible: false] `method secretProtected()Unit` +[accessible: false] `value __leftOfArrowaccessibility.Foo` +[accessible: false] `value __resultOfEnsuringaccessibility.Foo` +[accessible: false] `value selfAny` +================================================================================ + +askTypeCompletion at Completions.scala(37,8) +================================================================================ +[response] aksTypeCompletion at (37,8) +retrieved 42 members +[accessible: true] `method !=(x$1: Any)Boolean` +[accessible: true] `method !=(x$1: AnyRef)Boolean` +[accessible: true] `method ##()Int` +[accessible: true] `method +(other: String)String` +[accessible: true] `method ->[B](y: B)(accessibility.Foo, B)` +[accessible: true] `method ==(x$1: Any)Boolean` +[accessible: true] `method ==(x$1: AnyRef)Boolean` +[accessible: true] `method asInstanceOf[T0]=> T0` +[accessible: true] `method ensuring(cond: Boolean)accessibility.Foo` +[accessible: true] `method ensuring(cond: Boolean, msg: => Any)accessibility.Foo` +[accessible: true] `method ensuring(cond: accessibility.Foo => Boolean)accessibility.Foo` +[accessible: true] `method ensuring(cond: accessibility.Foo => Boolean, msg: => Any)accessibility.Foo` +[accessible: true] `method eq(x$1: AnyRef)Boolean` +[accessible: true] `method equals(x$1: Any)Boolean` +[accessible: true] `method formatted(fmtstr: String)String` +[accessible: true] `method hashCode()Int` +[accessible: true] `method isInstanceOf[T0]=> Boolean` +[accessible: true] `method ne(x$1: AnyRef)Boolean` +[accessible: true] `method notify()Unit` +[accessible: true] `method notifyAll()Unit` +[accessible: true] `method secretPublic()Unit` +[accessible: true] `method someTests(other: accessibility.Foo)Unit` +[accessible: true] `method synchronized[T0](x$1: T0)T0` +[accessible: true] `method toString()String` +[accessible: true] `method wait()Unit` +[accessible: true] `method wait(x$1: Long)Unit` +[accessible: true] `method wait(x$1: Long, x$2: Int)Unit` +[accessible: true] `method x=> accessibility.Foo` +[accessible: true] `method →[B](y: B)(accessibility.Foo, B)` +[accessible: false] `method clone()Object` +[accessible: false] `method finalize()Unit` +[accessible: false] `method secretPrivate()Unit` +[accessible: false] `method secretPrivateThis()Unit` +[accessible: false] `method secretProtected()Unit` +[accessible: false] `method secretProtectedInPackage()Unit` +[accessible: false] `value __leftOfArrowaccessibility.Foo` +[accessible: false] `value __resultOfEnsuringaccessibility.Foo` +[accessible: false] `value selfAny` +================================================================================ diff --git a/test/files/presentation/visibility/Test.scala b/test/files/presentation/visibility/Test.scala new file mode 100644 index 0000000000..96e758d974 --- /dev/null +++ b/test/files/presentation/visibility/Test.scala @@ -0,0 +1,5 @@ +import scala.tools.nsc.interactive.tests.InteractiveTest + +object Test extends InteractiveTest { + +} \ No newline at end of file diff --git a/test/files/presentation/visibility/src/Completions.scala b/test/files/presentation/visibility/src/Completions.scala new file mode 100644 index 0000000000..098b98a0fd --- /dev/null +++ b/test/files/presentation/visibility/src/Completions.scala @@ -0,0 +1,40 @@ +package accessibility { + + class Foo { + private def secretPrivate(): Unit = () + private[this] def secretPrivateThis(): Unit = () + + protected def secretProtected(): Unit + + protected[accessibility] def secretProtectedInPackage(): Unit + + def secretPublic(): Unit + + def someTests(other: Foo) { + other./*!*/secretPrivate // should be all but scretThis + + this./*!*/secretProtected // should hit five completions + } + } + + class AccessibilityChecks extends Foo { + def someTests { + this./*!*/ // should not list secretPrivate* + } + } + + class UnrelatedClass { + def someTests(foo: Foo) { + foo./*!*/ // should list public and protected[accessiblity] + } + } + +} + +package other { + class SomeChecsk { + def foo(o: accessibility.Foo) { + o./*!*/ // should only match secretPublic + } + } +} \ No newline at end of file -- cgit v1.2.3 From cf18d879d3f43d5a0c15c5c0af72f88c25605a08 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Mon, 30 Apr 2012 07:44:42 -0700 Subject: Optimization of Predef implicits. All those wildcards in a default-scoped implicit are expensive, they each lead to a typevar on every search. Restructured the Tuple2/Tuple3 Zipped classes, they're better this way anyway. This also gets all that Tuple[23] code out of genprod. --- src/build/genprod.scala | 224 +----------------------- src/compiler/scala/tools/cmd/gen/AnyVals.scala | 45 +++-- src/library/scala/Function0.scala | 2 +- src/library/scala/Predef.scala | 84 ++++----- src/library/scala/Tuple2.scala | 105 ----------- src/library/scala/Tuple3.scala | 120 ------------- src/library/scala/runtime/SeqCharSequence.scala | 25 +++ src/library/scala/runtime/Tuple2Zipped.scala | 130 ++++++++++++++ src/library/scala/runtime/Tuple3Zipped.scala | 141 +++++++++++++++ test/files/neg/t900.check | 4 +- test/files/run/tuple-zipped.scala | 4 +- tools/codegen | 2 +- 12 files changed, 364 insertions(+), 522 deletions(-) create mode 100644 src/library/scala/runtime/SeqCharSequence.scala create mode 100644 src/library/scala/runtime/Tuple2Zipped.scala create mode 100644 src/library/scala/runtime/Tuple3Zipped.scala (limited to 'src') diff --git a/src/build/genprod.scala b/src/build/genprod.scala index 5a77c7a699..8c91128de0 100644 --- a/src/build/genprod.scala +++ b/src/build/genprod.scala @@ -256,10 +256,7 @@ class Function(val i: Int) extends Group("Function") with Arity { zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz */ object Tuple { - val zipImports = """ -import scala.collection.{ TraversableLike => TLike, IterableLike => ILike } -import scala.collection.generic.{ CanBuildFrom => CBF } -""" + val zipImports = "" def make(i: Int) = apply(i)() def apply(i: Int) = i match { @@ -285,230 +282,11 @@ object TupleTwo extends Tuple(2) * second element is the first element of this Tuple. */ def swap: Tuple2[T2,T1] = Tuple2(_2, _1) - - @deprecated("Use `zipped` instead.", "2.9.0") - def zip[Repr1, El1, El2, To](implicit w1: T1 => TLike[El1, Repr1], - w2: T2 => Iterable[El2], - cbf1: CBF[Repr1, (El1, El2), To]): To = { - zipped map ((x, y) => ((x, y))) - } - - /** Wraps a tuple in a `Zipped`, which supports 2-ary generalisations of `map`, `flatMap`, `filter`, etc. - * Note that there must be an implicit value to convert this tuple's types into a [[scala.collection.TraversableLike]] - * or [[scala.collection.IterableLike]]. - * {{{ - * scala> val tuple = (List(1,2,3),List('a','b','c')) - * tuple: (List[Int], List[Char]) = (List(1, 2, 3),List(a, b, c)) - * - * scala> tuple.zipped map { (x,y) => x + ":" + y } - * res6: List[java.lang.String] = List(1:a, 2:b, 3:c) - * }}} - * - * @see Zipped - * Note: will not terminate for infinite-sized collections. - */ - def zipped[Repr1, El1, Repr2, El2](implicit w1: T1 => TLike[El1, Repr1], w2: T2 => ILike[El2, Repr2]): Zipped[Repr1, El1, Repr2, El2] - = new Zipped[Repr1, El1, Repr2, El2](_1, _2) - - class Zipped[+Repr1, +El1, +Repr2, +El2](coll1: TLike[El1, Repr1], coll2: ILike[El2, Repr2]) { // coll2: ILike for filter - def map[B, To](f: (El1, El2) => B)(implicit cbf: CBF[Repr1, B, To]): To = { - val b = cbf(coll1.repr) - b.sizeHint(coll1) - val elems2 = coll2.iterator - - for (el1 <- coll1) { - if (elems2.hasNext) - b += f(el1, elems2.next) - else - return b.result - } - - b.result - } - - def flatMap[B, To](f: (El1, El2) => TraversableOnce[B])(implicit cbf: CBF[Repr1, B, To]): To = { - val b = cbf(coll1.repr) - val elems2 = coll2.iterator - - for (el1 <- coll1) { - if (elems2.hasNext) - b ++= f(el1, elems2.next) - else - return b.result - } - - b.result - } - - def filter[To1, To2](f: (El1, El2) => Boolean)(implicit cbf1: CBF[Repr1, El1, To1], cbf2: CBF[Repr2, El2, To2]): (To1, To2) = { - val b1 = cbf1(coll1.repr) - val b2 = cbf2(coll2.repr) - val elems2 = coll2.iterator - - for (el1 <- coll1) { - if (elems2.hasNext) { - val el2 = elems2.next - if (f(el1, el2)) { - b1 += el1 - b2 += el2 - } - } - else return (b1.result, b2.result) - } - - (b1.result, b2.result) - } - - def exists(f: (El1, El2) => Boolean): Boolean = { - val elems2 = coll2.iterator - - for (el1 <- coll1) { - if (elems2.hasNext) { - if (f(el1, elems2.next)) - return true - } - else return false - } - false - } - - def forall(f: (El1, El2) => Boolean): Boolean = - !exists((x, y) => !f(x, y)) - - def foreach[U](f: (El1, El2) => U): Unit = { - val elems2 = coll2.iterator - - for (el1 <- coll1) { - if (elems2.hasNext) - f(el1, elems2.next) - else - return - } - } - } """ } object TupleThree extends Tuple(3) { override def imports = Tuple.zipImports - override def moreMethods = """ - - @deprecated("Use `zipped` instead.", "2.9.0") - def zip[Repr1, El1, El2, El3, To](implicit w1: T1 => TLike[El1, Repr1], - w2: T2 => Iterable[El2], - w3: T3 => Iterable[El3], - cbf1: CBF[Repr1, (El1, El2, El3), To]): To = { - zipped map ((x, y, z) => ((x, y, z))) - } - - /** Wraps a tuple in a `Zipped`, which supports 3-ary generalisations of `map`, `flatMap`, `filter`, etc. - * Note that there must be an implicit value to convert this tuple's types into a [[scala.collection.TraversableLike]] - * or [[scala.collection.IterableLike]]. - * {{{ - * scala> val tuple = (List(1,2,3),List('a','b','c'),List("x","y","z")) - * tuple: (List[Int], List[Char], List[java.lang.String]) = (List(1, 2, 3),List(a, b, c),List(x, y, z)) - * - * scala> tuple.zipped map { (x,y,z) => x + ":" + y + ":" + z} - * res8: List[java.lang.String] = List(1:a:x, 2:b:y, 3:c:z) - * }}} - * - * @see Zipped - * Note: will not terminate for infinite-sized collections. - */ - def zipped[Repr1, El1, Repr2, El2, Repr3, El3](implicit w1: T1 => TLike[El1, Repr1], - w2: T2 => ILike[El2, Repr2], - w3: T3 => ILike[El3, Repr3]): Zipped[Repr1, El1, Repr2, El2, Repr3, El3] - = new Zipped[Repr1, El1, Repr2, El2, Repr3, El3](_1, _2, _3) - - class Zipped[+Repr1, +El1, +Repr2, +El2, +Repr3, +El3](coll1: TLike[El1, Repr1], - coll2: ILike[El2, Repr2], - coll3: ILike[El3, Repr3]) { - def map[B, To](f: (El1, El2, El3) => B)(implicit cbf: CBF[Repr1, B, To]): To = { - val b = cbf(coll1.repr) - val elems2 = coll2.iterator - val elems3 = coll3.iterator - - for (el1 <- coll1) { - if (elems2.hasNext && elems3.hasNext) - b += f(el1, elems2.next, elems3.next) - else - return b.result - } - b.result - } - - def flatMap[B, To](f: (El1, El2, El3) => TraversableOnce[B])(implicit cbf: CBF[Repr1, B, To]): To = { - val b = cbf(coll1.repr) - val elems2 = coll2.iterator - val elems3 = coll3.iterator - - for (el1 <- coll1) { - if (elems2.hasNext && elems3.hasNext) - b ++= f(el1, elems2.next, elems3.next) - else - return b.result - } - b.result - } - - def filter[To1, To2, To3](f: (El1, El2, El3) => Boolean)( - implicit cbf1: CBF[Repr1, El1, To1], - cbf2: CBF[Repr2, El2, To2], - cbf3: CBF[Repr3, El3, To3]): (To1, To2, To3) = { - val b1 = cbf1(coll1.repr) - val b2 = cbf2(coll2.repr) - val b3 = cbf3(coll3.repr) - val elems2 = coll2.iterator - val elems3 = coll3.iterator - def result = (b1.result, b2.result, b3.result) - - for (el1 <- coll1) { - if (elems2.hasNext && elems3.hasNext) { - val el2 = elems2.next - val el3 = elems3.next - - if (f(el1, el2, el3)) { - b1 += el1 - b2 += el2 - b3 += el3 - } - } - else return result - } - - result - } - - def exists(f: (El1, El2, El3) => Boolean): Boolean = { - val elems2 = coll2.iterator - val elems3 = coll3.iterator - - for (el1 <- coll1) { - if (elems2.hasNext && elems3.hasNext) { - if (f(el1, elems2.next, elems3.next)) - return true - } - else return false - } - false - } - - def forall(f: (El1, El2, El3) => Boolean): Boolean = - !exists((x, y, z) => !f(x, y, z)) - - def foreach[U](f: (El1, El2, El3) => U): Unit = { - val elems2 = coll2.iterator - val elems3 = coll3.iterator - - for (el1 <- coll1) { - if (elems2.hasNext && elems3.hasNext) - f(el1, elems2.next, elems3.next) - else - return - } - } - } -""" } class Tuple(val i: Int) extends Group("Tuple") with Arity { diff --git a/src/compiler/scala/tools/cmd/gen/AnyVals.scala b/src/compiler/scala/tools/cmd/gen/AnyVals.scala index e8230b8ca4..83cd9c2578 100644 --- a/src/compiler/scala/tools/cmd/gen/AnyVals.scala +++ b/src/compiler/scala/tools/cmd/gen/AnyVals.scala @@ -15,18 +15,27 @@ trait AnyValReps { case class Op(val op : String, val doc : String) - private def companionCoercions(tos: String*) = { + private def companionCoercions(tos: AnyValRep*) = { tos.toList map (to => - """implicit def %s2%s(x: %s): %s = x.to%s""".format(javaEquiv, to, name, to.capitalize, to.capitalize) + """implicit def @javaequiv@2%s(x: @name@): %s = x.to%s""".format(to.javaEquiv, to.name, to.name) ) } - def implicitCoercions: List[String] = javaEquiv match { - case "byte" => companionCoercions("short", "int", "long", "float", "double") - case "short" | "char" => companionCoercions("int", "long", "float", "double") - case "int" => companionCoercions("long", "float", "double") - case "long" => companionCoercions("float", "double") - case "float" => companionCoercions("double") - case _ => Nil + def coercionCommentExtra = "" + def coercionComment = """ + /** Language mandated coercions from @name@ to "wider" types.%s + */""".format(coercionCommentExtra) + + def implicitCoercions: List[String] = { + val coercions = this match { + case B => companionCoercions(S, I, L, F, D) + case S | C => companionCoercions(I, L, F, D) + case I => companionCoercions(L, F, D) + case L => companionCoercions(F, D) + case F => companionCoercions(D) + case _ => Nil + } + if (coercions.isEmpty) Nil + else coercionComment :: coercions } def isCardinal: Boolean = isIntegerType(this) @@ -174,7 +183,7 @@ trait AnyValReps { } def objectLines = { val comp = if (isCardinal) cardinalCompanion else floatingCompanion - ((comp + allCompanions).trim.lines map interpolate).toList ++ implicitCoercions + (comp + allCompanions + "\n" + nonUnitCompanions).trim.lines.toList ++ implicitCoercions map interpolate } /** Makes a set of binary operations based on the given set of ops, args, and resultFn. @@ -238,8 +247,9 @@ trait AnyValReps { def classDoc = interpolate(classDocTemplate) def objectDoc = "" def mkImports = "" - def mkClass = assemble("final class", "private", "AnyVal", classLines) + "\n" - def mkObject = assemble("object", "", "AnyValCompanion", objectLines) + "\n" + + def mkClass = assemble("final class " + name + " private extends AnyVal", classLines) + def mkObject = assemble("object " + name + " extends AnyValCompanion", objectLines) def make() = List[String]( headerTemplate, mkImports, @@ -249,11 +259,10 @@ trait AnyValReps { mkObject ) mkString "" - def assemble(what: String, ctor: String, parent: String, lines: List[String]): String = { - val decl = "%s %s %s extends %s ".format(what, name, ctor, parent) - val body = if (lines.isEmpty) "{ }\n\n" else lines map indent mkString ("{\n", "\n", "\n}\n") + def assemble(decl: String, lines: List[String]): String = { + val body = if (lines.isEmpty) " { }\n\n" else lines map indent mkString (" {\n", "\n", "\n}\n") - decl + body + decl + body + "\n" } override def toString = name } @@ -310,6 +319,8 @@ def unbox(x: java.lang.Object): @name@ = @unboxImpl@ override def toString = "object scala.@name@" """ + def nonUnitCompanions = "" // todo + def cardinalCompanion = """ /** The smallest value representable as a @name@. */ @@ -446,7 +457,7 @@ def ^(x: Boolean): Boolean = sys.error("stub") override def getClass(): Class[Boolean] = sys.error("stub") """.trim.lines.toList - def objectLines = interpolate(allCompanions).lines.toList + def objectLines = interpolate(allCompanions + "\n" + nonUnitCompanions).lines.toList } object U extends AnyValRep("Unit", None, "void") { override def classDoc = """ diff --git a/src/library/scala/Function0.scala b/src/library/scala/Function0.scala index e1e9ddb3fb..3690a0e65b 100644 --- a/src/library/scala/Function0.scala +++ b/src/library/scala/Function0.scala @@ -6,7 +6,7 @@ ** |/ ** \* */ // GENERATED CODE: DO NOT EDIT. -// genprod generated these sources at: Sat Apr 28 12:59:55 PDT 2012 +// genprod generated these sources at: Mon Apr 30 07:46:11 PDT 2012 package scala diff --git a/src/library/scala/Predef.scala b/src/library/scala/Predef.scala index b84fcc4126..9eb1e6a11b 100644 --- a/src/library/scala/Predef.scala +++ b/src/library/scala/Predef.scala @@ -307,42 +307,36 @@ object Predef extends LowPriorityImplicits { // views -------------------------------------------------------------- - implicit def exceptionWrapper(exc: Throwable) = new runtime.RichException(exc) - - implicit def zipped2ToTraversable[El1, El2](zz: Tuple2[_, _]#Zipped[_, El1, _, El2]): Traversable[(El1, El2)] = - new collection.AbstractTraversable[(El1, El2)] { - def foreach[U](f: ((El1, El2)) => U): Unit = zz foreach Function.untupled(f) - } - - implicit def zipped3ToTraversable[El1, El2, El3](zz: Tuple3[_, _, _]#Zipped[_, El1, _, El2, _, El3]): Traversable[(El1, El2, El3)] = - new collection.AbstractTraversable[(El1, El2, El3)] { - def foreach[U](f: ((El1, El2, El3)) => U): Unit = zz foreach Function.untupled(f) - } - - implicit def genericArrayOps[T](xs: Array[T]): ArrayOps[T] = xs match { - case x: Array[AnyRef] => refArrayOps[AnyRef](x).asInstanceOf[ArrayOps[T]] - case x: Array[Int] => intArrayOps(x).asInstanceOf[ArrayOps[T]] - case x: Array[Double] => doubleArrayOps(x).asInstanceOf[ArrayOps[T]] - case x: Array[Long] => longArrayOps(x).asInstanceOf[ArrayOps[T]] - case x: Array[Float] => floatArrayOps(x).asInstanceOf[ArrayOps[T]] - case x: Array[Char] => charArrayOps(x).asInstanceOf[ArrayOps[T]] - case x: Array[Byte] => byteArrayOps(x).asInstanceOf[ArrayOps[T]] - case x: Array[Short] => shortArrayOps(x).asInstanceOf[ArrayOps[T]] - case x: Array[Boolean] => booleanArrayOps(x).asInstanceOf[ArrayOps[T]] - case x: Array[Unit] => unitArrayOps(x).asInstanceOf[ArrayOps[T]] + implicit def exceptionWrapper(exc: Throwable) = new runtime.RichException(exc) + implicit def tuple2ToZippedOps[T1, T2](x: (T1, T2)) = new runtime.Tuple2Zipped.Ops(x) + implicit def tuple3ToZippedOps[T1, T2, T3](x: (T1, T2, T3)) = new runtime.Tuple3Zipped.Ops(x) + implicit def seqToCharSequence(xs: collection.IndexedSeq[Char]): CharSequence = new runtime.SeqCharSequence(xs) + implicit def arrayToCharSequence(xs: Array[Char]): CharSequence = new runtime.ArrayCharSequence(xs) + + implicit def genericArrayOps[T](xs: Array[T]): ArrayOps[T] = (xs match { + case x: Array[AnyRef] => refArrayOps[AnyRef](x) + case x: Array[Boolean] => booleanArrayOps(x) + case x: Array[Byte] => byteArrayOps(x) + case x: Array[Char] => charArrayOps(x) + case x: Array[Double] => doubleArrayOps(x) + case x: Array[Float] => floatArrayOps(x) + case x: Array[Int] => intArrayOps(x) + case x: Array[Long] => longArrayOps(x) + case x: Array[Short] => shortArrayOps(x) + case x: Array[Unit] => unitArrayOps(x) case null => null - } + }).asInstanceOf[ArrayOps[T]] - implicit def refArrayOps[T <: AnyRef](xs: Array[T]): ArrayOps[T] = new ArrayOps.ofRef[T](xs) - implicit def intArrayOps(xs: Array[Int]): ArrayOps[Int] = new ArrayOps.ofInt(xs) - implicit def doubleArrayOps(xs: Array[Double]): ArrayOps[Double] = new ArrayOps.ofDouble(xs) - implicit def longArrayOps(xs: Array[Long]): ArrayOps[Long] = new ArrayOps.ofLong(xs) - implicit def floatArrayOps(xs: Array[Float]): ArrayOps[Float] = new ArrayOps.ofFloat(xs) - implicit def charArrayOps(xs: Array[Char]): ArrayOps[Char] = new ArrayOps.ofChar(xs) - implicit def byteArrayOps(xs: Array[Byte]): ArrayOps[Byte] = new ArrayOps.ofByte(xs) - implicit def shortArrayOps(xs: Array[Short]): ArrayOps[Short] = new ArrayOps.ofShort(xs) implicit def booleanArrayOps(xs: Array[Boolean]): ArrayOps[Boolean] = new ArrayOps.ofBoolean(xs) - implicit def unitArrayOps(xs: Array[Unit]): ArrayOps[Unit] = new ArrayOps.ofUnit(xs) + implicit def byteArrayOps(xs: Array[Byte]): ArrayOps[Byte] = new ArrayOps.ofByte(xs) + implicit def charArrayOps(xs: Array[Char]): ArrayOps[Char] = new ArrayOps.ofChar(xs) + implicit def doubleArrayOps(xs: Array[Double]): ArrayOps[Double] = new ArrayOps.ofDouble(xs) + implicit def floatArrayOps(xs: Array[Float]): ArrayOps[Float] = new ArrayOps.ofFloat(xs) + implicit def intArrayOps(xs: Array[Int]): ArrayOps[Int] = new ArrayOps.ofInt(xs) + implicit def longArrayOps(xs: Array[Long]): ArrayOps[Long] = new ArrayOps.ofLong(xs) + implicit def refArrayOps[T <: AnyRef](xs: Array[T]): ArrayOps[T] = new ArrayOps.ofRef[T](xs) + implicit def shortArrayOps(xs: Array[Short]): ArrayOps[Short] = new ArrayOps.ofShort(xs) + implicit def unitArrayOps(xs: Array[Unit]): ArrayOps[Unit] = new ArrayOps.ofUnit(xs) // Primitive Widenings -------------------------------------------------------------- @@ -406,29 +400,17 @@ object Predef extends LowPriorityImplicits { // Strings and CharSequences -------------------------------------------------------------- - implicit def any2stringadd(x: Any) = new runtime.StringAdd(x) @inline implicit def any2stringfmt(x: Any) = new runtime.StringFormat(x) @inline implicit def augmentString(x: String): StringOps = new StringOps(x) + implicit def any2stringadd(x: Any) = new runtime.StringAdd(x) implicit def unaugmentString(x: StringOps): String = x.repr - implicit def stringCanBuildFrom: CanBuildFrom[String, Char, String] = - new CanBuildFrom[String, Char, String] { - def apply(from: String) = apply() - def apply() = mutable.StringBuilder.newBuilder - } - - implicit def seqToCharSequence(xs: collection.IndexedSeq[Char]): CharSequence = new CharSequence { - def length: Int = xs.length - def charAt(index: Int): Char = xs(index) - def subSequence(start: Int, end: Int): CharSequence = seqToCharSequence(xs.slice(start, end)) - override def toString: String = xs.mkString("") - } + @deprecated("Use StringCanBuildFrom", "2.10.0") + def stringCanBuildFrom: CanBuildFrom[String, Char, String] = StringCanBuildFrom - implicit def arrayToCharSequence(xs: Array[Char]): CharSequence = new CharSequence { - def length: Int = xs.length - def charAt(index: Int): Char = xs(index) - def subSequence(start: Int, end: Int): CharSequence = arrayToCharSequence(xs.slice(start, end)) - override def toString: String = xs.mkString("") + implicit val StringCanBuildFrom: CanBuildFrom[String, Char, String] = new CanBuildFrom[String, Char, String] { + def apply(from: String) = apply() + def apply() = mutable.StringBuilder.newBuilder } // Type Constraints -------------------------------------------------------------- diff --git a/src/library/scala/Tuple2.scala b/src/library/scala/Tuple2.scala index 58638f440f..5e77127080 100644 --- a/src/library/scala/Tuple2.scala +++ b/src/library/scala/Tuple2.scala @@ -9,9 +9,6 @@ package scala -import scala.collection.{ TraversableLike => TLike, IterableLike => ILike } -import scala.collection.generic.{ CanBuildFrom => CBF } - /** A tuple of 2 elements; the canonical representation of a [[scala.Product2]]. * @@ -30,106 +27,4 @@ case class Tuple2[@specialized(Int, Long, Double, Char, Boolean, AnyRef) +T1, @s */ def swap: Tuple2[T2,T1] = Tuple2(_2, _1) - @deprecated("Use `zipped` instead.", "2.9.0") - @annotation.unspecialized - def zip[Repr1, El1, El2, To](implicit w1: T1 => TLike[El1, Repr1], - w2: T2 => Iterable[El2], - cbf1: CBF[Repr1, (El1, El2), To]): To = { - zipped map ((x, y) => ((x, y))) - } - - /** Wraps a tuple in a `Zipped`, which supports 2-ary generalisations of `map`, `flatMap`, `filter`, etc. - * Note that there must be an implicit value to convert this tuple's types into a [[scala.collection.TraversableLike]] - * or [[scala.collection.IterableLike]]. - * {{{ - * scala> val tuple = (List(1,2,3),List('a','b','c')) - * tuple: (List[Int], List[Char]) = (List(1, 2, 3),List(a, b, c)) - * - * scala> tuple.zipped map { (x,y) => x + ":" + y } - * res6: List[java.lang.String] = List(1:a, 2:b, 3:c) - * }}} - * - * @see Zipped - * Note: will not terminate for infinite-sized collections. - */ - def zipped[Repr1, El1, Repr2, El2](implicit w1: T1 => TLike[El1, Repr1], w2: T2 => ILike[El2, Repr2]): Zipped[Repr1, El1, Repr2, El2] - = new Zipped[Repr1, El1, Repr2, El2](_1, _2) - - class Zipped[+Repr1, +El1, +Repr2, +El2](coll1: TLike[El1, Repr1], coll2: ILike[El2, Repr2]) { // coll2: ILike for filter - def map[B, To](f: (El1, El2) => B)(implicit cbf: CBF[Repr1, B, To]): To = { - val b = cbf(coll1.repr) - b.sizeHint(coll1) - val elems2 = coll2.iterator - - for (el1 <- coll1) { - if (elems2.hasNext) - b += f(el1, elems2.next) - else - return b.result - } - - b.result - } - - def flatMap[B, To](f: (El1, El2) => TraversableOnce[B])(implicit cbf: CBF[Repr1, B, To]): To = { - val b = cbf(coll1.repr) - val elems2 = coll2.iterator - - for (el1 <- coll1) { - if (elems2.hasNext) - b ++= f(el1, elems2.next) - else - return b.result - } - - b.result - } - - def filter[To1, To2](f: (El1, El2) => Boolean)(implicit cbf1: CBF[Repr1, El1, To1], cbf2: CBF[Repr2, El2, To2]): (To1, To2) = { - val b1 = cbf1(coll1.repr) - val b2 = cbf2(coll2.repr) - val elems2 = coll2.iterator - - for (el1 <- coll1) { - if (elems2.hasNext) { - val el2 = elems2.next - if (f(el1, el2)) { - b1 += el1 - b2 += el2 - } - } - else return (b1.result, b2.result) - } - - (b1.result, b2.result) - } - - def exists(f: (El1, El2) => Boolean): Boolean = { - val elems2 = coll2.iterator - - for (el1 <- coll1) { - if (elems2.hasNext) { - if (f(el1, elems2.next)) - return true - } - else return false - } - false - } - - def forall(f: (El1, El2) => Boolean): Boolean = - !exists((x, y) => !f(x, y)) - - def foreach[U](f: (El1, El2) => U): Unit = { - val elems2 = coll2.iterator - - for (el1 <- coll1) { - if (elems2.hasNext) - f(el1, elems2.next) - else - return - } - } - } - } diff --git a/src/library/scala/Tuple3.scala b/src/library/scala/Tuple3.scala index 0d5399308b..5ed13602e3 100644 --- a/src/library/scala/Tuple3.scala +++ b/src/library/scala/Tuple3.scala @@ -9,9 +9,6 @@ package scala -import scala.collection.{ TraversableLike => TLike, IterableLike => ILike } -import scala.collection.generic.{ CanBuildFrom => CBF } - /** A tuple of 3 elements; the canonical representation of a [[scala.Product3]]. * @@ -25,121 +22,4 @@ case class Tuple3[+T1, +T2, +T3](_1: T1, _2: T2, _3: T3) { override def toString() = "(" + _1 + "," + _2 + "," + _3 + ")" - - @deprecated("Use `zipped` instead.", "2.9.0") - def zip[Repr1, El1, El2, El3, To](implicit w1: T1 => TLike[El1, Repr1], - w2: T2 => Iterable[El2], - w3: T3 => Iterable[El3], - cbf1: CBF[Repr1, (El1, El2, El3), To]): To = { - zipped map ((x, y, z) => ((x, y, z))) - } - - /** Wraps a tuple in a `Zipped`, which supports 3-ary generalisations of `map`, `flatMap`, `filter`, etc. - * Note that there must be an implicit value to convert this tuple's types into a [[scala.collection.TraversableLike]] - * or [[scala.collection.IterableLike]]. - * {{{ - * scala> val tuple = (List(1,2,3),List('a','b','c'),List("x","y","z")) - * tuple: (List[Int], List[Char], List[java.lang.String]) = (List(1, 2, 3),List(a, b, c),List(x, y, z)) - * - * scala> tuple.zipped map { (x,y,z) => x + ":" + y + ":" + z} - * res8: List[java.lang.String] = List(1:a:x, 2:b:y, 3:c:z) - * }}} - * - * @see Zipped - * Note: will not terminate for infinite-sized collections. - */ - def zipped[Repr1, El1, Repr2, El2, Repr3, El3](implicit w1: T1 => TLike[El1, Repr1], - w2: T2 => ILike[El2, Repr2], - w3: T3 => ILike[El3, Repr3]): Zipped[Repr1, El1, Repr2, El2, Repr3, El3] - = new Zipped[Repr1, El1, Repr2, El2, Repr3, El3](_1, _2, _3) - - class Zipped[+Repr1, +El1, +Repr2, +El2, +Repr3, +El3](coll1: TLike[El1, Repr1], - coll2: ILike[El2, Repr2], - coll3: ILike[El3, Repr3]) { - def map[B, To](f: (El1, El2, El3) => B)(implicit cbf: CBF[Repr1, B, To]): To = { - val b = cbf(coll1.repr) - val elems2 = coll2.iterator - val elems3 = coll3.iterator - - for (el1 <- coll1) { - if (elems2.hasNext && elems3.hasNext) - b += f(el1, elems2.next, elems3.next) - else - return b.result - } - b.result - } - - def flatMap[B, To](f: (El1, El2, El3) => TraversableOnce[B])(implicit cbf: CBF[Repr1, B, To]): To = { - val b = cbf(coll1.repr) - val elems2 = coll2.iterator - val elems3 = coll3.iterator - - for (el1 <- coll1) { - if (elems2.hasNext && elems3.hasNext) - b ++= f(el1, elems2.next, elems3.next) - else - return b.result - } - b.result - } - - def filter[To1, To2, To3](f: (El1, El2, El3) => Boolean)( - implicit cbf1: CBF[Repr1, El1, To1], - cbf2: CBF[Repr2, El2, To2], - cbf3: CBF[Repr3, El3, To3]): (To1, To2, To3) = { - val b1 = cbf1(coll1.repr) - val b2 = cbf2(coll2.repr) - val b3 = cbf3(coll3.repr) - val elems2 = coll2.iterator - val elems3 = coll3.iterator - def result = (b1.result, b2.result, b3.result) - - for (el1 <- coll1) { - if (elems2.hasNext && elems3.hasNext) { - val el2 = elems2.next - val el3 = elems3.next - - if (f(el1, el2, el3)) { - b1 += el1 - b2 += el2 - b3 += el3 - } - } - else return result - } - - result - } - - def exists(f: (El1, El2, El3) => Boolean): Boolean = { - val elems2 = coll2.iterator - val elems3 = coll3.iterator - - for (el1 <- coll1) { - if (elems2.hasNext && elems3.hasNext) { - if (f(el1, elems2.next, elems3.next)) - return true - } - else return false - } - false - } - - def forall(f: (El1, El2, El3) => Boolean): Boolean = - !exists((x, y, z) => !f(x, y, z)) - - def foreach[U](f: (El1, El2, El3) => U): Unit = { - val elems2 = coll2.iterator - val elems3 = coll3.iterator - - for (el1 <- coll1) { - if (elems2.hasNext && elems3.hasNext) - f(el1, elems2.next, elems3.next) - else - return - } - } - } - } diff --git a/src/library/scala/runtime/SeqCharSequence.scala b/src/library/scala/runtime/SeqCharSequence.scala new file mode 100644 index 0000000000..7f7bca789f --- /dev/null +++ b/src/library/scala/runtime/SeqCharSequence.scala @@ -0,0 +1,25 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +package scala.runtime + +import java.util.Arrays.copyOfRange + +final class SeqCharSequence(val xs: collection.IndexedSeq[Char]) extends CharSequence { + def length: Int = xs.length + def charAt(index: Int): Char = xs(index) + def subSequence(start: Int, end: Int): CharSequence = new SeqCharSequence(xs.slice(start, end)) + override def toString = xs.mkString("") +} + +final class ArrayCharSequence(val xs: Array[Char]) extends CharSequence { + def length: Int = xs.length + def charAt(index: Int): Char = xs(index) + def subSequence(start: Int, end: Int): CharSequence = new ArrayCharSequence(copyOfRange(xs, math.max(0, start), math.min(xs.length, end))) + override def toString = xs.mkString("") +} diff --git a/src/library/scala/runtime/Tuple2Zipped.scala b/src/library/scala/runtime/Tuple2Zipped.scala new file mode 100644 index 0000000000..5ad364c8a5 --- /dev/null +++ b/src/library/scala/runtime/Tuple2Zipped.scala @@ -0,0 +1,130 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +package scala.runtime + +import scala.collection.{ TraversableLike, IterableLike } +import scala.collection.generic.{ CanBuildFrom => CBF } + +/** This interface is intended as a minimal interface, not complicated + * by the requirement to resolve type constructors, for implicit search (which only + * needs to find an implicit conversion to Traversable for our purposes.) + */ +trait ZippedTraversable2[+El1, +El2] { + def foreach[U](f: (El1, El2) => U): Unit +} +object ZippedTraversable2 { + implicit def zippedTraversable2ToTraversable[El1, El2](zz: ZippedTraversable2[El1, El2]): Traversable[(El1, El2)] = { + new collection.AbstractTraversable[(El1, El2)] { + def foreach[U](f: ((El1, El2)) => U): Unit = zz foreach Function.untupled(f) + } + } +} + +class Tuple2Zipped[El1, Repr1, El2, Repr2]( + coll1: TraversableLike[El1, Repr1], + coll2: IterableLike[El2, Repr2] +) extends ZippedTraversable2[El1, El2] { + def map[B, To](f: (El1, El2) => B)(implicit cbf: CBF[Repr1, B, To]): To = { + val b = cbf(coll1.repr) + b.sizeHint(coll1) + val elems2 = coll2.iterator + + for (el1 <- coll1) { + if (elems2.hasNext) + b += f(el1, elems2.next) + else + return b.result + } + + b.result + } + + def flatMap[B, To](f: (El1, El2) => TraversableOnce[B])(implicit cbf: CBF[Repr1, B, To]): To = { + val b = cbf(coll1.repr) + val elems2 = coll2.iterator + + for (el1 <- coll1) { + if (elems2.hasNext) + b ++= f(el1, elems2.next) + else + return b.result + } + + b.result + } + + def filter[To1, To2](f: (El1, El2) => Boolean)(implicit cbf1: CBF[Repr1, El1, To1], cbf2: CBF[Repr2, El2, To2]): (To1, To2) = { + val b1 = cbf1(coll1.repr) + val b2 = cbf2(coll2.repr) + val elems2 = coll2.iterator + + for (el1 <- coll1) { + if (elems2.hasNext) { + val el2 = elems2.next + if (f(el1, el2)) { + b1 += el1 + b2 += el2 + } + } + else return (b1.result, b2.result) + } + + (b1.result, b2.result) + } + + def exists(f: (El1, El2) => Boolean): Boolean = { + val elems2 = coll2.iterator + + for (el1 <- coll1) { + if (elems2.hasNext) { + if (f(el1, elems2.next)) + return true + } + else return false + } + false + } + + def forall(f: (El1, El2) => Boolean): Boolean = + !exists((x, y) => !f(x, y)) + + def foreach[U](f: (El1, El2) => U): Unit = { + val elems2 = coll2.iterator + + for (el1 <- coll1) { + if (elems2.hasNext) + f(el1, elems2.next) + else + return + } + } +} + +object Tuple2Zipped { + class Ops[T1, T2](x: (T1, T2)) { + def invert[El1, CC1[X] <: TraversableOnce[X], El2, CC2[X] <: TraversableOnce[X], That] + (implicit w1: T1 <:< CC1[El1], + w2: T2 <:< CC2[El2], + bf: collection.generic.CanBuildFrom[CC1[_], (El1, El2), That] + ): That = { + val buf = bf(x._1) + val it1 = x._1.toIterator + val it2 = x._2.toIterator + while (it1.hasNext && it2.hasNext) + buf += ((it1.next, it2.next)) + + buf.result + } + + def zipped[El1, Repr1, El2, Repr2] + (implicit w1: T1 => TraversableLike[El1, Repr1], + w2: T2 => IterableLike[El2, Repr2] + ): Tuple2Zipped[El1, Repr1, El2, Repr2] = new Tuple2Zipped(x._1, x._2) + } +} diff --git a/src/library/scala/runtime/Tuple3Zipped.scala b/src/library/scala/runtime/Tuple3Zipped.scala new file mode 100644 index 0000000000..4e9c542c58 --- /dev/null +++ b/src/library/scala/runtime/Tuple3Zipped.scala @@ -0,0 +1,141 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +package scala.runtime + +import scala.collection.{ TraversableLike, IterableLike } +import scala.collection.generic.{ CanBuildFrom => CBF } + +/** See comment on ZippedTraversable2. */ +trait ZippedTraversable3[+El1, +El2, +El3] { + def foreach[U](f: (El1, El2, El3) => U): Unit +} +object ZippedTraversable3 { + implicit def zippedTraversable3ToTraversable[El1, El2, El3](zz: ZippedTraversable3[El1, El2, El3]): Traversable[(El1, El2, El3)] = { + new collection.AbstractTraversable[(El1, El2, El3)] { + def foreach[U](f: ((El1, El2, El3)) => U): Unit = zz foreach Function.untupled(f) + } + } +} + +class Tuple3Zipped[El1, Repr1, El2, Repr2, El3, Repr3]( + coll1: TraversableLike[El1, Repr1], + coll2: IterableLike[El2, Repr2], + coll3: IterableLike[El3, Repr3] +) extends ZippedTraversable3[El1, El2, El3] { + def map[B, To](f: (El1, El2, El3) => B)(implicit cbf: CBF[Repr1, B, To]): To = { + val b = cbf(coll1.repr) + val elems2 = coll2.iterator + val elems3 = coll3.iterator + + for (el1 <- coll1) { + if (elems2.hasNext && elems3.hasNext) + b += f(el1, elems2.next, elems3.next) + else + return b.result + } + b.result + } + + def flatMap[B, To](f: (El1, El2, El3) => TraversableOnce[B])(implicit cbf: CBF[Repr1, B, To]): To = { + val b = cbf(coll1.repr) + val elems2 = coll2.iterator + val elems3 = coll3.iterator + + for (el1 <- coll1) { + if (elems2.hasNext && elems3.hasNext) + b ++= f(el1, elems2.next, elems3.next) + else + return b.result + } + b.result + } + + def filter[To1, To2, To3](f: (El1, El2, El3) => Boolean)( + implicit cbf1: CBF[Repr1, El1, To1], + cbf2: CBF[Repr2, El2, To2], + cbf3: CBF[Repr3, El3, To3]): (To1, To2, To3) = { + val b1 = cbf1(coll1.repr) + val b2 = cbf2(coll2.repr) + val b3 = cbf3(coll3.repr) + val elems2 = coll2.iterator + val elems3 = coll3.iterator + def result = (b1.result, b2.result, b3.result) + + for (el1 <- coll1) { + if (elems2.hasNext && elems3.hasNext) { + val el2 = elems2.next + val el3 = elems3.next + + if (f(el1, el2, el3)) { + b1 += el1 + b2 += el2 + b3 += el3 + } + } + else return result + } + + result + } + + def exists(f: (El1, El2, El3) => Boolean): Boolean = { + val elems2 = coll2.iterator + val elems3 = coll3.iterator + + for (el1 <- coll1) { + if (elems2.hasNext && elems3.hasNext) { + if (f(el1, elems2.next, elems3.next)) + return true + } + else return false + } + false + } + + def forall(f: (El1, El2, El3) => Boolean): Boolean = + !exists((x, y, z) => !f(x, y, z)) + + def foreach[U](f: (El1, El2, El3) => U): Unit = { + val elems2 = coll2.iterator + val elems3 = coll3.iterator + + for (el1 <- coll1) { + if (elems2.hasNext && elems3.hasNext) + f(el1, elems2.next, elems3.next) + else + return + } + } +} + +object Tuple3Zipped { + class Ops[T1, T2, T3](x: (T1, T2, T3)) { + def invert[El1, CC1[X] <: TraversableOnce[X], El2, CC2[X] <: TraversableOnce[X], El3, CC3[X] <: TraversableOnce[X], That] + (implicit w1: T1 <:< CC1[El1], + w2: T2 <:< CC2[El2], + w3: T3 <:< CC3[El3], + bf: collection.generic.CanBuildFrom[CC1[_], (El1, El2, El3), That] + ): That = { + val buf = bf(x._1) + val it1 = x._1.toIterator + val it2 = x._2.toIterator + val it3 = x._3.toIterator + while (it1.hasNext && it2.hasNext && it3.hasNext) + buf += ((it1.next, it2.next, it3.next)) + + buf.result + } + + def zipped[El1, Repr1, El2, Repr2, El3, Repr3] + (implicit w1: T1 => TraversableLike[El1, Repr1], + w2: T2 => IterableLike[El2, Repr2], + w3: T3 => IterableLike[El3, Repr3] + ): Tuple3Zipped[El1, Repr1, El2, Repr2, El3, Repr3] = new Tuple3Zipped(x._1, x._2, x._3) + } +} diff --git a/test/files/neg/t900.check b/test/files/neg/t900.check index 047094ad6e..4611ceba8c 100644 --- a/test/files/neg/t900.check +++ b/test/files/neg/t900.check @@ -2,8 +2,8 @@ t900.scala:4: error: type mismatch; found : Foo.this.x.type (with underlying type Foo.this.bar) required: AnyRef Note that implicit conversions are not applicable because they are ambiguous: - both method any2stringadd in object Predef of type (x: Any)scala.runtime.StringAdd - and method any2stringfmt in object Predef of type (x: Any)scala.runtime.StringFormat + both method any2stringfmt in object Predef of type (x: Any)scala.runtime.StringFormat + and method any2stringadd in object Predef of type (x: Any)scala.runtime.StringAdd are possible conversion functions from Foo.this.x.type to AnyRef def break(): x.type ^ diff --git a/test/files/run/tuple-zipped.scala b/test/files/run/tuple-zipped.scala index a9851346bc..b197183844 100644 --- a/test/files/run/tuple-zipped.scala +++ b/test/files/run/tuple-zipped.scala @@ -15,14 +15,14 @@ object Test { def main(args: Array[String]): Unit = { for (cc1 <- xss1 ; cc2 <- xss2) { - val sum1 = (cc1, cc2).zip map { case (x, y) => x + y } sum + val sum1 = (cc1, cc2).zipped map { case (x, y) => x + y } sum val sum2 = (cc1, cc2).zipped map (_ + _) sum assert(sum1 == sum2) } for (cc1 <- xss1 ; cc2 <- xss2 ; cc3 <- xss3) { - val sum1 = (cc1, cc2, cc3).zip map { case (x, y, z) => x + y + z } sum + val sum1 = (cc1, cc2, cc3).zipped map { case (x, y, z) => x + y + z } sum val sum2 = (cc1, cc2, cc3).zipped map (_ + _ + _) sum assert(sum1 == sum2) diff --git a/tools/codegen b/tools/codegen index 734235aef8..35c93fba16 100755 --- a/tools/codegen +++ b/tools/codegen @@ -3,6 +3,6 @@ THISDIR=`dirname $0` SCALALIB=$THISDIR/../src/library/scala -BINDIR=$THISDIR/../build/pack/bin +BINDIR=$THISDIR/../build/quick/bin $BINDIR/scala scala.tools.cmd.gen.Codegen "$@" -- cgit v1.2.3 From 1d7430c7d574f02ea88ed8e1b5394e8986be5618 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Mon, 30 Apr 2012 09:22:12 -0700 Subject: De-duplication in Contexts. Friends don't let friends cut and paste. --- .../scala/tools/nsc/typechecker/Contexts.scala | 26 ++++++++++------------ 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala index 4584ba032d..0924789948 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala @@ -354,32 +354,30 @@ trait Contexts { self: Analyzer => private def unitError(pos: Position, msg: String) = unit.error(pos, if (checking) "\n**** ERROR DURING INTERNAL CHECKING ****\n" + msg else msg) - - def issue(err: AbsTypeError) { + + @inline private def issueCommon(err: AbsTypeError)(pf: PartialFunction[AbsTypeError, Unit]) { debugwarn("issue error: " + err.errMsg) if (settings.Yissuedebug.value) (new Exception).printStackTrace() - if (reportErrors) unitError(err.errPos, addDiagString(err.errMsg)) + if (pf isDefinedAt err) pf(err) else if (bufferErrors) { buffer += err } else throw new TypeError(err.errPos, err.errMsg) } + def issue(err: AbsTypeError) { + issueCommon(err) { case _ if reportErrors => + unitError(err.errPos, addDiagString(err.errMsg)) + } + } + def issueAmbiguousError(pre: Type, sym1: Symbol, sym2: Symbol, err: AbsTypeError) { - debugwarn("issue ambiguous error: " + err.errMsg) - if (settings.Yissuedebug.value) (new Exception).printStackTrace() - if (ambiguousErrors) { + issueCommon(err) { case _ if ambiguousErrors => if (!pre.isErroneous && !sym1.isErroneous && !sym2.isErroneous) unitError(err.errPos, err.errMsg) - } else if (bufferErrors) { buffer += err } - else throw new TypeError(err.errPos, err.errMsg) + } } def issueAmbiguousError(err: AbsTypeError) { - debugwarn("issue ambiguous error: " + err.errMsg) - if (settings.Yissuedebug.value) (new Exception).printStackTrace() - if (ambiguousErrors) - unitError(err.errPos, addDiagString(err.errMsg)) - else if (bufferErrors) { buffer += err } - else throw new TypeError(err.errPos, err.errMsg) + issueCommon(err) { case _ if ambiguousErrors => unitError(err.errPos, addDiagString(err.errMsg)) } } // TODO remove -- cgit v1.2.3