diff options
24 files changed, 156 insertions, 93 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 @@ -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 1c1c72671..d0c4cc02c 100644 --- a/src/dotty/tools/dotc/config/ScalaSettings.scala +++ b/src/dotty/tools/dotc/config/ScalaSettings.scala @@ -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/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/Types.scala b/src/dotty/tools/dotc/core/Types.scala index 46da20712..054c67e7e 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -2656,7 +2656,6 @@ object Types { cachedSuper } - /* (Not needed yet) */ def lowerBound(implicit ctx: Context) = tycon.stripTypeVar match { case tycon: TypeRef => tycon.info match { 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/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/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 26c8f5c95..d1074364c 100644 --- a/src/dotty/tools/dotc/typer/Namer.scala +++ b/src/dotty/tools/dotc/typer/Namer.scala @@ -936,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 @@ -956,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/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/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/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]) + } +} |