aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/common5
-rwxr-xr-xbin/dotc7
-rw-r--r--project/Build.scala1
-rw-r--r--src/dotty/tools/dotc/config/ScalaSettings.scala3
-rw-r--r--src/dotty/tools/dotc/core/Definitions.scala10
-rw-r--r--src/dotty/tools/dotc/core/TypeApplications.scala7
-rw-r--r--src/dotty/tools/dotc/core/TypeComparer.scala19
-rw-r--r--src/dotty/tools/dotc/core/TypeErasure.scala18
-rw-r--r--src/dotty/tools/dotc/core/TypeOps.scala22
-rw-r--r--src/dotty/tools/dotc/core/Types.scala25
-rw-r--r--src/dotty/tools/dotc/core/classfile/ClassfileParser.scala18
-rw-r--r--src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala6
-rw-r--r--src/dotty/tools/dotc/parsing/Parsers.scala5
-rw-r--r--src/dotty/tools/dotc/printing/RefinedPrinter.scala2
-rw-r--r--src/dotty/tools/dotc/repl/CompilingInterpreter.scala10
-rw-r--r--src/dotty/tools/dotc/repl/InteractiveReader.scala13
-rw-r--r--src/dotty/tools/dotc/repl/Interpreter.scala2
-rw-r--r--src/dotty/tools/dotc/repl/JLineReader.scala16
-rw-r--r--src/dotty/tools/dotc/repl/Main.scala3
-rw-r--r--src/dotty/tools/dotc/repl/REPL.scala2
-rw-r--r--src/dotty/tools/dotc/transform/ExpandPrivate.scala13
-rw-r--r--src/dotty/tools/dotc/transform/ExplicitOuter.scala2
-rw-r--r--src/dotty/tools/dotc/transform/TypeTestsCasts.scala31
-rw-r--r--src/dotty/tools/dotc/typer/Implicits.scala16
-rw-r--r--src/dotty/tools/dotc/typer/Namer.scala18
-rw-r--r--src/dotty/tools/dotc/util/DiffUtil.scala13
-rw-r--r--src/scala/Function23.scala21
-rw-r--r--src/scala/Function24.scala21
-rw-r--r--src/strawman/collections/CollectionStrawMan4.scala2
-rw-r--r--test/dotc/scala-collections.whitelist2
-rw-r--r--test/dotty/partest/DPConsoleRunner.scala82
-rw-r--r--test/test/CompilerTest.scala3
-rw-r--r--test/test/ShowClassTests.scala5
-rw-r--r--tests/pending/pos/java-interop/t1263/Test.java (renamed from tests/pos/java-interop/t1263/Test.java)0
-rw-r--r--tests/pending/pos/java-interop/t1263/test.scala (renamed from tests/pos/java-interop/t1263/test.scala)0
-rw-r--r--tests/pending/pos/java-interop/t1745/J.java (renamed from tests/pos/java-interop/t1745/J.java)0
-rw-r--r--tests/pending/pos/java-interop/t1745/S.scala (renamed from tests/pos/java-interop/t1745/S.scala)0
-rw-r--r--tests/pos/annot.scala2
-rw-r--r--tests/pos/i1385.scala7
-rw-r--r--tests/pos/i1401.scala25
-rw-r--r--tests/pos/java-interop/volatile/Foo.java (renamed from tests/pos/java-interop/volatile/volatile.java)0
-rw-r--r--tests/pos/nestedLambdas.scala21
-rw-r--r--tests/run/colltest4/CollectionStrawMan4_1.scala3
-rw-r--r--tests/run/colltest4/CollectionTests_2.scala4
-rw-r--r--tests/run/colltest5/CollectionStrawMan5_1.scala1
-rw-r--r--tests/run/colltest5/CollectionTests_2.scala2
-rw-r--r--tests/run/i1284.scala8
-rw-r--r--tests/run/i1354.check6
-rw-r--r--tests/run/i1354.scala27
49 files changed, 380 insertions, 149 deletions
diff --git a/bin/common b/bin/common
index 9b8b7a4da..dcfb5cc1f 100755
--- a/bin/common
+++ b/bin/common
@@ -11,7 +11,6 @@ function getLastStringOnLineWith {
SCALA_VERSION=$(getLastStringOnLineWith "scalaVersion in")
SCALA_BINARY_VERSION=2.11
SCALA_COMPILER_VERSION=$(getLastStringOnLineWith "scala-compiler")
-JLINE_VERSION=$(getLastStringOnLineWith "jline")
SBT_VERSION=$(grep "sbt.version=" "$DOTTY_ROOT/project/build.properties" | sed 's/sbt.version=//')
bootcp=true
bootstrapped=false
@@ -129,10 +128,6 @@ if [ "$SCALA_COMPILER_JAR" == "" ]; then
SCALA_COMPILER_JAR=$(find_jar "$HOME/.ivy2/cache/me.d-d/scala-compiler/jars" "scala-compiler-$SCALA_COMPILER_VERSION.jar")
fi
-if [ "$JLINE_JAR" == "" ]; then
- JLINE_JAR=$(find_jar "$HOME/.ivy2/cache/jline/jline/jars" "jline-$JLINE_VERSION.jar")
-fi
-
if [ "$SBT_INTERFACE_JAR" == "" ]; then
SBT_INTERFACE_JAR=$(find_jar "$HOME/.ivy2/cache/org.scala-sbt/interface/jars" "interface-$SBT_VERSION.jar")
fi
diff --git a/bin/dotc b/bin/dotc
index f604483c1..3a988a897 100755
--- a/bin/dotc
+++ b/bin/dotc
@@ -19,13 +19,12 @@ CompilerMain=dotty.tools.dotc.Main
FromTasty=dotty.tools.dotc.FromTasty
ReplMain=dotty.tools.dotc.repl.Main
-if [ ! -f "$SCALA_LIBRARY_JAR" -o ! -f "$SCALA_REFLECT_JAR" -o ! -f "$SCALA_COMPILER_JAR" -o ! -f "$JLINE_JAR" -o ! -f "$SBT_INTERFACE_JAR" ]
+if [ ! -f "$SCALA_LIBRARY_JAR" -o ! -f "$SCALA_REFLECT_JAR" -o ! -f "$SCALA_COMPILER_JAR" -o ! -f "$SBT_INTERFACE_JAR" ]
then
echo To use this script please set
echo SCALA_LIBRARY_JAR to point to scala-library-$SCALA_VERSION.jar "(currently $SCALA_LIBRARY_JAR)"
echo SCALA_REFLECT_JAR to point to scala-reflect-$SCALA_VERSION.jar "(currently $SCALA_REFLECT_JAR)"
echo SCALA_COMPILER_JAR to point to scala-compiler-$SCALA_VERSION.jar with bcode patches "(currently $SCALA_COMPILER_JAR)"
- echo JLINE_JAR to point to jline-$JLINE_VERSION.jar "(currently $JLINE_JAR)"
echo SBT_INTERFACE_JAR to point to interface-$SBT_VERSION.jar "(currently $SBT_INTERFACE_JAR)"
fi
@@ -116,9 +115,9 @@ trap onExit INT
classpathArgs () {
if [[ "true" == $bootstrapped ]]; then
check_jar "dotty-bootstrapped" $DOTTY_JAR "target" 'build_jar "test:runMain dotc.build" target' &> /dev/null
- toolchain="$DOTTY_JAR:$SCALA_LIBRARY_JAR:$SCALA_REFLECT_JAR:$SCALA_COMPILER_JAR:$JLINE_JAR:$SBT_INTERFACE_JAR"
+ toolchain="$DOTTY_JAR:$SCALA_LIBRARY_JAR:$SCALA_REFLECT_JAR:$SCALA_COMPILER_JAR:$SBT_INTERFACE_JAR"
else
- toolchain="$SCALA_LIBRARY_JAR:$SCALA_REFLECT_JAR:$SCALA_COMPILER_JAR:$JLINE_JAR:$SBT_INTERFACE_JAR"
+ toolchain="$SCALA_LIBRARY_JAR:$SCALA_REFLECT_JAR:$SCALA_COMPILER_JAR:$SBT_INTERFACE_JAR"
fi
bcpJars="$INTERFACES_JAR:$MAIN_JAR"
cpJars="$INTERFACES_JAR:$MAIN_JAR:$TEST_JAR"
diff --git a/project/Build.scala b/project/Build.scala
index f57c30e7d..a4e6551d7 100644
--- a/project/Build.scala
+++ b/project/Build.scala
@@ -99,7 +99,6 @@ object DottyBuild extends Build {
libraryDependencies ++= Seq("org.scala-lang.modules" %% "scala-xml" % "1.0.1",
"org.scala-lang.modules" %% "scala-partest" % "1.0.11" % "test",
"com.novocode" % "junit-interface" % "0.11" % "test",
- "jline" % "jline" % "2.12",
"com.googlecode.java-diff-utils" % "diffutils" % "1.3.0",
"com.typesafe.sbt" % "sbt-interface" % sbtVersion.value),
// enable improved incremental compilation algorithm
diff --git a/src/dotty/tools/dotc/config/ScalaSettings.scala b/src/dotty/tools/dotc/config/ScalaSettings.scala
index b2fa745f1..d0c4cc02c 100644
--- a/src/dotty/tools/dotc/config/ScalaSettings.scala
+++ b/src/dotty/tools/dotc/config/ScalaSettings.scala
@@ -37,7 +37,7 @@ class ScalaSettings extends Settings.SettingGroup {
val usejavacp = BooleanSetting("-usejavacp", "Utilize the java.class.path in classpath resolution.")
val verbose = BooleanSetting("-verbose", "Output messages about what the compiler is doing.")
val version = BooleanSetting("-version", "Print product version and exit.")
- val pageWidth = IntSetting("-pagewidth", "Set page width", 80)
+ val pageWidth = IntSetting("-pagewidth", "Set page width", 120)
val jvmargs = PrefixSetting("-J<flag>", "-J", "Pass <flag> directly to the runtime system.")
val defines = PrefixSetting("-Dproperty=value", "-D", "Pass -Dproperty=value directly to the runtime system.")
@@ -74,7 +74,6 @@ class ScalaSettings extends Settings.SettingGroup {
val maxClassfileName = IntSetting("-Xmax-classfile-name", "Maximum filename length for generated classes", 255, 72 to 255)
val Xmigration = VersionSetting("-Xmigration", "Warn about constructs whose behavior may have changed since version.")
val Xsource = VersionSetting("-Xsource", "Treat compiler input as Scala source for the specified version.")
- val Xnojline = BooleanSetting("-Xnojline", "Do not use JLine for editing.")
val Xverify = BooleanSetting("-Xverify", "Verify generic signatures in generated bytecode (asm backend only.)")
val plugin = MultiStringSetting("-Xplugin", "file", "Load one or more plugins from files.")
val disable = MultiStringSetting("-Xplugin-disable", "plugin", "Disable the given plugin(s).")
diff --git a/src/dotty/tools/dotc/core/Definitions.scala b/src/dotty/tools/dotc/core/Definitions.scala
index 6d183fe40..5a19903be 100644
--- a/src/dotty/tools/dotc/core/Definitions.scala
+++ b/src/dotty/tools/dotc/core/Definitions.scala
@@ -12,7 +12,13 @@ import collection.mutable
import scala.reflect.api.{ Universe => ApiUniverse }
object Definitions {
- val MaxFunctionArity, MaxTupleArity = 22
+ val MaxTupleArity, MaxAbstractFunctionArity = 22
+ val MaxFunctionArity = 24
+ // Awaiting a definite solution that drops the limit altogether, 24 gives a safety
+ // margin over the previous 22, so that treecopiers in miniphases are allowed to
+ // temporarily create larger closures. This is needed in lambda lift where large closures
+ // are first formed by treecopiers before they are split apart into parameters and
+ // environment in the lambdalift transform itself.
}
/** A class defining symbols and types of standard definitions
@@ -587,7 +593,7 @@ class Definitions {
// ----- Symbol sets ---------------------------------------------------
- lazy val AbstractFunctionType = mkArityArray("scala.runtime.AbstractFunction", MaxFunctionArity, 0)
+ lazy val AbstractFunctionType = mkArityArray("scala.runtime.AbstractFunction", MaxAbstractFunctionArity, 0)
val AbstractFunctionClassPerRun = new PerRun[Array[Symbol]](implicit ctx => AbstractFunctionType.map(_.symbol.asClass))
def AbstractFunctionClass(n: Int)(implicit ctx: Context) = AbstractFunctionClassPerRun()(ctx)(n)
lazy val FunctionType = mkArityArray("scala.Function", MaxFunctionArity, 0)
diff --git a/src/dotty/tools/dotc/core/TypeApplications.scala b/src/dotty/tools/dotc/core/TypeApplications.scala
index cb11d3fdc..af362f4da 100644
--- a/src/dotty/tools/dotc/core/TypeApplications.scala
+++ b/src/dotty/tools/dotc/core/TypeApplications.scala
@@ -223,12 +223,12 @@ class TypeApplications(val self: Type) extends AnyVal {
self.parent.typeParams.filterNot(_.paramName == self.refinedName)
case self: RecType =>
self.parent.typeParams
- case _: HKApply | _: SingletonType =>
+ case _: SingletonType =>
Nil
case self: WildcardType =>
self.optBounds.typeParams
case self: TypeProxy =>
- self.underlying.typeParams
+ self.superType.typeParams
case _ =>
Nil
}
@@ -312,14 +312,13 @@ class TypeApplications(val self: Type) extends AnyVal {
case self: TypeRef => self.info.isHK
case self: RefinedType => false
case self: TypeLambda => true
- case self: HKApply => false
case self: SingletonType => false
case self: TypeVar =>
// Using `origin` instead of `underlying`, as is done for typeParams,
// avoids having to set ephemeral in some cases.
self.origin.isHK
case self: WildcardType => self.optBounds.isHK
- case self: TypeProxy => self.underlying.isHK
+ case self: TypeProxy => self.superType.isHK
case _ => false
}
diff --git a/src/dotty/tools/dotc/core/TypeComparer.scala b/src/dotty/tools/dotc/core/TypeComparer.scala
index e984970b4..18eb424bc 100644
--- a/src/dotty/tools/dotc/core/TypeComparer.scala
+++ b/src/dotty/tools/dotc/core/TypeComparer.scala
@@ -665,6 +665,13 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
}
}
+ /** Fall back to comparing either with `fourthTry` or against the lower
+ * approximation of the rhs.
+ * @param tyconLo The type constructor's lower approximation.
+ */
+ def fallback(tyconLo: Type) =
+ either(fourthTry(tp1, tp2), isSubType(tp1, tyconLo.applyIfParameterized(args2)))
+
/** Let `tycon2bounds` be the bounds of the RHS type constructor `tycon2`.
* Let `app2 = tp2` where the type constructor of `tp2` is replaced by
* `tycon2bounds.lo`.
@@ -674,13 +681,13 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
* tp1 <:< tp2 using fourthTry (this might instantiate params in tp1)
* tp1 <:< app2 using isSubType (this might instantiate params in tp2)
*/
- def compareLower(tycon2bounds: TypeBounds, tyconIsTypeRef: Boolean): Boolean = {
- def app2 = tycon2bounds.lo.applyIfParameterized(args2)
+ def compareLower(tycon2bounds: TypeBounds, tyconIsTypeRef: Boolean): Boolean =
if (tycon2bounds.lo eq tycon2bounds.hi)
- isSubType(tp1, if (tyconIsTypeRef) tp2.superType else app2)
+ isSubType(tp1,
+ if (tyconIsTypeRef) tp2.superType
+ else tycon2bounds.lo.applyIfParameterized(args2))
else
- either(fourthTry(tp1, tp2), isSubType(tp1, app2))
- }
+ fallback(tycon2bounds.lo)
tycon2 match {
case param2: PolyParam =>
@@ -693,6 +700,8 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
compareLower(tycon2.info.bounds, tyconIsTypeRef = true)
case _: TypeVar | _: AnnotatedType =>
isSubType(tp1, tp2.superType)
+ case tycon2: HKApply =>
+ fallback(tycon2.lowerBound)
case _ =>
false
}
diff --git a/src/dotty/tools/dotc/core/TypeErasure.scala b/src/dotty/tools/dotc/core/TypeErasure.scala
index a1dab16cb..1a7342a12 100644
--- a/src/dotty/tools/dotc/core/TypeErasure.scala
+++ b/src/dotty/tools/dotc/core/TypeErasure.scala
@@ -277,6 +277,22 @@ object TypeErasure {
else tp1
}
}
+
+ /** Does the (possibly generic) type `tp` have the same erasure in all its
+ * possible instantiations?
+ */
+ def hasStableErasure(tp: Type)(implicit ctx: Context): Boolean = tp match {
+ case tp: TypeRef =>
+ tp.info match {
+ case TypeAlias(alias) => hasStableErasure(alias)
+ case _: ClassInfo => true
+ case _ => false
+ }
+ case tp: PolyParam => false
+ case tp: TypeProxy => hasStableErasure(tp.superType)
+ case tp: AndOrType => hasStableErasure(tp.tp1) && hasStableErasure(tp.tp2)
+ case _ => false
+ }
}
import TypeErasure._
@@ -493,4 +509,6 @@ class TypeErasure(isJava: Boolean, semiEraseVCs: Boolean, isConstructor: Boolean
println(s"no sig for $tp")
throw ex
}
+
+
}
diff --git a/src/dotty/tools/dotc/core/TypeOps.scala b/src/dotty/tools/dotc/core/TypeOps.scala
index 10b0f5615..93b1b1f02 100644
--- a/src/dotty/tools/dotc/core/TypeOps.scala
+++ b/src/dotty/tools/dotc/core/TypeOps.scala
@@ -361,13 +361,23 @@ trait TypeOps { this: Context => // TODO: Make standalone object.
* to the current scope, provided (1) variances of both aliases are the same, and
* (2) X is not yet defined in current scope. This "short-circuiting" prevents
* long chains of aliases which would have to be traversed in type comparers.
+ *
+ * Note: Test i1401.scala shows that `forwardRefs` is also necessary
+ * for typechecking in the case where self types refer to type parameters
+ * that are upper-bounded by subclass instances.
*/
def forwardRefs(from: Symbol, to: Type, prefs: List[TypeRef]) = to match {
case to @ TypeBounds(lo1, hi1) if lo1 eq hi1 =>
- for (pref <- prefs)
- for (argSym <- pref.decls)
- if (argSym is BaseTypeArg)
- forwardRef(argSym, from, to, cls, decls)
+ for (pref <- prefs) {
+ def forward(): Unit =
+ for (argSym <- pref.decls)
+ if (argSym is BaseTypeArg)
+ forwardRef(argSym, from, to, cls, decls)
+ pref.info match {
+ case info: TempClassInfo => info.addSuspension(forward)
+ case _ => forward()
+ }
+ }
case _ =>
}
@@ -419,9 +429,9 @@ trait TypeOps { this: Context => // TODO: Make standalone object.
s"redefinition of ${decls.lookup(name).debugString} in ${cls.showLocated}")
enterArgBinding(formals(name), refinedInfo, cls, decls)
}
- // Forward definitions in super classes that have one of the refined paramters
+ // Forward definitions in super classes that have one of the refined parameters
// as aliases directly to the refined info.
- // Note that this cannot be fused bwith the previous loop because we now
+ // Note that this cannot be fused with the previous loop because we now
// assume that all arguments have been entered in `decls`.
refinements foreachBinding { (name, refinedInfo) =>
forwardRefs(formals(name), refinedInfo, parentRefs)
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala
index 11da27265..054c67e7e 100644
--- a/src/dotty/tools/dotc/core/Types.scala
+++ b/src/dotty/tools/dotc/core/Types.scala
@@ -2645,6 +2645,9 @@ object Types {
if (ctx.period != validSuper) {
cachedSuper = tycon match {
case tp: TypeLambda => defn.AnyType
+ case tp: TypeVar if !tp.inst.exists =>
+ // supertype not stable, since underlying might change
+ return tp.underlying.applyIfParameterized(args)
case tp: TypeProxy => tp.superType.applyIfParameterized(args)
case _ => defn.AnyType
}
@@ -2653,7 +2656,6 @@ object Types {
cachedSuper
}
- /* (Not needed yet) */
def lowerBound(implicit ctx: Context) = tycon.stripTypeVar match {
case tycon: TypeRef =>
tycon.info match {
@@ -3043,9 +3045,28 @@ object Types {
override def toString = s"ClassInfo($prefix, $cls)"
}
- final class CachedClassInfo(prefix: Type, cls: ClassSymbol, classParents: List[TypeRef], decls: Scope, selfInfo: DotClass)
+ class CachedClassInfo(prefix: Type, cls: ClassSymbol, classParents: List[TypeRef], decls: Scope, selfInfo: DotClass)
extends ClassInfo(prefix, cls, classParents, decls, selfInfo)
+ /** A class for temporary class infos where `parents` are not yet known. */
+ final class TempClassInfo(prefix: Type, cls: ClassSymbol, decls: Scope, selfInfo: DotClass)
+ extends CachedClassInfo(prefix, cls, Nil, decls, selfInfo) {
+
+ /** A list of actions that were because they rely on the class info of `cls` to
+ * be no longer temporary. These actions will be performed once `cls` gets a real
+ * ClassInfo.
+ */
+ private var suspensions: List[() => Unit] = Nil
+
+ def addSuspension(suspension: () => Unit): Unit = suspensions ::= suspension
+
+ /** Install classinfo with known parents in `denot` and resume all suspensions */
+ def finalize(denot: SymDenotation, parents: List[TypeRef])(implicit ctx: Context) = {
+ denot.info = derivedClassInfo(classParents = parents)
+ suspensions.foreach(_())
+ }
+ }
+
object ClassInfo {
def apply(prefix: Type, cls: ClassSymbol, classParents: List[TypeRef], decls: Scope, selfInfo: DotClass = NoType)(implicit ctx: Context) =
unique(new CachedClassInfo(prefix, cls, classParents, decls, selfInfo))
diff --git a/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala b/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala
index 813376655..a6d381693 100644
--- a/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala
+++ b/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala
@@ -580,9 +580,6 @@ class ClassfileParser(
* parameters. For Java annotations we need to fake it by making up the constructor.
* Note that default getters have type Nothing. That's OK because we need
* them only to signal that the corresponding parameter is optional.
- * If the constructor takes as last parameter an array, it can also accept
- * a vararg argument. We solve this by creating two constructors, one with
- * an array, the other with a repeated parameter.
*/
def addAnnotationConstructor(classInfo: Type, tparams: List[TypeSymbol] = Nil)(implicit ctx: Context): Unit = {
def addDefaultGetter(attr: Symbol, n: Int) =
@@ -618,13 +615,26 @@ class ClassfileParser(
}
addConstr(paramTypes)
+
+ // The code below added an extra constructor to annotations where the
+ // last parameter of the constructor is an Array[X] for some X, the
+ // array was replaced by a vararg argument. Unfortunately this breaks
+ // inference when doing:
+ // @Annot(Array())
+ // The constructor is overloaded so the expected type of `Array()` is
+ // WildcardType, and the type parameter of the Array apply method gets
+ // instantiated to `Nothing` instead of `X`.
+ // I'm leaving this commented out in case we improve inference to make this work.
+ // Note that if this is reenabled then JavaParser will also need to be modified
+ // to add the extra constructor (this was not implemented before).
+ /*
if (paramTypes.nonEmpty)
paramTypes.last match {
case defn.ArrayOf(elemtp) =>
addConstr(paramTypes.init :+ defn.RepeatedParamType.appliedTo(elemtp))
case _ =>
}
-
+ */
}
}
diff --git a/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala b/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala
index 3dbeb4040..8ea4cecde 100644
--- a/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala
+++ b/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala
@@ -106,7 +106,8 @@ object Scala2Unpickler {
// `denot.sourceModule.exists` provision i859.scala crashes in the backend.
denot.owner.thisType select denot.sourceModule
else selfInfo
- denot.info = ClassInfo(denot.owner.thisType, denot.classSymbol, Nil, decls, ost) // first rough info to avoid CyclicReferences
+ val tempInfo = new TempClassInfo(denot.owner.thisType, denot.classSymbol, decls, ost)
+ denot.info = tempInfo // first rough info to avoid CyclicReferences
var parentRefs = ctx.normalizeToClassRefs(parents, cls, decls)
if (parentRefs.isEmpty) parentRefs = defn.ObjectType :: Nil
for (tparam <- tparams) {
@@ -132,8 +133,7 @@ object Scala2Unpickler {
registerCompanionPair(scalacCompanion, denot.classSymbol)
}
- denot.info = ClassInfo( // final info, except possibly for typeparams ordering
- denot.owner.thisType, denot.classSymbol, parentRefs, decls, ost)
+ tempInfo.finalize(denot, parentRefs) // install final info, except possibly for typeparams ordering
denot.ensureTypeParamsInCorrectOrder()
}
}
diff --git a/src/dotty/tools/dotc/parsing/Parsers.scala b/src/dotty/tools/dotc/parsing/Parsers.scala
index c535c4241..82add4c14 100644
--- a/src/dotty/tools/dotc/parsing/Parsers.scala
+++ b/src/dotty/tools/dotc/parsing/Parsers.scala
@@ -2046,7 +2046,10 @@ object Parsers {
else if (in.token == AT || isTemplateIntro || isModifier)
stats += tmplDef(in.offset, defAnnotsMods(modifierTokens))
else if (!isStatSep) {
- syntaxErrorOrIncomplete("expected class or object definition")
+ if (in.token == CASE)
+ syntaxErrorOrIncomplete("only `case class` or `case object` allowed")
+ else
+ syntaxErrorOrIncomplete("expected class or object definition")
if (mustStartStat) // do parse all definitions even if they are probably local (i.e. a "}" has been forgotten)
defOrDcl(in.offset, defAnnotsMods(modifierTokens))
}
diff --git a/src/dotty/tools/dotc/printing/RefinedPrinter.scala b/src/dotty/tools/dotc/printing/RefinedPrinter.scala
index bdfce266c..ce063f06a 100644
--- a/src/dotty/tools/dotc/printing/RefinedPrinter.scala
+++ b/src/dotty/tools/dotc/printing/RefinedPrinter.scala
@@ -403,7 +403,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
case impl: Template =>
modText(tree.mods, if ((tree).mods is Trait) "trait" else "class") ~~
nameIdText(tree) ~ withEnclosingDef(tree) { toTextTemplate(impl) } ~
- (if (tree.hasType && ctx.settings.verbose.value) s"[decls = ${tree.symbol.info.decls}]" else "")
+ (if (tree.hasType && ctx.settings.verbose.value) i"[decls = ${tree.symbol.info.decls}]" else "")
case rhs: TypeBoundsTree =>
typeDefText(toText(rhs))
case _ =>
diff --git a/src/dotty/tools/dotc/repl/CompilingInterpreter.scala b/src/dotty/tools/dotc/repl/CompilingInterpreter.scala
index 897011be2..9750c9039 100644
--- a/src/dotty/tools/dotc/repl/CompilingInterpreter.scala
+++ b/src/dotty/tools/dotc/repl/CompilingInterpreter.scala
@@ -88,11 +88,11 @@ class CompilingInterpreter(
private var printResults: Boolean = true
private var delayOutput: Boolean = false
- var previousOutput: List[String] = Nil
+ val previousOutput = ListBuffer.empty[String]
override def lastOutput() = {
- val prev = previousOutput
- previousOutput = Nil
+ val prev = previousOutput.toList
+ previousOutput.clear()
prev
}
@@ -129,7 +129,7 @@ class CompilingInterpreter(
// we drop the final `$' from module classes.
out.flush()
} else {
- previousOutput = (/*clean*/(msg) + "\n") :: previousOutput
+ previousOutput += (/*clean*/(msg) + "\n")
}
}
}
@@ -220,7 +220,7 @@ class CompilingInterpreter(
else {
val (resultStrings, succeeded) = req.loadAndRun()
if (delayOutput)
- previousOutput = resultStrings.map(clean) ::: previousOutput
+ previousOutput ++= resultStrings.map(clean)
else if (printResults || !succeeded)
resultStrings.map(x => out.print(clean(x)))
if (succeeded) {
diff --git a/src/dotty/tools/dotc/repl/InteractiveReader.scala b/src/dotty/tools/dotc/repl/InteractiveReader.scala
index 6ec6a0463..07ce23717 100644
--- a/src/dotty/tools/dotc/repl/InteractiveReader.scala
+++ b/src/dotty/tools/dotc/repl/InteractiveReader.scala
@@ -13,17 +13,8 @@ trait InteractiveReader {
/** The current Scala REPL know how to do this flexibly.
*/
object InteractiveReader {
- /** Create an interactive reader. Uses JLine if the
- * library is available, but otherwise uses a
- * SimpleReader. */
+ /** Create an interactive reader */
def createDefault(in: Interpreter)(implicit ctx: Context): InteractiveReader = {
- try {
- new AmmoniteReader(in)
- } catch { case e =>
- //out.println("jline is not available: " + e) //debug
- e.printStackTrace()
- println("Could not use ammonite, falling back to simple reader")
- new SimpleReader()
- }
+ new AmmoniteReader(in)
}
}
diff --git a/src/dotty/tools/dotc/repl/Interpreter.scala b/src/dotty/tools/dotc/repl/Interpreter.scala
index e11fbf5cc..edcc5b153 100644
--- a/src/dotty/tools/dotc/repl/Interpreter.scala
+++ b/src/dotty/tools/dotc/repl/Interpreter.scala
@@ -41,5 +41,5 @@ trait Interpreter {
def delayOutputDuring[T](operation: => T): T
/** Gets the last output not printed immediately */
- def lastOutput(): List[String]
+ def lastOutput(): Seq[String]
}
diff --git a/src/dotty/tools/dotc/repl/JLineReader.scala b/src/dotty/tools/dotc/repl/JLineReader.scala
deleted file mode 100644
index 73463cd7c..000000000
--- a/src/dotty/tools/dotc/repl/JLineReader.scala
+++ /dev/null
@@ -1,16 +0,0 @@
-package dotty.tools
-package dotc
-package repl
-
-import dotc.core.Contexts.Context
-import jline.console.ConsoleReader
-
-/** Adaptor for JLine
- */
-class JLineReader extends InteractiveReader {
- val reader = new ConsoleReader()
-
- val interactive = true
-
- def readLine(prompt: String) = reader.readLine(prompt)
-}
diff --git a/src/dotty/tools/dotc/repl/Main.scala b/src/dotty/tools/dotc/repl/Main.scala
index b2b92299e..48ed3e788 100644
--- a/src/dotty/tools/dotc/repl/Main.scala
+++ b/src/dotty/tools/dotc/repl/Main.scala
@@ -13,7 +13,6 @@ package repl
*
* There are a number of TODOs:
*
- * - re-enable jline support (urgent, easy, see TODO in InteractiveReader.scala)
* - figure out why we can launch REPL only with `java`, not with `scala`.
* - make a doti command (urgent, easy)
* - create or port REPL tests (urgent, intermediate)
@@ -26,4 +25,4 @@ package repl
* - integrate with presentation compiler for command completion (not urgent, hard)
*/
/** The main entry point of the REPL */
-object Main extends REPL \ No newline at end of file
+object Main extends REPL
diff --git a/src/dotty/tools/dotc/repl/REPL.scala b/src/dotty/tools/dotc/repl/REPL.scala
index cca5e8d6b..dd20852a4 100644
--- a/src/dotty/tools/dotc/repl/REPL.scala
+++ b/src/dotty/tools/dotc/repl/REPL.scala
@@ -90,7 +90,7 @@ object REPL {
def input(in: Interpreter)(implicit ctx: Context): InteractiveReader = {
val emacsShell = System.getProperty("env.emacs", "") != ""
//println("emacsShell="+emacsShell) //debug
- if (ctx.settings.Xnojline.value || emacsShell) new SimpleReader()
+ if (emacsShell) new SimpleReader()
else InteractiveReader.createDefault(in)
}
diff --git a/src/dotty/tools/dotc/transform/ExpandPrivate.scala b/src/dotty/tools/dotc/transform/ExpandPrivate.scala
index 2e0759b89..83cd395ff 100644
--- a/src/dotty/tools/dotc/transform/ExpandPrivate.scala
+++ b/src/dotty/tools/dotc/transform/ExpandPrivate.scala
@@ -17,10 +17,14 @@ import Decorators._
import ast.Trees._
import TreeTransforms._
import java.io.File.separatorChar
+import ValueClasses._
/** Make private term members that are accessed from another class
* non-private by resetting the Private flag and expanding their name.
*
+ * Make private accessor in value class not-private. Ihis is necessary to unbox
+ * the value class when accessing it from separate compilation units
+ *
* Also, make non-private any private parameter forwarders that forward to an inherited
* public or protected parameter accessor with the same name as the forwarder.
* This is necessary since private methods are not allowed to have the same name
@@ -52,13 +56,18 @@ class ExpandPrivate extends MiniPhaseTransform with IdentityDenotTransformer { t
}
}
+ private def isVCPrivateParamAccessor(d: SymDenotation)(implicit ctx: Context) =
+ d.isTerm && d.is(PrivateParamAccessor) && isDerivedValueClass(d.owner)
+
/** Make private terms accessed from different classes non-private.
* Note: this happens also for accesses between class and linked module class.
* If we change the scheme at one point to make static module class computations
* static members of the companion class, we should tighten the condition below.
*/
private def ensurePrivateAccessible(d: SymDenotation)(implicit ctx: Context) =
- if (d.is(PrivateTerm) && d.owner != ctx.owner.enclosingClass) {
+ if (isVCPrivateParamAccessor(d))
+ d.ensureNotPrivate.installAfter(thisTransform)
+ else if (d.is(PrivateTerm) && d.owner != ctx.owner.enclosingClass) {
// Paths `p1` and `p2` are similar if they have a common suffix that follows
// possibly different directory paths. That is, their common suffix extends
// in both cases either to the start of the path or to a file separator character.
@@ -94,6 +103,8 @@ class ExpandPrivate extends MiniPhaseTransform with IdentityDenotTransformer { t
if sym.is(PrivateParamAccessor) && sel.symbol.is(ParamAccessor) && sym.name == sel.symbol.name =>
sym.ensureNotPrivate.installAfter(thisTransform)
case _ =>
+ if (isVCPrivateParamAccessor(sym))
+ sym.ensureNotPrivate.installAfter(thisTransform)
}
tree
}
diff --git a/src/dotty/tools/dotc/transform/ExplicitOuter.scala b/src/dotty/tools/dotc/transform/ExplicitOuter.scala
index 7ec0739c1..6a52b128c 100644
--- a/src/dotty/tools/dotc/transform/ExplicitOuter.scala
+++ b/src/dotty/tools/dotc/transform/ExplicitOuter.scala
@@ -47,7 +47,7 @@ class ExplicitOuter extends MiniPhaseTransform with InfoTransformer { thisTransf
/** Add outer accessors if a class always needs an outer pointer */
override def transformInfo(tp: Type, sym: Symbol)(implicit ctx: Context) = tp match {
- case tp @ ClassInfo(_, cls, _, decls, _) if needsOuterAlways(cls) =>
+ case tp @ ClassInfo(_, cls, _, decls, _) if needsOuterAlways(cls) && !sym.is(JavaDefined) =>
val newDecls = decls.cloneScope
newOuterAccessors(cls).foreach(newDecls.enter)
tp.derivedClassInfo(decls = newDecls)
diff --git a/src/dotty/tools/dotc/transform/TypeTestsCasts.scala b/src/dotty/tools/dotc/transform/TypeTestsCasts.scala
index c57d6fd1a..6de2bf44c 100644
--- a/src/dotty/tools/dotc/transform/TypeTestsCasts.scala
+++ b/src/dotty/tools/dotc/transform/TypeTestsCasts.scala
@@ -1,16 +1,12 @@
package dotty.tools.dotc
package transform
-import TreeTransforms._
-import core.Denotations._
-import core.SymDenotations._
import core.Contexts._
import core.Symbols._
import core.Types._
import core.Constants._
import core.StdNames._
import core.TypeErasure.isUnboundedGeneric
-import typer.ErrorReporting._
import ast.Trees._
import Erasure.Boxing._
import core.TypeErasure._
@@ -92,14 +88,33 @@ trait TypeTestsCasts {
unbox(qual.ensureConforms(defn.ObjectType), argType)
else if (isDerivedValueClass(argCls)) {
qual // adaptToType in Erasure will do the necessary type adaptation
- } else
+ }
+ else
derivedTree(qual, defn.Any_asInstanceOf, argType)
}
- def erasedArg = erasure(tree.args.head.tpe)
+
+ /** Transform isInstanceOf OrType
+ *
+ * expr.isInstanceOf[A | B] ~~> expr.isInstanceOf[A] | expr.isInstanceOf[B]
+ *
+ * The transform happens before erasure of `argType`, thus cannot be merged
+ * with `transformIsInstanceOf`, which depends on erased type of `argType`.
+ */
+ def transformOrTypeTest(qual: Tree, argType: Type): Tree = argType match {
+ case OrType(tp1, tp2) =>
+ evalOnce(qual) { fun =>
+ transformOrTypeTest(fun, tp1)
+ .select(nme.OR)
+ .appliedTo(transformOrTypeTest(fun, tp2))
+ }
+ case _ =>
+ transformIsInstanceOf(qual, erasure(argType))
+ }
+
if (sym eq defn.Any_isInstanceOf)
- transformIsInstanceOf(qual, erasedArg)
+ transformOrTypeTest(qual, tree.args.head.tpe)
else if (sym eq defn.Any_asInstanceOf)
- transformAsInstanceOf(erasedArg)
+ transformAsInstanceOf(erasure(tree.args.head.tpe))
else tree
case _ =>
diff --git a/src/dotty/tools/dotc/typer/Implicits.scala b/src/dotty/tools/dotc/typer/Implicits.scala
index feed398aa..1eba64e2e 100644
--- a/src/dotty/tools/dotc/typer/Implicits.scala
+++ b/src/dotty/tools/dotc/typer/Implicits.scala
@@ -10,6 +10,7 @@ import printing.Showable
import Contexts._
import Types._
import Flags._
+import TypeErasure.{erasure, hasStableErasure}
import Mode.ImplicitsEnabled
import Denotations._
import NameOps._
@@ -479,15 +480,12 @@ trait Implicits { self: Typer =>
formal.argTypes match {
case arg :: Nil =>
val tp = fullyDefinedType(arg, "ClassTag argument", pos)
- tp.underlyingClassRef(refinementOK = false) match {
- case tref: TypeRef =>
- return ref(defn.ClassTagModule)
- .select(nme.apply)
- .appliedToType(tp)
- .appliedTo(clsOf(tref))
- .withPos(pos)
- case _ =>
- }
+ if (hasStableErasure(tp))
+ return ref(defn.ClassTagModule)
+ .select(nme.apply)
+ .appliedToType(tp)
+ .appliedTo(clsOf(erasure(tp)))
+ .withPos(pos)
case _ =>
}
EmptyTree
diff --git a/src/dotty/tools/dotc/typer/Namer.scala b/src/dotty/tools/dotc/typer/Namer.scala
index 3b193d2db..d1074364c 100644
--- a/src/dotty/tools/dotc/typer/Namer.scala
+++ b/src/dotty/tools/dotc/typer/Namer.scala
@@ -688,7 +688,8 @@ class Namer { typer: Typer =>
else createSymbol(self)
// pre-set info, so that parent types can refer to type params
- denot.info = ClassInfo(cls.owner.thisType, cls, Nil, decls, selfInfo)
+ val tempInfo = new TempClassInfo(cls.owner.thisType, cls, decls, selfInfo)
+ denot.info = tempInfo
// Ensure constructor is completed so that any parameter accessors
// which have type trees deriving from its parameters can be
@@ -704,7 +705,8 @@ class Namer { typer: Typer =>
typr.println(s"completing $denot, parents = $parents, parentTypes = $parentTypes, parentRefs = $parentRefs")
index(rest)(inClassContext(selfInfo))
- denot.info = ClassInfo(cls.owner.thisType, cls, parentRefs, decls, selfInfo)
+ tempInfo.finalize(denot, parentRefs)
+
Checking.checkWellFormed(cls)
if (isDerivedValueClass(cls)) cls.setFlag(Final)
cls.setApplicableFlags(
@@ -934,13 +936,8 @@ class Namer { typer: Typer =>
}
def typeDefSig(tdef: TypeDef, sym: Symbol, tparamSyms: List[TypeSymbol])(implicit ctx: Context): Type = {
- val isDerived = tdef.rhs.isInstanceOf[untpd.DerivedTypeTree]
- //val toParameterize = tparamSyms.nonEmpty && !isDerived
- //val needsLambda = sym.allOverriddenSymbols.exists(_ is HigherKinded) && !isDerived
def abstracted(tp: Type): Type =
- if (tparamSyms.nonEmpty && !tp.isHK) tp.LambdaAbstract(tparamSyms)
- //else if (toParameterize) tp.parameterizeWith(tparamSyms)
- else tp
+ if (tparamSyms.nonEmpty) tp.LambdaAbstract(tparamSyms) else tp
val dummyInfo = abstracted(TypeBounds.empty)
sym.info = dummyInfo
@@ -954,7 +951,10 @@ class Namer { typer: Typer =>
//
// The scheme critically relies on an implementation detail of isRef, which
// inspects a TypeRef's info, instead of simply dealiasing alias types.
- val rhsType = abstracted(typedAheadType(tdef.rhs).tpe)
+
+ val isDerived = tdef.rhs.isInstanceOf[untpd.DerivedTypeTree]
+ val rhsBodyType = typedAheadType(tdef.rhs).tpe
+ val rhsType = if (isDerived) rhsBodyType else abstracted(rhsBodyType)
val unsafeInfo = rhsType match {
case bounds: TypeBounds => bounds
case alias => TypeAlias(alias, if (sym is Local) sym.variance else 0)
diff --git a/src/dotty/tools/dotc/util/DiffUtil.scala b/src/dotty/tools/dotc/util/DiffUtil.scala
index 6718ccbf8..b28f36382 100644
--- a/src/dotty/tools/dotc/util/DiffUtil.scala
+++ b/src/dotty/tools/dotc/util/DiffUtil.scala
@@ -8,8 +8,9 @@ object DiffUtil {
private final val ANSI_DEFAULT = "\u001B[0m"
private final val ANSI_RED = "\u001B[31m"
private final val ANSI_GREEN = "\u001B[32m"
- private final val ANSI_YELLOW = "\u001B[33m"
- private final val ANSI_MAGENTA = "\u001B[35m"
+
+ private final val DELETION_COLOR = ANSI_RED
+ private final val ADDITION_COLOR = ANSI_GREEN
def mkColoredCodeDiff(code: String, lastCode: String, printDiffDel: Boolean): String = {
import scala.collection.JavaConversions._
@@ -42,19 +43,19 @@ object DiffUtil {
delta.getType.toString match { // Issue #1355 forces us to use the toString
case "INSERT" =>
- lines(pos) = ANSI_GREEN + lines(pos)
+ lines(pos) = ADDITION_COLOR + lines(pos)
lines(endPos) = lines(endPos) + ANSI_DEFAULT
case "CHANGE" =>
val old = if (!printDiffDel) "" else
- ANSI_MAGENTA + delta.getOriginal.getLines.mkString + ANSI_DEFAULT
- lines(pos) = old + ANSI_YELLOW + lines(pos)
+ DELETION_COLOR + delta.getOriginal.getLines.mkString + ANSI_DEFAULT
+ lines(pos) = old + ADDITION_COLOR + lines(pos)
lines(endPos) = lines(endPos) + ANSI_DEFAULT
case "DELETE" if printDiffDel =>
val deleted = delta.getOriginal.getLines.mkString
if (!deleted.forall(Character.isWhitespace)) {
- lines(pos) = ANSI_RED + deleted + ANSI_DEFAULT + lines(pos)
+ lines(pos) = DELETION_COLOR + deleted + ANSI_DEFAULT + lines(pos)
}
case _ =>
diff --git a/src/scala/Function23.scala b/src/scala/Function23.scala
new file mode 100644
index 000000000..254772d53
--- /dev/null
+++ b/src/scala/Function23.scala
@@ -0,0 +1,21 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+package scala
+
+
+/** A function of 23 parameters. Used as a temporary fix until arity limit is dropped.
+ *
+ */
+trait Function23[-T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, -T9, -T10, -T11, -T12, -T13, -T14, -T15, -T16, -T17, -T18, -T19, -T20, -T21, -T22, -T23, +R] extends AnyRef { self =>
+ /** Apply the body of this function to the arguments.
+ * @return the result of function application.
+ */
+ def apply(v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7, v8: T8, v9: T9, v10: T10, v11: T11, v12: T12, v13: T13, v14: T14, v15: T15, v16: T16, v17: T17, v18: T18, v19: T19, v20: T20, v21: T21, v22: T22, v23: T23): R
+
+ override def toString() = "<function23>"
+}
diff --git a/src/scala/Function24.scala b/src/scala/Function24.scala
new file mode 100644
index 000000000..8af8ed995
--- /dev/null
+++ b/src/scala/Function24.scala
@@ -0,0 +1,21 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+package scala
+
+
+/** A function of 24 parameters. Used as a temporary fix until arity limit is dropped.
+ *
+ */
+trait Function24[-T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, -T9, -T10, -T11, -T12, -T13, -T14, -T15, -T16, -T17, -T18, -T19, -T20, -T21, -T22, -T23, -T24, +R] extends AnyRef { self =>
+ /** Apply the body of this function to the arguments.
+ * @return the result of function application.
+ */
+ def apply(v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7, v8: T8, v9: T9, v10: T10, v11: T11, v12: T12, v13: T13, v14: T14, v15: T15, v16: T16, v17: T17, v18: T18, v19: T19, v20: T20, v21: T21, v22: T22, v23: T23, v24: T24): R
+
+ override def toString() = "<function24>"
+}
diff --git a/src/strawman/collections/CollectionStrawMan4.scala b/src/strawman/collections/CollectionStrawMan4.scala
index ec20849ff..fb95ea59f 100644
--- a/src/strawman/collections/CollectionStrawMan4.scala
+++ b/src/strawman/collections/CollectionStrawMan4.scala
@@ -218,7 +218,7 @@ object CollectionStrawMan4 {
def fromIterable[B](coll: Iterable[B]): ListBuffer[B] = coll match {
case pd @ View.Partitioned(partition: View.Partition[B]) =>
partition.distribute(new ListBuffer[B]())
- pd.forced.get.asInstanceOf[ListBuffer[B]]
+ new ListBuffer[B] ++= pd.forced.get
case _ =>
new ListBuffer[B] ++= coll
}
diff --git a/test/dotc/scala-collections.whitelist b/test/dotc/scala-collections.whitelist
index 50a3f3479..29db48cf2 100644
--- a/test/dotc/scala-collections.whitelist
+++ b/test/dotc/scala-collections.whitelist
@@ -83,7 +83,7 @@
./scala-scala/src/library/scala/collection/immutable/Seq.scala
./scala-scala/src/library/scala/collection/mutable/IndexedSeq.scala
./scala-scala/src/library/scala/collection/mutable/ListBuffer.scala
-#./scala-scala/src/library/scala/collection/mutable/BufferLike.scala // works under junit, fails under partest, but can't see more info on the cause
+./scala-scala/src/library/scala/collection/mutable/BufferLike.scala
./scala-scala/src/library/scala/collection/mutable/ArrayBuilder.scala
diff --git a/test/dotty/partest/DPConsoleRunner.scala b/test/dotty/partest/DPConsoleRunner.scala
index baa62579c..d445722c9 100644
--- a/test/dotty/partest/DPConsoleRunner.scala
+++ b/test/dotty/partest/DPConsoleRunner.scala
@@ -134,6 +134,62 @@ class DPTestRunner(testFile: File, suiteRunner: DPSuiteRunner) extends nest.Runn
// override to provide DottyCompiler
override def newCompiler = new dotty.partest.DPDirectCompiler(this)
+ // Adapted from nest.Runner#javac because:
+ // - Our classpath handling is different and we need to pass extraClassPath
+ // to java to get the scala-library which is required for some java tests
+ // - The compiler output should be redirected to cLogFile, like the output of
+ // dotty itself
+ override def javac(files: List[File]): TestState = {
+ import fileManager._
+ import suiteRunner._
+ import FileManager.joinPaths
+ // compile using command-line javac compiler
+ val args = Seq(
+ javacCmdPath,
+ "-d",
+ outDir.getAbsolutePath,
+ "-classpath",
+ joinPaths(outDir :: extraClasspath ++ testClassPath)
+ ) ++ files.map(_.getAbsolutePath)
+
+ pushTranscript(args mkString " ")
+
+ val captured = StreamCapture(runCommand(args, cLogFile))
+ if (captured.result) genPass() else {
+ cLogFile appendAll captured.stderr
+ cLogFile appendAll captured.stdout
+ genFail("java compilation failed")
+ }
+ }
+
+ // FIXME: This is copy-pasted from nest.Runner where it is private
+ // Remove this once https://github.com/scala/scala-partest/pull/61 is merged
+ /** Runs command redirecting standard out and
+ * error out to output file.
+ */
+ def runCommand(args: Seq[String], outFile: File): Boolean = {
+ import scala.sys.process.{ Process, ProcessLogger }
+ //(Process(args) #> outFile !) == 0 or (Process(args) ! pl) == 0
+ val pl = ProcessLogger(outFile)
+ val nonzero = 17 // rounding down from 17.3
+ def run: Int = {
+ val p = Process(args) run pl
+ try p.exitValue
+ catch {
+ case e: InterruptedException =>
+ NestUI verbose s"Interrupted waiting for command to finish (${args mkString " "})"
+ p.destroy
+ nonzero
+ case t: Throwable =>
+ NestUI verbose s"Exception waiting for command to finish: $t (${args mkString " "})"
+ p.destroy
+ throw t
+ }
+ finally pl.close()
+ }
+ (pl buffer run) == 0
+ }
+
// override to provide default dotty flags from file in directory
override def flagsForCompilation(sources: List[File]): List[String] = {
val specificFlags = super.flagsForCompilation(sources)
@@ -245,32 +301,6 @@ class DPTestRunner(testFile: File, suiteRunner: DPSuiteRunner) extends nest.Runn
} getOrElse true
}
- // override because Dotty currently doesn't handle separate compilation well,
- // so we ignore groups (tests suffixed with _1 and _2)
- override def groupedFiles(sources: List[File]): List[List[File]] = {
- val grouped = sources groupBy (_.group)
- val flatGroup = List(grouped.keys.toList.sorted.map({ k => grouped(k) sortBy (_.getName) }).flatten)
- try { // try/catch because of bug in partest that throws exception
- if (flatGroup != super.groupedFiles(sources))
- throw new java.lang.UnsupportedOperationException()
- } catch {
- case e: java.lang.UnsupportedOperationException =>
- val genlogFWriter = new FileWriter(DPConfig.genLog.jfile, true)
- val genlogWriter = new PrintWriter(genlogFWriter, true)
- genlogWriter.println("Warning: Overriding compilation groups for tests: " + sources)
- genlogWriter.close
- genlogFWriter.close
- }
- flatGroup
- }
-
- // override to avoid separate compilation of scala and java sources
- override def mixedCompileGroup(allFiles: List[File]): List[CompileRound] = List(OnlyDotty(allFiles))
- case class OnlyDotty(fs: List[File]) extends CompileRound {
- def description = s"dotc $fsString"
- lazy val result = { pushTranscript(description) ; attemptCompile(fs) }
- }
-
// override to add dotty and scala jars to classpath
override def extraClasspath = suiteRunner.fileManager.asInstanceOf[DottyFileManager].extraJarList ::: super.extraClasspath
diff --git a/test/test/CompilerTest.scala b/test/test/CompilerTest.scala
index 1d8fb9bf5..56b9e1099 100644
--- a/test/test/CompilerTest.scala
+++ b/test/test/CompilerTest.scala
@@ -410,7 +410,8 @@ abstract class CompilerTest {
nr: Int = 0, oldOutput: String = defaultOutputDir): Unit = {
val partestOutput = dest.jfile.getParentFile + JFile.separator + dest.stripExtension + "-" + kind + ".obj"
- val flags = oldFlags.map(f => if (f == oldOutput) partestOutput else f)
+ val flags = oldFlags.map(f => if (f == oldOutput) partestOutput else f) ++
+ List(s"-classpath $partestOutput") // Required for separate compilation tests
getExisting(dest).isDifferent(source, flags, nerr) match {
case NotExists => copyFiles(source, dest, partestOutput, flags, nerr, kind)
diff --git a/test/test/ShowClassTests.scala b/test/test/ShowClassTests.scala
index 5187de0bf..d5e59c169 100644
--- a/test/test/ShowClassTests.scala
+++ b/test/test/ShowClassTests.scala
@@ -96,11 +96,6 @@ class ShowClassTests extends DottyTest {
}
@Test
- def loadJavaClasses() = {
- showPackage("scala.tools.jline", 0)
- }
-
- @Test
def loadMoreClasses() = {
showClasses("scala.collection.JavaConversions")
showClasses("scala.collection.convert.Wrappers")
diff --git a/tests/pos/java-interop/t1263/Test.java b/tests/pending/pos/java-interop/t1263/Test.java
index 1718a9909..1718a9909 100644
--- a/tests/pos/java-interop/t1263/Test.java
+++ b/tests/pending/pos/java-interop/t1263/Test.java
diff --git a/tests/pos/java-interop/t1263/test.scala b/tests/pending/pos/java-interop/t1263/test.scala
index 92d8c1cdf..92d8c1cdf 100644
--- a/tests/pos/java-interop/t1263/test.scala
+++ b/tests/pending/pos/java-interop/t1263/test.scala
diff --git a/tests/pos/java-interop/t1745/J.java b/tests/pending/pos/java-interop/t1745/J.java
index 8444eabb2..8444eabb2 100644
--- a/tests/pos/java-interop/t1745/J.java
+++ b/tests/pending/pos/java-interop/t1745/J.java
diff --git a/tests/pos/java-interop/t1745/S.scala b/tests/pending/pos/java-interop/t1745/S.scala
index 84c437133..84c437133 100644
--- a/tests/pos/java-interop/t1745/S.scala
+++ b/tests/pending/pos/java-interop/t1745/S.scala
diff --git a/tests/pos/annot.scala b/tests/pos/annot.scala
index e6e4f8051..dec6af945 100644
--- a/tests/pos/annot.scala
+++ b/tests/pos/annot.scala
@@ -9,7 +9,7 @@ class Test {
@SuppressWarnings(Array("hi", "foo")) def foo2() = ??? //can be deferred as there is a non-generic method
- @SuppressWarnings("hi") def foo3() = ??? // can be written in java and is serialized this way in bytecode. doesn't typecheck
+ @SuppressWarnings(Array("hi")) def foo3() = ??? // can be written in java and is serialized this way in bytecode. doesn't typecheck
@Transient(false) def bar = ???
diff --git a/tests/pos/i1385.scala b/tests/pos/i1385.scala
new file mode 100644
index 000000000..87a0127cb
--- /dev/null
+++ b/tests/pos/i1385.scala
@@ -0,0 +1,7 @@
+object Test {
+def foo22[T](c1:T, c2:T, c3:T, c4:T, c5:T, c6:T, c7:T, c8:T, c9:T, c10:T, c11:T, c12:T, c13:T, c14:T, c15:T, c16:T, c17:T, c18:T, c19:T, c20:T, c21:T, c22:T): Int => T = {
+ (a: Int) => { // This lambda ends with 23 parameters (c1 to c22 and a)
+ c22; c21; c20; c19; c18; c17; c16; c15; c14; c13; c12; c11; c10; c9; c8; c7; c6; c5; c4; c3; c2; c1
+ }
+ }
+}
diff --git a/tests/pos/i1401.scala b/tests/pos/i1401.scala
new file mode 100644
index 000000000..140d78e7f
--- /dev/null
+++ b/tests/pos/i1401.scala
@@ -0,0 +1,25 @@
+package i1401
+
+trait Subtractable[A, +Repr <: Subtractable[A, Repr]] {
+ def -(elem: A): Repr
+}
+
+trait BufferLike[BA, +This <: BufferLike[BA, This] with Buffer[BA]]
+ extends Subtractable[BA, This]
+{ self : This =>
+
+ /* Without fix-#1401:
+ *
+ error: overriding method - in trait Subtractable of type (elem: A)This & i1401.Buffer[A];
+ method - of type (elem: BA)This has incompatible type
+ def -(elem: BA): This
+ ^
+ one error found
+ */
+ def -(elem: BA): This
+}
+
+trait Buffer[A] extends BufferLike[A, Buffer[A]]
+
+
+
diff --git a/tests/pos/java-interop/volatile/volatile.java b/tests/pos/java-interop/volatile/Foo.java
index c6a607b4d..c6a607b4d 100644
--- a/tests/pos/java-interop/volatile/volatile.java
+++ b/tests/pos/java-interop/volatile/Foo.java
diff --git a/tests/pos/nestedLambdas.scala b/tests/pos/nestedLambdas.scala
new file mode 100644
index 000000000..58be1ae2f
--- /dev/null
+++ b/tests/pos/nestedLambdas.scala
@@ -0,0 +1,21 @@
+class Test {
+
+ type T = [X] -> [Y] -> (X, Y)
+
+ type A[X] = [Y] -> (X, Y)
+
+ type B[X] = (X, X)
+
+ val x: T[Int][Boolean] = ???
+
+ val y: A[Int][Boolean] = x
+
+ def f[X <: T[Int]] = ???
+
+ f[A[Int]]
+
+ def g[X <: T] = ???
+
+ g[A]
+
+}
diff --git a/tests/run/colltest4/CollectionStrawMan4_1.scala b/tests/run/colltest4/CollectionStrawMan4_1.scala
index 874f67a2d..8f0bdc841 100644
--- a/tests/run/colltest4/CollectionStrawMan4_1.scala
+++ b/tests/run/colltest4/CollectionStrawMan4_1.scala
@@ -1,3 +1,4 @@
+package colltest4
package strawman.collections
import Predef.{augmentString => _, wrapString => _, _}
@@ -216,7 +217,7 @@ object CollectionStrawMan4 {
def fromIterable[B](coll: Iterable[B]): ListBuffer[B] = coll match {
case pd @ View.Partitioned(partition: View.Partition[B]) =>
partition.distribute(new ListBuffer[B]())
- pd.forced.get.asInstanceOf[ListBuffer[B]]
+ new ListBuffer[B] ++= pd.forced.get
case _ =>
new ListBuffer[B] ++= coll
}
diff --git a/tests/run/colltest4/CollectionTests_2.scala b/tests/run/colltest4/CollectionTests_2.scala
index 0961180ed..45da9d8a5 100644
--- a/tests/run/colltest4/CollectionTests_2.scala
+++ b/tests/run/colltest4/CollectionTests_2.scala
@@ -2,8 +2,8 @@ import Predef.{augmentString => _, wrapString => _, _}
import scala.reflect.ClassTag
object Test {
- import strawman.collections._
- import CollectionStrawMan5._
+ import colltest4.strawman.collections._
+ import CollectionStrawMan4._
def seqOps(xs: Seq[Int]) = {
val x1 = xs.foldLeft("")(_ + _)
diff --git a/tests/run/colltest5/CollectionStrawMan5_1.scala b/tests/run/colltest5/CollectionStrawMan5_1.scala
index 1a89d9659..bb6ed4426 100644
--- a/tests/run/colltest5/CollectionStrawMan5_1.scala
+++ b/tests/run/colltest5/CollectionStrawMan5_1.scala
@@ -1,3 +1,4 @@
+package colltest5
package strawman.collections
import Predef.{augmentString => _, wrapString => _, _}
diff --git a/tests/run/colltest5/CollectionTests_2.scala b/tests/run/colltest5/CollectionTests_2.scala
index 0961180ed..1a0bf37ac 100644
--- a/tests/run/colltest5/CollectionTests_2.scala
+++ b/tests/run/colltest5/CollectionTests_2.scala
@@ -2,7 +2,7 @@ import Predef.{augmentString => _, wrapString => _, _}
import scala.reflect.ClassTag
object Test {
- import strawman.collections._
+ import colltest5.strawman.collections._
import CollectionStrawMan5._
def seqOps(xs: Seq[Int]) = {
diff --git a/tests/run/i1284.scala b/tests/run/i1284.scala
new file mode 100644
index 000000000..f8b9de0de
--- /dev/null
+++ b/tests/run/i1284.scala
@@ -0,0 +1,8 @@
+case object A
+case object B
+
+object Test {
+ def main(args: Array[String]): Unit = {
+ assert(Array(A, B).deep.toString == "Array(A, B)")
+ }
+}
diff --git a/tests/run/i1354.check b/tests/run/i1354.check
new file mode 100644
index 000000000..ce686866d
--- /dev/null
+++ b/tests/run/i1354.check
@@ -0,0 +1,6 @@
+0
+false
+5
+1
+true
+true
diff --git a/tests/run/i1354.scala b/tests/run/i1354.scala
new file mode 100644
index 000000000..08b129e4e
--- /dev/null
+++ b/tests/run/i1354.scala
@@ -0,0 +1,27 @@
+object Test {
+ def foo(a: Int | Double) = a match {
+ case a: (Float | Boolean) => 1
+ case _ => 0
+ }
+
+ def typeTest(a: Int | Double) = a.isInstanceOf[Float | Boolean] // false
+
+ def typeCast(a: Int | Double) = a.asInstanceOf[Float | Boolean] // no error
+
+ def main(args: Array[String]): Unit = {
+ println(foo(4))
+
+ println(typeTest(4))
+
+ println(typeCast(5))
+
+ Boolean.box(true) match {
+ case a: (Float | Boolean) => println(1)
+ case _ => println(0)
+ }
+
+ println(Boolean.box(true).isInstanceOf[Float | Boolean])
+
+ println(Boolean.box(true).asInstanceOf[Float | Boolean])
+ }
+}