From ad7333eb7ed2d891789f187c880d6bc64b1d9c26 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 14 Dec 2015 18:06:55 +0100 Subject: [PATCH 01/22] Print bounds of TypeVars only when option is enabled. --- src/dotty/tools/dotc/config/ScalaSettings.scala | 1 + src/dotty/tools/dotc/printing/PlainPrinter.scala | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/dotty/tools/dotc/config/ScalaSettings.scala b/src/dotty/tools/dotc/config/ScalaSettings.scala index 62b0713724ab..b1f6ca61a206 100644 --- a/src/dotty/tools/dotc/config/ScalaSettings.scala +++ b/src/dotty/tools/dotc/config/ScalaSettings.scala @@ -173,6 +173,7 @@ class ScalaSettings extends Settings.SettingGroup { val Ypatmatdebug = BooleanSetting("-Ypatmat-debug", "Trace pattern matching translation.") val Yexplainlowlevel = BooleanSetting("-Yexplain-lowlevel", "When explaining type errors, show types at a lower level.") val YnoDoubleBindings = BooleanSetting("-Yno-double-bindings", "Assert no namedtype is bound twice (should be enabled only if program is error-free).") + val YshowVarBounds = BooleanSetting("-YshowVarBounds", "Print type variables with their bounds") val optimise = BooleanSetting("-optimise", "Generates faster bytecode by applying optimisations to the program") withAbbreviation "-optimize" diff --git a/src/dotty/tools/dotc/printing/PlainPrinter.scala b/src/dotty/tools/dotc/printing/PlainPrinter.scala index 9e5ab5d8ccbe..8f9d70d4c4db 100644 --- a/src/dotty/tools/dotc/printing/PlainPrinter.scala +++ b/src/dotty/tools/dotc/printing/PlainPrinter.scala @@ -170,7 +170,8 @@ class PlainPrinter(_ctx: Context) extends Printer { val bounds = if (constr.contains(tp)) constr.fullBounds(tp.origin)(ctx.addMode(Mode.Printing)) else TypeBounds.empty - "(" ~ toText(tp.origin) ~ "?" ~ toText(bounds) ~ ")" + if (ctx.settings.YshowVarBounds.value) "(" ~ toText(tp.origin) ~ "?" ~ toText(bounds) ~ ")" + else toText(tp.origin) } case tp: LazyRef => "LazyRef(" ~ toTextGlobal(tp.ref) ~ ")" From 300992407ca0e03eeda93cbb1a34ebc5907586b5 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Tue, 15 Dec 2015 14:01:15 +0100 Subject: [PATCH 02/22] Better error message in splitter --- src/dotty/tools/dotc/transform/Splitter.scala | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/dotty/tools/dotc/transform/Splitter.scala b/src/dotty/tools/dotc/transform/Splitter.scala index 62a080f37001..410b412e05d9 100644 --- a/src/dotty/tools/dotc/transform/Splitter.scala +++ b/src/dotty/tools/dotc/transform/Splitter.scala @@ -47,7 +47,10 @@ class Splitter extends MiniPhaseTransform { thisTransform => if (!mbr.isOverloaded) mbr.asSingleDenotation else tree.tpe match { case tref: TermRefWithSignature => mbr.atSignature(tref.sig) - case _ => ctx.error(s"cannot disambiguate overloaded member $mbr"); NoDenotation + case _ => + def alts = mbr.alternatives.map(alt => i"$alt: ${alt.info}").mkString(", ") + ctx.error(s"cannot disambiguate overloaded members $alts", tree.pos) + NoDenotation } } From ee76fda79d446a2d6db51cb4af032a8e92936013 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Tue, 15 Dec 2015 14:05:46 +0100 Subject: [PATCH 03/22] Dont push `|' inside refined types. As the comment explains, this is not sound. --- src/dotty/tools/dotc/core/TypeComparer.scala | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/dotty/tools/dotc/core/TypeComparer.scala b/src/dotty/tools/dotc/core/TypeComparer.scala index 163fa4919bef..b3d926a291a3 100644 --- a/src/dotty/tools/dotc/core/TypeComparer.scala +++ b/src/dotty/tools/dotc/core/TypeComparer.scala @@ -1106,18 +1106,15 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling { NoType } - /** Try to distribute `|` inside type, detect and handle conflicts */ + /** Try to distribute `|` inside type, detect and handle conflicts. + * Note that, unlike for `&`, a disjunction cannot be pushed into + * a refined or applied type. Example: + * + * List[T] | List[U] is not the same as List[T | U]. + * + * The rhs is a proper supertype of the lhs. + */ private def distributeOr(tp1: Type, tp2: Type): Type = tp1 match { - case tp1: RefinedType => - tp2 match { - case tp2: RefinedType if tp1.refinedName == tp2.refinedName => - tp1.derivedRefinedType( - tp1.parent | tp2.parent, - tp1.refinedName, - tp1.refinedInfo | tp2.refinedInfo.substRefinedThis(tp2, RefinedThis(tp1))) - case _ => - NoType - } case tp1: TypeBounds => tp2 match { case tp2: TypeBounds => tp1 | tp2 From 9b630fae0d3c772610a2c58d9dbb4b95710c8c68 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Tue, 15 Dec 2015 14:11:42 +0100 Subject: [PATCH 04/22] Revise alias rules in type comparisons. The fix solves two cases where we had a deep subtype before. --- src/dotty/tools/dotc/core/TypeComparer.scala | 76 ++++++++++---------- test/dotc/tests.scala | 2 - tests/{pos-special => pos}/sets.scala | 0 tests/{pos-special => pos}/t2613.scala | 0 4 files changed, 36 insertions(+), 42 deletions(-) rename tests/{pos-special => pos}/sets.scala (100%) rename tests/{pos-special => pos}/t2613.scala (100%) diff --git a/src/dotty/tools/dotc/core/TypeComparer.scala b/src/dotty/tools/dotc/core/TypeComparer.scala index b3d926a291a3..d14875877a07 100644 --- a/src/dotty/tools/dotc/core/TypeComparer.scala +++ b/src/dotty/tools/dotc/core/TypeComparer.scala @@ -144,47 +144,41 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling { def compareNamed(tp1: Type, tp2: NamedType): Boolean = { implicit val ctx: Context = this.ctx tp2.info match { - case info2: TypeAlias if tp2.prefix.isStable => - // If prefix is not stable (i.e. is not a path), then we have a true - // projection `T # A` which is treated as the existential type - // `ex(x: T)x.A`. We need to deal with the existential first before - // following the alias. If we did follow the alias we could be - // unsound as well as incomplete. An example of this was discovered in Iter2.scala. - // It failed to validate the subtype test - // - // (([+X] -> Seq[X]) & C)[SA] <: C[SA] - // - // Both sides are projections of $Apply. The left $Apply does have an - // aliased info, namely, Seq[SA]. But that is not a subtype of C[SA]. - // The problem is that, with the prefix not being a path, an aliased info - // does not necessarily give all of the information of the original projection. - // So we can't follow the alias without a backup strategy. If the alias - // would appear on the right then I believe this can be turned into a case - // of unsoundness. - isSubType(tp1, info2.alias) + case info2: TypeAlias => isSubType(tp1, info2.alias) case _ => tp1 match { case tp1: NamedType => tp1.info match { - case info1: TypeAlias if tp1.prefix.isStable => - isSubType(info1.alias, tp2) + case info1: TypeAlias => + if (isSubType(info1.alias, tp2)) return true + if (tp1.prefix.isStable) return false + // If tp1.prefix is stable, the alias does contain all information about the original ref, so + // there's no need to try something else. (This is important for performance). + // To see why we cannot in general stop here, consider: + // + // trait C { type A } + // trait D { type A = String } + // (C & D)#A <: C#A + // + // Following the alias leads to the judgment `String <: C#A` which is false. + // However the original judgment should be true. case _ => - val sym1 = tp1.symbol - if ((sym1 ne NoSymbol) && (sym1 eq tp2.symbol)) - ctx.erasedTypes || - sym1.isStaticOwner || - isSubType(tp1.prefix, tp2.prefix) || - thirdTryNamed(tp1, tp2) - else - ( (tp1.name eq tp2.name) - && isSubType(tp1.prefix, tp2.prefix) - && tp1.signature == tp2.signature - && !tp1.isInstanceOf[WithFixedSym] - && !tp2.isInstanceOf[WithFixedSym] - ) || - compareHK(tp1, tp2, inOrder = true) || - compareHK(tp2, tp1, inOrder = false) || - thirdTryNamed(tp1, tp2) } + val sym1 = tp1.symbol + if ((sym1 ne NoSymbol) && (sym1 eq tp2.symbol)) + ctx.erasedTypes || + sym1.isStaticOwner || + isSubType(tp1.prefix, tp2.prefix) || + thirdTryNamed(tp1, tp2) + else + ( (tp1.name eq tp2.name) + && isSubType(tp1.prefix, tp2.prefix) + && tp1.signature == tp2.signature + && !tp1.isInstanceOf[WithFixedSym] + && !tp2.isInstanceOf[WithFixedSym] + ) || + compareHK(tp1, tp2, inOrder = true) || + compareHK(tp2, tp1, inOrder = false) || + thirdTryNamed(tp1, tp2) case _ => compareHK(tp2, tp1, inOrder = false) || secondTry(tp1, tp2) @@ -258,11 +252,13 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling { private def secondTry(tp1: Type, tp2: Type): Boolean = tp1 match { case tp1: NamedType => tp1.info match { - case info1: TypeAlias => isSubType(info1.alias, tp2) + case info1: TypeAlias => + if (isSubType(info1.alias, tp2)) return true + if (tp1.prefix.isStable) return false case _ => - compareHK(tp1, tp2, inOrder = true) || - thirdTry(tp1, tp2) } + compareHK(tp1, tp2, inOrder = true) || + thirdTry(tp1, tp2) case tp1: PolyParam => def flagNothingBound = { if (!frozenConstraint && tp2.isRef(defn.NothingClass) && state.isGlobalCommittable) { @@ -1106,7 +1102,7 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling { NoType } - /** Try to distribute `|` inside type, detect and handle conflicts. + /** Try to distribute `|` inside type, detect and handle conflicts * Note that, unlike for `&`, a disjunction cannot be pushed into * a refined or applied type. Example: * diff --git a/test/dotc/tests.scala b/test/dotc/tests.scala index f5012efe92f4..3787a9c98cb7 100644 --- a/test/dotc/tests.scala +++ b/test/dotc/tests.scala @@ -100,8 +100,6 @@ class tests extends CompilerTest { @Test def pos_all = compileFiles(posDir) // twice omitted to make tests run faster - @Test def pos_sets = compileFile(posSpecialDir, "sets")(allowDeepSubtypes) - @Test def pos_t2613 = compileFile(posSpecialDir, "t2613")(allowDeepSubtypes) @Test def pos_i871 = compileFile(posSpecialDir, "i871", scala2mode) @Test def pos_variancesConstr = compileFile(posSpecialDir, "variances-constr", scala2mode) diff --git a/tests/pos-special/sets.scala b/tests/pos/sets.scala similarity index 100% rename from tests/pos-special/sets.scala rename to tests/pos/sets.scala diff --git a/tests/pos-special/t2613.scala b/tests/pos/t2613.scala similarity index 100% rename from tests/pos-special/t2613.scala rename to tests/pos/t2613.scala From fd9d3f3944852da09278196ae69d99af37e7bb13 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Tue, 15 Dec 2015 15:37:48 +0100 Subject: [PATCH 05/22] Optionally rewrite projections. --- src/dotty/tools/dotc/config/Config.scala | 9 +++++++ src/dotty/tools/dotc/core/Types.scala | 34 ++++++++++++++++++++++-- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/src/dotty/tools/dotc/config/Config.scala b/src/dotty/tools/dotc/config/Config.scala index 7e3615416b85..cf43d277ea2c 100644 --- a/src/dotty/tools/dotc/config/Config.scala +++ b/src/dotty/tools/dotc/config/Config.scala @@ -87,6 +87,15 @@ object Config { /** Check that certain types cannot be created in erasedTypes phases */ final val checkUnerased = true + /** In `derivedSelect`, rewrite + * + * (S & T)#A --> S#A & T#A + * (S | T)#A --> S#A | T#A + * + * Not sure whether this is useful. Preliminary measurements show a slowdown of about + * 7% for the build when this option is enabled. + */ + final val splitProjections = false /** Initial size of superId table */ final val InitialSuperIdsSize = 4096 diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala index 21b74e07b866..52a69e5fd848 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -1533,9 +1533,40 @@ object Types { ctx.underlyingRecursions -= 1 } + /** A selection of the same kind, but with potentially a differet prefix. + * The following normalizations are performed for type selections T#A: + * + * 1. If Config.splitProjections is true: + * + * (S & T)#A --> S#A & T#A + * (S | T)#A --> S#A | T#A + * + * 2. If A is bound to an alias `= B` in T + * + * T#A --> B + */ def derivedSelect(prefix: Type)(implicit ctx: Context): Type = if (prefix eq this.prefix) this else { + if (Config.splitProjections && isType) + prefix match { + case prefix: AndType => + def isMissing(tp: Type) = tp match { + case tp: TypeRef => !tp.info.exists + case _ => false + } + val derived1 = derivedSelect(prefix.tp1) + val derived2 = derivedSelect(prefix.tp2) + return ( + if (isMissing(derived1)) derived2 + else if (isMissing(derived2)) derived1 + else prefix.derivedAndType(derived1, derived2)) + case prefix: OrType => + val derived1 = derivedSelect(prefix.tp1) + val derived2 = derivedSelect(prefix.tp2) + return prefix.derivedOrType(derived1, derived2) + case _ => + } val res = prefix.lookupRefined(name) if (res.exists) res else if (name == tpnme.hkApply && prefix.classNotLambda) { @@ -1543,8 +1574,7 @@ object Types { // `C { type hk$0 = T0; ...; type hk$n = Tn } # $Apply` // where C is a class. In that case we eta expand `C`. derivedSelect(prefix.EtaExpandCore(this.prefix.typeConstructor.typeParams)) - } - else newLikeThis(prefix) + } else newLikeThis(prefix) } /** Create a NamedType of the same kind as this type, but with a new prefix. From 570cf0f84b0daa78a6234ead4b5b3c5b58b5db79 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Tue, 15 Dec 2015 15:51:02 +0100 Subject: [PATCH 06/22] Fix layout --- src/dotty/tools/dotc/core/Types.scala | 34 +++++++++++++-------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala index 52a69e5fd848..d1d202855102 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -1550,23 +1550,23 @@ object Types { else { if (Config.splitProjections && isType) prefix match { - case prefix: AndType => - def isMissing(tp: Type) = tp match { - case tp: TypeRef => !tp.info.exists - case _ => false - } - val derived1 = derivedSelect(prefix.tp1) - val derived2 = derivedSelect(prefix.tp2) - return ( - if (isMissing(derived1)) derived2 - else if (isMissing(derived2)) derived1 - else prefix.derivedAndType(derived1, derived2)) - case prefix: OrType => - val derived1 = derivedSelect(prefix.tp1) - val derived2 = derivedSelect(prefix.tp2) - return prefix.derivedOrType(derived1, derived2) - case _ => - } + case prefix: AndType => + def isMissing(tp: Type) = tp match { + case tp: TypeRef => !tp.info.exists + case _ => false + } + val derived1 = derivedSelect(prefix.tp1) + val derived2 = derivedSelect(prefix.tp2) + return ( + if (isMissing(derived1)) derived2 + else if (isMissing(derived2)) derived1 + else prefix.derivedAndType(derived1, derived2)) + case prefix: OrType => + val derived1 = derivedSelect(prefix.tp1) + val derived2 = derivedSelect(prefix.tp2) + return prefix.derivedOrType(derived1, derived2) + case _ => + } val res = prefix.lookupRefined(name) if (res.exists) res else if (name == tpnme.hkApply && prefix.classNotLambda) { From d362455add3fcfb99d87c1e8290d9f6e1bf23654 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Fri, 18 Dec 2015 18:50:18 +0100 Subject: [PATCH 07/22] Fix higher-kinded unions and intersections Since And/Or type themselves are parameterless, their the union and intersection of hgiher-kinded types has to be treated specially: The types have to be pulled under a common lambda. --- .../tools/dotc/core/TypeApplications.scala | 45 ++++++++++++ src/dotty/tools/dotc/core/TypeComparer.scala | 71 ++++++++++--------- src/dotty/tools/dotc/typer/TypeAssigner.scala | 2 +- 3 files changed, 83 insertions(+), 35 deletions(-) diff --git a/src/dotty/tools/dotc/core/TypeApplications.scala b/src/dotty/tools/dotc/core/TypeApplications.scala index fbab4ee39744..9a12d263525d 100644 --- a/src/dotty/tools/dotc/core/TypeApplications.scala +++ b/src/dotty/tools/dotc/core/TypeApplications.scala @@ -173,8 +173,45 @@ object TypeApplications { if (tparams.isEmpty) args else args.zipWithConserve(tparams)((arg, tparam) => arg.etaExpandIfHK(tparam.infoOrCompleter)) + /** The references `.this.$hk0, ..., .this.$hk`. */ def argRefs(rt: RefinedType, n: Int)(implicit ctx: Context) = List.range(0, n).map(i => RefinedThis(rt).select(tpnme.hkArg(i))) + + /** Merge `tp1` and `tp2` under a common lambda, combining them with `op`. + * @param tparams1 The type parameters of `tp1` + * @param tparams2 The type parameters of `tp2` + * Produces the type lambda + * + * [v1 X1 B1, ..., vn Xn Bn] -> op(tp1[X1, ..., Xn], tp2[X1, ..., Xn]) + * + * where + * + * - variances `vi` are the variances of corresponding type parameters for `tp1` + * or `tp2`, or are 0 of the latter disagree. + * - bounds `Bi` are the intersection of the corresponding type parameter bounds + * of `tp1` and `tp2`. + */ + def hkCombine(tp1: Type, tp2: Type, + tparams1: List[TypeSymbol], tparams2: List[TypeSymbol], op: (Type, Type) => Type) + (implicit ctx: Context): Type = { + val variances = (tparams1, tparams2).zipped.map { (tparam1, tparam2) => + val v1 = tparam1.variance + val v2 = tparam2.variance + if (v1 == v2) v1 else 0 + } + val bounds: List[RefinedType => TypeBounds] = + (tparams1, tparams2).zipped.map { (tparam1, tparam2) => + val b1: RefinedType => TypeBounds = + tp1.memberInfo(tparam1).bounds.internalizeFrom(tparams1) + val b2: RefinedType => TypeBounds = + tp2.memberInfo(tparam2).bounds.internalizeFrom(tparams2) + (rt: RefinedType) => b1(rt) & b2(rt) + } + val app1: RefinedType => Type = rt => tp1.appliedTo(argRefs(rt, tparams1.length)) + val app2: RefinedType => Type = rt => tp2.appliedTo(argRefs(rt, tparams2.length)) + val body = (rt: RefinedType) => op(app1(rt), app2(rt)) + TypeLambda(variances, bounds, body) + } } import TypeApplications._ @@ -273,6 +310,14 @@ class TypeApplications(val self: Type) extends AnyVal { false } + /** Replace references to type parameters with references to hk arguments `this.$hk_i` + * Care is needed not to cause cyclic reference errors, hence `SafeSubstMap`. + */ + private[TypeApplications] def internalizeFrom[T <: Type](tparams: List[Symbol])(implicit ctx: Context): RefinedType => T = + (rt: RefinedType) => + new ctx.SafeSubstMap(tparams , argRefs(rt, tparams.length)) + .apply(self).asInstanceOf[T] + /** Lambda abstract `self` with given type parameters. Examples: * * type T[X] = U becomes type T = [X] -> U diff --git a/src/dotty/tools/dotc/core/TypeComparer.scala b/src/dotty/tools/dotc/core/TypeComparer.scala index d14875877a07..1e90bd6c89c0 100644 --- a/src/dotty/tools/dotc/core/TypeComparer.scala +++ b/src/dotty/tools/dotc/core/TypeComparer.scala @@ -176,11 +176,11 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling { && !tp1.isInstanceOf[WithFixedSym] && !tp2.isInstanceOf[WithFixedSym] ) || - compareHK(tp1, tp2, inOrder = true) || - compareHK(tp2, tp1, inOrder = false) || + compareHkApply(tp1, tp2, inOrder = true) || + compareHkApply(tp2, tp1, inOrder = false) || thirdTryNamed(tp1, tp2) case _ => - compareHK(tp2, tp1, inOrder = false) || + compareHkApply(tp2, tp1, inOrder = false) || secondTry(tp1, tp2) } } @@ -257,7 +257,7 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling { if (tp1.prefix.isStable) return false case _ => } - compareHK(tp1, tp2, inOrder = true) || + compareHkApply(tp1, tp2, inOrder = true) || thirdTry(tp1, tp2) case tp1: PolyParam => def flagNothingBound = { @@ -352,8 +352,6 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling { isSubType(tp1, tp2.parent) && (name2 == nme.WILDCARD || hasMatchingMember(name2, tp1, tp2)) } - def etaExpandedSubType(tp1: Type) = - isSubType(tp1.typeConstructor.EtaExpand(tp2.typeParams), tp2) def compareRefined: Boolean = { val tp1w = tp1.widen val skipped2 = skipMatching(tp1w, tp2) @@ -367,7 +365,7 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling { case _ => compareRefinedSlow || fourthTry(tp1, tp2) || - needsEtaLift(tp1, tp2) && testLifted(tp1, tp2, tp2.typeParams, etaExpandedSubType) + compareHkLambda(tp2, tp1, inOrder = false) } else // fast path, in particular for refinements resulting from parameterization. isSubType(tp1, skipped2) && @@ -487,10 +485,7 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling { } isNewSubType(tp1.underlying.widenExpr, tp2) || comparePaths case tp1: RefinedType => - isNewSubType(tp1.parent, tp2) || - needsEtaLift(tp2, tp1) && - tp2.typeParams.length == tp1.typeParams.length && - isSubType(tp1, tp2.EtaExpand(tp1.typeParams)) + isNewSubType(tp1.parent, tp2) || compareHkLambda(tp1, tp2, inOrder = true) case AndType(tp11, tp12) => // Rewrite (T111 | T112) & T12 <: T2 to (T111 & T12) <: T2 and (T112 | T12) <: T2 // and analogously for T11 & (T121 | T122) & T12 <: T2 @@ -521,14 +516,6 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling { false } - /** Does `tp` need to be eta lifted to be comparable to `target`? - * This is the case if: - * - target is a type lambda, and - * - `tp` is eta-expandable (i.e. is a non-lambda class ref) - */ - private def needsEtaLift(tp: Type, target: RefinedType): Boolean = - target.refinedName == tpnme.hkApply && tp.isEtaExpandable - /** Test whether `tp1` has a base type of the form `B[T1, ..., Tn]` where * - `B` derives from one of the class symbols of `tp2`, * - the type parameters of `B` match one-by-one the variances of `tparams`, @@ -570,7 +557,7 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling { * * (4) If `inOrder`, test `projection <: other` else test `other <: projection`. */ - def compareHK(projection: NamedType, other: Type, inOrder: Boolean): Boolean = { + def compareHkApply(projection: NamedType, other: Type, inOrder: Boolean): Boolean = { def tryInfer(tp: Type): Boolean = ctx.traceIndented(i"compareHK($projection, $other, inOrder = $inOrder, constr = $tp)", subtyping) { tp match { case tp: TypeVar => tryInfer(tp.underlying) @@ -605,6 +592,18 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling { tryInfer(projection.prefix.typeConstructor.dealias) } + /** Compare type lambda with non-lambda type. */ + def compareHkLambda(rt: RefinedType, other: Type, inOrder: Boolean) = rt match { + case TypeLambda(vs, args, body) => + other.isInstanceOf[TypeRef] && + args.length == other.typeParams.length && { + val applied = other.appliedTo(argRefs(rt, args.length)) + if (inOrder) isSubType(body, applied) else isSubType(applied, body) + } + case _ => + false + } + /** Returns true iff either `tp11 <:< tp21` or `tp12 <:< tp22`, trying at the same time * to keep the constraint as wide as possible. Specifically, if * @@ -1003,12 +1002,7 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling { val t2 = distributeAnd(tp2, tp1) if (t2.exists) t2 else if (erased) erasedGlb(tp1, tp2, isJava = false) - else { - //if (isHKRef(tp1)) tp2 - //else if (isHKRef(tp2)) tp1 - //else - AndType(tp1, tp2) - } + else liftIfHK(tp1, tp2, AndType(_, _)) } } @@ -1032,14 +1026,23 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling { val t2 = distributeOr(tp2, tp1) if (t2.exists) t2 else if (erased) erasedLub(tp1, tp2) - else - //if (isHKRef(tp1)) tp1 - //else if (isHKRef(tp2)) tp2 - //else - OrType(tp1, tp2) + else liftIfHK(tp1, tp2, OrType(_, _)) } } + /** `op(tp1, tp2)` unless `tp1` and `tp2` are type-constructors. + * In the latter case, combine `tp1` and `tp2` under a type lambda like this: + * + * [X1, ..., Xn] -> op(tp1[X1, ..., Xn], tp2[X1, ..., Xn]) + */ + private def liftIfHK(tp1: Type, tp2: Type, op: (Type, Type) => Type) = { + val tparams1 = tp1.typeParams + val tparams2 = tp2.typeParams + if (tparams1.isEmpty || tparams2.isEmpty) op(tp1, tp2) + else if (tparams1.length != tparams2.length) mergeConflict(tp1, tp2) + else hkCombine(tp1, tp2, tparams1, tparams2, op) + } + /** Try to distribute `&` inside type, detect and handle conflicts */ private def distributeAnd(tp1: Type, tp2: Type): Type = tp1 match { // opportunistically merge same-named refinements @@ -1318,12 +1321,12 @@ class ExplainingTypeComparer(initctx: Context) extends TypeComparer(initctx) { override def copyIn(ctx: Context) = new ExplainingTypeComparer(ctx) - override def compareHK(projection: NamedType, other: Type, inOrder: Boolean) = + override def compareHkApply(projection: NamedType, other: Type, inOrder: Boolean) = if (projection.name == tpnme.hkApply) traceIndented(i"compareHK $projection, $other, $inOrder") { - super.compareHK(projection, other, inOrder) + super.compareHkApply(projection, other, inOrder) } - else super.compareHK(projection, other, inOrder) + else super.compareHkApply(projection, other, inOrder) override def toString = "Subtype trace:" + { try b.toString finally b.clear() } } diff --git a/src/dotty/tools/dotc/typer/TypeAssigner.scala b/src/dotty/tools/dotc/typer/TypeAssigner.scala index 2b7eb3936d00..42ee513cd8d1 100644 --- a/src/dotty/tools/dotc/typer/TypeAssigner.scala +++ b/src/dotty/tools/dotc/typer/TypeAssigner.scala @@ -282,7 +282,7 @@ trait TypeAssigner { else if (!mix.isEmpty) findMixinSuper(cls.info) else if (inConstrCall || ctx.erasedTypes) cls.info.firstParent else { - val ps = cls.info.parents + val ps = cls.classInfo.instantiatedParents if (ps.isEmpty) defn.AnyType else ps.reduceLeft((x: Type, y: Type) => x & y) } tree.withType(SuperType(cls.thisType, owntype)) From 871188627d5bee19488e60922d23df2243d068d9 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Fri, 18 Dec 2015 21:25:41 +0100 Subject: [PATCH 08/22] Refactoring of derivedSelect If splitProjections is set, it is more efficient that way. --- src/dotty/tools/dotc/core/Types.scala | 34 +++++++++++++-------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala index d1d202855102..624549bac2a8 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -1536,19 +1536,24 @@ object Types { /** A selection of the same kind, but with potentially a differet prefix. * The following normalizations are performed for type selections T#A: * - * 1. If Config.splitProjections is true: + * T#A --> B if A is bound to an alias `= B` in T * - * (S & T)#A --> S#A & T#A + * (S & T)#A --> S#A if T does not have a member namd A + * --> T#A if S does not have a member namd A + * --> S#A & T#A otherwise * (S | T)#A --> S#A | T#A - * - * 2. If A is bound to an alias `= B` in T - * - * T#A --> B */ def derivedSelect(prefix: Type)(implicit ctx: Context): Type = if (prefix eq this.prefix) this - else { - if (Config.splitProjections && isType) + else if (isType) { + val res = prefix.lookupRefined(name) + if (res.exists) res + else if (name == tpnme.hkApply && prefix.classNotLambda) + // After substitution we might end up with a type like + // `C { type hk$0 = T0; ...; type hk$n = Tn } # $Apply` + // where C is a class. In that case we eta expand `C`. + derivedSelect(prefix.EtaExpandCore(this.prefix.typeConstructor.typeParams)) + else if (Config.splitProjections) prefix match { case prefix: AndType => def isMissing(tp: Type) = tp match { @@ -1566,16 +1571,11 @@ object Types { val derived2 = derivedSelect(prefix.tp2) return prefix.derivedOrType(derived1, derived2) case _ => + newLikeThis(prefix) } - val res = prefix.lookupRefined(name) - if (res.exists) res - else if (name == tpnme.hkApply && prefix.classNotLambda) { - // After substitution we might end up with a type like - // `C { type hk$0 = T0; ...; type hk$n = Tn } # $Apply` - // where C is a class. In that case we eta expand `C`. - derivedSelect(prefix.EtaExpandCore(this.prefix.typeConstructor.typeParams)) - } else newLikeThis(prefix) + else newLikeThis(prefix) } + else newLikeThis(prefix) /** Create a NamedType of the same kind as this type, but with a new prefix. */ @@ -2804,7 +2804,7 @@ object Types { } override def toString = - if (lo eq hi) s"TypeAlias($lo)" else s"TypeBounds($lo, $hi)" + if (lo eq hi) s"TypeAlias($lo, $variance)" else s"TypeBounds($lo, $hi)" } class RealTypeBounds(lo: Type, hi: Type) extends TypeBounds(lo, hi) { From 8e257a63872697bd48a51ce93a0289c9f5acdfd8 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Sat, 19 Dec 2015 11:36:07 +0100 Subject: [PATCH 09/22] Add test case --- test/dotc/tests.scala | 1 + tests/neg/Iter2.scala | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 tests/neg/Iter2.scala diff --git a/test/dotc/tests.scala b/test/dotc/tests.scala index 3787a9c98cb7..895bf89a7334 100644 --- a/test/dotc/tests.scala +++ b/test/dotc/tests.scala @@ -148,6 +148,7 @@ class tests extends CompilerTest { @Test def neg_boundspropagation = compileFile(negDir, "boundspropagation", xerrors = 5) @Test def neg_refinedSubtyping = compileFile(negDir, "refinedSubtyping", xerrors = 2) @Test def neg_hklower = compileFile(negDir, "hklower", xerrors = 3) + @Test def neg_Iter2 = compileFile(negDir, "Iter2", xerrors = 2) @Test def neg_i0091_infpaths = compileFile(negDir, "i0091-infpaths", xerrors = 3) @Test def neg_i0248_inherit_refined = compileFile(negDir, "i0248-inherit-refined", xerrors = 4) @Test def neg_i0281 = compileFile(negDir, "i0281-null-primitive-conforms", xerrors = 3) diff --git a/tests/neg/Iter2.scala b/tests/neg/Iter2.scala new file mode 100644 index 000000000000..d938f0379b02 --- /dev/null +++ b/tests/neg/Iter2.scala @@ -0,0 +1,40 @@ +// NOTE: this test case is very fragile, removing seemingly unrelated code like +// the "Dummy" trait somehow changes how the types of cget and dget are inferred +// and avoids the bug. + +object Test { + trait Dummy { + def foo: Unit = { + var i = 0 + i += 1 + } + } + + trait FromIterator[+C[X] <: Iterable[X]] { + def get(): C[Int] + } + + trait Iterable[+IA] extends FromIterator[Iterable] + trait SubIterable[+IA] extends Iterable[IA] with FromIterator[SubIterable] + + class IterableC extends Iterable[Int] { def get() = this } + class SubIterableC extends SubIterable[Int] { def get() = this } + + + implicit class IterableTransforms[A, C[X] <: Iterable[X], D[X] <: SubIterable[X]] + (val dummy: Unit) { + def foo(c: Iterable[A] with FromIterator[C], d: Iterable[A] with FromIterator[D]): Unit = { + var cget = c.get() + var dget = d.get() + dget = cget // error + cget = dget // error + } + } + + def main(args: Array[String]): Unit = { + new IterableTransforms(()).foo(new IterableC, new SubIterableC) + // java.lang.ClassCastException: Test$IterableC cannot be cast to Test$SubIterable + } +} + + From 4619393a6c3b52127ceec07e2fc3630d22aef51a Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Tue, 15 Dec 2015 17:46:39 +0100 Subject: [PATCH 10/22] Categorize more tests All pos tests up to 3999 have been triaged. One new test in pending. --- tests/{untried => pending}/pos/t3862.scala | 2 + tests/{untried => }/pos/t3048.scala | 0 tests/{untried => }/pos/t3071.scala | 0 tests/{untried => }/pos/t3079.scala | 0 tests/{untried => }/pos/t3136.scala | 0 tests/{untried => }/pos/t3160.scala | 0 tests/{untried => }/pos/t3174b.scala | 0 tests/{untried => }/pos/t318.scala | 0 tests/{untried => }/pos/t3272.scala | 0 tests/{untried => }/pos/t3312.scala | 0 tests/{untried => }/pos/t3371.scala | 0 tests/{untried => }/pos/t3373.scala | 0 tests/{untried => }/pos/t3374.scala | 0 tests/{untried => }/pos/t3384.scala | 0 tests/{untried => }/pos/t3420.scala | 0 tests/{untried => }/pos/t3430.scala | 0 tests/{untried => }/pos/t3440.scala | 0 tests/{untried => }/pos/t3452f.scala | 0 tests/{untried => }/pos/t348plus.scala | 0 tests/{untried => }/pos/t3495.scala | 0 tests/{untried => }/pos/t3528.scala | 0 tests/{untried => }/pos/t3560.scala | 0 tests/{untried => }/pos/t3570.scala | 0 tests/{untried => }/pos/t3578.scala | 0 tests/{untried => }/pos/t3582.scala | 0 tests/{untried => }/pos/t359.scala | 0 tests/{untried => }/pos/t361.scala | 0 tests/{untried => }/pos/t3636.scala | 0 tests/{untried => }/pos/t3670.scala | 0 tests/{untried => }/pos/t3671.scala | 0 tests/{untried => }/pos/t3672.scala | 0 tests/{untried => }/pos/t3676.scala | 0 tests/{untried => }/pos/t372.scala | 0 tests/{untried => }/pos/t3731.scala | 0 tests/{untried => }/pos/t374.scala | 0 tests/{untried => }/pos/t3774.scala | 0 tests/{untried => }/pos/t3792.scala | 0 tests/{untried => }/pos/t3808.scala | 0 tests/{untried => }/pos/t3833.scala | 0 tests/{untried => }/pos/t3836.scala | 0 tests/{untried => }/pos/t3837.scala | 0 tests/{untried => }/pos/t3861.scala | 0 tests/{untried => }/pos/t3866.scala | 0 tests/{untried => }/pos/t3883.scala | 0 tests/{untried => }/pos/t389.scala | 0 tests/{untried => }/pos/t3890.scala | 0 tests/{untried => }/pos/t3898.scala | 0 tests/{untried => }/pos/t3924.scala | 0 tests/{untried => }/pos/t3927.scala | 0 tests/{untried => }/pos/t397.scala | 0 tests/{untried => }/pos/t3972.scala | 0 tests/untried/pos/t2619.scala | 80 ---------------------- tests/untried/pos/t262.scala | 14 ---- tests/untried/pos/t2635.scala | 16 ----- tests/untried/pos/t2664.scala | 9 --- tests/untried/pos/t2665.scala | 3 - tests/untried/pos/t2667.scala | 6 -- tests/untried/pos/t2669.scala | 28 -------- tests/untried/pos/t2683.scala | 7 -- tests/untried/pos/t2691.scala | 16 ----- tests/untried/pos/t2693.scala | 6 -- tests/untried/pos/t2698.scala | 14 ---- 62 files changed, 2 insertions(+), 199 deletions(-) rename tests/{untried => pending}/pos/t3862.scala (71%) rename tests/{untried => }/pos/t3048.scala (100%) rename tests/{untried => }/pos/t3071.scala (100%) rename tests/{untried => }/pos/t3079.scala (100%) rename tests/{untried => }/pos/t3136.scala (100%) rename tests/{untried => }/pos/t3160.scala (100%) rename tests/{untried => }/pos/t3174b.scala (100%) rename tests/{untried => }/pos/t318.scala (100%) rename tests/{untried => }/pos/t3272.scala (100%) rename tests/{untried => }/pos/t3312.scala (100%) rename tests/{untried => }/pos/t3371.scala (100%) rename tests/{untried => }/pos/t3373.scala (100%) rename tests/{untried => }/pos/t3374.scala (100%) rename tests/{untried => }/pos/t3384.scala (100%) rename tests/{untried => }/pos/t3420.scala (100%) rename tests/{untried => }/pos/t3430.scala (100%) rename tests/{untried => }/pos/t3440.scala (100%) rename tests/{untried => }/pos/t3452f.scala (100%) rename tests/{untried => }/pos/t348plus.scala (100%) rename tests/{untried => }/pos/t3495.scala (100%) rename tests/{untried => }/pos/t3528.scala (100%) rename tests/{untried => }/pos/t3560.scala (100%) rename tests/{untried => }/pos/t3570.scala (100%) rename tests/{untried => }/pos/t3578.scala (100%) rename tests/{untried => }/pos/t3582.scala (100%) rename tests/{untried => }/pos/t359.scala (100%) rename tests/{untried => }/pos/t361.scala (100%) rename tests/{untried => }/pos/t3636.scala (100%) rename tests/{untried => }/pos/t3670.scala (100%) rename tests/{untried => }/pos/t3671.scala (100%) rename tests/{untried => }/pos/t3672.scala (100%) rename tests/{untried => }/pos/t3676.scala (100%) rename tests/{untried => }/pos/t372.scala (100%) rename tests/{untried => }/pos/t3731.scala (100%) rename tests/{untried => }/pos/t374.scala (100%) rename tests/{untried => }/pos/t3774.scala (100%) rename tests/{untried => }/pos/t3792.scala (100%) rename tests/{untried => }/pos/t3808.scala (100%) rename tests/{untried => }/pos/t3833.scala (100%) rename tests/{untried => }/pos/t3836.scala (100%) rename tests/{untried => }/pos/t3837.scala (100%) rename tests/{untried => }/pos/t3861.scala (100%) rename tests/{untried => }/pos/t3866.scala (100%) rename tests/{untried => }/pos/t3883.scala (100%) rename tests/{untried => }/pos/t389.scala (100%) rename tests/{untried => }/pos/t3890.scala (100%) rename tests/{untried => }/pos/t3898.scala (100%) rename tests/{untried => }/pos/t3924.scala (100%) rename tests/{untried => }/pos/t3927.scala (100%) rename tests/{untried => }/pos/t397.scala (100%) rename tests/{untried => }/pos/t3972.scala (100%) delete mode 100644 tests/untried/pos/t2619.scala delete mode 100644 tests/untried/pos/t262.scala delete mode 100644 tests/untried/pos/t2635.scala delete mode 100644 tests/untried/pos/t2664.scala delete mode 100644 tests/untried/pos/t2665.scala delete mode 100644 tests/untried/pos/t2667.scala delete mode 100644 tests/untried/pos/t2669.scala delete mode 100644 tests/untried/pos/t2683.scala delete mode 100644 tests/untried/pos/t2691.scala delete mode 100644 tests/untried/pos/t2693.scala delete mode 100644 tests/untried/pos/t2698.scala diff --git a/tests/untried/pos/t3862.scala b/tests/pending/pos/t3862.scala similarity index 71% rename from tests/untried/pos/t3862.scala rename to tests/pending/pos/t3862.scala index 8ca4a0586120..0d978caa41e3 100644 --- a/tests/untried/pos/t3862.scala +++ b/tests/pending/pos/t3862.scala @@ -1,3 +1,5 @@ +// Currently takes a very long time (more than a minute) and then +// does not find an alternative. object OverloadingShapeType { // comment out this, and the other alternative is chosen. def blerg(f: String): Unit = {} diff --git a/tests/untried/pos/t3048.scala b/tests/pos/t3048.scala similarity index 100% rename from tests/untried/pos/t3048.scala rename to tests/pos/t3048.scala diff --git a/tests/untried/pos/t3071.scala b/tests/pos/t3071.scala similarity index 100% rename from tests/untried/pos/t3071.scala rename to tests/pos/t3071.scala diff --git a/tests/untried/pos/t3079.scala b/tests/pos/t3079.scala similarity index 100% rename from tests/untried/pos/t3079.scala rename to tests/pos/t3079.scala diff --git a/tests/untried/pos/t3136.scala b/tests/pos/t3136.scala similarity index 100% rename from tests/untried/pos/t3136.scala rename to tests/pos/t3136.scala diff --git a/tests/untried/pos/t3160.scala b/tests/pos/t3160.scala similarity index 100% rename from tests/untried/pos/t3160.scala rename to tests/pos/t3160.scala diff --git a/tests/untried/pos/t3174b.scala b/tests/pos/t3174b.scala similarity index 100% rename from tests/untried/pos/t3174b.scala rename to tests/pos/t3174b.scala diff --git a/tests/untried/pos/t318.scala b/tests/pos/t318.scala similarity index 100% rename from tests/untried/pos/t318.scala rename to tests/pos/t318.scala diff --git a/tests/untried/pos/t3272.scala b/tests/pos/t3272.scala similarity index 100% rename from tests/untried/pos/t3272.scala rename to tests/pos/t3272.scala diff --git a/tests/untried/pos/t3312.scala b/tests/pos/t3312.scala similarity index 100% rename from tests/untried/pos/t3312.scala rename to tests/pos/t3312.scala diff --git a/tests/untried/pos/t3371.scala b/tests/pos/t3371.scala similarity index 100% rename from tests/untried/pos/t3371.scala rename to tests/pos/t3371.scala diff --git a/tests/untried/pos/t3373.scala b/tests/pos/t3373.scala similarity index 100% rename from tests/untried/pos/t3373.scala rename to tests/pos/t3373.scala diff --git a/tests/untried/pos/t3374.scala b/tests/pos/t3374.scala similarity index 100% rename from tests/untried/pos/t3374.scala rename to tests/pos/t3374.scala diff --git a/tests/untried/pos/t3384.scala b/tests/pos/t3384.scala similarity index 100% rename from tests/untried/pos/t3384.scala rename to tests/pos/t3384.scala diff --git a/tests/untried/pos/t3420.scala b/tests/pos/t3420.scala similarity index 100% rename from tests/untried/pos/t3420.scala rename to tests/pos/t3420.scala diff --git a/tests/untried/pos/t3430.scala b/tests/pos/t3430.scala similarity index 100% rename from tests/untried/pos/t3430.scala rename to tests/pos/t3430.scala diff --git a/tests/untried/pos/t3440.scala b/tests/pos/t3440.scala similarity index 100% rename from tests/untried/pos/t3440.scala rename to tests/pos/t3440.scala diff --git a/tests/untried/pos/t3452f.scala b/tests/pos/t3452f.scala similarity index 100% rename from tests/untried/pos/t3452f.scala rename to tests/pos/t3452f.scala diff --git a/tests/untried/pos/t348plus.scala b/tests/pos/t348plus.scala similarity index 100% rename from tests/untried/pos/t348plus.scala rename to tests/pos/t348plus.scala diff --git a/tests/untried/pos/t3495.scala b/tests/pos/t3495.scala similarity index 100% rename from tests/untried/pos/t3495.scala rename to tests/pos/t3495.scala diff --git a/tests/untried/pos/t3528.scala b/tests/pos/t3528.scala similarity index 100% rename from tests/untried/pos/t3528.scala rename to tests/pos/t3528.scala diff --git a/tests/untried/pos/t3560.scala b/tests/pos/t3560.scala similarity index 100% rename from tests/untried/pos/t3560.scala rename to tests/pos/t3560.scala diff --git a/tests/untried/pos/t3570.scala b/tests/pos/t3570.scala similarity index 100% rename from tests/untried/pos/t3570.scala rename to tests/pos/t3570.scala diff --git a/tests/untried/pos/t3578.scala b/tests/pos/t3578.scala similarity index 100% rename from tests/untried/pos/t3578.scala rename to tests/pos/t3578.scala diff --git a/tests/untried/pos/t3582.scala b/tests/pos/t3582.scala similarity index 100% rename from tests/untried/pos/t3582.scala rename to tests/pos/t3582.scala diff --git a/tests/untried/pos/t359.scala b/tests/pos/t359.scala similarity index 100% rename from tests/untried/pos/t359.scala rename to tests/pos/t359.scala diff --git a/tests/untried/pos/t361.scala b/tests/pos/t361.scala similarity index 100% rename from tests/untried/pos/t361.scala rename to tests/pos/t361.scala diff --git a/tests/untried/pos/t3636.scala b/tests/pos/t3636.scala similarity index 100% rename from tests/untried/pos/t3636.scala rename to tests/pos/t3636.scala diff --git a/tests/untried/pos/t3670.scala b/tests/pos/t3670.scala similarity index 100% rename from tests/untried/pos/t3670.scala rename to tests/pos/t3670.scala diff --git a/tests/untried/pos/t3671.scala b/tests/pos/t3671.scala similarity index 100% rename from tests/untried/pos/t3671.scala rename to tests/pos/t3671.scala diff --git a/tests/untried/pos/t3672.scala b/tests/pos/t3672.scala similarity index 100% rename from tests/untried/pos/t3672.scala rename to tests/pos/t3672.scala diff --git a/tests/untried/pos/t3676.scala b/tests/pos/t3676.scala similarity index 100% rename from tests/untried/pos/t3676.scala rename to tests/pos/t3676.scala diff --git a/tests/untried/pos/t372.scala b/tests/pos/t372.scala similarity index 100% rename from tests/untried/pos/t372.scala rename to tests/pos/t372.scala diff --git a/tests/untried/pos/t3731.scala b/tests/pos/t3731.scala similarity index 100% rename from tests/untried/pos/t3731.scala rename to tests/pos/t3731.scala diff --git a/tests/untried/pos/t374.scala b/tests/pos/t374.scala similarity index 100% rename from tests/untried/pos/t374.scala rename to tests/pos/t374.scala diff --git a/tests/untried/pos/t3774.scala b/tests/pos/t3774.scala similarity index 100% rename from tests/untried/pos/t3774.scala rename to tests/pos/t3774.scala diff --git a/tests/untried/pos/t3792.scala b/tests/pos/t3792.scala similarity index 100% rename from tests/untried/pos/t3792.scala rename to tests/pos/t3792.scala diff --git a/tests/untried/pos/t3808.scala b/tests/pos/t3808.scala similarity index 100% rename from tests/untried/pos/t3808.scala rename to tests/pos/t3808.scala diff --git a/tests/untried/pos/t3833.scala b/tests/pos/t3833.scala similarity index 100% rename from tests/untried/pos/t3833.scala rename to tests/pos/t3833.scala diff --git a/tests/untried/pos/t3836.scala b/tests/pos/t3836.scala similarity index 100% rename from tests/untried/pos/t3836.scala rename to tests/pos/t3836.scala diff --git a/tests/untried/pos/t3837.scala b/tests/pos/t3837.scala similarity index 100% rename from tests/untried/pos/t3837.scala rename to tests/pos/t3837.scala diff --git a/tests/untried/pos/t3861.scala b/tests/pos/t3861.scala similarity index 100% rename from tests/untried/pos/t3861.scala rename to tests/pos/t3861.scala diff --git a/tests/untried/pos/t3866.scala b/tests/pos/t3866.scala similarity index 100% rename from tests/untried/pos/t3866.scala rename to tests/pos/t3866.scala diff --git a/tests/untried/pos/t3883.scala b/tests/pos/t3883.scala similarity index 100% rename from tests/untried/pos/t3883.scala rename to tests/pos/t3883.scala diff --git a/tests/untried/pos/t389.scala b/tests/pos/t389.scala similarity index 100% rename from tests/untried/pos/t389.scala rename to tests/pos/t389.scala diff --git a/tests/untried/pos/t3890.scala b/tests/pos/t3890.scala similarity index 100% rename from tests/untried/pos/t3890.scala rename to tests/pos/t3890.scala diff --git a/tests/untried/pos/t3898.scala b/tests/pos/t3898.scala similarity index 100% rename from tests/untried/pos/t3898.scala rename to tests/pos/t3898.scala diff --git a/tests/untried/pos/t3924.scala b/tests/pos/t3924.scala similarity index 100% rename from tests/untried/pos/t3924.scala rename to tests/pos/t3924.scala diff --git a/tests/untried/pos/t3927.scala b/tests/pos/t3927.scala similarity index 100% rename from tests/untried/pos/t3927.scala rename to tests/pos/t3927.scala diff --git a/tests/untried/pos/t397.scala b/tests/pos/t397.scala similarity index 100% rename from tests/untried/pos/t397.scala rename to tests/pos/t397.scala diff --git a/tests/untried/pos/t3972.scala b/tests/pos/t3972.scala similarity index 100% rename from tests/untried/pos/t3972.scala rename to tests/pos/t3972.scala diff --git a/tests/untried/pos/t2619.scala b/tests/untried/pos/t2619.scala deleted file mode 100644 index 283d93bf2b97..000000000000 --- a/tests/untried/pos/t2619.scala +++ /dev/null @@ -1,80 +0,0 @@ -abstract class F { - final def apply(x: Int): AnyRef = null -} -abstract class AbstractModule { - def as: List[AnyRef] - def ms: List[AbstractModule] - def fs: List[F] = Nil - def rs(x: Int): List[AnyRef] = fs.map(_(x)) -} -abstract class ModuleType1 extends AbstractModule {} -abstract class ModuleType2 extends AbstractModule {} - -object ModuleAE extends ModuleType1 { - def as = Nil - def ms = Nil -} -object ModuleAF extends ModuleType2 { - def as = Nil - def ms = List(ModuleAE) -} -object ModuleAG extends ModuleType1 { - def as = List("") - def ms = Nil -} -object ModuleAI extends ModuleType1 { - def as = Nil - def ms = List(ModuleAE) -} -object ModuleAK extends ModuleType2 { - def as = Nil - def ms = List(ModuleAF) -} -object ModuleAL extends ModuleType1 { - def as = Nil - def ms = List( - ModuleAG, - ModuleAI - ) -} -object ModuleAM extends ModuleType1 { - def as = Nil - def ms = List( - ModuleAL, - ModuleAE - ) ::: List(ModuleAK) -} -object ModuleBE extends ModuleType1 { - def as = Nil - def ms = Nil -} -object ModuleBF extends ModuleType2 { - def as = Nil - def ms = List(ModuleBE) -} -object ModuleBG extends ModuleType1 { - def as = List("") - def ms = Nil -} -object ModuleBI extends ModuleType1 { - def as = Nil - def ms = List(ModuleBE) -} -object ModuleBK extends ModuleType2 { - def as = Nil - def ms = List(ModuleBF) -} -object ModuleBL extends ModuleType1 { - def as = Nil - def ms = List( - ModuleBG, - ModuleBI - ) -} -object ModuleBM extends ModuleType1 { - def as = Nil - def ms = List( - ModuleBL, - ModuleBE - ) ::: List(ModuleBK) -} diff --git a/tests/untried/pos/t262.scala b/tests/untried/pos/t262.scala deleted file mode 100644 index 9f7686a8f342..000000000000 --- a/tests/untried/pos/t262.scala +++ /dev/null @@ -1,14 +0,0 @@ -object O { - abstract class A { - def f:A; - } - class B extends A { - def f = if (1 == 2) new C else new D; - } - class C extends A { - def f = this; - } - class D extends A { - def f = this; - } -} diff --git a/tests/untried/pos/t2635.scala b/tests/untried/pos/t2635.scala deleted file mode 100644 index 7cd55313561a..000000000000 --- a/tests/untried/pos/t2635.scala +++ /dev/null @@ -1,16 +0,0 @@ -abstract class Base - -object Test -{ - def run(c: Class[_ <: Base]): Unit = { - } - - def main(args: Array[String]): Unit = - { - val sc: Option[Class[_ <: Base]] = Some(classOf[Base]) - sc match { - case Some(c) => run(c) - case None => - } - } -} diff --git a/tests/untried/pos/t2664.scala b/tests/untried/pos/t2664.scala deleted file mode 100644 index 7b667d0106e2..000000000000 --- a/tests/untried/pos/t2664.scala +++ /dev/null @@ -1,9 +0,0 @@ -package pkg1 { - class C { - private[pkg1] def foo: Int = 1 - } - - trait T extends C { - private[pkg1] abstract override def foo = super.foo + 1 - } -} diff --git a/tests/untried/pos/t2665.scala b/tests/untried/pos/t2665.scala deleted file mode 100644 index e46453534c0f..000000000000 --- a/tests/untried/pos/t2665.scala +++ /dev/null @@ -1,3 +0,0 @@ -object Test { - val x: Unit = Array("") -} diff --git a/tests/untried/pos/t2667.scala b/tests/untried/pos/t2667.scala deleted file mode 100644 index 7f1f36f00bad..000000000000 --- a/tests/untried/pos/t2667.scala +++ /dev/null @@ -1,6 +0,0 @@ -object A { - def foo(x: Int, y: Int*): Int = 45 - def foo[T](x: T*): Int = 55 - - val x: Unit = foo(23, 23f) -} diff --git a/tests/untried/pos/t2669.scala b/tests/untried/pos/t2669.scala deleted file mode 100644 index 72e931178c06..000000000000 --- a/tests/untried/pos/t2669.scala +++ /dev/null @@ -1,28 +0,0 @@ -// #2629, #2639, #2669 -object Test2669 { - - def test[T](l: java.util.ArrayList[_ <: T]) = 1 - test(new java.util.ArrayList[String]()) - -} - -import java.util.ArrayList - -object Test2629 { - def main(args: Array[String]): Unit = { - val l = new ArrayList[String](1) - val m = new ArrayList(l) - - println(l.size) - println(m.size) - } -} - - -import java.util.Vector - -// scalac cannot detect lack of type params, but then throws AssertionError later: -class TVector2639 { - val b = new Vector // this line passed without error detected - val a = new Vector(1) // this line caused throwing AssertionError when scalac -} diff --git a/tests/untried/pos/t2683.scala b/tests/untried/pos/t2683.scala deleted file mode 100644 index 4ba34b554a91..000000000000 --- a/tests/untried/pos/t2683.scala +++ /dev/null @@ -1,7 +0,0 @@ -class A -class B extends A - -object Test { - val c: Class[_ <: A] = Class.forName("B").asSubclass(classOf[A]) - val x: Option[Class[_ <: A]] = Some(3).map { case _ => c } -} diff --git a/tests/untried/pos/t2691.scala b/tests/untried/pos/t2691.scala deleted file mode 100644 index 5f0ddd122f87..000000000000 --- a/tests/untried/pos/t2691.scala +++ /dev/null @@ -1,16 +0,0 @@ -object Breakdown { - def unapplySeq(x: Int): Some[List[String]] = Some(List("", "there")) -} -object Test { - 42 match { - case Breakdown("") => // needed to trigger bug - case Breakdown("", who) => println ("hello " + who) - } -} -object Test2 { - 42 match { - case Breakdown("") => // needed to trigger bug - case Breakdown("foo") => // needed to trigger bug - case Breakdown("", who) => println ("hello " + who) - } -} diff --git a/tests/untried/pos/t2693.scala b/tests/untried/pos/t2693.scala deleted file mode 100644 index 5d4d0380c418..000000000000 --- a/tests/untried/pos/t2693.scala +++ /dev/null @@ -1,6 +0,0 @@ -class A { - trait T[A] - def usetHk[T[_], A](ta: T[A]) = 0 - usetHk(new T[Int]{}: T[Int]) - usetHk(new T[Int]{}) // fails with: found: java.lang.Object with T[Int], required: ?T[ ?A ] -} diff --git a/tests/untried/pos/t2698.scala b/tests/untried/pos/t2698.scala deleted file mode 100644 index bce02e48b3d6..000000000000 --- a/tests/untried/pos/t2698.scala +++ /dev/null @@ -1,14 +0,0 @@ -class WordExp { - abstract class Label - type _labelT <: Label -} - -import scala.collection._ - -abstract class S2 { - val lang: WordExp - type __labelT = lang._labelT - - var deltaq: Array[__labelT] = _ - def delta1 = immutable.Map(deltaq.zipWithIndex: _*) -} From 1de9e43ce85f7ddc93e21c4c7dc2c8b6558e95fb Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Sat, 19 Dec 2015 17:28:25 +0100 Subject: [PATCH 11/22] Fix eta lifting for functions with vararg parameters. --- src/dotty/tools/dotc/ast/untpd.scala | 9 +++++---- src/dotty/tools/dotc/typer/EtaExpansion.scala | 4 ++-- tests/pos/t4176b.scala | 5 +++++ 3 files changed, 12 insertions(+), 6 deletions(-) create mode 100644 tests/pos/t4176b.scala diff --git a/src/dotty/tools/dotc/ast/untpd.scala b/src/dotty/tools/dotc/ast/untpd.scala index 28a3cf1ff405..85052a4da950 100644 --- a/src/dotty/tools/dotc/ast/untpd.scala +++ b/src/dotty/tools/dotc/ast/untpd.scala @@ -234,12 +234,13 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo { * parameter, the reference will be a repeated argument. */ def refOfDef(tree: MemberDef)(implicit ctx: Context) = tree match { - case ValDef(_, PostfixOp(_, nme.raw.STAR), _) => - Typed(Ident(tree.name), Ident(tpnme.WILDCARD_STAR)) - case _ => - Ident(tree.name) + case ValDef(_, PostfixOp(_, nme.raw.STAR), _) => repeated(Ident(tree.name)) + case _ => Ident(tree.name) } + /** A repeated argument such as `arg: _*` */ + def repeated(arg: Tree)(implicit ctx: Context) = Typed(arg, Ident(tpnme.WILDCARD_STAR)) + // ------- Decorators ------------------------------------------------- implicit class UntypedTreeDecorator(val self: Tree) extends AnyVal { diff --git a/src/dotty/tools/dotc/typer/EtaExpansion.scala b/src/dotty/tools/dotc/typer/EtaExpansion.scala index 89415024e74c..42fcd94a46a9 100644 --- a/src/dotty/tools/dotc/typer/EtaExpansion.scala +++ b/src/dotty/tools/dotc/typer/EtaExpansion.scala @@ -141,8 +141,8 @@ object EtaExpansion { else mt.paramTypes map TypeTree val params = (mt.paramNames, paramTypes).zipped.map((name, tpe) => ValDef(name, TypeTree(tpe), EmptyTree).withFlags(Synthetic | Param).withPos(tree.pos)) - val ids = mt.paramNames map (name => - Ident(name).withPos(tree.pos)) + var ids: List[Tree] = mt.paramNames map (name => Ident(name).withPos(tree.pos)) + if (mt.paramTypes.last.isRepeatedParam)ids = ids.init :+ repeated(ids.last) val body = Apply(lifted, ids) val fn = untpd.Function(params, body) if (defs.nonEmpty) untpd.Block(defs.toList map untpd.TypedSplice, fn) else fn diff --git a/tests/pos/t4176b.scala b/tests/pos/t4176b.scala new file mode 100644 index 000000000000..eebb5dda583d --- /dev/null +++ b/tests/pos/t4176b.scala @@ -0,0 +1,5 @@ +object Test { + def foo(a1: String*) = a1 +// val fooEta = foo _ + (foo: Seq[String] => Seq[String]) +} From ec54cd557f3a9f52db9e280043a5b9657ca6fc30 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Sat, 19 Dec 2015 17:54:16 +0100 Subject: [PATCH 12/22] Fix desugaring of symbols. Symbols can appear in patterns, so inserting an `apply` is wrong. --- src/dotty/tools/dotc/ast/Desugar.scala | 2 +- tests/pos/t4579.scala | 518 +++++++++++++++++++++++++ 2 files changed, 519 insertions(+), 1 deletion(-) create mode 100644 tests/pos/t4579.scala diff --git a/src/dotty/tools/dotc/ast/Desugar.scala b/src/dotty/tools/dotc/ast/Desugar.scala index 12f3e44068c1..d59c2dd7b7b9 100644 --- a/src/dotty/tools/dotc/ast/Desugar.scala +++ b/src/dotty/tools/dotc/ast/Desugar.scala @@ -801,7 +801,7 @@ object desugar { tree match { case SymbolLit(str) => Apply( - Select(ref(defn.SymbolClass.companionModule.termRef), nme.apply), + ref(defn.SymbolClass.companionModule.termRef), Literal(Constant(str)) :: Nil) case InterpolatedString(id, strs, elems) => Apply(Select(Apply(Ident(nme.StringContext), strs), id), elems) diff --git a/tests/pos/t4579.scala b/tests/pos/t4579.scala new file mode 100644 index 000000000000..8ce657eff6a6 --- /dev/null +++ b/tests/pos/t4579.scala @@ -0,0 +1,518 @@ +//############################################################################ +// Lisp interpreter (revived as an optimizer test.) +//############################################################################ + +//############################################################################ +// Lisp Scanner + +class LispTokenizer(s: String) extends Iterator[String] { + private var i = 0; + private def isDelimiter(ch: Char) = ch <= ' ' || ch == '(' || ch == ')' + def hasNext: Boolean = { + while (i < s.length() && s.charAt(i) <= ' ') i += 1 + i < s.length() + } + def next: String = + if (hasNext) { + val start = i + if (isDelimiter(s charAt i)) i += 1 + else + do i = i + 1 + while (!isDelimiter(s charAt i)) + s.substring(start, i) + } else sys.error("premature end of string") +} + +//############################################################################ +// Lisp Interface + +trait Lisp { + type Data + + def string2lisp(s: String): Data + def lisp2string(s: Data): String + + def evaluate(d: Data): Data + // !!! def evaluate(s: String): Data = evaluate(string2lisp(s)) + def evaluate(s: String): Data +} + +//############################################################################ +// Lisp Implementation Using Case Classes + +object LispCaseClasses extends Lisp { + + import List.range + + trait Data { + def elemsToString(): String = toString(); + } + case class CONS(car: Data, cdr: Data) extends Data { + override def toString() = "(" + elemsToString() + ")"; + override def elemsToString() = car.toString() + (cdr match { + case NIL() => "" + case _ => " " + cdr.elemsToString(); + }) + } + case class NIL() extends Data { // !!! use case object + override def toString() = "()"; + } + case class SYM(name: String) extends Data { + override def toString() = name; + } + case class NUM(x: Int) extends Data { + override def toString() = x.toString(); + } + case class STR(x: String) extends Data { + override def toString() = "\"" + x + "\""; + } + case class FUN(f: List[Data] => Data) extends Data { + override def toString() = ""; + } + + def list(): Data = + NIL(); + def list(x0: Data): Data = + CONS(x0, NIL()); + def list(x0: Data, x1: Data): Data = + CONS(x0, list(x1)); + def list(x0: Data, x1: Data, x2: Data): Data = + CONS(x0, list(x1, x2)); + def list(x0: Data, x1: Data, x2: Data, x3: Data): Data = + CONS(x0, list(x1, x2, x3)); + def list(x0: Data, x1: Data, x2: Data, x3: Data, x4: Data): Data = + CONS(x0, list(x1, x2, x3, x4)); + def list(x0: Data, x1: Data, x2: Data, x3: Data, x4: Data, x5: Data): Data = + CONS(x0, list(x1, x2, x3, x4, x5)); + def list(x0: Data, x1: Data, x2: Data, x3: Data, x4: Data, x5: Data, + x6: Data): Data = + CONS(x0, list(x1, x2, x3, x4, x5, x6)); + def list(x0: Data, x1: Data, x2: Data, x3: Data, x4: Data, x5: Data, + x6: Data, x7: Data): Data = + CONS(x0, list(x1, x2, x3, x4, x5, x6, x7)); + def list(x0: Data, x1: Data, x2: Data, x3: Data, x4: Data, x5: Data, + x6: Data, x7: Data, x8: Data): Data = + CONS(x0, list(x1, x2, x3, x4, x5, x6, x7, x8)); + def list(x0: Data, x1: Data, x2: Data, x3: Data, x4: Data, x5: Data, + x6: Data, x7: Data, x8: Data, x9: Data): Data = + CONS(x0, list(x1, x2, x3, x4, x5, x6, x7, x8, x9)); + + var curexp: Data = null + var trace: Boolean = false + var indent: Int = 0 + + def lispError[a](msg: String): a = + sys.error("error: " + msg + "\n" + curexp); + + trait Environment { + def lookup(n: String): Data; + def extendRec(name: String, expr: Environment => Data) = + new Environment { + def lookup(n: String): Data = + if (n == name) expr(this) else Environment.this.lookup(n); + } + def extend(name: String, v: Data) = extendRec(name, (env1 => v)); + } + val EmptyEnvironment = new Environment { + def lookup(n: String): Data = lispError("undefined: " + n); + } + + def toList(x: Data): List[Data] = x match { + case NIL() => List() + case CONS(y, ys) => y :: toList(ys) + case _ => lispError("malformed list: " + x); + } + + def toBoolean(x: Data) = x match { + case NUM(0) => false + case _ => true + } + + def normalize(x: Data): Data = x match { + case CONS(SYM("def"), + CONS(CONS(SYM(name), args), CONS(body, CONS(expr, NIL())))) => + normalize(list(SYM("def"), + SYM(name), list(SYM("lambda"), args, body), expr)) + case CONS(SYM("cond"), CONS(CONS(SYM("else"), CONS(expr, NIL())),NIL())) => + normalize(expr) + case CONS(SYM("cond"), CONS(CONS(test, CONS(expr, NIL())), rest)) => + normalize(list(SYM("if"), test, expr, CONS(SYM("cond"), rest))) + case CONS(h, t) => CONS(normalize(h), normalize(t)) + case _ => x + } + + def eval(x: Data, env: Environment): Data = { + val prevexp = curexp; + curexp = x; + if (trace) { + for (x <- range(1, indent)) Console.print(" "); + Console.println("===> " + x); + indent = indent + 1; + } + val result = eval1(x, env); + if (trace) { + indent = indent - 1; + for (x <- range(1, indent)) Console.print(" "); + Console.println("<=== " + result); + } + curexp = prevexp; + result + } + + def eval1(x: Data, env: Environment): Data = x match { + case SYM(name) => + env lookup name + case CONS(SYM("def"), CONS(SYM(name), CONS(y, CONS(z, NIL())))) => + eval(z, env.extendRec(name, (env1 => eval(y, env1)))) + case CONS(SYM("val"), CONS(SYM(name), CONS(y, CONS(z, NIL())))) => + eval(z, env.extend(name, eval(y, env))) + case CONS(SYM("lambda"), CONS(params, CONS(y, NIL()))) => + mkLambda(params, y, env) + case CONS(SYM("if"), CONS(c, CONS(t, CONS(e, NIL())))) => + if (toBoolean(eval(c, env))) eval(t, env) else eval(e, env) + case CONS(SYM("quote"), CONS(x, NIL())) => + x + case CONS(y, xs) => + apply(eval(y, env), toList(xs) map (x => eval(x, env))) + case NUM(_) => x + case STR(_) => x + case FUN(_) => x + case _ => + lispError("illegal term") + } + + def apply(fn: Data, args: List[Data]): Data = fn match { + case FUN(f) => f(args); + case _ => lispError("application of non-function: " + fn); + } + + def mkLambda(params: Data, expr: Data, env: Environment): Data = { + + def extendEnv(env: Environment, + ps: List[String], args: List[Data]): Environment = + (ps, args) match { + case (List(), List()) => + env + case (p :: ps1, arg :: args1) => + extendEnv(env.extend(p, arg), ps1, args1) + case _ => + lispError("wrong number of arguments") + } + + val ps: List[String] = toList(params) map { + case SYM(name) => name + case _ => sys.error("illegal parameter list"); + } + + FUN(args => eval(expr, extendEnv(env, ps, args))) + } + + val globalEnv = EmptyEnvironment + .extend("=", FUN({ + case List(NUM(arg1),NUM(arg2)) => NUM(if (arg1 == arg2) 1 else 0) + case List(STR(arg1),STR(arg2)) => NUM(if (arg1 == arg2) 1 else 0)})) + .extend("+", FUN({ + case List(NUM(arg1),NUM(arg2)) => NUM(arg1 + arg2) + case List(STR(arg1),STR(arg2)) => STR(arg1 + arg2)})) + .extend("-", FUN({ + case List(NUM(arg1),NUM(arg2)) => NUM(arg1 - arg2)})) + .extend("*", FUN({ + case List(NUM(arg1),NUM(arg2)) => NUM(arg1 * arg2)})) + .extend("/", FUN({ + case List(NUM(arg1),NUM(arg2)) => NUM(arg1 / arg2)})) + .extend("car", FUN({ + case List(CONS(x, xs)) => x})) + .extend("cdr", FUN({ + case List(CONS(x, xs)) => xs})) + .extend("null?", FUN({ + case List(NIL()) => NUM(1) + case _ => NUM(0)})) + .extend("cons", FUN({ + case List(x, y) => CONS(x, y)})); + + def evaluate(x: Data): Data = eval(normalize(x), globalEnv); + def evaluate(s: String): Data = evaluate(string2lisp(s)); + + def string2lisp(s: String): Data = { + val it = new LispTokenizer(s); + def parse(token: String): Data = { + if (token == "(") parseList + else if (token == ")") sys.error("unbalanced parentheses") + else if ('0' <= token.charAt(0) && token.charAt(0) <= '9') + NUM(token.toInt) + else if (token.charAt(0) == '\"' && token.charAt(token.length()-1)=='\"') + STR(token.substring(1,token.length() - 1)) + else SYM(token) + } + def parseList: Data = { + val token = it.next; + if (token == ")") NIL() else CONS(parse(token), parseList) + } + parse(it.next) + } + + def lisp2string(d: Data): String = d.toString(); +} + +//############################################################################ +// Lisp Implementation Using Any + +object LispAny extends Lisp { + + import List._; + + type Data = Any; + + case class Lambda(f: List[Data] => Data); + + var curexp: Data = null; + var trace: Boolean = false; + var indent: Int = 0; + + def lispError[a](msg: String): a = + sys.error("error: " + msg + "\n" + curexp); + + trait Environment { + def lookup(n: String): Data; + def extendRec(name: String, expr: Environment => Data) = + new Environment { + def lookup(n: String): Data = + if (n == name) expr(this) else Environment.this.lookup(n); + } + def extend(name: String, v: Data) = extendRec(name, (env1 => v)); + } + val EmptyEnvironment = new Environment { + def lookup(n: String): Data = lispError("undefined: " + n); + } + + def asList(x: Data): List[Data] = x match { + case y: List[_] => y + case _ => lispError("malformed list: " + x) + } + + def asInt(x: Data): Int = x match { + case y: Int => y + case _ => lispError("not an integer: " + x) + } + + def asString(x: Data): String = x match { + case y: String => y + case _ => lispError("not a string: " + x) + } + + def asBoolean(x: Data): Boolean = x != 0 + + def normalize(x: Data): Data = x match { + case 'and :: x :: y :: Nil => + normalize('if :: x :: y :: 0 :: Nil) + case 'or :: x :: y :: Nil => + normalize('if :: x :: 1 :: y :: Nil) + case 'def :: (name :: args) :: body :: expr :: Nil => + normalize('def :: name :: ('lambda :: args :: body :: Nil) :: expr :: Nil) + case 'cond :: ('else :: expr :: Nil) :: rest => + normalize(expr); + case 'cond :: (test :: expr :: Nil) :: rest => + normalize('if :: test :: expr :: ('cond :: rest) :: Nil) + case 'cond :: 'else :: expr :: Nil => + normalize(expr) + case h :: t => + normalize(h) :: asList(normalize(t)) + case _ => + x + } + + def eval(x: Data, env: Environment): Data = { + val prevexp = curexp; + curexp = x; + if (trace) { + for (x <- range(1, indent)) Console.print(" "); + Console.println("===> " + x); + indent += 1; + } + val result = eval1(x, env); + if (trace) { + indent -= 1; + for (x <- range(1, indent)) Console.print(" "); + Console.println("<=== " + result); + } + curexp = prevexp; + result + } + + def eval1(x: Data, env: Environment): Data = x match { + case Symbol(name) => + env lookup name + case 'def :: Symbol(name) :: y :: z :: Nil => + eval(z, env.extendRec(name, (env1 => eval(y, env1)))) + case 'val :: Symbol(name) :: y :: z :: Nil => + eval(z, env.extend(name, eval(y, env))) + case 'lambda :: params :: y :: Nil => + mkLambda(params, y, env) + case 'if :: c :: y :: z :: Nil => + if (asBoolean(eval(c, env))) eval(y, env) else eval(z, env) + case 'quote :: y :: Nil => + y + case y :: z => + apply(eval(y, env), z map (x => eval(x, env))) + case Lambda(_) => x + case y: String => x + case y: Int => x + case y => lispError("illegal term") + } + + def lisp2string(x: Data): String = x match { + case Symbol(name) => name + case Nil => "()" + case y :: ys => + def list2string(xs: List[Data]): String = xs match { + case List() => "" + case y :: ys => " " + lisp2string(y) + list2string(ys) + } + "(" + lisp2string(y) + list2string(ys) + ")" + case _ => if (x.isInstanceOf[String]) "\"" + x + "\""; else x.toString() + } + + def apply(fn: Data, args: List[Data]): Data = fn match { + case Lambda(f) => f(args); + case _ => lispError("application of non-function: " + fn + " to " + args); + } + + def mkLambda(params: Data, expr: Data, env: Environment): Data = { + + def extendEnv(env: Environment, + ps: List[String], args: List[Data]): Environment = + (ps, args) match { + case (List(), List()) => + env + case (p :: ps1, arg :: args1) => + extendEnv(env.extend(p, arg), ps1, args1) + case _ => + lispError("wrong number of arguments") + } + + val ps: List[String] = asList(params) map { + case Symbol(name) => name + case _ => sys.error("illegal parameter list"); + } + + Lambda(args => eval(expr, extendEnv(env, ps, args))) + } + + val globalEnv = EmptyEnvironment + .extend("=", Lambda{ + case List(arg1, arg2) => if (arg1 == arg2) 1 else 0}) + .extend("+", Lambda{ + case List(arg1: Int, arg2: Int) => arg1 + arg2 + case List(arg1: String, arg2: String) => arg1 + arg2}) + .extend("-", Lambda{ + case List(arg1: Int, arg2: Int) => arg1 - arg2}) + .extend("*", Lambda{ + case List(arg1: Int, arg2: Int) => arg1 * arg2}) + .extend("/", Lambda{ + case List(arg1: Int, arg2: Int) => arg1 / arg2}) + .extend("nil", Nil) + .extend("cons", Lambda{ + case List(arg1, arg2) => arg1 :: asList(arg2)}) + .extend("car", Lambda{ + case List(x :: xs) => x}) + .extend("cdr", Lambda{ + case List(x :: xs) => xs}) + .extend("null?", Lambda{ + case List(Nil) => 1 + case _ => 0}); + + def evaluate(x: Data): Data = eval(normalize(x), globalEnv); + def evaluate(s: String): Data = evaluate(string2lisp(s)); + + def string2lisp(s: String): Data = { + val it = new LispTokenizer(s); + def parse(token: String): Data = { + if (token == "(") parseList + else if (token == ")") sys.error("unbalanced parentheses") + //else if (Character.isDigit(token.charAt(0))) + else if (token.charAt(0).isDigit) + token.toInt + else if (token.charAt(0) == '\"' && token.charAt(token.length()-1)=='\"') + token.substring(1,token.length() - 1) + else Symbol(token) + } + def parseList: List[Data] = { + val token = it.next; + if (token == ")") Nil else parse(token) :: parseList + } + parse(it.next) + } +} + +//############################################################################ +// List User + +class LispUser(lisp: Lisp) { + + import lisp._; + + def evaluate(s: String) = lisp2string(lisp.evaluate(s)); + + def run = { + + Console.println(string2lisp("(lambda (x) (+ (* x x) 1))").asInstanceOf[AnyRef]); + Console.println(lisp2string(string2lisp("(lambda (x) (+ (* x x) 1))"))); + Console.println; + + Console.println("( '(1 2 3)) = " + evaluate(" (quote(1 2 3))")); + Console.println("(car '(1 2 3)) = " + evaluate("(car (quote(1 2 3)))")); + Console.println("(cdr '(1 2 3)) = " + evaluate("(cdr (quote(1 2 3)))")); + Console.println("(null? '(2 3)) = " + evaluate("(null? (quote(2 3)))")); + Console.println("(null? '()) = " + evaluate("(null? (quote()))")); + Console.println; + + Console.println("faculty(10) = " + evaluate( + "(def (faculty n) " + + "(if (= n 0) " + + "1 " + + "(* n (faculty (- n 1)))) " + + "(faculty 10))")); + Console.println("faculty(10) = " + evaluate( + "(def (faculty n) " + + "(cond " + + "((= n 0) 1) " + + "(else (* n (faculty (- n 1))))) " + + "(faculty 10))")); + Console.println("foobar = " + evaluate( + "(def (foo n) " + + "(cond " + + "((= n 0) \"a\")" + + "((= n 1) \"b\")" + + "((= (/ n 2) 1) " + + "(cond " + + "((= n 2) \"c\")" + + "(else \"d\")))" + + "(else " + + "(def (bar m) " + + "(cond " + + "((= m 0) \"e\")" + + "((= m 1) \"f\")" + + "(else \"z\"))" + + "(bar (- n 4)))))" + + "(val nil (quote ())" + + "(val v1 (foo 0) " + + "(val v2 (+ (foo 1) (foo 2)) " + + "(val v3 (+ (+ (foo 3) (foo 4)) (foo 5)) " + + "(val v4 (foo 6) " + + "(cons v1 (cons v2 (cons v3 (cons v4 nil))))))))))")); + Console.println; + } +} + +//############################################################################ +// Main + +object Test { + def main(args: Array[String]): Unit = { + new LispUser(LispCaseClasses).run; + new LispUser(LispAny).run; + () + } +} + +//############################################################################ From 6c335b750fb65b1a605b9c8ad3a459113ffdbabf Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Sat, 19 Dec 2015 18:15:21 +0100 Subject: [PATCH 13/22] Fix parsing of blocks that end in an import --- docs/SyntaxSummary.txt | 2 +- src/dotty/tools/dotc/parsing/Parsers.scala | 3 +- tests/pos/t4760.scala | 35 ++++++++++++++++++++++ 3 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 tests/pos/t4760.scala diff --git a/docs/SyntaxSummary.txt b/docs/SyntaxSummary.txt index 764275f92046..11f23da9455e 100644 --- a/docs/SyntaxSummary.txt +++ b/docs/SyntaxSummary.txt @@ -129,7 +129,7 @@ grammar. | `_' ExprInParens ::= PostfixExpr `:' Type | Expr - BlockResult ::= (FunParams | [`implicit'] id `:' InfixType) => Block + BlockResult ::= (FunParams | [`implicit'] id `:' InfixType) `=>' Block | Expr1 Expr1 ::= `if' `(' Expr `)' {nl} Expr [[semi] else Expr] If(Parens(cond), thenp, elsep?) | `if' Expr `then' Expr [[semi] else Expr] If(cond, thenp, elsep?) diff --git a/src/dotty/tools/dotc/parsing/Parsers.scala b/src/dotty/tools/dotc/parsing/Parsers.scala index 71a03b9e2299..d59e087cb2a5 100644 --- a/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/src/dotty/tools/dotc/parsing/Parsers.scala @@ -1156,7 +1156,8 @@ object Parsers { */ def block(): Tree = { val stats = blockStatSeq() - if (stats.nonEmpty && !stats.last.isDef) Block(stats.init, stats.last) + def isExpr(stat: Tree) = !(stat.isDef || stat.isInstanceOf[Import]) + if (stats.nonEmpty && isExpr(stats.last)) Block(stats.init, stats.last) else Block(stats, EmptyTree) } diff --git a/tests/pos/t4760.scala b/tests/pos/t4760.scala new file mode 100644 index 000000000000..039f08368070 --- /dev/null +++ b/tests/pos/t4760.scala @@ -0,0 +1,35 @@ + +class Test { + // parses + def f1 = { + import scala._; + } + // b.scala:7: error: ';' expected but '}' found. + // } + // ^ + // one error found + def f2 = { + import scala._ + } + def f2b = { + import scala.collection.mutable.{ Map => MMap } + } + def f(): Unit = { + locally { + import scala.util.Properties.lineSeparator + } + } + + // parses + def f3 = { + import scala._ + 5 + } + locally { (x: Int) => + import scala.util._ + } + 1 match { + case 1 => import scala.concurrent._ + } +} + From 7dafb2ac6d5fd41cfc0a94f2a72b881987890abf Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Sat, 19 Dec 2015 18:58:36 +0100 Subject: [PATCH 14/22] Add position to implicit defs generated from implicit classes. --- src/dotty/tools/dotc/ast/Desugar.scala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/dotty/tools/dotc/ast/Desugar.scala b/src/dotty/tools/dotc/ast/Desugar.scala index d59c2dd7b7b9..87694843ad6a 100644 --- a/src/dotty/tools/dotc/ast/Desugar.scala +++ b/src/dotty/tools/dotc/ast/Desugar.scala @@ -403,7 +403,8 @@ object desugar { // implicit wrapper is typechecked in same scope as constructor, so // we can reuse the constructor parameters; no derived params are needed. DefDef(name.toTermName, constrTparams, constrVparamss, classTypeRef, creatorExpr) - .withFlags(Synthetic | Implicit) :: Nil + .withFlags(Synthetic | Implicit) + .withPos(cdef.pos) :: Nil val self1 = { From aad036c4720aac43a41ab8d994d51d71d233031d Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Sat, 19 Dec 2015 18:58:56 +0100 Subject: [PATCH 15/22] Don't flag override errors for synthetic companion objects. --- src/dotty/tools/dotc/typer/RefChecks.scala | 9 ++++++-- tests/pos/t6335.scala | 25 ++++++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 tests/pos/t6335.scala diff --git a/src/dotty/tools/dotc/typer/RefChecks.scala b/src/dotty/tools/dotc/typer/RefChecks.scala index 00518278c20a..7ccb3d10398e 100644 --- a/src/dotty/tools/dotc/typer/RefChecks.scala +++ b/src/dotty/tools/dotc/typer/RefChecks.scala @@ -211,7 +211,7 @@ object RefChecks { if (!(hasErrors && member.is(Synthetic) && member.is(Module))) { // suppress errors relating toi synthetic companion objects if other override // errors (e.g. relating to the companion class) have already been reported. - if (member.owner == clazz) ctx.error(fullmsg, member.pos) + if (member.owner == clazz) ctx.error(fullmsg+", member = $member", member.pos) else mixinOverrideErrors += new MixinOverrideError(member, fullmsg) hasErrors = true } @@ -221,6 +221,11 @@ object RefChecks { emitOverrideError(overrideErrorMsg(msg)) } + def autoOverride(sym: Symbol) = + sym.is(Synthetic) && ( + desugar.isDesugaredCaseClassMethodName(member.name) || // such names are added automatically, can't have an override preset. + sym.is(Module)) // synthetic companion + def overrideAccessError() = { ctx.log(i"member: ${member.showLocated} ${member.flags}") // DEBUG ctx.log(i"other: ${other.showLocated} ${other.flags}") // DEBUG @@ -300,7 +305,7 @@ object RefChecks { !member.isAnyOverride) { // (*) Exclusion for default getters, fixes SI-5178. We cannot assign the Override flag to // the default getter: one default getter might sometimes override, sometimes not. Example in comment on ticket. - if (member.is(Synthetic) && desugar.isDesugaredCaseClassMethodName(member.name)) // such names are added automatically, can't have an override preset. + if (autoOverride(member)) member.setFlag(Override) else if (member.owner != clazz && other.owner != clazz && !(other.owner derivesFrom member.owner)) emitOverrideError( diff --git a/tests/pos/t6335.scala b/tests/pos/t6335.scala new file mode 100644 index 000000000000..eb052db1998a --- /dev/null +++ b/tests/pos/t6335.scala @@ -0,0 +1,25 @@ +object E extends Z { + def X = 3 + implicit class X(val i: Int) { + def xx = i + } + + def Y(a: Any) = 0 + object Y + implicit class Y(val i: String) { def yy = i } + + implicit class Z(val i: Boolean) { def zz = i } +} + +trait Z { + def Z = 0 +} + +object Test { + import E._ + 0.xx + + "".yy + + true.zz +} From 05bc8a088a9ecabaa9d7424d51c8f4f218d0fd74 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Sat, 19 Dec 2015 19:03:08 +0100 Subject: [PATCH 16/22] Turn println into log --- src/dotty/tools/dotc/transform/SuperAccessors.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dotty/tools/dotc/transform/SuperAccessors.scala b/src/dotty/tools/dotc/transform/SuperAccessors.scala index 2febd267386b..ae9c493ae812 100644 --- a/src/dotty/tools/dotc/transform/SuperAccessors.scala +++ b/src/dotty/tools/dotc/transform/SuperAccessors.scala @@ -112,7 +112,7 @@ class SuperAccessors(thisTransformer: DenotTransformer) { ctx.error( i"${sym.showLocated} is accessed from super. It may not be abstract unless it is overridden by a member declared `abstract' and `override'", sel.pos) - else println(i"ok super $sel ${sym.showLocated} $member $clazz ${member.isIncompleteIn(clazz)}") + else ctx.log(i"ok super $sel ${sym.showLocated} $member $clazz ${member.isIncompleteIn(clazz)}") } else if (mix == tpnme.EMPTY && !(sym.owner is Trait)) // SI-4989 Check if an intermediate class between `clazz` and `sym.owner` redeclares the method as abstract. From ded374a5229a17c5c6dc04e50044d62422dc1023 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Sat, 19 Dec 2015 22:31:00 +0100 Subject: [PATCH 17/22] Fix eta expansion revios fix crashed for nullary functions --- src/dotty/tools/dotc/typer/EtaExpansion.scala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/dotty/tools/dotc/typer/EtaExpansion.scala b/src/dotty/tools/dotc/typer/EtaExpansion.scala index 42fcd94a46a9..aa210e6ed40a 100644 --- a/src/dotty/tools/dotc/typer/EtaExpansion.scala +++ b/src/dotty/tools/dotc/typer/EtaExpansion.scala @@ -142,7 +142,8 @@ object EtaExpansion { val params = (mt.paramNames, paramTypes).zipped.map((name, tpe) => ValDef(name, TypeTree(tpe), EmptyTree).withFlags(Synthetic | Param).withPos(tree.pos)) var ids: List[Tree] = mt.paramNames map (name => Ident(name).withPos(tree.pos)) - if (mt.paramTypes.last.isRepeatedParam)ids = ids.init :+ repeated(ids.last) + if (mt.paramTypes.nonEmpty && mt.paramTypes.last.isRepeatedParam) + ids = ids.init :+ repeated(ids.last) val body = Apply(lifted, ids) val fn = untpd.Function(params, body) if (defs.nonEmpty) untpd.Block(defs.toList map untpd.TypedSplice, fn) else fn From bde77d4c43dd994e0b9bd7feb9abf74bb9678e12 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Sun, 20 Dec 2015 11:50:32 +0100 Subject: [PATCH 18/22] Don't do eta expansion on bottom types --- src/dotty/tools/dotc/core/TypeApplications.scala | 10 +++------- src/dotty/tools/dotc/core/Types.scala | 12 ++++++++---- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/dotty/tools/dotc/core/TypeApplications.scala b/src/dotty/tools/dotc/core/TypeApplications.scala index 9a12d263525d..7d1b36db0694 100644 --- a/src/dotty/tools/dotc/core/TypeApplications.scala +++ b/src/dotty/tools/dotc/core/TypeApplications.scala @@ -373,14 +373,10 @@ class TypeApplications(val self: Type) extends AnyVal { //.ensuring(res => res.EtaReduce =:= self, s"res = $res, core = ${res.EtaReduce}, self = $self, hc = ${res.hashCode}") } - /** Eta expand the prefix in front of any refinements. - * @param tparamsForBottom Type parameters to use if core is a bottom type - */ - def EtaExpandCore(tparamsForBottom: List[TypeSymbol])(implicit ctx: Context): Type = self.stripTypeVar match { + /** Eta expand the prefix in front of any refinements. */ + def EtaExpandCore(implicit ctx: Context): Type = self.stripTypeVar match { case self: RefinedType => - self.derivedRefinedType(self.parent.EtaExpandCore(tparamsForBottom), self.refinedName, self.refinedInfo) - case tp: TypeRef if defn.isBottomClass(tp.symbol) => - self.LambdaAbstract(tparamsForBottom) + self.derivedRefinedType(self.parent.EtaExpandCore, self.refinedName, self.refinedInfo) case _ => self.EtaExpand(self.typeParams) } diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala index 624549bac2a8..13f1ff9a9a3c 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -1538,8 +1538,10 @@ object Types { * * T#A --> B if A is bound to an alias `= B` in T * - * (S & T)#A --> S#A if T does not have a member namd A - * --> T#A if S does not have a member namd A + * If Config.splitProjections is set: + * + * (S & T)#A --> S#A if T does not have a member named A + * --> T#A if S does not have a member named A * --> S#A & T#A otherwise * (S | T)#A --> S#A | T#A */ @@ -1548,11 +1550,13 @@ object Types { else if (isType) { val res = prefix.lookupRefined(name) if (res.exists) res - else if (name == tpnme.hkApply && prefix.classNotLambda) + else if (name == tpnme.hkApply && prefix.classNotLambda) { // After substitution we might end up with a type like // `C { type hk$0 = T0; ...; type hk$n = Tn } # $Apply` // where C is a class. In that case we eta expand `C`. - derivedSelect(prefix.EtaExpandCore(this.prefix.typeConstructor.typeParams)) + if (defn.isBottomType(prefix)) prefix.classSymbol.typeRef + else derivedSelect(prefix.EtaExpandCore) + } else if (Config.splitProjections) prefix match { case prefix: AndType => From a2f0fc167bddda7bdf1f6b3fa8e091770a80b379 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Sun, 20 Dec 2015 11:52:01 +0100 Subject: [PATCH 19/22] Fix hk comparison between class and range lambda In a situation like List <: [X] -> <: GenTraversable[X] We have to ask whether the rhs contains the instantiated lhs, not whether it is a supertype. --- src/dotty/tools/dotc/core/TypeComparer.scala | 19 +++++++++++++++---- tests/pos/hklub0.scala | 5 +++++ tests/pos/hkrange.scala | 5 +++++ 3 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 tests/pos/hklub0.scala create mode 100644 tests/pos/hkrange.scala diff --git a/src/dotty/tools/dotc/core/TypeComparer.scala b/src/dotty/tools/dotc/core/TypeComparer.scala index 1e90bd6c89c0..d5d8115428a5 100644 --- a/src/dotty/tools/dotc/core/TypeComparer.scala +++ b/src/dotty/tools/dotc/core/TypeComparer.scala @@ -124,7 +124,7 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling { pendingSubTypes = new mutable.HashSet[(Type, Type)] ctx.log(s"!!! deep subtype recursion involving ${tp1.show} <:< ${tp2.show}, constraint = ${state.constraint.show}") ctx.log(s"!!! constraint = ${constraint.show}") - if (ctx.settings.YnoDeepSubtypes.value) throw new Error("deep subtype") + assert(!ctx.settings.YnoDeepSubtypes.value) //throw new Error("deep subtype") if (Config.traceDeepSubTypeRecursions && !this.isInstanceOf[ExplainingTypeComparer]) ctx.log(TypeComparer.explained(implicit ctx => ctx.typeComparer.isSubType(tp1, tp2))) } @@ -598,7 +598,11 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling { other.isInstanceOf[TypeRef] && args.length == other.typeParams.length && { val applied = other.appliedTo(argRefs(rt, args.length)) - if (inOrder) isSubType(body, applied) else isSubType(applied, body) + if (inOrder) isSubType(body, applied) + else body match { + case body: TypeBounds => body.contains(applied) + case _ => isSubType(applied, body) + } } case _ => false @@ -1233,7 +1237,7 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling { /** Show subtype goal that led to an assertion failure */ def showGoal(tp1: Type, tp2: Type)(implicit ctx: Context) = { - ctx.println(disambiguated(implicit ctx => s"assertion failure for ${tp1.show} <:< ${tp2.show}, frozen = $frozenConstraint")) + println(disambiguated(implicit ctx => s"assertion failure for ${tp1.show} <:< ${tp2.show}, frozen = $frozenConstraint")) def explainPoly(tp: Type) = tp match { case tp: PolyParam => ctx.println(s"polyparam ${tp.show} found in ${tp.binder.show}") case tp: TypeRef if tp.symbol.exists => ctx.println(s"typeref ${tp.show} found in ${tp.symbol.owner.show}") @@ -1323,10 +1327,17 @@ class ExplainingTypeComparer(initctx: Context) extends TypeComparer(initctx) { override def compareHkApply(projection: NamedType, other: Type, inOrder: Boolean) = if (projection.name == tpnme.hkApply) - traceIndented(i"compareHK $projection, $other, $inOrder") { + traceIndented(i"compareHkApply $projection, $other, $inOrder") { super.compareHkApply(projection, other, inOrder) } else super.compareHkApply(projection, other, inOrder) + override def compareHkLambda(rt: RefinedType, other: Type, inOrder: Boolean) = + if (rt.refinedName == tpnme.hkApply) + traceIndented(i"compareHkLambda $rt, $other, $inOrder") { + super.compareHkLambda(rt, other, inOrder) + } + else super.compareHkLambda(rt, other, inOrder) + override def toString = "Subtype trace:" + { try b.toString finally b.clear() } } diff --git a/tests/pos/hklub0.scala b/tests/pos/hklub0.scala new file mode 100644 index 000000000000..36cd46332c28 --- /dev/null +++ b/tests/pos/hklub0.scala @@ -0,0 +1,5 @@ +object Test { + val a : scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq] = null + val b : scala.collection.generic.GenericCompanion[scala.collection.mutable.Seq] = null + List(a, b) // immutable.this.List.apply[scala.collection.generic.GenericCompanion[Seq]](Test.this.a, Test.this.b) +} diff --git a/tests/pos/hkrange.scala b/tests/pos/hkrange.scala new file mode 100644 index 000000000000..a6803230eda3 --- /dev/null +++ b/tests/pos/hkrange.scala @@ -0,0 +1,5 @@ +class A { + def f[CC[X] <: Traversable[X]](x: CC[Int]) = () + + f(1 to 5) +} From f780a371a3716c6917a510ed72a5927704634bb3 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Sun, 20 Dec 2015 11:52:55 +0100 Subject: [PATCH 20/22] Make isBottomType work for derives types as well. --- src/dotty/tools/dotc/core/Definitions.scala | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/dotty/tools/dotc/core/Definitions.scala b/src/dotty/tools/dotc/core/Definitions.scala index 5f794f2d51de..a7fecce8ec24 100644 --- a/src/dotty/tools/dotc/core/Definitions.scala +++ b/src/dotty/tools/dotc/core/Definitions.scala @@ -589,10 +589,7 @@ class Definitions { } def isBottomClass(cls: Symbol) = cls == NothingClass || cls == NullClass - def isBottomType(tp: Type) = tp match { - case tp: TypeRef => isBottomClass(tp.symbol) - case _ => false - } + def isBottomType(tp: Type) = tp.derivesFrom(NothingClass) || tp.derivesFrom(NullClass) def isFunctionClass(cls: Symbol) = isVarArityClass(cls, tpnme.Function) def isAbstractFunctionClass(cls: Symbol) = isVarArityClass(cls, tpnme.AbstractFunction) From 581fee04f808d6f7759f98358e7475e6a58138e3 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Sun, 20 Dec 2015 12:17:14 +0100 Subject: [PATCH 21/22] Fix problem dealing with symbolic import renames --- src/dotty/tools/dotc/typer/Typer.scala | 2 +- tests/pos/seq-ordering.scala | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 tests/pos/seq-ordering.scala diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala index e5509d50f1cb..182eab0ef21b 100644 --- a/src/dotty/tools/dotc/typer/Typer.scala +++ b/src/dotty/tools/dotc/typer/Typer.scala @@ -165,7 +165,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit tree.pos) found } - val Name = name.toTermName + val Name = name.toTermName.decode selectors match { case Pair(Ident(from), Ident(Name)) :: rest => val selName = if (name.isTypeName) from.toTypeName else from diff --git a/tests/pos/seq-ordering.scala b/tests/pos/seq-ordering.scala new file mode 100644 index 000000000000..517d8ae8aafe --- /dev/null +++ b/tests/pos/seq-ordering.scala @@ -0,0 +1,9 @@ +import Ordering.Implicits._ + +class A { + import Predef.{ implicitly => ? } + + ?[Ordering[List[Int]]] + ?[Ordering[IndexedSeq[(Int, String)]]] + ?[Ordering[Seq[Seq[Int]]]] +} From e51b8845fb20fe3a4e1c655d4b72e2833906bbc2 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Sun, 20 Dec 2015 22:00:29 +0100 Subject: [PATCH 22/22] The big pending/pos test triage --- .../pos/IterableSelfRec.scala | 1 + .../{pending => invalid}/pos/contrib701.scala | 0 .../pos/cycle-jsoup.flags | 0 .../pos/cycle-jsoup.scala | 0 .../{pending => invalid}/pos/depexists.scala | 0 .../pos/dotless-targs.scala | 1 + .../{pending => invalid}/pos/five-dot-f.flags | 0 .../{pending => invalid}/pos/five-dot-f.scala | 0 .../{pending => invalid}/pos/functions.scala | 0 .../pos/generic-sigs.scala | 0 tests/{pending => invalid}/pos/patmat.scala | 0 .../pos/pos-bug1241.scala | 0 .../pos/specializes-sym-crash.scala | 5 +- tests/{pending => invalid}/pos/t2782.scala | 0 tests/{pending => invalid}/pos/t3577.scala | 3 + tests/invalid/pos/t3856.scala | 16 + tests/{pending => invalid}/pos/t4202.scala | 2 + tests/{pending => invalid}/pos/t4237.scala | 1 + tests/{pending => invalid}/pos/t4363.scala | 1 + .../{pending => invalid}/pos/t4365/a_1.scala | 1 + .../{pending => invalid}/pos/t4365/b_1.scala | 0 tests/{pending => invalid}/pos/t4553.scala | 1 + tests/{pending => invalid}/pos/t5022.scala | 0 tests/{pending => invalid}/pos/t5119.scala | 0 tests/{pending => invalid}/pos/t5130.scala | 0 tests/{pending => invalid}/pos/t5156.scala | 0 tests/{pending => invalid}/pos/t533.scala | 0 tests/{pending => invalid}/pos/t5626.scala | 0 tests/{pending => invalid}/pos/t5654.scala | 0 .../{pending => invalid}/pos/t6169/Exist.java | 0 .../pos/t6169/ExistF.java | 0 .../pos/t6169/ExistIndir.java | 0 tests/{pending => invalid}/pos/t6169/OP.java | 0 .../{pending => invalid}/pos/t6169/Skin.java | 0 .../pos/t6169/Skinnable.java | 0 .../pos/t6169/skinnable.scala | 0 .../pos/t6169/t6169.scala | 0 tests/{pending => invalid}/pos/t6367.scala | 0 tests/{pending => invalid}/pos/t711.scala | 0 tests/{pending => invalid}/pos/t7505.scala | 0 tests/{pending => invalid}/pos/t8023.scala | 1 + tests/{pending => invalid}/pos/t8219b.scala | 0 tests/{pending => invalid}/pos/t8224.scala | 1 + .../{pending => invalid}/pos/ticket2251.scala | 0 .../pos/typesafecons.scala | 0 .../{pending => invalid}/pos/unapplySeq.scala | 0 tests/{pending/pos => new}/imports-pos.scala | 0 tests/{pending/pos => new}/infer2-pos.scala | 0 tests/{pending/pos => new}/looping-jsig.scala | 0 tests/{pending/pos => new}/matthias1.scala | 0 tests/{pending/pos => new}/michel6.scala | 0 tests/{pending/pos => new}/moduletrans.scala | 0 .../package-implicit/ActorRef.scala | 0 .../package-implicit/DataFlow.scala | 0 .../package-implicit/package.scala | 0 tests/{pending/pos => new}/patterns.scala | 0 tests/{pending/pos => new}/patterns1.scala | 0 tests/{pending/pos => new}/pmbug.scala | 0 .../private-types-after-typer.scala | 0 tests/{pending/pos => new}/selftails.scala | 0 tests/{pending/pos => new}/seqtest2.scala | 0 tests/pending/pos/hklub0.scala | 5 - tests/pending/pos/sammy_poly.flags | 1 - tests/pending/pos/sealed-final.flags | 1 - .../pos/{t5545 => spec-t5545}/S_1.scala | 0 .../pos/{t5545 => spec-t5545}/S_2.scala | 0 tests/pending/pos/t1843.scala | 24 - tests/pending/pos/t2613.scala | 11 - tests/pending/pos/t3252.flags | 1 - tests/pending/pos/t3856.scala | 9 - tests/pending/pos/t4176b.scala | 5 - tests/pending/pos/t4269.scala | 2 +- tests/pending/pos/t4579.scala | 518 ------------------ tests/pending/pos/t4760.scala | 34 -- tests/pending/pos/t5845.scala | 8 +- tests/pending/pos/t6335.scala | 25 - tests/pending/pos/t6976/Exts_1.scala | 2 +- tests/pending/pos/t7517.scala | 1 + tests/pending/pos/t7902.scala | 1 + tests/pending/pos/t7919.scala | 6 - tests/{new => pos}/conforms.scala | 0 tests/{pending => }/pos/constfold.scala | 0 .../pos/contextbounds-implicits-new.scala | 0 .../pos/delambdafy-lambdalift.scala | 0 tests/{pending => }/pos/exbound.scala | 0 tests/pos/hkrange.scala | 5 - tests/{new => pos}/implicits.scala | 0 tests/{pending => }/pos/philippe4.scala | 0 tests/pos/seq-ordering.scala | 9 - tests/{pending => }/pos/t1048.scala | 0 tests/pos/t1843.scala | 5 +- tests/{pending => }/pos/t3274.scala | 0 tests/{pending => }/pos/t3477.scala | 0 tests/{pending => }/pos/t3480.scala | 0 tests/{pending => }/pos/t3498-new.scala | 0 tests/{pending => }/pos/t3534.scala | 0 tests/{pending => }/pos/t3568.scala | 0 tests/{pending => }/pos/t3582b.scala | 0 tests/{pending => }/pos/t360.scala | 0 tests/{pending => }/pos/t3612.scala | 0 tests/{pending => }/pos/t3688.scala | 0 tests/{pending => }/pos/t3777.scala | 0 tests/{pending => }/pos/t3859.scala | 0 tests/{pending => }/pos/t3869.scala | 0 tests/{pending => }/pos/t3960.scala | 0 tests/{pending => }/pos/t3986.scala | 0 tests/{pending => }/pos/t404.scala | 0 tests/{pending => }/pos/t415.scala | 0 tests/{pending => }/pos/t4176.scala | 0 tests/{pending => }/pos/t430-feb09.scala | 0 tests/{pending => }/pos/t4336.scala | 0 tests/{pending => }/pos/t4345.scala | 0 tests/{pending => }/pos/t4545.scala | 0 tests/{pending => }/pos/t460.scala | 0 tests/{pending => }/pos/t4853.scala | 0 tests/{pending => }/pos/t4859.scala | 0 tests/pos/t4911.flags | 1 + tests/{pending => }/pos/t4911.scala | 0 tests/{pending => }/pos/t4975.scala | 0 tests/{pending => }/pos/t5012.scala | 0 tests/{pending => }/pos/t5029.scala | 0 tests/{pending => }/pos/t5041.scala | 0 tests/{pending => }/pos/t5082.scala | 0 tests/{pending => }/pos/t5541.scala | 0 tests/{pending => }/pos/t566.scala | 0 tests/{pending => }/pos/t5720-ownerous.scala | 0 tests/{pending => }/pos/t5729.scala | 0 tests/{pending => }/pos/t573.scala | 0 tests/{pending => }/pos/t5859.scala | 0 tests/{pending => }/pos/t5877.scala | 0 tests/{pending => }/pos/t5877b.scala | 0 tests/{pending => }/pos/t5900a.scala | 0 tests/{pending => }/pos/t5932.scala | 0 tests/{pending => }/pos/t596.scala | 0 tests/{pending => }/pos/t5967.scala | 0 tests/{pending => }/pos/t6014.scala | 0 tests/{pending => }/pos/t604.scala | 0 tests/{pending => }/pos/t6089b.scala | 0 tests/{pending => }/pos/t6117.scala | 0 .../pos/t6123-explaintypes-implicits.scala | 0 tests/{pending => }/pos/t6145.scala | 0 tests/{pending => }/pos/t6184.scala | 0 tests/{pending => }/pos/t6208.scala | 0 tests/{pending => }/pos/t6225.scala | 0 tests/{pending => }/pos/t6231.scala | 0 tests/{pending => }/pos/t6231b.scala | 0 tests/{pending => }/pos/t6575a.scala | 0 tests/{pending => }/pos/t6600.scala | 0 tests/{pending => }/pos/t661.scala | 2 +- tests/{pending => }/pos/t6664b.scala | 0 tests/{pending => }/pos/t697.scala | 0 tests/{pending => }/pos/t6994.scala | 0 tests/{pending => }/pos/t7011.scala | 0 tests/{pending => }/pos/t703.scala | 0 tests/{pending => }/pos/t704.scala | 0 tests/{pending => }/pos/t7126.scala | 0 tests/{pending => }/pos/t7226.scala | 0 tests/{pending => }/pos/t7285a.scala | 9 + tests/{pending => }/pos/t7475a.scala | 0 tests/{pending => }/pos/t7475b.scala | 0 tests/{pending => }/pos/t7520.scala | 0 tests/{pending => }/pos/t758.scala | 0 .../pos/t7591/Demo.scala => pos/t7591.scala} | 0 tests/{pending => }/pos/t7782.scala | 0 tests/{pending => }/pos/t7782b.scala | 0 tests/{pending => }/pos/t7785.scala | 0 tests/{pending => }/pos/t7853.scala | 0 tests/{pending => }/pos/t788.scala | 0 tests/{pending => }/pos/t7928.scala | 0 tests/{pending => }/pos/t796.scala | 0 tests/{pending => }/pos/t7983.scala | 0 tests/{pending => }/pos/t802.scala | 4 +- tests/{pending => }/pos/t8023b.scala | 0 tests/{pending => }/pos/t8045.scala | 0 tests/{pending => }/pos/t805.scala | 4 +- tests/{pending => }/pos/t8128.scala | 0 tests/{pending => }/pos/t8177a.scala | 0 tests/{pending => }/pos/t8187.scala | 0 tests/{pending => }/pos/t8219.scala | 0 tests/{pending => }/pos/t8367.scala | 0 tests/{pending => }/pos/t8369a.scala | 0 tests/{pending => }/pos/t873.scala | 0 tests/{pending => }/pos/t911.scala | 0 .../pos/tcpoly_infer_ticket1864.scala | 0 .../{pending => }/pos/tcpoly_ticket2096.scala | 0 .../pos/tcpoly_variance_pos.scala | 0 tests/{pending => }/pos/ted.scala | 0 tests/{pending => }/pos/test4.scala | 0 tests/{pending => }/pos/test5.scala | 0 tests/{pending => }/pos/test5refine.scala | 0 tests/{pending => }/pos/typealiases.scala | 0 .../{pending => }/pos/typerep-stephane.scala | 0 .../pos/virtpatmat_alts_subst.scala | 0 .../{pending => }/pos/virtpatmat_exist1.scala | 0 .../{pending => }/pos/virtpatmat_exist3.scala | 0 .../pos/virtpatmat_exist_uncurry.scala | 0 196 files changed, 57 insertions(+), 670 deletions(-) rename tests/{pending => invalid}/pos/IterableSelfRec.scala (95%) rename tests/{pending => invalid}/pos/contrib701.scala (100%) rename tests/{pending => invalid}/pos/cycle-jsoup.flags (100%) rename tests/{pending => invalid}/pos/cycle-jsoup.scala (100%) rename tests/{pending => invalid}/pos/depexists.scala (100%) rename tests/{pending => invalid}/pos/dotless-targs.scala (75%) rename tests/{pending => invalid}/pos/five-dot-f.flags (100%) rename tests/{pending => invalid}/pos/five-dot-f.scala (100%) rename tests/{pending => invalid}/pos/functions.scala (100%) rename tests/{pending => invalid}/pos/generic-sigs.scala (100%) rename tests/{pending => invalid}/pos/patmat.scala (100%) rename tests/{pending => invalid}/pos/pos-bug1241.scala (100%) rename tests/{pending => invalid}/pos/specializes-sym-crash.scala (75%) rename tests/{pending => invalid}/pos/t2782.scala (100%) rename tests/{pending => invalid}/pos/t3577.scala (79%) create mode 100644 tests/invalid/pos/t3856.scala rename tests/{pending => invalid}/pos/t4202.scala (69%) rename tests/{pending => invalid}/pos/t4237.scala (88%) rename tests/{pending => invalid}/pos/t4363.scala (71%) rename tests/{pending => invalid}/pos/t4365/a_1.scala (86%) rename tests/{pending => invalid}/pos/t4365/b_1.scala (100%) rename tests/{pending => invalid}/pos/t4553.scala (84%) rename tests/{pending => invalid}/pos/t5022.scala (100%) rename tests/{pending => invalid}/pos/t5119.scala (100%) rename tests/{pending => invalid}/pos/t5130.scala (100%) rename tests/{pending => invalid}/pos/t5156.scala (100%) rename tests/{pending => invalid}/pos/t533.scala (100%) rename tests/{pending => invalid}/pos/t5626.scala (100%) rename tests/{pending => invalid}/pos/t5654.scala (100%) rename tests/{pending => invalid}/pos/t6169/Exist.java (100%) rename tests/{pending => invalid}/pos/t6169/ExistF.java (100%) rename tests/{pending => invalid}/pos/t6169/ExistIndir.java (100%) rename tests/{pending => invalid}/pos/t6169/OP.java (100%) rename tests/{pending => invalid}/pos/t6169/Skin.java (100%) rename tests/{pending => invalid}/pos/t6169/Skinnable.java (100%) rename tests/{pending => invalid}/pos/t6169/skinnable.scala (100%) rename tests/{pending => invalid}/pos/t6169/t6169.scala (100%) rename tests/{pending => invalid}/pos/t6367.scala (100%) rename tests/{pending => invalid}/pos/t711.scala (100%) rename tests/{pending => invalid}/pos/t7505.scala (100%) rename tests/{pending => invalid}/pos/t8023.scala (86%) rename tests/{pending => invalid}/pos/t8219b.scala (100%) rename tests/{pending => invalid}/pos/t8224.scala (80%) rename tests/{pending => invalid}/pos/ticket2251.scala (100%) rename tests/{pending => invalid}/pos/typesafecons.scala (100%) rename tests/{pending => invalid}/pos/unapplySeq.scala (100%) rename tests/{pending/pos => new}/imports-pos.scala (100%) rename tests/{pending/pos => new}/infer2-pos.scala (100%) rename tests/{pending/pos => new}/looping-jsig.scala (100%) rename tests/{pending/pos => new}/matthias1.scala (100%) rename tests/{pending/pos => new}/michel6.scala (100%) rename tests/{pending/pos => new}/moduletrans.scala (100%) rename tests/{pending/pos => new}/package-implicit/ActorRef.scala (100%) rename tests/{pending/pos => new}/package-implicit/DataFlow.scala (100%) rename tests/{pending/pos => new}/package-implicit/package.scala (100%) rename tests/{pending/pos => new}/patterns.scala (100%) rename tests/{pending/pos => new}/patterns1.scala (100%) rename tests/{pending/pos => new}/pmbug.scala (100%) rename tests/{pending/pos => new}/private-types-after-typer.scala (100%) rename tests/{pending/pos => new}/selftails.scala (100%) rename tests/{pending/pos => new}/seqtest2.scala (100%) delete mode 100644 tests/pending/pos/hklub0.scala delete mode 100644 tests/pending/pos/sammy_poly.flags delete mode 100644 tests/pending/pos/sealed-final.flags rename tests/pending/pos/{t5545 => spec-t5545}/S_1.scala (100%) rename tests/pending/pos/{t5545 => spec-t5545}/S_2.scala (100%) delete mode 100644 tests/pending/pos/t1843.scala delete mode 100644 tests/pending/pos/t2613.scala delete mode 100644 tests/pending/pos/t3252.flags delete mode 100644 tests/pending/pos/t3856.scala delete mode 100644 tests/pending/pos/t4176b.scala delete mode 100644 tests/pending/pos/t4579.scala delete mode 100644 tests/pending/pos/t4760.scala delete mode 100644 tests/pending/pos/t6335.scala delete mode 100644 tests/pending/pos/t7919.scala rename tests/{new => pos}/conforms.scala (100%) rename tests/{pending => }/pos/constfold.scala (100%) rename tests/{pending => }/pos/contextbounds-implicits-new.scala (100%) rename tests/{pending => }/pos/delambdafy-lambdalift.scala (100%) rename tests/{pending => }/pos/exbound.scala (100%) delete mode 100644 tests/pos/hkrange.scala rename tests/{new => pos}/implicits.scala (100%) rename tests/{pending => }/pos/philippe4.scala (100%) delete mode 100644 tests/pos/seq-ordering.scala rename tests/{pending => }/pos/t1048.scala (100%) rename tests/{pending => }/pos/t3274.scala (100%) rename tests/{pending => }/pos/t3477.scala (100%) rename tests/{pending => }/pos/t3480.scala (100%) rename tests/{pending => }/pos/t3498-new.scala (100%) rename tests/{pending => }/pos/t3534.scala (100%) rename tests/{pending => }/pos/t3568.scala (100%) rename tests/{pending => }/pos/t3582b.scala (100%) rename tests/{pending => }/pos/t360.scala (100%) rename tests/{pending => }/pos/t3612.scala (100%) rename tests/{pending => }/pos/t3688.scala (100%) rename tests/{pending => }/pos/t3777.scala (100%) rename tests/{pending => }/pos/t3859.scala (100%) rename tests/{pending => }/pos/t3869.scala (100%) rename tests/{pending => }/pos/t3960.scala (100%) rename tests/{pending => }/pos/t3986.scala (100%) rename tests/{pending => }/pos/t404.scala (100%) rename tests/{pending => }/pos/t415.scala (100%) rename tests/{pending => }/pos/t4176.scala (100%) rename tests/{pending => }/pos/t430-feb09.scala (100%) rename tests/{pending => }/pos/t4336.scala (100%) rename tests/{pending => }/pos/t4345.scala (100%) rename tests/{pending => }/pos/t4545.scala (100%) rename tests/{pending => }/pos/t460.scala (100%) rename tests/{pending => }/pos/t4853.scala (100%) rename tests/{pending => }/pos/t4859.scala (100%) create mode 100644 tests/pos/t4911.flags rename tests/{pending => }/pos/t4911.scala (100%) rename tests/{pending => }/pos/t4975.scala (100%) rename tests/{pending => }/pos/t5012.scala (100%) rename tests/{pending => }/pos/t5029.scala (100%) rename tests/{pending => }/pos/t5041.scala (100%) rename tests/{pending => }/pos/t5082.scala (100%) rename tests/{pending => }/pos/t5541.scala (100%) rename tests/{pending => }/pos/t566.scala (100%) rename tests/{pending => }/pos/t5720-ownerous.scala (100%) rename tests/{pending => }/pos/t5729.scala (100%) rename tests/{pending => }/pos/t573.scala (100%) rename tests/{pending => }/pos/t5859.scala (100%) rename tests/{pending => }/pos/t5877.scala (100%) rename tests/{pending => }/pos/t5877b.scala (100%) rename tests/{pending => }/pos/t5900a.scala (100%) rename tests/{pending => }/pos/t5932.scala (100%) rename tests/{pending => }/pos/t596.scala (100%) rename tests/{pending => }/pos/t5967.scala (100%) rename tests/{pending => }/pos/t6014.scala (100%) rename tests/{pending => }/pos/t604.scala (100%) rename tests/{pending => }/pos/t6089b.scala (100%) rename tests/{pending => }/pos/t6117.scala (100%) rename tests/{pending => }/pos/t6123-explaintypes-implicits.scala (100%) rename tests/{pending => }/pos/t6145.scala (100%) rename tests/{pending => }/pos/t6184.scala (100%) rename tests/{pending => }/pos/t6208.scala (100%) rename tests/{pending => }/pos/t6225.scala (100%) rename tests/{pending => }/pos/t6231.scala (100%) rename tests/{pending => }/pos/t6231b.scala (100%) rename tests/{pending => }/pos/t6575a.scala (100%) rename tests/{pending => }/pos/t6600.scala (100%) rename tests/{pending => }/pos/t661.scala (88%) rename tests/{pending => }/pos/t6664b.scala (100%) rename tests/{pending => }/pos/t697.scala (100%) rename tests/{pending => }/pos/t6994.scala (100%) rename tests/{pending => }/pos/t7011.scala (100%) rename tests/{pending => }/pos/t703.scala (100%) rename tests/{pending => }/pos/t704.scala (100%) rename tests/{pending => }/pos/t7126.scala (100%) rename tests/{pending => }/pos/t7226.scala (100%) rename tests/{pending => }/pos/t7285a.scala (94%) rename tests/{pending => }/pos/t7475a.scala (100%) rename tests/{pending => }/pos/t7475b.scala (100%) rename tests/{pending => }/pos/t7520.scala (100%) rename tests/{pending => }/pos/t758.scala (100%) rename tests/{pending/pos/t7591/Demo.scala => pos/t7591.scala} (100%) rename tests/{pending => }/pos/t7782.scala (100%) rename tests/{pending => }/pos/t7782b.scala (100%) rename tests/{pending => }/pos/t7785.scala (100%) rename tests/{pending => }/pos/t7853.scala (100%) rename tests/{pending => }/pos/t788.scala (100%) rename tests/{pending => }/pos/t7928.scala (100%) rename tests/{pending => }/pos/t796.scala (100%) rename tests/{pending => }/pos/t7983.scala (100%) rename tests/{pending => }/pos/t802.scala (87%) rename tests/{pending => }/pos/t8023b.scala (100%) rename tests/{pending => }/pos/t8045.scala (100%) rename tests/{pending => }/pos/t805.scala (76%) rename tests/{pending => }/pos/t8128.scala (100%) rename tests/{pending => }/pos/t8177a.scala (100%) rename tests/{pending => }/pos/t8187.scala (100%) rename tests/{pending => }/pos/t8219.scala (100%) rename tests/{pending => }/pos/t8367.scala (100%) rename tests/{pending => }/pos/t8369a.scala (100%) rename tests/{pending => }/pos/t873.scala (100%) rename tests/{pending => }/pos/t911.scala (100%) rename tests/{pending => }/pos/tcpoly_infer_ticket1864.scala (100%) rename tests/{pending => }/pos/tcpoly_ticket2096.scala (100%) rename tests/{pending => }/pos/tcpoly_variance_pos.scala (100%) rename tests/{pending => }/pos/ted.scala (100%) rename tests/{pending => }/pos/test4.scala (100%) rename tests/{pending => }/pos/test5.scala (100%) rename tests/{pending => }/pos/test5refine.scala (100%) rename tests/{pending => }/pos/typealiases.scala (100%) rename tests/{pending => }/pos/typerep-stephane.scala (100%) rename tests/{pending => }/pos/virtpatmat_alts_subst.scala (100%) rename tests/{pending => }/pos/virtpatmat_exist1.scala (100%) rename tests/{pending => }/pos/virtpatmat_exist3.scala (100%) rename tests/{pending => }/pos/virtpatmat_exist_uncurry.scala (100%) diff --git a/tests/pending/pos/IterableSelfRec.scala b/tests/invalid/pos/IterableSelfRec.scala similarity index 95% rename from tests/pending/pos/IterableSelfRec.scala rename to tests/invalid/pos/IterableSelfRec.scala index a97833991785..7fd235f1211d 100644 --- a/tests/pending/pos/IterableSelfRec.scala +++ b/tests/invalid/pos/IterableSelfRec.scala @@ -1,3 +1,4 @@ +// This does not currently work because it mixes higher-kinded types and raw type constructors. package dotty.collection package immutable diff --git a/tests/pending/pos/contrib701.scala b/tests/invalid/pos/contrib701.scala similarity index 100% rename from tests/pending/pos/contrib701.scala rename to tests/invalid/pos/contrib701.scala diff --git a/tests/pending/pos/cycle-jsoup.flags b/tests/invalid/pos/cycle-jsoup.flags similarity index 100% rename from tests/pending/pos/cycle-jsoup.flags rename to tests/invalid/pos/cycle-jsoup.flags diff --git a/tests/pending/pos/cycle-jsoup.scala b/tests/invalid/pos/cycle-jsoup.scala similarity index 100% rename from tests/pending/pos/cycle-jsoup.scala rename to tests/invalid/pos/cycle-jsoup.scala diff --git a/tests/pending/pos/depexists.scala b/tests/invalid/pos/depexists.scala similarity index 100% rename from tests/pending/pos/depexists.scala rename to tests/invalid/pos/depexists.scala diff --git a/tests/pending/pos/dotless-targs.scala b/tests/invalid/pos/dotless-targs.scala similarity index 75% rename from tests/pending/pos/dotless-targs.scala rename to tests/invalid/pos/dotless-targs.scala index 8c0e244e4e8e..7394f361acaa 100644 --- a/tests/pending/pos/dotless-targs.scala +++ b/tests/invalid/pos/dotless-targs.scala @@ -1,3 +1,4 @@ +// Type arguments on infix operators are not supported by the syntax class A { def fn1 = List apply 1 def fn2 = List apply[Int] 2 diff --git a/tests/pending/pos/five-dot-f.flags b/tests/invalid/pos/five-dot-f.flags similarity index 100% rename from tests/pending/pos/five-dot-f.flags rename to tests/invalid/pos/five-dot-f.flags diff --git a/tests/pending/pos/five-dot-f.scala b/tests/invalid/pos/five-dot-f.scala similarity index 100% rename from tests/pending/pos/five-dot-f.scala rename to tests/invalid/pos/five-dot-f.scala diff --git a/tests/pending/pos/functions.scala b/tests/invalid/pos/functions.scala similarity index 100% rename from tests/pending/pos/functions.scala rename to tests/invalid/pos/functions.scala diff --git a/tests/pending/pos/generic-sigs.scala b/tests/invalid/pos/generic-sigs.scala similarity index 100% rename from tests/pending/pos/generic-sigs.scala rename to tests/invalid/pos/generic-sigs.scala diff --git a/tests/pending/pos/patmat.scala b/tests/invalid/pos/patmat.scala similarity index 100% rename from tests/pending/pos/patmat.scala rename to tests/invalid/pos/patmat.scala diff --git a/tests/pending/pos/pos-bug1241.scala b/tests/invalid/pos/pos-bug1241.scala similarity index 100% rename from tests/pending/pos/pos-bug1241.scala rename to tests/invalid/pos/pos-bug1241.scala diff --git a/tests/pending/pos/specializes-sym-crash.scala b/tests/invalid/pos/specializes-sym-crash.scala similarity index 75% rename from tests/pending/pos/specializes-sym-crash.scala rename to tests/invalid/pos/specializes-sym-crash.scala index 7778ba277b0f..e0e458170929 100644 --- a/tests/pending/pos/specializes-sym-crash.scala +++ b/tests/invalid/pos/specializes-sym-crash.scala @@ -1,3 +1,4 @@ +// This relies on the naming of the transformed classes which will have to change in the new stdlib. import scala.collection._ trait Foo[+A, @@ -6,12 +7,12 @@ trait Foo[+A, extends Seq[A] with SeqLike[A, This] with IterableView[A, Coll] with IterableViewLike[A, Coll, This] { self => - trait Transformed[+B] extends SeqView[B, Coll] with super.Transformed[B] { + trait TransformedFoo[+B] extends SeqView[B, Coll] with super.Transformed[B] { def length: Int def apply(idx: Int): B override def toString = viewToString } - trait Reversed extends Transformed[A] { + trait Reversed extends TransformedFoo[A] { override def iterator: Iterator[A] = createReversedIterator def length: Int = self.length def apply(idx: Int): A = self.apply(length - 1 - idx) diff --git a/tests/pending/pos/t2782.scala b/tests/invalid/pos/t2782.scala similarity index 100% rename from tests/pending/pos/t2782.scala rename to tests/invalid/pos/t2782.scala diff --git a/tests/pending/pos/t3577.scala b/tests/invalid/pos/t3577.scala similarity index 79% rename from tests/pending/pos/t3577.scala rename to tests/invalid/pos/t3577.scala index 1ac1786c1157..e94b69b4b3ab 100644 --- a/tests/pending/pos/t3577.scala +++ b/tests/invalid/pos/t3577.scala @@ -5,6 +5,9 @@ case class C2(checks: Check[_]*); object C { def m(x : C2): Any = (null: Any) match { case C2(_, rest : _*) => { + // Invalid: Vararg pattern cannot be split between normal and :_* patterns. + // This split also does not work for vararg arguments, so there's no + // good argument it should work for patterns rest.map(_.value) } } diff --git a/tests/invalid/pos/t3856.scala b/tests/invalid/pos/t3856.scala new file mode 100644 index 000000000000..8dfcccb5a8f1 --- /dev/null +++ b/tests/invalid/pos/t3856.scala @@ -0,0 +1,16 @@ +case class C[T](x: T) + +case class CS(xs: C[_]*) + +// t3856 +object Test { + val x = CS(C(5), C("abc")) match { case CS(C(5), xs : _*) => xs } + // Invalid: Vararg pattern cannot be split between normal and :_* patterns. + // This split also does not work for vararg arguments, so there's no + // good argument it should work for patterns + println(x) + + def foo(xs: Int*) = () + val xs = List(1, 2, 3) + foo(1, xs:_*) +} diff --git a/tests/pending/pos/t4202.scala b/tests/invalid/pos/t4202.scala similarity index 69% rename from tests/pending/pos/t4202.scala rename to tests/invalid/pos/t4202.scala index b2a0c0120a05..1bf0bf6ebdd4 100644 --- a/tests/pending/pos/t4202.scala +++ b/tests/invalid/pos/t4202.scala @@ -1,3 +1,5 @@ +// Invalid because syntax has changed; +// template statements cannot be lambdas. object t4202_1 { () => { trait T { diff --git a/tests/pending/pos/t4237.scala b/tests/invalid/pos/t4237.scala similarity index 88% rename from tests/pending/pos/t4237.scala rename to tests/invalid/pos/t4237.scala index 44bc814626fa..45a5050040a4 100644 --- a/tests/pending/pos/t4237.scala +++ b/tests/invalid/pos/t4237.scala @@ -1,3 +1,4 @@ +// Invalid because structural types are not supported. class A { (new { def field = 0; def field_=(i: Int) = () }).field = 5 // compiles as expected (new { def field(implicit i: Int) = 0; def field_=(i: Int) = () }).field = 5 // compiles even with implicit params on getter diff --git a/tests/pending/pos/t4363.scala b/tests/invalid/pos/t4363.scala similarity index 71% rename from tests/pending/pos/t4363.scala rename to tests/invalid/pos/t4363.scala index 64cdcd9356ef..e0ffa8fd9fbf 100644 --- a/tests/pending/pos/t4363.scala +++ b/tests/invalid/pos/t4363.scala @@ -1,3 +1,4 @@ +// Invalid because lambdas can no longer be tenmplate statements. object Test { trait Suite { def bar() = () } diff --git a/tests/pending/pos/t4365/a_1.scala b/tests/invalid/pos/t4365/a_1.scala similarity index 86% rename from tests/pending/pos/t4365/a_1.scala rename to tests/invalid/pos/t4365/a_1.scala index a24b57772d5b..0be5ca8a19e9 100644 --- a/tests/pending/pos/t4365/a_1.scala +++ b/tests/invalid/pos/t4365/a_1.scala @@ -1,3 +1,4 @@ +// Invalid because it relies on internal traits of views that will change their names. import scala.collection._ trait SeqViewLike[+A, diff --git a/tests/pending/pos/t4365/b_1.scala b/tests/invalid/pos/t4365/b_1.scala similarity index 100% rename from tests/pending/pos/t4365/b_1.scala rename to tests/invalid/pos/t4365/b_1.scala diff --git a/tests/pending/pos/t4553.scala b/tests/invalid/pos/t4553.scala similarity index 84% rename from tests/pending/pos/t4553.scala rename to tests/invalid/pos/t4553.scala index e9bef4099428..48846a369c03 100644 --- a/tests/pending/pos/t4553.scala +++ b/tests/invalid/pos/t4553.scala @@ -1,3 +1,4 @@ +// Invalid because hk type parameters may not appear in lower bounds trait VectorLike[+T, +V[A] <: Vector[A]] { def +[S, VResult[S] >: V[S]](v: VResult[S]): Unit } diff --git a/tests/pending/pos/t5022.scala b/tests/invalid/pos/t5022.scala similarity index 100% rename from tests/pending/pos/t5022.scala rename to tests/invalid/pos/t5022.scala diff --git a/tests/pending/pos/t5119.scala b/tests/invalid/pos/t5119.scala similarity index 100% rename from tests/pending/pos/t5119.scala rename to tests/invalid/pos/t5119.scala diff --git a/tests/pending/pos/t5130.scala b/tests/invalid/pos/t5130.scala similarity index 100% rename from tests/pending/pos/t5130.scala rename to tests/invalid/pos/t5130.scala diff --git a/tests/pending/pos/t5156.scala b/tests/invalid/pos/t5156.scala similarity index 100% rename from tests/pending/pos/t5156.scala rename to tests/invalid/pos/t5156.scala diff --git a/tests/pending/pos/t533.scala b/tests/invalid/pos/t533.scala similarity index 100% rename from tests/pending/pos/t533.scala rename to tests/invalid/pos/t533.scala diff --git a/tests/pending/pos/t5626.scala b/tests/invalid/pos/t5626.scala similarity index 100% rename from tests/pending/pos/t5626.scala rename to tests/invalid/pos/t5626.scala diff --git a/tests/pending/pos/t5654.scala b/tests/invalid/pos/t5654.scala similarity index 100% rename from tests/pending/pos/t5654.scala rename to tests/invalid/pos/t5654.scala diff --git a/tests/pending/pos/t6169/Exist.java b/tests/invalid/pos/t6169/Exist.java similarity index 100% rename from tests/pending/pos/t6169/Exist.java rename to tests/invalid/pos/t6169/Exist.java diff --git a/tests/pending/pos/t6169/ExistF.java b/tests/invalid/pos/t6169/ExistF.java similarity index 100% rename from tests/pending/pos/t6169/ExistF.java rename to tests/invalid/pos/t6169/ExistF.java diff --git a/tests/pending/pos/t6169/ExistIndir.java b/tests/invalid/pos/t6169/ExistIndir.java similarity index 100% rename from tests/pending/pos/t6169/ExistIndir.java rename to tests/invalid/pos/t6169/ExistIndir.java diff --git a/tests/pending/pos/t6169/OP.java b/tests/invalid/pos/t6169/OP.java similarity index 100% rename from tests/pending/pos/t6169/OP.java rename to tests/invalid/pos/t6169/OP.java diff --git a/tests/pending/pos/t6169/Skin.java b/tests/invalid/pos/t6169/Skin.java similarity index 100% rename from tests/pending/pos/t6169/Skin.java rename to tests/invalid/pos/t6169/Skin.java diff --git a/tests/pending/pos/t6169/Skinnable.java b/tests/invalid/pos/t6169/Skinnable.java similarity index 100% rename from tests/pending/pos/t6169/Skinnable.java rename to tests/invalid/pos/t6169/Skinnable.java diff --git a/tests/pending/pos/t6169/skinnable.scala b/tests/invalid/pos/t6169/skinnable.scala similarity index 100% rename from tests/pending/pos/t6169/skinnable.scala rename to tests/invalid/pos/t6169/skinnable.scala diff --git a/tests/pending/pos/t6169/t6169.scala b/tests/invalid/pos/t6169/t6169.scala similarity index 100% rename from tests/pending/pos/t6169/t6169.scala rename to tests/invalid/pos/t6169/t6169.scala diff --git a/tests/pending/pos/t6367.scala b/tests/invalid/pos/t6367.scala similarity index 100% rename from tests/pending/pos/t6367.scala rename to tests/invalid/pos/t6367.scala diff --git a/tests/pending/pos/t711.scala b/tests/invalid/pos/t711.scala similarity index 100% rename from tests/pending/pos/t711.scala rename to tests/invalid/pos/t711.scala diff --git a/tests/pending/pos/t7505.scala b/tests/invalid/pos/t7505.scala similarity index 100% rename from tests/pending/pos/t7505.scala rename to tests/invalid/pos/t7505.scala diff --git a/tests/pending/pos/t8023.scala b/tests/invalid/pos/t8023.scala similarity index 86% rename from tests/pending/pos/t8023.scala rename to tests/invalid/pos/t8023.scala index 502b5c55dfb0..9ce5619dbe39 100644 --- a/tests/pending/pos/t8023.scala +++ b/tests/invalid/pos/t8023.scala @@ -1,3 +1,4 @@ +// Invalid because nested hk type parameters are no longer allowed import language._ diff --git a/tests/pending/pos/t8219b.scala b/tests/invalid/pos/t8219b.scala similarity index 100% rename from tests/pending/pos/t8219b.scala rename to tests/invalid/pos/t8219b.scala diff --git a/tests/pending/pos/t8224.scala b/tests/invalid/pos/t8224.scala similarity index 80% rename from tests/pending/pos/t8224.scala rename to tests/invalid/pos/t8224.scala index 2fae925df3e4..d893f66307fd 100644 --- a/tests/pending/pos/t8224.scala +++ b/tests/invalid/pos/t8224.scala @@ -1,3 +1,4 @@ +// Invalid because nested hk type parameters are no longer allowed import language.higherKinds trait P [N1, +E1[X <: N1]] diff --git a/tests/pending/pos/ticket2251.scala b/tests/invalid/pos/ticket2251.scala similarity index 100% rename from tests/pending/pos/ticket2251.scala rename to tests/invalid/pos/ticket2251.scala diff --git a/tests/pending/pos/typesafecons.scala b/tests/invalid/pos/typesafecons.scala similarity index 100% rename from tests/pending/pos/typesafecons.scala rename to tests/invalid/pos/typesafecons.scala diff --git a/tests/pending/pos/unapplySeq.scala b/tests/invalid/pos/unapplySeq.scala similarity index 100% rename from tests/pending/pos/unapplySeq.scala rename to tests/invalid/pos/unapplySeq.scala diff --git a/tests/pending/pos/imports-pos.scala b/tests/new/imports-pos.scala similarity index 100% rename from tests/pending/pos/imports-pos.scala rename to tests/new/imports-pos.scala diff --git a/tests/pending/pos/infer2-pos.scala b/tests/new/infer2-pos.scala similarity index 100% rename from tests/pending/pos/infer2-pos.scala rename to tests/new/infer2-pos.scala diff --git a/tests/pending/pos/looping-jsig.scala b/tests/new/looping-jsig.scala similarity index 100% rename from tests/pending/pos/looping-jsig.scala rename to tests/new/looping-jsig.scala diff --git a/tests/pending/pos/matthias1.scala b/tests/new/matthias1.scala similarity index 100% rename from tests/pending/pos/matthias1.scala rename to tests/new/matthias1.scala diff --git a/tests/pending/pos/michel6.scala b/tests/new/michel6.scala similarity index 100% rename from tests/pending/pos/michel6.scala rename to tests/new/michel6.scala diff --git a/tests/pending/pos/moduletrans.scala b/tests/new/moduletrans.scala similarity index 100% rename from tests/pending/pos/moduletrans.scala rename to tests/new/moduletrans.scala diff --git a/tests/pending/pos/package-implicit/ActorRef.scala b/tests/new/package-implicit/ActorRef.scala similarity index 100% rename from tests/pending/pos/package-implicit/ActorRef.scala rename to tests/new/package-implicit/ActorRef.scala diff --git a/tests/pending/pos/package-implicit/DataFlow.scala b/tests/new/package-implicit/DataFlow.scala similarity index 100% rename from tests/pending/pos/package-implicit/DataFlow.scala rename to tests/new/package-implicit/DataFlow.scala diff --git a/tests/pending/pos/package-implicit/package.scala b/tests/new/package-implicit/package.scala similarity index 100% rename from tests/pending/pos/package-implicit/package.scala rename to tests/new/package-implicit/package.scala diff --git a/tests/pending/pos/patterns.scala b/tests/new/patterns.scala similarity index 100% rename from tests/pending/pos/patterns.scala rename to tests/new/patterns.scala diff --git a/tests/pending/pos/patterns1.scala b/tests/new/patterns1.scala similarity index 100% rename from tests/pending/pos/patterns1.scala rename to tests/new/patterns1.scala diff --git a/tests/pending/pos/pmbug.scala b/tests/new/pmbug.scala similarity index 100% rename from tests/pending/pos/pmbug.scala rename to tests/new/pmbug.scala diff --git a/tests/pending/pos/private-types-after-typer.scala b/tests/new/private-types-after-typer.scala similarity index 100% rename from tests/pending/pos/private-types-after-typer.scala rename to tests/new/private-types-after-typer.scala diff --git a/tests/pending/pos/selftails.scala b/tests/new/selftails.scala similarity index 100% rename from tests/pending/pos/selftails.scala rename to tests/new/selftails.scala diff --git a/tests/pending/pos/seqtest2.scala b/tests/new/seqtest2.scala similarity index 100% rename from tests/pending/pos/seqtest2.scala rename to tests/new/seqtest2.scala diff --git a/tests/pending/pos/hklub0.scala b/tests/pending/pos/hklub0.scala deleted file mode 100644 index 36cd46332c28..000000000000 --- a/tests/pending/pos/hklub0.scala +++ /dev/null @@ -1,5 +0,0 @@ -object Test { - val a : scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq] = null - val b : scala.collection.generic.GenericCompanion[scala.collection.mutable.Seq] = null - List(a, b) // immutable.this.List.apply[scala.collection.generic.GenericCompanion[Seq]](Test.this.a, Test.this.b) -} diff --git a/tests/pending/pos/sammy_poly.flags b/tests/pending/pos/sammy_poly.flags deleted file mode 100644 index 48fd867160ba..000000000000 --- a/tests/pending/pos/sammy_poly.flags +++ /dev/null @@ -1 +0,0 @@ --Xexperimental diff --git a/tests/pending/pos/sealed-final.flags b/tests/pending/pos/sealed-final.flags deleted file mode 100644 index cfabf7a5b451..000000000000 --- a/tests/pending/pos/sealed-final.flags +++ /dev/null @@ -1 +0,0 @@ --Xfatal-warnings -Yinline-warnings -optimise \ No newline at end of file diff --git a/tests/pending/pos/t5545/S_1.scala b/tests/pending/pos/spec-t5545/S_1.scala similarity index 100% rename from tests/pending/pos/t5545/S_1.scala rename to tests/pending/pos/spec-t5545/S_1.scala diff --git a/tests/pending/pos/t5545/S_2.scala b/tests/pending/pos/spec-t5545/S_2.scala similarity index 100% rename from tests/pending/pos/t5545/S_2.scala rename to tests/pending/pos/spec-t5545/S_2.scala diff --git a/tests/pending/pos/t1843.scala b/tests/pending/pos/t1843.scala deleted file mode 100644 index 871b21346cc2..000000000000 --- a/tests/pending/pos/t1843.scala +++ /dev/null @@ -1,24 +0,0 @@ -/** -* Scala Compiler Will Crash On this File -* ... Or Will It? -* -*/ -object Crash { - trait UpdateType[A] - case class StateUpdate[A](updateType : UpdateType[A], value : A) - case object IntegerUpdateType extends UpdateType[Integer] - - //However this method will cause a crash - def crash(updates: List[StateUpdate[_]]): Unit = { - updates match { - case Nil => - case u::us => - u match { - //Line below seems to be the crashing line - case StateUpdate(key, newValue) if (key == IntegerUpdateType) => - println("Requires a statement to induce the crash") - case _ => - } - } - } -} diff --git a/tests/pending/pos/t2613.scala b/tests/pending/pos/t2613.scala deleted file mode 100644 index 3a64dbc28222..000000000000 --- a/tests/pending/pos/t2613.scala +++ /dev/null @@ -1,11 +0,0 @@ -import language.existentials - -object Test { - class Row - - abstract class MyRelation [R <: Row, +Relation <: MyRelation[R, Relation]] - - type M = MyRelation[R, Relation] forSome {type R <: Row; type Relation <: MyRelation[R, Relation]} - - var (x,y): (String, M) = null -} diff --git a/tests/pending/pos/t3252.flags b/tests/pending/pos/t3252.flags deleted file mode 100644 index eb4d19bcb91a..000000000000 --- a/tests/pending/pos/t3252.flags +++ /dev/null @@ -1 +0,0 @@ --optimise \ No newline at end of file diff --git a/tests/pending/pos/t3856.scala b/tests/pending/pos/t3856.scala deleted file mode 100644 index 6b38edc52cbe..000000000000 --- a/tests/pending/pos/t3856.scala +++ /dev/null @@ -1,9 +0,0 @@ -case class C[T](x: T) - -case class CS(xs: C[_]*) - -// t3856 -object Test { - val x = CS(C(5), C("abc")) match { case CS(C(5), xs : _*) => xs } - println(x) -} diff --git a/tests/pending/pos/t4176b.scala b/tests/pending/pos/t4176b.scala deleted file mode 100644 index f7d83365c653..000000000000 --- a/tests/pending/pos/t4176b.scala +++ /dev/null @@ -1,5 +0,0 @@ -object Test { - def foo(a: String*) = a - val fooEta = foo _ - (foo: Seq[String] => Seq[String]) -} diff --git a/tests/pending/pos/t4269.scala b/tests/pending/pos/t4269.scala index 99a30785b4d1..fe0c20103c19 100644 --- a/tests/pending/pos/t4269.scala +++ b/tests/pending/pos/t4269.scala @@ -1,5 +1,5 @@ class A { PartialFunction.condOpt(Nil) { - case items@List(_*) if true => + case items@List(_: _*) if true => } } diff --git a/tests/pending/pos/t4579.scala b/tests/pending/pos/t4579.scala deleted file mode 100644 index 8ce657eff6a6..000000000000 --- a/tests/pending/pos/t4579.scala +++ /dev/null @@ -1,518 +0,0 @@ -//############################################################################ -// Lisp interpreter (revived as an optimizer test.) -//############################################################################ - -//############################################################################ -// Lisp Scanner - -class LispTokenizer(s: String) extends Iterator[String] { - private var i = 0; - private def isDelimiter(ch: Char) = ch <= ' ' || ch == '(' || ch == ')' - def hasNext: Boolean = { - while (i < s.length() && s.charAt(i) <= ' ') i += 1 - i < s.length() - } - def next: String = - if (hasNext) { - val start = i - if (isDelimiter(s charAt i)) i += 1 - else - do i = i + 1 - while (!isDelimiter(s charAt i)) - s.substring(start, i) - } else sys.error("premature end of string") -} - -//############################################################################ -// Lisp Interface - -trait Lisp { - type Data - - def string2lisp(s: String): Data - def lisp2string(s: Data): String - - def evaluate(d: Data): Data - // !!! def evaluate(s: String): Data = evaluate(string2lisp(s)) - def evaluate(s: String): Data -} - -//############################################################################ -// Lisp Implementation Using Case Classes - -object LispCaseClasses extends Lisp { - - import List.range - - trait Data { - def elemsToString(): String = toString(); - } - case class CONS(car: Data, cdr: Data) extends Data { - override def toString() = "(" + elemsToString() + ")"; - override def elemsToString() = car.toString() + (cdr match { - case NIL() => "" - case _ => " " + cdr.elemsToString(); - }) - } - case class NIL() extends Data { // !!! use case object - override def toString() = "()"; - } - case class SYM(name: String) extends Data { - override def toString() = name; - } - case class NUM(x: Int) extends Data { - override def toString() = x.toString(); - } - case class STR(x: String) extends Data { - override def toString() = "\"" + x + "\""; - } - case class FUN(f: List[Data] => Data) extends Data { - override def toString() = ""; - } - - def list(): Data = - NIL(); - def list(x0: Data): Data = - CONS(x0, NIL()); - def list(x0: Data, x1: Data): Data = - CONS(x0, list(x1)); - def list(x0: Data, x1: Data, x2: Data): Data = - CONS(x0, list(x1, x2)); - def list(x0: Data, x1: Data, x2: Data, x3: Data): Data = - CONS(x0, list(x1, x2, x3)); - def list(x0: Data, x1: Data, x2: Data, x3: Data, x4: Data): Data = - CONS(x0, list(x1, x2, x3, x4)); - def list(x0: Data, x1: Data, x2: Data, x3: Data, x4: Data, x5: Data): Data = - CONS(x0, list(x1, x2, x3, x4, x5)); - def list(x0: Data, x1: Data, x2: Data, x3: Data, x4: Data, x5: Data, - x6: Data): Data = - CONS(x0, list(x1, x2, x3, x4, x5, x6)); - def list(x0: Data, x1: Data, x2: Data, x3: Data, x4: Data, x5: Data, - x6: Data, x7: Data): Data = - CONS(x0, list(x1, x2, x3, x4, x5, x6, x7)); - def list(x0: Data, x1: Data, x2: Data, x3: Data, x4: Data, x5: Data, - x6: Data, x7: Data, x8: Data): Data = - CONS(x0, list(x1, x2, x3, x4, x5, x6, x7, x8)); - def list(x0: Data, x1: Data, x2: Data, x3: Data, x4: Data, x5: Data, - x6: Data, x7: Data, x8: Data, x9: Data): Data = - CONS(x0, list(x1, x2, x3, x4, x5, x6, x7, x8, x9)); - - var curexp: Data = null - var trace: Boolean = false - var indent: Int = 0 - - def lispError[a](msg: String): a = - sys.error("error: " + msg + "\n" + curexp); - - trait Environment { - def lookup(n: String): Data; - def extendRec(name: String, expr: Environment => Data) = - new Environment { - def lookup(n: String): Data = - if (n == name) expr(this) else Environment.this.lookup(n); - } - def extend(name: String, v: Data) = extendRec(name, (env1 => v)); - } - val EmptyEnvironment = new Environment { - def lookup(n: String): Data = lispError("undefined: " + n); - } - - def toList(x: Data): List[Data] = x match { - case NIL() => List() - case CONS(y, ys) => y :: toList(ys) - case _ => lispError("malformed list: " + x); - } - - def toBoolean(x: Data) = x match { - case NUM(0) => false - case _ => true - } - - def normalize(x: Data): Data = x match { - case CONS(SYM("def"), - CONS(CONS(SYM(name), args), CONS(body, CONS(expr, NIL())))) => - normalize(list(SYM("def"), - SYM(name), list(SYM("lambda"), args, body), expr)) - case CONS(SYM("cond"), CONS(CONS(SYM("else"), CONS(expr, NIL())),NIL())) => - normalize(expr) - case CONS(SYM("cond"), CONS(CONS(test, CONS(expr, NIL())), rest)) => - normalize(list(SYM("if"), test, expr, CONS(SYM("cond"), rest))) - case CONS(h, t) => CONS(normalize(h), normalize(t)) - case _ => x - } - - def eval(x: Data, env: Environment): Data = { - val prevexp = curexp; - curexp = x; - if (trace) { - for (x <- range(1, indent)) Console.print(" "); - Console.println("===> " + x); - indent = indent + 1; - } - val result = eval1(x, env); - if (trace) { - indent = indent - 1; - for (x <- range(1, indent)) Console.print(" "); - Console.println("<=== " + result); - } - curexp = prevexp; - result - } - - def eval1(x: Data, env: Environment): Data = x match { - case SYM(name) => - env lookup name - case CONS(SYM("def"), CONS(SYM(name), CONS(y, CONS(z, NIL())))) => - eval(z, env.extendRec(name, (env1 => eval(y, env1)))) - case CONS(SYM("val"), CONS(SYM(name), CONS(y, CONS(z, NIL())))) => - eval(z, env.extend(name, eval(y, env))) - case CONS(SYM("lambda"), CONS(params, CONS(y, NIL()))) => - mkLambda(params, y, env) - case CONS(SYM("if"), CONS(c, CONS(t, CONS(e, NIL())))) => - if (toBoolean(eval(c, env))) eval(t, env) else eval(e, env) - case CONS(SYM("quote"), CONS(x, NIL())) => - x - case CONS(y, xs) => - apply(eval(y, env), toList(xs) map (x => eval(x, env))) - case NUM(_) => x - case STR(_) => x - case FUN(_) => x - case _ => - lispError("illegal term") - } - - def apply(fn: Data, args: List[Data]): Data = fn match { - case FUN(f) => f(args); - case _ => lispError("application of non-function: " + fn); - } - - def mkLambda(params: Data, expr: Data, env: Environment): Data = { - - def extendEnv(env: Environment, - ps: List[String], args: List[Data]): Environment = - (ps, args) match { - case (List(), List()) => - env - case (p :: ps1, arg :: args1) => - extendEnv(env.extend(p, arg), ps1, args1) - case _ => - lispError("wrong number of arguments") - } - - val ps: List[String] = toList(params) map { - case SYM(name) => name - case _ => sys.error("illegal parameter list"); - } - - FUN(args => eval(expr, extendEnv(env, ps, args))) - } - - val globalEnv = EmptyEnvironment - .extend("=", FUN({ - case List(NUM(arg1),NUM(arg2)) => NUM(if (arg1 == arg2) 1 else 0) - case List(STR(arg1),STR(arg2)) => NUM(if (arg1 == arg2) 1 else 0)})) - .extend("+", FUN({ - case List(NUM(arg1),NUM(arg2)) => NUM(arg1 + arg2) - case List(STR(arg1),STR(arg2)) => STR(arg1 + arg2)})) - .extend("-", FUN({ - case List(NUM(arg1),NUM(arg2)) => NUM(arg1 - arg2)})) - .extend("*", FUN({ - case List(NUM(arg1),NUM(arg2)) => NUM(arg1 * arg2)})) - .extend("/", FUN({ - case List(NUM(arg1),NUM(arg2)) => NUM(arg1 / arg2)})) - .extend("car", FUN({ - case List(CONS(x, xs)) => x})) - .extend("cdr", FUN({ - case List(CONS(x, xs)) => xs})) - .extend("null?", FUN({ - case List(NIL()) => NUM(1) - case _ => NUM(0)})) - .extend("cons", FUN({ - case List(x, y) => CONS(x, y)})); - - def evaluate(x: Data): Data = eval(normalize(x), globalEnv); - def evaluate(s: String): Data = evaluate(string2lisp(s)); - - def string2lisp(s: String): Data = { - val it = new LispTokenizer(s); - def parse(token: String): Data = { - if (token == "(") parseList - else if (token == ")") sys.error("unbalanced parentheses") - else if ('0' <= token.charAt(0) && token.charAt(0) <= '9') - NUM(token.toInt) - else if (token.charAt(0) == '\"' && token.charAt(token.length()-1)=='\"') - STR(token.substring(1,token.length() - 1)) - else SYM(token) - } - def parseList: Data = { - val token = it.next; - if (token == ")") NIL() else CONS(parse(token), parseList) - } - parse(it.next) - } - - def lisp2string(d: Data): String = d.toString(); -} - -//############################################################################ -// Lisp Implementation Using Any - -object LispAny extends Lisp { - - import List._; - - type Data = Any; - - case class Lambda(f: List[Data] => Data); - - var curexp: Data = null; - var trace: Boolean = false; - var indent: Int = 0; - - def lispError[a](msg: String): a = - sys.error("error: " + msg + "\n" + curexp); - - trait Environment { - def lookup(n: String): Data; - def extendRec(name: String, expr: Environment => Data) = - new Environment { - def lookup(n: String): Data = - if (n == name) expr(this) else Environment.this.lookup(n); - } - def extend(name: String, v: Data) = extendRec(name, (env1 => v)); - } - val EmptyEnvironment = new Environment { - def lookup(n: String): Data = lispError("undefined: " + n); - } - - def asList(x: Data): List[Data] = x match { - case y: List[_] => y - case _ => lispError("malformed list: " + x) - } - - def asInt(x: Data): Int = x match { - case y: Int => y - case _ => lispError("not an integer: " + x) - } - - def asString(x: Data): String = x match { - case y: String => y - case _ => lispError("not a string: " + x) - } - - def asBoolean(x: Data): Boolean = x != 0 - - def normalize(x: Data): Data = x match { - case 'and :: x :: y :: Nil => - normalize('if :: x :: y :: 0 :: Nil) - case 'or :: x :: y :: Nil => - normalize('if :: x :: 1 :: y :: Nil) - case 'def :: (name :: args) :: body :: expr :: Nil => - normalize('def :: name :: ('lambda :: args :: body :: Nil) :: expr :: Nil) - case 'cond :: ('else :: expr :: Nil) :: rest => - normalize(expr); - case 'cond :: (test :: expr :: Nil) :: rest => - normalize('if :: test :: expr :: ('cond :: rest) :: Nil) - case 'cond :: 'else :: expr :: Nil => - normalize(expr) - case h :: t => - normalize(h) :: asList(normalize(t)) - case _ => - x - } - - def eval(x: Data, env: Environment): Data = { - val prevexp = curexp; - curexp = x; - if (trace) { - for (x <- range(1, indent)) Console.print(" "); - Console.println("===> " + x); - indent += 1; - } - val result = eval1(x, env); - if (trace) { - indent -= 1; - for (x <- range(1, indent)) Console.print(" "); - Console.println("<=== " + result); - } - curexp = prevexp; - result - } - - def eval1(x: Data, env: Environment): Data = x match { - case Symbol(name) => - env lookup name - case 'def :: Symbol(name) :: y :: z :: Nil => - eval(z, env.extendRec(name, (env1 => eval(y, env1)))) - case 'val :: Symbol(name) :: y :: z :: Nil => - eval(z, env.extend(name, eval(y, env))) - case 'lambda :: params :: y :: Nil => - mkLambda(params, y, env) - case 'if :: c :: y :: z :: Nil => - if (asBoolean(eval(c, env))) eval(y, env) else eval(z, env) - case 'quote :: y :: Nil => - y - case y :: z => - apply(eval(y, env), z map (x => eval(x, env))) - case Lambda(_) => x - case y: String => x - case y: Int => x - case y => lispError("illegal term") - } - - def lisp2string(x: Data): String = x match { - case Symbol(name) => name - case Nil => "()" - case y :: ys => - def list2string(xs: List[Data]): String = xs match { - case List() => "" - case y :: ys => " " + lisp2string(y) + list2string(ys) - } - "(" + lisp2string(y) + list2string(ys) + ")" - case _ => if (x.isInstanceOf[String]) "\"" + x + "\""; else x.toString() - } - - def apply(fn: Data, args: List[Data]): Data = fn match { - case Lambda(f) => f(args); - case _ => lispError("application of non-function: " + fn + " to " + args); - } - - def mkLambda(params: Data, expr: Data, env: Environment): Data = { - - def extendEnv(env: Environment, - ps: List[String], args: List[Data]): Environment = - (ps, args) match { - case (List(), List()) => - env - case (p :: ps1, arg :: args1) => - extendEnv(env.extend(p, arg), ps1, args1) - case _ => - lispError("wrong number of arguments") - } - - val ps: List[String] = asList(params) map { - case Symbol(name) => name - case _ => sys.error("illegal parameter list"); - } - - Lambda(args => eval(expr, extendEnv(env, ps, args))) - } - - val globalEnv = EmptyEnvironment - .extend("=", Lambda{ - case List(arg1, arg2) => if (arg1 == arg2) 1 else 0}) - .extend("+", Lambda{ - case List(arg1: Int, arg2: Int) => arg1 + arg2 - case List(arg1: String, arg2: String) => arg1 + arg2}) - .extend("-", Lambda{ - case List(arg1: Int, arg2: Int) => arg1 - arg2}) - .extend("*", Lambda{ - case List(arg1: Int, arg2: Int) => arg1 * arg2}) - .extend("/", Lambda{ - case List(arg1: Int, arg2: Int) => arg1 / arg2}) - .extend("nil", Nil) - .extend("cons", Lambda{ - case List(arg1, arg2) => arg1 :: asList(arg2)}) - .extend("car", Lambda{ - case List(x :: xs) => x}) - .extend("cdr", Lambda{ - case List(x :: xs) => xs}) - .extend("null?", Lambda{ - case List(Nil) => 1 - case _ => 0}); - - def evaluate(x: Data): Data = eval(normalize(x), globalEnv); - def evaluate(s: String): Data = evaluate(string2lisp(s)); - - def string2lisp(s: String): Data = { - val it = new LispTokenizer(s); - def parse(token: String): Data = { - if (token == "(") parseList - else if (token == ")") sys.error("unbalanced parentheses") - //else if (Character.isDigit(token.charAt(0))) - else if (token.charAt(0).isDigit) - token.toInt - else if (token.charAt(0) == '\"' && token.charAt(token.length()-1)=='\"') - token.substring(1,token.length() - 1) - else Symbol(token) - } - def parseList: List[Data] = { - val token = it.next; - if (token == ")") Nil else parse(token) :: parseList - } - parse(it.next) - } -} - -//############################################################################ -// List User - -class LispUser(lisp: Lisp) { - - import lisp._; - - def evaluate(s: String) = lisp2string(lisp.evaluate(s)); - - def run = { - - Console.println(string2lisp("(lambda (x) (+ (* x x) 1))").asInstanceOf[AnyRef]); - Console.println(lisp2string(string2lisp("(lambda (x) (+ (* x x) 1))"))); - Console.println; - - Console.println("( '(1 2 3)) = " + evaluate(" (quote(1 2 3))")); - Console.println("(car '(1 2 3)) = " + evaluate("(car (quote(1 2 3)))")); - Console.println("(cdr '(1 2 3)) = " + evaluate("(cdr (quote(1 2 3)))")); - Console.println("(null? '(2 3)) = " + evaluate("(null? (quote(2 3)))")); - Console.println("(null? '()) = " + evaluate("(null? (quote()))")); - Console.println; - - Console.println("faculty(10) = " + evaluate( - "(def (faculty n) " + - "(if (= n 0) " + - "1 " + - "(* n (faculty (- n 1)))) " + - "(faculty 10))")); - Console.println("faculty(10) = " + evaluate( - "(def (faculty n) " + - "(cond " + - "((= n 0) 1) " + - "(else (* n (faculty (- n 1))))) " + - "(faculty 10))")); - Console.println("foobar = " + evaluate( - "(def (foo n) " + - "(cond " + - "((= n 0) \"a\")" + - "((= n 1) \"b\")" + - "((= (/ n 2) 1) " + - "(cond " + - "((= n 2) \"c\")" + - "(else \"d\")))" + - "(else " + - "(def (bar m) " + - "(cond " + - "((= m 0) \"e\")" + - "((= m 1) \"f\")" + - "(else \"z\"))" + - "(bar (- n 4)))))" + - "(val nil (quote ())" + - "(val v1 (foo 0) " + - "(val v2 (+ (foo 1) (foo 2)) " + - "(val v3 (+ (+ (foo 3) (foo 4)) (foo 5)) " + - "(val v4 (foo 6) " + - "(cons v1 (cons v2 (cons v3 (cons v4 nil))))))))))")); - Console.println; - } -} - -//############################################################################ -// Main - -object Test { - def main(args: Array[String]): Unit = { - new LispUser(LispCaseClasses).run; - new LispUser(LispAny).run; - () - } -} - -//############################################################################ diff --git a/tests/pending/pos/t4760.scala b/tests/pending/pos/t4760.scala deleted file mode 100644 index d4407a86b496..000000000000 --- a/tests/pending/pos/t4760.scala +++ /dev/null @@ -1,34 +0,0 @@ - -class Test { - // parses - def f1 = { - import scala._; - } - // b.scala:7: error: ';' expected but '}' found. - // } - // ^ - // one error found - def f2 = { - import scala._ - } - def f2b = { - import scala.collection.mutable.{ Map => MMap } - } - def f(): Unit = { - locally { - import scala.util.Properties.lineSeparator - } - } - - // parses - def f3 = { - import scala._ - 5 - } - locally { (x: Int) => - import scala.util._ - } - 1 match { - case 1 => import scala.concurrent._ - } -} diff --git a/tests/pending/pos/t5845.scala b/tests/pending/pos/t5845.scala index 823c722c145d..b747a025e7d5 100644 --- a/tests/pending/pos/t5845.scala +++ b/tests/pending/pos/t5845.scala @@ -4,13 +4,13 @@ class Num[T] { } class A { - implicit def infixOps[T, CC[X] <: Num[X]](lhs: T)(implicit num: CC[T]) = num.mkOps - implicit val n1 = new Num[Int] { } - println(5 +++ 5) + implicit def infixOps[T, CC[X] <: Num[X]](lhs: T)(implicit num: CC[T]): num.Ops = num.mkOps + implicit val n1: Num[Int] = new Num[Int] { } + println(5 +++ 5) // should dependent be implicits forbidden? } class B { implicit def infixOps[T, CC[X] <: Num[X]](lhs: T)(implicit num: CC[T]) : CC[T]#Ops = num.mkOps - implicit val n1 = new Num[Int] {} + implicit val n1: Num[Int] = new Num[Int] {} println(5 +++ 5) } diff --git a/tests/pending/pos/t6335.scala b/tests/pending/pos/t6335.scala deleted file mode 100644 index eb052db1998a..000000000000 --- a/tests/pending/pos/t6335.scala +++ /dev/null @@ -1,25 +0,0 @@ -object E extends Z { - def X = 3 - implicit class X(val i: Int) { - def xx = i - } - - def Y(a: Any) = 0 - object Y - implicit class Y(val i: String) { def yy = i } - - implicit class Z(val i: Boolean) { def zz = i } -} - -trait Z { - def Z = 0 -} - -object Test { - import E._ - 0.xx - - "".yy - - true.zz -} diff --git a/tests/pending/pos/t6976/Exts_1.scala b/tests/pending/pos/t6976/Exts_1.scala index 9b3a69edd9aa..f5eaeea45531 100644 --- a/tests/pending/pos/t6976/Exts_1.scala +++ b/tests/pending/pos/t6976/Exts_1.scala @@ -6,5 +6,5 @@ object Exts { trait Exts { import language.implicitConversions - implicit def AnyExts[T](o: T) = Exts.AnyExts(o) + implicit def AnyExts[T](o: T): Exts.AnyExts[T] = Exts.AnyExts(o) } diff --git a/tests/pending/pos/t7517.scala b/tests/pending/pos/t7517.scala index df4f40130450..d0462c48dfbb 100644 --- a/tests/pending/pos/t7517.scala +++ b/tests/pending/pos/t7517.scala @@ -1,3 +1,4 @@ +// Invalid because nested hk type parameters are no longer allowed trait Box[ K[A[x]] ] object Box { diff --git a/tests/pending/pos/t7902.scala b/tests/pending/pos/t7902.scala index 47c525c1795d..7793d3723039 100644 --- a/tests/pending/pos/t7902.scala +++ b/tests/pending/pos/t7902.scala @@ -1,3 +1,4 @@ +// Invalid because nested hk type parameters are no longer allowed import scala.language.higherKinds object Bug { diff --git a/tests/pending/pos/t7919.scala b/tests/pending/pos/t7919.scala deleted file mode 100644 index 64f261ec1608..000000000000 --- a/tests/pending/pos/t7919.scala +++ /dev/null @@ -1,6 +0,0 @@ - -object X { - val x = s"" - val y = true -} - diff --git a/tests/new/conforms.scala b/tests/pos/conforms.scala similarity index 100% rename from tests/new/conforms.scala rename to tests/pos/conforms.scala diff --git a/tests/pending/pos/constfold.scala b/tests/pos/constfold.scala similarity index 100% rename from tests/pending/pos/constfold.scala rename to tests/pos/constfold.scala diff --git a/tests/pending/pos/contextbounds-implicits-new.scala b/tests/pos/contextbounds-implicits-new.scala similarity index 100% rename from tests/pending/pos/contextbounds-implicits-new.scala rename to tests/pos/contextbounds-implicits-new.scala diff --git a/tests/pending/pos/delambdafy-lambdalift.scala b/tests/pos/delambdafy-lambdalift.scala similarity index 100% rename from tests/pending/pos/delambdafy-lambdalift.scala rename to tests/pos/delambdafy-lambdalift.scala diff --git a/tests/pending/pos/exbound.scala b/tests/pos/exbound.scala similarity index 100% rename from tests/pending/pos/exbound.scala rename to tests/pos/exbound.scala diff --git a/tests/pos/hkrange.scala b/tests/pos/hkrange.scala deleted file mode 100644 index a6803230eda3..000000000000 --- a/tests/pos/hkrange.scala +++ /dev/null @@ -1,5 +0,0 @@ -class A { - def f[CC[X] <: Traversable[X]](x: CC[Int]) = () - - f(1 to 5) -} diff --git a/tests/new/implicits.scala b/tests/pos/implicits.scala similarity index 100% rename from tests/new/implicits.scala rename to tests/pos/implicits.scala diff --git a/tests/pending/pos/philippe4.scala b/tests/pos/philippe4.scala similarity index 100% rename from tests/pending/pos/philippe4.scala rename to tests/pos/philippe4.scala diff --git a/tests/pos/seq-ordering.scala b/tests/pos/seq-ordering.scala deleted file mode 100644 index 517d8ae8aafe..000000000000 --- a/tests/pos/seq-ordering.scala +++ /dev/null @@ -1,9 +0,0 @@ -import Ordering.Implicits._ - -class A { - import Predef.{ implicitly => ? } - - ?[Ordering[List[Int]]] - ?[Ordering[IndexedSeq[(Int, String)]]] - ?[Ordering[Seq[Seq[Int]]]] -} diff --git a/tests/pending/pos/t1048.scala b/tests/pos/t1048.scala similarity index 100% rename from tests/pending/pos/t1048.scala rename to tests/pos/t1048.scala diff --git a/tests/pos/t1843.scala b/tests/pos/t1843.scala index 5e8554a93862..871b21346cc2 100644 --- a/tests/pos/t1843.scala +++ b/tests/pos/t1843.scala @@ -3,10 +3,9 @@ * ... Or Will It? * */ - object Crash { - trait UpdateType[+A] - case class StateUpdate[+A](updateType : UpdateType[A], value : A) + trait UpdateType[A] + case class StateUpdate[A](updateType : UpdateType[A], value : A) case object IntegerUpdateType extends UpdateType[Integer] //However this method will cause a crash diff --git a/tests/pending/pos/t3274.scala b/tests/pos/t3274.scala similarity index 100% rename from tests/pending/pos/t3274.scala rename to tests/pos/t3274.scala diff --git a/tests/pending/pos/t3477.scala b/tests/pos/t3477.scala similarity index 100% rename from tests/pending/pos/t3477.scala rename to tests/pos/t3477.scala diff --git a/tests/pending/pos/t3480.scala b/tests/pos/t3480.scala similarity index 100% rename from tests/pending/pos/t3480.scala rename to tests/pos/t3480.scala diff --git a/tests/pending/pos/t3498-new.scala b/tests/pos/t3498-new.scala similarity index 100% rename from tests/pending/pos/t3498-new.scala rename to tests/pos/t3498-new.scala diff --git a/tests/pending/pos/t3534.scala b/tests/pos/t3534.scala similarity index 100% rename from tests/pending/pos/t3534.scala rename to tests/pos/t3534.scala diff --git a/tests/pending/pos/t3568.scala b/tests/pos/t3568.scala similarity index 100% rename from tests/pending/pos/t3568.scala rename to tests/pos/t3568.scala diff --git a/tests/pending/pos/t3582b.scala b/tests/pos/t3582b.scala similarity index 100% rename from tests/pending/pos/t3582b.scala rename to tests/pos/t3582b.scala diff --git a/tests/pending/pos/t360.scala b/tests/pos/t360.scala similarity index 100% rename from tests/pending/pos/t360.scala rename to tests/pos/t360.scala diff --git a/tests/pending/pos/t3612.scala b/tests/pos/t3612.scala similarity index 100% rename from tests/pending/pos/t3612.scala rename to tests/pos/t3612.scala diff --git a/tests/pending/pos/t3688.scala b/tests/pos/t3688.scala similarity index 100% rename from tests/pending/pos/t3688.scala rename to tests/pos/t3688.scala diff --git a/tests/pending/pos/t3777.scala b/tests/pos/t3777.scala similarity index 100% rename from tests/pending/pos/t3777.scala rename to tests/pos/t3777.scala diff --git a/tests/pending/pos/t3859.scala b/tests/pos/t3859.scala similarity index 100% rename from tests/pending/pos/t3859.scala rename to tests/pos/t3859.scala diff --git a/tests/pending/pos/t3869.scala b/tests/pos/t3869.scala similarity index 100% rename from tests/pending/pos/t3869.scala rename to tests/pos/t3869.scala diff --git a/tests/pending/pos/t3960.scala b/tests/pos/t3960.scala similarity index 100% rename from tests/pending/pos/t3960.scala rename to tests/pos/t3960.scala diff --git a/tests/pending/pos/t3986.scala b/tests/pos/t3986.scala similarity index 100% rename from tests/pending/pos/t3986.scala rename to tests/pos/t3986.scala diff --git a/tests/pending/pos/t404.scala b/tests/pos/t404.scala similarity index 100% rename from tests/pending/pos/t404.scala rename to tests/pos/t404.scala diff --git a/tests/pending/pos/t415.scala b/tests/pos/t415.scala similarity index 100% rename from tests/pending/pos/t415.scala rename to tests/pos/t415.scala diff --git a/tests/pending/pos/t4176.scala b/tests/pos/t4176.scala similarity index 100% rename from tests/pending/pos/t4176.scala rename to tests/pos/t4176.scala diff --git a/tests/pending/pos/t430-feb09.scala b/tests/pos/t430-feb09.scala similarity index 100% rename from tests/pending/pos/t430-feb09.scala rename to tests/pos/t430-feb09.scala diff --git a/tests/pending/pos/t4336.scala b/tests/pos/t4336.scala similarity index 100% rename from tests/pending/pos/t4336.scala rename to tests/pos/t4336.scala diff --git a/tests/pending/pos/t4345.scala b/tests/pos/t4345.scala similarity index 100% rename from tests/pending/pos/t4345.scala rename to tests/pos/t4345.scala diff --git a/tests/pending/pos/t4545.scala b/tests/pos/t4545.scala similarity index 100% rename from tests/pending/pos/t4545.scala rename to tests/pos/t4545.scala diff --git a/tests/pending/pos/t460.scala b/tests/pos/t460.scala similarity index 100% rename from tests/pending/pos/t460.scala rename to tests/pos/t460.scala diff --git a/tests/pending/pos/t4853.scala b/tests/pos/t4853.scala similarity index 100% rename from tests/pending/pos/t4853.scala rename to tests/pos/t4853.scala diff --git a/tests/pending/pos/t4859.scala b/tests/pos/t4859.scala similarity index 100% rename from tests/pending/pos/t4859.scala rename to tests/pos/t4859.scala diff --git a/tests/pos/t4911.flags b/tests/pos/t4911.flags new file mode 100644 index 000000000000..a5c112f5a7e7 --- /dev/null +++ b/tests/pos/t4911.flags @@ -0,0 +1 @@ +-language:Scala2 \ No newline at end of file diff --git a/tests/pending/pos/t4911.scala b/tests/pos/t4911.scala similarity index 100% rename from tests/pending/pos/t4911.scala rename to tests/pos/t4911.scala diff --git a/tests/pending/pos/t4975.scala b/tests/pos/t4975.scala similarity index 100% rename from tests/pending/pos/t4975.scala rename to tests/pos/t4975.scala diff --git a/tests/pending/pos/t5012.scala b/tests/pos/t5012.scala similarity index 100% rename from tests/pending/pos/t5012.scala rename to tests/pos/t5012.scala diff --git a/tests/pending/pos/t5029.scala b/tests/pos/t5029.scala similarity index 100% rename from tests/pending/pos/t5029.scala rename to tests/pos/t5029.scala diff --git a/tests/pending/pos/t5041.scala b/tests/pos/t5041.scala similarity index 100% rename from tests/pending/pos/t5041.scala rename to tests/pos/t5041.scala diff --git a/tests/pending/pos/t5082.scala b/tests/pos/t5082.scala similarity index 100% rename from tests/pending/pos/t5082.scala rename to tests/pos/t5082.scala diff --git a/tests/pending/pos/t5541.scala b/tests/pos/t5541.scala similarity index 100% rename from tests/pending/pos/t5541.scala rename to tests/pos/t5541.scala diff --git a/tests/pending/pos/t566.scala b/tests/pos/t566.scala similarity index 100% rename from tests/pending/pos/t566.scala rename to tests/pos/t566.scala diff --git a/tests/pending/pos/t5720-ownerous.scala b/tests/pos/t5720-ownerous.scala similarity index 100% rename from tests/pending/pos/t5720-ownerous.scala rename to tests/pos/t5720-ownerous.scala diff --git a/tests/pending/pos/t5729.scala b/tests/pos/t5729.scala similarity index 100% rename from tests/pending/pos/t5729.scala rename to tests/pos/t5729.scala diff --git a/tests/pending/pos/t573.scala b/tests/pos/t573.scala similarity index 100% rename from tests/pending/pos/t573.scala rename to tests/pos/t573.scala diff --git a/tests/pending/pos/t5859.scala b/tests/pos/t5859.scala similarity index 100% rename from tests/pending/pos/t5859.scala rename to tests/pos/t5859.scala diff --git a/tests/pending/pos/t5877.scala b/tests/pos/t5877.scala similarity index 100% rename from tests/pending/pos/t5877.scala rename to tests/pos/t5877.scala diff --git a/tests/pending/pos/t5877b.scala b/tests/pos/t5877b.scala similarity index 100% rename from tests/pending/pos/t5877b.scala rename to tests/pos/t5877b.scala diff --git a/tests/pending/pos/t5900a.scala b/tests/pos/t5900a.scala similarity index 100% rename from tests/pending/pos/t5900a.scala rename to tests/pos/t5900a.scala diff --git a/tests/pending/pos/t5932.scala b/tests/pos/t5932.scala similarity index 100% rename from tests/pending/pos/t5932.scala rename to tests/pos/t5932.scala diff --git a/tests/pending/pos/t596.scala b/tests/pos/t596.scala similarity index 100% rename from tests/pending/pos/t596.scala rename to tests/pos/t596.scala diff --git a/tests/pending/pos/t5967.scala b/tests/pos/t5967.scala similarity index 100% rename from tests/pending/pos/t5967.scala rename to tests/pos/t5967.scala diff --git a/tests/pending/pos/t6014.scala b/tests/pos/t6014.scala similarity index 100% rename from tests/pending/pos/t6014.scala rename to tests/pos/t6014.scala diff --git a/tests/pending/pos/t604.scala b/tests/pos/t604.scala similarity index 100% rename from tests/pending/pos/t604.scala rename to tests/pos/t604.scala diff --git a/tests/pending/pos/t6089b.scala b/tests/pos/t6089b.scala similarity index 100% rename from tests/pending/pos/t6089b.scala rename to tests/pos/t6089b.scala diff --git a/tests/pending/pos/t6117.scala b/tests/pos/t6117.scala similarity index 100% rename from tests/pending/pos/t6117.scala rename to tests/pos/t6117.scala diff --git a/tests/pending/pos/t6123-explaintypes-implicits.scala b/tests/pos/t6123-explaintypes-implicits.scala similarity index 100% rename from tests/pending/pos/t6123-explaintypes-implicits.scala rename to tests/pos/t6123-explaintypes-implicits.scala diff --git a/tests/pending/pos/t6145.scala b/tests/pos/t6145.scala similarity index 100% rename from tests/pending/pos/t6145.scala rename to tests/pos/t6145.scala diff --git a/tests/pending/pos/t6184.scala b/tests/pos/t6184.scala similarity index 100% rename from tests/pending/pos/t6184.scala rename to tests/pos/t6184.scala diff --git a/tests/pending/pos/t6208.scala b/tests/pos/t6208.scala similarity index 100% rename from tests/pending/pos/t6208.scala rename to tests/pos/t6208.scala diff --git a/tests/pending/pos/t6225.scala b/tests/pos/t6225.scala similarity index 100% rename from tests/pending/pos/t6225.scala rename to tests/pos/t6225.scala diff --git a/tests/pending/pos/t6231.scala b/tests/pos/t6231.scala similarity index 100% rename from tests/pending/pos/t6231.scala rename to tests/pos/t6231.scala diff --git a/tests/pending/pos/t6231b.scala b/tests/pos/t6231b.scala similarity index 100% rename from tests/pending/pos/t6231b.scala rename to tests/pos/t6231b.scala diff --git a/tests/pending/pos/t6575a.scala b/tests/pos/t6575a.scala similarity index 100% rename from tests/pending/pos/t6575a.scala rename to tests/pos/t6575a.scala diff --git a/tests/pending/pos/t6600.scala b/tests/pos/t6600.scala similarity index 100% rename from tests/pending/pos/t6600.scala rename to tests/pos/t6600.scala diff --git a/tests/pending/pos/t661.scala b/tests/pos/t661.scala similarity index 88% rename from tests/pending/pos/t661.scala rename to tests/pos/t661.scala index 3a447241fe12..f2b76ee2f894 100644 --- a/tests/pending/pos/t661.scala +++ b/tests/pos/t661.scala @@ -9,7 +9,7 @@ object test { } trait B extends A { type N; - trait C extends super.C { + trait CC extends super.C { type M = N; override def foo(n : M) : Unit = super.foo(n); } diff --git a/tests/pending/pos/t6664b.scala b/tests/pos/t6664b.scala similarity index 100% rename from tests/pending/pos/t6664b.scala rename to tests/pos/t6664b.scala diff --git a/tests/pending/pos/t697.scala b/tests/pos/t697.scala similarity index 100% rename from tests/pending/pos/t697.scala rename to tests/pos/t697.scala diff --git a/tests/pending/pos/t6994.scala b/tests/pos/t6994.scala similarity index 100% rename from tests/pending/pos/t6994.scala rename to tests/pos/t6994.scala diff --git a/tests/pending/pos/t7011.scala b/tests/pos/t7011.scala similarity index 100% rename from tests/pending/pos/t7011.scala rename to tests/pos/t7011.scala diff --git a/tests/pending/pos/t703.scala b/tests/pos/t703.scala similarity index 100% rename from tests/pending/pos/t703.scala rename to tests/pos/t703.scala diff --git a/tests/pending/pos/t704.scala b/tests/pos/t704.scala similarity index 100% rename from tests/pending/pos/t704.scala rename to tests/pos/t704.scala diff --git a/tests/pending/pos/t7126.scala b/tests/pos/t7126.scala similarity index 100% rename from tests/pending/pos/t7126.scala rename to tests/pos/t7126.scala diff --git a/tests/pending/pos/t7226.scala b/tests/pos/t7226.scala similarity index 100% rename from tests/pending/pos/t7226.scala rename to tests/pos/t7226.scala diff --git a/tests/pending/pos/t7285a.scala b/tests/pos/t7285a.scala similarity index 94% rename from tests/pending/pos/t7285a.scala rename to tests/pos/t7285a.scala index 34e79c741b5b..23b52f5950bb 100644 --- a/tests/pending/pos/t7285a.scala +++ b/tests/pos/t7285a.scala @@ -23,12 +23,15 @@ object Test1 { case object Up extends Base { } + locally { + (d1: Base, d2: Base) => (d1, d2) match { case (Up, Up) | (Down, Down) => false case (Down, Up) => true case (Up, Down) => false } + } } } @@ -42,10 +45,12 @@ object Test2 { case object Up extends Base { } + locally { (d1: Base, d2: Base) => (d1) match { case Up | Down => false } + } } } @@ -55,10 +60,12 @@ object Test3 { object Base { case object Down extends Base + locally { (d1: Base, d2: Base) => (d1, d2) match { case (Down, Down) => false } + } } } @@ -74,10 +81,12 @@ object Test4 { } import Test4.Base._ + locally { (d1: Base, d2: Base) => (d1, d2) match { case (Up, Up) | (Down, Down) => false case (Down, Test4.Base.Up) => true case (Up, Down) => false } + } } diff --git a/tests/pending/pos/t7475a.scala b/tests/pos/t7475a.scala similarity index 100% rename from tests/pending/pos/t7475a.scala rename to tests/pos/t7475a.scala diff --git a/tests/pending/pos/t7475b.scala b/tests/pos/t7475b.scala similarity index 100% rename from tests/pending/pos/t7475b.scala rename to tests/pos/t7475b.scala diff --git a/tests/pending/pos/t7520.scala b/tests/pos/t7520.scala similarity index 100% rename from tests/pending/pos/t7520.scala rename to tests/pos/t7520.scala diff --git a/tests/pending/pos/t758.scala b/tests/pos/t758.scala similarity index 100% rename from tests/pending/pos/t758.scala rename to tests/pos/t758.scala diff --git a/tests/pending/pos/t7591/Demo.scala b/tests/pos/t7591.scala similarity index 100% rename from tests/pending/pos/t7591/Demo.scala rename to tests/pos/t7591.scala diff --git a/tests/pending/pos/t7782.scala b/tests/pos/t7782.scala similarity index 100% rename from tests/pending/pos/t7782.scala rename to tests/pos/t7782.scala diff --git a/tests/pending/pos/t7782b.scala b/tests/pos/t7782b.scala similarity index 100% rename from tests/pending/pos/t7782b.scala rename to tests/pos/t7782b.scala diff --git a/tests/pending/pos/t7785.scala b/tests/pos/t7785.scala similarity index 100% rename from tests/pending/pos/t7785.scala rename to tests/pos/t7785.scala diff --git a/tests/pending/pos/t7853.scala b/tests/pos/t7853.scala similarity index 100% rename from tests/pending/pos/t7853.scala rename to tests/pos/t7853.scala diff --git a/tests/pending/pos/t788.scala b/tests/pos/t788.scala similarity index 100% rename from tests/pending/pos/t788.scala rename to tests/pos/t788.scala diff --git a/tests/pending/pos/t7928.scala b/tests/pos/t7928.scala similarity index 100% rename from tests/pending/pos/t7928.scala rename to tests/pos/t7928.scala diff --git a/tests/pending/pos/t796.scala b/tests/pos/t796.scala similarity index 100% rename from tests/pending/pos/t796.scala rename to tests/pos/t796.scala diff --git a/tests/pending/pos/t7983.scala b/tests/pos/t7983.scala similarity index 100% rename from tests/pending/pos/t7983.scala rename to tests/pos/t7983.scala diff --git a/tests/pending/pos/t802.scala b/tests/pos/t802.scala similarity index 87% rename from tests/pending/pos/t802.scala rename to tests/pos/t802.scala index 2dea7036d657..50a948251517 100644 --- a/tests/pending/pos/t802.scala +++ b/tests/pos/t802.scala @@ -8,12 +8,12 @@ trait Test { } abstract class ParensImpl extends BracesImpl { type Brace <: Singleton with BraceImpl; - trait BraceImpl extends super.BraceImpl; + trait BraceImpl2 extends super.BraceImpl; } val parens : ParensImpl; abstract class BracksImpl extends BracesImpl { type Brace <: Singleton with BraceImpl; - trait BraceImpl extends super.BraceImpl; + trait BraceImpl2 extends super.BraceImpl; } val bracks : BracksImpl; trait File { diff --git a/tests/pending/pos/t8023b.scala b/tests/pos/t8023b.scala similarity index 100% rename from tests/pending/pos/t8023b.scala rename to tests/pos/t8023b.scala diff --git a/tests/pending/pos/t8045.scala b/tests/pos/t8045.scala similarity index 100% rename from tests/pending/pos/t8045.scala rename to tests/pos/t8045.scala diff --git a/tests/pending/pos/t805.scala b/tests/pos/t805.scala similarity index 76% rename from tests/pending/pos/t805.scala rename to tests/pos/t805.scala index 37bf6b5ef87f..a1260a834f73 100644 --- a/tests/pending/pos/t805.scala +++ b/tests/pos/t805.scala @@ -5,11 +5,11 @@ trait MatcherYYY { } } trait BraceMatcherXXX extends MatcherYYY { - trait NodeImpl extends super.NodeImpl { + trait NodeImpl2 extends super.NodeImpl { def doMatch (braces : BracePair) : Unit } trait BracePair { - trait BraceImpl extends NodeImpl with Matchable { + trait BraceImpl extends NodeImpl2 with Matchable { override def doMatch : Unit = { super.doMatch; (); diff --git a/tests/pending/pos/t8128.scala b/tests/pos/t8128.scala similarity index 100% rename from tests/pending/pos/t8128.scala rename to tests/pos/t8128.scala diff --git a/tests/pending/pos/t8177a.scala b/tests/pos/t8177a.scala similarity index 100% rename from tests/pending/pos/t8177a.scala rename to tests/pos/t8177a.scala diff --git a/tests/pending/pos/t8187.scala b/tests/pos/t8187.scala similarity index 100% rename from tests/pending/pos/t8187.scala rename to tests/pos/t8187.scala diff --git a/tests/pending/pos/t8219.scala b/tests/pos/t8219.scala similarity index 100% rename from tests/pending/pos/t8219.scala rename to tests/pos/t8219.scala diff --git a/tests/pending/pos/t8367.scala b/tests/pos/t8367.scala similarity index 100% rename from tests/pending/pos/t8367.scala rename to tests/pos/t8367.scala diff --git a/tests/pending/pos/t8369a.scala b/tests/pos/t8369a.scala similarity index 100% rename from tests/pending/pos/t8369a.scala rename to tests/pos/t8369a.scala diff --git a/tests/pending/pos/t873.scala b/tests/pos/t873.scala similarity index 100% rename from tests/pending/pos/t873.scala rename to tests/pos/t873.scala diff --git a/tests/pending/pos/t911.scala b/tests/pos/t911.scala similarity index 100% rename from tests/pending/pos/t911.scala rename to tests/pos/t911.scala diff --git a/tests/pending/pos/tcpoly_infer_ticket1864.scala b/tests/pos/tcpoly_infer_ticket1864.scala similarity index 100% rename from tests/pending/pos/tcpoly_infer_ticket1864.scala rename to tests/pos/tcpoly_infer_ticket1864.scala diff --git a/tests/pending/pos/tcpoly_ticket2096.scala b/tests/pos/tcpoly_ticket2096.scala similarity index 100% rename from tests/pending/pos/tcpoly_ticket2096.scala rename to tests/pos/tcpoly_ticket2096.scala diff --git a/tests/pending/pos/tcpoly_variance_pos.scala b/tests/pos/tcpoly_variance_pos.scala similarity index 100% rename from tests/pending/pos/tcpoly_variance_pos.scala rename to tests/pos/tcpoly_variance_pos.scala diff --git a/tests/pending/pos/ted.scala b/tests/pos/ted.scala similarity index 100% rename from tests/pending/pos/ted.scala rename to tests/pos/ted.scala diff --git a/tests/pending/pos/test4.scala b/tests/pos/test4.scala similarity index 100% rename from tests/pending/pos/test4.scala rename to tests/pos/test4.scala diff --git a/tests/pending/pos/test5.scala b/tests/pos/test5.scala similarity index 100% rename from tests/pending/pos/test5.scala rename to tests/pos/test5.scala diff --git a/tests/pending/pos/test5refine.scala b/tests/pos/test5refine.scala similarity index 100% rename from tests/pending/pos/test5refine.scala rename to tests/pos/test5refine.scala diff --git a/tests/pending/pos/typealiases.scala b/tests/pos/typealiases.scala similarity index 100% rename from tests/pending/pos/typealiases.scala rename to tests/pos/typealiases.scala diff --git a/tests/pending/pos/typerep-stephane.scala b/tests/pos/typerep-stephane.scala similarity index 100% rename from tests/pending/pos/typerep-stephane.scala rename to tests/pos/typerep-stephane.scala diff --git a/tests/pending/pos/virtpatmat_alts_subst.scala b/tests/pos/virtpatmat_alts_subst.scala similarity index 100% rename from tests/pending/pos/virtpatmat_alts_subst.scala rename to tests/pos/virtpatmat_alts_subst.scala diff --git a/tests/pending/pos/virtpatmat_exist1.scala b/tests/pos/virtpatmat_exist1.scala similarity index 100% rename from tests/pending/pos/virtpatmat_exist1.scala rename to tests/pos/virtpatmat_exist1.scala diff --git a/tests/pending/pos/virtpatmat_exist3.scala b/tests/pos/virtpatmat_exist3.scala similarity index 100% rename from tests/pending/pos/virtpatmat_exist3.scala rename to tests/pos/virtpatmat_exist3.scala diff --git a/tests/pending/pos/virtpatmat_exist_uncurry.scala b/tests/pos/virtpatmat_exist_uncurry.scala similarity index 100% rename from tests/pending/pos/virtpatmat_exist_uncurry.scala rename to tests/pos/virtpatmat_exist_uncurry.scala