Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/2.12.x' into topic/pipeline-trac…
Browse files Browse the repository at this point in the history
…e-macro-omnibus-rebase
  • Loading branch information
retronym committed Mar 4, 2019
2 parents 3e500b2 + ce9a857 commit 5747be5
Show file tree
Hide file tree
Showing 12 changed files with 99 additions and 65 deletions.
34 changes: 17 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# Welcome!
This is the official repository for the [Scala Programming Language](http://www.scala-lang.org).

This is the official repository for the [Scala Programming Language](http://www.scala-lang.org)
standard library, compiler, and language spec.

# How to contribute

To contribute to the Scala standard library, Scala compiler, and Scala Language Specification, please send us a [pull request](https://help.github.com/articles/using-pull-requests/#fork--pull) from your fork of this repository.
To contribute in this repo, please open a [pull request](https://help.github.com/articles/using-pull-requests/#fork--pull) from your fork of this repository.

We do have to ask you to sign the [Scala CLA](http://www.lightbend.com/contribute/cla/scala) before we can merge any of your work into our code base, to protect its open source nature.
We do have to ask you to sign the [Scala CLA](http://www.lightbend.com/contribute/cla/scala) before we can merge any of your work, to protect its open source nature.

For more information on building and developing the core of Scala, make sure to read
the rest of this README!
Expand All @@ -25,17 +27,16 @@ If you need some help with your PR at any time, please feel free to @-mention an
| | username | talk to me about... |
--------------------------------------------------------------------------------------------------|----------------------------------------------------------------|---------------------------------------------------|
<img src="https://avatars.githubusercontent.com/adriaanm" height="50px" title="Adriaan Moors"/> | [`@adriaanm`](https://github.com/adriaanm) | type checker, pattern matcher, infrastructure, language spec |
<img src="https://avatars.githubusercontent.com/SethTisue" height="50px" title="Seth Tisue"/> | [`@SethTisue`](https://github.com/SethTisue) | build, developer docs, community build, Jenkins, library, the welcome-to-Scala experience |
<img src="https://avatars.githubusercontent.com/SethTisue" height="50px" title="Seth Tisue"/> | [`@SethTisue`](https://github.com/SethTisue) | getting started, build, developer docs, community build, Jenkins, library |
<img src="https://avatars.githubusercontent.com/retronym" height="50px" title="Jason Zaugg"/> | [`@retronym`](https://github.com/retronym) | compiler performance, weird compiler bugs, Java 8 lambdas, REPL |
<img src="https://avatars.githubusercontent.com/szeiger" height="50px" title="Stefan Zeiger"/> | [`@szeiger`](https://github.com/szeiger) | collections, build |
<img src="https://avatars.githubusercontent.com/lrytz" height="50px" title="Lukas Rytz"/> | [`@lrytz`](https://github.com/lrytz) | back end, optimizer, named & default arguments |
<img src="https://avatars.githubusercontent.com/Ichoran" height="50px" title="Rex Kerr"/> | [`@Ichoran`](https://github.com/Ichoran) | collections library, performance |
<img src="https://avatars.githubusercontent.com/lrytz" height="50px" title="Lukas Rytz"/> | [`@lrytz`](https://github.com/lrytz) | optimizer, named & default arguments |
<img src="https://avatars.githubusercontent.com/VladUreche" height="50px" title="Vlad Ureche"/> | [`@VladUreche`](https://github.com/VladUreche) | specialization, Scaladoc tool |
<img src="https://avatars.githubusercontent.com/densh" height="50px" title="Denys Shabalin"/> | [`@densh`](https://github.com/densh) | quasiquotes, parser, string interpolators, macros in standard library |
<img src="https://avatars.githubusercontent.com/xeno-by" height="50px" title="Eugene Burmako"/> | [`@xeno-by`](https://github.com/xeno-by) | macros and reflection |
<img src="https://avatars.githubusercontent.com/heathermiller" height="50px" title="Heather Miller"/> | [`@heathermiller`](https://github.com/heathermiller) | documentation |
<img src="https://avatars.githubusercontent.com/viktorklang" height="50px" title="Viktor Klang"/> | [`@viktorklang`](https://github.com/viktorklang) | concurrency, futures |
<img src="https://avatars.githubusercontent.com/axel22" height="50px" title="Aleksandr Prokopec"/> | [`@axel22`](https://github.com/axel22) | concurrency, parallel collections, specialization |
<img src="https://avatars.githubusercontent.com/dragos" height="50px" title="Iulian Dragos"/> | [`@dragos`](https://github.com/dragos) | specialization, back end |
<img src="https://avatars.githubusercontent.com/axel22" height="50px" title="Aleksandr Prokopec"/> | [`@axel22`](https://github.com/axel22) | collections, concurrency, specialization |
<img src="https://avatars.githubusercontent.com/janekdb" height="50px" title="Janek Bogucki"/> | [`@janekdb`](https://github.com/janekdb) | documentation |
<img src="https://avatars.githubusercontent.com/sjrd" height="50px" title="Sébastien Doeraene"/> | [`@sjrd`](https://github.com/sjrd) | interactions with Scala.js |

P.S.: If you have some spare time to help out around here, we would be delighted to add your name to this list!

Expand All @@ -50,13 +51,13 @@ scala/
+---/library Scala Standard Library
+---/reflect Scala Reflection
+---/compiler Scala Compiler
+---/eclipse Eclipse project files
+---/intellij IntelliJ project templates
+--spec/ The Scala language specification
+--scripts/ Scripts for the CI jobs (including building releases)
+--test/ The Scala test suite
+---/files Partest tests
+---/junit JUnit tests
+---/scalacheck ScalaCheck tests
+--build/ [Generated] Build output directory
```

Expand All @@ -68,10 +69,9 @@ You need the following tools:
- Java SDK. The baseline version is 8 for both 2.12.x and 2.13.x. It may be possible to use a
later SDK for local development, but the CI will verify against the baseline
version.
- sbt. We recommend the [sbt-extras](https://github.com/paulp/sbt-extras) runner
script. It provides sensible default jvm options (stack and heap size).
- sbt (sbt 0.13 on the 2.12.x branch, sbt 1 on the 2.13.x branch)

Mac OS X and Linux work. Windows may work if you use Cygwin. Community help with keeping
MacOS and Linux work. Windows may work if you use Cygwin. Community help with keeping
the build working on Windows is appreciated.

## Tools we use
Expand All @@ -87,7 +87,7 @@ We are grateful for the following OSS licenses:

During ordinary development, a new Scala build is built by the
previously released version. For short we call the previous release
"starr": the stable reference Scala release. Building with starr is
"starr": the stable reference release. Building with starr is
sufficient for most kinds of changes.

However, a full build of Scala (a *bootstrap*, as performed by our CI)
Expand Down Expand Up @@ -258,14 +258,14 @@ after an LGTM comment is in the [scala/scabot](https://github.com/scala/scabot)

## Community build

The Scala community build is a central element for testing Scala
The Scala community build is an important method for testing Scala
releases. A community build can be launched for any Scala commit, even
before the commit's PR has been merged. That commit is then used to
build a large number of open-source projects from source and run their
test suites.

To request a community build run on your PR, just ask in a comment on
the PR and a Scala team member will take care of
the PR and a Scala team member (probably @SethTisue) will take care of
it. ([details](https://github.com/scala/community-builds/wiki#can-i-run-it-against-a-pull-request-in-scalascala))

Community builds run on the Scala Jenkins instance. The jobs are
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/scala/tools/nsc/PickleExtractor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ object PickleExtractor {
true
}).asJava
}
val writer = new ClassWriter(Opcodes.ASM7_EXPERIMENTAL)
val writer = new ClassWriter(Opcodes.ASM7)
val isScalaRaw = foundScalaAttr && !foundScalaSig
if (isScalaRaw) Skip
else {
Expand Down
6 changes: 1 addition & 5 deletions src/compiler/scala/tools/nsc/backend/jvm/PostProcessor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,11 @@ abstract class PostProcessor extends PerRunInit {
setInnerClasses(classNode)
serializeClass(classNode)
} catch {
case e: java.lang.RuntimeException if e.getMessage != null && (e.getMessage contains "too large!") =>
backendReporting.error(NoPosition,
s"Could not write class ${internalName} because it exceeds JVM code size limits. ${e.getMessage}")
null
case ex: InterruptedException => throw ex
case ex: Throwable =>
// TODO fail fast rather than continuing to write the rest of the class files?
if (frontendAccess.compilerSettings.debug) ex.printStackTrace()
backendReporting.error(NoPosition, s"Error while emitting ${internalName}\n${ex.getMessage}")
backendReporting.error(NoPosition, s"Error while emitting $internalName\n${ex.getMessage}")
null
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import java.util

import scala.annotation.switch
import scala.tools.asm.tree.analysis._
import scala.tools.asm.tree.{AbstractInsnNode, LdcInsnNode, MethodInsnNode, MethodNode}
import scala.tools.asm.tree.{AbstractInsnNode, LdcInsnNode, MethodInsnNode, MethodNode, LabelNode}
import scala.tools.asm.{Opcodes, Type}
import scala.tools.nsc.backend.jvm.opt.BytecodeUtils
import scala.tools.nsc.backend.jvm.opt.BytecodeUtils._
Expand Down Expand Up @@ -146,15 +146,37 @@ final class NullnessInterpreter(knownNonNullInvocation: MethodInsnNode => Boolea
}

class NullnessFrame(nLocals: Int, nStack: Int) extends AliasingFrame[NullnessValue](nLocals, nStack) {
private[this] var ifNullAliases: AliasSet = null

// Auxiliary constructor required for implementing `NullnessAnalyzer.newFrame`
def this(src: Frame[_ <: NullnessValue]) {
this(src.getLocals, src.getMaxStackSize)
init(src)
}

private def setNullness(s: AliasSet, v: NullnessValue) = {
val it = s.iterator
while (it.hasNext)
this.setValue(it.next(), v)
}

override def initJumpTarget(opcode: Int, target: LabelNode): Unit = {
// when `target` is defined, we're in the case where the branch condition is true
val conditionTrue = target != null
if (opcode == Opcodes.IFNULL)
setNullness(ifNullAliases, if (conditionTrue) NullValue else NotNullValue)
else if (opcode == Opcodes.IFNONNULL)
setNullness(ifNullAliases, if (conditionTrue) NotNullValue else NullValue)
}

override def execute(insn: AbstractInsnNode, interpreter: Interpreter[NullnessValue]): Unit = {
import Opcodes._

ifNullAliases = insn.getOpcode match {
case IFNULL | IFNONNULL => aliasesOf(this.stackTop)
case _ => null
}

// get the alias set the object that is known to be not-null after this operation.
// alias sets are mutable / mutated, so after super.execute, this set contains the remaining
// aliases of the value that becomes not-null.
Expand Down Expand Up @@ -203,11 +225,8 @@ class NullnessFrame(nLocals: Int, nStack: Int) extends AliasingFrame[NullnessVal

super.execute(insn, interpreter)

if (nullCheckedAliases != null) {
val it = nullCheckedAliases.iterator
while (it.hasNext)
this.setValue(it.next(), NotNullValue)
}
if (nullCheckedAliases != null)
setNullness(nullCheckedAliases, NotNullValue)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -464,16 +464,16 @@ case class ParameterProducer(local: Int)
case class UninitializedLocalProducer(local: Int) extends InitialProducer
case class ExceptionProducer[V <: Value](handlerLabel: LabelNode, handlerStackTop: Int) extends InitialProducer

class InitialProducerSourceInterpreter extends SourceInterpreter(scala.tools.asm.Opcodes.ASM7_EXPERIMENTAL) {
class InitialProducerSourceInterpreter extends SourceInterpreter(scala.tools.asm.Opcodes.ASM7) {
override def newParameterValue(isInstanceMethod: Boolean, local: Int, tp: Type): SourceValue = {
new SourceValue(tp.getSize, ParameterProducer(local))
}

override def newEmptyNonParameterLocalValue(local: Int): SourceValue = {
override def newEmptyValue(local: Int): SourceValue = {
new SourceValue(1, UninitializedLocalProducer(local))
}

override def newExceptionValue(tryCatchBlockNode: TryCatchBlockNode, handlerFrame: Frame[_ <: Value], exceptionType: Type): SourceValue = {
override def newExceptionValue(tryCatchBlockNode: TryCatchBlockNode, handlerFrame: Frame[SourceValue], exceptionType: Type): SourceValue = {
val handlerStackTop = handlerFrame.stackTop + 1 // +1 because this value is about to be pushed onto `handlerFrame`.
new SourceValue(1, ExceptionProducer(tryCatchBlockNode.handler, handlerStackTop))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package analysis
import scala.tools.asm.Type
import scala.tools.asm.tree.analysis.{BasicValue, BasicInterpreter}

abstract class TypeFlowInterpreter extends BasicInterpreter(scala.tools.asm.Opcodes.ASM7_EXPERIMENTAL) {
abstract class TypeFlowInterpreter extends BasicInterpreter(scala.tools.asm.Opcodes.ASM7) {
override def newValue(tp: Type) = {
if (tp == null) super.newValue(tp)
else if (isRef(tp)) new BasicValue(tp)
Expand Down
8 changes: 6 additions & 2 deletions src/compiler/scala/tools/nsc/typechecker/Implicits.scala
Original file line number Diff line number Diff line change
Expand Up @@ -473,12 +473,16 @@ trait Implicits {
val syms = for (t <- tp; if t.typeSymbol.isTypeParameter) yield t.typeSymbol
deriveTypeWithWildcards(syms.distinct)(tp)
}
@annotation.tailrec def sumComplexity(acc: Int, xs: List[Type]): Int = xs match {
case h :: t => sumComplexity(acc + complexity(h), t)
case _: Nil.type => acc
}
def complexity(tp: Type): Int = tp.dealias match {
case NoPrefix => 0
case SingleType(pre, sym) => if (sym.hasPackageFlag) 0 else complexity(tp.dealiasWiden)
case ThisType(sym) => if (sym.hasPackageFlag) 0 else 1
case TypeRef(pre, sym, args) => complexity(pre) + (args map complexity).sum + 1
case RefinedType(parents, _) => (parents map complexity).sum + 1
case TypeRef(pre, sym, args) => 1 + complexity(pre) + sumComplexity(0, args)
case RefinedType(parents, _) => 1 + sumComplexity(0, parents)
case _ => 1
}
def overlaps(tp1: Type, tp2: Type): Boolean = (tp1, tp2) match {
Expand Down
2 changes: 2 additions & 0 deletions src/compiler/scala/tools/nsc/typechecker/Typers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,8 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
}
}

@deprecated("Use the overload accepting a Type.", "2.12.9")
def member(qual: Tree, name: Name): Symbol = member(qual.tpe, name)
/** The member with given name of given qualifier type */
def member(qual: Type, name: Name): Symbol = {
def callSiteWithinClass(clazz: Symbol) = context.enclClass.owner hasTransOwner clazz
Expand Down
63 changes: 37 additions & 26 deletions src/reflect/scala/reflect/internal/tpe/GlbLubs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -482,30 +482,34 @@ private[internal] trait GlbLubs {
try {
val (ts, tparams) = stripExistentialsAndTypeVars(ts0)
val glbOwner = commonOwner(ts)
def refinedToParents(t: Type): List[Type] = t match {
case RefinedType(ps, _) => ps flatMap refinedToParents
case _ => List(t)
}
def refinedToDecls(t: Type): List[Scope] = t match {
case RefinedType(ps, decls) =>
val dss = ps flatMap refinedToDecls
if (decls.isEmpty) dss else decls :: dss
case _ => List()
val ts1 = {
val res = mutable.ListBuffer.empty[Type]
def loop(ty: Type): Unit = ty match {
case RefinedType(ps, _) => ps.foreach(loop)
case _ => res += ty
}
ts foreach loop
res.toList
}
val ts1 = ts flatMap refinedToParents
val glbBase = intersectionType(ts1, glbOwner)
val glbType =
if (phase.erasedTypes || depth.isZero) glbBase
if (phase.erasedTypes || depth.isZero)
intersectionType(ts1, glbOwner)
else {
val glbRefined = refinedType(ts1, glbOwner)
val glbThisType = glbRefined.typeSymbol.thisType
def glbsym(proto: Symbol): Symbol = {
val prototp = glbThisType.memberInfo(proto)
val syms = for (t <- ts;
alt <- (t.nonPrivateMember(proto.name).alternatives)
if glbThisType.memberInfo(alt) matches prototp
) yield alt
val symtypes = syms map glbThisType.memberInfo
val symtypes: List[Type] = {
val res = mutable.ListBuffer.empty[Type]
ts foreach { t =>
t.nonPrivateMember(proto.name).alternatives foreach { alt =>
val mi = glbThisType.memberInfo(alt)
if (mi matches prototp)
res += mi
}
}
res.toList
}
assert(!symtypes.isEmpty)
proto.cloneSymbol(glbRefined.typeSymbol).setInfoOwnerAdjusted(
if (proto.isTerm) glb(symtypes, depth.decr)
Expand Down Expand Up @@ -534,18 +538,25 @@ private[internal] trait GlbLubs {
if (globalGlbDepth < globalGlbLimit)
try {
globalGlbDepth = globalGlbDepth.incr
val dss = ts flatMap refinedToDecls
for (ds <- dss; sym <- ds.iterator)
if (globalGlbDepth < globalGlbLimit && !specializesSym(glbThisType, sym, depth))
try {
addMember(glbThisType, glbRefined, glbsym(sym), depth)
} catch {
case ex: NoCommonType =>
}
def foreachRefinedDecls(ty: Type): Unit = ty match {
case RefinedType(ps, decls) =>
ps foreach foreachRefinedDecls
if (! decls.isEmpty)
decls.iterator.foreach { sym =>
if (globalGlbDepth < globalGlbLimit && !specializesSym(glbThisType, sym, depth))
try {
addMember(glbThisType, glbRefined, glbsym(sym), depth)
} catch {
case ex: NoCommonType =>
}
}
case _ =>
}
ts foreach foreachRefinedDecls
} finally {
globalGlbDepth = globalGlbDepth.decr
}
if (glbRefined.decls.isEmpty) glbBase else glbRefined
if (glbRefined.decls.isEmpty) intersectionType(ts1, glbOwner) else glbRefined
}
existentialAbstraction(tparams, glbType)
} catch {
Expand Down
3 changes: 2 additions & 1 deletion test/files/run/large_class.check
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
error: Could not write class BigEnoughToFail because it exceeds JVM code size limits. Class file too large!
error: Error while emitting BigEnoughToFail
Class too large: BigEnoughToFail
3 changes: 2 additions & 1 deletion test/files/run/large_code.check
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
error: Could not write class BigEnoughToFail because it exceeds JVM code size limits. Method tooLong's code too large!
error: Error while emitting BigEnoughToFail
Method too large: BigEnoughToFail.tooLong ()V
4 changes: 2 additions & 2 deletions versions.properties
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ scala.binary.version=2.12
scala-xml.version.number=1.0.6
scala-parser-combinators.version.number=1.0.7
scala-swing.version.number=2.0.3
partest.version.number=1.1.7
scala-asm.version=6.2.0-scala-2
partest.version.number=1.1.9
scala-asm.version=7.0.0-scala-1
jline.version=2.14.6

0 comments on commit 5747be5

Please sign in to comment.