diff options
88 files changed, 869 insertions, 276 deletions
diff --git a/.mailmap b/.mailmap new file mode 100644 index 0000000000..49d5dc6629 --- /dev/null +++ b/.mailmap @@ -0,0 +1,25 @@ +Aleksandar Prokopec <aleksandar@aleksandar-Latitude-E6500.(none)> +Aleksandar Prokopec <aleksandar@htpc.(none)> +Aleksandar Prokopec <aleksandar@htpc-axel22.(none)> +Aleksandar Prokopec <aleksandar@lampmac14.epfl.ch> +Aleksandar Prokopec <aleksandar.prokopec@epfl.ch> +Antonio Cunei <antonio.cunei@typesafe.com> +Caoyuan Deng <dcaoyuan@epfl.ch> +Chris Hodapp <clhodapp1@gmail.com> +Chris James <chrisJames@epfl.ch> +Christopher Vogt <vogt@epfl.ch> +Damien Obristi <damien.obrist@gmail.com> +Daniel C. Sobral <dcs@dcs-132-CK-NF79.(none)> +Ilya Sergei <ilyas@epfl.ch> +Ingo Maier <ingoem@gmail.com> +Kenji Yoshida <6b656e6a69@gmail.com> +Luc Bourlier <skyluc@epfl.ch> +Martin Odersky <odersky@gamil.com> +Nada Amin <amin@epfl.ch> +Nada Amin <nada.amin@epfl.ch> +Natallie Baikevich <lu-a-jalla@ya.ru> +Pavel Pavlov <pavel.e.pavlov@gmail.com> +Philipp Haller <philipp.haller@typesafe.com> +Roland Kuhn <rk@rkuhn.info> +Rüdiger Klaehn <rklaehn@gmail.com> +Stéphane Micheloud <michelou@epfl.ch> diff --git a/META-INF/MANIFEST.MF b/META-INF/MANIFEST.MF index 28a70d2879..4d5573db12 100644 --- a/META-INF/MANIFEST.MF +++ b/META-INF/MANIFEST.MF @@ -43,7 +43,7 @@ Export-Package: scala.reflect.internal.pickling, scala.reflect.internal.settings, scala.reflect.internal.util, - scala.reflect.makro, + scala.reflect.macros, scala.reflect.runtime, scala.reflect.internal.transform, scala.reflect.api, @@ -226,7 +226,7 @@ PROPERTIES <property name="dists.dir" value="${basedir}/dists"/> - <property name="copyright.string" value="Copyright 2002-2012, LAMP/EPFL"/> + <property name="copyright.string" value="Copyright 2002-2013, LAMP/EPFL"/> <property name="partest.version.number" value="0.9.2"/> <!-- These are NOT the flags used to run SuperSabbus, but the ones written @@ -2659,6 +2659,7 @@ Binary compatibility testing </artifact:dependencies> <artifact:dependencies pathId="old.bc.classpath"> <dependency groupId="org.scala-lang" artifactId="scala-library" version="2.10.0-RC2"/> + <dependency groupId="org.scala-lang" artifactId="scala-reflect" version="2.10.0-RC2"/> </artifact:dependencies> </target> @@ -2674,7 +2675,19 @@ Binary compatibility testing <classpath> <path refid="mima.classpath"/> </classpath> - </java> + </java> + <java + fork="true" + failonerror="true" + classname="com.typesafe.tools.mima.cli.Main"> + <arg value="--prev"/> + <arg value="${org.scala-lang:scala-reflect:jar}"/> + <arg value="--curr"/> + <arg value="${build-pack.dir}/lib/scala-reflect.jar"/> + <classpath> + <path refid="mima.classpath"/> + </classpath> + </java> </target> @@ -2706,7 +2719,12 @@ DISTRIBUTION <target name="dist.base" depends="dist.start"> <mkdir dir="${dist.dir}/lib"/> <copy toDir="${dist.dir}/lib"> - <fileset dir="${build-pack.dir}/lib"/> + <fileset dir="${build-pack.dir}/lib"> + <include name="jline.jar"/> + <include name="scalacheck.jar"/> + <include name="scala-partest.jar"/> + <include name="scalap.jar"/> + </fileset> </copy> <mkdir dir="${dist.dir}/bin"/> <!-- TODO - Stop being inefficient and don't copy OSGi bundles overtop other jars. --> diff --git a/project/Versions.scala b/project/Versions.scala index cc0ab7ff2b..57e274c15c 100644 --- a/project/Versions.scala +++ b/project/Versions.scala @@ -67,7 +67,7 @@ object Versions { IO.write(f, "version.number = "+versions.canonical+"\n"+ "osgi.number = "+versions.osgi+"\n"+ "maven.number = "+versions.maven+"\n"+ - "copyright.string = Copyright 2002-2012, LAMP/EPFL") + "copyright.string = Copyright 2002-2013, LAMP/EPFL") def makeCanonicalVersion(isRelease: Boolean, mvnVersion: String, base: BaseBuildNumber, gitDate: String, gitSha: String): String = if(isRelease) mvnVersion diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index 8883920325..757ac94dbd 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -779,7 +779,6 @@ class Global(var currentSettings: Settings, var reporter: Reporter) /* The set of phase objects that is the basis for the compiler phase chain */ protected lazy val phasesSet = new mutable.HashSet[SubComponent] protected lazy val phasesDescMap = new mutable.HashMap[SubComponent, String] withDefaultValue "" - private lazy val phaseTimings = new Phases.TimingModel // tracking phase stats protected def addToPhasesSet(sub: SubComponent, descr: String) { phasesSet += sub @@ -1584,7 +1583,6 @@ class Global(var currentSettings: Settings, var reporter: Reporter) // progress update informTime(globalPhase.description, startTime) - phaseTimings(globalPhase) = currentTime - startTime if (opt.writeICodeAtICode || (opt.printPhase && runIsAtOptimiz)) { // Write *.icode files when -Xprint-icode or -Xprint:<some-optimiz-phase> was given. diff --git a/src/compiler/scala/tools/nsc/Phases.scala b/src/compiler/scala/tools/nsc/Phases.scala index c914344fd5..0901ade2d7 100644 --- a/src/compiler/scala/tools/nsc/Phases.scala +++ b/src/compiler/scala/tools/nsc/Phases.scala @@ -9,6 +9,7 @@ import symtab.Flags import scala.reflect.internal.util.TableDef import scala.language.postfixOps +@deprecated("Scheduled for removal as being a dead-code in the compiler.", "2.10.1") object Phases { val MaxPhases = 64 diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenJVMASM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenJVMASM.scala index 49c0fa2757..540935fd57 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenJVMASM.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenJVMASM.scala @@ -78,17 +78,19 @@ trait GenJVMASM { failNoForwarder("companion is a trait") // Now either succeeed, or issue some additional warnings for things which look like // attempts to be java main methods. - else possibles exists { m => - m.info match { - case PolyType(_, _) => - fail("main methods cannot be generic.") - case MethodType(params, res) => - if (res.typeSymbol :: params exists (_.isAbstractType)) - fail("main methods cannot refer to type parameters or abstract types.", m.pos) - else - isJavaMainMethod(m) || fail("main method must have exact signature (Array[String])Unit", m.pos) - case tp => - fail("don't know what this is: " + tp, m.pos) + else (possibles exists isJavaMainMethod) || { + possibles exists { m => + m.info match { + case PolyType(_, _) => + fail("main methods cannot be generic.") + case MethodType(params, res) => + if (res.typeSymbol :: params exists (_.isAbstractType)) + fail("main methods cannot refer to type parameters or abstract types.", m.pos) + else + isJavaMainMethod(m) || fail("main method must have exact signature (Array[String])Unit", m.pos) + case tp => + fail("don't know what this is: " + tp, m.pos) + } } } } diff --git a/src/compiler/scala/tools/nsc/doc/base/MemberLookupBase.scala b/src/compiler/scala/tools/nsc/doc/base/MemberLookupBase.scala index f3a5660dc4..35390adcd9 100755 --- a/src/compiler/scala/tools/nsc/doc/base/MemberLookupBase.scala +++ b/src/compiler/scala/tools/nsc/doc/base/MemberLookupBase.scala @@ -15,6 +15,7 @@ trait MemberLookupBase { import global._ def internalLink(sym: Symbol, site: Symbol): Option[LinkTo] def chooseLink(links: List[LinkTo]): LinkTo + def toString(link: LinkTo): String import global._ import definitions.{ NothingClass, AnyClass, AnyValClass, AnyRefClass, ListClass } @@ -25,6 +26,25 @@ trait MemberLookupBase { def makeEntityLink(title: Inline, pos: Position, query: String, siteOpt: Option[Symbol]) = new EntityLink(title) { lazy val link = memberLookup(pos, query, siteOpt) } + private var showExplanation = true + private def explanation: String = + if (showExplanation) { + showExplanation = false + """ + |Quick crash course on using Scaladoc links + |========================================== + |Disambiguating terms and types: Prefix terms with '$' and types with '!' in case both names are in use: + | - [[scala.collection.immutable.List!.apply class List's apply method]] and + | - [[scala.collection.immutable.List$.apply object List's apply method]] + |Disambiguating overloaded members: If a term is overloaded, you can indicate the first part of its signature followed by *: + | - [[[scala.collection.immutable.List$.fill[A](Int)(⇒A):List[A]* Fill with a single parameter]]] + | - [[[scala.collection.immutable.List$.fill[A](Int,Int)(⇒A):List[List[A]]* Fill with a two parameters]]] + |Notes: + | - you can use any number of matching square brackets to avoid interference with the signature + | - you can use \\. to escape dots in prefixes (don't forget to use * at the end to match the signature!) + | - you can use \\# to escape hashes, otherwise they will be considered as delimiters, like dots.""".stripMargin + } else "" + def memberLookup(pos: Position, query: String, siteOpt: Option[Symbol]): LinkTo = { var members = breakMembers(query) @@ -73,36 +93,23 @@ trait MemberLookupBase { def linkToString(link: LinkTo) = { val chosenInfo = if (link == chosen) " [chosen]" else "" - link.toString + chosenInfo + "\n" + toString(link) + chosenInfo + "\n" } - if (!settings.docNoLinkWarnings.value) + if (!settings.docNoLinkWarnings.value) { + val allLinks = links.map(linkToString).mkString reporter.warning(pos, - "The link target \"" + query + "\" is ambiguous. Several (possibly overloaded) members fit the target:\n" + - links.map(linkToString).mkString + - (if (MemberLookup.showExplanation) - "\n\n" + - "Quick crash course on using Scaladoc links\n" + - "==========================================\n" + - "Disambiguating terms and types: Prefix terms with '$' and types with '!' in case both names are in use:\n" + - " - [[scala.collection.immutable.List!.apply class List's apply method]] and\n" + - " - [[scala.collection.immutable.List$.apply object List's apply method]]\n" + - "Disambiguating overloaded members: If a term is overloaded, you can indicate the first part of its signature followed by *:\n" + - " - [[[scala.collection.immutable.List$.fill[A](Int)(⇒A):List[A]* Fill with a single parameter]]]\n" + - " - [[[scala.collection.immutable.List$.fill[A](Int,Int)(⇒A):List[List[A]]* Fill with a two parameters]]]\n" + - "Notes: \n" + - " - you can use any number of matching square brackets to avoid interference with the signature\n" + - " - you can use \\. to escape dots in prefixes (don't forget to use * at the end to match the signature!)\n" + - " - you can use \\# to escape hashes, otherwise they will be considered as delimiters, like dots.\n" - else "") - ) + s"""The link target \"$query\" is ambiguous. Several members fit the target: + |$allLinks + |$explanation""".stripMargin) + } chosen } } - private abstract class SearchStrategy - private object BothTypeAndTerm extends SearchStrategy - private object OnlyType extends SearchStrategy - private object OnlyTerm extends SearchStrategy + private sealed trait SearchStrategy + private case object BothTypeAndTerm extends SearchStrategy + private case object OnlyType extends SearchStrategy + private case object OnlyTerm extends SearchStrategy private def lookupInRootPackage(pos: Position, members: List[String]) = lookupInTemplate(pos, members, EmptyPackage) ::: lookupInTemplate(pos, members, RootPackage) @@ -156,14 +163,11 @@ trait MemberLookupBase { else if (member.endsWith("*")) cleanupBogusClasses(container.info.nonPrivateDecls) filter signatureMatch else - if (strategy == BothTypeAndTerm) - termSyms ::: typeSyms - else if (strategy == OnlyType) - typeSyms - else if (strategy == OnlyTerm) - termSyms - else - Nil + strategy match { + case BothTypeAndTerm => termSyms ::: typeSyms + case OnlyType => typeSyms + case OnlyTerm => termSyms + } //println("lookupInTemplate(" + member + ", " + container + ") => " + result) result @@ -223,8 +227,3 @@ trait MemberLookupBase { (sym.nameString + sym.signatureString).replaceAll("\\s", "") } } - -object MemberLookup { - private[this] var _showExplanation = true - def showExplanation: Boolean = if (_showExplanation) { _showExplanation = false; true } else false -} diff --git a/src/compiler/scala/tools/nsc/doc/html/page/Template.scala b/src/compiler/scala/tools/nsc/doc/html/page/Template.scala index e885e9c56e..ea07ff29c4 100644 --- a/src/compiler/scala/tools/nsc/doc/html/page/Template.scala +++ b/src/compiler/scala/tools/nsc/doc/html/page/Template.scala @@ -335,12 +335,10 @@ class Template(universe: doc.Universe, generator: DiagramGenerator, tpl: DocTemp } } - def memberToShortCommentHtml(mbr: MemberEntity, isSelf: Boolean): NodeSeq = { - if (mbr.comment.isEmpty) - NodeSeq.Empty - else - <p class="shortcomment cmt">{ memberToUseCaseCommentHtml(mbr, isSelf) }{ inlineToHtml(mbr.comment.get.short) }</p> - } + def memberToShortCommentHtml(mbr: MemberEntity, isSelf: Boolean): NodeSeq = + mbr.comment.fold(NodeSeq.Empty) { comment => + <p class="shortcomment cmt">{ memberToUseCaseCommentHtml(mbr, isSelf) }{ inlineToHtml(comment.short) }</p> + } def memberToInlineCommentHtml(mbr: MemberEntity, isSelf: Boolean): NodeSeq = <p class="comment cmt">{ inlineToHtml(mbr.comment.get.short) }</p> @@ -361,37 +359,34 @@ class Template(universe: doc.Universe, generator: DiagramGenerator, tpl: DocTemp case _ => Nil } - def mbrCmt = mbr.comment.get - - def paramCommentToHtml(prs: List[ParameterEntity]): NodeSeq = prs match { + def paramCommentToHtml(prs: List[ParameterEntity], comment: Comment): NodeSeq = prs match { case (tp: TypeParam) :: rest => val paramEntry: NodeSeq = { - <dt class="tparam">{ tp.name }</dt><dd class="cmt">{ bodyToHtml(mbrCmt.typeParams(tp.name)) }</dd> + <dt class="tparam">{ tp.name }</dt><dd class="cmt">{ bodyToHtml(comment.typeParams(tp.name)) }</dd> } - paramEntry ++ paramCommentToHtml(rest) + paramEntry ++ paramCommentToHtml(rest, comment) case (vp: ValueParam) :: rest => val paramEntry: NodeSeq = { - <dt class="param">{ vp.name }</dt><dd class="cmt">{ bodyToHtml(mbrCmt.valueParams(vp.name)) }</dd> + <dt class="param">{ vp.name }</dt><dd class="cmt">{ bodyToHtml(comment.valueParams(vp.name)) }</dd> } - paramEntry ++ paramCommentToHtml(rest) + paramEntry ++ paramCommentToHtml(rest, comment) case _ => NodeSeq.Empty } - if (mbr.comment.isEmpty) NodeSeq.Empty - else { + mbr.comment.fold(NodeSeq.Empty) { comment => val cmtedPrs = prs filter { - case tp: TypeParam => mbrCmt.typeParams isDefinedAt tp.name - case vp: ValueParam => mbrCmt.valueParams isDefinedAt vp.name + case tp: TypeParam => comment.typeParams isDefinedAt tp.name + case vp: ValueParam => comment.valueParams isDefinedAt vp.name } - if (cmtedPrs.isEmpty && mbrCmt.result.isEmpty) NodeSeq.Empty + if (cmtedPrs.isEmpty && comment.result.isEmpty) NodeSeq.Empty else { <dl class="paramcmts block">{ - paramCommentToHtml(cmtedPrs) ++ ( - mbrCmt.result match { + paramCommentToHtml(cmtedPrs, comment) ++ ( + comment.result match { case None => NodeSeq.Empty case Some(cmt) => <dt>returns</dt><dd class="cmt">{ bodyToHtml(cmt) }</dd> @@ -470,7 +465,7 @@ class Template(universe: doc.Universe, generator: DiagramGenerator, tpl: DocTemp } // --- start attributes block vals - val attributes: Seq[scala.xml.Node] = { + val attributes: NodeSeq = { val fvs: List[comment.Paragraph] = visibility(mbr).toList if (fvs.isEmpty || isReduced) NodeSeq.Empty else { @@ -479,7 +474,7 @@ class Template(universe: doc.Universe, generator: DiagramGenerator, tpl: DocTemp } } - val definitionClasses: Seq[scala.xml.Node] = { + val definitionClasses: NodeSeq = { val inDefTpls = mbr.inDefinitionTemplates if ((inDefTpls.tail.isEmpty && (inDefTpls.head == inTpl)) || isReduced) NodeSeq.Empty else { @@ -488,7 +483,7 @@ class Template(universe: doc.Universe, generator: DiagramGenerator, tpl: DocTemp } } - val fullSignature: Seq[scala.xml.Node] = { + val fullSignature: NodeSeq = { mbr match { case nte: NonTemplateMemberEntity if nte.isUseCase => <div class="full-signature-block toggleContainer"> @@ -499,14 +494,14 @@ class Template(universe: doc.Universe, generator: DiagramGenerator, tpl: DocTemp } } - val selfType: Seq[scala.xml.Node] = mbr match { + val selfType: NodeSeq = mbr match { case dtpl: DocTemplateEntity if (isSelf && !dtpl.selfType.isEmpty && !isReduced) => <dt>Self Type</dt> <dd>{ typeToHtml(dtpl.selfType.get, hasLinks = true) }</dd> case _ => NodeSeq.Empty } - val annotations: Seq[scala.xml.Node] = { + val annotations: NodeSeq = { // A list of annotations which don't show their arguments, e. g. because they are shown separately. val annotationsWithHiddenArguments = List("deprecated", "Deprecated", "migration") @@ -528,7 +523,7 @@ class Template(universe: doc.Universe, generator: DiagramGenerator, tpl: DocTemp } else NodeSeq.Empty } - val sourceLink: Seq[scala.xml.Node] = mbr match { + val sourceLink: NodeSeq = mbr match { case dtpl: DocTemplateEntity if (isSelf && dtpl.sourceUrl.isDefined && dtpl.inSource.isDefined && !isReduced) => val (absFile, line) = dtpl.inSource.get <dt>Source</dt> @@ -536,83 +531,87 @@ class Template(universe: doc.Universe, generator: DiagramGenerator, tpl: DocTemp case _ => NodeSeq.Empty } - val deprecation: Seq[scala.xml.Node] = - if (mbr.deprecation.isEmpty || isReduced) NodeSeq.Empty - else { - <dt>Deprecated</dt> - <dd class="cmt">{ bodyToHtml(mbr.deprecation.get) }</dd> + val deprecation: NodeSeq = + mbr.deprecation match { + case Some(deprecation) if !isReduced => + <dt>Deprecated</dt> + <dd class="cmt">{ bodyToHtml(deprecation) }</dd> + case _ => NodeSeq.Empty } - val migration: Seq[scala.xml.Node] = - if(mbr.migration.isEmpty || isReduced) NodeSeq.Empty - else { + val migration: NodeSeq = + mbr.migration match { + case Some(migration) if !isReduced => <dt>Migration</dt> - <dd class="cmt">{ bodyToHtml(mbr.migration.get) }</dd> + <dd class="cmt">{ bodyToHtml(migration) }</dd> + case _ => NodeSeq.Empty } - val mainComment: Seq[scala.xml.Node] = mbr.comment match { + val mainComment: NodeSeq = mbr.comment match { case Some(comment) if (! isReduced) => + def orEmpty[T](it: Iterable[T])(gen: =>NodeSeq): NodeSeq = + if (it.isEmpty) NodeSeq.Empty else gen + val example = - if(!comment.example.isEmpty) + orEmpty(comment.example) { <div class="block">Example{ if (comment.example.length > 1) "s" else ""}: - <ol>{ - val exampleXml: List[scala.xml.NodeSeq] = - for(example <- comment.example ) yield - <li class="cmt">{ bodyToHtml(example) }</li> - exampleXml.reduceLeft(_ ++ Text(", ") ++ _) + <ol>{ + val exampleXml: List[NodeSeq] = for (ex <- comment.example) yield + <li class="cmt">{ bodyToHtml(ex) }</li> + exampleXml.reduceLeft(_ ++ Text(", ") ++ _) }</ol> - </div> - else NodeSeq.Empty + </div> + } - val version: Seq[scala.xml.Node] = - if(!comment.version.isEmpty) { + val version: NodeSeq = + orEmpty(comment.version) { <dt>Version</dt> - <dd>{ for(body <- comment.version.toList) yield {bodyToHtml(body)} }</dd> - } else NodeSeq.Empty + <dd>{ for(body <- comment.version.toList) yield bodyToHtml(body) }</dd> + } - val sinceVersion: Seq[scala.xml.Node] = - if(!comment.since.isEmpty) { + val sinceVersion: NodeSeq = + orEmpty(comment.since) { <dt>Since</dt> - <dd>{ for(body <- comment.since.toList) yield {bodyToHtml(body)} }</dd> - } else NodeSeq.Empty + <dd>{ for(body <- comment.since.toList) yield bodyToHtml(body) }</dd> + } - val note: Seq[scala.xml.Node] = - if(!comment.note.isEmpty) { + val note: NodeSeq = + orEmpty(comment.note) { <dt>Note</dt> <dd>{ - val noteXml: List[scala.xml.NodeSeq] = (for(note <- comment.note ) yield <span class="cmt">{bodyToHtml(note)}</span> ) + val noteXml: List[NodeSeq] = for(note <- comment.note ) yield <span class="cmt">{bodyToHtml(note)}</span> noteXml.reduceLeft(_ ++ Text(", ") ++ _) }</dd> - } else NodeSeq.Empty + } - val seeAlso: Seq[scala.xml.Node] = - if(!comment.see.isEmpty) { + val seeAlso: NodeSeq = + orEmpty(comment.see) { <dt>See also</dt> <dd>{ - val seeXml:List[scala.xml.NodeSeq]=(for(see <- comment.see ) yield <span class="cmt">{bodyToHtml(see)}</span> ) + val seeXml: List[NodeSeq] = for(see <- comment.see ) yield <span class="cmt">{bodyToHtml(see)}</span> seeXml.reduceLeft(_ ++ _) }</dd> - } else NodeSeq.Empty + } - val exceptions: Seq[scala.xml.Node] = - if(!comment.throws.isEmpty) { + val exceptions: NodeSeq = + orEmpty(comment.throws) { <dt>Exceptions thrown</dt> <dd>{ - val exceptionsXml: Iterable[scala.xml.NodeSeq] = - for(exception <- comment.throws.toList.sortBy(_._1) ) yield - <span class="cmt">{Text(exception._1) ++ bodyToHtml(exception._2)}</span> + val exceptionsXml: List[NodeSeq] = + for((name, body) <- comment.throws.toList.sortBy(_._1) ) yield + <span class="cmt">{Text(name) ++ bodyToHtml(body)}</span> exceptionsXml.reduceLeft(_ ++ Text("") ++ _) }</dd> - } else NodeSeq.Empty + } - val todo: Seq[scala.xml.Node] = - if(!comment.todo.isEmpty) { + val todo: NodeSeq = + orEmpty(comment.todo) { <dt>To do</dt> <dd>{ - val todoXml: List[scala.xml.NodeSeq] = (for(todo <- comment.todo ) yield <span class="cmt">{bodyToHtml(todo)}</span> ) + val todoXml: List[NodeSeq] = (for(todo <- comment.todo ) yield <span class="cmt">{bodyToHtml(todo)}</span> ) todoXml.reduceLeft(_ ++ Text(", ") ++ _) }</dd> - } else NodeSeq.Empty + } example ++ version ++ sinceVersion ++ exceptions ++ todo ++ note ++ seeAlso diff --git a/src/compiler/scala/tools/nsc/doc/model/MemberLookup.scala b/src/compiler/scala/tools/nsc/doc/model/MemberLookup.scala index b1105196b7..c7a767f992 100644 --- a/src/compiler/scala/tools/nsc/doc/model/MemberLookup.scala +++ b/src/compiler/scala/tools/nsc/doc/model/MemberLookup.scala @@ -28,4 +28,11 @@ trait MemberLookup extends base.MemberLookupBase { else mbrs.min(Ordering[MemberEntity].on[(MemberEntity, LinkTo)](_._1))._2 } + + override def toString(link: LinkTo) = link match { + case LinkToTpl(tpl: EntityImpl) => tpl.sym.toString + case LinkToMember(mbr: EntityImpl, inTpl: EntityImpl) => + mbr.sym.signatureString + " in " + inTpl.sym.toString + case _ => link.toString + } } diff --git a/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala b/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala index ea074873e8..c6cfc317ea 100644 --- a/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala +++ b/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala @@ -1093,13 +1093,5 @@ class ModelFactory(val global: Global, val settings: doc.Settings) { (bSym.isAliasType || bSym.isAbstractType) && { val rawComment = global.expandedDocComment(bSym, inTpl.sym) rawComment.contains("@template") || rawComment.contains("@documentable") } - - object LinkToTpl { - // this makes it easier to create links - def apply(tpl: TemplateEntity): LinkTo = tpl match { - case dtpl: DocTemplateEntity => new LinkToTpl(dtpl) - case _ => new Tooltip(tpl.qualifiedName) - } - } } diff --git a/src/compiler/scala/tools/nsc/doc/model/ModelFactoryTypeSupport.scala b/src/compiler/scala/tools/nsc/doc/model/ModelFactoryTypeSupport.scala index 87dc615c8e..844a509b7e 100644 --- a/src/compiler/scala/tools/nsc/doc/model/ModelFactoryTypeSupport.scala +++ b/src/compiler/scala/tools/nsc/doc/model/ModelFactoryTypeSupport.scala @@ -92,7 +92,10 @@ trait ModelFactoryTypeSupport { findTemplateMaybe(bSym) match { case Some(bTpl) if owner == bSym.owner => // (0) the owner's class is linked AND has a template - lovely - LinkToTpl(bTpl) + bTpl match { + case dtpl: DocTemplateEntity => new LinkToTpl(dtpl) + case _ => new Tooltip(bTpl.qualifiedName) + } case _ => val oTpl = findTemplateMaybe(owner) (oTpl, oTpl flatMap (findMember(bSym, _))) match { diff --git a/src/compiler/scala/tools/nsc/interactive/Doc.scala b/src/compiler/scala/tools/nsc/interactive/Doc.scala index 4d02de6198..ad28a28105 100755 --- a/src/compiler/scala/tools/nsc/interactive/Doc.scala +++ b/src/compiler/scala/tools/nsc/interactive/Doc.scala @@ -32,6 +32,15 @@ abstract class Doc(val settings: doc.Settings) extends MemberLookupBase with Com None } + override def toString(link: LinkTo) = ask { () => + link match { + case LinkToMember(mbr: Symbol, site: Symbol) => + mbr.signatureString + " in " + site.toString + case LinkToTpl(sym: Symbol) => sym.toString + case _ => link.toString + } + } + def retrieve(sym: Symbol, site: Symbol): Option[DocResult] = { val sig = ask { () => externalSignature(sym) } findExternalLink(sym, sig) map { link => UrlResult(link.url) } orElse { diff --git a/src/compiler/scala/tools/nsc/interactive/Global.scala b/src/compiler/scala/tools/nsc/interactive/Global.scala index 0fc4fcaaf7..4ab7b98b3d 100644 --- a/src/compiler/scala/tools/nsc/interactive/Global.scala +++ b/src/compiler/scala/tools/nsc/interactive/Global.scala @@ -56,7 +56,6 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "") import log.logreplay debugLog("logger: " + log.getClass + " writing to " + (new java.io.File(logName)).getAbsolutePath) debugLog("classpath: "+classPath) - Console.err.println("\n ======= CHECK THREAD ACCESS compiler build ========\n") private var curTime = System.nanoTime private def timeStep = { diff --git a/src/compiler/scala/tools/nsc/interpreter/TypeStrings.scala b/src/compiler/scala/tools/nsc/interpreter/TypeStrings.scala index 6abb52a649..60399f53bf 100644 --- a/src/compiler/scala/tools/nsc/interpreter/TypeStrings.scala +++ b/src/compiler/scala/tools/nsc/interpreter/TypeStrings.scala @@ -212,7 +212,11 @@ trait TypeStrings { } private def tparamString[T: ru.TypeTag] : String = { - def typeArguments: List[ru.Type] = ru.typeOf[T] match { case ru.TypeRef(_, _, args) => args; case _ => Nil } + def typeArguments: List[ru.Type] = { + import ru.TypeRefTag // otherwise the pattern match will be unchecked + // because TypeRef is an abstract type + ru.typeOf[T] match { case ru.TypeRef(_, _, args) => args; case _ => Nil } + } // [Eugene to Paul] need to use not the `rootMirror`, but a mirror with the REPL's classloader // how do I get to it? acquiring context classloader seems unreliable because of multithreading def typeVariables: List[java.lang.Class[_]] = typeArguments map (targ => ru.rootMirror.runtimeClass(targ)) diff --git a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala index ae3b0bc0b7..4268398081 100644 --- a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala +++ b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala @@ -980,7 +980,7 @@ trait ContextErrors { object SymValidateErrors extends Enumeration { val ImplicitConstr, ImplicitNotTermOrClass, ImplicitAtToplevel, OverrideClass, SealedNonClass, AbstractNonClass, - OverrideConstr, AbstractOverride, LazyAndEarlyInit, + OverrideConstr, AbstractOverride, AbstractOverrideOnTypeMember, LazyAndEarlyInit, ByNameParameter, AbstractVar = Value } @@ -1079,6 +1079,9 @@ trait ContextErrors { case AbstractOverride => "`abstract override' modifier only allowed for members of traits" + case AbstractOverrideOnTypeMember => + "`abstract override' modifier not allowed for type members" + case LazyAndEarlyInit => "`lazy' definitions may not be initialized early" diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala index ad01de9447..70a736c91f 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala @@ -946,8 +946,8 @@ trait Implicits { * - for alias types and abstract types, we take instead the parts * - of their upper bounds. * @return For those parts that refer to classes with companion objects that - * can be accessed with unambiguous stable prefixes, the implicits infos - * which are members of these companion objects. + * can be accessed with unambiguous stable prefixes that are not existentially + * bound, the implicits infos which are members of these companion objects. */ private def companionImplicitMap(tp: Type): InfoMap = { @@ -963,7 +963,7 @@ trait Implicits { infoMap(sym) = List() // ambiguous prefix - ignore implicit members } case None => - if (pre.isStable) { + if (pre.isStable && !pre.typeSymbol.isExistentiallyBound) { val companion = companionSymbolOf(sym, context) companion.moduleClass match { case mc: ModuleClassSymbol => diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala index 3f546c9a51..98b6264051 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala @@ -1443,8 +1443,12 @@ trait Namers extends MethodSynthesis { if (sym.isConstructor && sym.isAnyOverride) fail(OverrideConstr) - if (sym.isAbstractOverride && !sym.owner.isTrait) - fail(AbstractOverride) + if (sym.isAbstractOverride) { + if (!sym.owner.isTrait) + fail(AbstractOverride) + if(sym.isType) + fail(AbstractOverrideOnTypeMember) + } if (sym.isLazy && sym.hasFlag(PRESUPER)) fail(LazyAndEarlyInit) if (sym.info.typeSymbol == FunctionClass(0) && sym.isValueParameter && sym.owner.isCaseClass) diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala index 3e1d3fdcc4..9bd3aa8fe5 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -1536,8 +1536,14 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans sym.name == nme.apply && isClassTypeAccessible(tree) - if (doTransform) + if (doTransform) { + tree foreach { + case i@Ident(_) => + enterReference(i.pos, i.symbol) // SI-5390 need to `enterReference` for `a` in `a.B()` + case _ => + } toConstructor(tree.pos, tree.tpe) + } else { ifNot tree diff --git a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala index 17e67e6429..a907ab6c66 100644 --- a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala +++ b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala @@ -157,11 +157,23 @@ trait SyntheticMethods extends ast.TreeDSL { Ident(m.firstParam) IS_OBJ classExistentialType(clazz)) } - /** (that.isInstanceOf[this.C]) - * where that is the given methods first parameter. + /** that match { case _: this.C => true ; case _ => false } + * where `that` is the given method's first parameter. + * + * An isInstanceOf test is insufficient because it has weaker + * requirements than a pattern match. Given an inner class Foo and + * two different instantiations of the container, an x.Foo and and a y.Foo + * are both .isInstanceOf[Foo], but the one does not match as the other. */ - def thatTest(eqmeth: Symbol): Tree = - gen.mkIsInstanceOf(Ident(eqmeth.firstParam), classExistentialType(clazz), true, false) + def thatTest(eqmeth: Symbol): Tree = { + Match( + Ident(eqmeth.firstParam), + List( + CaseDef(Typed(Ident(nme.WILDCARD), TypeTree(clazz.tpe)), EmptyTree, TRUE), + CaseDef(WILD.empty, EmptyTree, FALSE) + ) + ) + } /** (that.asInstanceOf[this.C]) * where that is the given methods first parameter. diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index f8adcaa25b..9d390476db 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -3497,12 +3497,13 @@ trait Typers extends Modes with Adaptations with Tags { // println(util.Position.formatMessage(uncheckedPattern.pos, "made unchecked type test into a checked one", true)) val args = List(uncheckedPattern) + val app = atPos(uncheckedPattern.pos)(Apply(classTagExtractor, args)) // must call doTypedUnapply directly, as otherwise we get undesirable rewrites // and re-typechecks of the target of the unapply call in PATTERNmode, // this breaks down when the classTagExtractor (which defineds the unapply member) is not a simple reference to an object, // but an arbitrary tree as is the case here - doTypedUnapply(Apply(classTagExtractor, args), classTagExtractor, classTagExtractor, args, PATTERNmode, pt) - } + doTypedUnapply(app, classTagExtractor, classTagExtractor, args, PATTERNmode, pt) + } // if there's a ClassTag that allows us to turn the unchecked type test for `pt` into a checked type test // return the corresponding extractor (an instance of ClassTag[`pt`]) @@ -4646,12 +4647,11 @@ trait Typers extends Modes with Adaptations with Tags { // [Eugene] no more MaxArrayDims. ClassTags are flexible enough to allow creation of arrays of arbitrary dimensionality (w.r.t JVM restrictions) val Some((level, componentType)) = erasure.GenericArray.unapply(tpt.tpe) val tagType = List.iterate(componentType, level)(tpe => appliedType(ArrayClass.toTypeConstructor, List(tpe))).last - val newArrayApp = atPos(tree.pos) { + atPos(tree.pos) { val tag = resolveClassTag(tree.pos, tagType) if (tag.isEmpty) MissingClassTagError(tree, tagType) - else new ApplyToImplicitArgs(Select(tag, nme.newArray), args) + else typed(new ApplyToImplicitArgs(Select(tag, nme.newArray), args)) } - typed(newArrayApp, mode, pt) case Apply(Select(fun, nme.apply), _) if treeInfo.isSuperConstrCall(fun) => //SI-5696 TooManyArgumentListsForConstructor(tree) case tree1 => @@ -5264,7 +5264,7 @@ trait Typers extends Modes with Adaptations with Tags { def typedDocDef(docdef: DocDef) = { if (forScaladoc && (sym ne null) && (sym ne NoSymbol)) { - val comment = docdef.comment + val comment = docdef.comment docComments(sym) = comment comment.defineVariables(sym) val typer1 = newTyper(context.makeNewScope(tree, context.owner)) @@ -5595,12 +5595,18 @@ trait Typers extends Modes with Adaptations with Tags { "context.owner" -> context.owner ) ) - val tree1 = typed1(tree, mode, dropExistential(pt)) + typed1(tree, mode, dropExistential(pt)) + } + // Can happen during erroneous compilation - error(s) have been + // reported, but we need to avoid causing an NPE with this tree + if (tree1.tpe eq null) + return setError(tree) + + if (!alreadyTyped) { printTyping("typed %s: %s%s".format( ptTree(tree1), tree1.tpe, if (isSingleType(tree1.tpe)) " with underlying "+tree1.tpe.widen else "") ) - tree1 } tree1.tpe = addAnnotations(tree1, tree1.tpe) diff --git a/src/compiler/scala/tools/nsc/util/ClassPath.scala b/src/compiler/scala/tools/nsc/util/ClassPath.scala index 8732e06502..471e2653cf 100644 --- a/src/compiler/scala/tools/nsc/util/ClassPath.scala +++ b/src/compiler/scala/tools/nsc/util/ClassPath.scala @@ -15,6 +15,7 @@ import scala.reflect.ClassTag import Jar.isJarOrZip import File.pathSeparator import java.net.MalformedURLException +import java.util.regex.PatternSyntaxException /** <p> * This module provides star expansion of '-classpath' option arguments, behaves the same as @@ -39,8 +40,11 @@ object ClassPath { if (pattern == "*") lsDir(Directory(".")) else if (pattern endsWith wildSuffix) lsDir(Directory(pattern dropRight 2)) else if (pattern contains '*') { - val regexp = ("^%s$" format pattern.replaceAll("""\*""", """.*""")).r - lsDir(Directory(pattern).parent, regexp findFirstIn _ isDefined) + try { + val regexp = ("^" + pattern.replaceAllLiterally("""\*""", """.*""") + "$").r + lsDir(Directory(pattern).parent, regexp findFirstIn _ isDefined) + } + catch { case _: PatternSyntaxException => List(pattern) } } else List(pattern) } diff --git a/src/library/scala/collection/Iterator.scala b/src/library/scala/collection/Iterator.scala index cbf8cc4931..696bc4ab5c 100644 --- a/src/library/scala/collection/Iterator.scala +++ b/src/library/scala/collection/Iterator.scala @@ -1111,9 +1111,10 @@ trait Iterator[+A] extends TraversableOnce[A] { * $willNotTerminateInf */ def copyToArray[B >: A](xs: Array[B], start: Int, len: Int): Unit = { + require(start >= 0 && start < xs.length, s"start $start out of range ${xs.length}") var i = start - val end = start + math.min(len, xs.length) - while (hasNext && i < end) { + val end = start + math.min(len, xs.length - start) + while (i < end && hasNext) { xs(i) = next() i += 1 } diff --git a/src/library/scala/collection/LinearSeqOptimized.scala b/src/library/scala/collection/LinearSeqOptimized.scala index 0f0a405a85..81cccea519 100755 --- a/src/library/scala/collection/LinearSeqOptimized.scala +++ b/src/library/scala/collection/LinearSeqOptimized.scala @@ -12,6 +12,7 @@ import generic._ import mutable.ListBuffer import immutable.List import scala.util.control.Breaks._ +import scala.annotation.tailrec /** A template trait for linear sequences of type `LinearSeq[A]` which optimizes * the implementation of several methods under the assumption of fast linear access. @@ -247,14 +248,17 @@ trait LinearSeqOptimized[+A, +Repr <: LinearSeqOptimized[A, Repr]] extends Linea } override /*SeqLike*/ - def lengthCompare(len: Int): Int = { - var i = 0 - var these = self - while (!these.isEmpty && i <= len) { - i += 1 - these = these.tail + def lengthCompare(len: Int): Int = { + @tailrec def loop(i: Int, xs: Repr): Int = { + if (i == len) + if (xs.isEmpty) 0 else 1 + else if (xs.isEmpty) + -1 + else + loop(i + 1, xs.tail) } - i - len + if (len < 0) 1 + else loop(0, this) } override /*SeqLike*/ diff --git a/src/library/scala/collection/SeqLike.scala b/src/library/scala/collection/SeqLike.scala index f65e2ef9cd..1be0dba29f 100644 --- a/src/library/scala/collection/SeqLike.scala +++ b/src/library/scala/collection/SeqLike.scala @@ -84,13 +84,17 @@ trait SeqLike[+A, +Repr] extends Any with IterableLike[A, Repr] with GenSeqLike[ * if computing `length` is cheap. */ def lengthCompare(len: Int): Int = { - var i = 0 - val it = iterator - while (it.hasNext && i <= len) { - it.next() - i += 1 + if (len < 0) 1 + else { + var i = 0 + val it = iterator + while (it.hasNext) { + if (i == len) return if (it.hasNext) 1 else 0 + it.next() + i += 1 + } + i - len } - i - len } override /*IterableLike*/ def isEmpty: Boolean = lengthCompare(0) == 0 diff --git a/src/library/scala/collection/immutable/Stream.scala b/src/library/scala/collection/immutable/Stream.scala index be2cd91c68..1c461973e4 100644 --- a/src/library/scala/collection/immutable/Stream.scala +++ b/src/library/scala/collection/immutable/Stream.scala @@ -625,7 +625,7 @@ self => * * @example {{{ * $naturalsEx - * naturalsFrom(1) zip naturalsFrom(2) zip take 5 foreach println + * naturalsFrom(1) zip naturalsFrom(2) take 5 foreach println * // prints * // (1,2) * // (2,3) diff --git a/src/library/scala/collection/mutable/ArrayOps.scala b/src/library/scala/collection/mutable/ArrayOps.scala index bb938a7aeb..6b778b26f5 100644 --- a/src/library/scala/collection/mutable/ArrayOps.scala +++ b/src/library/scala/collection/mutable/ArrayOps.scala @@ -52,6 +52,20 @@ trait ArrayOps[T] extends Any with ArrayLike[T, Array[T]] with CustomParalleliza super.toArray[U] } + def :+[B >: T: scala.reflect.ClassTag](elem: B): Array[B] = { + val result = Array.ofDim[B](repr.length + 1) + Array.copy(repr, 0, result, 0, repr.length) + result(repr.length) = elem + result + } + + def +:[B >: T: scala.reflect.ClassTag](elem: B): Array[B] = { + val result = Array.ofDim[B](repr.length + 1) + result(0) = elem + Array.copy(repr, 0, result, 1, repr.length) + result + } + override def par = ParArray.handoff(repr) /** Flattens a two-dimensional array by concatenating all its rows diff --git a/src/library/scala/collection/mutable/WrappedArray.scala b/src/library/scala/collection/mutable/WrappedArray.scala index f02f5a241f..b83724090c 100644 --- a/src/library/scala/collection/mutable/WrappedArray.scala +++ b/src/library/scala/collection/mutable/WrappedArray.scala @@ -62,7 +62,7 @@ extends AbstractSeq[T] override def par = ParArray.handoff(array) private def elementClass: Class[_] = - arrayElementClass(repr.getClass) + arrayElementClass(array.getClass) override def toArray[U >: T : ClassTag]: Array[U] = { val thatElementClass = arrayElementClass(implicitly[ClassTag[U]]) diff --git a/src/library/scala/reflect/Manifest.scala b/src/library/scala/reflect/Manifest.scala index eddfe63118..f62d0ecd16 100644 --- a/src/library/scala/reflect/Manifest.scala +++ b/src/library/scala/reflect/Manifest.scala @@ -162,11 +162,13 @@ object ManifestFactory { private val NullTYPE = classOf[scala.runtime.Null$] val Any: Manifest[scala.Any] = new PhantomManifest[scala.Any](ObjectTYPE, "Any") { + override def newArray(len: Int) = new Array[scala.Any](len) override def <:<(that: ClassManifest[_]): Boolean = (that eq this) private def readResolve(): Any = Manifest.Any } val Object: Manifest[java.lang.Object] = new PhantomManifest[java.lang.Object](ObjectTYPE, "Object") { + override def newArray(len: Int) = new Array[java.lang.Object](len) override def <:<(that: ClassManifest[_]): Boolean = (that eq this) || (that eq Any) private def readResolve(): Any = Manifest.Object } @@ -174,17 +176,20 @@ object ManifestFactory { val AnyRef: Manifest[scala.AnyRef] = Object.asInstanceOf[Manifest[scala.AnyRef]] val AnyVal: Manifest[scala.AnyVal] = new PhantomManifest[scala.AnyVal](ObjectTYPE, "AnyVal") { + override def newArray(len: Int) = new Array[scala.AnyVal](len) override def <:<(that: ClassManifest[_]): Boolean = (that eq this) || (that eq Any) private def readResolve(): Any = Manifest.AnyVal } val Null: Manifest[scala.Null] = new PhantomManifest[scala.Null](NullTYPE, "Null") { + override def newArray(len: Int) = new Array[scala.Null](len) override def <:<(that: ClassManifest[_]): Boolean = (that ne null) && (that ne Nothing) && !(that <:< AnyVal) private def readResolve(): Any = Manifest.Null } val Nothing: Manifest[scala.Nothing] = new PhantomManifest[scala.Nothing](NothingTYPE, "Nothing") { + override def newArray(len: Int) = new Array[scala.Nothing](len) override def <:<(that: ClassManifest[_]): Boolean = (that ne null) private def readResolve(): Any = Manifest.Nothing } diff --git a/src/library/scala/util/Properties.scala b/src/library/scala/util/Properties.scala index fd1364c2dc..cc145134c4 100644 --- a/src/library/scala/util/Properties.scala +++ b/src/library/scala/util/Properties.scala @@ -102,7 +102,7 @@ private[scala] trait PropertiesTrait { * or "version (unknown)" if it cannot be determined. */ val versionString = "version " + scalaPropOrElse("version.number", "(unknown)") - val copyrightString = scalaPropOrElse("copyright.string", "(c) 2002-2011 LAMP/EPFL") + val copyrightString = scalaPropOrElse("copyright.string", "Copyright 2002-2013, LAMP/EPFL") /** This is the encoding to use reading in source files, overridden with -encoding * Note that it uses "prop" i.e. looks in the scala jar, not the system properties. diff --git a/src/partest/scala/tools/partest/PartestDefaults.scala b/src/partest/scala/tools/partest/PartestDefaults.scala index b27ce6ff75..a21c602d14 100644 --- a/src/partest/scala/tools/partest/PartestDefaults.scala +++ b/src/partest/scala/tools/partest/PartestDefaults.scala @@ -21,7 +21,7 @@ object PartestDefaults { def javaCmd = propOrElse("partest.javacmd", "java") def javacCmd = propOrElse("partest.javac_cmd", "javac") def javaOpts = propOrElse("partest.java_opts", "") - def scalacOpts = propOrElse("partest.scalac_opts", "-deprecation") + def scalacOpts = propOrElse("partest.scalac_opts", "") def testBuild = propOrNone("partest.build") def errorCount = propOrElse("partest.errors", "0").toInt diff --git a/src/partest/scala/tools/partest/nest/CompileManager.scala b/src/partest/scala/tools/partest/nest/CompileManager.scala index 188ebf66ed..3d902d6d00 100644 --- a/src/partest/scala/tools/partest/nest/CompileManager.scala +++ b/src/partest/scala/tools/partest/nest/CompileManager.scala @@ -41,7 +41,6 @@ class ExtConsoleReporter(settings: Settings, val writer: PrintWriter) extends Co class TestSettings(cp: String, error: String => Unit) extends Settings(error) { def this(cp: String) = this(cp, _ => ()) - deprecation.value = true nowarnings.value = false encoding.value = "UTF-8" classpath.value = cp diff --git a/src/reflect/scala/reflect/internal/Flags.scala b/src/reflect/scala/reflect/internal/Flags.scala index 30dd9c3e49..a0362c8921 100644 --- a/src/reflect/scala/reflect/internal/Flags.scala +++ b/src/reflect/scala/reflect/internal/Flags.scala @@ -262,7 +262,7 @@ class Flags extends ModifierFlags { * Getters of immutable values also get STABLE. */ final val GetterFlags = ~(PRESUPER | MUTABLE) - final val SetterFlags = ~(PRESUPER | MUTABLE | STABLE | CASEACCESSOR) + final val SetterFlags = ~(PRESUPER | MUTABLE | STABLE | CASEACCESSOR | IMPLICIT) /** When a symbol for a default getter is created, it inherits these * flags from the method with the default. Other flags applied at creation diff --git a/src/reflect/scala/reflect/internal/Trees.scala b/src/reflect/scala/reflect/internal/Trees.scala index dceec18e57..431afd286d 100644 --- a/src/reflect/scala/reflect/internal/Trees.scala +++ b/src/reflect/scala/reflect/internal/Trees.scala @@ -811,7 +811,7 @@ trait Trees extends api.Trees { self: SymbolTable => } def Annotated(tree: Tree, annot: Tree, arg: Tree) = tree match { case t @ Annotated(annot0, arg0) - if (annot0==annot) => t + if (annot0==annot && arg0==arg) => t case _ => treeCopy.Annotated(tree, annot, arg) } def SingletonTypeTree(tree: Tree, ref: Tree) = tree match { diff --git a/src/reflect/scala/reflect/internal/Types.scala b/src/reflect/scala/reflect/internal/Types.scala index 119a57d268..bfd18f6a43 100644 --- a/src/reflect/scala/reflect/internal/Types.scala +++ b/src/reflect/scala/reflect/internal/Types.scala @@ -6801,7 +6801,10 @@ trait Types extends api.Types { self: SymbolTable => else lubBase } } - existentialAbstraction(tparams, lubType) + // dropRepeatedParamType is a localized fix for SI-6897. We should probably + // integrate that transformation at a lower level in master, but lubs are + // the likely and maybe only spot they escape, so fixing here for 2.10.1. + existentialAbstraction(tparams, dropRepeatedParamType(lubType)) } if (printLubs) { println(indent + "lub of " + ts + " at depth "+depth)//debug diff --git a/src/reflect/scala/reflect/runtime/JavaMirrors.scala b/src/reflect/scala/reflect/runtime/JavaMirrors.scala index d110bd4273..01e0634902 100644 --- a/src/reflect/scala/reflect/runtime/JavaMirrors.scala +++ b/src/reflect/scala/reflect/runtime/JavaMirrors.scala @@ -574,7 +574,7 @@ private[reflect] trait JavaMirrors extends internal.SymbolTable with api.JavaUni case None => // class does not have a Scala signature; it's a Java class info("translating reflection info for Java " + jclazz) //debug - initClassModule(clazz, module, new FromJavaClassCompleter(clazz, module, jclazz)) + initClassAndModule(clazz, module, new FromJavaClassCompleter(clazz, module, jclazz)) } } } catch { @@ -676,9 +676,9 @@ private[reflect] trait JavaMirrors extends internal.SymbolTable with api.JavaUni def enter(sym: Symbol, mods: Int) = (if (jModifier.isStatic(mods)) module.moduleClass else clazz).info.decls enter sym - for (jinner <- jclazz.getDeclaredClasses) { - enter(jclassAsScala(jinner, clazz), jinner.getModifiers) - } + for (jinner <- jclazz.getDeclaredClasses) + jclassAsScala(jinner) // inner class is entered as a side-effect + // no need to call enter explicitly pendingLoadActions = { () => @@ -1036,14 +1036,14 @@ private[reflect] trait JavaMirrors extends internal.SymbolTable with api.JavaUni * @param jclazz The Java class * @return A Scala class symbol that wraps all reflection info of `jclazz` */ - private def jclassAsScala(jclazz: jClass[_]): Symbol = jclassAsScala(jclazz, sOwner(jclazz)) + private def jclassAsScala(jclazz: jClass[_]): ClassSymbol = + toScala(classCache, jclazz)(_ jclassAsScala1 _) - private def jclassAsScala(jclazz: jClass[_], owner: Symbol): ClassSymbol = { + private def jclassAsScala1(jclazz: jClass[_]): ClassSymbol = { + val owner = sOwner(jclazz) val name = scalaSimpleName(jclazz) val completer = (clazz: Symbol, module: Symbol) => new FromJavaClassCompleter(clazz, module, jclazz) - val (clazz, module) = createClassModule(owner, name, completer) - classCache enter (jclazz, clazz) - clazz + initAndEnterClassAndModule(owner, name, completer)._1 } /** diff --git a/src/reflect/scala/reflect/runtime/SymbolLoaders.scala b/src/reflect/scala/reflect/runtime/SymbolLoaders.scala index 61663f6181..311db64b91 100644 --- a/src/reflect/scala/reflect/runtime/SymbolLoaders.scala +++ b/src/reflect/scala/reflect/runtime/SymbolLoaders.scala @@ -57,7 +57,7 @@ private[reflect] trait SymbolLoaders { self: SymbolTable => * @param name The simple name of the newly created class * @param completer The completer to be used to set the info of the class and the module */ - protected def createClassModule(owner: Symbol, name: TypeName, completer: (Symbol, Symbol) => LazyType) = { + protected def initAndEnterClassAndModule(owner: Symbol, name: TypeName, completer: (Symbol, Symbol) => LazyType) = { assert(!(name.toString endsWith "[]"), name) val clazz = owner.newClass(name) val module = owner.newModule(name.toTermName) @@ -67,7 +67,7 @@ private[reflect] trait SymbolLoaders { self: SymbolTable => owner.info.decls enter clazz owner.info.decls enter module } - initClassModule(clazz, module, completer(clazz, module)) + initClassAndModule(clazz, module, completer(clazz, module)) (clazz, module) } @@ -75,7 +75,7 @@ private[reflect] trait SymbolLoaders { self: SymbolTable => List(clazz, module, module.moduleClass) foreach (_ setInfo info) } - protected def initClassModule(clazz: Symbol, module: Symbol, completer: LazyType) = + protected def initClassAndModule(clazz: Symbol, module: Symbol, completer: LazyType) = setAllInfos(clazz, module, completer) /** The type completer for packages. @@ -118,7 +118,7 @@ private[reflect] trait SymbolLoaders { self: SymbolTable => val loadingMirror = currentMirror.mirrorDefining(cls) val (clazz, module) = if (loadingMirror eq currentMirror) { - createClassModule(pkgClass, name.toTypeName, new TopClassCompleter(_, _)) + initAndEnterClassAndModule(pkgClass, name.toTypeName, new TopClassCompleter(_, _)) } else { val origOwner = loadingMirror.packageNameToScala(pkgClass.fullName) val clazz = origOwner.info decl name.toTypeName diff --git a/test/files/lib/javac-artifacts.jar.desired.sha1 b/test/files/lib/javac-artifacts.jar.desired.sha1 index 8dbbc1d451..a49c986386 100644 --- a/test/files/lib/javac-artifacts.jar.desired.sha1 +++ b/test/files/lib/javac-artifacts.jar.desired.sha1 @@ -1 +1 @@ -c5788c5e518eb267445c5a995fd98b2210f90a58 ?javac-artifacts.jar +61931a51bb1a2d308d214b96d06e9a8808515dcf ?javac-artifacts.jar diff --git a/test/files/neg/classmanifests_new_deprecations.flags b/test/files/neg/classmanifests_new_deprecations.flags index e8fb65d50c..c6bfaf1f64 100644 --- a/test/files/neg/classmanifests_new_deprecations.flags +++ b/test/files/neg/classmanifests_new_deprecations.flags @@ -1 +1 @@ --Xfatal-warnings
\ No newline at end of file +-deprecation -Xfatal-warnings diff --git a/test/files/neg/for-comprehension-old.flags b/test/files/neg/for-comprehension-old.flags new file mode 100644 index 0000000000..dcc59ebe32 --- /dev/null +++ b/test/files/neg/for-comprehension-old.flags @@ -0,0 +1 @@ +-deprecation diff --git a/test/files/neg/macro-deprecate-idents.flags b/test/files/neg/macro-deprecate-idents.flags index e8fb65d50c..c6bfaf1f64 100644 --- a/test/files/neg/macro-deprecate-idents.flags +++ b/test/files/neg/macro-deprecate-idents.flags @@ -1 +1 @@ --Xfatal-warnings
\ No newline at end of file +-deprecation -Xfatal-warnings diff --git a/test/files/neg/macro-invalidshape-d.flags b/test/files/neg/macro-invalidshape-d.flags index cd66464f2f..83b7265eb9 100644 --- a/test/files/neg/macro-invalidshape-d.flags +++ b/test/files/neg/macro-invalidshape-d.flags @@ -1 +1 @@ --language:experimental.macros
\ No newline at end of file +-deprecation -language:experimental.macros diff --git a/test/files/neg/names-defaults-neg.flags b/test/files/neg/names-defaults-neg.flags new file mode 100644 index 0000000000..dcc59ebe32 --- /dev/null +++ b/test/files/neg/names-defaults-neg.flags @@ -0,0 +1 @@ +-deprecation diff --git a/test/files/neg/t3995.check b/test/files/neg/t3995.check new file mode 100644 index 0000000000..00ecf4ca5b --- /dev/null +++ b/test/files/neg/t3995.check @@ -0,0 +1,6 @@ +t3995.scala:31: error: type mismatch; + found : String("") + required: _1.F0 where val _1: Lift + (new Lift).apply("") + ^ +one error found diff --git a/test/files/neg/t3995.scala b/test/files/neg/t3995.scala new file mode 100644 index 0000000000..b03617ac86 --- /dev/null +++ b/test/files/neg/t3995.scala @@ -0,0 +1,32 @@ +class Lift { + def apply(f: F0) {} + + class F0 + object F0 { + implicit def f2f0(fn: String): F0 = ??? + } +} + +object Test { + val l = new Lift + val f = "" + + "": l.F0 // okay + + l.apply("") // okay + + { + val l = new Lift + l.apply("") // okay + } + + // fails trying to mkAttributedQualifier for pre = Skolem(_1 <: Lift with Singletom).F0 + // should this even have shown up in `companionImplicitMap`? It says that: + // + // "@return For those parts that refer to classes with companion objects that + // can be accessed with unambiguous stable prefixes, the implicits infos + // which are members of these companion objects." + // + // The skolem is stable, but it doen't seem much good to us + (new Lift).apply("") +} diff --git a/test/files/neg/t5390.check b/test/files/neg/t5390.check new file mode 100644 index 0000000000..6a0129b898 --- /dev/null +++ b/test/files/neg/t5390.check @@ -0,0 +1,4 @@ +t5390.scala:7: error: forward reference extends over definition of value b + val b = a.B("") + ^ +one error found diff --git a/test/files/neg/t5390.scala b/test/files/neg/t5390.scala new file mode 100644 index 0000000000..dd628f8851 --- /dev/null +++ b/test/files/neg/t5390.scala @@ -0,0 +1,10 @@ +class A { + object B { def apply(s: String) = 0} +} + +object X { + def foo { + val b = a.B("") + val a = new A + } +}
\ No newline at end of file diff --git a/test/files/neg/t5390b.check b/test/files/neg/t5390b.check new file mode 100644 index 0000000000..cbf8fafa6b --- /dev/null +++ b/test/files/neg/t5390b.check @@ -0,0 +1,4 @@ +t5390b.scala:7: error: forward reference extends over definition of value b + val b = a.B("") + ^ +one error found diff --git a/test/files/neg/t5390b.scala b/test/files/neg/t5390b.scala new file mode 100644 index 0000000000..c3373b87d3 --- /dev/null +++ b/test/files/neg/t5390b.scala @@ -0,0 +1,10 @@ +class A { + case class B(s: String) +} + +object X { + def foo { + val b = a.B("") + val a = new A + } +}
\ No newline at end of file diff --git a/test/files/neg/t5390c.check b/test/files/neg/t5390c.check new file mode 100644 index 0000000000..f8a794d690 --- /dev/null +++ b/test/files/neg/t5390c.check @@ -0,0 +1,4 @@ +t5390c.scala:7: error: forward reference extends over definition of value b + val b = new a.B("") + ^ +one error found diff --git a/test/files/neg/t5390c.scala b/test/files/neg/t5390c.scala new file mode 100644 index 0000000000..6b11576611 --- /dev/null +++ b/test/files/neg/t5390c.scala @@ -0,0 +1,10 @@ +class A { + case class B(s: String) +} + +object X { + def foo { + val b = new a.B("") + val a = new A + } +}
\ No newline at end of file diff --git a/test/files/neg/t5390d.check b/test/files/neg/t5390d.check new file mode 100644 index 0000000000..daa29142e7 --- /dev/null +++ b/test/files/neg/t5390d.check @@ -0,0 +1,4 @@ +t5390d.scala:7: error: forward reference extends over definition of value b + val b = a.B.toString + ^ +one error found diff --git a/test/files/neg/t5390d.scala b/test/files/neg/t5390d.scala new file mode 100644 index 0000000000..7a2671b443 --- /dev/null +++ b/test/files/neg/t5390d.scala @@ -0,0 +1,10 @@ +class A { + case class B(s: String) +} + +object X { + def foo { + val b = a.B.toString + val a = new A + } +}
\ No newline at end of file diff --git a/test/files/neg/t5589neg.flags b/test/files/neg/t5589neg.flags new file mode 100644 index 0000000000..dcc59ebe32 --- /dev/null +++ b/test/files/neg/t5589neg.flags @@ -0,0 +1 @@ +-deprecation diff --git a/test/files/neg/t5956.flags b/test/files/neg/t5956.flags new file mode 100644 index 0000000000..dcc59ebe32 --- /dev/null +++ b/test/files/neg/t5956.flags @@ -0,0 +1 @@ +-deprecation diff --git a/test/files/neg/t6788.check b/test/files/neg/t6788.check new file mode 100644 index 0000000000..96a6f8b601 --- /dev/null +++ b/test/files/neg/t6788.check @@ -0,0 +1,5 @@ +t6788.scala:6: error: not found: value foo +Error occurred in an application involving default arguments. + s.copy(b = foo) + ^ +one error found diff --git a/test/files/neg/t6788.scala b/test/files/neg/t6788.scala new file mode 100644 index 0000000000..77949ed621 --- /dev/null +++ b/test/files/neg/t6788.scala @@ -0,0 +1,7 @@ +case class B[T](b: T, a: List[Int]) // need two args, B must be polymorphic + +class A { + var s: B[Int] = _ // has to be a var + + s.copy(b = foo) +} diff --git a/test/files/neg/t6795.check b/test/files/neg/t6795.check new file mode 100644 index 0000000000..88ef3e9a52 --- /dev/null +++ b/test/files/neg/t6795.check @@ -0,0 +1,4 @@ +t6795.scala:3: error: `abstract override' modifier not allowed for type members +trait T1 extends T { abstract override type U = Int } + ^ +one error found diff --git a/test/files/neg/t6795.scala b/test/files/neg/t6795.scala new file mode 100644 index 0000000000..a523c89c82 --- /dev/null +++ b/test/files/neg/t6795.scala @@ -0,0 +1,3 @@ +trait T { type U } +// "abstract override" shouldn't be allowed on types +trait T1 extends T { abstract override type U = Int } diff --git a/test/files/neg/t6829.check b/test/files/neg/t6829.check new file mode 100644 index 0000000000..8ee6d182eb --- /dev/null +++ b/test/files/neg/t6829.check @@ -0,0 +1,36 @@ +t6829.scala:35: error: type mismatch; + found : AgentSimulation.this.state.type (with underlying type G#State) + required: _10.State + lazy val actions: Map[G#Agent,G#Action] = agents.map(a => a -> a.chooseAction(state)).toMap + ^ +t6829.scala:45: error: trait AgentSimulation takes type parameters + pastHistory: List[G#State] = Nil) extends AgentSimulation + ^ +t6829.scala:47: error: class LearningSimulation takes type parameters + lazy val step: LearningSimulation = { + ^ +t6829.scala:49: error: not found: value actions + val (s,a,s2) = (state,actions(agent),nextState) + ^ +t6829.scala:49: error: not found: value nextState + val (s,a,s2) = (state,actions(agent),nextState) + ^ +t6829.scala:50: error: type mismatch; + found : s.type (with underlying type Any) + required: _54.State where val _54: G + val r = rewards(agent).r(s,a,s2) + ^ +t6829.scala:51: error: type mismatch; + found : s.type (with underlying type Any) + required: _51.State + agent.learn(s,a,s2,r): G#Agent + ^ +t6829.scala:53: error: not found: value nextState +Error occurred in an application involving default arguments. + copy(agents = updatedAgents, state = nextState, pastHistory = currentHistory) + ^ +t6829.scala:53: error: not found: value currentHistory +Error occurred in an application involving default arguments. + copy(agents = updatedAgents, state = nextState, pastHistory = currentHistory) + ^ +9 errors found diff --git a/test/files/neg/t6829.scala b/test/files/neg/t6829.scala new file mode 100644 index 0000000000..7cbe3c9542 --- /dev/null +++ b/test/files/neg/t6829.scala @@ -0,0 +1,64 @@ +package bugs + +/** + * Created with IntelliJ IDEA. + * User: arya + * Date: 12/18/12 + * Time: 4:17 PM + * To change this template use File | Settings | File Templates. + */ +object currenttype2 { + + type Reward = Double + + trait AbstractAgent[State,Action] { + type A = AbstractAgent[State,Action] + def chooseAction(s: State): Action + def startEpisode: A = this + def learn(s1: State, a: Action, s2: State, r: Reward): A + } + + case class RewardFunction[State,Action](r: (State,Action,State) => Reward) + + trait Rules[G<:GameDomain] { + def simulate(state: G#State, agentActions: List[(G#Agent,G#Action)]): G#State + } + + trait AgentSimulation[G<:GameDomain] { + val agents: List[G#Agent] + val state: G#State + val rewards: Map[G#Agent,G#Rewards] + val rules: Rules[G] + val pastHistory: List[G#State] + lazy val currentHistory = state :: pastHistory + + lazy val actions: Map[G#Agent,G#Action] = agents.map(a => a -> a.chooseAction(state)).toMap + lazy val nextState: G#State = rules.simulate(state, actions.toList) + + def step: AgentSimulation[G] + } + + case class LearningSimulation[G<:GameDomain](agents: List[G#Agent], + state: G#State, + rewards: Map[G#Agent,G#Rewards], + rules: Rules[G], + pastHistory: List[G#State] = Nil) extends AgentSimulation + { + lazy val step: LearningSimulation = { + val updatedAgents: List[G#Agent] = agents map { agent => + val (s,a,s2) = (state,actions(agent),nextState) + val r = rewards(agent).r(s,a,s2) + agent.learn(s,a,s2,r): G#Agent + } + copy(agents = updatedAgents, state = nextState, pastHistory = currentHistory) + } + } + + trait GameDomain { + domain => + type State + type Action + type Agent = AbstractAgent[State, Action] // agent supertype + type Rewards = RewardFunction[State,Action] + } + } diff --git a/test/files/pos/annotated-treecopy.check b/test/files/pos/annotated-treecopy.check new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/files/pos/annotated-treecopy.check diff --git a/test/files/pos/annotated-treecopy.flags b/test/files/pos/annotated-treecopy.flags new file mode 100644 index 0000000000..cd66464f2f --- /dev/null +++ b/test/files/pos/annotated-treecopy.flags @@ -0,0 +1 @@ +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/pos/annotated-treecopy/Impls_Macros_1.scala b/test/files/pos/annotated-treecopy/Impls_Macros_1.scala new file mode 100644 index 0000000000..d92fbca380 --- /dev/null +++ b/test/files/pos/annotated-treecopy/Impls_Macros_1.scala @@ -0,0 +1,53 @@ +import scala.language.experimental.macros +import scala.reflect.macros.Context +import collection.mutable.ListBuffer +import collection.mutable.Stack + +object Macros { + trait TypedFunction { + def tree: scala.reflect.runtime.universe.Tree + val typeIn: String + val typeOut: String + } + + def tree[T,U](f:Function1[T,U]): Function1[T,U] = macro tree_impl[T,U] + + def tree_impl[T:c.WeakTypeTag,U:c.WeakTypeTag](c: Context) + (f:c.Expr[Function1[T,U]]): c.Expr[Function1[T,U]] = { + import c.universe._ + val ttag = c.weakTypeTag[U] + f match { + case Expr(Function(List(ValDef(_,n,tp,_)),b)) => + // normalize argument name + var b1 = new Transformer { + override def transform(tree: Tree): Tree = tree match { + case Ident(x) if (x==n) => Ident(newTermName("_arg")) + case tt @ TypeTree() if tt.original != null => TypeTree(tt.tpe) setOriginal transform(tt.original) + // without the fix to LazyTreeCopier.Annotated, we would need to uncomment the line below to make the macro work + // that's because the pattern match in the input expression gets expanded into Typed(<x>, TypeTree(<Int @unchecked>)) + // with the original of the TypeTree being Annotated(<@unchecked>, Ident(<x>)) + // then the macro tries to replace all Ident(<x>) trees with Ident(<_arg>), recurs into the original of the TypeTree, changes it, + // but leaves the <@unchecked> part untouched. this signals the misguided LazyTreeCopier that the Annotated tree hasn't been modified, + // so the original tree should be copied over and returned => crash when later <x: @unchecked> re-emerges from TypeTree.original + // case Annotated(annot, arg) => treeCopy.Annotated(tree, transform(annot).duplicate, transform(arg)) + case _ => super.transform(tree) + } + }.transform(b) + + val reifiedTree = c.reifyTree(treeBuild.mkRuntimeUniverseRef, EmptyTree, b1) + val reifiedExpr = c.Expr[scala.reflect.runtime.universe.Expr[T => U]](reifiedTree) + val template = + c.universe.reify(new (T => U) with TypedFunction { + override def toString = c.literal(tp+" => "+ttag.tpe+" { "+b1.toString+" } ").splice // DEBUG + def tree = reifiedExpr.splice.tree + val typeIn = c.literal(tp.toString).splice + val typeOut = c.literal(ttag.tpe.toString).splice + def apply(_arg: T): U = c.Expr[U](b1)(ttag.asInstanceOf[c.WeakTypeTag[U]]).splice + }) + val untyped = c.resetLocalAttrs(template.tree) + + c.Expr[T => U](untyped) + case _ => sys.error("Bad function type") + } + } +}
\ No newline at end of file diff --git a/test/files/pos/annotated-treecopy/Test_2.scala b/test/files/pos/annotated-treecopy/Test_2.scala new file mode 100644 index 0000000000..836e0d888d --- /dev/null +++ b/test/files/pos/annotated-treecopy/Test_2.scala @@ -0,0 +1,5 @@ +object Test extends App { + import Macros._ + // tree { (x:((Int,Int,Int),(Int,Int,Int))) => { val y=x; val ((r1,m1,c1),(r2,m2,c2))=y; (r1, m1 + m2 + r1 * c1 * c2, c2) } } + tree { (x:((Int,Int,Int),(Int,Int,Int))) => { val ((r1,m1,c1),(r2,m2,c2))=x; (r1, m1 + m2 + r1 * c1 * c2, c2) } } +}
\ No newline at end of file diff --git a/test/files/pos/classtag-pos.flags b/test/files/pos/classtag-pos.flags new file mode 100644 index 0000000000..281f0a10cd --- /dev/null +++ b/test/files/pos/classtag-pos.flags @@ -0,0 +1 @@ +-Yrangepos diff --git a/test/files/pos/classtag-pos.scala b/test/files/pos/classtag-pos.scala new file mode 100644 index 0000000000..768d2e27f4 --- /dev/null +++ b/test/files/pos/classtag-pos.scala @@ -0,0 +1,5 @@ +import scala.reflect.runtime.universe._ + +class A { + def f[T: TypeTag] = typeOf[T] match { case TypeRef(_, _, args) => args } +} diff --git a/test/files/pos/setter-not-implicit.flags b/test/files/pos/setter-not-implicit.flags new file mode 100644 index 0000000000..792c40565b --- /dev/null +++ b/test/files/pos/setter-not-implicit.flags @@ -0,0 +1 @@ +-feature -Xfatal-warnings
\ No newline at end of file diff --git a/test/files/pos/setter-not-implicit.scala b/test/files/pos/setter-not-implicit.scala new file mode 100644 index 0000000000..9bfffc2ceb --- /dev/null +++ b/test/files/pos/setter-not-implicit.scala @@ -0,0 +1,3 @@ +object O { + implicit var x: Int = 0 +} diff --git a/test/files/pos/t5390.scala b/test/files/pos/t5390.scala new file mode 100644 index 0000000000..36febb6a58 --- /dev/null +++ b/test/files/pos/t5390.scala @@ -0,0 +1,11 @@ +class A { + case class B[A](s: String) +} + +object X { + def foo { + val a = new A + val b = new a.B[c.type]("") // not a forward reference + val c = "" + } +}
\ No newline at end of file diff --git a/test/files/pos/t6896.flags b/test/files/pos/t6896.flags new file mode 100644 index 0000000000..85d8eb2ba2 --- /dev/null +++ b/test/files/pos/t6896.flags @@ -0,0 +1 @@ +-Xfatal-warnings diff --git a/test/files/pos/t6896.scala b/test/files/pos/t6896.scala new file mode 100644 index 0000000000..ab527a804a --- /dev/null +++ b/test/files/pos/t6896.scala @@ -0,0 +1,7 @@ +object TooManyMains { + def main(args: Array[String]): Unit = { + println("Hello, World!") + } + def main(a: Int, b: Int) = ??? + def main(s: String, n: String) = ??? +} diff --git a/test/files/pos/t6897.scala b/test/files/pos/t6897.scala new file mode 100644 index 0000000000..a7a03a1d3a --- /dev/null +++ b/test/files/pos/t6897.scala @@ -0,0 +1,6 @@ +class A { + val html = (null: Any) match { + case 1 => <xml:group></xml:group> + case 2 => <p></p> + } +} diff --git a/test/files/run/array-addition.check b/test/files/run/array-addition.check new file mode 100644 index 0000000000..7bfbd9c711 --- /dev/null +++ b/test/files/run/array-addition.check @@ -0,0 +1,4 @@ +Array(1, 2, 3, 4) +Array(1, 2, 3, 4) +Array(1) +Array(1) diff --git a/test/files/run/array-addition.scala b/test/files/run/array-addition.scala new file mode 100644 index 0000000000..8def48e85c --- /dev/null +++ b/test/files/run/array-addition.scala @@ -0,0 +1,11 @@ +object Test { + def prettyPrintArray(x: Array[_]) = println("Array(" + x.mkString(", ") + ")") + + def main(args: Array[String]): Unit = { + prettyPrintArray(Array(1,2,3) :+ 4) + prettyPrintArray(1 +: Array(2,3,4)) + prettyPrintArray(Array() :+ 1) + prettyPrintArray(1 +: Array()) + } +} + diff --git a/test/files/run/idempotency-case-classes.check b/test/files/run/idempotency-case-classes.check index d2fb8169cb..700af3b81b 100644 --- a/test/files/run/idempotency-case-classes.check +++ b/test/files/run/idempotency-case-classes.check @@ -29,7 +29,10 @@ C(2,3) Statics.this.finalizeHash(acc, 2) }; override <synthetic> def toString(): String = ScalaRunTime.this._toString(C.this); - override <synthetic> def equals(x$1: Any): Boolean = C.this.eq(x$1.asInstanceOf[Object]).||(x$1.isInstanceOf[C].&&({ + override <synthetic> def equals(x$1: Any): Boolean = C.this.eq(x$1.asInstanceOf[Object]).||(x$1 match { + case (_: C) => true + case _ => false +}.&&({ <synthetic> val C$1: C = x$1.asInstanceOf[C]; C.this.x.==(C$1.x).&&(C.this.y.==(C$1.y)).&&(C$1.canEqual(C.this)) })) diff --git a/test/files/run/inline-ex-handlers.check b/test/files/run/inline-ex-handlers.check index 45db7c3a15..282542a732 100644 --- a/test/files/run/inline-ex-handlers.check +++ b/test/files/run/inline-ex-handlers.check @@ -13,15 +13,23 @@ < 92 JUMP 2 < < 2: -370c369 +247c246 +< blocks: [1,2,3,4,5,6,7,8,10,11,12,13,14,15,16,17,18] +--- +> blocks: [1,2,3,4,5,6,8,10,11,12,13,14,15,16,17,18] +258,260d256 +< 92 JUMP 7 +< +< 7: +395c391 < locals: value args, variable result, value ex6, value x4, value x5, value message, value x --- > locals: value args, variable result, value ex6, value x4, value x5, value x -372c371 +397c393 < blocks: [1,2,3,4,5,8,11,13,14,16] --- > blocks: [1,2,3,5,8,11,13,14,16,17] -396c395,404 +421c417,426 < 103 THROW(MyException) --- > ? STORE_LOCAL(value ex6) @@ -34,25 +42,25 @@ > 106 LOAD_LOCAL(value x4) > 106 IS_INSTANCE REF(class MyException) > 106 CZJUMP (BOOL)NE ? 5 : 11 -409,411d416 +434,436d438 < 101 JUMP 4 < < 4: -425,428d429 +450,453d451 < 106 LOAD_LOCAL(value x5) < 106 CALL_METHOD MyException.message (dynamic) < 106 STORE_LOCAL(value message) < 106 SCOPE_ENTER value message -430c431,432 +455c453,454 < 106 LOAD_LOCAL(value message) --- > ? LOAD_LOCAL(value x5) > 106 CALL_METHOD MyException.message (dynamic) -502c504 +527c526 < blocks: [1,2,3,4,6,7,8,9,10] --- > blocks: [1,2,3,4,6,7,8,9,10,11,12,13] -531c533,538 +556c555,560 < 306 THROW(MyException) --- > ? JUMP 11 @@ -61,11 +69,11 @@ > ? LOAD_LOCAL(variable monitor4) > 305 MONITOR_EXIT > ? JUMP 12 -537c544 +562c566 < ? THROW(Throwable) --- > ? JUMP 12 -543c550,557 +568c572,579 < ? THROW(Throwable) --- > ? STORE_LOCAL(value t) @@ -76,7 +84,7 @@ > 304 MONITOR_EXIT > ? STORE_LOCAL(value t) > ? JUMP 13 -558a573,584 +583a595,606 > 13: > 310 LOAD_MODULE object Predef > 310 CALL_PRIMITIVE(StartConcat) @@ -89,34 +97,35 @@ > 310 CALL_METHOD scala.Predef.println (dynamic) > 310 JUMP 2 > -567c593 +592c615 < catch (Throwable) in ArrayBuffer(7, 8, 9, 10) starting at: 6 --- > catch (Throwable) in ArrayBuffer(7, 8, 9, 10, 11) starting at: 6 -570c596 +595c618 < catch (Throwable) in ArrayBuffer(4, 6, 7, 8, 9, 10) starting at: 3 --- > catch (Throwable) in ArrayBuffer(4, 6, 7, 8, 9, 10, 11, 12) starting at: 3 -602c628 +627c650 < blocks: [1,2,3,4,5,6,7,9,10] --- > blocks: [1,2,3,4,5,6,7,9,10,11,12] -626c652,658 +651c674,675 < 78 THROW(IllegalArgumentException) --- > ? STORE_LOCAL(value e) > ? JUMP 11 -> +652a677,681 > 11: > 81 LOAD_LOCAL(value e) > ? STORE_LOCAL(variable exc1) > ? JUMP 12 -655c687,688 +> +680c709,710 < 81 THROW(Exception) --- > ? STORE_LOCAL(variable exc1) > ? JUMP 12 -671a705,717 +696a727,739 > 12: > 83 LOAD_MODULE object Predef > 83 CONSTANT("finally") @@ -130,19 +139,19 @@ > 84 LOAD_LOCAL(variable exc1) > 84 THROW(Throwable) > -677c723 +702c745 < catch (<none>) in ArrayBuffer(4, 6, 7, 9) starting at: 3 --- > catch (<none>) in ArrayBuffer(4, 6, 7, 9, 11) starting at: 3 -701c747 +726c769 < locals: value args, variable result, value ex6, variable exc2, value x4, value x5, value message, value x, value ex6, value x4, value x5, value message, value x --- > locals: value args, variable result, value ex6, variable exc2, value x4, value x5, value x, value ex6, value x4, value x5, value x -703c749 +728c771 < blocks: [1,2,3,4,5,6,9,12,14,17,18,19,22,25,27,28,30,31] --- > blocks: [1,2,3,4,5,6,9,12,14,17,18,19,22,25,27,28,30,31,32,33,34] -727c773,780 +752c795,802 < 172 THROW(MyException) --- > ? STORE_LOCAL(value ex6) @@ -153,64 +162,64 @@ > 170 STORE_LOCAL(value x4) > 170 SCOPE_ENTER value x4 > 170 JUMP 18 -774,777d826 +799,802d848 < 175 LOAD_LOCAL(value x5) < 175 CALL_METHOD MyException.message (dynamic) < 175 STORE_LOCAL(value message) < 175 SCOPE_ENTER value message -779c828,829 +804c850,851 < 176 LOAD_LOCAL(value message) --- > ? LOAD_LOCAL(value x5) > 176 CALL_METHOD MyException.message (dynamic) -783c833,834 +808c855,856 < 177 LOAD_LOCAL(value message) --- > ? LOAD_LOCAL(value x5) > 177 CALL_METHOD MyException.message (dynamic) -785c836,837 +810c858,859 < 177 THROW(MyException) --- > ? STORE_LOCAL(value ex6) > ? JUMP 33 -789c841,842 +814c863,864 < 170 THROW(Throwable) --- > ? STORE_LOCAL(value ex6) > ? JUMP 33 -798a852,857 +823a874,879 > 33: > 169 LOAD_LOCAL(value ex6) > 169 STORE_LOCAL(value x4) > 169 SCOPE_ENTER value x4 > 169 JUMP 5 > -813,816d871 +838,841d893 < 180 LOAD_LOCAL(value x5) < 180 CALL_METHOD MyException.message (dynamic) < 180 STORE_LOCAL(value message) < 180 SCOPE_ENTER value message -818c873,874 +843c895,896 < 181 LOAD_LOCAL(value message) --- > ? LOAD_LOCAL(value x5) > 181 CALL_METHOD MyException.message (dynamic) -822c878,879 +847c900,901 < 182 LOAD_LOCAL(value message) --- > ? LOAD_LOCAL(value x5) > 182 CALL_METHOD MyException.message (dynamic) -824c881,882 +849c903,904 < 182 THROW(MyException) --- > ? STORE_LOCAL(variable exc2) > ? JUMP 34 -828c886,887 +853c908,909 < 169 THROW(Throwable) --- > ? STORE_LOCAL(variable exc2) > ? JUMP 34 -844a904,916 +869a926,938 > 34: > 184 LOAD_MODULE object Predef > 184 CONSTANT("finally") @@ -224,23 +233,23 @@ > 185 LOAD_LOCAL(variable exc2) > 185 THROW(Throwable) > -850c922 +875c944 < catch (Throwable) in ArrayBuffer(17, 18, 19, 22, 25, 27, 28, 30) starting at: 4 --- > catch (Throwable) in ArrayBuffer(17, 18, 19, 22, 25, 27, 28, 30, 32) starting at: 4 -853c925 +878c947 < catch (<none>) in ArrayBuffer(4, 5, 6, 9, 12, 17, 18, 19, 22, 25, 27, 28, 30) starting at: 3 --- > catch (<none>) in ArrayBuffer(4, 5, 6, 9, 12, 17, 18, 19, 22, 25, 27, 28, 30, 32, 33) starting at: 3 -877c949 +902c971 < locals: value args, variable result, value e, value ex6, value x4, value x5, value message, value x --- > locals: value args, variable result, value e, value ex6, value x4, value x5, value x -879c951 +904c973 < blocks: [1,2,3,6,7,8,11,14,16,17,19] --- > blocks: [1,2,3,6,7,8,11,14,16,17,19,20] -903c975,982 +928c997,1004 < 124 THROW(MyException) --- > ? STORE_LOCAL(value ex6) @@ -251,29 +260,29 @@ > 122 STORE_LOCAL(value x4) > 122 SCOPE_ENTER value x4 > 122 JUMP 7 -932,935d1010 +957,960d1032 < 127 LOAD_LOCAL(value x5) < 127 CALL_METHOD MyException.message (dynamic) < 127 STORE_LOCAL(value message) < 127 SCOPE_ENTER value message -937c1012,1013 +962c1034,1035 < 127 LOAD_LOCAL(value message) --- > ? LOAD_LOCAL(value x5) > 127 CALL_METHOD MyException.message (dynamic) -966c1042 +991c1064 < catch (IllegalArgumentException) in ArrayBuffer(6, 7, 8, 11, 14, 16, 17, 19) starting at: 3 --- > catch (IllegalArgumentException) in ArrayBuffer(6, 7, 8, 11, 14, 16, 17, 19, 20) starting at: 3 -990c1066 +1015c1088 < locals: value args, variable result, value ex6, value x4, value x5, value message, value x, value e --- > locals: value args, variable result, value ex6, value x4, value x5, value x, value e -992c1068 +1017c1090 < blocks: [1,2,3,4,5,8,11,15,16,17,19] --- > blocks: [1,2,3,5,8,11,15,16,17,19,20] -1016c1092,1101 +1041c1114,1123 < 148 THROW(MyException) --- > ? STORE_LOCAL(value ex6) @@ -286,49 +295,50 @@ > 154 LOAD_LOCAL(value x4) > 154 IS_INSTANCE REF(class MyException) > 154 CZJUMP (BOOL)NE ? 5 : 11 -1037,1039d1121 +1062,1064d1143 < 145 JUMP 4 < < 4: -1053,1056d1134 +1078,1081d1156 < 154 LOAD_LOCAL(value x5) < 154 CALL_METHOD MyException.message (dynamic) < 154 STORE_LOCAL(value message) < 154 SCOPE_ENTER value message -1058c1136,1137 +1083c1158,1159 < 154 LOAD_LOCAL(value message) --- > ? LOAD_LOCAL(value x5) > 154 CALL_METHOD MyException.message (dynamic) -1275c1354 +1300c1376 < blocks: [1,2,3,4,5,7] --- > blocks: [1,2,3,4,5,7,8] -1299c1378,1385 +1324c1400,1401 < 38 THROW(IllegalArgumentException) --- > ? STORE_LOCAL(value e) > ? JUMP 8 -> +1325a1403,1408 > 8: > 42 LOAD_MODULE object Predef > 42 CONSTANT("IllegalArgumentException") > 42 CALL_METHOD scala.Predef.println (dynamic) > 42 JUMP 2 -1346c1432 +> +1371c1454 < locals: value args, variable result, value ex6, value x4, value x5, value message, value x --- > locals: value args, variable result, value ex6, value x4, value x5, value x -1348c1434 +1373c1456 < blocks: [1,2,3,4,5,8,11,13,14,16,17,19] --- > blocks: [1,2,3,5,8,11,13,14,16,17,19,20] -1372c1458,1459 +1397c1480,1481 < 203 THROW(MyException) --- > ? STORE_LOCAL(value ex6) > ? JUMP 20 -1392c1479,1488 +1417c1501,1510 < 209 THROW(MyException) --- > ? STORE_LOCAL(value ex6) @@ -341,41 +351,41 @@ > 212 LOAD_LOCAL(value x4) > 212 IS_INSTANCE REF(class MyException) > 212 CZJUMP (BOOL)NE ? 5 : 11 -1405,1407d1500 +1430,1432d1522 < 200 JUMP 4 < < 4: -1421,1424d1513 +1446,1449d1535 < 212 LOAD_LOCAL(value x5) < 212 CALL_METHOD MyException.message (dynamic) < 212 STORE_LOCAL(value message) < 212 SCOPE_ENTER value message -1426c1515,1516 +1451c1537,1538 < 213 LOAD_LOCAL(value message) --- > ? LOAD_LOCAL(value x5) > 213 CALL_METHOD MyException.message (dynamic) -1470c1560 +1495c1582 < blocks: [1,2,3,4,5,7] --- > blocks: [1,2,3,4,5,7,8] -1494c1584,1585 +1519c1606,1607 < 58 THROW(IllegalArgumentException) --- > ? STORE_LOCAL(value e) > ? JUMP 8 -1495a1587,1592 +1520a1609,1614 > 8: > 62 LOAD_MODULE object Predef > 62 CONSTANT("RuntimeException") > 62 CALL_METHOD scala.Predef.println (dynamic) > 62 JUMP 2 > -1543c1640 +1568c1662 < blocks: [1,2,3,4] --- > blocks: [1,2,3,4,5] -1563c1660,1665 +1588c1682,1687 < 229 THROW(MyException) --- > ? JUMP 5 @@ -384,19 +394,19 @@ > ? LOAD_LOCAL(variable monitor1) > 228 MONITOR_EXIT > 228 THROW(Throwable) -1569c1671 +1594c1693 < ? THROW(Throwable) --- > 228 THROW(Throwable) -1597c1699 +1622c1721 < locals: value args, variable result, variable monitor2, variable monitorResult1 --- > locals: value exception$1, value args, variable result, variable monitor2, variable monitorResult1 -1599c1701 +1624c1723 < blocks: [1,2,3,4] --- > blocks: [1,2,3,4,5] -1622c1724,1732 +1647c1746,1754 < 245 THROW(MyException) --- > ? STORE_LOCAL(value exception$1) @@ -408,7 +418,7 @@ > ? LOAD_LOCAL(variable monitor2) > 244 MONITOR_EXIT > 244 THROW(Throwable) -1628c1738 +1653c1760 < ? THROW(Throwable) --- > 244 THROW(Throwable) diff --git a/test/files/run/streams.check b/test/files/run/streams.check index 7f894052d9..db6d2eebab 100644 --- a/test/files/run/streams.check +++ b/test/files/run/streams.check @@ -1,5 +1,8 @@ Stream() Stream() +true +true +true Array(1) Stream(1, ?) @@ -8,12 +11,21 @@ Stream() Stream() Stream(1) Stream() +true +true +true +true Array(1, 2) Stream(2) Stream() Stream(1, 2) Stream() +true +true +true +true +true 999 512 @@ -23,3 +35,5 @@ Stream(100001, ?) true true 705082704 + +true diff --git a/test/files/run/streams.scala b/test/files/run/streams.scala index 51b4e5d76c..03b2622edd 100644 --- a/test/files/run/streams.scala +++ b/test/files/run/streams.scala @@ -2,6 +2,9 @@ object Test extends App { val s0: Stream[Int] = Stream.empty println(s0.take(1)) println(s0.takeWhile(_ > 0)) + println(s0.lengthCompare(-5) > 0) + println(s0.lengthCompare(0) == 0) + println(s0.lengthCompare(5) < 0) println val s1 = Stream.cons(1, Stream.empty) @@ -12,6 +15,10 @@ object Test extends App { println(s1.drop(2)) println(s1.drop(-1)) println(s1.dropWhile(_ > 0)) + println(s1.lengthCompare(-5) > 0) + println(s1.lengthCompare(0) > 0) + println(s1.lengthCompare(1) == 0) + println(s1.lengthCompare(5) < 0) println val s2 = s1.append(Stream.cons(2, Stream.empty)) @@ -20,6 +27,11 @@ object Test extends App { println(s2.drop(2)) println(s2.drop(-1)) println(s2.dropWhile(_ > 0)) + println(s2.lengthCompare(-5) > 0) + println(s2.lengthCompare(0) > 0) + println(s2.lengthCompare(1) > 0) + println(s2.lengthCompare(2) == 0) + println(s2.lengthCompare(5) < 0) println val s3 = Stream.range(1, 1000) //100000 (ticket #153: Stackoverflow) @@ -43,4 +55,12 @@ object Test extends App { println(Stream.from(1).take(size).foldLeft(0)(_ + _)) val arr = new Array[Int](size) Stream.from(1).take(size).copyToArray(arr, 0) + + println + + // ticket #6415 + lazy val x = { println("evaluated"); 1 } + val s4 = 0 #:: x #:: Stream.empty + + println(s4.isDefinedAt(0)) } diff --git a/test/files/run/t2544.check b/test/files/run/t2544.check index 716b146ac4..d19538dca3 100644 --- a/test/files/run/t2544.check +++ b/test/files/run/t2544.check @@ -2,8 +2,8 @@ 2 3 3 --2 --2 +-1 +-1 1 1 0 diff --git a/test/files/run/t2544.scala b/test/files/run/t2544.scala index 7e7cfeb357..6bee2f1082 100644 --- a/test/files/run/t2544.scala +++ b/test/files/run/t2544.scala @@ -1,19 +1,25 @@ object Test { object Foo extends Seq[Int] { def apply(i: Int) = i - def length = 4 + def length = 5 def iterator = Iterator(0,1,2,3,4) } + def lengthEquiv(result: Int) = println( + if (result < 0) -1 + else if (result == 0) 0 + else 1 + ) + def main(args: Array[String]) = { println(Foo indexWhere(_ >= 2,1)) println(Foo.toList indexWhere(_ >= 2,1)) println(Foo segmentLength(_ <= 3,1)) println(Foo.toList segmentLength(_ <= 3,1)) - println(Foo lengthCompare 7) - println(Foo.toList lengthCompare 7) - println(Foo lengthCompare 2) - println(Foo.toList lengthCompare 2) - println(Foo lengthCompare 5) - println(Foo.toList lengthCompare 5) + lengthEquiv(Foo lengthCompare 7) + lengthEquiv(Foo.toList lengthCompare 7) + lengthEquiv(Foo lengthCompare 2) + lengthEquiv(Foo.toList lengthCompare 2) + lengthEquiv(Foo lengthCompare 5) + lengthEquiv(Foo.toList lengthCompare 5) } -}
\ No newline at end of file +} diff --git a/test/files/run/t6194.check b/test/files/run/t6194.check new file mode 100644 index 0000000000..b325f479d7 --- /dev/null +++ b/test/files/run/t6194.check @@ -0,0 +1 @@ +C:\FooBar\Java\includes\*.jar diff --git a/test/files/run/t6194.scala b/test/files/run/t6194.scala new file mode 100644 index 0000000000..ced3259427 --- /dev/null +++ b/test/files/run/t6194.scala @@ -0,0 +1,8 @@ +import scala.tools.nsc.util._ + +object Test { + def main(args: Array[String]): Unit = { + val cp = ClassPath.expandPath("""C:\FooBar\Java\includes\*.jar""") mkString java.io.File.pathSeparator + println(cp) + } +} diff --git a/test/files/run/t6548.check b/test/files/run/t6548.check new file mode 100644 index 0000000000..e82cae110a --- /dev/null +++ b/test/files/run/t6548.check @@ -0,0 +1,2 @@ +false +List(JavaAnnotationWithNestedEnum(value = VALUE)) diff --git a/test/files/run/t6548.scala b/test/files/run/t6548.scala new file mode 100644 index 0000000000..be3eb5b932 --- /dev/null +++ b/test/files/run/t6548.scala @@ -0,0 +1,12 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.runtime.{currentMirror => cm} + +class Bean { + @JavaAnnotationWithNestedEnum(JavaAnnotationWithNestedEnum.Value.VALUE) + def value = 1 +} + +object Test extends App { + println(cm.staticClass("Bean").isCaseClass) + println(typeOf[Bean].declaration(newTermName("value")).annotations) +} diff --git a/test/files/run/t6827.check b/test/files/run/t6827.check new file mode 100644 index 0000000000..3a3a71c67d --- /dev/null +++ b/test/files/run/t6827.check @@ -0,0 +1,15 @@ +start at -5: java.lang.IllegalArgumentException: requirement failed: start -5 out of range 10 +start at -1: java.lang.IllegalArgumentException: requirement failed: start -1 out of range 10 +start at limit: java.lang.IllegalArgumentException: requirement failed: start 10 out of range 10 +start at limit-1: ok +first 10: ok +read all: ok +test huge len: ok +5 from 5: ok +20 from 5: ok +test len overflow: ok +start beyond limit: java.lang.IllegalArgumentException: requirement failed: start 30 out of range 10 +read 0: ok +read -1: ok +invalid read 0: java.lang.IllegalArgumentException: requirement failed: start 30 out of range 10 +invalid read -1: java.lang.IllegalArgumentException: requirement failed: start 30 out of range 10 diff --git a/test/files/run/t6827.scala b/test/files/run/t6827.scala new file mode 100644 index 0000000000..7e8918e3dc --- /dev/null +++ b/test/files/run/t6827.scala @@ -0,0 +1,31 @@ +object Test extends App { + val ns = (0 until 20) + val arr = new Array[Int](10) + + def tryit(label: String, start: Int, len: Int): Unit = { + val status = try { + val it = ns.toIterator + it.copyToArray(arr, start, len) + "ok" + } catch { + case e: Exception => e.toString + } + println("%s: %s" format (label, status)) + } + + tryit("start at -5", -5, 10) + tryit("start at -1", -1, 10) + tryit("start at limit", 10, 10) + tryit("start at limit-1", 9, 10) + tryit("first 10", 0, 10) + tryit("read all", 0, 20) + tryit("test huge len", 0, Int.MaxValue) + tryit("5 from 5", 5, 10) + tryit("20 from 5", 5, 20) + tryit("test len overflow", 5, Int.MaxValue) + tryit("start beyond limit", 30, 10) + tryit("read 0", 0, 0) + tryit("read -1", 0, -1) + tryit("invalid read 0", 30, 0) + tryit("invalid read -1", 30, -1) +} diff --git a/test/files/run/t6911.scala b/test/files/run/t6911.scala new file mode 100644 index 0000000000..dd81257a96 --- /dev/null +++ b/test/files/run/t6911.scala @@ -0,0 +1,24 @@ +trait K { + case class CC(name: String) + case class DD[+A1, A2](x1: A1, x2: A2) +} + +object Test { + object Foo extends K + object Bar extends K + + val b1 = Foo.CC("b") + val b2 = Bar.CC("b") + val b3 = Foo.CC("b") + + val c1 = Foo.DD("a", 5) + val c2 = Bar.DD("a", 5) + val c3 = Foo.DD("a", 5) + + def main(args: Array[String]): Unit = { + assert(b1 != b2, ((b1, b2))) // false under 2.9, true under 2.10-RC5 + assert(b1 == b3, ((b1, b3))) + assert(c1 != c2, ((c1, c2))) + assert(c1 == c3, ((c1, c3))) + } +} |