diff options
539 files changed, 3648 insertions, 2188 deletions
diff --git a/src/compiler/scala/reflect/internal/Definitions.scala b/src/compiler/scala/reflect/internal/Definitions.scala index 26b6a3cd14..72fca5da12 100644 --- a/src/compiler/scala/reflect/internal/Definitions.scala +++ b/src/compiler/scala/reflect/internal/Definitions.scala @@ -924,6 +924,18 @@ trait Definitions extends reflect.api.StandardDefinitions { lazy val ClassTargetClass = getMetaAnnotation("companionClass") lazy val ObjectTargetClass = getMetaAnnotation("companionObject") lazy val MethodTargetClass = getMetaAnnotation("companionMethod") // TODO: module, moduleClass? package, packageObject? + lazy val LanguageFeatureAnnot = getMetaAnnotation("languageFeature") + + // Language features + lazy val languageFeatureModule = getRequiredModule("scala.languageFeature") + lazy val experimentalModule = getMember(languageFeatureModule, newTermName("experimental")) + lazy val MacrosFeature = getLanguageFeature("macros", experimentalModule) + lazy val DynamicsFeature = getLanguageFeature("dynamics") + lazy val PostfixOpsFeature = getLanguageFeature("postfixOps") + lazy val ReflectiveCallsFeature = getLanguageFeature("reflectiveCalls") + lazy val ImplicitConversionsFeature = getLanguageFeature("implicitConversions") + lazy val HigherKindsFeature = getLanguageFeature("higherKinds") + lazy val ExistentialsFeature = getLanguageFeature("existentials") private def getMetaAnnotation(name: String) = getRequiredClass("scala.annotation.meta." + name) def isMetaAnnotation(sym: Symbol): Boolean = metaAnnotations(sym) || ( @@ -975,6 +987,9 @@ trait Definitions extends reflect.api.StandardDefinitions { try getModule(fullname.toTermName) catch { case _: MissingRequirementError => NoSymbol } + def getLanguageFeature(name: String, owner: Symbol = languageFeatureModule) = + getMember(owner, newTypeName(name)) + def termMember(owner: Symbol, name: String): Symbol = owner.info.member(newTermName(name)) def typeMember(owner: Symbol, name: String): Symbol = owner.info.member(newTypeName(name)) @@ -994,7 +1009,13 @@ trait Definitions extends reflect.api.StandardDefinitions { def getMember(owner: Symbol, name: Name): Symbol = { getMemberIfDefined(owner, name) orElse { - throw new FatalError(owner + " does not have a member " + name) + if (phase.flatClasses && name.isTypeName && !owner.isPackageObjectOrClass) { + val pkg = owner.owner + val flatname = nme.flattenedName(owner.name, name) + getMember(pkg, flatname) + } else { + throw new FatalError(owner + " does not have a member " + name) + } } } def getMemberIfDefined(owner: Symbol, name: Name): Symbol = @@ -1011,7 +1032,7 @@ trait Definitions extends reflect.api.StandardDefinitions { } def getDeclIfDefined(owner: Symbol, name: Name): Symbol = owner.info.nonPrivateDecl(name) - + def packageExists(packageName: String): Boolean = getModuleIfDefined(packageName).isPackage diff --git a/src/compiler/scala/reflect/internal/Names.scala b/src/compiler/scala/reflect/internal/Names.scala index 5f38374f20..d2b55d9d39 100644 --- a/src/compiler/scala/reflect/internal/Names.scala +++ b/src/compiler/scala/reflect/internal/Names.scala @@ -8,6 +8,7 @@ package internal import scala.io.Codec import java.security.MessageDigest +import language.implicitConversions /** The class Names ... * diff --git a/src/compiler/scala/reflect/internal/StdNames.scala b/src/compiler/scala/reflect/internal/StdNames.scala index 04f67a3196..ac2cf178bf 100644 --- a/src/compiler/scala/reflect/internal/StdNames.scala +++ b/src/compiler/scala/reflect/internal/StdNames.scala @@ -9,12 +9,13 @@ package internal import scala.collection.immutable import NameTransformer.MODULE_SUFFIX_STRING import annotation.switch +import language.implicitConversions trait StdNames extends NameManglers { self: SymbolTable => def encode(str: String): TermName = newTermNameCached(NameTransformer.encode(str)) - implicit def lowerTermNames(n: TermName): String = "" + n + implicit def lowerTermNames(n: TermName): String = n.toString // implicit def stringToTermName(s: String): TermName = newTermName(s) @@ -56,6 +57,7 @@ trait StdNames extends NameManglers { self: SymbolTable => final val RETURNkw: TermName = kw("return") final val SEALEDkw: TermName = kw("sealed") final val SUPERkw: TermName = kw("super") + final val THENkw: TermName = kw("then") final val THISkw: TermName = kw("this") final val THROWkw: TermName = kw("throw") final val TRAITkw: TermName = kw("trait") @@ -323,6 +325,7 @@ trait StdNames extends NameManglers { self: SymbolTable => val append: NameType = "append" val apply: NameType = "apply" val applyDynamic: NameType = "applyDynamic" + val applyDynamicNamed: NameType = "applyDynamicNamed" val applyOrElse: NameType = "applyOrElse" val args : NameType = "args" val argv : NameType = "argv" @@ -424,6 +427,7 @@ trait StdNames extends NameManglers { self: SymbolTable => val runtime: NameType = "runtime" val sameElements: NameType = "sameElements" val scala_ : NameType = "scala" + val selectDynamic: NameType = "selectDynamic" val selectOverloadedMethod: NameType = "selectOverloadedMethod" val selectTerm: NameType = "selectTerm" val selectType: NameType = "selectType" @@ -453,6 +457,7 @@ trait StdNames extends NameManglers { self: SymbolTable => val unapplySeq: NameType = "unapplySeq" val unbox: NameType = "unbox" val update: NameType = "update" + val updateDynamic: NameType = "updateDynamic" val value: NameType = "value" val valueOf : NameType = "valueOf" val values : NameType = "values" diff --git a/src/compiler/scala/reflect/internal/SymbolTable.scala b/src/compiler/scala/reflect/internal/SymbolTable.scala index 5ed37c04ad..0268339ed0 100644 --- a/src/compiler/scala/reflect/internal/SymbolTable.scala +++ b/src/compiler/scala/reflect/internal/SymbolTable.scala @@ -267,6 +267,8 @@ abstract class SymbolTable extends api.Universe import java.lang.ref.WeakReference import scala.runtime.ScalaRunTime.stringOf + import language.reflectiveCalls + // We can allow ourselves a structural type, these methods // amount to a few calls per run at most. This does suggest // a "Clearable" trait may be useful. diff --git a/src/compiler/scala/reflect/internal/Symbols.scala b/src/compiler/scala/reflect/internal/Symbols.scala index fc94e96acd..3bb57cea04 100644 --- a/src/compiler/scala/reflect/internal/Symbols.scala +++ b/src/compiler/scala/reflect/internal/Symbols.scala @@ -850,6 +850,16 @@ trait Symbols extends api.Symbols { self: SymbolTable => final def isStructuralRefinement: Boolean = (isClass || isType || isModule) && info.normalize/*.underlying*/.isStructuralRefinement + /** Is this a term symbol only defined in a refinement (so that it needs + * to be accessed by reflection)? + */ + def isOnlyRefinementMember: Boolean = + isTerm && // type members are not affected + owner.isRefinementClass && // owner must be a refinement class + (owner.info decl name) == this && // symbol must be explicitly declared in the refinement (not synthesized from glb) + allOverriddenSymbols.isEmpty && // symbol must not override a symbol in a base class + !isConstant // symbol must not be a constant. Question: Can we exclude @inline methods as well? + final def isStructuralRefinementMember = owner.isStructuralRefinement && isPossibleInRefinement && isPublic final def isPossibleInRefinement = !isConstructor && !isOverridingSymbol @@ -1751,7 +1761,8 @@ trait Symbols extends api.Symbols { self: SymbolTable => } else owner.enclosingTopLevelClass /** Is this symbol defined in the same scope and compilation unit as `that` symbol? */ - def isCoDefinedWith(that: Symbol) = ( + def isCoDefinedWith(that: Symbol) = { + import language.reflectiveCalls (this.rawInfo ne NoType) && (this.effectiveOwner == that.effectiveOwner) && { !this.effectiveOwner.isPackageClass || @@ -1770,7 +1781,7 @@ trait Symbols extends api.Symbols { self: SymbolTable => false } } - ) + } /** The internal representation of classes and objects: * @@ -1874,7 +1885,7 @@ trait Symbols extends api.Symbols { self: SymbolTable => site.nonPrivateMemberAdmitting(name, admit).filter(sym => !sym.isTerm || (site.memberType(this) matches site.memberType(sym))) - /** The symbol overridden by this symbol in given class `ofclazz`. + /** The symbol, in class `ofclazz`, that is overridden by this symbol. * * @param ofclazz is a base class of this symbol's owner. */ @@ -3093,10 +3104,11 @@ trait Symbols extends api.Symbols { self: SymbolTable => if (settings.debug.value) printStackTrace() } - case class InvalidCompanions(sym1: Symbol, sym2: Symbol) extends Throwable( + case class InvalidCompanions(sym1: Symbol, sym2: Symbol) extends Throwable({ + import language.reflectiveCalls "Companions '" + sym1 + "' and '" + sym2 + "' must be defined in same file:\n" + " Found in " + sym1.sourceFile.canonicalPath + " and " + sym2.sourceFile.canonicalPath - ) { + }) { override def toString = getMessage } diff --git a/src/compiler/scala/reflect/internal/TreeInfo.scala b/src/compiler/scala/reflect/internal/TreeInfo.scala index ed22cad730..a8cca1625f 100644 --- a/src/compiler/scala/reflect/internal/TreeInfo.scala +++ b/src/compiler/scala/reflect/internal/TreeInfo.scala @@ -532,6 +532,21 @@ abstract class TreeInfo { } } + def isApplyDynamicName(name: Name) = (name == nme.updateDynamic) || (name == nme.selectDynamic) || (name == nme.applyDynamic) || (name == nme.applyDynamicNamed) + + class DynamicApplicationExtractor(nameTest: Name => Boolean) { + def unapply(tree: Tree) = tree match { + case Apply(TypeApply(Select(qual, oper), _), List(Literal(Constant(name)))) if nameTest(oper) => Some((qual, name)) + case Apply(Select(qual, oper), List(Literal(Constant(name)))) if nameTest(oper) => Some((qual, name)) + case Apply(Ident(oper), List(Literal(Constant(name)))) if nameTest(oper) => Some((EmptyTree, name)) + case _ => None + } + } + object DynamicUpdate extends DynamicApplicationExtractor(_ == nme.updateDynamic) + object DynamicApplication extends DynamicApplicationExtractor(isApplyDynamicName) + object DynamicApplicationNamed extends DynamicApplicationExtractor(_ == nme.applyDynamicNamed) + + // domain-specific extractors for reification import definitions._ diff --git a/src/compiler/scala/reflect/internal/TreePrinters.scala b/src/compiler/scala/reflect/internal/TreePrinters.scala index 9b4c18ce86..486a3d3567 100644 --- a/src/compiler/scala/reflect/internal/TreePrinters.scala +++ b/src/compiler/scala/reflect/internal/TreePrinters.scala @@ -103,6 +103,16 @@ trait TreePrinters extends api.TreePrinters { self: SymbolTable => } } + def printLabelParams(ps: List[Ident]) { + print("(") + printSeq(ps){printLabelParam}{print(", ")} + print(")") + } + + def printLabelParam(p: Ident) { + print(symName(p, p.name)); printOpt(": ", TypeTree() setType p.tpe) + } + def printValueParams(ts: List[ValDef]) { print("(") if (!ts.isEmpty) printFlags(ts.head.mods.flags & IMPLICIT, "") @@ -219,7 +229,7 @@ trait TreePrinters extends api.TreePrinters { self: SymbolTable => } case LabelDef(name, params, rhs) => - print(symName(tree, name)); printRow(params, "(", ",", ")"); printBlock(rhs) + print(symName(tree, name)); printLabelParams(params); printBlock(rhs) case Import(expr, selectors) => // Is this selector remapping a name (i.e, {name1 => name2}) diff --git a/src/compiler/scala/reflect/internal/Trees.scala b/src/compiler/scala/reflect/internal/Trees.scala index 0d7e68aee3..5f1a8f3fbe 100644 --- a/src/compiler/scala/reflect/internal/Trees.scala +++ b/src/compiler/scala/reflect/internal/Trees.scala @@ -103,9 +103,7 @@ trait Trees extends api.Trees { self: SymbolTable => // --- extension methods -------------------------------------------------------- - implicit def treeOps(tree: Tree): TreeOps = new TreeOps(tree) - - class TreeOps(tree: Tree) { + implicit class TreeOps(tree: Tree) { def isErroneous = (tree.tpe ne null) && tree.tpe.isErroneous def isTyped = (tree.tpe ne null) && !tree.tpe.isErroneous @@ -146,11 +144,9 @@ trait Trees extends api.Trees { self: SymbolTable => * less than the whole tree. */ def summaryString: String = tree match { - case Select(qual, name) => qual.summaryString + "." + name.decode - case Ident(name) => name.longString case Literal(const) => "Literal(" + const + ")" - case t: DefTree => t.shortClass + " `" + t.name.decode + "`" - case t: RefTree => t.shortClass + " `" + t.name.longString + "`" + case Select(qual, name) => qual.summaryString + "." + name.decode + case t: NameTree => t.name.longString case t => t.shortClass + ( if (t.symbol != null && t.symbol != NoSymbol) " " + t.symbol diff --git a/src/compiler/scala/reflect/internal/Types.scala b/src/compiler/scala/reflect/internal/Types.scala index c6b320b444..17c9b955ca 100644 --- a/src/compiler/scala/reflect/internal/Types.scala +++ b/src/compiler/scala/reflect/internal/Types.scala @@ -97,7 +97,7 @@ trait Types extends api.Types { self: SymbolTable => */ private final val propagateParameterBoundsToTypeVars = sys.props contains "scalac.debug.prop-constraints" - protected val enableTypeVarExperimentals = settings.Xexperimental.value || settings.YvirtPatmat.value + protected val enableTypeVarExperimentals = settings.Xexperimental.value || !settings.XoldPatmat.value /** Empty immutable maps to avoid allocations. */ private val emptySymMap = immutable.Map[Symbol, Symbol]() @@ -712,7 +712,9 @@ trait Types extends api.Types { self: SymbolTable => /** Returns all parts of this type which satisfy predicate `p` */ def filter(p: Type => Boolean): List[Type] = new FilterTypeCollector(p) collect this - def withFilter(p: Type => Boolean) = new FilterTypeCollector(p) { + def withFilter(p: Type => Boolean) = new FilterMapForeach(p) + + class FilterMapForeach(p: Type => Boolean) extends FilterTypeCollector(p){ def foreach[U](f: Type => U): Unit = collect(Type.this) foreach f def map[T](f: Type => T): List[T] = collect(Type.this) map f } @@ -2518,39 +2520,46 @@ trait Types extends api.Types { self: SymbolTable => override def skolemizeExistential(owner: Symbol, origin: AnyRef) = deriveType(quantified, tparam => (owner orElse tparam.owner).newExistentialSkolem(tparam, origin))(underlying) - private def wildcardArgsString(available: Set[Symbol], args: List[Type]): List[String] = args match { - case TypeRef(_, sym, _) :: args1 if (available contains sym) => - ("_"+sym.infoString(sym.info)) :: wildcardArgsString(available - sym, args1) - case arg :: args1 if !(quantified exists (arg contains _)) => - arg.toString :: wildcardArgsString(available, args1) - case _ => - List() + private def wildcardArgsString(qset: Set[Symbol], args: List[Type]): List[String] = args map { + case TypeRef(_, sym, _) if (qset contains sym) => + "_"+sym.infoString(sym.info) + case arg => + arg.toString } + /** An existential can only be printed with wildcards if: * - the underlying type is a typeref - * - where there is a 1-to-1 correspondence between underlying's typeargs and quantified - * - and none of the existential parameters is referenced from anywhere else in the type - * - and none of the existential parameters are singleton types + * - every quantified variable appears at most once as a type argument and + * nowhere inside a type argument + * - no quantified type argument contains a quantified variable in its bound + * - the typeref's symbol is not itself quantified + * - the prefix is not quanitified */ - private def isRepresentableWithWildcards = !settings.debug.value && { + def isRepresentableWithWildcards = { val qset = quantified.toSet - !qset.exists(_.isSingletonExistential) && (underlying match { - case TypeRef(_, sym, args) => - sameLength(args, quantified) && { - args forall { arg => - qset(arg.typeSymbol) && !qset.exists(arg.typeSymbol.info.bounds contains _) - } + underlying match { + case TypeRef(pre, sym, args) => + def isQuantified(tpe: Type): Boolean = { + (tpe exists (t => qset contains t.typeSymbol)) || + tpe.typeSymbol.isRefinementClass && (tpe.parents exists isQuantified) } + val (wildcardArgs, otherArgs) = args partition (arg => qset contains arg.typeSymbol) + wildcardArgs.distinct == wildcardArgs && + !(otherArgs exists (arg => isQuantified(arg))) && + !(wildcardArgs exists (arg => isQuantified(arg.typeSymbol.info.bounds))) && + !(qset contains sym) && + !isQuantified(pre) case _ => false - }) + } } + override def safeToString: String = { def clauses = { val str = quantified map (_.existentialToString) mkString (" forSome { ", "; ", " }") if (settings.explaintypes.value) "(" + str + ")" else str } underlying match { - case TypeRef(pre, sym, args) if isRepresentableWithWildcards => + case TypeRef(pre, sym, args) if !settings.debug.value && isRepresentableWithWildcards => "" + TypeRef(pre, sym, Nil) + wildcardArgsString(quantified.toSet, args).mkString("[", ", ", "]") case MethodType(_, _) | NullaryMethodType(_) | PolyType(_, _) => "(" + underlying + ")" + clauses diff --git a/src/compiler/scala/reflect/internal/settings/MutableSettings.scala b/src/compiler/scala/reflect/internal/settings/MutableSettings.scala index b556c33aba..45ba4ed3e6 100644 --- a/src/compiler/scala/reflect/internal/settings/MutableSettings.scala +++ b/src/compiler/scala/reflect/internal/settings/MutableSettings.scala @@ -43,5 +43,5 @@ abstract class MutableSettings extends AbsSettings { def Yrecursion: IntSetting def maxClassfileName: IntSetting def Xexperimental: BooleanSetting - def YvirtPatmat: BooleanSetting + def XoldPatmat: BooleanSetting }
\ No newline at end of file diff --git a/src/compiler/scala/reflect/makro/runtime/Errors.scala b/src/compiler/scala/reflect/makro/runtime/AbortMacroException.scala index d78eae9237..d78eae9237 100644 --- a/src/compiler/scala/reflect/makro/runtime/Errors.scala +++ b/src/compiler/scala/reflect/makro/runtime/AbortMacroException.scala diff --git a/src/compiler/scala/reflect/reify/Reifiers.scala b/src/compiler/scala/reflect/reify/Reifier.scala index 16c26734b2..16c26734b2 100644 --- a/src/compiler/scala/reflect/reify/Reifiers.scala +++ b/src/compiler/scala/reflect/reify/Reifier.scala diff --git a/src/compiler/scala/reflect/reify/phases/Calculate.scala b/src/compiler/scala/reflect/reify/phases/Calculate.scala index 59a36f0ba4..e4f3fce407 100644 --- a/src/compiler/scala/reflect/reify/phases/Calculate.scala +++ b/src/compiler/scala/reflect/reify/phases/Calculate.scala @@ -8,14 +8,12 @@ trait Calculate { import definitions._ import treeInfo._ - implicit def sym2richSym(sym: Symbol): RichSymbol = new RichSymbol(sym) - class RichSymbol(sym: Symbol) { + implicit class RichSymbol(sym: Symbol) { def metalevel: Int = { assert(sym != NoSymbol); localSymbols.getOrElse(sym, 0) } def isLocalToReifee = (localSymbols contains sym) // [Eugene] how do I account for local skolems? } - implicit def tpe2richTpe(tpe: Type): RichType = new RichType(tpe) - class RichType(tpe: Type) { + implicit class RichType(tpe: Type) { def isLocalToReifee = tpe != null && (tpe exists (tp => (localSymbols contains tp.typeSymbol) || (localSymbols contains tp.termSymbol))) } @@ -58,4 +56,4 @@ trait Calculate { super.traverse(tree) } } -}
\ No newline at end of file +} diff --git a/src/compiler/scala/reflect/runtime/Settings.scala b/src/compiler/scala/reflect/runtime/Settings.scala index 27e90c94bd..bbe4d60e9c 100644 --- a/src/compiler/scala/reflect/runtime/Settings.scala +++ b/src/compiler/scala/reflect/runtime/Settings.scala @@ -34,5 +34,5 @@ class Settings extends internal.settings.MutableSettings { val maxClassfileName = new IntSetting(255) val Xexperimental = new BooleanSetting(false) val deepCloning = new BooleanSetting (false) - val YvirtPatmat = new BooleanSetting(false) + val XoldPatmat = new BooleanSetting(false) } diff --git a/src/compiler/scala/tools/cmd/gen/AnyVals.scala b/src/compiler/scala/tools/cmd/gen/AnyVals.scala index 0869350dd3..e8230b8ca4 100644 --- a/src/compiler/scala/tools/cmd/gen/AnyVals.scala +++ b/src/compiler/scala/tools/cmd/gen/AnyVals.scala @@ -14,20 +14,34 @@ trait AnyValReps { sealed abstract class AnyValNum(name: String, repr: Option[String], javaEquiv: String) extends AnyValRep(name,repr,javaEquiv) { case class Op(val op : String, val doc : String) + + private def companionCoercions(tos: String*) = { + tos.toList map (to => + """implicit def %s2%s(x: %s): %s = x.to%s""".format(javaEquiv, to, name, to.capitalize, to.capitalize) + ) + } + def implicitCoercions: List[String] = javaEquiv match { + case "byte" => companionCoercions("short", "int", "long", "float", "double") + case "short" | "char" => companionCoercions("int", "long", "float", "double") + case "int" => companionCoercions("long", "float", "double") + case "long" => companionCoercions("float", "double") + case "float" => companionCoercions("double") + case _ => Nil + } def isCardinal: Boolean = isIntegerType(this) def unaryOps = { val ops = List( Op("+", "/**\n" + - " * @return this value, unmodified\n" + + " * Returns this value, unmodified.\n" + " */"), Op("-", "/**\n" + - " * @return the negation of this value\n" + + " * Returns the negation of this value.\n" + " */")) if(isCardinal) Op("~", "/**\n" + - " * @return the bitwise negation of this value\n" + + " * Returns the bitwise negation of this value.\n" + " * @example {{{\n" + " * ~5 == -6\n" + " * // in binary: ~00000101 ==\n" + @@ -41,7 +55,7 @@ trait AnyValReps { if (isCardinal) List( Op("|", "/**\n" + - " * @return the bitwise OR of this value and x\n" + + " * Returns the bitwise OR of this value and `x`.\n" + " * @example {{{\n" + " * (0xf0 | 0xaa) == 0xfa\n" + " * // in binary: 11110000\n" + @@ -51,7 +65,7 @@ trait AnyValReps { " * }}}\n" + " */"), Op("&", "/**\n" + - " * @return the bitwise AND of this value and x\n" + + " * Returns the bitwise AND of this value and `x`.\n" + " * @example {{{\n" + " * (0xf0 & 0xaa) == 0xa0\n" + " * // in binary: 11110000\n" + @@ -61,7 +75,7 @@ trait AnyValReps { " * }}}\n" + " */"), Op("^", "/**\n" + - " * @return the bitwise XOR of this value and x\n" + + " * Returns the bitwise XOR of this value and `x`.\n" + " * @example {{{\n" + " * (0xf0 ^ 0xaa) == 0x5a\n" + " * // in binary: 11110000\n" + @@ -76,13 +90,13 @@ trait AnyValReps { if (isCardinal) List( Op("<<", "/**\n" + - " * @return this value bit-shifted left by the specified number of bits,\n" + + " * Returns this value bit-shifted left by the specified number of bits,\n" + " * filling in the new right bits with zeroes.\n" + " * @example {{{ 6 << 3 == 48 // in binary: 0110 << 3 == 0110000 }}}\n" + " */"), Op(">>>", "/**\n" + - " * @return this value bit-shifted right by the specified number of bits,\n" + + " * Returns this value bit-shifted right by the specified number of bits,\n" + " * filling the new left bits with zeroes.\n" + " * @example {{{ 21 >>> 3 == 2 // in binary: 010101 >>> 3 == 010 }}}\n" + " * @example {{{\n" + @@ -93,7 +107,7 @@ trait AnyValReps { " */"), Op(">>", "/**\n" + - " * @return this value bit-shifted left by the specified number of bits,\n" + + " * Returns this value bit-shifted left by the specified number of bits,\n" + " * filling in the right bits with the same value as the left-most bit of this.\n" + " * The effect of this is to retain the sign of the value.\n" + " * @example {{{\n" + @@ -105,19 +119,19 @@ trait AnyValReps { else Nil def comparisonOps = List( - Op("==", "/**\n * @return `true` if this value is equal x, `false` otherwise\n */"), - Op("!=", "/**\n * @return `true` if this value is not equal to x, `false` otherwise\n */"), - Op("<", "/**\n * @return `true` if this value is less than x, `false` otherwise\n */"), - Op("<=", "/**\n * @return `true` if this value is less than or equal to x, `false` otherwise\n */"), - Op(">", "/**\n * @return `true` if this value is greater than x, `false` otherwise\n */"), - Op(">=", "/**\n * @return `true` if this value is greater than or equal to x, `false` otherwise\n */")) + Op("==", "/**\n * Returns `true` if this value is equal to x, `false` otherwise.\n */"), + Op("!=", "/**\n * Returns `true` if this value is not equal to x, `false` otherwise.\n */"), + Op("<", "/**\n * Returns `true` if this value is less than x, `false` otherwise.\n */"), + Op("<=", "/**\n * Returns `true` if this value is less than or equal to x, `false` otherwise.\n */"), + Op(">", "/**\n * Returns `true` if this value is greater than x, `false` otherwise.\n */"), + Op(">=", "/**\n * Returns `true` if this value is greater than or equal to x, `false` otherwise.\n */")) def otherOps = List( - Op("+", "/**\n * @return the sum of this value and x\n */"), - Op("-", "/**\n * @return the difference of this value and x\n */"), - Op("*", "/**\n * @return the product of this value and x\n */"), - Op("/", "/**\n * @return the quotient of this value and x\n */"), - Op("%", "/**\n * @return the remainder of the division of this value by x\n */")) + Op("+", "/**\n * Returns the sum of this value and `x`.\n */"), + Op("-", "/**\n * Returns the difference of this value and `x`.\n */"), + Op("*", "/**\n * Returns the product of this value and `x`.\n */"), + Op("/", "/**\n * Returns the quotient of this value and `x`.\n */"), + Op("%", "/**\n * Returns the remainder of the division of this value by `x`.\n */")) // Given two numeric value types S and T , the operation type of S and T is defined as follows: // If both S and T are subrange types then the operation type of S and T is Int. @@ -160,7 +174,7 @@ trait AnyValReps { } def objectLines = { val comp = if (isCardinal) cardinalCompanion else floatingCompanion - (comp + allCompanions).trim.lines map interpolate toList + ((comp + allCompanions).trim.lines map interpolate).toList ++ implicitCoercions } /** Makes a set of binary operations based on the given set of ops, args, and resultFn. @@ -224,8 +238,8 @@ trait AnyValReps { def classDoc = interpolate(classDocTemplate) def objectDoc = "" def mkImports = "" - def mkClass = assemble("final class", "AnyVal", classLines) + "\n" - def mkObject = assemble("object", "AnyValCompanion", objectLines) + "\n" + def mkClass = assemble("final class", "private", "AnyVal", classLines) + "\n" + def mkObject = assemble("object", "", "AnyValCompanion", objectLines) + "\n" def make() = List[String]( headerTemplate, mkImports, @@ -235,8 +249,8 @@ trait AnyValReps { mkObject ) mkString "" - def assemble(what: String, parent: String, lines: List[String]): String = { - val decl = "%s %s extends %s ".format(what, name, parent) + def assemble(what: String, ctor: String, parent: String, lines: List[String]): String = { + val decl = "%s %s %s extends %s ".format(what, name, ctor, parent) val body = if (lines.isEmpty) "{ }\n\n" else lines map indent mkString ("{\n", "\n", "\n}\n") decl + body diff --git a/src/compiler/scala/tools/nsc/CompilationUnits.scala b/src/compiler/scala/tools/nsc/CompilationUnits.scala index d6f57801e7..92a0efff1e 100644 --- a/src/compiler/scala/tools/nsc/CompilationUnits.scala +++ b/src/compiler/scala/tools/nsc/CompilationUnits.scala @@ -61,6 +61,9 @@ trait CompilationUnits { self: Global => /** things to check at end of compilation unit */ val toCheck = new ListBuffer[() => Unit] + /** The features that were already checked for this unit */ + var checkedFeatures = Set[Symbol]() + def position(pos: Int) = source.position(pos) /** The position of a targeted type check @@ -85,12 +88,10 @@ trait CompilationUnits { self: Global => reporter.warning(pos, msg) def deprecationWarning(pos: Position, msg: String) = - if (opt.deprecation) warning(pos, msg) - else currentRun.deprecationWarnings ::= ((pos, msg)) + currentRun.deprecationWarnings.warn(pos, msg) def uncheckedWarning(pos: Position, msg: String) = - if (opt.unchecked) warning(pos, msg) - else currentRun.uncheckedWarnings ::= ((pos, msg)) + currentRun.uncheckedWarnings.warn(pos, msg) def incompleteInputError(pos: Position, msg:String) = reporter.incompleteInputError(pos, msg) @@ -104,10 +105,14 @@ trait CompilationUnits { self: Global => override def toString() = source.toString() def clear() { - fresh = null - body = null + fresh = new FreshNameCreator.Default + body = EmptyTree depends.clear() defined.clear() + synthetics.clear() + toCheck.clear() + checkedFeatures = Set() + icode.clear() } } } diff --git a/src/compiler/scala/tools/nsc/CompileSocket.scala b/src/compiler/scala/tools/nsc/CompileSocket.scala index a0c39f71fb..a4a8e1fd11 100644 --- a/src/compiler/scala/tools/nsc/CompileSocket.scala +++ b/src/compiler/scala/tools/nsc/CompileSocket.scala @@ -93,7 +93,7 @@ class CompileSocket extends CompileOutputCommon { /** Start a new server. */ private def startNewServer(vmArgs: String) = { - val cmd = serverCommand(vmArgs split " " toSeq) + val cmd = serverCommand((vmArgs split " ").toSeq) info("[Executing command: %s]" format cmd.mkString(" ")) // Hiding inadequate daemonized implementation from public API for now @@ -206,7 +206,7 @@ class CompileSocket extends CompileOutputCommon { Thread sleep 100 ff.length } - if (Iterator continually check take 50 find (_ > 0) isEmpty) { + if ((Iterator continually check take 50 find (_ > 0)).isEmpty) { ff.delete() fatal("Unable to establish connection to server.") } diff --git a/src/compiler/scala/tools/nsc/CompilerCommand.scala b/src/compiler/scala/tools/nsc/CompilerCommand.scala index 54bc218912..4c8a27083a 100644 --- a/src/compiler/scala/tools/nsc/CompilerCommand.scala +++ b/src/compiler/scala/tools/nsc/CompilerCommand.scala @@ -47,7 +47,7 @@ class CompilerCommand(arguments: List[String], val settings: Settings) { /** Creates a help message for a subset of options based on cond */ def createUsageMsg(cond: Setting => Boolean): String = { val baseList = (settings.visibleSettings filter cond).toList sortBy (_.name) - val width = baseList map (_.helpSyntax.length) max + val width = (baseList map (_.helpSyntax.length)).max def format(s: String) = ("%-" + width + "s") format s def helpStr(s: Setting) = { val str = format(s.helpSyntax) + " " + s.helpDescription diff --git a/src/compiler/scala/tools/nsc/GenericRunnerSettings.scala b/src/compiler/scala/tools/nsc/GenericRunnerSettings.scala index b9e9a14adf..f91cb854c6 100644 --- a/src/compiler/scala/tools/nsc/GenericRunnerSettings.scala +++ b/src/compiler/scala/tools/nsc/GenericRunnerSettings.scala @@ -8,7 +8,7 @@ package scala.tools.nsc import scala.tools.util.PathResolver class GenericRunnerSettings(error: String => Unit) extends Settings(error) { - def classpathURLs = new PathResolver(this) asURLs + def classpathURLs = new PathResolver(this).asURLs val howtorun = ChoiceSetting( diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index b7d7f5d16f..403b5717b0 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -31,6 +31,7 @@ import backend.{ ScalaPrimitives, Platform, MSILPlatform, JavaPlatform } import backend.jvm.GenJVM import backend.opt.{ Inliners, InlineExceptionHandlers, ClosureElimination, DeadCodeElimination } import backend.icode.analysis._ +import language.postfixOps class Global(var currentSettings: Settings, var reporter: NscReporter) extends SymbolTable with ClassLoaders @@ -346,7 +347,7 @@ class Global(var currentSettings: Settings, var reporter: NscReporter) extends S override protected val etaExpandKeepsStar = settings.etaExpandKeepsStar.value // Here comes another one... override protected val enableTypeVarExperimentals = ( - settings.Xexperimental.value || settings.YvirtPatmat.value + settings.Xexperimental.value || !settings.XoldPatmat.value ) // True if -Xscript has been set, indicating a script run. @@ -938,6 +939,17 @@ class Global(var currentSettings: Settings, var reporter: NscReporter) extends S inform("[running phase " + ph.name + " on " + currentRun.size + " compilation units]") } + /** Collects for certain classes of warnings during this run. */ + class ConditionalWarning(what: String, option: Settings#BooleanSetting) { + val warnings = new mutable.ListBuffer[(Position, String)] + def warn(pos: Position, msg: String) = + if (option.value) reporter.warning(pos, msg) + else warnings += ((pos, msg)) + def summarize() = + if (option.isDefault && warnings.nonEmpty) + reporter.warning(NoPosition, "there were %d %s warnings; re-run with %s for details".format(warnings.size, what, option.name)) + } + /** A Run is a single execution of the compiler on a sets of units */ class Run { @@ -949,9 +961,12 @@ class Global(var currentSettings: Settings, var reporter: NscReporter) extends S /** The currently compiled unit; set from GlobalPhase */ var currentUnit: CompilationUnit = NoCompilationUnit - /** Counts for certain classes of warnings during this run. */ - var deprecationWarnings: List[(Position, String)] = Nil - var uncheckedWarnings: List[(Position, String)] = Nil + val deprecationWarnings = new ConditionalWarning("deprecation", settings.deprecation) + val uncheckedWarnings = new ConditionalWarning("unchecked", settings.unchecked) + val featureWarnings = new ConditionalWarning("feature", settings.feature) + val allConditionalWarnings = List(deprecationWarnings, uncheckedWarnings, featureWarnings) + + var reportedFeature = Set[Symbol]() /** A flag whether macro expansions failed */ var macroExpansionFailed = false @@ -1241,12 +1256,8 @@ class Global(var currentSettings: Settings, var reporter: NscReporter) extends S } } else { - def warn(count: Int, what: String, option: Settings#BooleanSetting) = ( - if (option.isDefault && count > 0) - warning("there were %d %s warnings; re-run with %s for details".format(count, what, option.name)) - ) - warn(deprecationWarnings.size, "deprecation", settings.deprecation) - warn(uncheckedWarnings.size, "unchecked", settings.unchecked) + allConditionalWarnings foreach (_.summarize) + if (macroExpansionFailed) warning("some macros could not be expanded and code fell back to overridden methods;"+ "\nrecompiling with generated classfiles on the classpath might help.") diff --git a/src/compiler/scala/tools/nsc/PhaseAssembly.scala b/src/compiler/scala/tools/nsc/PhaseAssembly.scala index a627b982b6..a9e029e485 100644 --- a/src/compiler/scala/tools/nsc/PhaseAssembly.scala +++ b/src/compiler/scala/tools/nsc/PhaseAssembly.scala @@ -8,6 +8,7 @@ package scala.tools.nsc import java.io.{ BufferedWriter, FileWriter } import scala.collection.mutable +import language.postfixOps /** * PhaseAssembly diff --git a/src/compiler/scala/tools/nsc/Phases.scala b/src/compiler/scala/tools/nsc/Phases.scala index d18495458c..1fa576afb6 100644 --- a/src/compiler/scala/tools/nsc/Phases.scala +++ b/src/compiler/scala/tools/nsc/Phases.scala @@ -7,6 +7,7 @@ package scala.tools.nsc import symtab.Flags import util.TableDef +import language.postfixOps object Phases { val MaxPhases = 64 diff --git a/src/compiler/scala/tools/nsc/ast/NodePrinters.scala b/src/compiler/scala/tools/nsc/ast/NodePrinters.scala index c79ca1206e..108c8fcbfa 100644 --- a/src/compiler/scala/tools/nsc/ast/NodePrinters.scala +++ b/src/compiler/scala/tools/nsc/ast/NodePrinters.scala @@ -8,6 +8,7 @@ package ast import compat.Platform.EOL import symtab.Flags._ +import language.postfixOps /** The object `nodePrinter` converts the internal tree * representation to a string. diff --git a/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala b/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala index 3302c11127..b4beb231ab 100644 --- a/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala +++ b/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala @@ -18,6 +18,7 @@ import scala.concurrent.Lock import scala.text._ import symtab.Flags._ import symtab.SymbolTable +import language.implicitConversions /** * Tree browsers can show the AST in a graphical and interactive diff --git a/src/compiler/scala/tools/nsc/ast/TreeDSL.scala b/src/compiler/scala/tools/nsc/ast/TreeDSL.scala index 2b75925d9a..283bdecf26 100644 --- a/src/compiler/scala/tools/nsc/ast/TreeDSL.scala +++ b/src/compiler/scala/tools/nsc/ast/TreeDSL.scala @@ -9,6 +9,7 @@ package ast import PartialFunction._ import symtab.Flags +import language.implicitConversions /** A DSL for generating scala code. The goal is that the * code generating code should look a lot like the code it diff --git a/src/compiler/scala/tools/nsc/ast/TreeGen.scala b/src/compiler/scala/tools/nsc/ast/TreeGen.scala index 19d1e0a51a..d3e64811d3 100644 --- a/src/compiler/scala/tools/nsc/ast/TreeGen.scala +++ b/src/compiler/scala/tools/nsc/ast/TreeGen.scala @@ -9,6 +9,7 @@ package ast import scala.collection.mutable.ListBuffer import symtab.Flags._ import symtab.SymbolTable +import language.postfixOps /** XXX to resolve: TreeGen only assumes global is a SymbolTable, but * TreeDSL at the moment expects a Global. Can we get by with SymbolTable? @@ -71,14 +72,6 @@ abstract class TreeGen extends reflect.internal.TreeGen with TreeDSL { Annotated(Ident(nme.synthSwitch), expr) } - // must be kept in synch with the codegen in PatMatVirtualiser - object VirtualCaseDef { - def unapply(b: Block): Option[(Assign, Tree, Tree)] = b match { - case Block(List(assign@Assign(keepGoingLhs, falseLit), matchRes), zero) => Some((assign, matchRes, zero)) // TODO: check tree annotation - case _ => None - } - } - def hasSynthCaseSymbol(t: Tree) = (t.symbol ne null) && (t.symbol hasFlag (CASE | SYNTHETIC)) // TODO: would be so much nicer if we would know during match-translation (i.e., type checking) @@ -86,9 +79,11 @@ abstract class TreeGen extends reflect.internal.TreeGen with TreeDSL { class MatchMatcher { def caseMatch(orig: Tree, selector: Tree, cases: List[CaseDef], wrap: Tree => Tree): Tree = unknownTree(orig) def caseVirtualizedMatch(orig: Tree, _match: Tree, targs: List[Tree], scrut: Tree, matcher: Tree): Tree = unknownTree(orig) - def caseVirtualizedMatchOpt(orig: Tree, zero: ValDef, x: ValDef, matchRes: ValDef, keepGoing: ValDef, stats: List[Tree], epilogue: Tree, wrap: Tree => Tree): Tree = unknownTree(orig) + def caseVirtualizedMatchOpt(orig: Tree, prologue: List[Tree], cases: List[Tree], matchEndDef: Tree, wrap: Tree => Tree): Tree = unknownTree(orig) - def apply(matchExpr: Tree): Tree = (matchExpr: @unchecked) match { + def genVirtualizedMatch(prologue: List[Tree], cases: List[Tree], matchEndDef: Tree): Tree = Block(prologue ++ cases, matchEndDef) + + def apply(matchExpr: Tree): Tree = matchExpr match { // old-style match or virtpatmat switch case Match(selector, cases) => // println("simple match: "+ (selector, cases) + "for:\n"+ matchExpr ) caseMatch(matchExpr, selector, cases, identity) @@ -99,11 +94,15 @@ abstract class TreeGen extends reflect.internal.TreeGen with TreeDSL { case Apply(Apply(TypeApply(Select(tgt, nme.runOrElse), targs), List(scrut)), List(matcher)) if opt.virtPatmat => // println("virt match: "+ (tgt, targs, scrut, matcher) + "for:\n"+ matchExpr ) caseVirtualizedMatch(matchExpr, tgt, targs, scrut, matcher) // optimized version of virtpatmat - case Block((zero: ValDef) :: (x: ValDef) :: (matchRes: ValDef) :: (keepGoing: ValDef) :: stats, epilogue) if opt.virtPatmat => // TODO: check tree annotation // println("virtopt match: "+ (zero, x, matchRes, keepGoing, stats) + "for:\n"+ matchExpr ) - caseVirtualizedMatchOpt(matchExpr, zero, x, matchRes, keepGoing, stats, epilogue, identity) + case Block(stats, matchEndDef) if opt.virtPatmat && (stats forall hasSynthCaseSymbol) => + // the assumption is once we encounter a case, the remainder of the block will consist of cases + // the prologue may be empty, usually it is the valdef that stores the scrut + val (prologue, cases) = stats span (s => !s.isInstanceOf[LabelDef]) + caseVirtualizedMatchOpt(matchExpr, prologue, cases, matchEndDef, identity) // optimized version of virtpatmat - case Block(outerStats, orig@Block((zero: ValDef) :: (x: ValDef) :: (matchRes: ValDef) :: (keepGoing: ValDef) :: stats, epilogue)) if opt.virtPatmat => // TODO: check tree annotation // println("virt opt block match: "+ (zero, x, matchRes, keepGoing, stats, outerStats) + "for:\n"+ matchExpr ) - caseVirtualizedMatchOpt(matchExpr, zero, x, matchRes, keepGoing, stats, epilogue, m => copyBlock(matchExpr, outerStats, m)) + case Block(outerStats, orig@Block(stats, matchEndDef)) if opt.virtPatmat && (stats forall hasSynthCaseSymbol) => + val (prologue, cases) = stats span (s => !s.isInstanceOf[LabelDef]) + caseVirtualizedMatchOpt(matchExpr, prologue, cases, matchEndDef, m => copyBlock(matchExpr, outerStats, m)) case other => unknownTree(other) } @@ -119,35 +118,6 @@ abstract class TreeGen extends reflect.internal.TreeGen with TreeDSL { } } - def withDefaultCase(matchExpr: Tree, defaultAction: Tree/*scrutinee*/ => Tree): Tree = { - object withDefaultTransformer extends MatchMatcher { - override def caseMatch(orig: Tree, selector: Tree, cases: List[CaseDef], wrap: Tree => Tree): Tree = { - val casesNoSynthCatchAll = dropSyntheticCatchAll(cases) - if (casesNoSynthCatchAll exists treeInfo.isDefaultCase) orig - else { - val defaultCase = CaseDef(Ident(nme.WILDCARD), EmptyTree, defaultAction(selector.duplicate)) - wrap(Match(selector, casesNoSynthCatchAll :+ defaultCase)) - } - } - override def caseVirtualizedMatch(orig: Tree, _match: Tree, targs: List[Tree], scrut: Tree, matcher: Tree): Tree = { import CODE._ - ((matcher APPLY (scrut)) DOT nme.getOrElse) APPLY (defaultAction(scrut.duplicate)) // TODO: pass targs - } - override def caseVirtualizedMatchOpt(orig: Tree, zero: ValDef, x: ValDef, matchRes: ValDef, keepGoing: ValDef, stats: List[Tree], epilogue: Tree, wrap: Tree => Tree): Tree = { import CODE._ - wrap(Block( - zero :: - x :: - matchRes :: - keepGoing :: - stats, - // replace `if (keepGoing) throw new MatchError(...) else matchRes` by `if (keepGoing) ${defaultAction(`x`)} else matchRes` - (IF (REF(keepGoing.symbol)) THEN defaultAction(x.rhs.duplicate) ELSE REF(matchRes.symbol)) - )) - } - } - withDefaultTransformer(matchExpr) - } - - def mkCached(cvar: Symbol, expr: Tree): Tree = { val cvarRef = mkUnattributedRef(cvar) Block( diff --git a/src/compiler/scala/tools/nsc/ast/Trees.scala b/src/compiler/scala/tools/nsc/ast/Trees.scala index 66704680ae..04452c68e5 100644 --- a/src/compiler/scala/tools/nsc/ast/Trees.scala +++ b/src/compiler/scala/tools/nsc/ast/Trees.scala @@ -58,6 +58,8 @@ trait Trees extends reflect.internal.Trees { self: Global => case class InjectDerivedValue(arg: Tree) extends SymTree + class PostfixSelect(qual: Tree, name: Name) extends Select(qual, name) + /** emitted by typer, eliminated by refchecks */ case class TypeTreeWithDeferredRefCheck()(val check: () => TypeTree) extends TypTree @@ -253,6 +255,7 @@ trait Trees extends reflect.internal.Trees { self: Global => def resetAllAttrs[A <: Tree](x: A, leaveAlone: Tree => Boolean = null): A = new ResetAttrs(false, leaveAlone).transform(x) def resetLocalAttrs[A <: Tree](x: A, leaveAlone: Tree => Boolean = null): A = new ResetAttrs(true, leaveAlone).transform(x) + def resetLocalAttrsKeepLabels[A<:Tree](x: A, leaveAlone: Tree => Boolean = null): A = new ResetAttrs(true, leaveAlone, true).transform(x) /** A transformer which resets symbol and tpe fields of all nodes in a given tree, * with special treatment of: @@ -263,7 +266,7 @@ trait Trees extends reflect.internal.Trees { self: Global => * * (bq:) This transformer has mutable state and should be discarded after use */ - private class ResetAttrs(localOnly: Boolean, leaveAlone: Tree => Boolean = null) { + private class ResetAttrs(localOnly: Boolean, leaveAlone: Tree => Boolean = null, keepLabels: Boolean = false) { val debug = settings.debug.value val trace = scala.tools.nsc.util.trace when debug @@ -326,18 +329,18 @@ trait Trees extends reflect.internal.Trees { self: Global => case EmptyTree => tree case _ => - if (tree.hasSymbol && (!localOnly || (locals contains tree.symbol))) + if (tree.hasSymbol && (!localOnly || (locals contains tree.symbol)) && !(keepLabels && tree.symbol.isLabel)) tree.symbol = NoSymbol tree.tpe = null tree } } - } + } } def transform[T <: Tree](x: T): T = { if (localOnly) - new MarkLocals().traverse(x) + new MarkLocals().traverse(x) if (localOnly && debug) { assert(locals.size == orderedLocals.size) @@ -361,4 +364,4 @@ trait Trees extends reflect.internal.Trees { self: Global => */ - }
\ No newline at end of file + } diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala index daabfae6b3..eb4deeeee2 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala @@ -70,6 +70,9 @@ trait ParsersCommon extends ScannersCommon { @inline final def inBracesOrNil[T](body: => List[T]): List[T] = inBracesOrError(body, Nil) @inline final def inBracesOrUnit[T](body: => Tree): Tree = inBracesOrError(body, Literal(Constant())) + @inline final def dropAnyBraces[T](body: => T): T = + if (in.token == LBRACE) inBraces(body) + else body @inline final def inBrackets[T](body: => T): T = { accept(LBRACKET) @@ -1106,7 +1109,7 @@ self => * }}} * @note The returned tree does not yet have a position */ - def literal(isNegated: Boolean = false): Tree = { + def literal(isNegated: Boolean = false, inPattern: Boolean = false): Tree = { def finish(value: Any): Tree = { val t = Literal(Constant(value)) in.nextToken() @@ -1115,7 +1118,7 @@ self => if (in.token == SYMBOLLIT) Apply(scalaDot(nme.Symbol), List(finish(in.strVal))) else if (in.token == INTERPOLATIONID) - interpolatedString() + interpolatedString(inPattern) else finish(in.token match { case CHARLIT => in.charVal case INTLIT => in.intVal(isNegated).toInt @@ -1141,7 +1144,7 @@ self => } } - private def interpolatedString(): Tree = atPos(in.offset) { + private def interpolatedString(inPattern: Boolean = false): Tree = atPos(in.offset) { val start = in.offset val interpolator = in.name @@ -1151,8 +1154,11 @@ self => while (in.token == STRINGPART) { partsBuf += literal() exprBuf += { - if (in.token == IDENTIFIER) atPos(in.offset)(Ident(ident())) - else expr() + if (inPattern) dropAnyBraces(pattern()) + else { + if (in.token == IDENTIFIER) atPos(in.offset)(Ident(ident())) + else expr() + } } } if (in.token == STRINGLIT) partsBuf += literal() @@ -1456,11 +1462,12 @@ self => return reduceStack(true, base, top, 0, true) top = next } else { + // postfix expression val topinfo = opstack.head opstack = opstack.tail val od = stripParens(reduceStack(true, base, topinfo.operand, 0, true)) return atPos(od.pos.startOrPoint, topinfo.offset) { - Select(od, topinfo.operator.encode) + new PostfixSelect(od, topinfo.operator.encode) } } } @@ -1772,21 +1779,7 @@ self => */ def pattern2(): Tree = { val nameOffset = in.offset - def warnIfMacro(tree: Tree): Unit = { - def check(name: Name): Unit = if (name.toString == nme.MACROkw.toString) - warning(nameOffset, "in future versions of Scala \"macro\" will be a keyword. consider using a different name.") - tree match { - case _: BackQuotedIdent => - ; - case Ident(name) => - check(name) - case _ => - ; - } - } - val p = pattern3() - warnIfMacro(p) if (in.token != AT) p else p match { @@ -1850,7 +1843,7 @@ self => case INTLIT | LONGLIT | FLOATLIT | DOUBLELIT => t match { case Ident(nme.MINUS) => - return atPos(start) { literal(isNegated = true) } + return atPos(start) { literal(isNegated = true, inPattern = true) } case _ => } case _ => @@ -1868,7 +1861,7 @@ self => atPos(start, start) { Ident(nme.WILDCARD) } case CHARLIT | INTLIT | LONGLIT | FLOATLIT | DOUBLELIT | STRINGLIT | INTERPOLATIONID | SYMBOLLIT | TRUE | FALSE | NULL => - atPos(start) { literal() } + atPos(start) { literal(inPattern = true) } case LPAREN => atPos(start)(makeParens(noSeq.patterns())) case XMLSTART => @@ -2462,8 +2455,6 @@ self => val nameOffset = in.offset val isBackquoted = in.token == BACKQUOTED_IDENT val name = ident() - if (name.toString == nme.MACROkw.toString && !isBackquoted) - warning(nameOffset, "in future versions of Scala \"macro\" will be a keyword. consider using a different name.") funDefRest(start, nameOffset, mods, name) } } @@ -2479,7 +2470,7 @@ self => val vparamss = paramClauses(name, contextBoundBuf.toList, false) newLineOptWhenFollowedBy(LBRACE) var restype = fromWithinReturnType(typedOpt()) - val rhs = + val rhs = if (isStatSep || in.token == RBRACE) { if (restype.isEmpty) restype = scalaUnitConstr newmods |= Flags.DEFERRED @@ -2488,10 +2479,15 @@ self => restype = scalaUnitConstr blockExpr() } else { - accept(EQUALS) - if (settings.Xmacros.value && in.token == MACRO) { - in.nextToken() - newmods |= Flags.MACRO + if (in.token == EQUALS) { + in.nextTokenAllow(nme.MACROkw) + if (settings.Xmacros.value && in.token == MACRO || // [Martin] Xmacros can be retired now + in.token == IDENTIFIER && in.name == nme.MACROkw) { + in.nextToken() + newmods |= Flags.MACRO + } + } else { + accept(EQUALS) } expr() } @@ -2554,8 +2550,6 @@ self => val nameOffset = in.offset val isBackquoted = in.token == BACKQUOTED_IDENT val name = identForType() - if (name.toString == nme.MACROkw.toString && !isBackquoted) - warning(nameOffset, "in future versions of Scala \"macro\" will be a keyword. consider using a different name.") // @M! a type alias as well as an abstract type may declare type parameters val tparams = typeParamClauseOpt(name, null) in.token match { @@ -2615,15 +2609,12 @@ self => val nameOffset = in.offset val isBackquoted = in.token == BACKQUOTED_IDENT val name = identForType() - if (name.toString == nme.MACROkw.toString && !isBackquoted) - warning(nameOffset, "in future versions of Scala \"macro\" will be a keyword. consider using a different name.") - atPos(start, if (name == tpnme.ERROR) start else nameOffset) { savingClassContextBounds { val contextBoundBuf = new ListBuffer[Tree] val tparams = typeParamClauseOpt(name, contextBoundBuf) classContextBounds = contextBoundBuf.toList - val tstart = in.offset :: classContextBounds.map(_.pos.startOrPoint) min; + val tstart = (in.offset :: classContextBounds.map(_.pos.startOrPoint)).min if (!classContextBounds.isEmpty && mods.isTrait) { syntaxError("traits cannot have type parameters with context bounds `: ...' nor view bounds `<% ...'", false) classContextBounds = List() @@ -2659,8 +2650,6 @@ self => val nameOffset = in.offset val isBackquoted = in.token == BACKQUOTED_IDENT val name = ident() - if (name.toString == nme.MACROkw.toString && !isBackquoted) - warning(nameOffset, "in future versions of Scala \"macro\" will be a keyword. consider using a different name.") val tstart = in.offset atPos(start, if (name == nme.ERROR) start else nameOffset) { val mods1 = if (in.token == SUBTYPE) mods | Flags.DEFERRED else mods @@ -2839,24 +2828,7 @@ self => */ def packaging(start: Int): Tree = { val nameOffset = in.offset - def warnIfMacro(tree: Tree): Unit = { - def check(name: Name): Unit = if (name.toString == nme.MACROkw.toString) - warning(nameOffset, "in future versions of Scala \"macro\" will be a keyword. consider using a different name.") - tree match { - case _: BackQuotedIdent => - ; - case Ident(name) => - check(name) - case Select(qual, name) => - warnIfMacro(qual) - check(name) - case _ => - ; - } - } - val pkg = pkgQualId() - warnIfMacro(pkg) val stats = inBracesOrNil(topStatSeq()) makePackaging(start, pkg, stats) } @@ -3059,27 +3031,8 @@ self => } } else { val nameOffset = in.offset - def warnIfMacro(tree: Tree): Unit = { - def check(name: Name): Unit = if (name.toString == nme.MACROkw.toString) - warning(nameOffset, "in future versions of Scala \"macro\" will be a keyword. consider using a different name.") - tree match { - // [Eugene] pkgQualId never returns BackQuotedIdents - // this means that we'll get spurious warnings even if we wrap macro package name in backquotes - case _: BackQuotedIdent => - ; - case Ident(name) => - check(name) - case Select(qual, name) => - warnIfMacro(qual) - check(name) - case _ => - ; - } - } - in.flushDoc val pkg = pkgQualId() - warnIfMacro(pkg) if (in.token == EOF) { ts += makePackaging(start, pkg, List()) diff --git a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala index ce38f034cf..87072f3172 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala @@ -113,10 +113,18 @@ trait Scanners extends ScannersCommon { } /** Clear buffer and set name and token */ - private def finishNamed() { + private def finishNamed(idtoken: Int = IDENTIFIER) { name = newTermName(cbuf.toString) - token = name2token(name) cbuf.clear() + token = idtoken + if (idtoken == IDENTIFIER) { + val idx = name.start - kwOffset + if (idx >= 0 && idx < kwArray.length) { + token = kwArray(idx) + if (token == IDENTIFIER && allowIdent != name) + deprecationWarning(name+" is now a reserved word; usage as an identifier is deprecated") + } + } } /** Clear buffer and set string */ @@ -190,6 +198,20 @@ trait Scanners extends ScannersCommon { off } + /** Allow an otherwise deprecated ident here */ + private var allowIdent: Name = nme.EMPTY + + /** Get next token, and allow the otherwise deprecated ident `name` */ + def nextTokenAllow(name: Name) = { + val prev = allowIdent + allowIdent = name + try { + nextToken() + } finally { + allowIdent = prev + } + } + /** Produce next token, filling TokenData fields of Scanner. */ def nextToken() { @@ -568,9 +590,8 @@ trait Scanners extends ScannersCommon { getLitChars('`') if (ch == '`') { nextChar() - finishNamed() + finishNamed(BACKQUOTED_IDENT) if (name.length == 0) syntaxError("empty quoted identifier") - token = BACKQUOTED_IDENT } else syntaxError("unclosed quoted identifier") } @@ -1130,9 +1151,9 @@ trait Scanners extends ScannersCommon { nme.VIEWBOUNDkw -> VIEWBOUND, nme.SUPERTYPEkw -> SUPERTYPE, nme.HASHkw -> HASH, - nme.ATkw -> AT - ) ++ - (if (settings.Xmacros.value) List(nme.MACROkw -> MACRO) else List()) + nme.ATkw -> AT, + nme.MACROkw -> IDENTIFIER, + nme.THENkw -> IDENTIFIER) private var kwOffset: Int = -1 private val kwArray: Array[Int] = { @@ -1141,14 +1162,7 @@ trait Scanners extends ScannersCommon { arr } - final val token2name = allKeywords map (_.swap) toMap - - /** Convert name to token */ - final def name2token(name: Name) = { - val idx = name.start - kwOffset - if (idx >= 0 && idx < kwArray.length) kwArray(idx) - else IDENTIFIER - } + final val token2name = (allKeywords map (_.swap)).toMap // Token representation ---------------------------------------------------- diff --git a/src/compiler/scala/tools/nsc/ast/parser/SymbolicXMLBuilder.scala b/src/compiler/scala/tools/nsc/ast/parser/SymbolicXMLBuilder.scala index 849437e4ff..0f2a3e0395 100755 --- a/src/compiler/scala/tools/nsc/ast/parser/SymbolicXMLBuilder.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/SymbolicXMLBuilder.scala @@ -11,6 +11,7 @@ import xml.{ EntityRef, Text } import xml.XML.{ xmlns } import symtab.Flags.MUTABLE import scala.tools.util.StringOps.splitWhere +import language.implicitConversions /** This class builds instance of `Tree` that represent XML. * diff --git a/src/compiler/scala/tools/nsc/ast/parser/Tokens.scala b/src/compiler/scala/tools/nsc/ast/parser/Tokens.scala index e17bbf5e46..a4a062609b 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Tokens.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Tokens.scala @@ -110,7 +110,8 @@ object Tokens extends Tokens { final val MATCH = 58 final val FORSOME = 59 final val LAZY = 61 - final val MACRO = 62 + final val MACRO = 62 // not yet used in 2.10 + final val THEN = 63 // not yet used in 2.10 def isKeyword(code: Int) = code >= IF && code <= LAZY diff --git a/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala b/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala index 4f3b0bf951..dcbabd6517 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala @@ -11,6 +11,7 @@ import scala.collection.{ mutable, immutable } import mutable.{ ListBuffer, ArrayBuffer } import util.{ Position, NoPosition } import backend.icode.analysis.ProgramPoint +import language.postfixOps trait BasicBlocks { self: ICodes => diff --git a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala index ec303d76ee..ff58de5f12 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala @@ -13,6 +13,7 @@ import scala.collection.mutable.{ ListBuffer, Buffer } import scala.tools.nsc.symtab._ import scala.annotation.switch import PartialFunction._ +import language.postfixOps /** This class ... * diff --git a/src/compiler/scala/tools/nsc/backend/icode/Members.scala b/src/compiler/scala/tools/nsc/backend/icode/Members.scala index 36651541b2..71795a02aa 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/Members.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/Members.scala @@ -44,7 +44,7 @@ trait Members { def blocksList: List[BasicBlock] = blocks.toList def instructions = blocksList flatMap (_.iterator) def blockCount = blocks.size - def instructionCount = blocks map (_.length) sum + def instructionCount = (blocks map (_.length)).sum def touched = _touched def touched_=(b: Boolean): Unit = { diff --git a/src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala b/src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala index 7ad7cadd92..f61f78ebb2 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala @@ -44,7 +44,7 @@ trait TypeKinds { self: ICodes => } /** Reverse map for toType */ private lazy val reversePrimitiveMap: Map[TypeKind, Symbol] = - primitiveTypeMap map (_.swap) toMap + (primitiveTypeMap map (_.swap)).toMap /** This class represents a type kind. Type kinds * represent the types that the VM know (or the ICode diff --git a/src/compiler/scala/tools/nsc/backend/icode/analysis/CopyPropagation.scala b/src/compiler/scala/tools/nsc/backend/icode/analysis/CopyPropagation.scala index f5be82a776..4427da92c8 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/analysis/CopyPropagation.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/analysis/CopyPropagation.scala @@ -566,8 +566,8 @@ abstract class CopyPropagation { method.blocks map { b => "\nIN(%s):\t Bindings: %s".format(b.label, in(b).bindings) + "\nIN(%s):\t Stack: %s".format(b.label, in(b).stack) - } mkString - ) + } + ).mkString } /* class CopyAnalysis */ } diff --git a/src/compiler/scala/tools/nsc/backend/icode/analysis/Liveness.scala b/src/compiler/scala/tools/nsc/backend/icode/analysis/Liveness.scala index 49f5b51d51..5f261ba05e 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/analysis/Liveness.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/analysis/Liveness.scala @@ -97,6 +97,6 @@ abstract class Liveness { } } override def toString() = - method.blocks map (b => "\nlive-in(%s)=%s\nlive-out(%s)=%s".format(b, in(b), b, out(b))) mkString + (method.blocks map (b => "\nlive-in(%s)=%s\nlive-out(%s)=%s".format(b, in(b), b, out(b)))).mkString } /* Liveness analysis */ } diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BytecodeWriters.scala b/src/compiler/scala/tools/nsc/backend/jvm/BytecodeWriters.scala index c217869a48..0bc41b51bb 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/BytecodeWriters.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/BytecodeWriters.scala @@ -13,6 +13,7 @@ import scala.tools.nsc.util.ScalaClassLoader import scala.tools.util.JavapClass import java.util.jar.{ JarEntry, JarOutputStream, Attributes } import Attributes.Name +import language.postfixOps /** For the last mile: turning generated bytecode in memory into * something you can use. Has implementations for writing to class diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala index c04be1721e..f7898f2aa2 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala @@ -19,6 +19,7 @@ import JAccessFlags._ import JObjectType.{ JAVA_LANG_STRING, JAVA_LANG_OBJECT } import java.util.jar.{ JarEntry, JarOutputStream } import scala.tools.nsc.io.AbstractFile +import language.postfixOps /** This class ... * diff --git a/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala b/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala index 98c1fc2f63..66e7becb12 100644 --- a/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala +++ b/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala @@ -15,6 +15,7 @@ import scala.tools.nsc.symtab._ import ch.epfl.lamp.compiler.msil.{Type => MsilType, _} import ch.epfl.lamp.compiler.msil.emit._ import ch.epfl.lamp.compiler.msil.util.PECustomMod +import language.postfixOps abstract class GenMSIL extends SubComponent { import global._ diff --git a/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala b/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala index 95c371fa8b..d4ee9b6b48 100644 --- a/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala +++ b/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala @@ -82,7 +82,7 @@ abstract class DeadCodeElimination extends SubComponent { mark sweep(m) accessedLocals = accessedLocals.distinct - if (m.locals diff accessedLocals nonEmpty) { + if ((m.locals diff accessedLocals).nonEmpty) { log("Removed dead locals: " + (m.locals diff accessedLocals)) m.locals = accessedLocals.reverse } diff --git a/src/compiler/scala/tools/nsc/backend/opt/InlineExceptionHandlers.scala b/src/compiler/scala/tools/nsc/backend/opt/InlineExceptionHandlers.scala index ec137203bf..0d47352215 100644 --- a/src/compiler/scala/tools/nsc/backend/opt/InlineExceptionHandlers.scala +++ b/src/compiler/scala/tools/nsc/backend/opt/InlineExceptionHandlers.scala @@ -360,7 +360,7 @@ abstract class InlineExceptionHandlers extends SubComponent { val caughtException = toTypeKind(caughtClass.tpe) // copy the exception handler code once again, dropping the LOAD_EXCEPTION val copy = handler.code.newBlock - copy.emitOnly(handler.iterator drop dropCount toSeq: _*) + copy.emitOnly((handler.iterator drop dropCount).toSeq: _*) // extend the handlers of the handler to the copy for (parentHandler <- handler.method.exh ; if parentHandler covers handler) { diff --git a/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala b/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala index dfe9081ee5..cf51a5b926 100644 --- a/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala +++ b/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala @@ -854,7 +854,7 @@ abstract class Inliners extends SubComponent { def lookupIMethod(meth: Symbol, receiver: Symbol): Option[IMethod] = { def tryParent(sym: Symbol) = icodes icode sym flatMap (_ lookupMethod meth) - receiver.info.baseClasses.iterator map tryParent find (_.isDefined) flatten + (receiver.info.baseClasses.iterator map tryParent find (_.isDefined)).flatten } } /* class Inliner */ } /* class Inliners */ diff --git a/src/compiler/scala/tools/nsc/doc/Settings.scala b/src/compiler/scala/tools/nsc/doc/Settings.scala index 3da87bf763..17bfb7d21d 100644 --- a/src/compiler/scala/tools/nsc/doc/Settings.scala +++ b/src/compiler/scala/tools/nsc/doc/Settings.scala @@ -8,6 +8,7 @@ package doc import java.io.File import java.lang.System +import language.postfixOps /** An extended version of compiler settings, with additional Scaladoc-specific options. * @param error A function that prints a string to the appropriate error stream. */ diff --git a/src/compiler/scala/tools/nsc/doc/Uncompilable.scala b/src/compiler/scala/tools/nsc/doc/Uncompilable.scala index dbeca46c25..8f426a443d 100644 --- a/src/compiler/scala/tools/nsc/doc/Uncompilable.scala +++ b/src/compiler/scala/tools/nsc/doc/Uncompilable.scala @@ -5,6 +5,8 @@ package scala.tools.nsc package doc +import language.implicitConversions +import language.postfixOps /** Some glue between DocParser (which reads source files which can't be compiled) * and the scaladoc model. diff --git a/src/compiler/scala/tools/nsc/doc/html/page/Template.scala b/src/compiler/scala/tools/nsc/doc/html/page/Template.scala index 680957c64c..d3f42ffe6e 100644 --- a/src/compiler/scala/tools/nsc/doc/html/page/Template.scala +++ b/src/compiler/scala/tools/nsc/doc/html/page/Template.scala @@ -10,6 +10,7 @@ package page import model._ import scala.xml.{ NodeSeq, Text, UnprefixedAttribute } +import language.postfixOps class Template(universe: doc.Universe, tpl: DocTemplateEntity) extends HtmlPage { diff --git a/src/compiler/scala/tools/nsc/doc/model/IndexModelFactory.scala b/src/compiler/scala/tools/nsc/doc/model/IndexModelFactory.scala index ef3c2beffb..6392de22ff 100755 --- a/src/compiler/scala/tools/nsc/doc/model/IndexModelFactory.scala +++ b/src/compiler/scala/tools/nsc/doc/model/IndexModelFactory.scala @@ -8,6 +8,7 @@ package doc package model import scala.collection._ +import language.reflectiveCalls object IndexModelFactory { @@ -15,7 +16,7 @@ object IndexModelFactory { lazy val firstLetterIndex: Map[Char, SymbolMap] = { - val result = new mutable.HashMap[Char,SymbolMap] { + object result extends mutable.HashMap[Char,SymbolMap] { /* Owner template ordering */ implicit def orderingSet = math.Ordering.String.on { x: MemberEntity => x.name.toLowerCase } diff --git a/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala b/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala index f295e4d211..124a7509e8 100644 --- a/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala +++ b/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala @@ -398,11 +398,13 @@ class ModelFactory(val global: Global, val settings: doc.Settings) { else if (bSym.isPackage) makeTemplate(bSym.owner) match { case inPkg: PackageImpl => makePackage(bSym, inPkg) getOrElse (new NoDocTemplateImpl(bSym, inPkg)) + case inNoDocTpl: NoDocTemplateImpl => new NoDocTemplateImpl(bSym, inNoDocTpl) case _ => throw new Error("'" + bSym + "' must be in a package") } else if (templateShouldDocument(bSym)) makeTemplate(bSym.owner) match { case inDTpl: DocTemplateImpl => makeDocTemplate(bSym, inDTpl) + case inNoDocTpl: NoDocTemplateImpl => new NoDocTemplateImpl(bSym, inNoDocTpl) case _ => throw new Error("'" + bSym + "' must be in documentable template") } else @@ -693,9 +695,9 @@ class ModelFactory(val global: Global, val settings: doc.Settings) { nameBuffer append '⇒' appendType0(result) /* Polymorphic types */ - case PolyType(tparams, result) => assert(tparams nonEmpty) + case PolyType(tparams, result) => assert(tparams.nonEmpty) // throw new Error("Polymorphic type '" + tpe + "' cannot be printed as a type") - def typeParamsToString(tps: List[Symbol]): String = if(tps isEmpty) "" else + def typeParamsToString(tps: List[Symbol]): String = if (tps.isEmpty) "" else tps.map{tparam => tparam.varianceString + tparam.name + typeParamsToString(tparam.typeParams) }.mkString("[", ", ", "]") diff --git a/src/compiler/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala b/src/compiler/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala index 23bef02bed..0e44933ac6 100644 --- a/src/compiler/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala +++ b/src/compiler/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala @@ -137,8 +137,8 @@ trait ModelFactoryImplicitSupport { // Members inherited by implicit conversions cannot override actual members memberSyms = memberSyms.filterNot((sym1: Symbol) => - existingMembers.exists(sym2 => sym1.name == sym2.name && - isSameType(toType.memberInfo(sym1), sym.info.memberInfo(sym2)))) + existingMembers.exists(sym2 => sym1.name == sym2.name && + !isDistinguishableFrom(toType.memberInfo(sym1), sym.info.memberInfo(sym2)))) debug(" -> full type: " + toType) if (constraints.length != 0) { @@ -498,4 +498,22 @@ trait ModelFactoryImplicitSupport { (aSym.isMethod || aSym.isGetter || aSym.isSetter) && (aSym.nameString != "getClass") } + + /* To put it very bluntly: checks if you can call implicitly added method with t1 when t2 is already there in the + * class. We suppose the name of the two members coincides + * + * The trick here is that the resultType does not matter - the condition for removal it that paramss have the same + * structure (A => B => C may not override (A, B) => C) and that all the types involved are + * of the implcit conversion's member are subtypes of the parent members' parameters */ + def isDistinguishableFrom(t1: Type, t2: Type): Boolean = + if (t1.paramss.map(_.length) == t2.paramss.map(_.length)) { + for ((t1p, t2p) <- t1.paramss.flatten zip t2.paramss.flatten) + if (!isSubType(t1 memberInfo t1p, t2 memberInfo t2p)) + return true // if on the corresponding parameter you give a type that is in t1 but not in t2 + // example: + // def foo(a: Either[Int, Double]): Int = 3 + // def foo(b: Left[T1]): Int = 6 + // a.foo(Right(4.5d)) prints out 3 :) + false + } else true // the member structure is different foo(3, 5) vs foo(3)(5) }
\ No newline at end of file diff --git a/src/compiler/scala/tools/nsc/doc/model/comment/CommentFactory.scala b/src/compiler/scala/tools/nsc/doc/model/comment/CommentFactory.scala index bc5cd4a958..e6bc76f676 100644 --- a/src/compiler/scala/tools/nsc/doc/model/comment/CommentFactory.scala +++ b/src/compiler/scala/tools/nsc/doc/model/comment/CommentFactory.scala @@ -13,6 +13,7 @@ import scala.collection._ import scala.util.matching.Regex import scala.annotation.switch import util.{NoPosition, Position} +import language.postfixOps /** The comment parser transforms raw comment strings into `Comment` objects. * Call `parse` to run the parser. Note that the parser is stateless and diff --git a/src/compiler/scala/tools/nsc/interactive/BuildManager.scala b/src/compiler/scala/tools/nsc/interactive/BuildManager.scala index 2ef34cdd96..0f89236861 100644 --- a/src/compiler/scala/tools/nsc/interactive/BuildManager.scala +++ b/src/compiler/scala/tools/nsc/interactive/BuildManager.scala @@ -13,6 +13,7 @@ import util.FakePos import dependencies._ import io.AbstractFile +import language.implicitConversions trait BuildManager { diff --git a/src/compiler/scala/tools/nsc/interactive/Global.scala b/src/compiler/scala/tools/nsc/interactive/Global.scala index 12a3c4b3c6..ec73af4dca 100644 --- a/src/compiler/scala/tools/nsc/interactive/Global.scala +++ b/src/compiler/scala/tools/nsc/interactive/Global.scala @@ -19,6 +19,7 @@ import scala.tools.nsc.io.Pickler._ import scala.tools.nsc.typechecker.DivergentImplicit import scala.annotation.tailrec import symtab.Flags.{ACCESSOR, PARAMACCESSOR} +import language.implicitConversions /** The main class of the presentation compiler in an interactive environment such as an IDE */ @@ -530,6 +531,7 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "") unit.defined.clear() unit.synthetics.clear() unit.toCheck.clear() + unit.checkedFeatures = Set() unit.targetPos = NoPosition unit.contexts.clear() unit.problems.clear() diff --git a/src/compiler/scala/tools/nsc/interactive/ScratchPadMaker.scala b/src/compiler/scala/tools/nsc/interactive/ScratchPadMaker.scala index 34a0a4abb6..e2dcc48709 100644 --- a/src/compiler/scala/tools/nsc/interactive/ScratchPadMaker.scala +++ b/src/compiler/scala/tools/nsc/interactive/ScratchPadMaker.scala @@ -79,7 +79,7 @@ trait ScratchPadMaker { self: Global => addSandbox(stat) } else { val resName = nextRes() - val dispResName = resName filter ('$' !=) + val dispResName = resName filter ('$' != _) patches += Patch(stat.pos.start, "val " + resName + " = ") addSandbox(stat) toPrint += resultString(nameType(dispResName, stat.tpe), resName) diff --git a/src/compiler/scala/tools/nsc/interactive/tests/core/CoreTestDefs.scala b/src/compiler/scala/tools/nsc/interactive/tests/core/CoreTestDefs.scala index 40bbd3fa8e..99541ff4b4 100644 --- a/src/compiler/scala/tools/nsc/interactive/tests/core/CoreTestDefs.scala +++ b/src/compiler/scala/tools/nsc/interactive/tests/core/CoreTestDefs.scala @@ -81,7 +81,7 @@ private[tests] trait CoreTestDefs else { reporter.println("\naskHyperlinkPos for `" + tree.symbol.name + "` at " + format(pos) + " " + pos.source.file.name) val r = new Response[Position] - // `tree.symbol.sourceFile` was discovered to be null when testing -Yvirtpatmat on the akka presentation test, where a position had shifted to point to `Int` + // `tree.symbol.sourceFile` was discovered to be null when testing using virtpatmat on the akka presentation test, where a position had shifted to point to `Int` // askHyperlinkPos for `Int` at (73,19) pi.scala --> class Int in package scala has null sourceFile! val treePath = if (tree.symbol.sourceFile ne null) tree.symbol.sourceFile.path else null val treeName = if (tree.symbol.sourceFile ne null) tree.symbol.sourceFile.name else null diff --git a/src/compiler/scala/tools/nsc/interpreter/ILoop.scala b/src/compiler/scala/tools/nsc/interpreter/ILoop.scala index 108d4377a8..bf386d8a12 100644 --- a/src/compiler/scala/tools/nsc/interpreter/ILoop.scala +++ b/src/compiler/scala/tools/nsc/interpreter/ILoop.scala @@ -23,6 +23,7 @@ import scala.reflect.NameTransformer._ import util.ScalaClassLoader import ScalaClassLoader._ import scala.tools.util._ +import language.{implicitConversions, existentials} /** The Scala interactive shell. It provides a read-eval-print loop * around the Interpreter class. diff --git a/src/compiler/scala/tools/nsc/interpreter/IMain.scala b/src/compiler/scala/tools/nsc/interpreter/IMain.scala index c0f7d8412a..43e01bebfd 100644 --- a/src/compiler/scala/tools/nsc/interpreter/IMain.scala +++ b/src/compiler/scala/tools/nsc/interpreter/IMain.scala @@ -24,6 +24,7 @@ import scala.collection.{ mutable, immutable } import scala.util.control.Exception.{ ultimately } import IMain._ import java.util.concurrent.Future +import language.implicitConversions /** directory to save .class files to */ private class ReplVirtualDirectory(out: JPrintWriter) extends VirtualDirectory("(memory)", None) { @@ -203,8 +204,7 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends }).toList } - implicit def installReplTypeOps(tp: Type): ReplTypeOps = new ReplTypeOps(tp) - class ReplTypeOps(tp: Type) { + implicit class ReplTypeOps(tp: Type) { def orElse(other: => Type): Type = if (tp ne NoType) tp else other def andAlso(fn: Type => Type): Type = if (tp eq NoType) tp else fn(tp) } @@ -825,7 +825,7 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends } def lastWarnings: List[(Position, String)] = ( if (lastRun == null) Nil - else removeDupWarnings(lastRun.deprecationWarnings.reverse) ++ lastRun.uncheckedWarnings.reverse + else removeDupWarnings(lastRun.allConditionalWarnings flatMap (_.warnings)) ) private var lastRun: Run = _ private def evalMethod(name: String) = evalClass.getMethods filter (_.getName == name) match { diff --git a/src/compiler/scala/tools/nsc/interpreter/LoopCommands.scala b/src/compiler/scala/tools/nsc/interpreter/LoopCommands.scala index 9469baa4e2..3520a60ee5 100644 --- a/src/compiler/scala/tools/nsc/interpreter/LoopCommands.scala +++ b/src/compiler/scala/tools/nsc/interpreter/LoopCommands.scala @@ -8,6 +8,7 @@ package interpreter import collection.{ mutable, immutable } import mutable.ListBuffer +import language.implicitConversions class ProcessResult(val line: String) { import sys.process._ diff --git a/src/compiler/scala/tools/nsc/interpreter/MemberHandlers.scala b/src/compiler/scala/tools/nsc/interpreter/MemberHandlers.scala index 099034fe97..40993eb916 100644 --- a/src/compiler/scala/tools/nsc/interpreter/MemberHandlers.scala +++ b/src/compiler/scala/tools/nsc/interpreter/MemberHandlers.scala @@ -9,6 +9,7 @@ package interpreter import scala.collection.{ mutable, immutable } import scala.PartialFunction.cond import scala.reflect.internal.Chars +import language.implicitConversions trait MemberHandlers { val intp: IMain diff --git a/src/compiler/scala/tools/nsc/interpreter/NamedParam.scala b/src/compiler/scala/tools/nsc/interpreter/NamedParam.scala index e92888d89b..e2b1bf34d6 100644 --- a/src/compiler/scala/tools/nsc/interpreter/NamedParam.scala +++ b/src/compiler/scala/tools/nsc/interpreter/NamedParam.scala @@ -7,6 +7,7 @@ package scala.tools.nsc package interpreter import NamedParam._ +import language.implicitConversions trait NamedParamCreator { protected def freshName: () => String @@ -43,4 +44,4 @@ trait NamedParam { def tpe: String def value: Any override def toString = name + ": " + tpe -}
\ No newline at end of file +} diff --git a/src/compiler/scala/tools/nsc/interpreter/Phased.scala b/src/compiler/scala/tools/nsc/interpreter/Phased.scala index d164d1cbb0..f39c025a86 100644 --- a/src/compiler/scala/tools/nsc/interpreter/Phased.scala +++ b/src/compiler/scala/tools/nsc/interpreter/Phased.scala @@ -7,6 +7,7 @@ package scala.tools.nsc package interpreter import scala.collection.{ mutable, immutable } +import language.implicitConversions /** Mix this into an object and use it as a phasing * swiss army knife. diff --git a/src/compiler/scala/tools/nsc/interpreter/Power.scala b/src/compiler/scala/tools/nsc/interpreter/Power.scala index cc06100f5f..ecf9dd219b 100644 --- a/src/compiler/scala/tools/nsc/interpreter/Power.scala +++ b/src/compiler/scala/tools/nsc/interpreter/Power.scala @@ -13,6 +13,7 @@ import session.{ History } import scala.io.Codec import java.net.{ URL, MalformedURLException } import io.{ Path } +import language.implicitConversions /** Collecting some power mode examples. diff --git a/src/compiler/scala/tools/nsc/interpreter/ReplTokens.scala b/src/compiler/scala/tools/nsc/interpreter/ReplTokens.scala index 1c7b256c33..e63fabf151 100644 --- a/src/compiler/scala/tools/nsc/interpreter/ReplTokens.scala +++ b/src/compiler/scala/tools/nsc/interpreter/ReplTokens.scala @@ -9,6 +9,7 @@ package interpreter import util.{ BatchSourceFile, Indenter } import scala.tools.nsc.ast.parser.Tokens._ import java.lang.Integer.toOctalString +import language.{implicitConversions, existentials} /** This began as an attempt at a completely minimal * pretty printer for a token stream, but as it turns out diff --git a/src/compiler/scala/tools/nsc/interpreter/ReplVals.scala b/src/compiler/scala/tools/nsc/interpreter/ReplVals.scala index e293c0fed9..8b891e0010 100644 --- a/src/compiler/scala/tools/nsc/interpreter/ReplVals.scala +++ b/src/compiler/scala/tools/nsc/interpreter/ReplVals.scala @@ -6,6 +6,8 @@ package scala.tools.nsc package interpreter +import language.implicitConversions + /** A class which the repl utilizes to expose predefined objects. * The base implementation is empty; the standard repl implementation * is StdReplVals. diff --git a/src/compiler/scala/tools/nsc/interpreter/package.scala b/src/compiler/scala/tools/nsc/interpreter/package.scala index e78e92c8f8..7d2610e3c8 100644 --- a/src/compiler/scala/tools/nsc/interpreter/package.scala +++ b/src/compiler/scala/tools/nsc/interpreter/package.scala @@ -5,6 +5,8 @@ package scala.tools.nsc +import language.implicitConversions + /** The main REPL related classes and values are as follows. * In addition to standard compiler classes Global and Settings, there are: * @@ -33,6 +35,8 @@ package object interpreter extends ReplConfig with ReplStrings { val IR = Results + implicit def postfixOps = language.postfixOps // make all postfix ops in this package compile without warning + private[interpreter] implicit def javaCharSeqCollectionToScala(xs: JCollection[_ <: CharSequence]): List[String] = { import collection.JavaConverters._ xs.asScala.toList map ("" + _) diff --git a/src/compiler/scala/tools/nsc/interpreter/session/package.scala b/src/compiler/scala/tools/nsc/interpreter/session/package.scala index 8fbba2f05e..4e5b08c8cb 100644 --- a/src/compiler/scala/tools/nsc/interpreter/session/package.scala +++ b/src/compiler/scala/tools/nsc/interpreter/session/package.scala @@ -5,6 +5,7 @@ package scala.tools.nsc package interpreter +import language.implicitConversions /** Files having to do with the state of a repl session: * lines of text entered, types and terms defined, etc. diff --git a/src/compiler/scala/tools/nsc/io/File.scala b/src/compiler/scala/tools/nsc/io/File.scala index cc512493d9..06cb20e4ac 100644 --- a/src/compiler/scala/tools/nsc/io/File.scala +++ b/src/compiler/scala/tools/nsc/io/File.scala @@ -15,6 +15,7 @@ import java.io.{ BufferedInputStream, BufferedOutputStream, IOException, PrintStream, PrintWriter, Closeable => JCloseable } import java.nio.channels.{ Channel, FileChannel } import scala.io.Codec +import language.{reflectiveCalls, implicitConversions} object File { def pathSeparator = java.io.File.pathSeparator diff --git a/src/compiler/scala/tools/nsc/io/Jar.scala b/src/compiler/scala/tools/nsc/io/Jar.scala index bbed5a9e20..b322df986c 100644 --- a/src/compiler/scala/tools/nsc/io/Jar.scala +++ b/src/compiler/scala/tools/nsc/io/Jar.scala @@ -11,6 +11,7 @@ import java.util.jar._ import collection.JavaConverters._ import Attributes.Name import util.ClassPath +import language.implicitConversions // Attributes.Name instances: // diff --git a/src/compiler/scala/tools/nsc/io/Path.scala b/src/compiler/scala/tools/nsc/io/Path.scala index a1b8e5e4d5..b8cf15bfcf 100644 --- a/src/compiler/scala/tools/nsc/io/Path.scala +++ b/src/compiler/scala/tools/nsc/io/Path.scala @@ -11,6 +11,7 @@ import java.io.{ BufferedInputStream, BufferedOutputStream, RandomAccessFile } import java.net.{ URI, URL } import scala.util.Random.alphanumeric +import language.implicitConversions /** An abstraction for filesystem paths. The differences between * Path, File, and Directory are primarily to communicate intent. diff --git a/src/compiler/scala/tools/nsc/io/Pickler.scala b/src/compiler/scala/tools/nsc/io/Pickler.scala index 80b6e086da..86c7ca7b9a 100644 --- a/src/compiler/scala/tools/nsc/io/Pickler.scala +++ b/src/compiler/scala/tools/nsc/io/Pickler.scala @@ -3,6 +3,7 @@ package scala.tools.nsc.io import annotation.unchecked import Lexer._ import java.io.Writer +import language.implicitConversions /** An abstract class for writing and reading Scala objects to and * from a legible representation. The presesentation follows the following grammar: @@ -168,14 +169,11 @@ object Pickler { case class ~[+S, +T](fst: S, snd: T) /** A wrapper class to be able to use `~` s an infix method */ - class TildeDecorator[S](x: S) { + implicit class TildeDecorator[S](x: S) { /** Infix method that forms a `~`-pair. */ def ~ [T](y: T): S ~ T = new ~ (x, y) } - /** An implicit wrapper that adds `~` as a method to any value. */ - implicit def tildeDecorator[S](x: S): TildeDecorator[S] = new TildeDecorator(x) - /** A converter from binary functions to functions over `~`-pairs */ implicit def fromTilde[T1, T2, R](f: (T1, T2) => R): T1 ~ T2 => R = { case x1 ~ x2 => f(x1, x2) } diff --git a/src/compiler/scala/tools/nsc/io/package.scala b/src/compiler/scala/tools/nsc/io/package.scala index 88679e6dce..52e6de0bed 100644 --- a/src/compiler/scala/tools/nsc/io/package.scala +++ b/src/compiler/scala/tools/nsc/io/package.scala @@ -8,8 +8,11 @@ package scala.tools.nsc import java.util.concurrent.{ Future, Callable } import java.util.{ Timer, TimerTask } import java.util.jar.{ Attributes } +import language.implicitConversions package object io { + implicit def postfixOps = language.postfixOps // make all postfix ops in this package compile without warning + type JManifest = java.util.jar.Manifest type JFile = java.io.File @@ -41,4 +44,4 @@ package object io { alarm.schedule(tt, seconds * 1000) alarm } -}
\ No newline at end of file +} diff --git a/src/compiler/scala/tools/nsc/javac/JavaParsers.scala b/src/compiler/scala/tools/nsc/javac/JavaParsers.scala index 06b06c50a6..ca3f3ff635 100644 --- a/src/compiler/scala/tools/nsc/javac/JavaParsers.scala +++ b/src/compiler/scala/tools/nsc/javac/JavaParsers.scala @@ -12,6 +12,7 @@ import scala.tools.nsc.util.OffsetPosition import scala.collection.mutable.ListBuffer import symtab.Flags import JavaTokens._ +import language.implicitConversions trait JavaParsers extends ast.parser.ParsersCommon with JavaScanners { val global : Global diff --git a/src/compiler/scala/tools/nsc/javac/JavaScanners.scala b/src/compiler/scala/tools/nsc/javac/JavaScanners.scala index 45b63b0ca0..d47756e757 100644 --- a/src/compiler/scala/tools/nsc/javac/JavaScanners.scala +++ b/src/compiler/scala/tools/nsc/javac/JavaScanners.scala @@ -10,6 +10,7 @@ import scala.tools.nsc.util._ import scala.reflect.internal.Chars._ import JavaTokens._ import scala.annotation.switch +import language.implicitConversions // Todo merge these better with Scanners trait JavaScanners extends ast.parser.ScannersCommon { diff --git a/src/compiler/scala/tools/nsc/matching/MatchSupport.scala b/src/compiler/scala/tools/nsc/matching/MatchSupport.scala index 371f4bc4d8..249f754e8f 100644 --- a/src/compiler/scala/tools/nsc/matching/MatchSupport.scala +++ b/src/compiler/scala/tools/nsc/matching/MatchSupport.scala @@ -10,6 +10,7 @@ import transform.ExplicitOuter import ast.{ TreePrinters, Trees } import java.io.{ StringWriter, PrintWriter } import annotation.elidable +import language.postfixOps /** Ancillary bits of ParallelMatching which are better off * out of the way. @@ -29,11 +30,10 @@ trait MatchSupport extends ast.TreeDSL { self: ParallelMatching => object Types { import definitions._ - implicit def enrichType(x: Type): RichType = new RichType(x) val subrangeTypes = Set(ByteClass, ShortClass, CharClass, IntClass) - class RichType(undecodedTpe: Type) { + implicit class RichType(undecodedTpe: Type) { def tpe = decodedEqualsType(undecodedTpe) def isAnyRef = tpe <:< AnyRefClass.tpe diff --git a/src/compiler/scala/tools/nsc/matching/Matrix.scala b/src/compiler/scala/tools/nsc/matching/Matrix.scala index e1ff88557e..b29fac225a 100644 --- a/src/compiler/scala/tools/nsc/matching/Matrix.scala +++ b/src/compiler/scala/tools/nsc/matching/Matrix.scala @@ -9,6 +9,7 @@ package matching import transform.ExplicitOuter import symtab.Flags import scala.collection.mutable +import language.implicitConversions trait Matrix extends MatrixAdditions { self: ExplicitOuter with ParallelMatching => @@ -255,4 +256,4 @@ trait Matrix extends MatrixAdditions { recordSyntheticSym(owner.newVariable(n, pos, flagsLong) setInfo tpe) } } -}
\ No newline at end of file +} diff --git a/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala b/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala index 43aad9f591..7346d9c59f 100644 --- a/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala +++ b/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala @@ -14,6 +14,7 @@ import transform.ExplicitOuter import symtab.Flags import mutable.ListBuffer import annotation.elidable +import language.postfixOps trait ParallelMatching extends ast.TreeDSL with MatchSupport diff --git a/src/compiler/scala/tools/nsc/matching/PatternBindings.scala b/src/compiler/scala/tools/nsc/matching/PatternBindings.scala index 56297f0195..b2a721c586 100644 --- a/src/compiler/scala/tools/nsc/matching/PatternBindings.scala +++ b/src/compiler/scala/tools/nsc/matching/PatternBindings.scala @@ -8,6 +8,7 @@ package matching import transform.ExplicitOuter import PartialFunction._ +import language.postfixOps trait PatternBindings extends ast.TreeDSL { @@ -133,4 +134,4 @@ trait PatternBindings extends ast.TreeDSL } val NoBinding: Bindings = new Bindings(Nil) -}
\ No newline at end of file +} diff --git a/src/compiler/scala/tools/nsc/plugins/Plugin.scala b/src/compiler/scala/tools/nsc/plugins/Plugin.scala index 9254ec8628..48c4a9b5b3 100644 --- a/src/compiler/scala/tools/nsc/plugins/Plugin.scala +++ b/src/compiler/scala/tools/nsc/plugins/Plugin.scala @@ -138,7 +138,7 @@ object Plugin { } yield entry)).distinct val loader = loaderFor(alljars) - alljars map (loadFrom(_, loader)) flatten + (alljars map (loadFrom(_, loader))).flatten } /** Instantiate a plugin class, given the class and diff --git a/src/compiler/scala/tools/nsc/plugins/Plugins.scala b/src/compiler/scala/tools/nsc/plugins/Plugins.scala index da913a1601..ba042b7b78 100644 --- a/src/compiler/scala/tools/nsc/plugins/Plugins.scala +++ b/src/compiler/scala/tools/nsc/plugins/Plugins.scala @@ -70,7 +70,7 @@ trait Plugins { } } - val plugs = pick(roughPluginsList, Set(), phasesSet map (_.phaseName) toSet) + val plugs = pick(roughPluginsList, Set(), (phasesSet map (_.phaseName)).toSet) /** Verify requirements are present. */ for (req <- settings.require.value ; if !(plugs exists (_.name == req))) @@ -112,5 +112,5 @@ trait Plugins { def pluginOptionsHelp: String = (for (plug <- roughPluginsList ; help <- plug.optionsHelp) yield { "\nOptions for plugin '%s':\n%s\n".format(plug.name, help) - }) mkString + }).mkString } diff --git a/src/compiler/scala/tools/nsc/settings/AbsSettings.scala b/src/compiler/scala/tools/nsc/settings/AbsSettings.scala index 9cea935a63..c1dad2da82 100644 --- a/src/compiler/scala/tools/nsc/settings/AbsSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/AbsSettings.scala @@ -35,7 +35,7 @@ trait AbsSettings extends scala.reflect.internal.settings.AbsSettings { case s: AbsSettings => this.userSetSettings == s.userSetSettings case _ => false } - override def toString() = "Settings {\n%s}\n" format (userSetSettings map (" " + _ + "\n") mkString) + override def toString() = "Settings {\n%s}\n" format (userSetSettings map (" " + _ + "\n")).mkString def toConciseString = userSetSettings.mkString("(", " ", ")") def checkDependencies = diff --git a/src/compiler/scala/tools/nsc/settings/AestheticSettings.scala b/src/compiler/scala/tools/nsc/settings/AestheticSettings.scala index c010c6a3ea..63775ff1c5 100644 --- a/src/compiler/scala/tools/nsc/settings/AestheticSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/AestheticSettings.scala @@ -23,6 +23,7 @@ trait AestheticSettings { def deprecation = settings.deprecation.value def experimental = settings.Xexperimental.value def fatalWarnings = settings.fatalWarnings.value + def feature = settings.feature.value def future = settings.future.value def logClasspath = settings.Ylogcp.value def printStats = settings.Ystatistics.value @@ -30,7 +31,7 @@ trait AestheticSettings { def target = settings.target.value def unchecked = settings.unchecked.value def verbose = settings.verbose.value - def virtPatmat = settings.YvirtPatmat.value + def virtPatmat = !settings.XoldPatmat.value /** Derived values */ def jvm = target startsWith "jvm" diff --git a/src/compiler/scala/tools/nsc/settings/MutableSettings.scala b/src/compiler/scala/tools/nsc/settings/MutableSettings.scala index ea12300785..a52e3b8bbe 100644 --- a/src/compiler/scala/tools/nsc/settings/MutableSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/MutableSettings.scala @@ -136,7 +136,7 @@ class MutableSettings(val errorFn: String => Unit) val (p, args) = StringOps.splitWhere(s, _ == ':', true) getOrElse (return None) // any non-Nil return value means failure and we return s unmodified - tryToSetIfExists(p, args split "," toList, (s: Setting) => s.tryToSetColon _) + tryToSetIfExists(p, (args split ",").toList, (s: Setting) => s.tryToSetColon _) } // if arg is of form -Xfoo or -Xfoo bar (name = "-Xfoo") diff --git a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala index e9a7e3dab4..d4c2ffa832 100644 --- a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala @@ -11,6 +11,7 @@ package settings import annotation.elidable import scala.tools.util.PathResolver.Defaults import scala.collection.mutable +import language.{implicitConversions, existentials} trait ScalaSettings extends AbsScalaSettings with StandardScalaSettings @@ -62,6 +63,7 @@ trait ScalaSettings extends AbsScalaSettings val classpath = PathSetting ("-classpath", "Specify where to find user class files.", defaultClasspath) withAbbreviation "-cp" val d = OutputSetting (outputDirs, ".") val nospecialization = BooleanSetting ("-no-specialization", "Ignore @specialize annotations.") + val language = MultiStringSetting("-language", "feature", "Enable one or more language features.") /** * -X "Advanced" settings @@ -106,6 +108,8 @@ trait ScalaSettings extends AbsScalaSettings val showPhases = BooleanSetting ("-Xshow-phases", "Print a synopsis of compiler phases.") val sourceReader = StringSetting ("-Xsource-reader", "classname", "Specify a custom method for reading source files.", "") + val XoldPatmat = BooleanSetting ("-Xoldpatmat", "Use the pre-2.10 pattern matcher. Otherwise, the 'virtualizing' pattern matcher is used in 2.10.") + /** Compatibility stubs for options whose value name did * not previously match the option name. */ @@ -173,7 +177,6 @@ trait ScalaSettings extends AbsScalaSettings val YmethodInfer = BooleanSetting ("-Yinfer-argument-types", "Infer types for arguments of overriden methods.") val etaExpandKeepsStar = BooleanSetting ("-Yeta-expand-keeps-star", "Eta-expand varargs methods to T* rather than Seq[T]. This is a temporary option to ease transition.") val noSelfCheck = BooleanSetting ("-Yno-self-type-checks", "Suppress check for self-type conformance among inherited members.") - val YvirtPatmat = BooleanSetting ("-Yvirtpatmat", "Translate pattern matches into flatMap/orElse calls. See scala.MatchingStrategy.") val YvirtClasses = false // too embryonic to even expose as a -Y //BooleanSetting ("-Yvirtual-classes", "Support virtual classes") val exposeEmptyPackage = BooleanSetting("-Yexpose-empty-package", "Internal only: expose the empty package.").internalOnly() @@ -203,7 +206,7 @@ trait ScalaSettings extends AbsScalaSettings val Xexperimental = BooleanSetting("-Xexperimental", "Enable experimental extensions.") enabling experimentalSettings // Feature extensions - val Xmacros = BooleanSetting("-Xmacros", "Enable macros.") + val Xmacros = BooleanSetting("-Xmacros", "Enable macros.") // [Martin] Can be retired now. val XmacroSettings = MultiStringSetting("-Xmacro-settings", "option", "Custom settings for macros.") val XmacroPrimaryClasspath = PathSetting("-Xmacro-primary-classpath", "Classpath to load macros implementations from, defaults to compilation classpath (aka \"library classpath\".", "") val XmacroFallbackClasspath = PathSetting("-Xmacro-fallback-classpath", "Classpath to load macros implementations from if they cannot be loaded from library classpath.", "") diff --git a/src/compiler/scala/tools/nsc/settings/StandardScalaSettings.scala b/src/compiler/scala/tools/nsc/settings/StandardScalaSettings.scala index c5b477c7bd..a69b88a5df 100644 --- a/src/compiler/scala/tools/nsc/settings/StandardScalaSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/StandardScalaSettings.scala @@ -32,6 +32,7 @@ trait StandardScalaSettings { val deprecation = BooleanSetting ("-deprecation", "Emit warning and location for usages of deprecated APIs.") val encoding = StringSetting ("-encoding", "encoding", "Specify character encoding used by source files.", Properties.sourceEncoding) val explaintypes = BooleanSetting ("-explaintypes", "Explain type errors in more detail.") + val feature = BooleanSetting ("-feature", "Emit warning and location for usages of features that should be imported explicitly.") val g = ChoiceSetting ("-g", "level", "Set level of generated debugging info.", List("none", "source", "line", "vars", "notailcalls"), "vars") val help = BooleanSetting ("-help", "Print a synopsis of standard options") val make = ChoiceSetting ("-make", "policy", "Recompilation detection policy", List("all", "changed", "immediate", "transitive", "transitivenocp"), "all") diff --git a/src/compiler/scala/tools/nsc/symtab/SymbolTrackers.scala b/src/compiler/scala/tools/nsc/symtab/SymbolTrackers.scala index e62070a239..3cf5cc2f54 100644 --- a/src/compiler/scala/tools/nsc/symtab/SymbolTrackers.scala +++ b/src/compiler/scala/tools/nsc/symtab/SymbolTrackers.scala @@ -7,6 +7,8 @@ package scala.tools.nsc package symtab import scala.collection.{ mutable, immutable } +import language.implicitConversions +import language.postfixOps /** Printing the symbol graph (for those symbols attached to an AST node) * after each phase. diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala index edbe6df472..52648380ec 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala @@ -149,7 +149,7 @@ abstract class Pickler extends SubComponent { putChildren(sym, children.toList sortBy (_.sealedSortName)) } - for (annot <- sym.annotations filter (ann => ann.isStatic && !ann.isErroneous) reverse) + for (annot <- (sym.annotations filter (ann => ann.isStatic && !ann.isErroneous)).reverse) putAnnotation(sym, annot) } else if (sym != NoSymbol) { diff --git a/src/compiler/scala/tools/nsc/symtab/clr/TypeParser.scala b/src/compiler/scala/tools/nsc/symtab/clr/TypeParser.scala index 4b847fa94a..028d6f2484 100644 --- a/src/compiler/scala/tools/nsc/symtab/clr/TypeParser.scala +++ b/src/compiler/scala/tools/nsc/symtab/clr/TypeParser.scala @@ -12,6 +12,7 @@ import ch.epfl.lamp.compiler.msil.{Type => MSILType, Attribute => MSILAttribute, import scala.collection.{ mutable, immutable } import scala.reflect.internal.pickling.UnPickler import ch.epfl.lamp.compiler.msil.Type.TMVarUsage +import language.implicitConversions /** * @author Nikolay Mihaylov diff --git a/src/compiler/scala/tools/nsc/transform/CleanUp.scala b/src/compiler/scala/tools/nsc/transform/CleanUp.scala index eea87c8ba6..fd15d92e37 100644 --- a/src/compiler/scala/tools/nsc/transform/CleanUp.scala +++ b/src/compiler/scala/tools/nsc/transform/CleanUp.scala @@ -9,6 +9,7 @@ package transform import symtab._ import Flags._ import scala.collection._ +import language.postfixOps abstract class CleanUp extends Transform with ast.TreeDSL { import global._ diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala index e2ce3b62b4..5e61359a25 100644 --- a/src/compiler/scala/tools/nsc/transform/Erasure.scala +++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala @@ -210,7 +210,7 @@ abstract class Erasure extends AddInterfaces } else parents ) - ps map boxedSig mkString + (ps map boxedSig).mkString } def boxedSig(tp: Type) = jsig(tp, primitiveOK = false) def boundsSig(bounds: List[Type]) = traceSig("boundsSig", bounds) { @@ -480,11 +480,10 @@ abstract class Erasure extends AddInterfaces // TODO: should we do this for user-defined unapplies as well? // does the first argument list have exactly one argument -- for user-defined unapplies we can't be sure def maybeWrap(bridgingCall: Tree): Tree = { - val canReturnNone = afterErasure( - member.isSynthetic - && (member.name == nme.unapply || member.name == nme.unapplySeq) - && !(member.tpe <:< other.tpe) // no static guarantees (TODO: is the subtype test ever true?) - ) + val canReturnNone = ( // can't statically know which member is going to be selected, so don't let this depend on member.isSynthetic + (member.name == nme.unapply || member.name == nme.unapplySeq) + && !afterErasure((member.tpe <:< other.tpe))) // no static guarantees (TODO: is the subtype test ever true?) + if (canReturnNone) { import CODE._ val typeTest = gen.mkIsInstanceOf(REF(bridge.firstParam), member.tpe.params.head.tpe) diff --git a/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala b/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala index 16c7c3c3ff..8daad8a2ac 100644 --- a/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala +++ b/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala @@ -357,7 +357,7 @@ abstract class ExplicitOuter extends InfoTransform */ def mixinOuterAccessorDef(mixinClass: Symbol): Tree = { val outerAcc = outerAccessor(mixinClass) overridingSymbol currentClass - def mixinPrefix = currentClass.thisType baseType mixinClass prefix; + def mixinPrefix = (currentClass.thisType baseType mixinClass).prefix assert(outerAcc != NoSymbol, "No outer accessor for inner mixin " + mixinClass + " in " + currentClass) // I added the mixinPrefix.typeArgs.nonEmpty condition to address the // crash in SI-4970. I feel quite sure this can be improved. diff --git a/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala b/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala index 3515c1d521..007457ef7b 100644 --- a/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala +++ b/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala @@ -50,7 +50,7 @@ abstract class ExtensionMethods extends Transform with TypingTransformers { val index = alts indexOf imeth assert(index >= 0, alts+" does not contain "+imeth) def altName(index: Int) = newTermName("extension"+index+"$"+imeth.name) - altName(index) #:: ((0 until alts.length).toStream filter (index !=) map altName) + altName(index) #:: ((0 until alts.length).toStream filter (index != _) map altName) case tpe => assert(tpe != NoType, imeth.name+" not found in "+imeth.owner+"'s decls: "+imeth.owner.info.decls) Stream(newTermName("extension$"+imeth.name)) diff --git a/src/compiler/scala/tools/nsc/transform/Mixin.scala b/src/compiler/scala/tools/nsc/transform/Mixin.scala index 0e4975c04c..19f32a5411 100644 --- a/src/compiler/scala/tools/nsc/transform/Mixin.scala +++ b/src/compiler/scala/tools/nsc/transform/Mixin.scala @@ -123,7 +123,7 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL { */ private def rebindSuper(base: Symbol, member: Symbol, mixinClass: Symbol): Symbol = afterPickler { - var bcs = base.info.baseClasses.dropWhile(mixinClass !=).tail + var bcs = base.info.baseClasses.dropWhile(mixinClass != _).tail var sym: Symbol = NoSymbol debuglog("starting rebindsuper " + base + " " + member + ":" + member.tpe + " " + mixinClass + " " + base.info.baseClasses + "/" + bcs) @@ -778,7 +778,7 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL { val fields0 = usedBits(cl) if (requiredBitmaps(fields0) < bitmapNum) { - val fields1 = cl.info.decls filter isNonLocalFieldWithBitmap size; + val fields1 = (cl.info.decls filter isNonLocalFieldWithBitmap).size return { if (requiredBitmaps(fields0 + fields1) >= bitmapNum) Some(bitmapFor(cl, offset, valSym, false)) diff --git a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala index 8d08888a1f..ff671088ac 100644 --- a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala +++ b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala @@ -8,6 +8,7 @@ package transform import scala.tools.nsc.symtab.Flags import scala.collection.{ mutable, immutable } +import language.postfixOps /** Specialize code on types. * diff --git a/src/compiler/scala/tools/nsc/transform/UnCurry.scala b/src/compiler/scala/tools/nsc/transform/UnCurry.scala index 11f06a0541..57cd51ad35 100644 --- a/src/compiler/scala/tools/nsc/transform/UnCurry.scala +++ b/src/compiler/scala/tools/nsc/transform/UnCurry.scala @@ -8,6 +8,7 @@ package transform import symtab.Flags._ import scala.collection.{ mutable, immutable } +import language.postfixOps /*<export> */ /** - uncurry all symbol and tree types (@see UnCurryPhase) -- this includes normalizing all proper types. @@ -240,7 +241,6 @@ abstract class UnCurry extends InfoTransform def owner = fun.symbol.owner def targs = fun.tpe.typeArgs def isPartial = fun.tpe.typeSymbol == PartialFunctionClass - assert(!(opt.virtPatmat && isPartial)) // empty-selector matches have already been translated into instantiations of anonymous (partial) functions def parents = if (isFunctionType(fun.tpe)) List(abstractFunctionForFunctionType(fun.tpe), SerializableClass.tpe) @@ -281,7 +281,44 @@ abstract class UnCurry extends InfoTransform val substParam = new TreeSymSubstituter(fun.vparams map (_.symbol), List(x)) val body = localTyper.typedPos(fun.pos) { import CODE._ - gen.mkUncheckedMatch(gen.withDefaultCase(substParam(fun.body), scrut => REF(default) APPLY (REF(x)))) + def defaultAction(scrut: Tree) = REF(default) APPLY (REF(x)) + + object withDefaultTransformer extends gen.MatchMatcher { + override def caseMatch(orig: Tree, selector: Tree, cases: List[CaseDef], wrap: Tree => Tree): Tree = { + val casesNoSynthCatchAll = dropSyntheticCatchAll(cases) + if (casesNoSynthCatchAll exists treeInfo.isDefaultCase) orig + else { + val defaultCase = CaseDef(Ident(nme.WILDCARD), EmptyTree, defaultAction(selector.duplicate)) + wrap(Match(/*gen.mkUnchecked*/(selector), casesNoSynthCatchAll :+ defaultCase)) + } + } + override def caseVirtualizedMatch(orig: Tree, _match: Tree, targs: List[Tree], scrut: Tree, matcher: Tree): Tree = { import CODE._ + ((matcher APPLY (scrut)) DOT nme.getOrElse) APPLY (defaultAction(scrut.duplicate)) // TODO: pass targs + } + override def caseVirtualizedMatchOpt(orig: Tree, prologue: List[Tree], cases: List[Tree], matchEndDef: Tree, wrap: Tree => Tree): Tree = { import CODE._ + val scrutRef = REF(prologue.head.symbol) // scrut valdef is always emitted (except for nested matchers that handle alternatives) + + val casesNewSynthCatchAll = cases.init :+ (deriveLabelDef(cases.last){ + case Apply(matchEnd, List(Throw(Apply(Select(New(exTpt), nme.CONSTRUCTOR), _)))) if exTpt.tpe.typeSymbol eq MatchErrorClass => + assert(matchEnd.symbol == matchEndDef.symbol, "matchEnd discrepancy "+(matchEnd, matchEndDef)) + matchEnd APPLY (defaultAction(scrutRef)) + case x => x + } setSymbol cases.last.symbol setType null) + + val LabelDef(_, List(matchRes), rhs) = matchEndDef + val matchEnd = matchEndDef.symbol + matchRes setType B1.tpe + rhs setType B1.tpe + matchEndDef setType B1.tpe + matchRes.symbol setInfo B1.tpe + matchEnd setInfo MethodType(List(matchRes.symbol), B1.tpe) + cases foreach (c => c.symbol setInfo MethodType(List(), B1.tpe)) + + wrap(Block(prologue ++ casesNewSynthCatchAll, matchEndDef)) + } + } + + withDefaultTransformer(substParam(fun.body)) } body.changeOwner(fun.symbol -> methSym) @@ -293,30 +330,115 @@ abstract class UnCurry extends InfoTransform methDef } - // duplicate before applyOrElseMethodDef is run so we start with the same symbols as applyOrElseMethodDef + // duplicate before applyOrElseMethodDef is run so that it does not mess up our trees and label symbols (we have a fresh set) // otherwise `TreeSymSubstituter(fun.vparams map (_.symbol), params)` won't work as the subst has been run already - val bodyForIDA = fun.body.duplicate + val bodyForIDA = { + val duped = fun.body.duplicate + val oldParams = new mutable.ListBuffer[Symbol]() + val newParams = new mutable.ListBuffer[Symbol]() + + val oldSyms0 = + duped filter { + case l@LabelDef(_, params, _) => + params foreach {p => + val oldSym = p.symbol + p.symbol = oldSym.cloneSymbol + oldParams += oldSym + newParams += p.symbol + } + true + case _ => false + } map (_.symbol) + val oldSyms = oldParams.toList ++ oldSyms0 + val newSyms = newParams.toList ++ (oldSyms0 map (_.cloneSymbol)) + // println("duping "+ oldSyms +" --> "+ (newSyms map (_.ownerChain))) + + val substLabels = new TreeSymSubstituter(oldSyms, newSyms) + + substLabels(duped) + } + def isDefinedAtMethodDef = { val methSym = anonClass.newMethod(nme.isDefinedAt, fun.pos, FINAL) val params = methSym newSyntheticValueParams formals methSym setInfoAndEnter MethodType(params, BooleanClass.tpe) val substParam = new TreeSymSubstituter(fun.vparams map (_.symbol), params) - def doSubst(x: Tree) = substParam(resetLocalAttrs(x)) // see pos/t1761 for why `resetLocalAttrs` + def doSubst(x: Tree) = substParam(resetLocalAttrsKeepLabels(x)) // see pos/t1761 for why `resetLocalAttrs`, but must keep label symbols around + object isDefinedAtTransformer extends gen.MatchMatcher { // TODO: optimize duplication, but make sure ValDef's introduced by wrap are treated correctly override def caseMatch(orig: Tree, selector: Tree, cases: List[CaseDef], wrap: Tree => Tree): Tree = { import CODE._ - gen.mkUncheckedMatch( - if (cases exists treeInfo.isDefaultCase) TRUE_typed + val casesNoSynthCatchAll = dropSyntheticCatchAll(cases) + if (casesNoSynthCatchAll exists treeInfo.isDefaultCase) TRUE_typed else doSubst(wrap( - Match(selector, - (cases map (c => deriveCaseDef(c)(x => TRUE_typed))) :+ ( + Match(/*gen.mkUnchecked*/(selector), + (casesNoSynthCatchAll map (c => deriveCaseDef(c)(x => TRUE_typed))) :+ ( DEFAULT ==> FALSE_typed) ))) - ) + } + override def caseVirtualizedMatch(orig: Tree, _match: Tree, targs: List[Tree], scrut: Tree, matcher: Tree): Tree = { + object noOne extends Transformer { + override val treeCopy = newStrictTreeCopier // must duplicate everything + val one = _match.tpe member newTermName("one") + override def transform(tree: Tree): Tree = tree match { + case Apply(fun, List(a)) if fun.symbol == one => + // blow one's argument away since all we want to know is whether the match succeeds or not + // (the alternative, making `one` CBN, would entail moving away from Option) + Apply(fun.duplicate, List(gen.mkZeroContravariantAfterTyper(a.tpe))) + case _ => + super.transform(tree) + } + } + doSubst(Apply(Apply(TypeApply(Select(_match.duplicate, _match.tpe.member(newTermName("isSuccess"))), targs map (_.duplicate)), List(scrut.duplicate)), List(noOne.transform(matcher)))) + } + + override def caseVirtualizedMatchOpt(orig: Tree, prologue: List[Tree], cases: List[Tree], matchEndDef: Tree, wrap: Tree => Tree) = { + val matchEnd = matchEndDef.symbol + val LabelDef(_, List(matchRes), rhs) = matchEndDef + matchRes setType BooleanClass.tpe + rhs setType BooleanClass.tpe + matchEndDef setType BooleanClass.tpe + matchRes.symbol setInfo BooleanClass.tpe + matchEnd setInfo MethodType(List(matchRes.symbol), BooleanClass.tpe) + cases foreach (c => c.symbol setInfo MethodType(List(), BooleanClass.tpe)) + // println("matchEnd: "+ matchEnd) + + // when the type of the selector contains a skolem owned by the applyOrElseMethod, should reskolemize everything, + // for now, just cast the RHS (since we're just trying to keep the typer happy, the cast is meaningless) + // ARGH -- this is why I would prefer the typedMatchAnonFun approach (but alas, CPS blocks that) + val newPrologue = prologue match { + case List(vd@ValDef(mods, name, tpt, rhs)) => List(treeCopy.ValDef(vd, mods, name, tpt, gen.mkAsInstanceOf(rhs, tpt.tpe, true, false))) + case _ => prologue + } + object casesReturnTrue extends Transformer { + // override val treeCopy = newStrictTreeCopier // will duplicate below + override def transform(tree: Tree): Tree = tree match { + // don't compute the result of the match, return true instead + case Apply(fun, List(res)) if fun.symbol eq matchEnd => + // println("matchend call "+ fun.symbol) + Apply(fun, List(TRUE_typed)) setType BooleanClass.tpe + case _ => super.transform(tree) + } + } + val newCatchAll = cases.last match { + case LabelDef(n, ps, Apply(matchEnd1, List(Throw(Apply(Select(New(exTpt), nme.CONSTRUCTOR), _))))) if exTpt.tpe.typeSymbol eq MatchErrorClass => + assert(matchEnd1.symbol == matchEnd, "matchEnd discrepancy "+(matchEnd, matchEndDef)) + List(treeCopy.LabelDef(cases.last, n, ps, matchEnd APPLY (FALSE_typed)) setSymbol cases.last.symbol) + case x => Nil + } + val casesWithoutCatchAll = if(newCatchAll.isEmpty) cases else cases.init + doSubst(wrap(Block(newPrologue ++ casesReturnTrue.transformTrees(casesWithoutCatchAll) ++ newCatchAll, matchEndDef))) + + // val duped = idaBlock //.duplicate // TODO: duplication of labeldefs is BROKEN + // duped foreach { + // case l@LabelDef(name, params, rhs) if gen.hasSynthCaseSymbol(l) => println("newInfo"+ l.symbol.info) + // case _ => + // } } } + val body = isDefinedAtTransformer(bodyForIDA) body.changeOwner(fun.symbol -> methSym) @@ -327,11 +449,14 @@ abstract class UnCurry extends InfoTransform if (isPartial) List(applyOrElseMethodDef, isDefinedAtMethodDef) else List(applyMethodDef) - localTyper.typedPos(fun.pos) { + // println("MEMBERS "+ members) + val res = localTyper.typedPos(fun.pos) { Block( List(ClassDef(anonClass, NoMods, List(List()), List(List()), members, fun.pos)), Typed(New(anonClass.tpe), TypeTree(fun.tpe))) } + // println("MEMBERS TYPED "+ members) + res } def transformArgs(pos: Position, fun: Symbol, args: List[Tree], formals: List[Type]) = { diff --git a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala index edc69be827..e9c3bef737 100644 --- a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala +++ b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala @@ -483,7 +483,7 @@ trait ContextErrors { val keep = missing take 3 map (_.name) ".\nUnspecified value parameter%s %s".format( if (missing.tail.isEmpty) "" else "s", - if (missing drop 3 nonEmpty) (keep :+ "...").mkString(", ") + if ((missing drop 3).nonEmpty) (keep :+ "...").mkString(", ") else keep.mkString("", ", ", ".") ) } @@ -504,6 +504,9 @@ trait ContextErrors { def ApplyWithoutArgsError(tree: Tree, fun: Tree) = NormalTypeError(tree, fun.tpe+" does not take parameters") + def DynamicVarArgUnsupported(tree: Tree, name: String) = + issueNormalTypeError(tree, name+ " does not support passing a vararg parameter") + //checkClassType def TypeNotAStablePrefixError(tpt: Tree, pre: Type) = { issueNormalTypeError(tpt, "type "+pre+" is not a stable prefix") @@ -644,7 +647,7 @@ trait ContextErrors { private def applyErrorMsg(tree: Tree, msg: String, argtpes: List[Type], pt: Type) = { def asParams(xs: List[Any]) = xs.mkString("(", ", ", ")") - def resType = if (pt isWildcard) "" else " with expected result type " + pt + def resType = if (pt.isWildcard) "" else " with expected result type " + pt def allTypes = (alternatives(tree) flatMap (_.paramTypes)) ++ argtpes :+ pt def locals = alternatives(tree) flatMap (_.typeParams) diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala index fe1c90fe67..e2d4efab83 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala @@ -67,6 +67,7 @@ trait Contexts { self: Analyzer => val c = sc.make(unit, tree, sc.owner, sc.scope, sc.imports) if (erasedTypes) c.setThrowErrors() else c.setReportErrors() c.implicitsEnabled = !erasedTypes + c.enrichmentEnabled = c.implicitsEnabled c } @@ -106,7 +107,7 @@ trait Contexts { self: Analyzer => var depth: Int = 0 var imports: List[ImportInfo] = List() // currently visible imports var openImplicits: List[(Type,Tree)] = List() // types for which implicit arguments - // are currently searched + // are currently searched // for a named application block (Tree) the corresponding NamedApplyInfo var namedApplyBlockInfo: Option[(Tree, NamedApplyInfo)] = None var prefix: Type = NoPrefix @@ -120,6 +121,7 @@ trait Contexts { self: Analyzer => var diagnostic: List[String] = Nil // these messages are printed when issuing an error var implicitsEnabled = false var macrosEnabled = true + var enrichmentEnabled = false // to selectively allow enrichment in patterns, where other kinds of implicit conversions are not allowed var checking = false var retyping = false @@ -192,8 +194,25 @@ trait Contexts { self: Analyzer => def withImplicitsDisabled[T](op: => T): T = { val saved = implicitsEnabled implicitsEnabled = false + val savedP = enrichmentEnabled + enrichmentEnabled = false try op - finally implicitsEnabled = saved + finally { + implicitsEnabled = saved + enrichmentEnabled = savedP + } + } + + def withImplicitsDisabledAllowEnrichment[T](op: => T): T = { + val saved = implicitsEnabled + implicitsEnabled = false + val savedP = enrichmentEnabled + enrichmentEnabled = true + try op + finally { + implicitsEnabled = saved + enrichmentEnabled = savedP + } } def withMacrosEnabled[T](op: => T): T = { @@ -246,6 +265,7 @@ trait Contexts { self: Analyzer => c.typingIndentLevel = typingIndentLevel c.implicitsEnabled = this.implicitsEnabled c.macrosEnabled = this.macrosEnabled + c.enrichmentEnabled = this.enrichmentEnabled c.checking = this.checking c.retyping = this.retyping c.openImplicits = this.openImplicits @@ -298,6 +318,7 @@ trait Contexts { self: Analyzer => def makeImplicit(reportAmbiguousErrors: Boolean) = { val c = makeSilent(reportAmbiguousErrors) c.implicitsEnabled = false + c.enrichmentEnabled = false c } diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala index eb8bef3b58..4fb9362ccc 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala @@ -166,7 +166,7 @@ trait Implicits { } def isCyclicOrErroneous = - try containsError(tpe) + try sym.hasFlag(LOCKED) || containsError(tpe) catch { case _: CyclicReference => true } var useCountArg: Int = 0 @@ -710,7 +710,7 @@ trait Implicits { def comesBefore(sym: Symbol, owner: Symbol) = { val ownerPos = owner.pos.pointOrElse(Int.MaxValue) sym.pos.pointOrElse(0) < ownerPos && ( - if (sym hasAccessorFlag) { + if (sym.hasAccessorFlag) { val symAcc = sym.accessed // #3373 symAcc.pos.pointOrElse(0) < ownerPos && !(owner.ownerChain exists (o => (o eq sym) || (o eq symAcc))) // probably faster to iterate only once, don't feel like duplicating hasTransOwner for this case @@ -830,7 +830,7 @@ trait Implicits { /** Returns all eligible ImplicitInfos and their SearchResults in a map. */ - def findAll() = eligible map (info => (info, typedImplicit(info, false))) toMap + def findAll() = (eligible map (info => (info, typedImplicit(info, false)))).toMap /** Returns the SearchResult of the best match. */ @@ -1251,7 +1251,7 @@ trait Implicits { // where `X` refers to a type parameter of `sym` def check(sym: Symbol): Option[String] = sym.getAnnotation(ImplicitNotFoundClass).flatMap(_.stringArg(0) match { - case Some(m) => new Message(sym, m) validate + case Some(m) => new Message(sym, m).validate case None => Some("Missing argument `msg` on implicitNotFound annotation.") }) @@ -1276,7 +1276,7 @@ trait Implicits { val decls = typeParamNames.toSet (refs &~ decls) match { - case s if s isEmpty => None + case s if s.isEmpty => None case unboundNames => val singular = unboundNames.size == 1 Some("The type parameter"+( if(singular) " " else "s " )+ unboundNames.mkString(", ") + diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala index d2fe106b14..fb0616c890 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala @@ -446,7 +446,7 @@ trait Infer { type Result = collection.mutable.LinkedHashMap[Symbol, Option[Type]] def unapply(m: Result): Some[(List[Symbol], List[Type])] = Some(toLists( - m collect {case (p, Some(a)) => (p, a)} unzip )) + (m collect {case (p, Some(a)) => (p, a)}).unzip )) object Undets { def unapply(m: Result): Some[(List[Symbol], List[Type], List[Symbol])] = Some(toLists{ @@ -766,7 +766,7 @@ trait Infer { isAsSpecific(res, ftpe2) case mt: MethodType if mt.isImplicit => isAsSpecific(ftpe1.resultType, ftpe2) - case MethodType(params, _) if params nonEmpty => + case MethodType(params, _) if params.nonEmpty => var argtpes = params map (_.tpe) if (isVarArgsList(params) && isVarArgsList(ftpe2.params)) argtpes = argtpes map (argtpe => @@ -776,7 +776,7 @@ trait Infer { isAsSpecific(PolyType(tparams, res), ftpe2) case PolyType(tparams, mt: MethodType) if mt.isImplicit => isAsSpecific(PolyType(tparams, mt.resultType), ftpe2) - case PolyType(_, MethodType(params, _)) if params nonEmpty => + case PolyType(_, MethodType(params, _)) if params.nonEmpty => isApplicable(List(), ftpe2, params map (_.tpe), WildcardType) // case NullaryMethodType(res) => // isAsSpecific(res, ftpe2) @@ -1189,6 +1189,50 @@ trait Infer { } } + /** Does `tp` contain any types that cannot be checked at run-time (i.e., after erasure, will isInstanceOf[erased(tp)] imply conceptualIsInstanceOf[tp]?) + * we should find a way to ask erasure: hey, is `tp` going to make it through you with all of its isInstanceOf resolving powers intact? + * TODO: at the very least, reduce duplication wrt checkCheckable + */ + def containsUnchecked(tp: Type): Boolean = { + def check(tp: Type, bound: List[Symbol]): Boolean = { + def isSurroundingTypeParam(sym: Symbol) = { + val e = context.scope.lookupEntry(sym.name) + ( (e ne null) + && (e.sym == sym ) + && !e.sym.isTypeParameterOrSkolem + && (e.owner == context.scope) + ) + } + def isLocalBinding(sym: Symbol) = ( + sym.isAbstractType && ( + (bound contains sym) + || (sym.name == tpnme.WILDCARD) + || isSurroundingTypeParam(sym) + ) + ) + tp.normalize match { + case SingleType(pre, _) => + check(pre, bound) + case TypeRef(_, ArrayClass, arg :: _) => + check(arg, bound) + case tp @ TypeRef(pre, sym, args) => + ( (sym.isAbstractType && !isLocalBinding(sym)) + || (args exists (x => !isLocalBinding(x.typeSymbol))) + || check(pre, bound) + ) + // case RefinedType(_, decls) if decls.nonEmpty => + // patternWarning(tp, "refinement ") + case RefinedType(parents, _) => + parents exists (p => check(p, bound)) + case ExistentialType(quantified, tp1) => + check(tp1, bound ::: quantified) + case _ => + false + } + } + check(tp, Nil) + } + def checkCheckable(tree: Tree, tp: Type, kind: String) { def patternWarning(tp0: Type, prefix: String) = { context.unit.uncheckedWarning(tree.pos, prefix+tp0+" in type "+kind+tp+" is unchecked since it is eliminated by erasure") diff --git a/src/compiler/scala/tools/nsc/typechecker/Macros.scala b/src/compiler/scala/tools/nsc/typechecker/Macros.scala index be7db9a920..b7e0eaef2b 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Macros.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Macros.scala @@ -185,8 +185,21 @@ trait Macros { self: Analyzer => import typer.context if (macroDebug) println("typechecking macro def %s at %s".format(ddef.symbol, ddef.pos)) - implicit def augmentString(s: String) = new AugmentedString(s) - class AugmentedString(s: String) { + typer.checkFeature(ddef.pos, MacrosFeature) + + // [Eugene to Martin] todo. copy/pasted this from checkFeature, because don't know a better way + // this is necessary to prevent macros from typechecking/expanding when they are not enabled + // `checkFeature` call alone is not enough, because it merely posts validation callback to unit.toCheck + def hasImport = inferImplicit(EmptyTree: Tree, MacrosFeature.tpe, true, false, typer.context) != SearchFailure + val nestedOwners = MacrosFeature.owner.ownerChain.takeWhile(_ != languageFeatureModule.moduleClass).reverse + val featureName = (nestedOwners map (_.name + ".")).mkString + MacrosFeature.name + def hasOption = settings.language.value contains featureName + if (!hasImport && !hasOption) { + ddef.symbol setFlag IS_ERROR + return EmptyTree + } + + implicit class AugmentedString(s: String) { def abbreviateCoreAliases: String = { // hack! var result = s result = result.replace("c.mirror.TypeTag", "c.TypeTag") @@ -544,14 +557,14 @@ trait Macros { self: Analyzer => val implCtxParam = if (implParamss.length > 0 && implParamss(0).length > 0) implParamss(0)(0) else null def implParamToDefParam(implParam: Symbol): Symbol = { - val indices = (implParamss drop 1 zipWithIndex) map { case (implParams, index) => (index, implParams indexOf implParam) } filter (_._2 != -1) headOption; + val indices = (((implParamss drop 1).zipWithIndex) map { case (implParams, index) => (index, implParams indexOf implParam) } filter (_._2 != -1)).headOption val defParam = indices flatMap { case (plistIndex, pIndex) => if (defParamss.length <= plistIndex) None else if (defParamss(plistIndex).length <= pIndex) None else Some(defParamss(plistIndex)(pIndex)) } - defParam orNull + defParam.orNull } class UnsigmaTypeMap extends TypeMap { diff --git a/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala b/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala index e1c12adbcc..9e06cbe0d3 100644 --- a/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala +++ b/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala @@ -8,6 +8,7 @@ package typechecker import symtab.Flags._ import scala.collection.{ mutable, immutable } import scala.tools.util.StringOps.{ ojoin } +import language.higherKinds /** Logic related to method synthesis which involves cooperation between * Namer and Typer. @@ -377,7 +378,7 @@ trait MethodSynthesis { } def derivedTree: DefDef = factoryMeth(mods & flagsMask | flagsExtra, name, tree, symbolic = false) - def flagsExtra: Long = METHOD | IMPLICIT + def flagsExtra: Long = METHOD | IMPLICIT | SYNTHETIC def flagsMask: Long = AccessFlags def name: TermName = tree.name.toTermName } diff --git a/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala b/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala index 4d84bf4af2..be269cf4b2 100644 --- a/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala +++ b/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala @@ -48,7 +48,7 @@ trait NamesDefaults { self: Analyzer => /** @param pos maps indices from new to old (!) */ def reorderArgsInv[T: ClassManifest](args: List[T], pos: Int => Int): List[T] = { val argsArray = args.toArray - argsArray.indices map (i => argsArray(pos(i))) toList + (argsArray.indices map (i => argsArray(pos(i)))).toList } /** returns `true` if every element is equal to its index */ diff --git a/src/compiler/scala/tools/nsc/typechecker/PatMatVirtualiser.scala b/src/compiler/scala/tools/nsc/typechecker/PatMatVirtualiser.scala index aff8368f75..1fd9f6fc13 100644 --- a/src/compiler/scala/tools/nsc/typechecker/PatMatVirtualiser.scala +++ b/src/compiler/scala/tools/nsc/typechecker/PatMatVirtualiser.scala @@ -8,6 +8,7 @@ package typechecker import symtab._ import Flags.{MUTABLE, METHOD, LABEL, SYNTHETIC} +import language.postfixOps /** Translate pattern matching into method calls (these methods form a zero-plus monad), similar in spirit to how for-comprehensions are compiled. * @@ -21,7 +22,7 @@ import Flags.{MUTABLE, METHOD, LABEL, SYNTHETIC} * - Array patterns * - implement spec more closely (see TODO's) * - DCE - * - use manifests for type testing + * - use TypeTags for type testing * * (longer-term) TODO: * - user-defined unapplyProd @@ -118,6 +119,7 @@ trait PatMatVirtualiser extends ast.TreeDSL { self: Analyzer => trait MatchTranslation extends MatchMonadInterface { self: TreeMakers with CodegenCore => import typer.{typed, context, silent, reallyExists} + // import typer.infer.containsUnchecked /** Implement a pattern match by turning its cases (including the implicit failure case) * into the corresponding (monadic) extractors, and combining them with the `orElse` combinator. @@ -130,10 +132,10 @@ trait PatMatVirtualiser extends ast.TreeDSL { self: Analyzer => * this could probably optimized... (but note that the matchStrategy must be solved for each nested patternmatch) */ def translateMatch(scrut: Tree, cases: List[CaseDef], pt: Type, scrutType: Type, matchFailGenOverride: Option[Tree => Tree] = None): Tree = { - // we don't transform after typers - // (that would require much more sophistication when generating trees, + // we don't transform after uncurry + // (that would require more sophistication when generating trees, // and the only place that emits Matches after typers is for exception handling anyway) - assert(phase.id <= currentRun.typerPhase.id, phase) + assert(phase.id < currentRun.uncurryPhase.id, phase) val scrutSym = freshSym(scrut.pos, pureType(scrutType)) setFlag SYNTH_CASE // pt = Any* occurs when compiling test/files/pos/annotDepMethType.scala with -Xexperimental @@ -157,12 +159,12 @@ trait PatMatVirtualiser extends ast.TreeDSL { self: Analyzer => (caseScrutSym, propagateSubstitution(translateCase(caseScrutSym, pt)(caseDef), EmptySubstitution)) } - for(cases <- emitTypeSwitch(bindersAndCases, pt) toList; + for(cases <- emitTypeSwitch(bindersAndCases, pt).toList; if cases forall treeInfo.isCatchCase; // must check again, since it's not guaranteed -- TODO: can we eliminate this? e.g., a type test could test for a trait or a non-trivial prefix, which are not handled by the back-end cse <- cases) yield fixerUpper(matchOwner, pos)(cse).asInstanceOf[CaseDef] } - val catches = if (swatches nonEmpty) swatches else { + val catches = if (swatches.nonEmpty) swatches else { val scrutSym = freshSym(pos, pureType(ThrowableClass.tpe)) val casesNoSubstOnly = caseDefs map { caseDef => (propagateSubstitution(translateCase(scrutSym, pt)(caseDef), EmptySubstitution))} @@ -819,13 +821,34 @@ class Foo(x: Other) { x._1 } // no error in this order cond } - // TODO: also need to test when erasing pt loses crucial information (and if we can recover it using a manifest) - def needsTypeTest(tp: Type, pt: Type) = !(tp <:< pt) - private def typeTest(binder: Symbol, pt: Type) = maybeWithOuterCheck(binder, pt)(codegen._isInstanceOf(binder, pt)) + // containsUnchecked: also need to test when erasing pt loses crucial information (maybe we can recover it using a TypeTag) + def needsTypeTest(tp: Type, pt: Type): Boolean = !(tp <:< pt) // || containsUnchecked(pt) + // TODO: try to find the TypeTag for the binder's type and the expected type, and if they exists, + // check that the TypeTag of the binder's type conforms to the TypeTag of the expected type + private def typeTest(binderToTest: Symbol, expectedTp: Type, disableOuterCheck: Boolean = false, dynamic: Boolean = false): Tree = { import CODE._ + // def coreTest = + if (disableOuterCheck) codegen._isInstanceOf(binderToTest, expectedTp) else maybeWithOuterCheck(binderToTest, expectedTp)(codegen._isInstanceOf(binderToTest, expectedTp)) + // if (opt.experimental && containsUnchecked(expectedTp)) { + // if (dynamic) { + // val expectedTpTagTree = findManifest(expectedTp, true) + // if (!expectedTpTagTree.isEmpty) + // ((expectedTpTagTree DOT "erasure".toTermName) DOT "isAssignableFrom".toTermName)(REF(binderToTest) DOT nme.getClass_) + // else + // coreTest + // } else { + // val expectedTpTagTree = findManifest(expectedTp, true) + // val binderTpTagTree = findManifest(binderToTest.info, true) + // if(!(expectedTpTagTree.isEmpty || binderTpTagTree.isEmpty)) + // coreTest AND (binderTpTagTree DOT nme.CONFORMS)(expectedTpTagTree) + // else + // coreTest + // } + // } else coreTest + } // need to substitute since binder may be used outside of the next extractor call (say, in the body of the case) case class TypeTestTreeMaker(prevBinder: Symbol, nextBinderTp: Type, pos: Position) extends CondTreeMaker { - val cond = typeTest(prevBinder, nextBinderTp) + val cond = typeTest(prevBinder, nextBinderTp, dynamic = true) val res = codegen._asInstanceOf(prevBinder, nextBinderTp) override def toString = "TT"+(prevBinder, nextBinderTp) } @@ -865,7 +888,7 @@ class Foo(x: Other) { x._1 } // no error in this order // TODO: `null match { x : T }` will yield a check that (indirectly) tests whether `null ne null` // don't bother (so that we don't end up with the warning "comparing values of types Null and Null using `ne' will always yield false") def genEqualsAndInstanceOf(sym: Symbol): Tree - = codegen._equals(REF(sym), patBinder) AND codegen._isInstanceOf(patBinder, pt.widen) + = codegen._equals(REF(sym), patBinder) AND typeTest(patBinder, pt.widen, disableOuterCheck = true) def isRefTp(tp: Type) = tp <:< AnyRefClass.tpe @@ -873,7 +896,7 @@ class Foo(x: Other) { x._1 } // no error in this order def isMatchUnlessNull = isRefTp(pt) && !needsTypeTest(patBinderTp, pt) // TODO: [SPEC] type test for Array - // TODO: use manifests to improve tests (for erased types we can do better when we have a manifest) + // TODO: use TypeTags to improve tests (for erased types we can do better when we have a TypeTag) pt match { case SingleType(_, sym) /*this implies sym.isStable*/ => genEqualsAndInstanceOf(sym) // TODO: [SPEC] the spec requires `eq` instead of `==` here case ThisType(sym) if sym.isModule => genEqualsAndInstanceOf(sym) // must use == to support e.g. List() == Nil @@ -1082,22 +1105,14 @@ class Foo(x: Other) { x._1 } // no error in this order def _equals(checker: Tree, binder: Symbol): Tree = checker MEMBER_== REF(binder) // NOTE: checker must be the target of the ==, that's the patmat semantics for ya def and(a: Tree, b: Tree): Tree = a AND b + // drop annotations generated by CPS plugin etc, since its annotationchecker rejects T @cps[U] <: Any + // let's assume for now annotations don't affect casts, drop them there, and bring them back using the outer Typed tree + private def mkCast(t: Tree, tp: Type) = Typed(gen.mkAsInstanceOf(t, tp.withoutAnnotations, true, false), TypeTree() setType tp) // the force is needed mainly to deal with the GADT typing hack (we can't detect it otherwise as tp nor pt need contain an abstract type, we're just casting wildly) - def _asInstanceOf(t: Tree, tp: Type, force: Boolean = false): Tree = { val tpX = /*repackExistential*/(tp) - if (!force && (t.tpe ne NoType) && t.isTyped && typesConform(t.tpe, tpX)) t //{ println("warning: emitted redundant asInstanceOf: "+(t, t.tpe, tp)); t } //.setType(tpX) - else gen.mkAsInstanceOf(t, tpX, true, false) - } - - def _isInstanceOf(b: Symbol, tp: Type): Tree = gen.mkIsInstanceOf(REF(b), /*repackExistential*/(tp), true, false) - // { val tpX = /*repackExistential*/(tp) + def _asInstanceOf(t: Tree, tp: Type, force: Boolean = false): Tree = if (!force && (t.tpe ne NoType) && t.isTyped && typesConform(t.tpe, tp)) t else mkCast(t, tp) + def _asInstanceOf(b: Symbol, tp: Type): Tree = if (typesConform(b.info, tp)) REF(b) else mkCast(REF(b), tp) + def _isInstanceOf(b: Symbol, tp: Type): Tree = gen.mkIsInstanceOf(REF(b), tp.withoutAnnotations, true, false) // if (typesConform(b.info, tpX)) { println("warning: emitted spurious isInstanceOf: "+(b, tp)); TRUE } - // else gen.mkIsInstanceOf(REF(b), tpX, true, false) - // } - - def _asInstanceOf(b: Symbol, tp: Type): Tree = { val tpX = /*repackExistential*/(tp) - if (typesConform(b.info, tpX)) REF(b) //{ println("warning: emitted redundant asInstanceOf: "+(b, b.info, tp)); REF(b) } //.setType(tpX) - else gen.mkAsInstanceOf(REF(b), tpX, true, false) - } // duplicated out of frustration with cast generation def mkZero(tp: Type): Tree = { @@ -1635,7 +1650,7 @@ class Foo(x: Other) { x._1 } // no error in this order */ def matcher(scrut: Tree, scrutSym: Symbol, restpe: Type)(cases: List[Casegen => Tree], matchFailGen: Option[Tree => Tree]): Tree = { val matchEnd = NoSymbol.newLabel(freshName("matchEnd"), NoPosition) setFlag SYNTH_CASE - val matchRes = NoSymbol.newValueParameter(newTermName("x"), NoPosition, SYNTHETIC) setInfo restpe + val matchRes = NoSymbol.newValueParameter(newTermName("x"), NoPosition, SYNTHETIC) setInfo restpe.withoutAnnotations // matchEnd setInfo MethodType(List(matchRes), restpe) def newCaseSym = NoSymbol.newLabel(freshName("case"), NoPosition) setInfo MethodType(Nil, restpe) setFlag SYNTH_CASE @@ -1649,7 +1664,11 @@ class Foo(x: Other) { x._1 } // no error in this order def catchAll = matchFailGen map { matchFailGen => val scrutRef = if(scrutSym ne NoSymbol) REF(scrutSym) else EmptyTree // for alternatives - LabelDef(nextCase, Nil, matchEnd APPLY (_asInstanceOf(matchFailGen(scrutRef), restpe))) // need to jump to matchEnd with result generated by matchFailGen (could be `FALSE` for isDefinedAt) + // must jump to matchEnd, use result generated by matchFailGen (could be `FALSE` for isDefinedAt) + LabelDef(nextCase, Nil, matchEnd APPLY (matchFailGen(scrutRef))) + // don't cast the arg to matchEnd when using PartialFun synth in uncurry, since it won't detect the throw (see gen.withDefaultCase) + // the cast is necessary when using typedMatchAnonFun-style PartialFun synth: + // (_asInstanceOf(matchFailGen(scrutRef), restpe)) } toList // catchAll.isEmpty iff no synthetic default case needed (the (last) user-defined case is a default) // if the last user-defined case is a default, it will never jump to the next case; it will go immediately to matchEnd diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala index ad727d4082..21336c2375 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -10,6 +10,7 @@ import symtab.Flags._ import collection.{ mutable, immutable } import transform.InfoTransform import scala.collection.mutable.ListBuffer +import language.postfixOps /** <p> * Post-attribution checking and transformation. @@ -358,7 +359,7 @@ abstract class RefChecks extends InfoTransform with reflect.internal.transform.R /** Is the intersection between given two lists of overridden symbols empty? */ def intersectionIsEmpty(syms1: List[Symbol], syms2: List[Symbol]) = - !(syms1 exists (syms2 contains)) + !(syms1 exists (syms2 contains _)) if (typesOnly) checkOverrideTypes() else { @@ -1065,12 +1066,10 @@ abstract class RefChecks extends InfoTransform with reflect.internal.transform.R // equals. def isUsingWarnableEquals = { val m = receiver.info.member(nme.equals_) - def n = actual.info.member(nme.equals_) - ( (m == Object_equals) - || (m == Any_equals) - || (m.isSynthetic && m.owner.isCase && !n.owner.isCase) - ) + ((m == Object_equals) || (m == Any_equals) || isMethodCaseEquals(m)) } + def isMethodCaseEquals(m: Symbol) = m.isSynthetic && m.owner.isCase + def isCaseEquals = isMethodCaseEquals(receiver.info.member(nme.equals_)) // Whether this == or != is one of those defined in Any/AnyRef or an overload from elsewhere. def isUsingDefaultScalaOp = { val s = fn.symbol @@ -1093,9 +1092,11 @@ abstract class RefChecks extends InfoTransform with reflect.internal.transform.R val msg = alwaysEqual == (name == nme.EQ || name == nme.eq) unit.warning(pos, "comparing "+what+" using `"+name.decode+"' will always yield " + msg) } - def nonSensible(pre: String, alwaysEqual: Boolean) = nonSensibleWarning(pre+"values of types "+typesString, alwaysEqual) + def nonSensiblyEq() = nonSensible("", true) + def nonSensiblyNeq() = nonSensible("", false) + def nonSensiblyNew() = nonSensibleWarning("a fresh object", false) def unrelatedTypes() = { val msg = if (name == nme.EQ || name == nme.eq) @@ -1103,52 +1104,73 @@ abstract class RefChecks extends InfoTransform with reflect.internal.transform.R unit.warning(pos, typesString + " are unrelated: they will most likely " + msg) } - if (nullCount == 2) - nonSensible("", true) // null == null + if (nullCount == 2) // null == null + nonSensiblyEq() else if (nullCount == 1) { if (onSyms(_ exists isPrimitiveValueClass)) // null == 5 - nonSensible("", false) + nonSensiblyNeq() else if (onTrees( _ exists isNew)) // null == new AnyRef - nonSensibleWarning("a fresh object", false) + nonSensiblyNew() } else if (isBoolean(receiver)) { if (!isBoolean(actual) && !isMaybeValue(actual)) // true == 5 - nonSensible("", false) + nonSensiblyNeq() } else if (isUnit(receiver)) { if (isUnit(actual)) // () == () - nonSensible("", true) + nonSensiblyEq() else if (!isUnit(actual) && !isMaybeValue(actual)) // () == "abc" - nonSensible("", false) + nonSensiblyNeq() } else if (isNumeric(receiver)) { if (!isNumeric(actual) && !forMSIL) if (isUnit(actual) || isBoolean(actual) || !isMaybeValue(actual)) // 5 == "abc" - nonSensible("", false) + nonSensiblyNeq() } - else if (isWarnable) { + else if (isWarnable && !isCaseEquals) { if (isNew(qual)) // new X == y - nonSensibleWarning("a fresh object", false) + nonSensiblyNew() else if (isNew(args.head) && (receiver.isEffectivelyFinal || isReferenceOp)) // object X ; X == new Y - nonSensibleWarning("a fresh object", false) + nonSensiblyNew() else if (receiver.isEffectivelyFinal && !(receiver isSubClass actual)) { // object X, Y; X == Y if (isEitherNullable) nonSensible("non-null ", false) else - nonSensible("", false) + nonSensiblyNeq() } } // possibleNumericCount is insufficient or this will warn on e.g. Boolean == j.l.Boolean if (isWarnable && nullCount == 0 && !(isSpecial(receiver) && isSpecial(actual))) { - if (actual isSubClass receiver) () - else if (receiver isSubClass actual) () - // warn only if they have no common supertype below Object - else { + // better to have lubbed and lost + def warnIfLubless(): Unit = { val common = global.lub(List(actual.tpe, receiver.tpe)) if (ObjectClass.tpe <:< common) unrelatedTypes() } + def eitherSubclasses = (actual isSubClass receiver) || (receiver isSubClass actual) + // warn if actual has a case parent that is not same as receiver's; + // if actual is not a case, then warn if no common supertype, as below + if (isCaseEquals) { + def thisCase = receiver.info.member(nme.equals_).owner + actual.info.baseClasses.find(_.isCase) match { + case Some(p) if (p != thisCase) => nonSensible("case class ", false) + case None => + // stronger message on (Some(1) == None) + //if (receiver.isCase && receiver.isEffectivelyFinal && !(receiver isSubClass actual)) nonSensiblyNeq() + //else + // if a class, it must be super to thisCase (and receiver) since not <: thisCase + if (!actual.isTrait && !(receiver isSubClass actual)) nonSensiblyNeq() + else if (!eitherSubclasses) warnIfLubless() + case _ => + } + } + else if (actual isSubClass receiver) () + else if (receiver isSubClass actual) () + // warn only if they have no common supertype below Object + else { + warnIfLubless() + } } case _ => } @@ -1654,9 +1676,10 @@ abstract class RefChecks extends InfoTransform with reflect.internal.transform.R inPattern = false treeCopy.CaseDef(tree, pat1, transform(guard), transform(body)) case LabelDef(_, _, _) if gen.hasSynthCaseSymbol(result) => + val old = inPattern inPattern = true val res = deriveLabelDef(result)(transform) - inPattern = false + inPattern = old res case _ => super.transform(result) diff --git a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala index da87d38ab0..868c236ee9 100644 --- a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala +++ b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala @@ -50,7 +50,7 @@ trait SyntheticMethods extends ast.TreeDSL { import synthesizer._ if (clazz0 == AnyValClass || isPrimitiveValueClass(clazz0)) return { - if (clazz0.info member nme.getClass_ isDeferred) { + if ((clazz0.info member nme.getClass_).isDeferred) { // XXX dummy implementation for now val getClassMethod = createMethod(nme.getClass_, getClassReturnType(clazz.tpe))(_ => NULL) deriveTemplate(templ)(_ :+ getClassMethod) @@ -303,7 +303,7 @@ trait SyntheticMethods extends ast.TreeDSL { lb += logResult("case accessor new")(newAcc) } - lb ++= templ.body ++= synthesize() toList + (lb ++= templ.body ++= synthesize()).toList } if (phase.id > currentRun.typerPhase.id) templ diff --git a/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala b/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala index 8895905ca7..4319dd10c7 100644 --- a/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala @@ -14,8 +14,9 @@ import util.returning abstract class TreeCheckers extends Analyzer { import global._ - private val everything = ListBuffer[(Phase, Map[Tree, (Symbol, Type)])]() + private val everything = ListBuffer[(Phase, Map[Tree, (Symbol, Type)])]() private val currentTrees = mutable.Map[Tree, (Symbol, Type)]() + private val tpeOfTree = mutable.HashMap[Tree, Type]() if (settings.debug.value) { sys addShutdownHook { @@ -28,7 +29,7 @@ abstract class TreeCheckers extends Analyzer { } } - private def classstr(x: AnyRef) = x.getClass.getName split """\\.|\\$""" last; + private def classstr(x: AnyRef) = (x.getClass.getName split """\\.|\\$""").last private def typestr(x: Type) = " (tpe = " + x + ")" private def treestr(t: Tree) = t + " [" + classstr(t) + "]" + typestr(t.tpe) private def ownerstr(s: Symbol) = "'" + s + "'" + s.locationString @@ -49,12 +50,13 @@ abstract class TreeCheckers extends Analyzer { object SymbolTracker extends Traverser { type PhaseMap = mutable.HashMap[Symbol, List[Tree]] + val defSyms = mutable.HashMap[Symbol, List[DefTree]]() withDefaultValue Nil + val newSyms = mutable.HashSet[Symbol]() val maps = ListBuffer[(Phase, PhaseMap)]() + val movedMsgs = ListBuffer[String]() + def prev = maps.init.last._2 def latest = maps.last._2 - val defSyms = mutable.HashMap[Symbol, List[DefTree]]() - val newSyms = mutable.HashSet[Symbol]() - val movedMsgs = new ListBuffer[String] def sortedNewSyms = newSyms.toList.distinct sortBy (_.name.toString) def inPrev(sym: Symbol) = { @@ -119,10 +121,8 @@ abstract class TreeCheckers extends Analyzer { if (sym != null && sym != NoSymbol) { record(sym, tree) tree match { - case x: DefTree => - if (defSyms contains sym) defSyms(sym) = defSyms(sym) :+ x - else defSyms(sym) = List(x) - case _ => () + case x: DefTree => defSyms(sym) :+= x + case _ => () } } @@ -130,8 +130,6 @@ abstract class TreeCheckers extends Analyzer { } } - lazy val tpeOfTree = mutable.HashMap[Tree, Type]() - def posstr(p: Position) = try p.source.path + ":" + p.line catch { case _: UnsupportedOperationException => p.toString } @@ -147,9 +145,7 @@ abstract class TreeCheckers extends Analyzer { if (!cond) errorFn(msg) def checkTrees() { - if (settings.verbose.value) - Console.println("[consistency check at the beginning of phase " + phase + "]") - + informFn("[consistency check at the beginning of phase " + phase + "]") currentRun.units foreach check } @@ -172,7 +168,7 @@ abstract class TreeCheckers extends Analyzer { informProgress("checking "+unit) val context = rootContext(unit) context.checking = true - tpeOfTree.clear + tpeOfTree.clear() SymbolTracker.check(phase, unit) val checker = new TreeChecker(context) runWithUnit(unit) { diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 2d1c62d347..0541f85f31 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -512,7 +512,6 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser { res } - /** The typer for a label definition. If this is part of a template we * first have to enter the label definition. */ @@ -675,7 +674,7 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser { } if (tree.tpe.isInstanceOf[MethodType] && pre.isStable && sym.tpe.params.isEmpty && (isStableContext(tree, mode, pt) || sym.isModule)) - tree.setType(MethodType(List(), singleType(pre, sym))) + tree.setType(MethodType(List(), singleType(pre, sym))) // TODO: should this be a NullaryMethodType? else tree } @@ -734,6 +733,39 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser { } } + def checkFeature(pos: Position, featureTrait: Symbol, construct: => String = "") = + if (!isPastTyper) { + val nestedOwners = + featureTrait.owner.ownerChain.takeWhile(_ != languageFeatureModule.moduleClass).reverse + val featureName = (nestedOwners map (_.name + ".")).mkString + featureTrait.name + unit.toCheck += { () => + def hasImport = inferImplicit(EmptyTree: Tree, featureTrait.tpe, true, false, context) != SearchFailure + def hasOption = settings.language.value contains featureName + if (!hasImport && !hasOption) { + val Some(AnnotationInfo(_, List(Literal(Constant(featureDesc: String)), Literal(Constant(required: Boolean))), _)) = + featureTrait getAnnotation LanguageFeatureAnnot + val req = if (required) "needs to" else "should" + var raw = featureDesc + " " + req + " be enabled\n" + + "by making the implicit value language." + featureName + " visible." + if (!(currentRun.reportedFeature contains featureTrait)) + raw += "\nThis can be achieved by adding the import clause 'import language." + featureName + "'\n" + + "or by setting the compiler option -language:" + featureName + ".\n" + + "See the Scala docs for value scala.language." + featureName + " for a discussion\n" + + "why the feature " + req + " be explicitly enabled." + currentRun.reportedFeature += featureTrait + val msg = raw replace ("#", construct) + if (required) unit.error(pos, msg) + else currentRun.featureWarnings.warn(pos, msg) + } + } + } + + def checkExistentialsFeature(pos: Position, tpe: Type, prefix: String) = tpe match { + case extp: ExistentialType if !extp.isRepresentableWithWildcards => + checkFeature(pos, ExistentialsFeature, prefix+" "+tpe) + case _ => + } + /** Perform the following adaptations of expression, pattern or type `tree` wrt to * given mode `mode` and given prototype `pt`: * (-1) For expressions with annotated types, let AnnotationCheckers decide what to do @@ -773,7 +805,7 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser { protected def adapt(tree: Tree, mode: Int, pt: Type, original: Tree = EmptyTree): Tree = { def adaptToImplicitMethod(mt: MethodType): Tree = { - if (context.undetparams nonEmpty) { // (9) -- should revisit dropped condition `(mode & POLYmode) == 0` + if (context.undetparams.nonEmpty) { // (9) -- should revisit dropped condition `(mode & POLYmode) == 0` // dropped so that type args of implicit method are inferred even if polymorphic expressions are allowed // needed for implicits in 2.8 collection library -- maybe once #3346 is fixed, we can reinstate the condition? context.undetparams = inferExprInstance(tree, context.extractUndetparams(), pt, @@ -1171,7 +1203,7 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser { && !qtpe.typeSymbol.isBottomClass && qtpe != WildcardType && !qual.isInstanceOf[ApplyImplicitView] // don't chain views - && context.implicitsEnabled + && (context.implicitsEnabled || context.enrichmentEnabled) // Elaborating `context.implicitsEnabled`: // don't try to adapt a top-level type that's the subject of an implicit search // this happens because, if isView, typedImplicit tries to apply the "current" implicit value to @@ -1941,6 +1973,12 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser { if (meth.isStructuralRefinementMember) checkMethodStructuralCompatible(meth) + if (meth.isImplicit && !meth.isSynthetic) meth.info.paramss match { + case List(param) :: _ if !param.isImplicit => + checkFeature(ddef.pos, ImplicitConversionsFeature, meth.toString) + case _ => + } + treeCopy.DefDef(ddef, typedMods, ddef.name, tparams1, vparamss1, tpt1, rhs1) setType NoType } @@ -1972,6 +2010,10 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser { case TypeBounds(lo1, hi1) if (!(lo1 <:< hi1)) => LowerBoundError(tdef, lo1, hi1) case _ => () } + + if (tdef.symbol.isDeferred && tdef.symbol.info.isHigherKinded) + checkFeature(tdef.pos, HigherKindsFeature) + treeCopy.TypeDef(tdef, typedMods, tdef.name, tparams1, rhs1) setType NoType } @@ -2115,7 +2157,7 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser { var body1: Tree = typed(cdef.body, pt) val contextWithTypeBounds = context.nextEnclosing(_.tree.isInstanceOf[CaseDef]) - if (contextWithTypeBounds.savedTypeBounds nonEmpty) { + if (contextWithTypeBounds.savedTypeBounds.nonEmpty) { body1.tpe = contextWithTypeBounds restoreTypeBounds body1.tpe // insert a cast if something typechecked under the GADT constraints, @@ -2151,13 +2193,13 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser { def adaptCase(cdef: CaseDef, mode: Int, tpe: Type): CaseDef = deriveCaseDef(cdef)(adapt(_, mode, tpe)) - def prepareTranslateMatch(selector0: Tree, cases: List[CaseDef], mode: Int, resTp: Type) = { + def typedMatch(selector0: Tree, cases: List[CaseDef], mode: Int, resTp: Type) = { val (selector, doTranslation) = selector0 match { case Annotated(Ident(nme.synthSwitch), selector) => (selector, false) case s => (s, true) } val selector1 = checkDead(typed(selector, EXPRmode | BYVALmode, WildcardType)) - val selectorTp = packCaptured(selector1.tpe.widen) + val selectorTp = packCaptured(selector1.tpe.widen.withoutAnnotations) val casesTyped = typedCases(cases, selectorTp, resTp) val caseTypes = casesTyped map (c => packedType(c, context.owner).deconst) @@ -2168,7 +2210,7 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser { (selector1, selectorTp, casesAdapted, ownType, doTranslation) } - def translateMatch(selector1: Tree, selectorTp: Type, casesAdapted: List[CaseDef], ownType: Type, doTranslation: Boolean, matchFailGen: Option[Tree => Tree] = None) = { + def translatedMatch(selector1: Tree, selectorTp: Type, casesAdapted: List[CaseDef], ownType: Type, doTranslation: Boolean, matchFailGen: Option[Tree => Tree] = None) = { def repeatedToSeq(tp: Type): Type = (tp baseType RepeatedParamClass) match { case TypeRef(_, RepeatedParamClass, arg :: Nil) => seqType(arg) case _ => tp @@ -2178,10 +2220,12 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser { Match(selector1, casesAdapted) setType ownType // setType of the Match to avoid recursing endlessly } else { val scrutType = repeatedToSeq(elimAnonymousClass(selectorTp)) - // we've packed the type for each case in prepareTranslateMatch so that if all cases have the same existential case, we get a clean lub + // we've packed the type for each case in typedMatch so that if all cases have the same existential case, we get a clean lub // here, we should open up the existential again // relevant test cases: pos/existentials-harmful.scala, pos/gadt-gilles.scala, pos/t2683.scala, pos/virtpatmat_exist4.scala - MatchTranslator(this).translateMatch(selector1, casesAdapted, repeatedToSeq(ownType.skolemizeExistential(context.owner, context.tree)), scrutType, matchFailGen) + // TODO: fix skolemizeExistential (it should preserve annotations, right?) + val ownTypeSkolemized = ownType.skolemizeExistential(context.owner, context.tree) withAnnotations ownType.annotations + MatchTranslator(this).translateMatch(selector1, casesAdapted, repeatedToSeq(ownTypeSkolemized), scrutType, matchFailGen) } } @@ -2241,7 +2285,7 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser { val methodBodyTyper = newTyper(context.makeNewScope(context.tree, methodSym)) // should use the DefDef for the context's tree, but it doesn't exist yet (we need the typer we're creating to create it) paramSyms foreach (methodBodyTyper.context.scope enter _) - val (selector1, selectorTp, casesAdapted, resTp, doTranslation) = methodBodyTyper.prepareTranslateMatch(selector, cases, mode, ptRes) + val (selector1, selectorTp, casesAdapted, resTp, doTranslation) = methodBodyTyper.typedMatch(selector, cases, mode, ptRes) val methFormals = paramSyms map (_.tpe) val parents = List(abstractFunctionType(methFormals, resTp), SerializableClass.tpe) @@ -2249,7 +2293,7 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser { anonClass setInfo ClassInfoType(parents, newScope, anonClass) methodSym setInfoAndEnter MethodType(paramSyms, resTp) - DefDef(methodSym, methodBodyTyper.translateMatch(selector1, selectorTp, casesAdapted, resTp, doTranslation)) + DefDef(methodSym, methodBodyTyper.translatedMatch(selector1, selectorTp, casesAdapted, resTp, doTranslation)) } } @@ -2279,7 +2323,7 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser { val methodBodyTyper = newTyper(context.makeNewScope(context.tree, methodSym)) // should use the DefDef for the context's tree, but it doesn't exist yet (we need the typer we're creating to create it) paramSyms foreach (methodBodyTyper.context.scope enter _) - val (selector1, selectorTp, casesAdapted, resTp, doTranslation) = methodBodyTyper.prepareTranslateMatch(selector, cases, mode, ptRes) + val (selector1, selectorTp, casesAdapted, resTp, doTranslation) = methodBodyTyper.typedMatch(selector, cases, mode, ptRes) anonClass setInfo ClassInfoType(parents(List(argTp, resTp)), newScope, anonClass) B1 setInfo TypeBounds.lower(resTp) @@ -2288,7 +2332,7 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser { // use applyOrElse's first parameter since the scrut's type has been widened def doDefault(scrut_ignored: Tree) = REF(default) APPLY (REF(x)) - val body = methodBodyTyper.translateMatch(selector1, selectorTp, casesAdapted, B1.tpe, doTranslation, Some(doDefault)) + val body = methodBodyTyper.translatedMatch(selector1, selectorTp, casesAdapted, B1.tpe, doTranslation, Some(doDefault)) DefDef(methodSym, body) } @@ -2303,8 +2347,8 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser { paramSyms foreach (methodBodyTyper.context.scope enter _) methodSym setInfoAndEnter MethodType(paramSyms, BooleanClass.tpe) - val (selector1, selectorTp, casesAdapted, resTp, doTranslation) = methodBodyTyper.prepareTranslateMatch(selector, casesTrue, mode, BooleanClass.tpe) - val body = methodBodyTyper.translateMatch(selector1, selectorTp, casesAdapted, resTp, doTranslation, Some(scrutinee => FALSE_typed)) + val (selector1, selectorTp, casesAdapted, resTp, doTranslation) = methodBodyTyper.typedMatch(selector, casesTrue, mode, BooleanClass.tpe) + val body = methodBodyTyper.translatedMatch(selector1, selectorTp, casesAdapted, resTp, doTranslation, Some(scrutinee => FALSE_typed)) DefDef(methodSym, body) } @@ -2365,29 +2409,21 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser { } } - fun.body match { - case Match(sel, cases) if opt.virtPatmat => - // go to outer context -- must discard the context that was created for the Function since we're discarding the function - // thus, its symbol, which serves as the current context.owner, is not the right owner - // you won't know you're using the wrong owner until lambda lift crashes (unless you know better than to use the wrong owner) - newTyper(context.outer).typedMatchAnonFun(fun, cases, mode, pt, Some((fun.vparams, sel))) - case _ => - val vparamSyms = fun.vparams map { vparam => - enterSym(context, vparam) - if (context.retyping) context.scope enter vparam.symbol - vparam.symbol - } - val vparams = fun.vparams mapConserve (typedValDef) - // for (vparam <- vparams) { - // checkNoEscaping.locals(context.scope, WildcardType, vparam.tpt); () - // } - val formals = vparamSyms map (_.tpe) - val body1 = typed(fun.body, respt) - val restpe = packedType(body1, fun.symbol).deconst.resultType - val funtpe = typeRef(clazz.tpe.prefix, clazz, formals :+ restpe) - // body = checkNoEscaping.locals(context.scope, restpe, body) - treeCopy.Function(fun, vparams, body1).setType(funtpe) + val vparamSyms = fun.vparams map { vparam => + enterSym(context, vparam) + if (context.retyping) context.scope enter vparam.symbol + vparam.symbol } + val vparams = fun.vparams mapConserve (typedValDef) +// for (vparam <- vparams) { +// checkNoEscaping.locals(context.scope, WildcardType, vparam.tpt); () +// } + val formals = vparamSyms map (_.tpe) + val body1 = typed(fun.body, respt) + val restpe = packedType(body1, fun.symbol).deconst.resultType + val funtpe = typeRef(clazz.tpe.prefix, clazz, formals :+ restpe) +// body = checkNoEscaping.locals(context.scope, restpe, body) + treeCopy.Function(fun, vparams, body1).setType(funtpe) } } @@ -2817,7 +2853,8 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser { (args exists isNamed) || // uses a named argument isNamedApplyBlock(fun)) { // fun was transformed to a named apply block => // integrate this application into the block - tryNamesDefaults + if (dyna.isApplyDynamicNamed(fun)) dyna.typedNamedApply(tree, fun, args, mode, pt) + else tryNamesDefaults } else { val tparams = context.extractUndetparams() if (tparams.isEmpty) { // all type params are defined @@ -3438,7 +3475,108 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser { case ErrorType => setError(treeCopy.TypeApply(tree, fun, args)) case _ => - TypedApplyDoesNotTakeTpeParametersError(tree, fun) + fun match { + // drop the application for an applyDynamic or selectDynamic call since it has been pushed down + case treeInfo.DynamicApplication(_, _) => fun + case _ => TypedApplyDoesNotTakeTpeParametersError(tree, fun) + } + } + + object dyna { + import treeInfo.{isApplyDynamicName, DynamicUpdate, DynamicApplicationNamed} + + def acceptsApplyDynamic(tp: Type) = tp.typeSymbol isNonBottomSubClass DynamicClass + + /** Returns `Some(t)` if `name` can be selected dynamically on `qual`, `None` if not. + * `t` specifies the type to be passed to the applyDynamic/selectDynamic call (unless it is NoType) + * NOTE: currently either returns None or Some(NoType) (scala-virtualized extends this to Some(t) for selections on staged Structs) + */ + def acceptsApplyDynamicWithType(qual: Tree, name: Name): Option[Type] = + // don't selectDynamic selectDynamic, do select dynamic at unknown type, + // in scala-virtualized, we may return a Some(tp) where tp ne NoType + if (!isApplyDynamicName(name) && acceptsApplyDynamic(qual.tpe.widen)) Some(NoType) + else None + + def isDynamicallyUpdatable(tree: Tree) = tree match { + case DynamicUpdate(qual, name) => + // if the qualifier is a Dynamic, that's all we need to know + acceptsApplyDynamic(qual.tpe) + case _ => false + } + + def isApplyDynamicNamed(fun: Tree): Boolean = fun match { + case DynamicApplicationNamed(qual, _) if acceptsApplyDynamic(qual.tpe.widen) => true + case _ => false + // look deeper? + // val methPart = treeInfo.methPart(fun) + // println("methPart of "+ fun +" is "+ methPart) + // if (methPart ne fun) isApplyDynamicNamed(methPart) + // else false + } + + def typedNamedApply(orig: Tree, fun: Tree, args: List[Tree], mode: Int, pt: Type): Tree = { + def argToBinding(arg: Tree): Tree = arg match { + case AssignOrNamedArg(Ident(name), rhs) => gen.mkTuple(List(CODE.LIT(name.toString), rhs)) + case _ => gen.mkTuple(List(CODE.LIT(""), arg)) + } + typed(treeCopy.Apply(orig, fun, args map argToBinding), mode, pt) + } + + /** Translate selection that does not typecheck according to the normal rules into a selectDynamic/applyDynamic. + * + * foo.method("blah") ~~> foo.applyDynamic("method")("blah") + * foo.method(x = "blah") ~~> foo.applyDynamicNamed("method")(("x", "blah")) + * foo.varia = 10 ~~> foo.updateDynamic("varia")(10) + * foo.field ~~> foo.selectDynamic("field") + * foo.arr(10) = 13 ~~> foo.selectDynamic("arr").update(10, 13) + * + * what if we want foo.field == foo.selectDynamic("field") == 1, but `foo.field = 10` == `foo.selectDynamic("field").update(10)` == () + * what would the signature for selectDynamic be? (hint: it needs to depend on whether an update call is coming or not) + * + * need to distinguish selectDynamic and applyDynamic somehow: the former must return the selected value, the latter must accept an apply or an update + * - could have only selectDynamic and pass it a boolean whether more is to come, + * so that it can either return the bare value or something that can handle the apply/update + * HOWEVER that makes it hard to return unrelated values for the two cases + * --> selectDynamic's return type is now dependent on the boolean flag whether more is to come + * - simplest solution: have two method calls + * + */ + def mkInvoke(cxTree: Tree, tree: Tree, qual: Tree, name: Name): Option[Tree] = + acceptsApplyDynamicWithType(qual, name) map { tp => + // tp eq NoType => can call xxxDynamic, but not passing any type args (unless specified explicitly by the user) + // in scala-virtualized, when not NoType, tp is passed as type argument (for selection on a staged Struct) + + // strip off type application -- we're not doing much with outer, so don't bother preserving cxTree's attributes etc + val (outer, explicitTargs) = cxTree match { + case TypeApply(fun, targs) => (fun, targs) + case Apply(TypeApply(fun, targs), args) => (Apply(fun, args), targs) + case t => (t, Nil) + } + + @inline def hasNamedArg(as: List[Tree]) = as collectFirst {case AssignOrNamedArg(lhs, rhs) =>} nonEmpty + + // note: context.tree includes at most one Apply node + // thus, we can't use it to detect we're going to receive named args in expressions such as: + // qual.sel(a)(a2, arg2 = "a2") + val oper = outer match { + case Apply(`tree`, as) => + val oper = + if (hasNamedArg(as)) nme.applyDynamicNamed + else nme.applyDynamic + // not supported: foo.bar(a1,..., an: _*) + if (treeInfo.isWildcardStarArgList(as)) { + DynamicVarArgUnsupported(tree, oper) + return Some(setError(tree)) + } else oper + case Assign(`tree`, _) => nme.updateDynamic + case _ => nme.selectDynamic + } + + val dynSel = Select(qual, oper) + val tappSel = if (explicitTargs nonEmpty) TypeApply(dynSel, explicitTargs) else dynSel + + atPos(qual.pos)(Apply(tappSel, List(Literal(Constant(name.decode))))) + } } @inline final def deindentTyping() = context.typingIndentLevel -= 2 @@ -3611,10 +3749,17 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser { case _ => } } +// if (varsym.isVariable || +// // setter-rewrite has been done above, so rule out methods here, but, wait a minute, why are we assigning to non-variables after erasure?! +// (phase.erasedTypes && varsym.isValue && !varsym.isMethod)) { if (varsym.isVariable || varsym.isValue && phase.erasedTypes) { val rhs1 = typed(rhs, EXPRmode | BYVALmode, lhs1.tpe) treeCopy.Assign(tree, lhs1, checkDead(rhs1)) setType UnitClass.tpe } + else if(dyna.isDynamicallyUpdatable(lhs1)) { + val rhs1 = typed(rhs, EXPRmode | BYVALmode, WildcardType) + typed1(Apply(lhs1, List(rhs1)), mode, pt) + } else fail() } @@ -3629,12 +3774,16 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser { lazy val thenTp = packedType(thenp1, context.owner) lazy val elseTp = packedType(elsep1, context.owner) + // println("typedIf: "+(thenp1.tpe, elsep1.tpe, ptOrLub(List(thenp1.tpe, elsep1.tpe)),"\n", thenTp, elseTp, thenTp =:= elseTp)) val (owntype, needAdapt) = // in principle we should pack the types of each branch before lubbing, but lub doesn't really work for existentials anyway // in the special (though common) case where the types are equal, it pays to pack before comparing // especially virtpatmat needs more aggressive unification of skolemized types // this breaks src/library/scala/collection/immutable/TrieIterator.scala - if (opt.virtPatmat && !isPastTyper && thenTp =:= elseTp) (thenp1.tpe, false) // use unpacked type + if ( opt.virtPatmat && !isPastTyper + && thenp1.tpe.annotations.isEmpty && elsep1.tpe.annotations.isEmpty // annotated types need to be lubbed regardless (at least, continations break if you by pass them like this) + && thenTp =:= elseTp + ) (thenp1.tpe, false) // use unpacked type // TODO: skolemize (lub of packed types) when that no longer crashes on files/pos/t4070b.scala else ptOrLub(List(thenp1.tpe, elsep1.tpe)) @@ -3646,13 +3795,9 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser { } } - def typedMatch(tree: Tree, selector: Tree, cases: List[CaseDef]): Tree = { - if (opt.virtPatmat && !isPastTyper) { - if (selector ne EmptyTree) { - val (selector1, selectorTp, casesAdapted, ownType, doTranslation) = prepareTranslateMatch(selector, cases, mode, pt) - typed(translateMatch(selector1, selectorTp, casesAdapted, ownType, doTranslation), mode, pt) - } else typedMatchAnonFun(tree, cases, mode, pt) - } else if (selector == EmptyTree) { + // translation only happens when (selector != EmptyTree) && !isPastTyper && opt.virtPatmat + def typedTranslatedMatch(tree: Tree, selector: Tree, cases: List[CaseDef]): Tree = { + if (selector == EmptyTree) { val arity = if (isFunctionType(pt)) pt.normalize.typeArgs.length - 1 else 1 val params = for (i <- List.range(0, arity)) yield atPos(tree.pos.focusStart) { @@ -3663,7 +3808,7 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser { val selector1 = atPos(tree.pos.focusStart) { if (arity == 1) ids.head else gen.mkTuple(ids) } val body = treeCopy.Match(tree, selector1, cases) typed1(atPos(tree.pos) { Function(params, body) }, mode, pt) - } else { + } else if (!((phase.id < currentRun.uncurryPhase.id) && opt.virtPatmat)) { val selector1 = checkDead(typed(selector, EXPRmode | BYVALmode, WildcardType)) var cases1 = typedCases(cases, packCaptured(selector1.tpe.widen), pt) val (owntype, needAdapt) = ptOrLub(cases1 map (_.tpe)) @@ -3671,6 +3816,9 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser { cases1 = cases1 map (adaptCase(_, mode, owntype)) } treeCopy.Match(tree, selector1, cases1) setType owntype + } else { + val (selector1, selectorTp, casesAdapted, ownType, doTranslation) = typedMatch(selector, cases, mode, pt) + typed(translatedMatch(selector1, selectorTp, casesAdapted, ownType, doTranslation), mode, pt) } } @@ -4062,7 +4210,10 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser { } else { member(qual, name) } - if (sym == NoSymbol && name != nme.CONSTRUCTOR && (mode & EXPRmode) != 0) { + + // symbol not found? --> try to convert implicitly to a type that does have the required member + // added `| PATTERNmode` to allow enrichment in patterns (so we can add e.g., an xml member to StringContext, which in turn has an unapply[Seq] method) + if (sym == NoSymbol && name != nme.CONSTRUCTOR && (mode & (EXPRmode | PATTERNmode)) != 0) { val qual1 = if (member(qual, name) != NoSymbol) qual else adaptToMemberWithArgs(tree, qual, name, mode, true, true) @@ -4070,6 +4221,7 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser { if (qual1 ne qual) return typed(treeCopy.Select(tree, qual1, name), mode, pt) } + if (!reallyExists(sym)) { if (context.owner.enclosingTopLevelClass.isJavaDefined && name.isTypeName) { val tree1 = atPos(tree.pos) { gen.convertToSelectFromType(qual, name) } @@ -4077,16 +4229,10 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser { } // try to expand according to Dynamic rules. - - if (settings.Xexperimental.value && (qual.tpe.widen.typeSymbol isNonBottomSubClass DynamicClass)) { - var dynInvoke = Apply(Select(qual, nme.applyDynamic), List(Literal(Constant(name.decode)))) - context.tree match { - case Apply(tree1, args) if tree1 eq tree => - ; - case _ => - dynInvoke = Apply(dynInvoke, List()) - } - return typed1(util.trace("dynatype: ")(dynInvoke), mode, pt) + dyna.mkInvoke(context.tree, tree, qual, name) match { + case Some(invocation) => + return typed1(invocation, mode, pt) + case _ => } if (settings.debug.value) { @@ -4145,7 +4291,7 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser { result match { // could checkAccessible (called by makeAccessible) potentially have skipped checking a type application in qual? - case SelectFromTypeTree(qual@TypeTree(), name) if qual.tpe.typeArgs nonEmpty => // TODO: somehow the new qual is not checked in refchecks + case SelectFromTypeTree(qual@TypeTree(), name) if qual.tpe.typeArgs.nonEmpty => // TODO: somehow the new qual is not checked in refchecks treeCopy.SelectFromTypeTree( result, (TypeTreeWithDeferredRefCheck(){ () => val tp = qual.tpe; val sym = tp.typeSymbolDirect @@ -4536,7 +4682,7 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser { typedIf(cond, thenp, elsep) case tree @ Match(selector, cases) => - typedMatch(tree, selector, cases) + typedTranslatedMatch(tree, selector, cases) case Return(expr) => typedReturn(expr) @@ -4552,7 +4698,7 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser { catches1 = catches1 map (adaptCase(_, mode, owntype)) } - if(!isPastTyper && opt.virtPatmat) { + if((phase.id < currentRun.uncurryPhase.id) && opt.virtPatmat) { catches1 = (MatchTranslator(this)).translateTry(catches1, owntype, tree.pos) } @@ -4708,6 +4854,11 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser { else typedSelect(qual1, name) + if (tree.isInstanceOf[PostfixSelect]) + checkFeature(tree.pos, PostfixOpsFeature, name.decode) + if (tree1.symbol != null && tree1.symbol.isOnlyRefinementMember) + checkFeature(tree1.pos, ReflectiveCallsFeature, tree1.symbol.toString) + if (qual1.symbol == RootPackage) treeCopy.Ident(tree1, name) else tree1 @@ -4753,9 +4904,11 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser { treeCopy.TypeBoundsTree(tree, lo1, hi1) setType TypeBounds(lo1.tpe, hi1.tpe) case etpt @ ExistentialTypeTree(_, _) => - typerWithLocalContext(context.makeNewScope(tree, context.owner)){ + val tree1 = typerWithLocalContext(context.makeNewScope(tree, context.owner)){ _.typedExistentialTypeTree(etpt, mode) } + checkExistentialsFeature(tree1.pos, tree1.tpe, "the existential type") + tree1 case dc@TypeTreeWithDeferredRefCheck() => dc // TODO: should we re-type the wrapped tree? then we need to change TypeTreeWithDeferredRefCheck's representation to include the wrapped tree explicitly (instead of in its closure) case tpt @ TypeTree() => @@ -4805,6 +4958,8 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser { ptLine("typing %s: pt = %s".format(ptTree(tree), pt), "undetparams" -> context.undetparams, "implicitsEnabled" -> context.implicitsEnabled, + "enrichmentEnabled" -> context.enrichmentEnabled, + "mode" -> modeString(mode), "silent" -> context.bufferErrors, "context.owner" -> context.owner ) @@ -4908,7 +5063,22 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser { // We disable implicits because otherwise some constructs will // type check which should not. The pattern matcher does not // perform implicit conversions in an attempt to consummate a match. - context.withImplicitsDisabled(typed(tree, PATTERNmode, pt)) + + // on the one hand, + // "abc" match { case Seq('a', 'b', 'c') => true } + // should be ruled out statically, otherwise this is a runtime + // error both because there is an implicit from String to Seq + // (even though such implicits are not used by the matcher) and + // because the typer is fine with concluding that "abc" might + // be of type "String with Seq[T]" and thus eligible for a call + // to unapplySeq. + + // on the other hand, we want to be able to use implicits to add members retro-actively (e.g., add xml to StringContext) + + // as a compromise, context.enrichmentEnabled tells adaptToMember to go ahead and enrich, + // but arbitrary conversions (in adapt) are disabled + // TODO: can we achieve the pattern matching bit of the string interpolation SIP without this? + context.withImplicitsDisabledAllowEnrichment(typed(tree, PATTERNmode, pt)) } /** Types a (fully parameterized) type tree */ @@ -4965,7 +5135,9 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser { assert(!context.owner.isTermMacro, context.owner) val tree1 = typed(tree, pt) transformed(tree) = tree1 - packedType(tree1, context.owner) + val tpe = packedType(tree1, context.owner) + checkExistentialsFeature(tree.pos, tpe, "inferred existential type") + tpe } def computeMacroDefType(tree: Tree, pt: Type): Type = { diff --git a/src/compiler/scala/tools/nsc/typechecker/Unapplies.scala b/src/compiler/scala/tools/nsc/typechecker/Unapplies.scala index 1f79d8212d..1ebcea4a07 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Unapplies.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Unapplies.scala @@ -200,7 +200,7 @@ trait Unapplies extends ast.TreeDSL def caseClassCopyMeth(cdef: ClassDef): Option[DefDef] = { def isDisallowed(vd: ValDef) = isRepeatedParamType(vd.tpt) || isByNameParamType(vd.tpt) val cparamss = constrParamss(cdef) - val flat = cparamss flatten + val flat = cparamss.flatten if (cdef.symbol.hasAbstractFlag || (flat exists isDisallowed)) None else { diff --git a/src/compiler/scala/tools/nsc/util/ClassPath.scala b/src/compiler/scala/tools/nsc/util/ClassPath.scala index 11d7db5180..5dd9ce0e02 100644 --- a/src/compiler/scala/tools/nsc/util/ClassPath.scala +++ b/src/compiler/scala/tools/nsc/util/ClassPath.scala @@ -29,7 +29,7 @@ object ClassPath { def infoFor[T](value: T) = info(value.getClass) def info[T](clazz: Class[T]) = new ClassAndJarInfo()(ClassManifest[T](clazz)) def info[T: ClassManifest] = new ClassAndJarInfo[T] - def locate[T: ClassManifest] = info[T] rootClasspath + def locate[T: ClassManifest] = info[T].rootClasspath def locateJar[T: ClassManifest] = info[T].rootPossibles find (x => isJarOrZip(x)) map (x => File(x)) def locateDir[T: ClassManifest] = info[T].rootPossibles find (_.isDirectory) map (_.toDirectory) @@ -373,7 +373,7 @@ extends ClassPath[T] { this(entries.toIndexedSeq, context) def name = entries.head.name - def asURLs = entries flatMap (_.asURLs) toList + def asURLs = (entries flatMap (_.asURLs)).toList lazy val sourcepaths: IndexedSeq[AbstractFile] = entries flatMap (_.sourcepaths) override def origin = Some(entries map (x => x.origin getOrElse x.name) mkString ("Merged(", ", ", ")")) diff --git a/src/compiler/scala/tools/nsc/util/CommandLineParser.scala b/src/compiler/scala/tools/nsc/util/CommandLineParser.scala index 00fe49d36a..78bfd5e908 100644 --- a/src/compiler/scala/tools/nsc/util/CommandLineParser.scala +++ b/src/compiler/scala/tools/nsc/util/CommandLineParser.scala @@ -20,11 +20,10 @@ import scala.collection.mutable.ListBuffer */ trait ParserUtil extends Parsers { - class ParserPlus[+T](underlying: Parser[T]) { + protected implicit class ParserPlus[+T](underlying: Parser[T]) { def !~>[U](p: => Parser[U]): Parser[U] = (underlying ~! p) ^^ { case a~b => b } def <~![U](p: => Parser[U]): Parser[T] = (underlying ~! p) ^^ { case a~b => a } } - protected implicit def parser2parserPlus[T](p: Parser[T]): ParserPlus[T] = new ParserPlus(p) } case class CommandLine( diff --git a/src/compiler/scala/tools/nsc/util/Exceptional.scala b/src/compiler/scala/tools/nsc/util/Exceptional.scala index 667b7d15a6..7452aa1b67 100644 --- a/src/compiler/scala/tools/nsc/util/Exceptional.scala +++ b/src/compiler/scala/tools/nsc/util/Exceptional.scala @@ -5,6 +5,7 @@ import java.util.concurrent.ExecutionException import java.lang.reflect.{ InvocationTargetException, UndeclaredThrowableException } import io.{ Sources, Fileish } import scala.tools.util.StringOps._ +import language.implicitConversions /** A simple throwable wrapper so it looks more like a parade of * glittering frame-shaped beauties than the other thing. diff --git a/src/compiler/scala/tools/nsc/util/ScalaClassLoader.scala b/src/compiler/scala/tools/nsc/util/ScalaClassLoader.scala index fda713c5c6..700fe0c1a6 100644 --- a/src/compiler/scala/tools/nsc/util/ScalaClassLoader.scala +++ b/src/compiler/scala/tools/nsc/util/ScalaClassLoader.scala @@ -14,6 +14,8 @@ import java.net.URL import scala.reflect.ReflectionUtils.unwrapHandler import ScalaClassLoader._ import scala.util.control.Exception.{ catching } +import language.implicitConversions + // import Exceptional.unwrap trait HasClassPath { diff --git a/src/compiler/scala/tools/nsc/util/package.scala b/src/compiler/scala/tools/nsc/util/package.scala index 88e6c51e9f..1336cca3c5 100644 --- a/src/compiler/scala/tools/nsc/util/package.scala +++ b/src/compiler/scala/tools/nsc/util/package.scala @@ -9,6 +9,8 @@ import java.io.{ OutputStream, PrintStream, ByteArrayOutputStream, PrintWriter, package object util { + implicit def postfixOps = language.postfixOps // make all postfix ops in this package compile without warning + // forwarder for old code that builds against 2.9 and 2.10 val Chars = scala.reflect.internal.Chars diff --git a/src/continuations/plugin/scala/tools/selectivecps/SelectiveANFTransform.scala b/src/continuations/plugin/scala/tools/selectivecps/SelectiveANFTransform.scala index a6737573ea..0975f16c6e 100644 --- a/src/continuations/plugin/scala/tools/selectivecps/SelectiveANFTransform.scala +++ b/src/continuations/plugin/scala/tools/selectivecps/SelectiveANFTransform.scala @@ -71,24 +71,46 @@ abstract class SelectiveANFTransform extends PluginComponent with Transform with // { x => x match { case A => ... }} to // { x => shiftUnit(x match { case A => ... })} // which Uncurry cannot handle (see function6.scala) + // thus, we push down the shiftUnit to each of the case bodies val ext = getExternalAnswerTypeAnn(body.tpe) + val pureBody = getAnswerTypeAnn(body.tpe).isEmpty + + def transformPureMatch(tree: Tree, selector: Tree, cases: List[CaseDef]) = { + val caseVals = cases map { case cd @ CaseDef(pat, guard, body) => + // if (!hasPlusMarker(body.tpe)) body.tpe = body.tpe withAnnotation newPlusMarker() // TODO: to avoid warning + val bodyVal = transExpr(body, None, ext) // ??? triggers "cps-transformed unexpectedly" warning in transTailValue + treeCopy.CaseDef(cd, transform(pat), transform(guard), bodyVal) + } + treeCopy.Match(tree, transform(selector), caseVals) + } + + def transformPureVirtMatch(body: Block, selDef: ValDef, cases: List[Tree], matchEnd: Tree) = { + val stats = transform(selDef) :: (cases map (transExpr(_, None, ext))) + treeCopy.Block(body, stats, transExpr(matchEnd, None, ext)) + } val body1 = body match { - case Match(selector, cases) if (ext.isDefined && getAnswerTypeAnn(body.tpe).isEmpty) => - val cases1 = for { - cd @ CaseDef(pat, guard, caseBody) <- cases - caseBody1 = transExpr(body, None, ext) - } yield { - treeCopy.CaseDef(cd, transform(pat), transform(guard), caseBody1) - } - treeCopy.Match(tree, transform(selector), cases1) + case Match(selector, cases) if ext.isDefined && pureBody => + transformPureMatch(body, selector, cases) + + // virtpatmat switch + case Block(List(selDef: ValDef), mat@Match(selector, cases)) if ext.isDefined && pureBody => + treeCopy.Block(body, List(transform(selDef)), transformPureMatch(mat, selector, cases)) + + // virtpatmat + case b@Block(matchStats@((selDef: ValDef) :: cases), matchEnd) if ext.isDefined && pureBody && (matchStats forall gen.hasSynthCaseSymbol) => + transformPureVirtMatch(b, selDef, cases, matchEnd) + + // virtpatmat that stores the scrut separately -- TODO: can we eliminate this case?? + case Block(List(selDef0: ValDef), mat@Block(matchStats@((selDef: ValDef) :: cases), matchEnd)) if ext.isDefined && pureBody && (matchStats forall gen.hasSynthCaseSymbol)=> + treeCopy.Block(body, List(transform(selDef0)), transformPureVirtMatch(mat, selDef, cases, matchEnd)) case _ => transExpr(body, None, ext) } - debuglog("result "+body1) + debuglog("anf result "+body1) debuglog("result is of type "+body1.tpe) treeCopy.Function(ff, transformValDefs(vparams), body1) @@ -170,63 +192,72 @@ abstract class SelectiveANFTransform extends PluginComponent with Transform with tree match { case Block(stms, expr) => val (cpsA2, cpsR2) = (cpsA, linearize(cpsA, getAnswerTypeAnn(tree.tpe))) // tbd -// val (cpsA2, cpsR2) = (None, getAnswerTypeAnn(tree.tpe)) - val (a, b) = transBlock(stms, expr, cpsA2, cpsR2) + // val (cpsA2, cpsR2) = (None, getAnswerTypeAnn(tree.tpe)) - val tree1 = (treeCopy.Block(tree, a, b)) // no updateSynthFlag here!!! + val (a, b) = transBlock(stms, expr, cpsA2, cpsR2) + val tree1 = (treeCopy.Block(tree, a, b)) // no updateSynthFlag here!!! (Nil, tree1, cpsA) - case If(cond, thenp, elsep) => - /* possible situations: - cps before (cpsA) - cps in condition (spc) <-- synth flag set if *only* here! - cps in (one or both) branches */ - val (condStats, condVal, spc) = transInlineValue(cond, cpsA) - val (cpsA2, cpsR2) = if (hasSynthMarker(tree.tpe)) - (spc, linearize(spc, getAnswerTypeAnn(tree.tpe))) else - (None, getAnswerTypeAnn(tree.tpe)) // if no cps in condition, branches must conform to tree.tpe directly - val thenVal = transExpr(thenp, cpsA2, cpsR2) - val elseVal = transExpr(elsep, cpsA2, cpsR2) - - // check that then and else parts agree (not necessary any more, but left as sanity check) - if (cpsR.isDefined) { - if (elsep == EmptyTree) - unit.error(tree.pos, "always need else part in cps code") - } - if (hasAnswerTypeAnn(thenVal.tpe) != hasAnswerTypeAnn(elseVal.tpe)) { - unit.error(tree.pos, "then and else parts must both be cps code or neither of them") - } - - (condStats, updateSynthFlag(treeCopy.If(tree, condVal, thenVal, elseVal)), spc) + case If(cond, thenp, elsep) => + /* possible situations: + cps before (cpsA) + cps in condition (spc) <-- synth flag set if *only* here! + cps in (one or both) branches */ + val (condStats, condVal, spc) = transInlineValue(cond, cpsA) + val (cpsA2, cpsR2) = if (hasSynthMarker(tree.tpe)) + (spc, linearize(spc, getAnswerTypeAnn(tree.tpe))) else + (None, getAnswerTypeAnn(tree.tpe)) // if no cps in condition, branches must conform to tree.tpe directly + val thenVal = transExpr(thenp, cpsA2, cpsR2) + val elseVal = transExpr(elsep, cpsA2, cpsR2) + + // check that then and else parts agree (not necessary any more, but left as sanity check) + if (cpsR.isDefined) { + if (elsep == EmptyTree) + unit.error(tree.pos, "always need else part in cps code") + } + if (hasAnswerTypeAnn(thenVal.tpe) != hasAnswerTypeAnn(elseVal.tpe)) { + unit.error(tree.pos, "then and else parts must both be cps code or neither of them") + } - case Match(selector, cases) => + (condStats, updateSynthFlag(treeCopy.If(tree, condVal, thenVal, elseVal)), spc) - val (selStats, selVal, spc) = transInlineValue(selector, cpsA) - val (cpsA2, cpsR2) = if (hasSynthMarker(tree.tpe)) - (spc, linearize(spc, getAnswerTypeAnn(tree.tpe))) else - (None, getAnswerTypeAnn(tree.tpe)) + case Match(selector, cases) => + val (selStats, selVal, spc) = transInlineValue(selector, cpsA) + val (cpsA2, cpsR2) = + if (hasSynthMarker(tree.tpe)) (spc, linearize(spc, getAnswerTypeAnn(tree.tpe))) + else (None, getAnswerTypeAnn(tree.tpe)) - val caseVals = for { - cd @ CaseDef(pat, guard, body) <- cases - bodyVal = transExpr(body, cpsA2, cpsR2) - } yield { - treeCopy.CaseDef(cd, transform(pat), transform(guard), bodyVal) - } + val caseVals = cases map { case cd @ CaseDef(pat, guard, body) => + val bodyVal = transExpr(body, cpsA2, cpsR2) + treeCopy.CaseDef(cd, transform(pat), transform(guard), bodyVal) + } - (selStats, updateSynthFlag(treeCopy.Match(tree, selVal, caseVals)), spc) + (selStats, updateSynthFlag(treeCopy.Match(tree, selVal, caseVals)), spc) + // this is utterly broken: LabelDefs need to be considered together when transforming them to DefDefs: + // suppose a Block {L1; ... ; LN} + // this should become {D1def ; ... ; DNdef ; D1()} + // where D$idef = def L$i(..) = {L$i.body; L${i+1}(..)} case ldef @ LabelDef(name, params, rhs) => if (hasAnswerTypeAnn(tree.tpe)) { - val sym = currentOwner.newMethod(name, tree.pos, Flags.SYNTHETIC) setInfo ldef.symbol.info - val rhs1 = new TreeSymSubstituter(List(ldef.symbol), List(sym)).transform(rhs) + // currentOwner.newMethod(name, tree.pos, Flags.SYNTHETIC) setInfo ldef.symbol.info + val sym = ldef.symbol resetFlag Flags.LABEL + val rhs1 = rhs //new TreeSymSubstituter(List(ldef.symbol), List(sym)).transform(rhs) val rhsVal = transExpr(rhs1, None, getAnswerTypeAnn(tree.tpe)) changeOwner (currentOwner -> sym) val stm1 = localTyper.typed(DefDef(sym, rhsVal)) - val expr = localTyper.typed(Apply(Ident(sym), List())) - - (List(stm1), expr, cpsA) + // since virtpatmat does not rely on fall-through, don't call the labels it emits + // transBlock will take care of calling the first label + // calling each labeldef is wrong, since some labels may be jumped over + // we can get away with this for now since the only other labels we emit are for tailcalls/while loops, + // which do not have consecutive labeldefs (and thus fall-through is irrelevant) + if (gen.hasSynthCaseSymbol(ldef)) (List(stm1), localTyper.typed{Literal(Constant(()))}, cpsA) + else { + assert(params.isEmpty, "problem in ANF transforming label with non-empty params "+ ldef) + (List(stm1), localTyper.typed{Apply(Ident(sym), List())}, cpsA) + } } else { val rhsVal = transExpr(rhs, None, None) (Nil, updateSynthFlag(treeCopy.LabelDef(tree, name, params, rhsVal)), cpsA) @@ -412,18 +443,29 @@ abstract class SelectiveANFTransform extends PluginComponent with Transform with } def transBlock(stms: List[Tree], expr: Tree, cpsA: CPSInfo, cpsR: CPSInfo): (List[Tree], Tree) = { - stms match { - case Nil => - transTailValue(expr, cpsA, cpsR) - - case stm::rest => - var (rest2, expr2) = (rest, expr) - val (headStms, headSpc) = transInlineStm(stm, cpsA) - val (restStms, restExpr) = transBlock(rest2, expr2, headSpc, cpsR) - (headStms:::restStms, restExpr) - } + def rec(currStats: List[Tree], currAns: CPSInfo, accum: List[Tree]): (List[Tree], Tree) = + currStats match { + case Nil => + val (anfStats, anfExpr) = transTailValue(expr, currAns, cpsR) + (accum ++ anfStats, anfExpr) + + case stat :: rest => + val (stats, nextAns) = transInlineStm(stat, currAns) + rec(rest, nextAns, accum ++ stats) + } + + val (anfStats, anfExpr) = rec(stms, cpsA, List()) + // println("\nanf-block:\n"+ ((stms :+ expr) mkString ("{", "\n", "}")) +"\nBECAME\n"+ ((anfStats :+ anfExpr) mkString ("{", "\n", "}"))) + + if (anfStats.nonEmpty && (anfStats forall gen.hasSynthCaseSymbol)) { + val (prologue, rest) = (anfStats :+ anfExpr) span (s => !s.isInstanceOf[DefDef]) // find first case + // val (defs, calls) = rest partition (_.isInstanceOf[DefDef]) + if (rest nonEmpty){ + val stats = prologue ++ rest.reverse // ++ calls + // println("REVERSED "+ (stats mkString ("{", "\n", "}"))) + (stats, localTyper.typed{Apply(Ident(rest.head.symbol), List())}) // call first label to kick-start the match + } else (anfStats, anfExpr) + } else (anfStats, anfExpr) } - - } } diff --git a/src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSTransform.scala b/src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSTransform.scala index 6453671eac..2db4054ef5 100644 --- a/src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSTransform.scala +++ b/src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSTransform.scala @@ -15,7 +15,7 @@ import scala.tools.nsc.ast._ * In methods marked @cps, CPS-transform assignments introduced by ANF-transform phase. */ abstract class SelectiveCPSTransform extends PluginComponent with - InfoTransform with TypingTransformers with CPSUtils { + InfoTransform with TypingTransformers with CPSUtils with TreeDSL { // inherits abstract value `global` and class `Phase` from Transform import global._ // the global environment @@ -203,12 +203,16 @@ abstract class SelectiveCPSTransform extends PluginComponent with rhs.changeOwner(currentOwner -> fun.symbol) val exSym = currentOwner.newValueParameter(cpsNames.ex, pos).setInfo(ThrowableClass.tpe) - val catch2 = { localTyper.typedCases(List( - CaseDef(Bind(exSym, Typed(Ident("_"), TypeTree(ThrowableClass.tpe))), - Apply(Select(Ident(funSym), nme.isDefinedAt), List(Ident(exSym))), - Apply(Ident(funSym), List(Ident(exSym)))) - ), ThrowableClass.tpe, targettp) } + import CODE._ + // generate a case that is supported directly by the back-end + val catchIfDefined = CaseDef( + Bind(exSym, Ident(nme.WILDCARD)), + EmptyTree, + IF ((REF(funSym) DOT nme.isDefinedAt)(REF(exSym))) THEN (REF(funSym) APPLY (REF(exSym))) ELSE Throw(REF(exSym)) + ) + + val catch2 = localTyper.typedCases(List(catchIfDefined), ThrowableClass.tpe, targettp) //typedCases(tree, catches, ThrowableClass.tpe, pt) localTyper.typed(Block(List(funDef), treeCopy.Try(tree, treeCopy.Block(block1, stms, expr2), catch2, finalizer1))) diff --git a/src/library/scala/Boolean.scala b/src/library/scala/Boolean.scala index 5078e59d28..edb82b33fe 100644 --- a/src/library/scala/Boolean.scala +++ b/src/library/scala/Boolean.scala @@ -17,7 +17,7 @@ package scala * There is an implicit conversion from [[scala.Boolean]] => [[scala.runtime.RichBoolean]] * which provides useful non-primitive operations. */ -final class Boolean extends AnyVal { +final class Boolean private extends AnyVal { /** * Negates a Boolean expression. * @@ -110,7 +110,7 @@ final class Boolean extends AnyVal { override def getClass(): Class[Boolean] = sys.error("stub") } -object Boolean extends AnyValCompanion { +object Boolean extends AnyValCompanion { /** Transform a value type into a boxed reference type. * diff --git a/src/library/scala/Byte.scala b/src/library/scala/Byte.scala index f9c5f6003e..b5b3d88e3f 100644 --- a/src/library/scala/Byte.scala +++ b/src/library/scala/Byte.scala @@ -17,7 +17,7 @@ package scala * There is an implicit conversion from [[scala.Byte]] => [[scala.runtime.RichByte]] * which provides useful non-primitive operations. */ -final class Byte extends AnyVal { +final class Byte private extends AnyVal { def toByte: Byte = sys.error("stub") def toShort: Short = sys.error("stub") def toChar: Char = sys.error("stub") @@ -27,7 +27,7 @@ final class Byte extends AnyVal { def toDouble: Double = sys.error("stub") /** - * @return the bitwise negation of this value + * Returns the bitwise negation of this value. * @example {{{ * ~5 == -6 * // in binary: ~00000101 == @@ -36,30 +36,30 @@ final class Byte extends AnyVal { */ def unary_~ : Int = sys.error("stub") /** - * @return this value, unmodified + * Returns this value, unmodified. */ def unary_+ : Int = sys.error("stub") /** - * @return the negation of this value + * Returns the negation of this value. */ def unary_- : Int = sys.error("stub") def +(x: String): String = sys.error("stub") /** - * @return this value bit-shifted left by the specified number of bits, + * Returns this value bit-shifted left by the specified number of bits, * filling in the new right bits with zeroes. * @example {{{ 6 << 3 == 48 // in binary: 0110 << 3 == 0110000 }}} */ def <<(x: Int): Int = sys.error("stub") /** - * @return this value bit-shifted left by the specified number of bits, + * Returns this value bit-shifted left by the specified number of bits, * filling in the new right bits with zeroes. * @example {{{ 6 << 3 == 48 // in binary: 0110 << 3 == 0110000 }}} */ def <<(x: Long): Int = sys.error("stub") /** - * @return this value bit-shifted right by the specified number of bits, + * Returns this value bit-shifted right by the specified number of bits, * filling the new left bits with zeroes. * @example {{{ 21 >>> 3 == 2 // in binary: 010101 >>> 3 == 010 }}} * @example {{{ @@ -70,7 +70,7 @@ final class Byte extends AnyVal { */ def >>>(x: Int): Int = sys.error("stub") /** - * @return this value bit-shifted right by the specified number of bits, + * Returns this value bit-shifted right by the specified number of bits, * filling the new left bits with zeroes. * @example {{{ 21 >>> 3 == 2 // in binary: 010101 >>> 3 == 010 }}} * @example {{{ @@ -81,7 +81,7 @@ final class Byte extends AnyVal { */ def >>>(x: Long): Int = sys.error("stub") /** - * @return this value bit-shifted left by the specified number of bits, + * Returns this value bit-shifted left by the specified number of bits, * filling in the right bits with the same value as the left-most bit of this. * The effect of this is to retain the sign of the value. * @example {{{ @@ -92,7 +92,7 @@ final class Byte extends AnyVal { */ def >>(x: Int): Int = sys.error("stub") /** - * @return this value bit-shifted left by the specified number of bits, + * Returns this value bit-shifted left by the specified number of bits, * filling in the right bits with the same value as the left-most bit of this. * The effect of this is to retain the sign of the value. * @example {{{ @@ -104,181 +104,181 @@ final class Byte extends AnyVal { def >>(x: Long): Int = sys.error("stub") /** - * @return `true` if this value is equal x, `false` otherwise + * Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Byte): Boolean = sys.error("stub") /** - * @return `true` if this value is equal x, `false` otherwise + * Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Short): Boolean = sys.error("stub") /** - * @return `true` if this value is equal x, `false` otherwise + * Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Char): Boolean = sys.error("stub") /** - * @return `true` if this value is equal x, `false` otherwise + * Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Int): Boolean = sys.error("stub") /** - * @return `true` if this value is equal x, `false` otherwise + * Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Long): Boolean = sys.error("stub") /** - * @return `true` if this value is equal x, `false` otherwise + * Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Float): Boolean = sys.error("stub") /** - * @return `true` if this value is equal x, `false` otherwise + * Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Double): Boolean = sys.error("stub") /** - * @return `true` if this value is not equal to x, `false` otherwise + * Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Byte): Boolean = sys.error("stub") /** - * @return `true` if this value is not equal to x, `false` otherwise + * Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Short): Boolean = sys.error("stub") /** - * @return `true` if this value is not equal to x, `false` otherwise + * Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Char): Boolean = sys.error("stub") /** - * @return `true` if this value is not equal to x, `false` otherwise + * Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Int): Boolean = sys.error("stub") /** - * @return `true` if this value is not equal to x, `false` otherwise + * Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Long): Boolean = sys.error("stub") /** - * @return `true` if this value is not equal to x, `false` otherwise + * Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Float): Boolean = sys.error("stub") /** - * @return `true` if this value is not equal to x, `false` otherwise + * Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Double): Boolean = sys.error("stub") /** - * @return `true` if this value is less than x, `false` otherwise + * Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Byte): Boolean = sys.error("stub") /** - * @return `true` if this value is less than x, `false` otherwise + * Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Short): Boolean = sys.error("stub") /** - * @return `true` if this value is less than x, `false` otherwise + * Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Char): Boolean = sys.error("stub") /** - * @return `true` if this value is less than x, `false` otherwise + * Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Int): Boolean = sys.error("stub") /** - * @return `true` if this value is less than x, `false` otherwise + * Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Long): Boolean = sys.error("stub") /** - * @return `true` if this value is less than x, `false` otherwise + * Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Float): Boolean = sys.error("stub") /** - * @return `true` if this value is less than x, `false` otherwise + * Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Double): Boolean = sys.error("stub") /** - * @return `true` if this value is less than or equal to x, `false` otherwise + * Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Byte): Boolean = sys.error("stub") /** - * @return `true` if this value is less than or equal to x, `false` otherwise + * Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Short): Boolean = sys.error("stub") /** - * @return `true` if this value is less than or equal to x, `false` otherwise + * Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Char): Boolean = sys.error("stub") /** - * @return `true` if this value is less than or equal to x, `false` otherwise + * Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Int): Boolean = sys.error("stub") /** - * @return `true` if this value is less than or equal to x, `false` otherwise + * Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Long): Boolean = sys.error("stub") /** - * @return `true` if this value is less than or equal to x, `false` otherwise + * Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Float): Boolean = sys.error("stub") /** - * @return `true` if this value is less than or equal to x, `false` otherwise + * Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Double): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than x, `false` otherwise + * Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Byte): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than x, `false` otherwise + * Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Short): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than x, `false` otherwise + * Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Char): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than x, `false` otherwise + * Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Int): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than x, `false` otherwise + * Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Long): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than x, `false` otherwise + * Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Float): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than x, `false` otherwise + * Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Double): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than or equal to x, `false` otherwise + * Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Byte): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than or equal to x, `false` otherwise + * Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Short): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than or equal to x, `false` otherwise + * Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Char): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than or equal to x, `false` otherwise + * Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Int): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than or equal to x, `false` otherwise + * Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Long): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than or equal to x, `false` otherwise + * Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Float): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than or equal to x, `false` otherwise + * Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Double): Boolean = sys.error("stub") /** - * @return the bitwise OR of this value and x + * Returns the bitwise OR of this value and `x`. * @example {{{ * (0xf0 | 0xaa) == 0xfa * // in binary: 11110000 @@ -289,7 +289,7 @@ final class Byte extends AnyVal { */ def |(x: Byte): Int = sys.error("stub") /** - * @return the bitwise OR of this value and x + * Returns the bitwise OR of this value and `x`. * @example {{{ * (0xf0 | 0xaa) == 0xfa * // in binary: 11110000 @@ -300,7 +300,7 @@ final class Byte extends AnyVal { */ def |(x: Short): Int = sys.error("stub") /** - * @return the bitwise OR of this value and x + * Returns the bitwise OR of this value and `x`. * @example {{{ * (0xf0 | 0xaa) == 0xfa * // in binary: 11110000 @@ -311,7 +311,7 @@ final class Byte extends AnyVal { */ def |(x: Char): Int = sys.error("stub") /** - * @return the bitwise OR of this value and x + * Returns the bitwise OR of this value and `x`. * @example {{{ * (0xf0 | 0xaa) == 0xfa * // in binary: 11110000 @@ -322,7 +322,7 @@ final class Byte extends AnyVal { */ def |(x: Int): Int = sys.error("stub") /** - * @return the bitwise OR of this value and x + * Returns the bitwise OR of this value and `x`. * @example {{{ * (0xf0 | 0xaa) == 0xfa * // in binary: 11110000 @@ -334,7 +334,7 @@ final class Byte extends AnyVal { def |(x: Long): Long = sys.error("stub") /** - * @return the bitwise AND of this value and x + * Returns the bitwise AND of this value and `x`. * @example {{{ * (0xf0 & 0xaa) == 0xa0 * // in binary: 11110000 @@ -345,7 +345,7 @@ final class Byte extends AnyVal { */ def &(x: Byte): Int = sys.error("stub") /** - * @return the bitwise AND of this value and x + * Returns the bitwise AND of this value and `x`. * @example {{{ * (0xf0 & 0xaa) == 0xa0 * // in binary: 11110000 @@ -356,7 +356,7 @@ final class Byte extends AnyVal { */ def &(x: Short): Int = sys.error("stub") /** - * @return the bitwise AND of this value and x + * Returns the bitwise AND of this value and `x`. * @example {{{ * (0xf0 & 0xaa) == 0xa0 * // in binary: 11110000 @@ -367,7 +367,7 @@ final class Byte extends AnyVal { */ def &(x: Char): Int = sys.error("stub") /** - * @return the bitwise AND of this value and x + * Returns the bitwise AND of this value and `x`. * @example {{{ * (0xf0 & 0xaa) == 0xa0 * // in binary: 11110000 @@ -378,7 +378,7 @@ final class Byte extends AnyVal { */ def &(x: Int): Int = sys.error("stub") /** - * @return the bitwise AND of this value and x + * Returns the bitwise AND of this value and `x`. * @example {{{ * (0xf0 & 0xaa) == 0xa0 * // in binary: 11110000 @@ -390,7 +390,7 @@ final class Byte extends AnyVal { def &(x: Long): Long = sys.error("stub") /** - * @return the bitwise XOR of this value and x + * Returns the bitwise XOR of this value and `x`. * @example {{{ * (0xf0 ^ 0xaa) == 0x5a * // in binary: 11110000 @@ -401,7 +401,7 @@ final class Byte extends AnyVal { */ def ^(x: Byte): Int = sys.error("stub") /** - * @return the bitwise XOR of this value and x + * Returns the bitwise XOR of this value and `x`. * @example {{{ * (0xf0 ^ 0xaa) == 0x5a * // in binary: 11110000 @@ -412,7 +412,7 @@ final class Byte extends AnyVal { */ def ^(x: Short): Int = sys.error("stub") /** - * @return the bitwise XOR of this value and x + * Returns the bitwise XOR of this value and `x`. * @example {{{ * (0xf0 ^ 0xaa) == 0x5a * // in binary: 11110000 @@ -423,7 +423,7 @@ final class Byte extends AnyVal { */ def ^(x: Char): Int = sys.error("stub") /** - * @return the bitwise XOR of this value and x + * Returns the bitwise XOR of this value and `x`. * @example {{{ * (0xf0 ^ 0xaa) == 0x5a * // in binary: 11110000 @@ -434,7 +434,7 @@ final class Byte extends AnyVal { */ def ^(x: Int): Int = sys.error("stub") /** - * @return the bitwise XOR of this value and x + * Returns the bitwise XOR of this value and `x`. * @example {{{ * (0xf0 ^ 0xaa) == 0x5a * // in binary: 11110000 @@ -446,154 +446,154 @@ final class Byte extends AnyVal { def ^(x: Long): Long = sys.error("stub") /** - * @return the sum of this value and x + * Returns the sum of this value and `x`. */ def +(x: Byte): Int = sys.error("stub") /** - * @return the sum of this value and x + * Returns the sum of this value and `x`. */ def +(x: Short): Int = sys.error("stub") /** - * @return the sum of this value and x + * Returns the sum of this value and `x`. */ def +(x: Char): Int = sys.error("stub") /** - * @return the sum of this value and x + * Returns the sum of this value and `x`. */ def +(x: Int): Int = sys.error("stub") /** - * @return the sum of this value and x + * Returns the sum of this value and `x`. */ def +(x: Long): Long = sys.error("stub") /** - * @return the sum of this value and x + * Returns the sum of this value and `x`. */ def +(x: Float): Float = sys.error("stub") /** - * @return the sum of this value and x + * Returns the sum of this value and `x`. */ def +(x: Double): Double = sys.error("stub") /** - * @return the difference of this value and x + * Returns the difference of this value and `x`. */ def -(x: Byte): Int = sys.error("stub") /** - * @return the difference of this value and x + * Returns the difference of this value and `x`. */ def -(x: Short): Int = sys.error("stub") /** - * @return the difference of this value and x + * Returns the difference of this value and `x`. */ def -(x: Char): Int = sys.error("stub") /** - * @return the difference of this value and x + * Returns the difference of this value and `x`. */ def -(x: Int): Int = sys.error("stub") /** - * @return the difference of this value and x + * Returns the difference of this value and `x`. */ def -(x: Long): Long = sys.error("stub") /** - * @return the difference of this value and x + * Returns the difference of this value and `x`. */ def -(x: Float): Float = sys.error("stub") /** - * @return the difference of this value and x + * Returns the difference of this value and `x`. */ def -(x: Double): Double = sys.error("stub") /** - * @return the product of this value and x + * Returns the product of this value and `x`. */ def *(x: Byte): Int = sys.error("stub") /** - * @return the product of this value and x + * Returns the product of this value and `x`. */ def *(x: Short): Int = sys.error("stub") /** - * @return the product of this value and x + * Returns the product of this value and `x`. */ def *(x: Char): Int = sys.error("stub") /** - * @return the product of this value and x + * Returns the product of this value and `x`. */ def *(x: Int): Int = sys.error("stub") /** - * @return the product of this value and x + * Returns the product of this value and `x`. */ def *(x: Long): Long = sys.error("stub") /** - * @return the product of this value and x + * Returns the product of this value and `x`. */ def *(x: Float): Float = sys.error("stub") /** - * @return the product of this value and x + * Returns the product of this value and `x`. */ def *(x: Double): Double = sys.error("stub") /** - * @return the quotient of this value and x + * Returns the quotient of this value and `x`. */ def /(x: Byte): Int = sys.error("stub") /** - * @return the quotient of this value and x + * Returns the quotient of this value and `x`. */ def /(x: Short): Int = sys.error("stub") /** - * @return the quotient of this value and x + * Returns the quotient of this value and `x`. */ def /(x: Char): Int = sys.error("stub") /** - * @return the quotient of this value and x + * Returns the quotient of this value and `x`. */ def /(x: Int): Int = sys.error("stub") /** - * @return the quotient of this value and x + * Returns the quotient of this value and `x`. */ def /(x: Long): Long = sys.error("stub") /** - * @return the quotient of this value and x + * Returns the quotient of this value and `x`. */ def /(x: Float): Float = sys.error("stub") /** - * @return the quotient of this value and x + * Returns the quotient of this value and `x`. */ def /(x: Double): Double = sys.error("stub") /** - * @return the remainder of the division of this value by x + * Returns the remainder of the division of this value by `x`. */ def %(x: Byte): Int = sys.error("stub") /** - * @return the remainder of the division of this value by x + * Returns the remainder of the division of this value by `x`. */ def %(x: Short): Int = sys.error("stub") /** - * @return the remainder of the division of this value by x + * Returns the remainder of the division of this value by `x`. */ def %(x: Char): Int = sys.error("stub") /** - * @return the remainder of the division of this value by x + * Returns the remainder of the division of this value by `x`. */ def %(x: Int): Int = sys.error("stub") /** - * @return the remainder of the division of this value by x + * Returns the remainder of the division of this value by `x`. */ def %(x: Long): Long = sys.error("stub") /** - * @return the remainder of the division of this value by x + * Returns the remainder of the division of this value by `x`. */ def %(x: Float): Float = sys.error("stub") /** - * @return the remainder of the division of this value by x + * Returns the remainder of the division of this value by `x`. */ def %(x: Double): Double = sys.error("stub") override def getClass(): Class[Byte] = sys.error("stub") } -object Byte extends AnyValCompanion { +object Byte extends AnyValCompanion { /** The smallest value representable as a Byte. */ final val MinValue = java.lang.Byte.MIN_VALUE @@ -622,5 +622,10 @@ object Byte extends AnyValCompanion { /** The String representation of the scala.Byte companion object. */ override def toString = "object scala.Byte" + implicit def byte2short(x: Byte): Short = x.toShort + implicit def byte2int(x: Byte): Int = x.toInt + implicit def byte2long(x: Byte): Long = x.toLong + implicit def byte2float(x: Byte): Float = x.toFloat + implicit def byte2double(x: Byte): Double = x.toDouble } diff --git a/src/library/scala/Char.scala b/src/library/scala/Char.scala index 3d459782cd..e0ac9a2550 100644 --- a/src/library/scala/Char.scala +++ b/src/library/scala/Char.scala @@ -17,7 +17,7 @@ package scala * There is an implicit conversion from [[scala.Char]] => [[scala.runtime.RichChar]] * which provides useful non-primitive operations. */ -final class Char extends AnyVal { +final class Char private extends AnyVal { def toByte: Byte = sys.error("stub") def toShort: Short = sys.error("stub") def toChar: Char = sys.error("stub") @@ -27,7 +27,7 @@ final class Char extends AnyVal { def toDouble: Double = sys.error("stub") /** - * @return the bitwise negation of this value + * Returns the bitwise negation of this value. * @example {{{ * ~5 == -6 * // in binary: ~00000101 == @@ -36,30 +36,30 @@ final class Char extends AnyVal { */ def unary_~ : Int = sys.error("stub") /** - * @return this value, unmodified + * Returns this value, unmodified. */ def unary_+ : Int = sys.error("stub") /** - * @return the negation of this value + * Returns the negation of this value. */ def unary_- : Int = sys.error("stub") def +(x: String): String = sys.error("stub") /** - * @return this value bit-shifted left by the specified number of bits, + * Returns this value bit-shifted left by the specified number of bits, * filling in the new right bits with zeroes. * @example {{{ 6 << 3 == 48 // in binary: 0110 << 3 == 0110000 }}} */ def <<(x: Int): Int = sys.error("stub") /** - * @return this value bit-shifted left by the specified number of bits, + * Returns this value bit-shifted left by the specified number of bits, * filling in the new right bits with zeroes. * @example {{{ 6 << 3 == 48 // in binary: 0110 << 3 == 0110000 }}} */ def <<(x: Long): Int = sys.error("stub") /** - * @return this value bit-shifted right by the specified number of bits, + * Returns this value bit-shifted right by the specified number of bits, * filling the new left bits with zeroes. * @example {{{ 21 >>> 3 == 2 // in binary: 010101 >>> 3 == 010 }}} * @example {{{ @@ -70,7 +70,7 @@ final class Char extends AnyVal { */ def >>>(x: Int): Int = sys.error("stub") /** - * @return this value bit-shifted right by the specified number of bits, + * Returns this value bit-shifted right by the specified number of bits, * filling the new left bits with zeroes. * @example {{{ 21 >>> 3 == 2 // in binary: 010101 >>> 3 == 010 }}} * @example {{{ @@ -81,7 +81,7 @@ final class Char extends AnyVal { */ def >>>(x: Long): Int = sys.error("stub") /** - * @return this value bit-shifted left by the specified number of bits, + * Returns this value bit-shifted left by the specified number of bits, * filling in the right bits with the same value as the left-most bit of this. * The effect of this is to retain the sign of the value. * @example {{{ @@ -92,7 +92,7 @@ final class Char extends AnyVal { */ def >>(x: Int): Int = sys.error("stub") /** - * @return this value bit-shifted left by the specified number of bits, + * Returns this value bit-shifted left by the specified number of bits, * filling in the right bits with the same value as the left-most bit of this. * The effect of this is to retain the sign of the value. * @example {{{ @@ -104,181 +104,181 @@ final class Char extends AnyVal { def >>(x: Long): Int = sys.error("stub") /** - * @return `true` if this value is equal x, `false` otherwise + * Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Byte): Boolean = sys.error("stub") /** - * @return `true` if this value is equal x, `false` otherwise + * Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Short): Boolean = sys.error("stub") /** - * @return `true` if this value is equal x, `false` otherwise + * Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Char): Boolean = sys.error("stub") /** - * @return `true` if this value is equal x, `false` otherwise + * Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Int): Boolean = sys.error("stub") /** - * @return `true` if this value is equal x, `false` otherwise + * Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Long): Boolean = sys.error("stub") /** - * @return `true` if this value is equal x, `false` otherwise + * Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Float): Boolean = sys.error("stub") /** - * @return `true` if this value is equal x, `false` otherwise + * Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Double): Boolean = sys.error("stub") /** - * @return `true` if this value is not equal to x, `false` otherwise + * Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Byte): Boolean = sys.error("stub") /** - * @return `true` if this value is not equal to x, `false` otherwise + * Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Short): Boolean = sys.error("stub") /** - * @return `true` if this value is not equal to x, `false` otherwise + * Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Char): Boolean = sys.error("stub") /** - * @return `true` if this value is not equal to x, `false` otherwise + * Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Int): Boolean = sys.error("stub") /** - * @return `true` if this value is not equal to x, `false` otherwise + * Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Long): Boolean = sys.error("stub") /** - * @return `true` if this value is not equal to x, `false` otherwise + * Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Float): Boolean = sys.error("stub") /** - * @return `true` if this value is not equal to x, `false` otherwise + * Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Double): Boolean = sys.error("stub") /** - * @return `true` if this value is less than x, `false` otherwise + * Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Byte): Boolean = sys.error("stub") /** - * @return `true` if this value is less than x, `false` otherwise + * Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Short): Boolean = sys.error("stub") /** - * @return `true` if this value is less than x, `false` otherwise + * Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Char): Boolean = sys.error("stub") /** - * @return `true` if this value is less than x, `false` otherwise + * Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Int): Boolean = sys.error("stub") /** - * @return `true` if this value is less than x, `false` otherwise + * Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Long): Boolean = sys.error("stub") /** - * @return `true` if this value is less than x, `false` otherwise + * Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Float): Boolean = sys.error("stub") /** - * @return `true` if this value is less than x, `false` otherwise + * Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Double): Boolean = sys.error("stub") /** - * @return `true` if this value is less than or equal to x, `false` otherwise + * Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Byte): Boolean = sys.error("stub") /** - * @return `true` if this value is less than or equal to x, `false` otherwise + * Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Short): Boolean = sys.error("stub") /** - * @return `true` if this value is less than or equal to x, `false` otherwise + * Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Char): Boolean = sys.error("stub") /** - * @return `true` if this value is less than or equal to x, `false` otherwise + * Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Int): Boolean = sys.error("stub") /** - * @return `true` if this value is less than or equal to x, `false` otherwise + * Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Long): Boolean = sys.error("stub") /** - * @return `true` if this value is less than or equal to x, `false` otherwise + * Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Float): Boolean = sys.error("stub") /** - * @return `true` if this value is less than or equal to x, `false` otherwise + * Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Double): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than x, `false` otherwise + * Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Byte): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than x, `false` otherwise + * Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Short): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than x, `false` otherwise + * Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Char): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than x, `false` otherwise + * Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Int): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than x, `false` otherwise + * Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Long): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than x, `false` otherwise + * Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Float): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than x, `false` otherwise + * Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Double): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than or equal to x, `false` otherwise + * Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Byte): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than or equal to x, `false` otherwise + * Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Short): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than or equal to x, `false` otherwise + * Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Char): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than or equal to x, `false` otherwise + * Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Int): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than or equal to x, `false` otherwise + * Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Long): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than or equal to x, `false` otherwise + * Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Float): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than or equal to x, `false` otherwise + * Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Double): Boolean = sys.error("stub") /** - * @return the bitwise OR of this value and x + * Returns the bitwise OR of this value and `x`. * @example {{{ * (0xf0 | 0xaa) == 0xfa * // in binary: 11110000 @@ -289,7 +289,7 @@ final class Char extends AnyVal { */ def |(x: Byte): Int = sys.error("stub") /** - * @return the bitwise OR of this value and x + * Returns the bitwise OR of this value and `x`. * @example {{{ * (0xf0 | 0xaa) == 0xfa * // in binary: 11110000 @@ -300,7 +300,7 @@ final class Char extends AnyVal { */ def |(x: Short): Int = sys.error("stub") /** - * @return the bitwise OR of this value and x + * Returns the bitwise OR of this value and `x`. * @example {{{ * (0xf0 | 0xaa) == 0xfa * // in binary: 11110000 @@ -311,7 +311,7 @@ final class Char extends AnyVal { */ def |(x: Char): Int = sys.error("stub") /** - * @return the bitwise OR of this value and x + * Returns the bitwise OR of this value and `x`. * @example {{{ * (0xf0 | 0xaa) == 0xfa * // in binary: 11110000 @@ -322,7 +322,7 @@ final class Char extends AnyVal { */ def |(x: Int): Int = sys.error("stub") /** - * @return the bitwise OR of this value and x + * Returns the bitwise OR of this value and `x`. * @example {{{ * (0xf0 | 0xaa) == 0xfa * // in binary: 11110000 @@ -334,7 +334,7 @@ final class Char extends AnyVal { def |(x: Long): Long = sys.error("stub") /** - * @return the bitwise AND of this value and x + * Returns the bitwise AND of this value and `x`. * @example {{{ * (0xf0 & 0xaa) == 0xa0 * // in binary: 11110000 @@ -345,7 +345,7 @@ final class Char extends AnyVal { */ def &(x: Byte): Int = sys.error("stub") /** - * @return the bitwise AND of this value and x + * Returns the bitwise AND of this value and `x`. * @example {{{ * (0xf0 & 0xaa) == 0xa0 * // in binary: 11110000 @@ -356,7 +356,7 @@ final class Char extends AnyVal { */ def &(x: Short): Int = sys.error("stub") /** - * @return the bitwise AND of this value and x + * Returns the bitwise AND of this value and `x`. * @example {{{ * (0xf0 & 0xaa) == 0xa0 * // in binary: 11110000 @@ -367,7 +367,7 @@ final class Char extends AnyVal { */ def &(x: Char): Int = sys.error("stub") /** - * @return the bitwise AND of this value and x + * Returns the bitwise AND of this value and `x`. * @example {{{ * (0xf0 & 0xaa) == 0xa0 * // in binary: 11110000 @@ -378,7 +378,7 @@ final class Char extends AnyVal { */ def &(x: Int): Int = sys.error("stub") /** - * @return the bitwise AND of this value and x + * Returns the bitwise AND of this value and `x`. * @example {{{ * (0xf0 & 0xaa) == 0xa0 * // in binary: 11110000 @@ -390,7 +390,7 @@ final class Char extends AnyVal { def &(x: Long): Long = sys.error("stub") /** - * @return the bitwise XOR of this value and x + * Returns the bitwise XOR of this value and `x`. * @example {{{ * (0xf0 ^ 0xaa) == 0x5a * // in binary: 11110000 @@ -401,7 +401,7 @@ final class Char extends AnyVal { */ def ^(x: Byte): Int = sys.error("stub") /** - * @return the bitwise XOR of this value and x + * Returns the bitwise XOR of this value and `x`. * @example {{{ * (0xf0 ^ 0xaa) == 0x5a * // in binary: 11110000 @@ -412,7 +412,7 @@ final class Char extends AnyVal { */ def ^(x: Short): Int = sys.error("stub") /** - * @return the bitwise XOR of this value and x + * Returns the bitwise XOR of this value and `x`. * @example {{{ * (0xf0 ^ 0xaa) == 0x5a * // in binary: 11110000 @@ -423,7 +423,7 @@ final class Char extends AnyVal { */ def ^(x: Char): Int = sys.error("stub") /** - * @return the bitwise XOR of this value and x + * Returns the bitwise XOR of this value and `x`. * @example {{{ * (0xf0 ^ 0xaa) == 0x5a * // in binary: 11110000 @@ -434,7 +434,7 @@ final class Char extends AnyVal { */ def ^(x: Int): Int = sys.error("stub") /** - * @return the bitwise XOR of this value and x + * Returns the bitwise XOR of this value and `x`. * @example {{{ * (0xf0 ^ 0xaa) == 0x5a * // in binary: 11110000 @@ -446,154 +446,154 @@ final class Char extends AnyVal { def ^(x: Long): Long = sys.error("stub") /** - * @return the sum of this value and x + * Returns the sum of this value and `x`. */ def +(x: Byte): Int = sys.error("stub") /** - * @return the sum of this value and x + * Returns the sum of this value and `x`. */ def +(x: Short): Int = sys.error("stub") /** - * @return the sum of this value and x + * Returns the sum of this value and `x`. */ def +(x: Char): Int = sys.error("stub") /** - * @return the sum of this value and x + * Returns the sum of this value and `x`. */ def +(x: Int): Int = sys.error("stub") /** - * @return the sum of this value and x + * Returns the sum of this value and `x`. */ def +(x: Long): Long = sys.error("stub") /** - * @return the sum of this value and x + * Returns the sum of this value and `x`. */ def +(x: Float): Float = sys.error("stub") /** - * @return the sum of this value and x + * Returns the sum of this value and `x`. */ def +(x: Double): Double = sys.error("stub") /** - * @return the difference of this value and x + * Returns the difference of this value and `x`. */ def -(x: Byte): Int = sys.error("stub") /** - * @return the difference of this value and x + * Returns the difference of this value and `x`. */ def -(x: Short): Int = sys.error("stub") /** - * @return the difference of this value and x + * Returns the difference of this value and `x`. */ def -(x: Char): Int = sys.error("stub") /** - * @return the difference of this value and x + * Returns the difference of this value and `x`. */ def -(x: Int): Int = sys.error("stub") /** - * @return the difference of this value and x + * Returns the difference of this value and `x`. */ def -(x: Long): Long = sys.error("stub") /** - * @return the difference of this value and x + * Returns the difference of this value and `x`. */ def -(x: Float): Float = sys.error("stub") /** - * @return the difference of this value and x + * Returns the difference of this value and `x`. */ def -(x: Double): Double = sys.error("stub") /** - * @return the product of this value and x + * Returns the product of this value and `x`. */ def *(x: Byte): Int = sys.error("stub") /** - * @return the product of this value and x + * Returns the product of this value and `x`. */ def *(x: Short): Int = sys.error("stub") /** - * @return the product of this value and x + * Returns the product of this value and `x`. */ def *(x: Char): Int = sys.error("stub") /** - * @return the product of this value and x + * Returns the product of this value and `x`. */ def *(x: Int): Int = sys.error("stub") /** - * @return the product of this value and x + * Returns the product of this value and `x`. */ def *(x: Long): Long = sys.error("stub") /** - * @return the product of this value and x + * Returns the product of this value and `x`. */ def *(x: Float): Float = sys.error("stub") /** - * @return the product of this value and x + * Returns the product of this value and `x`. */ def *(x: Double): Double = sys.error("stub") /** - * @return the quotient of this value and x + * Returns the quotient of this value and `x`. */ def /(x: Byte): Int = sys.error("stub") /** - * @return the quotient of this value and x + * Returns the quotient of this value and `x`. */ def /(x: Short): Int = sys.error("stub") /** - * @return the quotient of this value and x + * Returns the quotient of this value and `x`. */ def /(x: Char): Int = sys.error("stub") /** - * @return the quotient of this value and x + * Returns the quotient of this value and `x`. */ def /(x: Int): Int = sys.error("stub") /** - * @return the quotient of this value and x + * Returns the quotient of this value and `x`. */ def /(x: Long): Long = sys.error("stub") /** - * @return the quotient of this value and x + * Returns the quotient of this value and `x`. */ def /(x: Float): Float = sys.error("stub") /** - * @return the quotient of this value and x + * Returns the quotient of this value and `x`. */ def /(x: Double): Double = sys.error("stub") /** - * @return the remainder of the division of this value by x + * Returns the remainder of the division of this value by `x`. */ def %(x: Byte): Int = sys.error("stub") /** - * @return the remainder of the division of this value by x + * Returns the remainder of the division of this value by `x`. */ def %(x: Short): Int = sys.error("stub") /** - * @return the remainder of the division of this value by x + * Returns the remainder of the division of this value by `x`. */ def %(x: Char): Int = sys.error("stub") /** - * @return the remainder of the division of this value by x + * Returns the remainder of the division of this value by `x`. */ def %(x: Int): Int = sys.error("stub") /** - * @return the remainder of the division of this value by x + * Returns the remainder of the division of this value by `x`. */ def %(x: Long): Long = sys.error("stub") /** - * @return the remainder of the division of this value by x + * Returns the remainder of the division of this value by `x`. */ def %(x: Float): Float = sys.error("stub") /** - * @return the remainder of the division of this value by x + * Returns the remainder of the division of this value by `x`. */ def %(x: Double): Double = sys.error("stub") override def getClass(): Class[Char] = sys.error("stub") } -object Char extends AnyValCompanion { +object Char extends AnyValCompanion { /** The smallest value representable as a Char. */ final val MinValue = java.lang.Character.MIN_VALUE @@ -622,5 +622,9 @@ object Char extends AnyValCompanion { /** The String representation of the scala.Char companion object. */ override def toString = "object scala.Char" + implicit def char2int(x: Char): Int = x.toInt + implicit def char2long(x: Char): Long = x.toLong + implicit def char2float(x: Char): Float = x.toFloat + implicit def char2double(x: Char): Double = x.toDouble } diff --git a/src/library/scala/Double.scala b/src/library/scala/Double.scala index 01414265c4..bb659b963a 100644 --- a/src/library/scala/Double.scala +++ b/src/library/scala/Double.scala @@ -17,7 +17,7 @@ package scala * There is an implicit conversion from [[scala.Double]] => [[scala.runtime.RichDouble]] * which provides useful non-primitive operations. */ -final class Double extends AnyVal { +final class Double private extends AnyVal { def toByte: Byte = sys.error("stub") def toShort: Short = sys.error("stub") def toChar: Char = sys.error("stub") @@ -27,339 +27,339 @@ final class Double extends AnyVal { def toDouble: Double = sys.error("stub") /** - * @return this value, unmodified + * Returns this value, unmodified. */ def unary_+ : Double = sys.error("stub") /** - * @return the negation of this value + * Returns the negation of this value. */ def unary_- : Double = sys.error("stub") def +(x: String): String = sys.error("stub") /** - * @return `true` if this value is equal x, `false` otherwise + * Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Byte): Boolean = sys.error("stub") /** - * @return `true` if this value is equal x, `false` otherwise + * Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Short): Boolean = sys.error("stub") /** - * @return `true` if this value is equal x, `false` otherwise + * Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Char): Boolean = sys.error("stub") /** - * @return `true` if this value is equal x, `false` otherwise + * Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Int): Boolean = sys.error("stub") /** - * @return `true` if this value is equal x, `false` otherwise + * Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Long): Boolean = sys.error("stub") /** - * @return `true` if this value is equal x, `false` otherwise + * Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Float): Boolean = sys.error("stub") /** - * @return `true` if this value is equal x, `false` otherwise + * Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Double): Boolean = sys.error("stub") /** - * @return `true` if this value is not equal to x, `false` otherwise + * Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Byte): Boolean = sys.error("stub") /** - * @return `true` if this value is not equal to x, `false` otherwise + * Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Short): Boolean = sys.error("stub") /** - * @return `true` if this value is not equal to x, `false` otherwise + * Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Char): Boolean = sys.error("stub") /** - * @return `true` if this value is not equal to x, `false` otherwise + * Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Int): Boolean = sys.error("stub") /** - * @return `true` if this value is not equal to x, `false` otherwise + * Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Long): Boolean = sys.error("stub") /** - * @return `true` if this value is not equal to x, `false` otherwise + * Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Float): Boolean = sys.error("stub") /** - * @return `true` if this value is not equal to x, `false` otherwise + * Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Double): Boolean = sys.error("stub") /** - * @return `true` if this value is less than x, `false` otherwise + * Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Byte): Boolean = sys.error("stub") /** - * @return `true` if this value is less than x, `false` otherwise + * Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Short): Boolean = sys.error("stub") /** - * @return `true` if this value is less than x, `false` otherwise + * Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Char): Boolean = sys.error("stub") /** - * @return `true` if this value is less than x, `false` otherwise + * Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Int): Boolean = sys.error("stub") /** - * @return `true` if this value is less than x, `false` otherwise + * Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Long): Boolean = sys.error("stub") /** - * @return `true` if this value is less than x, `false` otherwise + * Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Float): Boolean = sys.error("stub") /** - * @return `true` if this value is less than x, `false` otherwise + * Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Double): Boolean = sys.error("stub") /** - * @return `true` if this value is less than or equal to x, `false` otherwise + * Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Byte): Boolean = sys.error("stub") /** - * @return `true` if this value is less than or equal to x, `false` otherwise + * Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Short): Boolean = sys.error("stub") /** - * @return `true` if this value is less than or equal to x, `false` otherwise + * Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Char): Boolean = sys.error("stub") /** - * @return `true` if this value is less than or equal to x, `false` otherwise + * Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Int): Boolean = sys.error("stub") /** - * @return `true` if this value is less than or equal to x, `false` otherwise + * Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Long): Boolean = sys.error("stub") /** - * @return `true` if this value is less than or equal to x, `false` otherwise + * Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Float): Boolean = sys.error("stub") /** - * @return `true` if this value is less than or equal to x, `false` otherwise + * Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Double): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than x, `false` otherwise + * Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Byte): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than x, `false` otherwise + * Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Short): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than x, `false` otherwise + * Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Char): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than x, `false` otherwise + * Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Int): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than x, `false` otherwise + * Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Long): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than x, `false` otherwise + * Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Float): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than x, `false` otherwise + * Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Double): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than or equal to x, `false` otherwise + * Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Byte): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than or equal to x, `false` otherwise + * Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Short): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than or equal to x, `false` otherwise + * Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Char): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than or equal to x, `false` otherwise + * Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Int): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than or equal to x, `false` otherwise + * Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Long): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than or equal to x, `false` otherwise + * Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Float): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than or equal to x, `false` otherwise + * Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Double): Boolean = sys.error("stub") /** - * @return the sum of this value and x + * Returns the sum of this value and `x`. */ def +(x: Byte): Double = sys.error("stub") /** - * @return the sum of this value and x + * Returns the sum of this value and `x`. */ def +(x: Short): Double = sys.error("stub") /** - * @return the sum of this value and x + * Returns the sum of this value and `x`. */ def +(x: Char): Double = sys.error("stub") /** - * @return the sum of this value and x + * Returns the sum of this value and `x`. */ def +(x: Int): Double = sys.error("stub") /** - * @return the sum of this value and x + * Returns the sum of this value and `x`. */ def +(x: Long): Double = sys.error("stub") /** - * @return the sum of this value and x + * Returns the sum of this value and `x`. */ def +(x: Float): Double = sys.error("stub") /** - * @return the sum of this value and x + * Returns the sum of this value and `x`. */ def +(x: Double): Double = sys.error("stub") /** - * @return the difference of this value and x + * Returns the difference of this value and `x`. */ def -(x: Byte): Double = sys.error("stub") /** - * @return the difference of this value and x + * Returns the difference of this value and `x`. */ def -(x: Short): Double = sys.error("stub") /** - * @return the difference of this value and x + * Returns the difference of this value and `x`. */ def -(x: Char): Double = sys.error("stub") /** - * @return the difference of this value and x + * Returns the difference of this value and `x`. */ def -(x: Int): Double = sys.error("stub") /** - * @return the difference of this value and x + * Returns the difference of this value and `x`. */ def -(x: Long): Double = sys.error("stub") /** - * @return the difference of this value and x + * Returns the difference of this value and `x`. */ def -(x: Float): Double = sys.error("stub") /** - * @return the difference of this value and x + * Returns the difference of this value and `x`. */ def -(x: Double): Double = sys.error("stub") /** - * @return the product of this value and x + * Returns the product of this value and `x`. */ def *(x: Byte): Double = sys.error("stub") /** - * @return the product of this value and x + * Returns the product of this value and `x`. */ def *(x: Short): Double = sys.error("stub") /** - * @return the product of this value and x + * Returns the product of this value and `x`. */ def *(x: Char): Double = sys.error("stub") /** - * @return the product of this value and x + * Returns the product of this value and `x`. */ def *(x: Int): Double = sys.error("stub") /** - * @return the product of this value and x + * Returns the product of this value and `x`. */ def *(x: Long): Double = sys.error("stub") /** - * @return the product of this value and x + * Returns the product of this value and `x`. */ def *(x: Float): Double = sys.error("stub") /** - * @return the product of this value and x + * Returns the product of this value and `x`. */ def *(x: Double): Double = sys.error("stub") /** - * @return the quotient of this value and x + * Returns the quotient of this value and `x`. */ def /(x: Byte): Double = sys.error("stub") /** - * @return the quotient of this value and x + * Returns the quotient of this value and `x`. */ def /(x: Short): Double = sys.error("stub") /** - * @return the quotient of this value and x + * Returns the quotient of this value and `x`. */ def /(x: Char): Double = sys.error("stub") /** - * @return the quotient of this value and x + * Returns the quotient of this value and `x`. */ def /(x: Int): Double = sys.error("stub") /** - * @return the quotient of this value and x + * Returns the quotient of this value and `x`. */ def /(x: Long): Double = sys.error("stub") /** - * @return the quotient of this value and x + * Returns the quotient of this value and `x`. */ def /(x: Float): Double = sys.error("stub") /** - * @return the quotient of this value and x + * Returns the quotient of this value and `x`. */ def /(x: Double): Double = sys.error("stub") /** - * @return the remainder of the division of this value by x + * Returns the remainder of the division of this value by `x`. */ def %(x: Byte): Double = sys.error("stub") /** - * @return the remainder of the division of this value by x + * Returns the remainder of the division of this value by `x`. */ def %(x: Short): Double = sys.error("stub") /** - * @return the remainder of the division of this value by x + * Returns the remainder of the division of this value by `x`. */ def %(x: Char): Double = sys.error("stub") /** - * @return the remainder of the division of this value by x + * Returns the remainder of the division of this value by `x`. */ def %(x: Int): Double = sys.error("stub") /** - * @return the remainder of the division of this value by x + * Returns the remainder of the division of this value by `x`. */ def %(x: Long): Double = sys.error("stub") /** - * @return the remainder of the division of this value by x + * Returns the remainder of the division of this value by `x`. */ def %(x: Float): Double = sys.error("stub") /** - * @return the remainder of the division of this value by x + * Returns the remainder of the division of this value by `x`. */ def %(x: Double): Double = sys.error("stub") override def getClass(): Class[Double] = sys.error("stub") } -object Double extends AnyValCompanion { +object Double extends AnyValCompanion { /** The smallest positive value greater than 0.0d which is * representable as a Double. */ diff --git a/src/library/scala/Either.scala b/src/library/scala/Either.scala index e454cdf5ec..a5e1dc7fe7 100644 --- a/src/library/scala/Either.scala +++ b/src/library/scala/Either.scala @@ -10,6 +10,8 @@ package scala +import language.implicitConversions + /** Represents a value of one of two possible types (a disjoint union.) * Instances of Either are either an instance of [[scala.Left]] or [[scala.Right]]. * @@ -201,12 +203,6 @@ final case class Right[+A, +B](b: B) extends Either[A, B] { } object Either { - class MergeableEither[A](x: Either[A, A]) { - def merge: A = x match { - case Left(a) => a - case Right(a) => a - } - } /** * Allows use of a ``merge`` method to extract values from Either instances @@ -219,7 +215,14 @@ object Either { * r.merge: Seq[Int] // Vector(1) * }}} */ - implicit def either2mergeable[A](x: Either[A, A]): MergeableEither[A] = new MergeableEither(x) + implicit class MergeableEither[A](x: Either[A, A]) { + def merge: A = x match { + case Left(a) => a + case Right(a) => a + } + } + @deprecated("use MergeableEither instead", "2.10") + def either2mergeable[A](x: Either[A, A]): MergeableEither[A] = new MergeableEither(x) /** * Projects an `Either` into a `Left`. diff --git a/src/library/scala/Enumeration.scala b/src/library/scala/Enumeration.scala index dc67d32ba0..ea0d20957d 100644 --- a/src/library/scala/Enumeration.scala +++ b/src/library/scala/Enumeration.scala @@ -70,10 +70,9 @@ abstract class Enumeration (initial: Int) extends Serializable { /** The name of this enumeration. */ - override def toString = ( - (getClass.getName stripSuffix MODULE_SUFFIX_STRING split '.' last) - split Pattern.quote(NAME_JOIN_STRING) last - ) + override def toString = + ((getClass.getName stripSuffix MODULE_SUFFIX_STRING split '.').last split + Pattern.quote(NAME_JOIN_STRING)).last /** The mapping from the integer used to identify values to the actual * values. */ diff --git a/src/library/scala/Float.scala b/src/library/scala/Float.scala index ff5b3cb112..bb03581062 100644 --- a/src/library/scala/Float.scala +++ b/src/library/scala/Float.scala @@ -17,7 +17,7 @@ package scala * There is an implicit conversion from [[scala.Float]] => [[scala.runtime.RichFloat]] * which provides useful non-primitive operations. */ -final class Float extends AnyVal { +final class Float private extends AnyVal { def toByte: Byte = sys.error("stub") def toShort: Short = sys.error("stub") def toChar: Char = sys.error("stub") @@ -27,339 +27,339 @@ final class Float extends AnyVal { def toDouble: Double = sys.error("stub") /** - * @return this value, unmodified + * Returns this value, unmodified. */ def unary_+ : Float = sys.error("stub") /** - * @return the negation of this value + * Returns the negation of this value. */ def unary_- : Float = sys.error("stub") def +(x: String): String = sys.error("stub") /** - * @return `true` if this value is equal x, `false` otherwise + * Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Byte): Boolean = sys.error("stub") /** - * @return `true` if this value is equal x, `false` otherwise + * Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Short): Boolean = sys.error("stub") /** - * @return `true` if this value is equal x, `false` otherwise + * Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Char): Boolean = sys.error("stub") /** - * @return `true` if this value is equal x, `false` otherwise + * Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Int): Boolean = sys.error("stub") /** - * @return `true` if this value is equal x, `false` otherwise + * Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Long): Boolean = sys.error("stub") /** - * @return `true` if this value is equal x, `false` otherwise + * Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Float): Boolean = sys.error("stub") /** - * @return `true` if this value is equal x, `false` otherwise + * Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Double): Boolean = sys.error("stub") /** - * @return `true` if this value is not equal to x, `false` otherwise + * Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Byte): Boolean = sys.error("stub") /** - * @return `true` if this value is not equal to x, `false` otherwise + * Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Short): Boolean = sys.error("stub") /** - * @return `true` if this value is not equal to x, `false` otherwise + * Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Char): Boolean = sys.error("stub") /** - * @return `true` if this value is not equal to x, `false` otherwise + * Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Int): Boolean = sys.error("stub") /** - * @return `true` if this value is not equal to x, `false` otherwise + * Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Long): Boolean = sys.error("stub") /** - * @return `true` if this value is not equal to x, `false` otherwise + * Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Float): Boolean = sys.error("stub") /** - * @return `true` if this value is not equal to x, `false` otherwise + * Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Double): Boolean = sys.error("stub") /** - * @return `true` if this value is less than x, `false` otherwise + * Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Byte): Boolean = sys.error("stub") /** - * @return `true` if this value is less than x, `false` otherwise + * Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Short): Boolean = sys.error("stub") /** - * @return `true` if this value is less than x, `false` otherwise + * Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Char): Boolean = sys.error("stub") /** - * @return `true` if this value is less than x, `false` otherwise + * Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Int): Boolean = sys.error("stub") /** - * @return `true` if this value is less than x, `false` otherwise + * Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Long): Boolean = sys.error("stub") /** - * @return `true` if this value is less than x, `false` otherwise + * Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Float): Boolean = sys.error("stub") /** - * @return `true` if this value is less than x, `false` otherwise + * Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Double): Boolean = sys.error("stub") /** - * @return `true` if this value is less than or equal to x, `false` otherwise + * Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Byte): Boolean = sys.error("stub") /** - * @return `true` if this value is less than or equal to x, `false` otherwise + * Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Short): Boolean = sys.error("stub") /** - * @return `true` if this value is less than or equal to x, `false` otherwise + * Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Char): Boolean = sys.error("stub") /** - * @return `true` if this value is less than or equal to x, `false` otherwise + * Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Int): Boolean = sys.error("stub") /** - * @return `true` if this value is less than or equal to x, `false` otherwise + * Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Long): Boolean = sys.error("stub") /** - * @return `true` if this value is less than or equal to x, `false` otherwise + * Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Float): Boolean = sys.error("stub") /** - * @return `true` if this value is less than or equal to x, `false` otherwise + * Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Double): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than x, `false` otherwise + * Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Byte): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than x, `false` otherwise + * Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Short): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than x, `false` otherwise + * Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Char): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than x, `false` otherwise + * Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Int): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than x, `false` otherwise + * Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Long): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than x, `false` otherwise + * Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Float): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than x, `false` otherwise + * Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Double): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than or equal to x, `false` otherwise + * Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Byte): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than or equal to x, `false` otherwise + * Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Short): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than or equal to x, `false` otherwise + * Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Char): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than or equal to x, `false` otherwise + * Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Int): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than or equal to x, `false` otherwise + * Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Long): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than or equal to x, `false` otherwise + * Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Float): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than or equal to x, `false` otherwise + * Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Double): Boolean = sys.error("stub") /** - * @return the sum of this value and x + * Returns the sum of this value and `x`. */ def +(x: Byte): Float = sys.error("stub") /** - * @return the sum of this value and x + * Returns the sum of this value and `x`. */ def +(x: Short): Float = sys.error("stub") /** - * @return the sum of this value and x + * Returns the sum of this value and `x`. */ def +(x: Char): Float = sys.error("stub") /** - * @return the sum of this value and x + * Returns the sum of this value and `x`. */ def +(x: Int): Float = sys.error("stub") /** - * @return the sum of this value and x + * Returns the sum of this value and `x`. */ def +(x: Long): Float = sys.error("stub") /** - * @return the sum of this value and x + * Returns the sum of this value and `x`. */ def +(x: Float): Float = sys.error("stub") /** - * @return the sum of this value and x + * Returns the sum of this value and `x`. */ def +(x: Double): Double = sys.error("stub") /** - * @return the difference of this value and x + * Returns the difference of this value and `x`. */ def -(x: Byte): Float = sys.error("stub") /** - * @return the difference of this value and x + * Returns the difference of this value and `x`. */ def -(x: Short): Float = sys.error("stub") /** - * @return the difference of this value and x + * Returns the difference of this value and `x`. */ def -(x: Char): Float = sys.error("stub") /** - * @return the difference of this value and x + * Returns the difference of this value and `x`. */ def -(x: Int): Float = sys.error("stub") /** - * @return the difference of this value and x + * Returns the difference of this value and `x`. */ def -(x: Long): Float = sys.error("stub") /** - * @return the difference of this value and x + * Returns the difference of this value and `x`. */ def -(x: Float): Float = sys.error("stub") /** - * @return the difference of this value and x + * Returns the difference of this value and `x`. */ def -(x: Double): Double = sys.error("stub") /** - * @return the product of this value and x + * Returns the product of this value and `x`. */ def *(x: Byte): Float = sys.error("stub") /** - * @return the product of this value and x + * Returns the product of this value and `x`. */ def *(x: Short): Float = sys.error("stub") /** - * @return the product of this value and x + * Returns the product of this value and `x`. */ def *(x: Char): Float = sys.error("stub") /** - * @return the product of this value and x + * Returns the product of this value and `x`. */ def *(x: Int): Float = sys.error("stub") /** - * @return the product of this value and x + * Returns the product of this value and `x`. */ def *(x: Long): Float = sys.error("stub") /** - * @return the product of this value and x + * Returns the product of this value and `x`. */ def *(x: Float): Float = sys.error("stub") /** - * @return the product of this value and x + * Returns the product of this value and `x`. */ def *(x: Double): Double = sys.error("stub") /** - * @return the quotient of this value and x + * Returns the quotient of this value and `x`. */ def /(x: Byte): Float = sys.error("stub") /** - * @return the quotient of this value and x + * Returns the quotient of this value and `x`. */ def /(x: Short): Float = sys.error("stub") /** - * @return the quotient of this value and x + * Returns the quotient of this value and `x`. */ def /(x: Char): Float = sys.error("stub") /** - * @return the quotient of this value and x + * Returns the quotient of this value and `x`. */ def /(x: Int): Float = sys.error("stub") /** - * @return the quotient of this value and x + * Returns the quotient of this value and `x`. */ def /(x: Long): Float = sys.error("stub") /** - * @return the quotient of this value and x + * Returns the quotient of this value and `x`. */ def /(x: Float): Float = sys.error("stub") /** - * @return the quotient of this value and x + * Returns the quotient of this value and `x`. */ def /(x: Double): Double = sys.error("stub") /** - * @return the remainder of the division of this value by x + * Returns the remainder of the division of this value by `x`. */ def %(x: Byte): Float = sys.error("stub") /** - * @return the remainder of the division of this value by x + * Returns the remainder of the division of this value by `x`. */ def %(x: Short): Float = sys.error("stub") /** - * @return the remainder of the division of this value by x + * Returns the remainder of the division of this value by `x`. */ def %(x: Char): Float = sys.error("stub") /** - * @return the remainder of the division of this value by x + * Returns the remainder of the division of this value by `x`. */ def %(x: Int): Float = sys.error("stub") /** - * @return the remainder of the division of this value by x + * Returns the remainder of the division of this value by `x`. */ def %(x: Long): Float = sys.error("stub") /** - * @return the remainder of the division of this value by x + * Returns the remainder of the division of this value by `x`. */ def %(x: Float): Float = sys.error("stub") /** - * @return the remainder of the division of this value by x + * Returns the remainder of the division of this value by `x`. */ def %(x: Double): Double = sys.error("stub") override def getClass(): Class[Float] = sys.error("stub") } -object Float extends AnyValCompanion { +object Float extends AnyValCompanion { /** The smallest positive value greater than 0.0f which is * representable as a Float. */ @@ -401,5 +401,6 @@ object Float extends AnyValCompanion { /** The String representation of the scala.Float companion object. */ override def toString = "object scala.Float" + implicit def float2double(x: Float): Double = x.toDouble } diff --git a/src/library/scala/Int.scala b/src/library/scala/Int.scala index 316bbced2d..d5d7ef011d 100644 --- a/src/library/scala/Int.scala +++ b/src/library/scala/Int.scala @@ -17,7 +17,7 @@ package scala * There is an implicit conversion from [[scala.Int]] => [[scala.runtime.RichInt]] * which provides useful non-primitive operations. */ -final class Int extends AnyVal { +final class Int private extends AnyVal { def toByte: Byte = sys.error("stub") def toShort: Short = sys.error("stub") def toChar: Char = sys.error("stub") @@ -27,7 +27,7 @@ final class Int extends AnyVal { def toDouble: Double = sys.error("stub") /** - * @return the bitwise negation of this value + * Returns the bitwise negation of this value. * @example {{{ * ~5 == -6 * // in binary: ~00000101 == @@ -36,30 +36,30 @@ final class Int extends AnyVal { */ def unary_~ : Int = sys.error("stub") /** - * @return this value, unmodified + * Returns this value, unmodified. */ def unary_+ : Int = sys.error("stub") /** - * @return the negation of this value + * Returns the negation of this value. */ def unary_- : Int = sys.error("stub") def +(x: String): String = sys.error("stub") /** - * @return this value bit-shifted left by the specified number of bits, + * Returns this value bit-shifted left by the specified number of bits, * filling in the new right bits with zeroes. * @example {{{ 6 << 3 == 48 // in binary: 0110 << 3 == 0110000 }}} */ def <<(x: Int): Int = sys.error("stub") /** - * @return this value bit-shifted left by the specified number of bits, + * Returns this value bit-shifted left by the specified number of bits, * filling in the new right bits with zeroes. * @example {{{ 6 << 3 == 48 // in binary: 0110 << 3 == 0110000 }}} */ def <<(x: Long): Int = sys.error("stub") /** - * @return this value bit-shifted right by the specified number of bits, + * Returns this value bit-shifted right by the specified number of bits, * filling the new left bits with zeroes. * @example {{{ 21 >>> 3 == 2 // in binary: 010101 >>> 3 == 010 }}} * @example {{{ @@ -70,7 +70,7 @@ final class Int extends AnyVal { */ def >>>(x: Int): Int = sys.error("stub") /** - * @return this value bit-shifted right by the specified number of bits, + * Returns this value bit-shifted right by the specified number of bits, * filling the new left bits with zeroes. * @example {{{ 21 >>> 3 == 2 // in binary: 010101 >>> 3 == 010 }}} * @example {{{ @@ -81,7 +81,7 @@ final class Int extends AnyVal { */ def >>>(x: Long): Int = sys.error("stub") /** - * @return this value bit-shifted left by the specified number of bits, + * Returns this value bit-shifted left by the specified number of bits, * filling in the right bits with the same value as the left-most bit of this. * The effect of this is to retain the sign of the value. * @example {{{ @@ -92,7 +92,7 @@ final class Int extends AnyVal { */ def >>(x: Int): Int = sys.error("stub") /** - * @return this value bit-shifted left by the specified number of bits, + * Returns this value bit-shifted left by the specified number of bits, * filling in the right bits with the same value as the left-most bit of this. * The effect of this is to retain the sign of the value. * @example {{{ @@ -104,181 +104,181 @@ final class Int extends AnyVal { def >>(x: Long): Int = sys.error("stub") /** - * @return `true` if this value is equal x, `false` otherwise + * Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Byte): Boolean = sys.error("stub") /** - * @return `true` if this value is equal x, `false` otherwise + * Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Short): Boolean = sys.error("stub") /** - * @return `true` if this value is equal x, `false` otherwise + * Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Char): Boolean = sys.error("stub") /** - * @return `true` if this value is equal x, `false` otherwise + * Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Int): Boolean = sys.error("stub") /** - * @return `true` if this value is equal x, `false` otherwise + * Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Long): Boolean = sys.error("stub") /** - * @return `true` if this value is equal x, `false` otherwise + * Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Float): Boolean = sys.error("stub") /** - * @return `true` if this value is equal x, `false` otherwise + * Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Double): Boolean = sys.error("stub") /** - * @return `true` if this value is not equal to x, `false` otherwise + * Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Byte): Boolean = sys.error("stub") /** - * @return `true` if this value is not equal to x, `false` otherwise + * Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Short): Boolean = sys.error("stub") /** - * @return `true` if this value is not equal to x, `false` otherwise + * Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Char): Boolean = sys.error("stub") /** - * @return `true` if this value is not equal to x, `false` otherwise + * Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Int): Boolean = sys.error("stub") /** - * @return `true` if this value is not equal to x, `false` otherwise + * Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Long): Boolean = sys.error("stub") /** - * @return `true` if this value is not equal to x, `false` otherwise + * Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Float): Boolean = sys.error("stub") /** - * @return `true` if this value is not equal to x, `false` otherwise + * Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Double): Boolean = sys.error("stub") /** - * @return `true` if this value is less than x, `false` otherwise + * Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Byte): Boolean = sys.error("stub") /** - * @return `true` if this value is less than x, `false` otherwise + * Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Short): Boolean = sys.error("stub") /** - * @return `true` if this value is less than x, `false` otherwise + * Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Char): Boolean = sys.error("stub") /** - * @return `true` if this value is less than x, `false` otherwise + * Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Int): Boolean = sys.error("stub") /** - * @return `true` if this value is less than x, `false` otherwise + * Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Long): Boolean = sys.error("stub") /** - * @return `true` if this value is less than x, `false` otherwise + * Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Float): Boolean = sys.error("stub") /** - * @return `true` if this value is less than x, `false` otherwise + * Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Double): Boolean = sys.error("stub") /** - * @return `true` if this value is less than or equal to x, `false` otherwise + * Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Byte): Boolean = sys.error("stub") /** - * @return `true` if this value is less than or equal to x, `false` otherwise + * Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Short): Boolean = sys.error("stub") /** - * @return `true` if this value is less than or equal to x, `false` otherwise + * Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Char): Boolean = sys.error("stub") /** - * @return `true` if this value is less than or equal to x, `false` otherwise + * Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Int): Boolean = sys.error("stub") /** - * @return `true` if this value is less than or equal to x, `false` otherwise + * Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Long): Boolean = sys.error("stub") /** - * @return `true` if this value is less than or equal to x, `false` otherwise + * Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Float): Boolean = sys.error("stub") /** - * @return `true` if this value is less than or equal to x, `false` otherwise + * Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Double): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than x, `false` otherwise + * Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Byte): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than x, `false` otherwise + * Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Short): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than x, `false` otherwise + * Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Char): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than x, `false` otherwise + * Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Int): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than x, `false` otherwise + * Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Long): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than x, `false` otherwise + * Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Float): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than x, `false` otherwise + * Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Double): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than or equal to x, `false` otherwise + * Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Byte): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than or equal to x, `false` otherwise + * Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Short): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than or equal to x, `false` otherwise + * Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Char): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than or equal to x, `false` otherwise + * Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Int): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than or equal to x, `false` otherwise + * Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Long): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than or equal to x, `false` otherwise + * Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Float): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than or equal to x, `false` otherwise + * Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Double): Boolean = sys.error("stub") /** - * @return the bitwise OR of this value and x + * Returns the bitwise OR of this value and `x`. * @example {{{ * (0xf0 | 0xaa) == 0xfa * // in binary: 11110000 @@ -289,7 +289,7 @@ final class Int extends AnyVal { */ def |(x: Byte): Int = sys.error("stub") /** - * @return the bitwise OR of this value and x + * Returns the bitwise OR of this value and `x`. * @example {{{ * (0xf0 | 0xaa) == 0xfa * // in binary: 11110000 @@ -300,7 +300,7 @@ final class Int extends AnyVal { */ def |(x: Short): Int = sys.error("stub") /** - * @return the bitwise OR of this value and x + * Returns the bitwise OR of this value and `x`. * @example {{{ * (0xf0 | 0xaa) == 0xfa * // in binary: 11110000 @@ -311,7 +311,7 @@ final class Int extends AnyVal { */ def |(x: Char): Int = sys.error("stub") /** - * @return the bitwise OR of this value and x + * Returns the bitwise OR of this value and `x`. * @example {{{ * (0xf0 | 0xaa) == 0xfa * // in binary: 11110000 @@ -322,7 +322,7 @@ final class Int extends AnyVal { */ def |(x: Int): Int = sys.error("stub") /** - * @return the bitwise OR of this value and x + * Returns the bitwise OR of this value and `x`. * @example {{{ * (0xf0 | 0xaa) == 0xfa * // in binary: 11110000 @@ -334,7 +334,7 @@ final class Int extends AnyVal { def |(x: Long): Long = sys.error("stub") /** - * @return the bitwise AND of this value and x + * Returns the bitwise AND of this value and `x`. * @example {{{ * (0xf0 & 0xaa) == 0xa0 * // in binary: 11110000 @@ -345,7 +345,7 @@ final class Int extends AnyVal { */ def &(x: Byte): Int = sys.error("stub") /** - * @return the bitwise AND of this value and x + * Returns the bitwise AND of this value and `x`. * @example {{{ * (0xf0 & 0xaa) == 0xa0 * // in binary: 11110000 @@ -356,7 +356,7 @@ final class Int extends AnyVal { */ def &(x: Short): Int = sys.error("stub") /** - * @return the bitwise AND of this value and x + * Returns the bitwise AND of this value and `x`. * @example {{{ * (0xf0 & 0xaa) == 0xa0 * // in binary: 11110000 @@ -367,7 +367,7 @@ final class Int extends AnyVal { */ def &(x: Char): Int = sys.error("stub") /** - * @return the bitwise AND of this value and x + * Returns the bitwise AND of this value and `x`. * @example {{{ * (0xf0 & 0xaa) == 0xa0 * // in binary: 11110000 @@ -378,7 +378,7 @@ final class Int extends AnyVal { */ def &(x: Int): Int = sys.error("stub") /** - * @return the bitwise AND of this value and x + * Returns the bitwise AND of this value and `x`. * @example {{{ * (0xf0 & 0xaa) == 0xa0 * // in binary: 11110000 @@ -390,7 +390,7 @@ final class Int extends AnyVal { def &(x: Long): Long = sys.error("stub") /** - * @return the bitwise XOR of this value and x + * Returns the bitwise XOR of this value and `x`. * @example {{{ * (0xf0 ^ 0xaa) == 0x5a * // in binary: 11110000 @@ -401,7 +401,7 @@ final class Int extends AnyVal { */ def ^(x: Byte): Int = sys.error("stub") /** - * @return the bitwise XOR of this value and x + * Returns the bitwise XOR of this value and `x`. * @example {{{ * (0xf0 ^ 0xaa) == 0x5a * // in binary: 11110000 @@ -412,7 +412,7 @@ final class Int extends AnyVal { */ def ^(x: Short): Int = sys.error("stub") /** - * @return the bitwise XOR of this value and x + * Returns the bitwise XOR of this value and `x`. * @example {{{ * (0xf0 ^ 0xaa) == 0x5a * // in binary: 11110000 @@ -423,7 +423,7 @@ final class Int extends AnyVal { */ def ^(x: Char): Int = sys.error("stub") /** - * @return the bitwise XOR of this value and x + * Returns the bitwise XOR of this value and `x`. * @example {{{ * (0xf0 ^ 0xaa) == 0x5a * // in binary: 11110000 @@ -434,7 +434,7 @@ final class Int extends AnyVal { */ def ^(x: Int): Int = sys.error("stub") /** - * @return the bitwise XOR of this value and x + * Returns the bitwise XOR of this value and `x`. * @example {{{ * (0xf0 ^ 0xaa) == 0x5a * // in binary: 11110000 @@ -446,154 +446,154 @@ final class Int extends AnyVal { def ^(x: Long): Long = sys.error("stub") /** - * @return the sum of this value and x + * Returns the sum of this value and `x`. */ def +(x: Byte): Int = sys.error("stub") /** - * @return the sum of this value and x + * Returns the sum of this value and `x`. */ def +(x: Short): Int = sys.error("stub") /** - * @return the sum of this value and x + * Returns the sum of this value and `x`. */ def +(x: Char): Int = sys.error("stub") /** - * @return the sum of this value and x + * Returns the sum of this value and `x`. */ def +(x: Int): Int = sys.error("stub") /** - * @return the sum of this value and x + * Returns the sum of this value and `x`. */ def +(x: Long): Long = sys.error("stub") /** - * @return the sum of this value and x + * Returns the sum of this value and `x`. */ def +(x: Float): Float = sys.error("stub") /** - * @return the sum of this value and x + * Returns the sum of this value and `x`. */ def +(x: Double): Double = sys.error("stub") /** - * @return the difference of this value and x + * Returns the difference of this value and `x`. */ def -(x: Byte): Int = sys.error("stub") /** - * @return the difference of this value and x + * Returns the difference of this value and `x`. */ def -(x: Short): Int = sys.error("stub") /** - * @return the difference of this value and x + * Returns the difference of this value and `x`. */ def -(x: Char): Int = sys.error("stub") /** - * @return the difference of this value and x + * Returns the difference of this value and `x`. */ def -(x: Int): Int = sys.error("stub") /** - * @return the difference of this value and x + * Returns the difference of this value and `x`. */ def -(x: Long): Long = sys.error("stub") /** - * @return the difference of this value and x + * Returns the difference of this value and `x`. */ def -(x: Float): Float = sys.error("stub") /** - * @return the difference of this value and x + * Returns the difference of this value and `x`. */ def -(x: Double): Double = sys.error("stub") /** - * @return the product of this value and x + * Returns the product of this value and `x`. */ def *(x: Byte): Int = sys.error("stub") /** - * @return the product of this value and x + * Returns the product of this value and `x`. */ def *(x: Short): Int = sys.error("stub") /** - * @return the product of this value and x + * Returns the product of this value and `x`. */ def *(x: Char): Int = sys.error("stub") /** - * @return the product of this value and x + * Returns the product of this value and `x`. */ def *(x: Int): Int = sys.error("stub") /** - * @return the product of this value and x + * Returns the product of this value and `x`. */ def *(x: Long): Long = sys.error("stub") /** - * @return the product of this value and x + * Returns the product of this value and `x`. */ def *(x: Float): Float = sys.error("stub") /** - * @return the product of this value and x + * Returns the product of this value and `x`. */ def *(x: Double): Double = sys.error("stub") /** - * @return the quotient of this value and x + * Returns the quotient of this value and `x`. */ def /(x: Byte): Int = sys.error("stub") /** - * @return the quotient of this value and x + * Returns the quotient of this value and `x`. */ def /(x: Short): Int = sys.error("stub") /** - * @return the quotient of this value and x + * Returns the quotient of this value and `x`. */ def /(x: Char): Int = sys.error("stub") /** - * @return the quotient of this value and x + * Returns the quotient of this value and `x`. */ def /(x: Int): Int = sys.error("stub") /** - * @return the quotient of this value and x + * Returns the quotient of this value and `x`. */ def /(x: Long): Long = sys.error("stub") /** - * @return the quotient of this value and x + * Returns the quotient of this value and `x`. */ def /(x: Float): Float = sys.error("stub") /** - * @return the quotient of this value and x + * Returns the quotient of this value and `x`. */ def /(x: Double): Double = sys.error("stub") /** - * @return the remainder of the division of this value by x + * Returns the remainder of the division of this value by `x`. */ def %(x: Byte): Int = sys.error("stub") /** - * @return the remainder of the division of this value by x + * Returns the remainder of the division of this value by `x`. */ def %(x: Short): Int = sys.error("stub") /** - * @return the remainder of the division of this value by x + * Returns the remainder of the division of this value by `x`. */ def %(x: Char): Int = sys.error("stub") /** - * @return the remainder of the division of this value by x + * Returns the remainder of the division of this value by `x`. */ def %(x: Int): Int = sys.error("stub") /** - * @return the remainder of the division of this value by x + * Returns the remainder of the division of this value by `x`. */ def %(x: Long): Long = sys.error("stub") /** - * @return the remainder of the division of this value by x + * Returns the remainder of the division of this value by `x`. */ def %(x: Float): Float = sys.error("stub") /** - * @return the remainder of the division of this value by x + * Returns the remainder of the division of this value by `x`. */ def %(x: Double): Double = sys.error("stub") override def getClass(): Class[Int] = sys.error("stub") } -object Int extends AnyValCompanion { +object Int extends AnyValCompanion { /** The smallest value representable as a Int. */ final val MinValue = java.lang.Integer.MIN_VALUE @@ -622,5 +622,8 @@ object Int extends AnyValCompanion { /** The String representation of the scala.Int companion object. */ override def toString = "object scala.Int" + implicit def int2long(x: Int): Long = x.toLong + implicit def int2float(x: Int): Float = x.toFloat + implicit def int2double(x: Int): Double = x.toDouble } diff --git a/src/library/scala/Long.scala b/src/library/scala/Long.scala index ce8618c22a..85131b4f54 100644 --- a/src/library/scala/Long.scala +++ b/src/library/scala/Long.scala @@ -17,7 +17,7 @@ package scala * There is an implicit conversion from [[scala.Long]] => [[scala.runtime.RichLong]] * which provides useful non-primitive operations. */ -final class Long extends AnyVal { +final class Long private extends AnyVal { def toByte: Byte = sys.error("stub") def toShort: Short = sys.error("stub") def toChar: Char = sys.error("stub") @@ -27,7 +27,7 @@ final class Long extends AnyVal { def toDouble: Double = sys.error("stub") /** - * @return the bitwise negation of this value + * Returns the bitwise negation of this value. * @example {{{ * ~5 == -6 * // in binary: ~00000101 == @@ -36,30 +36,30 @@ final class Long extends AnyVal { */ def unary_~ : Long = sys.error("stub") /** - * @return this value, unmodified + * Returns this value, unmodified. */ def unary_+ : Long = sys.error("stub") /** - * @return the negation of this value + * Returns the negation of this value. */ def unary_- : Long = sys.error("stub") def +(x: String): String = sys.error("stub") /** - * @return this value bit-shifted left by the specified number of bits, + * Returns this value bit-shifted left by the specified number of bits, * filling in the new right bits with zeroes. * @example {{{ 6 << 3 == 48 // in binary: 0110 << 3 == 0110000 }}} */ def <<(x: Int): Long = sys.error("stub") /** - * @return this value bit-shifted left by the specified number of bits, + * Returns this value bit-shifted left by the specified number of bits, * filling in the new right bits with zeroes. * @example {{{ 6 << 3 == 48 // in binary: 0110 << 3 == 0110000 }}} */ def <<(x: Long): Long = sys.error("stub") /** - * @return this value bit-shifted right by the specified number of bits, + * Returns this value bit-shifted right by the specified number of bits, * filling the new left bits with zeroes. * @example {{{ 21 >>> 3 == 2 // in binary: 010101 >>> 3 == 010 }}} * @example {{{ @@ -70,7 +70,7 @@ final class Long extends AnyVal { */ def >>>(x: Int): Long = sys.error("stub") /** - * @return this value bit-shifted right by the specified number of bits, + * Returns this value bit-shifted right by the specified number of bits, * filling the new left bits with zeroes. * @example {{{ 21 >>> 3 == 2 // in binary: 010101 >>> 3 == 010 }}} * @example {{{ @@ -81,7 +81,7 @@ final class Long extends AnyVal { */ def >>>(x: Long): Long = sys.error("stub") /** - * @return this value bit-shifted left by the specified number of bits, + * Returns this value bit-shifted left by the specified number of bits, * filling in the right bits with the same value as the left-most bit of this. * The effect of this is to retain the sign of the value. * @example {{{ @@ -92,7 +92,7 @@ final class Long extends AnyVal { */ def >>(x: Int): Long = sys.error("stub") /** - * @return this value bit-shifted left by the specified number of bits, + * Returns this value bit-shifted left by the specified number of bits, * filling in the right bits with the same value as the left-most bit of this. * The effect of this is to retain the sign of the value. * @example {{{ @@ -104,181 +104,181 @@ final class Long extends AnyVal { def >>(x: Long): Long = sys.error("stub") /** - * @return `true` if this value is equal x, `false` otherwise + * Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Byte): Boolean = sys.error("stub") /** - * @return `true` if this value is equal x, `false` otherwise + * Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Short): Boolean = sys.error("stub") /** - * @return `true` if this value is equal x, `false` otherwise + * Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Char): Boolean = sys.error("stub") /** - * @return `true` if this value is equal x, `false` otherwise + * Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Int): Boolean = sys.error("stub") /** - * @return `true` if this value is equal x, `false` otherwise + * Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Long): Boolean = sys.error("stub") /** - * @return `true` if this value is equal x, `false` otherwise + * Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Float): Boolean = sys.error("stub") /** - * @return `true` if this value is equal x, `false` otherwise + * Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Double): Boolean = sys.error("stub") /** - * @return `true` if this value is not equal to x, `false` otherwise + * Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Byte): Boolean = sys.error("stub") /** - * @return `true` if this value is not equal to x, `false` otherwise + * Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Short): Boolean = sys.error("stub") /** - * @return `true` if this value is not equal to x, `false` otherwise + * Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Char): Boolean = sys.error("stub") /** - * @return `true` if this value is not equal to x, `false` otherwise + * Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Int): Boolean = sys.error("stub") /** - * @return `true` if this value is not equal to x, `false` otherwise + * Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Long): Boolean = sys.error("stub") /** - * @return `true` if this value is not equal to x, `false` otherwise + * Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Float): Boolean = sys.error("stub") /** - * @return `true` if this value is not equal to x, `false` otherwise + * Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Double): Boolean = sys.error("stub") /** - * @return `true` if this value is less than x, `false` otherwise + * Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Byte): Boolean = sys.error("stub") /** - * @return `true` if this value is less than x, `false` otherwise + * Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Short): Boolean = sys.error("stub") /** - * @return `true` if this value is less than x, `false` otherwise + * Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Char): Boolean = sys.error("stub") /** - * @return `true` if this value is less than x, `false` otherwise + * Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Int): Boolean = sys.error("stub") /** - * @return `true` if this value is less than x, `false` otherwise + * Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Long): Boolean = sys.error("stub") /** - * @return `true` if this value is less than x, `false` otherwise + * Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Float): Boolean = sys.error("stub") /** - * @return `true` if this value is less than x, `false` otherwise + * Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Double): Boolean = sys.error("stub") /** - * @return `true` if this value is less than or equal to x, `false` otherwise + * Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Byte): Boolean = sys.error("stub") /** - * @return `true` if this value is less than or equal to x, `false` otherwise + * Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Short): Boolean = sys.error("stub") /** - * @return `true` if this value is less than or equal to x, `false` otherwise + * Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Char): Boolean = sys.error("stub") /** - * @return `true` if this value is less than or equal to x, `false` otherwise + * Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Int): Boolean = sys.error("stub") /** - * @return `true` if this value is less than or equal to x, `false` otherwise + * Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Long): Boolean = sys.error("stub") /** - * @return `true` if this value is less than or equal to x, `false` otherwise + * Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Float): Boolean = sys.error("stub") /** - * @return `true` if this value is less than or equal to x, `false` otherwise + * Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Double): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than x, `false` otherwise + * Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Byte): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than x, `false` otherwise + * Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Short): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than x, `false` otherwise + * Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Char): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than x, `false` otherwise + * Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Int): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than x, `false` otherwise + * Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Long): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than x, `false` otherwise + * Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Float): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than x, `false` otherwise + * Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Double): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than or equal to x, `false` otherwise + * Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Byte): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than or equal to x, `false` otherwise + * Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Short): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than or equal to x, `false` otherwise + * Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Char): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than or equal to x, `false` otherwise + * Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Int): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than or equal to x, `false` otherwise + * Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Long): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than or equal to x, `false` otherwise + * Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Float): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than or equal to x, `false` otherwise + * Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Double): Boolean = sys.error("stub") /** - * @return the bitwise OR of this value and x + * Returns the bitwise OR of this value and `x`. * @example {{{ * (0xf0 | 0xaa) == 0xfa * // in binary: 11110000 @@ -289,7 +289,7 @@ final class Long extends AnyVal { */ def |(x: Byte): Long = sys.error("stub") /** - * @return the bitwise OR of this value and x + * Returns the bitwise OR of this value and `x`. * @example {{{ * (0xf0 | 0xaa) == 0xfa * // in binary: 11110000 @@ -300,7 +300,7 @@ final class Long extends AnyVal { */ def |(x: Short): Long = sys.error("stub") /** - * @return the bitwise OR of this value and x + * Returns the bitwise OR of this value and `x`. * @example {{{ * (0xf0 | 0xaa) == 0xfa * // in binary: 11110000 @@ -311,7 +311,7 @@ final class Long extends AnyVal { */ def |(x: Char): Long = sys.error("stub") /** - * @return the bitwise OR of this value and x + * Returns the bitwise OR of this value and `x`. * @example {{{ * (0xf0 | 0xaa) == 0xfa * // in binary: 11110000 @@ -322,7 +322,7 @@ final class Long extends AnyVal { */ def |(x: Int): Long = sys.error("stub") /** - * @return the bitwise OR of this value and x + * Returns the bitwise OR of this value and `x`. * @example {{{ * (0xf0 | 0xaa) == 0xfa * // in binary: 11110000 @@ -334,7 +334,7 @@ final class Long extends AnyVal { def |(x: Long): Long = sys.error("stub") /** - * @return the bitwise AND of this value and x + * Returns the bitwise AND of this value and `x`. * @example {{{ * (0xf0 & 0xaa) == 0xa0 * // in binary: 11110000 @@ -345,7 +345,7 @@ final class Long extends AnyVal { */ def &(x: Byte): Long = sys.error("stub") /** - * @return the bitwise AND of this value and x + * Returns the bitwise AND of this value and `x`. * @example {{{ * (0xf0 & 0xaa) == 0xa0 * // in binary: 11110000 @@ -356,7 +356,7 @@ final class Long extends AnyVal { */ def &(x: Short): Long = sys.error("stub") /** - * @return the bitwise AND of this value and x + * Returns the bitwise AND of this value and `x`. * @example {{{ * (0xf0 & 0xaa) == 0xa0 * // in binary: 11110000 @@ -367,7 +367,7 @@ final class Long extends AnyVal { */ def &(x: Char): Long = sys.error("stub") /** - * @return the bitwise AND of this value and x + * Returns the bitwise AND of this value and `x`. * @example {{{ * (0xf0 & 0xaa) == 0xa0 * // in binary: 11110000 @@ -378,7 +378,7 @@ final class Long extends AnyVal { */ def &(x: Int): Long = sys.error("stub") /** - * @return the bitwise AND of this value and x + * Returns the bitwise AND of this value and `x`. * @example {{{ * (0xf0 & 0xaa) == 0xa0 * // in binary: 11110000 @@ -390,7 +390,7 @@ final class Long extends AnyVal { def &(x: Long): Long = sys.error("stub") /** - * @return the bitwise XOR of this value and x + * Returns the bitwise XOR of this value and `x`. * @example {{{ * (0xf0 ^ 0xaa) == 0x5a * // in binary: 11110000 @@ -401,7 +401,7 @@ final class Long extends AnyVal { */ def ^(x: Byte): Long = sys.error("stub") /** - * @return the bitwise XOR of this value and x + * Returns the bitwise XOR of this value and `x`. * @example {{{ * (0xf0 ^ 0xaa) == 0x5a * // in binary: 11110000 @@ -412,7 +412,7 @@ final class Long extends AnyVal { */ def ^(x: Short): Long = sys.error("stub") /** - * @return the bitwise XOR of this value and x + * Returns the bitwise XOR of this value and `x`. * @example {{{ * (0xf0 ^ 0xaa) == 0x5a * // in binary: 11110000 @@ -423,7 +423,7 @@ final class Long extends AnyVal { */ def ^(x: Char): Long = sys.error("stub") /** - * @return the bitwise XOR of this value and x + * Returns the bitwise XOR of this value and `x`. * @example {{{ * (0xf0 ^ 0xaa) == 0x5a * // in binary: 11110000 @@ -434,7 +434,7 @@ final class Long extends AnyVal { */ def ^(x: Int): Long = sys.error("stub") /** - * @return the bitwise XOR of this value and x + * Returns the bitwise XOR of this value and `x`. * @example {{{ * (0xf0 ^ 0xaa) == 0x5a * // in binary: 11110000 @@ -446,154 +446,154 @@ final class Long extends AnyVal { def ^(x: Long): Long = sys.error("stub") /** - * @return the sum of this value and x + * Returns the sum of this value and `x`. */ def +(x: Byte): Long = sys.error("stub") /** - * @return the sum of this value and x + * Returns the sum of this value and `x`. */ def +(x: Short): Long = sys.error("stub") /** - * @return the sum of this value and x + * Returns the sum of this value and `x`. */ def +(x: Char): Long = sys.error("stub") /** - * @return the sum of this value and x + * Returns the sum of this value and `x`. */ def +(x: Int): Long = sys.error("stub") /** - * @return the sum of this value and x + * Returns the sum of this value and `x`. */ def +(x: Long): Long = sys.error("stub") /** - * @return the sum of this value and x + * Returns the sum of this value and `x`. */ def +(x: Float): Float = sys.error("stub") /** - * @return the sum of this value and x + * Returns the sum of this value and `x`. */ def +(x: Double): Double = sys.error("stub") /** - * @return the difference of this value and x + * Returns the difference of this value and `x`. */ def -(x: Byte): Long = sys.error("stub") /** - * @return the difference of this value and x + * Returns the difference of this value and `x`. */ def -(x: Short): Long = sys.error("stub") /** - * @return the difference of this value and x + * Returns the difference of this value and `x`. */ def -(x: Char): Long = sys.error("stub") /** - * @return the difference of this value and x + * Returns the difference of this value and `x`. */ def -(x: Int): Long = sys.error("stub") /** - * @return the difference of this value and x + * Returns the difference of this value and `x`. */ def -(x: Long): Long = sys.error("stub") /** - * @return the difference of this value and x + * Returns the difference of this value and `x`. */ def -(x: Float): Float = sys.error("stub") /** - * @return the difference of this value and x + * Returns the difference of this value and `x`. */ def -(x: Double): Double = sys.error("stub") /** - * @return the product of this value and x + * Returns the product of this value and `x`. */ def *(x: Byte): Long = sys.error("stub") /** - * @return the product of this value and x + * Returns the product of this value and `x`. */ def *(x: Short): Long = sys.error("stub") /** - * @return the product of this value and x + * Returns the product of this value and `x`. */ def *(x: Char): Long = sys.error("stub") /** - * @return the product of this value and x + * Returns the product of this value and `x`. */ def *(x: Int): Long = sys.error("stub") /** - * @return the product of this value and x + * Returns the product of this value and `x`. */ def *(x: Long): Long = sys.error("stub") /** - * @return the product of this value and x + * Returns the product of this value and `x`. */ def *(x: Float): Float = sys.error("stub") /** - * @return the product of this value and x + * Returns the product of this value and `x`. */ def *(x: Double): Double = sys.error("stub") /** - * @return the quotient of this value and x + * Returns the quotient of this value and `x`. */ def /(x: Byte): Long = sys.error("stub") /** - * @return the quotient of this value and x + * Returns the quotient of this value and `x`. */ def /(x: Short): Long = sys.error("stub") /** - * @return the quotient of this value and x + * Returns the quotient of this value and `x`. */ def /(x: Char): Long = sys.error("stub") /** - * @return the quotient of this value and x + * Returns the quotient of this value and `x`. */ def /(x: Int): Long = sys.error("stub") /** - * @return the quotient of this value and x + * Returns the quotient of this value and `x`. */ def /(x: Long): Long = sys.error("stub") /** - * @return the quotient of this value and x + * Returns the quotient of this value and `x`. */ def /(x: Float): Float = sys.error("stub") /** - * @return the quotient of this value and x + * Returns the quotient of this value and `x`. */ def /(x: Double): Double = sys.error("stub") /** - * @return the remainder of the division of this value by x + * Returns the remainder of the division of this value by `x`. */ def %(x: Byte): Long = sys.error("stub") /** - * @return the remainder of the division of this value by x + * Returns the remainder of the division of this value by `x`. */ def %(x: Short): Long = sys.error("stub") /** - * @return the remainder of the division of this value by x + * Returns the remainder of the division of this value by `x`. */ def %(x: Char): Long = sys.error("stub") /** - * @return the remainder of the division of this value by x + * Returns the remainder of the division of this value by `x`. */ def %(x: Int): Long = sys.error("stub") /** - * @return the remainder of the division of this value by x + * Returns the remainder of the division of this value by `x`. */ def %(x: Long): Long = sys.error("stub") /** - * @return the remainder of the division of this value by x + * Returns the remainder of the division of this value by `x`. */ def %(x: Float): Float = sys.error("stub") /** - * @return the remainder of the division of this value by x + * Returns the remainder of the division of this value by `x`. */ def %(x: Double): Double = sys.error("stub") override def getClass(): Class[Long] = sys.error("stub") } -object Long extends AnyValCompanion { +object Long extends AnyValCompanion { /** The smallest value representable as a Long. */ final val MinValue = java.lang.Long.MIN_VALUE @@ -622,5 +622,7 @@ object Long extends AnyValCompanion { /** The String representation of the scala.Long companion object. */ override def toString = "object scala.Long" + implicit def long2float(x: Long): Float = x.toFloat + implicit def long2double(x: Long): Double = x.toDouble } diff --git a/src/library/scala/LowPriorityImplicits.scala b/src/library/scala/LowPriorityImplicits.scala index 447a3c3819..491cd417a3 100644 --- a/src/library/scala/LowPriorityImplicits.scala +++ b/src/library/scala/LowPriorityImplicits.scala @@ -12,6 +12,7 @@ import scala.collection.{ mutable, immutable, generic } import mutable.WrappedArray import immutable.WrappedString import generic.CanBuildFrom +import language.implicitConversions /** The `LowPriorityImplicits` class provides implicit values that * are valid in all Scala compilation units without explicit qualification, diff --git a/src/library/scala/Option.scala b/src/library/scala/Option.scala index 68ea67ca00..a58297d7d4 100644 --- a/src/library/scala/Option.scala +++ b/src/library/scala/Option.scala @@ -9,6 +9,9 @@ package scala object Option { + + import language.implicitConversions + /** An implicit conversion that converts an option to an iterable value */ implicit def option2Iterable[A](xo: Option[A]): Iterable[A] = xo.toList diff --git a/src/library/scala/Predef.scala b/src/library/scala/Predef.scala index 837ce96baa..15e007528b 100644 --- a/src/library/scala/Predef.scala +++ b/src/library/scala/Predef.scala @@ -14,6 +14,7 @@ import mutable.ArrayOps import generic.CanBuildFrom import annotation.{ elidable, implicitNotFound } import annotation.elidable.ASSERTION +import language.{implicitConversions, existentials} /** The `Predef` object provides definitions that are accessible in all Scala * compilation units without explicit qualification. @@ -348,30 +349,30 @@ object Predef extends LowPriorityImplicits { // Primitive Widenings -------------------------------------------------------------- - implicit def byte2short(x: Byte): Short = x.toShort - implicit def byte2int(x: Byte): Int = x.toInt - implicit def byte2long(x: Byte): Long = x.toLong - implicit def byte2float(x: Byte): Float = x.toFloat - implicit def byte2double(x: Byte): Double = x.toDouble + @deprecated("Use a method in an AnyVal's companion object", "2.10.0") def byte2short(x: Byte): Short = x.toShort + @deprecated("Use a method in an AnyVal's companion object", "2.10.0") def byte2int(x: Byte): Int = x.toInt + @deprecated("Use a method in an AnyVal's companion object", "2.10.0") def byte2long(x: Byte): Long = x.toLong + @deprecated("Use a method in an AnyVal's companion object", "2.10.0") def byte2float(x: Byte): Float = x.toFloat + @deprecated("Use a method in an AnyVal's companion object", "2.10.0") def byte2double(x: Byte): Double = x.toDouble - implicit def short2int(x: Short): Int = x.toInt - implicit def short2long(x: Short): Long = x.toLong - implicit def short2float(x: Short): Float = x.toFloat - implicit def short2double(x: Short): Double = x.toDouble + @deprecated("Use a method in an AnyVal's companion object", "2.10.0") def short2int(x: Short): Int = x.toInt + @deprecated("Use a method in an AnyVal's companion object", "2.10.0") def short2long(x: Short): Long = x.toLong + @deprecated("Use a method in an AnyVal's companion object", "2.10.0") def short2float(x: Short): Float = x.toFloat + @deprecated("Use a method in an AnyVal's companion object", "2.10.0") def short2double(x: Short): Double = x.toDouble - implicit def char2int(x: Char): Int = x.toInt - implicit def char2long(x: Char): Long = x.toLong - implicit def char2float(x: Char): Float = x.toFloat - implicit def char2double(x: Char): Double = x.toDouble + @deprecated("Use a method in an AnyVal's companion object", "2.10.0") def char2int(x: Char): Int = x.toInt + @deprecated("Use a method in an AnyVal's companion object", "2.10.0") def char2long(x: Char): Long = x.toLong + @deprecated("Use a method in an AnyVal's companion object", "2.10.0") def char2float(x: Char): Float = x.toFloat + @deprecated("Use a method in an AnyVal's companion object", "2.10.0") def char2double(x: Char): Double = x.toDouble - implicit def int2long(x: Int): Long = x.toLong - implicit def int2float(x: Int): Float = x.toFloat - implicit def int2double(x: Int): Double = x.toDouble + @deprecated("Use a method in an AnyVal's companion object", "2.10.0") def int2long(x: Int): Long = x.toLong + @deprecated("Use a method in an AnyVal's companion object", "2.10.0") def int2float(x: Int): Float = x.toFloat + @deprecated("Use a method in an AnyVal's companion object", "2.10.0") def int2double(x: Int): Double = x.toDouble - implicit def long2float(x: Long): Float = x.toFloat - implicit def long2double(x: Long): Double = x.toDouble + @deprecated("Use a method in an AnyVal's companion object", "2.10.0") def long2float(x: Long): Float = x.toFloat + @deprecated("Use a method in an AnyVal's companion object", "2.10.0") def long2double(x: Long): Double = x.toDouble - implicit def float2double(x: Float): Double = x.toDouble + @deprecated("Use a method in an AnyVal's companion object", "2.10.0") def float2double(x: Float): Double = x.toDouble // "Autoboxing" and "Autounboxing" --------------------------------------------------- diff --git a/src/library/scala/Short.scala b/src/library/scala/Short.scala index 5664c3b44c..1060a9db16 100644 --- a/src/library/scala/Short.scala +++ b/src/library/scala/Short.scala @@ -17,7 +17,7 @@ package scala * There is an implicit conversion from [[scala.Short]] => [[scala.runtime.RichShort]] * which provides useful non-primitive operations. */ -final class Short extends AnyVal { +final class Short private extends AnyVal { def toByte: Byte = sys.error("stub") def toShort: Short = sys.error("stub") def toChar: Char = sys.error("stub") @@ -27,7 +27,7 @@ final class Short extends AnyVal { def toDouble: Double = sys.error("stub") /** - * @return the bitwise negation of this value + * Returns the bitwise negation of this value. * @example {{{ * ~5 == -6 * // in binary: ~00000101 == @@ -36,30 +36,30 @@ final class Short extends AnyVal { */ def unary_~ : Int = sys.error("stub") /** - * @return this value, unmodified + * Returns this value, unmodified. */ def unary_+ : Int = sys.error("stub") /** - * @return the negation of this value + * Returns the negation of this value. */ def unary_- : Int = sys.error("stub") def +(x: String): String = sys.error("stub") /** - * @return this value bit-shifted left by the specified number of bits, + * Returns this value bit-shifted left by the specified number of bits, * filling in the new right bits with zeroes. * @example {{{ 6 << 3 == 48 // in binary: 0110 << 3 == 0110000 }}} */ def <<(x: Int): Int = sys.error("stub") /** - * @return this value bit-shifted left by the specified number of bits, + * Returns this value bit-shifted left by the specified number of bits, * filling in the new right bits with zeroes. * @example {{{ 6 << 3 == 48 // in binary: 0110 << 3 == 0110000 }}} */ def <<(x: Long): Int = sys.error("stub") /** - * @return this value bit-shifted right by the specified number of bits, + * Returns this value bit-shifted right by the specified number of bits, * filling the new left bits with zeroes. * @example {{{ 21 >>> 3 == 2 // in binary: 010101 >>> 3 == 010 }}} * @example {{{ @@ -70,7 +70,7 @@ final class Short extends AnyVal { */ def >>>(x: Int): Int = sys.error("stub") /** - * @return this value bit-shifted right by the specified number of bits, + * Returns this value bit-shifted right by the specified number of bits, * filling the new left bits with zeroes. * @example {{{ 21 >>> 3 == 2 // in binary: 010101 >>> 3 == 010 }}} * @example {{{ @@ -81,7 +81,7 @@ final class Short extends AnyVal { */ def >>>(x: Long): Int = sys.error("stub") /** - * @return this value bit-shifted left by the specified number of bits, + * Returns this value bit-shifted left by the specified number of bits, * filling in the right bits with the same value as the left-most bit of this. * The effect of this is to retain the sign of the value. * @example {{{ @@ -92,7 +92,7 @@ final class Short extends AnyVal { */ def >>(x: Int): Int = sys.error("stub") /** - * @return this value bit-shifted left by the specified number of bits, + * Returns this value bit-shifted left by the specified number of bits, * filling in the right bits with the same value as the left-most bit of this. * The effect of this is to retain the sign of the value. * @example {{{ @@ -104,181 +104,181 @@ final class Short extends AnyVal { def >>(x: Long): Int = sys.error("stub") /** - * @return `true` if this value is equal x, `false` otherwise + * Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Byte): Boolean = sys.error("stub") /** - * @return `true` if this value is equal x, `false` otherwise + * Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Short): Boolean = sys.error("stub") /** - * @return `true` if this value is equal x, `false` otherwise + * Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Char): Boolean = sys.error("stub") /** - * @return `true` if this value is equal x, `false` otherwise + * Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Int): Boolean = sys.error("stub") /** - * @return `true` if this value is equal x, `false` otherwise + * Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Long): Boolean = sys.error("stub") /** - * @return `true` if this value is equal x, `false` otherwise + * Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Float): Boolean = sys.error("stub") /** - * @return `true` if this value is equal x, `false` otherwise + * Returns `true` if this value is equal to x, `false` otherwise. */ def ==(x: Double): Boolean = sys.error("stub") /** - * @return `true` if this value is not equal to x, `false` otherwise + * Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Byte): Boolean = sys.error("stub") /** - * @return `true` if this value is not equal to x, `false` otherwise + * Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Short): Boolean = sys.error("stub") /** - * @return `true` if this value is not equal to x, `false` otherwise + * Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Char): Boolean = sys.error("stub") /** - * @return `true` if this value is not equal to x, `false` otherwise + * Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Int): Boolean = sys.error("stub") /** - * @return `true` if this value is not equal to x, `false` otherwise + * Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Long): Boolean = sys.error("stub") /** - * @return `true` if this value is not equal to x, `false` otherwise + * Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Float): Boolean = sys.error("stub") /** - * @return `true` if this value is not equal to x, `false` otherwise + * Returns `true` if this value is not equal to x, `false` otherwise. */ def !=(x: Double): Boolean = sys.error("stub") /** - * @return `true` if this value is less than x, `false` otherwise + * Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Byte): Boolean = sys.error("stub") /** - * @return `true` if this value is less than x, `false` otherwise + * Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Short): Boolean = sys.error("stub") /** - * @return `true` if this value is less than x, `false` otherwise + * Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Char): Boolean = sys.error("stub") /** - * @return `true` if this value is less than x, `false` otherwise + * Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Int): Boolean = sys.error("stub") /** - * @return `true` if this value is less than x, `false` otherwise + * Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Long): Boolean = sys.error("stub") /** - * @return `true` if this value is less than x, `false` otherwise + * Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Float): Boolean = sys.error("stub") /** - * @return `true` if this value is less than x, `false` otherwise + * Returns `true` if this value is less than x, `false` otherwise. */ def <(x: Double): Boolean = sys.error("stub") /** - * @return `true` if this value is less than or equal to x, `false` otherwise + * Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Byte): Boolean = sys.error("stub") /** - * @return `true` if this value is less than or equal to x, `false` otherwise + * Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Short): Boolean = sys.error("stub") /** - * @return `true` if this value is less than or equal to x, `false` otherwise + * Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Char): Boolean = sys.error("stub") /** - * @return `true` if this value is less than or equal to x, `false` otherwise + * Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Int): Boolean = sys.error("stub") /** - * @return `true` if this value is less than or equal to x, `false` otherwise + * Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Long): Boolean = sys.error("stub") /** - * @return `true` if this value is less than or equal to x, `false` otherwise + * Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Float): Boolean = sys.error("stub") /** - * @return `true` if this value is less than or equal to x, `false` otherwise + * Returns `true` if this value is less than or equal to x, `false` otherwise. */ def <=(x: Double): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than x, `false` otherwise + * Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Byte): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than x, `false` otherwise + * Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Short): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than x, `false` otherwise + * Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Char): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than x, `false` otherwise + * Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Int): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than x, `false` otherwise + * Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Long): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than x, `false` otherwise + * Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Float): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than x, `false` otherwise + * Returns `true` if this value is greater than x, `false` otherwise. */ def >(x: Double): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than or equal to x, `false` otherwise + * Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Byte): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than or equal to x, `false` otherwise + * Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Short): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than or equal to x, `false` otherwise + * Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Char): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than or equal to x, `false` otherwise + * Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Int): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than or equal to x, `false` otherwise + * Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Long): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than or equal to x, `false` otherwise + * Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Float): Boolean = sys.error("stub") /** - * @return `true` if this value is greater than or equal to x, `false` otherwise + * Returns `true` if this value is greater than or equal to x, `false` otherwise. */ def >=(x: Double): Boolean = sys.error("stub") /** - * @return the bitwise OR of this value and x + * Returns the bitwise OR of this value and `x`. * @example {{{ * (0xf0 | 0xaa) == 0xfa * // in binary: 11110000 @@ -289,7 +289,7 @@ final class Short extends AnyVal { */ def |(x: Byte): Int = sys.error("stub") /** - * @return the bitwise OR of this value and x + * Returns the bitwise OR of this value and `x`. * @example {{{ * (0xf0 | 0xaa) == 0xfa * // in binary: 11110000 @@ -300,7 +300,7 @@ final class Short extends AnyVal { */ def |(x: Short): Int = sys.error("stub") /** - * @return the bitwise OR of this value and x + * Returns the bitwise OR of this value and `x`. * @example {{{ * (0xf0 | 0xaa) == 0xfa * // in binary: 11110000 @@ -311,7 +311,7 @@ final class Short extends AnyVal { */ def |(x: Char): Int = sys.error("stub") /** - * @return the bitwise OR of this value and x + * Returns the bitwise OR of this value and `x`. * @example {{{ * (0xf0 | 0xaa) == 0xfa * // in binary: 11110000 @@ -322,7 +322,7 @@ final class Short extends AnyVal { */ def |(x: Int): Int = sys.error("stub") /** - * @return the bitwise OR of this value and x + * Returns the bitwise OR of this value and `x`. * @example {{{ * (0xf0 | 0xaa) == 0xfa * // in binary: 11110000 @@ -334,7 +334,7 @@ final class Short extends AnyVal { def |(x: Long): Long = sys.error("stub") /** - * @return the bitwise AND of this value and x + * Returns the bitwise AND of this value and `x`. * @example {{{ * (0xf0 & 0xaa) == 0xa0 * // in binary: 11110000 @@ -345,7 +345,7 @@ final class Short extends AnyVal { */ def &(x: Byte): Int = sys.error("stub") /** - * @return the bitwise AND of this value and x + * Returns the bitwise AND of this value and `x`. * @example {{{ * (0xf0 & 0xaa) == 0xa0 * // in binary: 11110000 @@ -356,7 +356,7 @@ final class Short extends AnyVal { */ def &(x: Short): Int = sys.error("stub") /** - * @return the bitwise AND of this value and x + * Returns the bitwise AND of this value and `x`. * @example {{{ * (0xf0 & 0xaa) == 0xa0 * // in binary: 11110000 @@ -367,7 +367,7 @@ final class Short extends AnyVal { */ def &(x: Char): Int = sys.error("stub") /** - * @return the bitwise AND of this value and x + * Returns the bitwise AND of this value and `x`. * @example {{{ * (0xf0 & 0xaa) == 0xa0 * // in binary: 11110000 @@ -378,7 +378,7 @@ final class Short extends AnyVal { */ def &(x: Int): Int = sys.error("stub") /** - * @return the bitwise AND of this value and x + * Returns the bitwise AND of this value and `x`. * @example {{{ * (0xf0 & 0xaa) == 0xa0 * // in binary: 11110000 @@ -390,7 +390,7 @@ final class Short extends AnyVal { def &(x: Long): Long = sys.error("stub") /** - * @return the bitwise XOR of this value and x + * Returns the bitwise XOR of this value and `x`. * @example {{{ * (0xf0 ^ 0xaa) == 0x5a * // in binary: 11110000 @@ -401,7 +401,7 @@ final class Short extends AnyVal { */ def ^(x: Byte): Int = sys.error("stub") /** - * @return the bitwise XOR of this value and x + * Returns the bitwise XOR of this value and `x`. * @example {{{ * (0xf0 ^ 0xaa) == 0x5a * // in binary: 11110000 @@ -412,7 +412,7 @@ final class Short extends AnyVal { */ def ^(x: Short): Int = sys.error("stub") /** - * @return the bitwise XOR of this value and x + * Returns the bitwise XOR of this value and `x`. * @example {{{ * (0xf0 ^ 0xaa) == 0x5a * // in binary: 11110000 @@ -423,7 +423,7 @@ final class Short extends AnyVal { */ def ^(x: Char): Int = sys.error("stub") /** - * @return the bitwise XOR of this value and x + * Returns the bitwise XOR of this value and `x`. * @example {{{ * (0xf0 ^ 0xaa) == 0x5a * // in binary: 11110000 @@ -434,7 +434,7 @@ final class Short extends AnyVal { */ def ^(x: Int): Int = sys.error("stub") /** - * @return the bitwise XOR of this value and x + * Returns the bitwise XOR of this value and `x`. * @example {{{ * (0xf0 ^ 0xaa) == 0x5a * // in binary: 11110000 @@ -446,154 +446,154 @@ final class Short extends AnyVal { def ^(x: Long): Long = sys.error("stub") /** - * @return the sum of this value and x + * Returns the sum of this value and `x`. */ def +(x: Byte): Int = sys.error("stub") /** - * @return the sum of this value and x + * Returns the sum of this value and `x`. */ def +(x: Short): Int = sys.error("stub") /** - * @return the sum of this value and x + * Returns the sum of this value and `x`. */ def +(x: Char): Int = sys.error("stub") /** - * @return the sum of this value and x + * Returns the sum of this value and `x`. */ def +(x: Int): Int = sys.error("stub") /** - * @return the sum of this value and x + * Returns the sum of this value and `x`. */ def +(x: Long): Long = sys.error("stub") /** - * @return the sum of this value and x + * Returns the sum of this value and `x`. */ def +(x: Float): Float = sys.error("stub") /** - * @return the sum of this value and x + * Returns the sum of this value and `x`. */ def +(x: Double): Double = sys.error("stub") /** - * @return the difference of this value and x + * Returns the difference of this value and `x`. */ def -(x: Byte): Int = sys.error("stub") /** - * @return the difference of this value and x + * Returns the difference of this value and `x`. */ def -(x: Short): Int = sys.error("stub") /** - * @return the difference of this value and x + * Returns the difference of this value and `x`. */ def -(x: Char): Int = sys.error("stub") /** - * @return the difference of this value and x + * Returns the difference of this value and `x`. */ def -(x: Int): Int = sys.error("stub") /** - * @return the difference of this value and x + * Returns the difference of this value and `x`. */ def -(x: Long): Long = sys.error("stub") /** - * @return the difference of this value and x + * Returns the difference of this value and `x`. */ def -(x: Float): Float = sys.error("stub") /** - * @return the difference of this value and x + * Returns the difference of this value and `x`. */ def -(x: Double): Double = sys.error("stub") /** - * @return the product of this value and x + * Returns the product of this value and `x`. */ def *(x: Byte): Int = sys.error("stub") /** - * @return the product of this value and x + * Returns the product of this value and `x`. */ def *(x: Short): Int = sys.error("stub") /** - * @return the product of this value and x + * Returns the product of this value and `x`. */ def *(x: Char): Int = sys.error("stub") /** - * @return the product of this value and x + * Returns the product of this value and `x`. */ def *(x: Int): Int = sys.error("stub") /** - * @return the product of this value and x + * Returns the product of this value and `x`. */ def *(x: Long): Long = sys.error("stub") /** - * @return the product of this value and x + * Returns the product of this value and `x`. */ def *(x: Float): Float = sys.error("stub") /** - * @return the product of this value and x + * Returns the product of this value and `x`. */ def *(x: Double): Double = sys.error("stub") /** - * @return the quotient of this value and x + * Returns the quotient of this value and `x`. */ def /(x: Byte): Int = sys.error("stub") /** - * @return the quotient of this value and x + * Returns the quotient of this value and `x`. */ def /(x: Short): Int = sys.error("stub") /** - * @return the quotient of this value and x + * Returns the quotient of this value and `x`. */ def /(x: Char): Int = sys.error("stub") /** - * @return the quotient of this value and x + * Returns the quotient of this value and `x`. */ def /(x: Int): Int = sys.error("stub") /** - * @return the quotient of this value and x + * Returns the quotient of this value and `x`. */ def /(x: Long): Long = sys.error("stub") /** - * @return the quotient of this value and x + * Returns the quotient of this value and `x`. */ def /(x: Float): Float = sys.error("stub") /** - * @return the quotient of this value and x + * Returns the quotient of this value and `x`. */ def /(x: Double): Double = sys.error("stub") /** - * @return the remainder of the division of this value by x + * Returns the remainder of the division of this value by `x`. */ def %(x: Byte): Int = sys.error("stub") /** - * @return the remainder of the division of this value by x + * Returns the remainder of the division of this value by `x`. */ def %(x: Short): Int = sys.error("stub") /** - * @return the remainder of the division of this value by x + * Returns the remainder of the division of this value by `x`. */ def %(x: Char): Int = sys.error("stub") /** - * @return the remainder of the division of this value by x + * Returns the remainder of the division of this value by `x`. */ def %(x: Int): Int = sys.error("stub") /** - * @return the remainder of the division of this value by x + * Returns the remainder of the division of this value by `x`. */ def %(x: Long): Long = sys.error("stub") /** - * @return the remainder of the division of this value by x + * Returns the remainder of the division of this value by `x`. */ def %(x: Float): Float = sys.error("stub") /** - * @return the remainder of the division of this value by x + * Returns the remainder of the division of this value by `x`. */ def %(x: Double): Double = sys.error("stub") override def getClass(): Class[Short] = sys.error("stub") } -object Short extends AnyValCompanion { +object Short extends AnyValCompanion { /** The smallest value representable as a Short. */ final val MinValue = java.lang.Short.MIN_VALUE @@ -622,5 +622,9 @@ object Short extends AnyValCompanion { /** The String representation of the scala.Short companion object. */ override def toString = "object scala.Short" + implicit def short2int(x: Short): Int = x.toInt + implicit def short2long(x: Short): Long = x.toLong + implicit def short2float(x: Short): Float = x.toFloat + implicit def short2double(x: Short): Double = x.toDouble } diff --git a/src/library/scala/Unit.scala b/src/library/scala/Unit.scala index f6ed0121ab..3da5c083d4 100644 --- a/src/library/scala/Unit.scala +++ b/src/library/scala/Unit.scala @@ -16,11 +16,11 @@ package scala * runtime system. A method with return type `Unit` is analogous to a Java * method which is declared `void`. */ -final class Unit extends AnyVal { +final class Unit private extends AnyVal { override def getClass(): Class[Unit] = sys.error("stub") } -object Unit extends AnyValCompanion { +object Unit extends AnyValCompanion { /** Transform a value type into a boxed reference type. * diff --git a/src/library/scala/annotation/meta/languageFeature.scala b/src/library/scala/annotation/meta/languageFeature.scala new file mode 100644 index 0000000000..23acc01b51 --- /dev/null +++ b/src/library/scala/annotation/meta/languageFeature.scala @@ -0,0 +1,13 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ +package scala.annotation.meta + +/** + * An annotation giving particulars for a language feature in object `scala.language`. + */ +final class languageFeature(feature: String, enableRequired: Boolean) extends annotation.StaticAnnotation diff --git a/src/library/scala/collection/DefaultMap.scala b/src/library/scala/collection/DefaultMap.scala index 3af535bdaa..d00414751a 100644 --- a/src/library/scala/collection/DefaultMap.scala +++ b/src/library/scala/collection/DefaultMap.scala @@ -41,7 +41,7 @@ trait DefaultMap[A, +B] extends Map[A, B] { self => */ override def - (key: A): Map[A, B] = { val b = newBuilder - b ++= this filter (key !=) + b ++= this filter (key != _) b.result } } diff --git a/src/library/scala/collection/GenSeqLike.scala b/src/library/scala/collection/GenSeqLike.scala index 755abcd2bf..71316cefc9 100644 --- a/src/library/scala/collection/GenSeqLike.scala +++ b/src/library/scala/collection/GenSeqLike.scala @@ -142,7 +142,7 @@ trait GenSeqLike[+A, +Repr] extends Any with GenIterableLike[A, Repr] with Equal * $mayNotTerminateInf * */ - def indexOf[B >: A](elem: B, from: Int): Int = indexWhere(elem ==, from) + def indexOf[B >: A](elem: B, from: Int): Int = indexWhere(elem == _, from) /** Finds index of last occurrence of some value in this $coll. * @@ -157,7 +157,7 @@ trait GenSeqLike[+A, +Repr] extends Any with GenIterableLike[A, Repr] with Equal * $willNotTerminateInf * */ - def lastIndexOf[B >: A](elem: B): Int = lastIndexWhere(elem ==) + def lastIndexOf[B >: A](elem: B): Int = lastIndexWhere(elem == _) /** Finds index of last occurrence of some value in this $coll before or at a given end index. * @@ -170,7 +170,7 @@ trait GenSeqLike[+A, +Repr] extends Any with GenIterableLike[A, Repr] with Equal * @usecase def lastIndexOf(elem: A, end: Int): Int * @inheritdoc */ - def lastIndexOf[B >: A](elem: B, end: Int): Int = lastIndexWhere(elem ==, end) + def lastIndexOf[B >: A](elem: B, end: Int): Int = lastIndexWhere(elem == _, end) /** Finds index of last element satisfying some predicate. * diff --git a/src/library/scala/collection/IterableLike.scala b/src/library/scala/collection/IterableLike.scala index fb6d154952..3c4ad0612a 100644 --- a/src/library/scala/collection/IterableLike.scala +++ b/src/library/scala/collection/IterableLike.scala @@ -134,7 +134,7 @@ self => it.next i += 1 } - b ++= it result + (b ++= it).result } override /*TraversableLike*/ def takeWhile(p: A => Boolean): Repr = { diff --git a/src/library/scala/collection/IterableViewLike.scala b/src/library/scala/collection/IterableViewLike.scala index ce2daf08d4..c842475590 100644 --- a/src/library/scala/collection/IterableViewLike.scala +++ b/src/library/scala/collection/IterableViewLike.scala @@ -11,6 +11,7 @@ package scala.collection import generic._ import TraversableView.NoBuilder import immutable.Stream +import language.implicitConversions /** A template trait for non-strict views of iterable collections. * $iterableViewInfo diff --git a/src/library/scala/collection/SeqLike.scala b/src/library/scala/collection/SeqLike.scala index fd1d42d7e9..ced99e897f 100644 --- a/src/library/scala/collection/SeqLike.scala +++ b/src/library/scala/collection/SeqLike.scala @@ -185,7 +185,7 @@ trait SeqLike[+A, +Repr] extends Any with IterableLike[A, Repr] with GenSeqLike[ private[this] def init() = { val m = mutable.HashMap[A, Int]() - val (es, is) = thisCollection map (e => (e, m.getOrElseUpdate(e, m.size))) sortBy (_._2) unzip + val (es, is) = (thisCollection map (e => (e, m.getOrElseUpdate(e, m.size))) sortBy (_._2)).unzip (es.toBuffer, is.toArray) } @@ -240,7 +240,7 @@ trait SeqLike[+A, +Repr] extends Any with IterableLike[A, Repr] with GenSeqLike[ val m = mutable.HashMap[A, Int]() // e => (e, weight(e)) - val (es, is) = thisCollection map (e => (e, m.getOrElseUpdate(e, m.size))) sortBy (_._2) unzip + val (es, is) = (thisCollection map (e => (e, m.getOrElseUpdate(e, m.size))) sortBy (_._2)).unzip val cs = new Array[Int](m.size) is foreach (i => cs(i) += 1) val ns = new Array[Int](cs.length) diff --git a/src/library/scala/collection/SeqProxyLike.scala b/src/library/scala/collection/SeqProxyLike.scala index ce32ba97c2..3783ef771f 100644 --- a/src/library/scala/collection/SeqProxyLike.scala +++ b/src/library/scala/collection/SeqProxyLike.scala @@ -36,7 +36,7 @@ trait SeqProxyLike[+A, +Repr <: SeqLike[A, Repr] with Seq[A]] extends SeqLike[A, override def indexOf[B >: A](elem: B): Int = self.indexOf(elem) override def indexOf[B >: A](elem: B, from: Int): Int = self.indexOf(elem, from) override def lastIndexOf[B >: A](elem: B): Int = self.lastIndexOf(elem) - override def lastIndexOf[B >: A](elem: B, end: Int): Int = self.lastIndexWhere(elem ==, end) + override def lastIndexOf[B >: A](elem: B, end: Int): Int = self.lastIndexWhere(elem == _, end) override def lastIndexWhere(p: A => Boolean): Int = self.lastIndexWhere(p, length - 1) override def lastIndexWhere(p: A => Boolean, end: Int): Int = self.lastIndexWhere(p) override def reverse: Repr = self.reverse diff --git a/src/library/scala/collection/TraversableLike.scala b/src/library/scala/collection/TraversableLike.scala index 1f5beb5109..a4f36d20c7 100644 --- a/src/library/scala/collection/TraversableLike.scala +++ b/src/library/scala/collection/TraversableLike.scala @@ -487,7 +487,7 @@ trait TraversableLike[+A, +Repr] extends Any if (n <= 0) { val b = newBuilder b.sizeHint(this) - b ++= thisCollection result + (b ++= thisCollection).result } else sliceWithKnownDelta(n, Int.MaxValue, -n) @@ -775,6 +775,6 @@ trait TraversableLike[+A, +Repr] extends Any // A helper for tails and inits. private def iterateUntilEmpty(f: Traversable[A @uV] => Traversable[A @uV]): Iterator[Repr] = { val it = Iterator.iterate(thisCollection)(f) takeWhile (x => !x.isEmpty) - it ++ Iterator(Nil) map (newBuilder ++= _ result) + it ++ Iterator(Nil) map (x => (newBuilder ++= x).result) } } diff --git a/src/library/scala/collection/TraversableOnce.scala b/src/library/scala/collection/TraversableOnce.scala index 62ea692b90..e68ef9e4de 100644 --- a/src/library/scala/collection/TraversableOnce.scala +++ b/src/library/scala/collection/TraversableOnce.scala @@ -10,6 +10,7 @@ package scala.collection import mutable.{ Buffer, ListBuffer, ArrayBuffer } import annotation.unchecked.{ uncheckedVariance => uV } +import language.{implicitConversions, higherKinds} /** A template trait for collections which can be traversed either once only * or one or more times. @@ -239,7 +240,7 @@ trait TraversableOnce[+A] extends Any with GenTraversableOnce[A] { def toTraversable: Traversable[A] - def toList: List[A] = new ListBuffer[A] ++= seq toList + def toList: List[A] = (new ListBuffer[A] ++= seq).toList def toIterable: Iterable[A] = toStream @@ -358,8 +359,11 @@ trait TraversableOnce[+A] extends Any with GenTraversableOnce[A] { object TraversableOnce { - implicit def traversableOnceCanBuildFrom[T] = new OnceCanBuildFrom[T] - implicit def wrapTraversableOnce[A](trav: TraversableOnce[A]) = new MonadOps(trav) + @deprecated("use OnceCanBuildFrom instead") + def traversableOnceCanBuildFrom[T] = new OnceCanBuildFrom[T] + @deprecated("use MonadOps instead") + def wrapTraversableOnce[A](trav: TraversableOnce[A]) = new MonadOps(trav) + implicit def alternateImplicit[A](trav: TraversableOnce[A]) = new ForceImplicitAmbiguity implicit def flattenTraversableOnce[A, CC[_]](travs: TraversableOnce[CC[A]])(implicit ev: CC[A] => TraversableOnce[A]) = new FlattenOps[A](travs map ev) @@ -368,7 +372,7 @@ object TraversableOnce { * operates on Iterators so they can be treated uniformly along with the collections. * See scala.util.Random.shuffle for an example. */ - class OnceCanBuildFrom[A] extends generic.CanBuildFrom[TraversableOnce[A], A, TraversableOnce[A]] { + implicit class OnceCanBuildFrom[A] extends generic.CanBuildFrom[TraversableOnce[A], A, TraversableOnce[A]] { def newIterator = new ArrayBuffer[A] mapResult (_.iterator) /** Creates a new builder on request of a collection. @@ -394,7 +398,7 @@ object TraversableOnce { class ForceImplicitAmbiguity - class MonadOps[+A](trav: TraversableOnce[A]) { + implicit class MonadOps[+A](trav: TraversableOnce[A]) { def map[B](f: A => B): TraversableOnce[B] = trav.toIterator map f def flatMap[B](f: A => GenTraversableOnce[B]): TraversableOnce[B] = trav.toIterator flatMap f def withFilter(p: A => Boolean) = trav.toIterator filter p diff --git a/src/library/scala/collection/TraversableViewLike.scala b/src/library/scala/collection/TraversableViewLike.scala index fbecad98fe..ad5e3d3240 100644 --- a/src/library/scala/collection/TraversableViewLike.scala +++ b/src/library/scala/collection/TraversableViewLike.scala @@ -12,13 +12,14 @@ import generic._ import mutable.{ Builder, ArrayBuffer } import TraversableView.NoBuilder import annotation.migration +import language.implicitConversions trait ViewMkString[+A] { self: Traversable[A] => // It is necessary to use thisSeq rather than toSeq to avoid cycles in the // eager evaluation of vals in transformed view subclasses, see #4558. - protected[this] def thisSeq: Seq[A] = new ArrayBuffer[A] ++= self result + protected[this] def thisSeq: Seq[A] = (new ArrayBuffer[A] ++= self).result // Have to overload all three to work around #4299. The overload // is because mkString should force a view but toString should not. diff --git a/src/library/scala/collection/convert/DecorateAsJava.scala b/src/library/scala/collection/convert/DecorateAsJava.scala index e05bfc41cd..bde13f2830 100644 --- a/src/library/scala/collection/convert/DecorateAsJava.scala +++ b/src/library/scala/collection/convert/DecorateAsJava.scala @@ -12,6 +12,8 @@ package convert import java.{ lang => jl, util => ju }, java.util.{ concurrent => juc } import Decorators._ import WrapAsJava._ +import language.implicitConversions + /** A collection of decorators that allow to convert between * Scala and Java collections using `asScala` and `asJava` methods. diff --git a/src/library/scala/collection/convert/DecorateAsScala.scala b/src/library/scala/collection/convert/DecorateAsScala.scala index 722f0b9af9..b170d8d139 100644 --- a/src/library/scala/collection/convert/DecorateAsScala.scala +++ b/src/library/scala/collection/convert/DecorateAsScala.scala @@ -12,6 +12,7 @@ package convert import java.{ lang => jl, util => ju }, java.util.{ concurrent => juc } import Decorators._ import WrapAsScala._ +import language.implicitConversions trait DecorateAsScala { /** diff --git a/src/library/scala/collection/convert/WrapAsJava.scala b/src/library/scala/collection/convert/WrapAsJava.scala index cdec72b9fe..ecf91deb3a 100644 --- a/src/library/scala/collection/convert/WrapAsJava.scala +++ b/src/library/scala/collection/convert/WrapAsJava.scala @@ -11,6 +11,7 @@ package convert import java.{ lang => jl, util => ju }, java.util.{ concurrent => juc } import Wrappers._ +import language.implicitConversions trait WrapAsJava { /** diff --git a/src/library/scala/collection/convert/WrapAsScala.scala b/src/library/scala/collection/convert/WrapAsScala.scala index 56e13b2105..14c64695ff 100644 --- a/src/library/scala/collection/convert/WrapAsScala.scala +++ b/src/library/scala/collection/convert/WrapAsScala.scala @@ -11,6 +11,7 @@ package convert import java.{ lang => jl, util => ju }, java.util.{ concurrent => juc } import Wrappers._ +import language.implicitConversions trait WrapAsScala { /** diff --git a/src/library/scala/collection/generic/ClassManifestTraversableFactory.scala b/src/library/scala/collection/generic/ClassManifestTraversableFactory.scala index e54ce9cdbf..e418ca623f 100644 --- a/src/library/scala/collection/generic/ClassManifestTraversableFactory.scala +++ b/src/library/scala/collection/generic/ClassManifestTraversableFactory.scala @@ -9,6 +9,8 @@ package scala.collection package generic +import language.higherKinds + /** A template for companion objects of `ClassManifestTraversable` and * subclasses thereof. * diff --git a/src/library/scala/collection/generic/GenMapFactory.scala b/src/library/scala/collection/generic/GenMapFactory.scala index d6f6978ead..b3faf0497b 100644 --- a/src/library/scala/collection/generic/GenMapFactory.scala +++ b/src/library/scala/collection/generic/GenMapFactory.scala @@ -10,6 +10,7 @@ package scala.collection package generic import mutable.{Builder, MapBuilder} +import language.higherKinds /** A template for companion objects of `Map` and subclasses thereof. * diff --git a/src/library/scala/collection/generic/GenSeqFactory.scala b/src/library/scala/collection/generic/GenSeqFactory.scala index ee6ecae3c2..3bd63c08b8 100644 --- a/src/library/scala/collection/generic/GenSeqFactory.scala +++ b/src/library/scala/collection/generic/GenSeqFactory.scala @@ -12,6 +12,7 @@ package scala.collection package generic import annotation.bridge +import language.higherKinds /** A template for companion objects of Seq and subclasses thereof. * diff --git a/src/library/scala/collection/generic/GenSetFactory.scala b/src/library/scala/collection/generic/GenSetFactory.scala index d83f248aff..caae8afa1c 100644 --- a/src/library/scala/collection/generic/GenSetFactory.scala +++ b/src/library/scala/collection/generic/GenSetFactory.scala @@ -12,6 +12,7 @@ package scala.collection package generic import mutable.Builder +import language.higherKinds /** A template for companion objects of `Set` and subclasses thereof. * diff --git a/src/library/scala/collection/generic/GenTraversableFactory.scala b/src/library/scala/collection/generic/GenTraversableFactory.scala index 34cbe1a7f2..f233a40d35 100644 --- a/src/library/scala/collection/generic/GenTraversableFactory.scala +++ b/src/library/scala/collection/generic/GenTraversableFactory.scala @@ -10,6 +10,8 @@ package scala.collection package generic +import language.higherKinds + /** A template for companion objects of `Traversable` and subclasses thereof. * This class provides a set of operations to create `$Coll` objects. * It is typically inherited by companion objects of subclasses of `Traversable`. @@ -71,7 +73,7 @@ abstract class GenTraversableFactory[CC[X] <: GenTraversable[X] with GenericTrav val b = newBuilder[A] // At present we're using IndexedSeq as a proxy for "has a cheap size method". if (xss forall (_.isInstanceOf[IndexedSeq[_]])) - b.sizeHint(xss map (_.size) sum) + b.sizeHint(xss.map(_.size).sum) for (xs <- xss.seq) b ++= xs b.result diff --git a/src/library/scala/collection/generic/GenericClassManifestCompanion.scala b/src/library/scala/collection/generic/GenericClassManifestCompanion.scala index 546e82fb4a..f357091361 100644 --- a/src/library/scala/collection/generic/GenericClassManifestCompanion.scala +++ b/src/library/scala/collection/generic/GenericClassManifestCompanion.scala @@ -10,6 +10,7 @@ package scala.collection package generic import mutable.Builder +import language.higherKinds /** This class represents companions of classes which require ClassManifests * for their element types. diff --git a/src/library/scala/collection/generic/GenericClassManifestTraversableTemplate.scala b/src/library/scala/collection/generic/GenericClassManifestTraversableTemplate.scala index 12b5a495f0..1a5db4bab2 100644 --- a/src/library/scala/collection/generic/GenericClassManifestTraversableTemplate.scala +++ b/src/library/scala/collection/generic/GenericClassManifestTraversableTemplate.scala @@ -11,6 +11,7 @@ package generic import mutable.Builder import annotation.unchecked.uncheckedVariance +import language.higherKinds /** This trait represents collections classes which require class * manifests for their element types. diff --git a/src/library/scala/collection/generic/GenericCompanion.scala b/src/library/scala/collection/generic/GenericCompanion.scala index b36a1e297f..cf01cf5f08 100644 --- a/src/library/scala/collection/generic/GenericCompanion.scala +++ b/src/library/scala/collection/generic/GenericCompanion.scala @@ -10,6 +10,7 @@ package scala.collection package generic import mutable.Builder +import language.higherKinds /** A template class for companion objects of "regular" collection classes * represent an unconstrained higher-kinded type. Typically diff --git a/src/library/scala/collection/generic/GenericOrderedCompanion.scala b/src/library/scala/collection/generic/GenericOrderedCompanion.scala index c3baa28147..290dc435c8 100644 --- a/src/library/scala/collection/generic/GenericOrderedCompanion.scala +++ b/src/library/scala/collection/generic/GenericOrderedCompanion.scala @@ -10,6 +10,7 @@ package scala.collection package generic import mutable.Builder +import language.higherKinds /** This class represents companions of classes which require the ordered trait * for their element types. diff --git a/src/library/scala/collection/generic/GenericOrderedTraversableTemplate.scala b/src/library/scala/collection/generic/GenericOrderedTraversableTemplate.scala index 5cfc4666b3..6e04420315 100644 --- a/src/library/scala/collection/generic/GenericOrderedTraversableTemplate.scala +++ b/src/library/scala/collection/generic/GenericOrderedTraversableTemplate.scala @@ -13,8 +13,7 @@ package generic import mutable.Builder import annotation.unchecked.uncheckedVariance - - +import language.higherKinds /** This trait represents collections classes which require * ordered element types. diff --git a/src/library/scala/collection/generic/GenericParCompanion.scala b/src/library/scala/collection/generic/GenericParCompanion.scala index 40fcfa31d0..93c166b7ba 100644 --- a/src/library/scala/collection/generic/GenericParCompanion.scala +++ b/src/library/scala/collection/generic/GenericParCompanion.scala @@ -11,6 +11,7 @@ package scala.collection.generic import scala.collection.parallel.Combiner import scala.collection.parallel.ParIterable import scala.collection.parallel.ParMap +import language.higherKinds /** A template class for companion objects of parallel collection classes. * They should be mixed in together with `GenericCompanion` type. diff --git a/src/library/scala/collection/generic/GenericParTemplate.scala b/src/library/scala/collection/generic/GenericParTemplate.scala index 430dcb9e29..fc1c3f5eaa 100644 --- a/src/library/scala/collection/generic/GenericParTemplate.scala +++ b/src/library/scala/collection/generic/GenericParTemplate.scala @@ -14,6 +14,7 @@ import scala.collection.parallel.ParMap import scala.collection.parallel.TaskSupport import annotation.unchecked.uncheckedVariance +import language.higherKinds /** A template trait for collections having a companion. * diff --git a/src/library/scala/collection/generic/GenericSeqCompanion.scala b/src/library/scala/collection/generic/GenericSeqCompanion.scala index 41e8d6dd39..4c0c34733c 100644 --- a/src/library/scala/collection/generic/GenericSeqCompanion.scala +++ b/src/library/scala/collection/generic/GenericSeqCompanion.scala @@ -11,6 +11,7 @@ package scala.collection package generic import annotation.bridge +import language.higherKinds trait GenericSeqCompanion[CC[X] <: Traversable[X]] extends GenericCompanion[CC] { diff --git a/src/library/scala/collection/generic/GenericSetTemplate.scala b/src/library/scala/collection/generic/GenericSetTemplate.scala index 6af6a36981..221bcfb379 100644 --- a/src/library/scala/collection/generic/GenericSetTemplate.scala +++ b/src/library/scala/collection/generic/GenericSetTemplate.scala @@ -8,7 +8,7 @@ package scala.collection package generic - +import language.higherKinds /** * @since 2.8 */ diff --git a/src/library/scala/collection/generic/GenericTraversableTemplate.scala b/src/library/scala/collection/generic/GenericTraversableTemplate.scala index 6586434924..b26e07393c 100644 --- a/src/library/scala/collection/generic/GenericTraversableTemplate.scala +++ b/src/library/scala/collection/generic/GenericTraversableTemplate.scala @@ -14,6 +14,7 @@ package generic import mutable.Builder import annotation.migration import annotation.unchecked.uncheckedVariance +import language.higherKinds /** A template class for companion objects of ``regular`` collection classes * that represent an unconstrained higher-kinded type. diff --git a/src/library/scala/collection/generic/ImmutableMapFactory.scala b/src/library/scala/collection/generic/ImmutableMapFactory.scala index bdb657f320..d893188e92 100644 --- a/src/library/scala/collection/generic/ImmutableMapFactory.scala +++ b/src/library/scala/collection/generic/ImmutableMapFactory.scala @@ -10,6 +10,8 @@ package scala.collection package generic +import language.higherKinds + /** A template for companion objects of `immutable.Map` and subclasses thereof. * @author Martin Odersky * @version 2.8 diff --git a/src/library/scala/collection/generic/ImmutableSetFactory.scala b/src/library/scala/collection/generic/ImmutableSetFactory.scala index e128be70a1..7bd5bf2ef8 100644 --- a/src/library/scala/collection/generic/ImmutableSetFactory.scala +++ b/src/library/scala/collection/generic/ImmutableSetFactory.scala @@ -10,6 +10,7 @@ package scala.collection package generic import mutable.{ Builder, SetBuilder } +import language.higherKinds abstract class ImmutableSetFactory[CC[X] <: immutable.Set[X] with SetLike[X, CC[X]]] extends SetFactory[CC] { diff --git a/src/library/scala/collection/generic/ImmutableSortedMapFactory.scala b/src/library/scala/collection/generic/ImmutableSortedMapFactory.scala index 89e19eed87..93aae0e355 100644 --- a/src/library/scala/collection/generic/ImmutableSortedMapFactory.scala +++ b/src/library/scala/collection/generic/ImmutableSortedMapFactory.scala @@ -11,6 +11,8 @@ package scala.collection package generic +import language.higherKinds + /** A template for companion objects of `SortedMap` and subclasses thereof. * * @since 2.8 diff --git a/src/library/scala/collection/generic/ImmutableSortedSetFactory.scala b/src/library/scala/collection/generic/ImmutableSortedSetFactory.scala index fe807d9fe6..67fb72270c 100644 --- a/src/library/scala/collection/generic/ImmutableSortedSetFactory.scala +++ b/src/library/scala/collection/generic/ImmutableSortedSetFactory.scala @@ -11,6 +11,8 @@ package scala.collection package generic +import language.higherKinds + /** A template for companion objects of `SortedSet` and subclasses thereof. * * @since 2.8 @@ -23,4 +25,4 @@ package generic * @define sortedSetCanBuildFromInfo * The standard `CanBuildFrom` instance for sorted sets */ -abstract class ImmutableSortedSetFactory[CC[A] <: immutable.SortedSet[A] with SortedSetLike[A, CC[A]]] extends SortedSetFactory[CC]
\ No newline at end of file +abstract class ImmutableSortedSetFactory[CC[A] <: immutable.SortedSet[A] with SortedSetLike[A, CC[A]]] extends SortedSetFactory[CC] diff --git a/src/library/scala/collection/generic/MapFactory.scala b/src/library/scala/collection/generic/MapFactory.scala index a60e3032c1..e502c4067e 100644 --- a/src/library/scala/collection/generic/MapFactory.scala +++ b/src/library/scala/collection/generic/MapFactory.scala @@ -12,6 +12,7 @@ package generic import mutable.{Builder, MapBuilder} import annotation.bridge +import language.higherKinds /** A template for companion objects of `Map` and subclasses thereof. * diff --git a/src/library/scala/collection/generic/MutableMapFactory.scala b/src/library/scala/collection/generic/MutableMapFactory.scala index 076e41c9f8..8b38b4ddd5 100644 --- a/src/library/scala/collection/generic/MutableMapFactory.scala +++ b/src/library/scala/collection/generic/MutableMapFactory.scala @@ -12,6 +12,7 @@ package scala.collection package generic import mutable.Builder +import language.higherKinds /** A template for companion objects of `mutable.Map` and subclasses thereof. * @author Martin Odersky diff --git a/src/library/scala/collection/generic/MutableSetFactory.scala b/src/library/scala/collection/generic/MutableSetFactory.scala index 6130ef2042..f130489814 100644 --- a/src/library/scala/collection/generic/MutableSetFactory.scala +++ b/src/library/scala/collection/generic/MutableSetFactory.scala @@ -10,6 +10,7 @@ package scala.collection package generic import mutable.{ Builder, GrowingBuilder } +import language.higherKinds abstract class MutableSetFactory[CC[X] <: mutable.Set[X] with mutable.SetLike[X, CC[X]]] extends SetFactory[CC] { diff --git a/src/library/scala/collection/generic/MutableSortedSetFactory.scala b/src/library/scala/collection/generic/MutableSortedSetFactory.scala index cbbedc0231..b0dd23ee1a 100644 --- a/src/library/scala/collection/generic/MutableSortedSetFactory.scala +++ b/src/library/scala/collection/generic/MutableSortedSetFactory.scala @@ -10,6 +10,7 @@ package scala.collection package generic import scala.collection.mutable.{ Builder, GrowingBuilder } +import language.higherKinds /** * @define Coll mutable.SortedSet diff --git a/src/library/scala/collection/generic/OrderedTraversableFactory.scala b/src/library/scala/collection/generic/OrderedTraversableFactory.scala index 259e4123c4..92f166ae08 100644 --- a/src/library/scala/collection/generic/OrderedTraversableFactory.scala +++ b/src/library/scala/collection/generic/OrderedTraversableFactory.scala @@ -10,9 +10,7 @@ package scala.collection package generic - - - +import language.higherKinds abstract class OrderedTraversableFactory[CC[X] <: Traversable[X] with GenericOrderedTraversableTemplate[X, CC]] extends GenericOrderedCompanion[CC] { diff --git a/src/library/scala/collection/generic/ParFactory.scala b/src/library/scala/collection/generic/ParFactory.scala index 558024d45c..0829ba6616 100644 --- a/src/library/scala/collection/generic/ParFactory.scala +++ b/src/library/scala/collection/generic/ParFactory.scala @@ -10,6 +10,7 @@ package scala.collection.generic import scala.collection.parallel.ParIterable import scala.collection.parallel.Combiner +import language.higherKinds /** A template class for companion objects of `ParIterable` and subclasses * thereof. This class extends `TraversableFactory` and provides a set of diff --git a/src/library/scala/collection/generic/ParMapFactory.scala b/src/library/scala/collection/generic/ParMapFactory.scala index 2d89f79c13..c05ab73431 100644 --- a/src/library/scala/collection/generic/ParMapFactory.scala +++ b/src/library/scala/collection/generic/ParMapFactory.scala @@ -12,6 +12,7 @@ import scala.collection.parallel.ParMap import scala.collection.parallel.ParMapLike import scala.collection.parallel.Combiner import scala.collection.mutable.Builder +import language.higherKinds /** A template class for companion objects of `ParMap` and subclasses thereof. * This class extends `TraversableFactory` and provides a set of operations diff --git a/src/library/scala/collection/generic/ParSetFactory.scala b/src/library/scala/collection/generic/ParSetFactory.scala index c2cf971d73..30a36a734a 100644 --- a/src/library/scala/collection/generic/ParSetFactory.scala +++ b/src/library/scala/collection/generic/ParSetFactory.scala @@ -12,6 +12,7 @@ import collection.mutable.Builder import collection.parallel.Combiner import collection.parallel.ParSet import collection.parallel.ParSetLike +import language.higherKinds /** * @author Aleksandar Prokopec diff --git a/src/library/scala/collection/generic/SeqFactory.scala b/src/library/scala/collection/generic/SeqFactory.scala index 7bd92173ff..3f61de6ceb 100644 --- a/src/library/scala/collection/generic/SeqFactory.scala +++ b/src/library/scala/collection/generic/SeqFactory.scala @@ -10,6 +10,7 @@ package scala.collection package generic +import language.higherKinds /** A template for companion objects of Seq and subclasses thereof. * diff --git a/src/library/scala/collection/generic/SetFactory.scala b/src/library/scala/collection/generic/SetFactory.scala index 348743a120..fb99f83ebb 100644 --- a/src/library/scala/collection/generic/SetFactory.scala +++ b/src/library/scala/collection/generic/SetFactory.scala @@ -13,6 +13,7 @@ package generic import mutable.Builder import annotation.bridge +import language.higherKinds abstract class SetFactory[CC[X] <: Set[X] with SetLike[X, CC[X]]] extends GenSetFactory[CC] with GenericSeqCompanion[CC] { diff --git a/src/library/scala/collection/generic/SortedMapFactory.scala b/src/library/scala/collection/generic/SortedMapFactory.scala index 962a945037..f038c8b09b 100644 --- a/src/library/scala/collection/generic/SortedMapFactory.scala +++ b/src/library/scala/collection/generic/SortedMapFactory.scala @@ -12,6 +12,7 @@ package scala.collection package generic import mutable.{Builder, MapBuilder} +import language.higherKinds /** A template for companion objects of mutable.Map and subclasses thereof. * diff --git a/src/library/scala/collection/generic/SortedSetFactory.scala b/src/library/scala/collection/generic/SortedSetFactory.scala index 45340cf6c1..bb261803a9 100644 --- a/src/library/scala/collection/generic/SortedSetFactory.scala +++ b/src/library/scala/collection/generic/SortedSetFactory.scala @@ -12,6 +12,7 @@ package scala.collection package generic import mutable.{Builder, SetBuilder} +import language.higherKinds /** A template for companion objects of Set and subclasses thereof. * diff --git a/src/library/scala/collection/generic/TraversableFactory.scala b/src/library/scala/collection/generic/TraversableFactory.scala index e71de1252c..07da1bb5c2 100644 --- a/src/library/scala/collection/generic/TraversableFactory.scala +++ b/src/library/scala/collection/generic/TraversableFactory.scala @@ -11,6 +11,7 @@ package scala.collection package generic import annotation.bridge +import language.higherKinds /** A template for companion objects of `Traversable` and subclasses thereof. * This class provides a set of operations to create `$Coll` objects. diff --git a/src/library/scala/collection/immutable/ListSet.scala b/src/library/scala/collection/immutable/ListSet.scala index 47e3245117..b71071d3c0 100644 --- a/src/library/scala/collection/immutable/ListSet.scala +++ b/src/library/scala/collection/immutable/ListSet.scala @@ -33,7 +33,7 @@ object ListSet extends ImmutableSetFactory[ListSet] { */ class ListSetBuilder[Elem](initial: ListSet[Elem]) extends Builder[Elem, ListSet[Elem]] { def this() = this(empty[Elem]) - protected val elems = new mutable.ListBuffer[Elem] ++= initial reverse + protected val elems = (new mutable.ListBuffer[Elem] ++= initial).reverse protected val seen = new mutable.HashSet[Elem] ++= initial def +=(x: Elem): this.type = { @@ -100,7 +100,7 @@ class ListSet[A] extends AbstractSet[A] */ override def ++(xs: GenTraversableOnce[A]): ListSet[A] = if (xs.isEmpty) this - else new ListSet.ListSetBuilder(this) ++= xs.seq result + else (new ListSet.ListSetBuilder(this) ++= xs.seq).result @bridge def ++(xs: TraversableOnce[A]): ListSet[A] = ++(xs: GenTraversableOnce[A]): ListSet[A] diff --git a/src/library/scala/collection/immutable/Stream.scala b/src/library/scala/collection/immutable/Stream.scala index 2eb2f8eb09..2df4ed70c7 100644 --- a/src/library/scala/collection/immutable/Stream.scala +++ b/src/library/scala/collection/immutable/Stream.scala @@ -13,6 +13,7 @@ import generic._ import mutable.{Builder, StringBuilder, LazyBuilder, ListBuffer} import scala.annotation.tailrec import Stream.cons +import language.implicitConversions /** The class `Stream` implements lazy lists where elements * are only evaluated when they are needed. Here is an example: @@ -821,7 +822,7 @@ self => */ override def distinct: Stream[A] = if (isEmpty) this - else cons(head, tail.filter(head !=).distinct) + else cons(head, tail.filter(head != _).distinct) /** Returns a new sequence of given length containing the elements of this * sequence followed by zero or more occurrences of given elements. diff --git a/src/library/scala/collection/immutable/StringLike.scala b/src/library/scala/collection/immutable/StringLike.scala index fc4e7bf0a8..06f09f359f 100644 --- a/src/library/scala/collection/immutable/StringLike.scala +++ b/src/library/scala/collection/immutable/StringLike.scala @@ -60,7 +60,7 @@ self => val end = until min length if (start >= end) newBuilder.result - else newBuilder ++= toString.substring(start, end) result + else (newBuilder ++= toString.substring(start, end)).result } /** Return the current string concatenated `n` times. diff --git a/src/library/scala/collection/immutable/TrieIterator.scala b/src/library/scala/collection/immutable/TrieIterator.scala index c77334b732..ead1a8c744 100644 --- a/src/library/scala/collection/immutable/TrieIterator.scala +++ b/src/library/scala/collection/immutable/TrieIterator.scala @@ -75,7 +75,7 @@ private[collection] abstract class TrieIterator[+T](elems: Array[Iterable[T]]) e } private[this] def iteratorWithSize(arr: Array[Iterable[T]]): (Iterator[T], Int) = - (newIterator(arr), arr map (_.size) sum) + (newIterator(arr), arr.map(_.size).sum) private[this] def arrayToIterators(arr: Array[Iterable[T]]): SplitIterators = { val (fst, snd) = arr.splitAt(arr.length / 2) diff --git a/src/library/scala/collection/mutable/ArrayOps.scala b/src/library/scala/collection/mutable/ArrayOps.scala index 3e7b8071be..875030ade0 100644 --- a/src/library/scala/collection/mutable/ArrayOps.scala +++ b/src/library/scala/collection/mutable/ArrayOps.scala @@ -65,7 +65,7 @@ abstract class ArrayOps[T] extends ArrayLike[T, Array[T]] with CustomParalleliza */ def flatten[U, To](implicit asTrav: T => collection.Traversable[U], m: ClassManifest[U]): Array[U] = { val b = Array.newBuilder[U] - b.sizeHint(map{case is: collection.IndexedSeq[_] => is.size case _ => 0} sum) + b.sizeHint(map{case is: collection.IndexedSeq[_] => is.size case _ => 0}.sum) for (xs <- this) b ++= asTrav(xs) b.result diff --git a/src/library/scala/collection/mutable/IndexedSeqView.scala b/src/library/scala/collection/mutable/IndexedSeqView.scala index 593af92255..a0de2ec8ad 100644 --- a/src/library/scala/collection/mutable/IndexedSeqView.scala +++ b/src/library/scala/collection/mutable/IndexedSeqView.scala @@ -14,6 +14,7 @@ package mutable import generic._ import TraversableView.NoBuilder +import language.implicitConversions /** A non-strict view of a mutable `IndexedSeq`. * $viewInfo diff --git a/src/library/scala/collection/mutable/LinkedHashSet.scala b/src/library/scala/collection/mutable/LinkedHashSet.scala index f6d4915fef..d2815cf9de 100644 --- a/src/library/scala/collection/mutable/LinkedHashSet.scala +++ b/src/library/scala/collection/mutable/LinkedHashSet.scala @@ -82,7 +82,7 @@ class LinkedHashSet[A] extends AbstractSet[A] private def readObject(in: java.io.ObjectInputStream) { ordered = new ListBuffer[A] - init(in, ordered += ) + init(in, ordered += _) } } diff --git a/src/library/scala/collection/mutable/StringBuilder.scala b/src/library/scala/collection/mutable/StringBuilder.scala index d9ad58f054..08c881dbb8 100644 --- a/src/library/scala/collection/mutable/StringBuilder.scala +++ b/src/library/scala/collection/mutable/StringBuilder.scala @@ -404,7 +404,7 @@ final class StringBuilder(private val underlying: JavaStringBuilder) * @return the reversed StringBuilder */ @migration("`reverse` returns a new instance. Use `reverseContents` to update in place and return that StringBuilder itself.", "2.8.0") - override def reverse: StringBuilder = new StringBuilder(new JavaStringBuilder(underlying) reverse) + override def reverse: StringBuilder = new StringBuilder(new JavaStringBuilder(underlying).reverse) override def clone(): StringBuilder = new StringBuilder(new JavaStringBuilder(underlying)) diff --git a/src/library/scala/collection/parallel/ParIterableLike.scala b/src/library/scala/collection/parallel/ParIterableLike.scala index 5551c04ce2..5bf338f560 100644 --- a/src/library/scala/collection/parallel/ParIterableLike.scala +++ b/src/library/scala/collection/parallel/ParIterableLike.scala @@ -29,6 +29,7 @@ import java.util.concurrent.atomic.AtomicBoolean import annotation.unchecked.uncheckedVariance import annotation.unchecked.uncheckedStable +import language.implicitConversions /** A template trait for parallel collections of type `ParIterable[T]`. diff --git a/src/library/scala/collection/parallel/ParIterableViewLike.scala b/src/library/scala/collection/parallel/ParIterableViewLike.scala index 536139c812..91eefc2aa5 100644 --- a/src/library/scala/collection/parallel/ParIterableViewLike.scala +++ b/src/library/scala/collection/parallel/ParIterableViewLike.scala @@ -18,6 +18,7 @@ import scala.collection.GenSeq import scala.collection.generic.{ CanBuildFrom, SliceInterval } import scala.collection.generic.CanCombineFrom import scala.collection.parallel.immutable.ParRange +import language.implicitConversions diff --git a/src/library/scala/collection/parallel/package.scala b/src/library/scala/collection/parallel/package.scala index 943e0208c7..e3124af12e 100644 --- a/src/library/scala/collection/parallel/package.scala +++ b/src/library/scala/collection/parallel/package.scala @@ -13,6 +13,7 @@ import scala.collection.generic.CanCombineFrom import scala.collection.parallel.mutable.ParArray import scala.collection.mutable.UnrolledBuffer import annotation.unchecked.uncheckedVariance +import language.implicitConversions /** Package object for parallel collections. */ diff --git a/src/library/scala/concurrent/ConcurrentPackageObject.scala b/src/library/scala/concurrent/ConcurrentPackageObject.scala index 789738e6ec..fafd7fd238 100644 --- a/src/library/scala/concurrent/ConcurrentPackageObject.scala +++ b/src/library/scala/concurrent/ConcurrentPackageObject.scala @@ -12,7 +12,7 @@ import java.util.concurrent.{ Executors, ExecutorService, ThreadFactory } import scala.concurrent.forkjoin.{ ForkJoinPool, ForkJoinWorkerThread } import scala.concurrent.util.Duration import ConcurrentPackageObject._ - +import language.implicitConversions /** This package object contains primitives for concurrent and parallel programming. diff --git a/src/library/scala/concurrent/Future.scala b/src/library/scala/concurrent/Future.scala index 1463dbcebf..0d76c23c25 100644 --- a/src/library/scala/concurrent/Future.scala +++ b/src/library/scala/concurrent/Future.scala @@ -24,6 +24,7 @@ import scala.annotation.tailrec import scala.collection.mutable.Stack import scala.collection.mutable.Builder import scala.collection.generic.CanBuildFrom +import language.higherKinds diff --git a/src/library/scala/concurrent/FutureTaskRunner.scala b/src/library/scala/concurrent/FutureTaskRunner.scala index 75e6299ad9..9d6f8a7a88 100644 --- a/src/library/scala/concurrent/FutureTaskRunner.scala +++ b/src/library/scala/concurrent/FutureTaskRunner.scala @@ -8,6 +8,8 @@ package scala.concurrent +import language.{implicitConversions, higherKinds} + /** The `FutureTaskRunner</code> trait is a base trait of task runners * that provide some sort of future abstraction. * diff --git a/src/library/scala/concurrent/JavaConversions.scala b/src/library/scala/concurrent/JavaConversions.scala index 127a0e0055..9b5e741549 100644 --- a/src/library/scala/concurrent/JavaConversions.scala +++ b/src/library/scala/concurrent/JavaConversions.scala @@ -9,6 +9,7 @@ package scala.concurrent import java.util.concurrent.{ExecutorService, Executor} +import language.implicitConversions /** The `JavaConversions` object provides implicit converstions supporting * interoperability between Scala and Java concurrency classes. diff --git a/src/library/scala/concurrent/TaskRunner.scala b/src/library/scala/concurrent/TaskRunner.scala index 500d79e07f..3180e9ce8a 100644 --- a/src/library/scala/concurrent/TaskRunner.scala +++ b/src/library/scala/concurrent/TaskRunner.scala @@ -8,6 +8,8 @@ package scala.concurrent +import language.{higherKinds, implicitConversions} + /** The `TaskRunner` trait... * * @author Philipp Haller diff --git a/src/library/scala/concurrent/ThreadPoolRunner.scala b/src/library/scala/concurrent/ThreadPoolRunner.scala index a3e0253634..fd6882348a 100644 --- a/src/library/scala/concurrent/ThreadPoolRunner.scala +++ b/src/library/scala/concurrent/ThreadPoolRunner.scala @@ -9,6 +9,7 @@ package scala.concurrent import java.util.concurrent.{ExecutorService, Callable, TimeUnit} +import language.implicitConversions /** The `ThreadPoolRunner` trait uses a `java.util.concurrent.ExecutorService` * to run submitted tasks. diff --git a/src/library/scala/concurrent/ThreadRunner.scala b/src/library/scala/concurrent/ThreadRunner.scala index 28fcf57df8..76be94aa6b 100644 --- a/src/library/scala/concurrent/ThreadRunner.scala +++ b/src/library/scala/concurrent/ThreadRunner.scala @@ -9,6 +9,7 @@ package scala.concurrent import java.lang.Thread +import language.implicitConversions /** The `ThreadRunner` trait... * diff --git a/src/library/scala/concurrent/util/Duration.scala b/src/library/scala/concurrent/util/Duration.scala index 6ee1696d39..15a546de10 100644 --- a/src/library/scala/concurrent/util/Duration.scala +++ b/src/library/scala/concurrent/util/Duration.scala @@ -7,6 +7,7 @@ package scala.concurrent.util import java.util.concurrent.TimeUnit import TimeUnit._ import java.lang.{ Double ⇒ JDouble } +import language.implicitConversions case class Deadline private (time: Duration) { def +(other: Duration): Deadline = copy(time = time + other) diff --git a/src/library/scala/concurrent/util/duration/NumericMultiplication.scala b/src/library/scala/concurrent/util/duration/IntMult.scala index 94c58fb8c2..94c58fb8c2 100644 --- a/src/library/scala/concurrent/util/duration/NumericMultiplication.scala +++ b/src/library/scala/concurrent/util/duration/IntMult.scala diff --git a/src/library/scala/io/BytePickle.scala b/src/library/scala/io/BytePickle.scala index bec0cfb53f..3bb5ea9c2b 100644 --- a/src/library/scala/io/BytePickle.scala +++ b/src/library/scala/io/BytePickle.scala @@ -269,7 +269,7 @@ object BytePickle { } def string: SPU[String] = share(wrap( - (a: Array[Byte]) => Codec fromUTF8 a mkString, + (a: Array[Byte]) => (Codec fromUTF8 a).mkString, (s: String) => Codec toUTF8 s, bytearray )) diff --git a/src/library/scala/io/Codec.scala b/src/library/scala/io/Codec.scala index d9cef0edb1..84cac88dcc 100644 --- a/src/library/scala/io/Codec.scala +++ b/src/library/scala/io/Codec.scala @@ -11,6 +11,7 @@ package scala.io import java.nio.charset.{ Charset, CharsetDecoder, CharsetEncoder, CharacterCodingException, CodingErrorAction => Action } import annotation.migration +import language.implicitConversions // Some notes about encodings for use in refining this implementation. // diff --git a/src/library/scala/io/Source.scala b/src/library/scala/io/Source.scala index 3cee0ace79..5e09e13680 100644 --- a/src/library/scala/io/Source.scala +++ b/src/library/scala/io/Source.scala @@ -188,7 +188,7 @@ abstract class Source extends Iterator[Char] { var nerrors = 0 var nwarnings = 0 - private def lineNum(line: Int): String = getLines() drop (line - 1) take 1 mkString + private def lineNum(line: Int): String = (getLines() drop (line - 1) take 1).mkString class LineIterator extends AbstractIterator[String] with Iterator[String] { private[this] val sb = new StringBuilder diff --git a/src/library/scala/language.scala b/src/library/scala/language.scala new file mode 100644 index 0000000000..907adb5f72 --- /dev/null +++ b/src/library/scala/language.scala @@ -0,0 +1,25 @@ +package scala + +object language { + + import languageFeature._ + + implicit val dynamics: dynamics = ??? + + implicit val postfixOps: postfixOps = ??? + + implicit val reflectiveCalls: reflectiveCalls = ??? + + implicit val implicitConversions: implicitConversions = ??? + + implicit val higherKinds: higherKinds = ??? + + implicit val existentials: existentials = ??? + + object experimental { + + import languageFeature.experimental._ + + implicit val macros: macros = ??? + } +} diff --git a/src/library/scala/languageFeature.scala b/src/library/scala/languageFeature.scala new file mode 100644 index 0000000000..c990f714c1 --- /dev/null +++ b/src/library/scala/languageFeature.scala @@ -0,0 +1,30 @@ +package scala + +import annotation.meta + +object languageFeature { + + @meta.languageFeature("extension of type scala.Dynamic", true) + sealed trait dynamics + + @meta.languageFeature("postfix operator #", false) + sealed trait postfixOps + + @meta.languageFeature("reflective access of structural type member #", false) + sealed trait reflectiveCalls + + @meta.languageFeature("implicit conversion #", false) + sealed trait implicitConversions + + @meta.languageFeature("higher-kinded type", false) + sealed trait higherKinds + + @meta.languageFeature("#, which cannot be expressed by wildcards, ", false) + sealed trait existentials + + object experimental { + @meta.languageFeature("macro definition", true) + sealed trait macros + } +} + diff --git a/src/library/scala/math/BigDecimal.scala b/src/library/scala/math/BigDecimal.scala index cb42b76b51..74daa510ca 100644 --- a/src/library/scala/math/BigDecimal.scala +++ b/src/library/scala/math/BigDecimal.scala @@ -12,6 +12,7 @@ package scala.math import java.{ lang => jl } import java.math.{ MathContext, BigDecimal => BigDec } import scala.collection.immutable.NumericRange +import language.implicitConversions /** @@ -292,7 +293,7 @@ extends ScalaNumber with ScalaNumericConversions with Serializable { /** Returns the absolute value of this BigDecimal */ - def abs: BigDecimal = this.bigDecimal abs + def abs: BigDecimal = this.bigDecimal.abs /** Returns the sign of this BigDecimal, i.e. * -1 if it is less than 0, diff --git a/src/library/scala/math/BigInt.scala b/src/library/scala/math/BigInt.scala index dbec30b2fe..ff52ca9bec 100644 --- a/src/library/scala/math/BigInt.scala +++ b/src/library/scala/math/BigInt.scala @@ -9,6 +9,7 @@ package scala.math import java.math.BigInteger +import language.implicitConversions /** * @author Martin Odersky diff --git a/src/library/scala/math/Fractional.scala b/src/library/scala/math/Fractional.scala index de09b184e0..0686569c16 100644 --- a/src/library/scala/math/Fractional.scala +++ b/src/library/scala/math/Fractional.scala @@ -8,6 +8,8 @@ package scala.math +import language.implicitConversions + /** * @since 2.8 */ diff --git a/src/library/scala/math/Integral.scala b/src/library/scala/math/Integral.scala index bb364a79b4..4b4de28228 100644 --- a/src/library/scala/math/Integral.scala +++ b/src/library/scala/math/Integral.scala @@ -10,6 +10,8 @@ package scala.math +import language.implicitConversions + /** * @since 2.8 */ diff --git a/src/library/scala/math/Numeric.scala b/src/library/scala/math/Numeric.scala index ff88e0ff4d..1f4e3c9865 100644 --- a/src/library/scala/math/Numeric.scala +++ b/src/library/scala/math/Numeric.scala @@ -8,6 +8,8 @@ package scala.math +import language.implicitConversions + /** * @since 2.8 */ diff --git a/src/library/scala/math/Ordered.scala b/src/library/scala/math/Ordered.scala index b76030718f..80addea7f3 100644 --- a/src/library/scala/math/Ordered.scala +++ b/src/library/scala/math/Ordered.scala @@ -8,6 +8,8 @@ package scala.math +import language.implicitConversions + /** A trait for data that have a single, natural ordering. See * [[scala.math.Ordering]] before using this trait for * more information about whether to use [[scala.math.Ordering]] instead. diff --git a/src/library/scala/math/Ordering.scala b/src/library/scala/math/Ordering.scala index 8fc74a9d5d..ab685815a1 100644 --- a/src/library/scala/math/Ordering.scala +++ b/src/library/scala/math/Ordering.scala @@ -9,6 +9,7 @@ package scala.math import java.util.Comparator +import language.{implicitConversions, higherKinds} /** Ordering is a trait whose instances each represent a strategy for sorting * instances of a type. diff --git a/src/library/scala/reflect/ArrayTags.scala b/src/library/scala/reflect/ArrayTag.scala index 8df7fe5f4e..8df7fe5f4e 100644 --- a/src/library/scala/reflect/ArrayTags.scala +++ b/src/library/scala/reflect/ArrayTag.scala diff --git a/src/library/scala/reflect/ClassTags.scala b/src/library/scala/reflect/ClassTag.scala index cde6da5539..7138837f0d 100644 --- a/src/library/scala/reflect/ClassTags.scala +++ b/src/library/scala/reflect/ClassTag.scala @@ -2,6 +2,7 @@ package scala.reflect import java.lang.{ Class => jClass } import scala.reflect.{ mirror => rm } +import language.{implicitConversions, existentials} /** A `ClassTag[T]` wraps a Java class, which can be accessed via the `erasure` method. * @@ -164,4 +165,4 @@ class DeprecatedClassManifestApis[T](ctag: ClassTag[T]) { @deprecated("`typeArguments` is no longer supported, and will always return an empty list. Use `@scala.reflect.TypeTag` or `@scala.reflect.ConcreteTypeTag` to capture and analyze type arguments", "2.10.0") def typeArguments: List[OptManifest[_]] = List() -}
\ No newline at end of file +} diff --git a/src/library/scala/reflect/DynamicProxy.scala b/src/library/scala/reflect/DynamicProxy.scala new file mode 100644 index 0000000000..ffd1e7a39f --- /dev/null +++ b/src/library/scala/reflect/DynamicProxy.scala @@ -0,0 +1,74 @@ +package scala.reflect +/** + * A dynamic proxy which redirects method calls and attribute access to a given + * target object at runtime using reflection. + * + * Usage example: + * + * object x{ def hello = "hello world" } + * val d = new DynamicProxy{ val dynamicProxyTarget = x } + * assert( d.hello == "hello world" ) + * + * Not supported (yet): + * - implicit conversions and parameters + * - multiple arguments lists + * - explicit type arguments + */ +trait DynamicProxy extends Dynamic{ + /** Method calls on DynamicProxy are redirected to this object. Needs to be defined in a subclass. */ + val dynamicProxyTarget : AnyRef + + import scala.reflect.mirror._ + /** + * boxing to preserve information on primitive types for overloading resolution + */ + case class DynamicReflectBoxed( class_ : Class[_], value: Any ) + object DynamicReflectBoxed{ + implicit def box[@specialized T]( v:T ) = DynamicReflectBoxed( v.getClass, v ) + } + + def selectDynamic( method:String ) = { + val symbol = classToType( dynamicProxyTarget.getClass ).member( newTermName(method).encodedName ) + invoke( dynamicProxyTarget, symbol )() + } + + def updateDynamic( method:String )( value : Any ) = { + val symbol = classToType( dynamicProxyTarget.getClass ).member( newTermName(method+"_=").encodedName ) + invoke( dynamicProxyTarget, symbol )( value ) + } + + def applyDynamic( method:String )( args:DynamicReflectBoxed* ) : Any + = applyDynamicNamed( method )( args.map( value => ("",value) ) :_* ) + + def applyDynamicNamed( method:String )( args:(String,DynamicReflectBoxed)* ) : Any = { + val class_ = dynamicProxyTarget.getClass + var i = 0 + val toolbox = mkToolBox(mkConsoleReporter(),"") + val symbol = classToType( dynamicProxyTarget.getClass ).member( newTermName(method).encodedName ) + if(args.size == 0){ + invoke( dynamicProxyTarget, symbol )() + } else { + val call = + Apply( + Select( + TypeApply( + Select( + Select( + Ident(newFreeTerm("__this", symbolForName("scala.reflect.DynamicProxy").asType, this, null)) + , newTermName("dynamicProxyTarget") + ), + newTermName("asInstanceOf") ) + , List(TypeTree().setType(classToType(class_))) + ) + ,newTermName(method).encodedName + ) + ,args.map{ case(name,box) => + val value = Ident(newFreeTerm("__arg"+({i+=1;i}.toString), classToType(box.class_), box.value, null)) + if( name == "" ) value + else AssignOrNamedArg( Ident(name), value ) + }.toList + ) + toolbox.runExpr( call ) + } + } +} diff --git a/src/library/scala/reflect/TagMaterialization.scala b/src/library/scala/reflect/TagMaterialization.scala index 5918b6effc..aede00020f 100644 --- a/src/library/scala/reflect/TagMaterialization.scala +++ b/src/library/scala/reflect/TagMaterialization.scala @@ -2,6 +2,7 @@ package scala.reflect import api.Universe import makro.Context +import language.implicitConversions // todo. unfortunately, current type inferencer doesn't infer type parameters of implicit values // this means that during macro expansion these macros will get Nothing instead of real T @@ -151,4 +152,4 @@ object TagMaterialization { c.abort(c.enclosingPosition, "No %s available for %s".format(tagModule.name, tpe)) } } -}
\ No newline at end of file +} diff --git a/src/library/scala/reflect/api/Attachments.scala b/src/library/scala/reflect/api/Attachment.scala index dfd362ebe0..dfd362ebe0 100644 --- a/src/library/scala/reflect/api/Attachments.scala +++ b/src/library/scala/reflect/api/Attachment.scala diff --git a/src/library/scala/reflect/api/Exprs.scala b/src/library/scala/reflect/api/Exprs.scala index 8c3f12783b..ff89a1cd48 100644 --- a/src/library/scala/reflect/api/Exprs.scala +++ b/src/library/scala/reflect/api/Exprs.scala @@ -5,6 +5,7 @@ package scala.reflect package api +import language.implicitConversions trait Exprs { self: Universe => @@ -38,10 +39,12 @@ trait Exprs { self: Universe => // and turns off typechecking whenever it's involved // that'd allow us to splice trees into quasiquotes and still have these qqs to be partially typechecked // see some exploration of these ideas here: https://github.com/xeno-by/alphakeplerdemo + // [Martin] I have some doubts whether it's god to have implicit conversions. implicit def tree2expr(tree: Tree): Expr[Nothing] = Expr[Nothing](tree)(TypeTag.Nothing) implicit def expr2tree(expr: Expr[_]): Tree = expr.tree // [Eugene] good idea? + // [Martin] probably not. implicit def trees2exprs(trees: List[Tree]): List[Expr[Nothing]] = trees map tree2expr implicit def exprs2trees(exprs: List[Expr[_]]): List[Tree] = exprs map expr2tree } diff --git a/src/library/scala/reflect/api/Names.scala b/src/library/scala/reflect/api/Names.scala index c72774dfc7..d92d056751 100755 --- a/src/library/scala/reflect/api/Names.scala +++ b/src/library/scala/reflect/api/Names.scala @@ -34,12 +34,12 @@ trait Names { def toTypeName: TypeName /** Replaces all occurrences of $op_names in this name by corresponding operator symbols. - * Example: `foo_+=` becomes `foo_$plus$eq`. + * Example: `foo_$plus$eq` becomes `foo_+=` */ def decoded: String /** Replaces all occurrences of operator symbols in this name by corresponding $op_names. - * Example: `foo_$plus$eq` becomes `foo_+=` + * Example: `foo_+=` becomes `foo_$plus$eq`. */ def encoded: String diff --git a/src/library/scala/reflect/api/Trees.scala b/src/library/scala/reflect/api/Trees.scala index 01f948809c..d659a9e9eb 100644 --- a/src/library/scala/reflect/api/Trees.scala +++ b/src/library/scala/reflect/api/Trees.scala @@ -294,18 +294,24 @@ trait Trees { self: Universe => override var symbol: Symbol = NoSymbol } + /** A tree with a name - effectively, a DefTree or RefTree. + */ + trait NameTree extends Tree { + def name: Name + } + /** A tree which references a symbol-carrying entity. * References one, as opposed to defining one; definitions * are in DefTrees. */ - trait RefTree extends SymTree { + trait RefTree extends SymTree with NameTree { def qualifier: Tree // empty for Idents def name: Name } /** A tree which defines a symbol-carrying entity. */ - abstract class DefTree extends SymTree { + abstract class DefTree extends SymTree with NameTree { def name: Name override def isDef = true } @@ -1519,7 +1525,7 @@ trait Trees { self: Universe => def transformStats(stats: List[Tree], exprOwner: Symbol): List[Tree] = stats mapConserve (stat => if (exprOwner != currentOwner && stat.isTerm) atOwner(exprOwner)(transform(stat)) - else transform(stat)) filter (EmptyTree !=) + else transform(stat)) filter (EmptyTree != _) def transformModifiers(mods: Modifiers): Modifiers = mods.mapAnnotations(transformTrees) diff --git a/src/library/scala/reflect/api/TypeTags.scala b/src/library/scala/reflect/api/TypeTags.scala index ed47620e13..4ffabe1c36 100644 --- a/src/library/scala/reflect/api/TypeTags.scala +++ b/src/library/scala/reflect/api/TypeTags.scala @@ -7,6 +7,7 @@ package scala.reflect package api import scala.reflect.{ mirror => rm } +import language.implicitConversions /** * Type tags encapsulate a representation of type T. @@ -191,4 +192,4 @@ trait TypeTags { self: Universe => // def typeTag[T](implicit ttag: TypeTag[T]) = ttag // def concreteTag[T](implicit gttag: ConcreteTypeTag[T]) = cttag // def concreteTypeTag[T](implicit gttag: ConcreteTypeTag[T]) = cttag -}
\ No newline at end of file +} diff --git a/src/library/scala/reflect/api/Universe.scala b/src/library/scala/reflect/api/Universe.scala index 60abd267cb..d1f546608e 100755 --- a/src/library/scala/reflect/api/Universe.scala +++ b/src/library/scala/reflect/api/Universe.scala @@ -1,5 +1,6 @@ package scala.reflect package api +import language.experimental.macros abstract class Universe extends Symbols with FreeVars diff --git a/src/library/scala/reflect/makro/Context.scala b/src/library/scala/reflect/makro/Context.scala index 96a41377b3..5ce801e2e6 100644 --- a/src/library/scala/reflect/makro/Context.scala +++ b/src/library/scala/reflect/makro/Context.scala @@ -1,5 +1,7 @@ package scala.reflect.makro +import language.experimental.macros + // todo. introduce context hierarchy // the most lightweight context should just expose the stuff from the SIP // the full context should include all traits from scala.reflect.makro (and probably reside in scala-compiler.jar) diff --git a/src/library/scala/reflect/makro/internal/typeTagImpl.scala b/src/library/scala/reflect/makro/internal/Utils.scala index de404ff39f..db658fd637 100644 --- a/src/library/scala/reflect/makro/internal/typeTagImpl.scala +++ b/src/library/scala/reflect/makro/internal/Utils.scala @@ -1,6 +1,8 @@ package scala.reflect.makro import scala.reflect.api.Universe +import language.implicitConversions +import language.experimental.macros /** This package is required by the compiler and <b>should not be used in client code</b>. */ package object internal { diff --git a/src/library/scala/runtime/ScalaRunTime.scala b/src/library/scala/runtime/ScalaRunTime.scala index d06eba8f7d..7a932c21bc 100644 --- a/src/library/scala/runtime/ScalaRunTime.scala +++ b/src/library/scala/runtime/ScalaRunTime.scala @@ -329,14 +329,14 @@ object ScalaRunTime { case null => "null" case "" => "\"\"" case x: String => if (x.head.isWhitespace || x.last.isWhitespace) "\"" + x + "\"" else x - case x if useOwnToString(x) => x toString + case x if useOwnToString(x) => x.toString case x: AnyRef if isArray(x) => arrayToString(x) case x: collection.Map[_, _] => x.iterator take maxElements map mapInner mkString (x.stringPrefix + "(", ", ", ")") case x: Iterable[_] => x.iterator take maxElements map inner mkString (x.stringPrefix + "(", ", ", ")") case x: Traversable[_] => x take maxElements map inner mkString (x.stringPrefix + "(", ", ", ")") case x: Product1[_] if isTuple(x) => "(" + inner(x._1) + ",)" // that special trailing comma case x: Product if isTuple(x) => x.productIterator map inner mkString ("(", ",", ")") - case x => x toString + case x => x.toString } // The try/catch is defense against iterables which aren't actually designed diff --git a/src/library/scala/sys/BooleanProp.scala b/src/library/scala/sys/BooleanProp.scala index e940990785..45fc6f5897 100644 --- a/src/library/scala/sys/BooleanProp.scala +++ b/src/library/scala/sys/BooleanProp.scala @@ -8,6 +8,8 @@ package scala.sys +import language.implicitConversions + /** A few additional conveniences for Boolean properties. */ trait BooleanProp extends Prop[Boolean] { diff --git a/src/library/scala/sys/SystemProperties.scala b/src/library/scala/sys/SystemProperties.scala index 52e0ac230b..4853da3495 100644 --- a/src/library/scala/sys/SystemProperties.scala +++ b/src/library/scala/sys/SystemProperties.scala @@ -11,6 +11,8 @@ package scala.sys import scala.collection.{ mutable, Iterator } import scala.collection.JavaConverters._ import java.security.AccessControlException +import language.implicitConversions + /** A bidirectional map wrapping the java System properties. * Changes to System properties will be immediately visible in the map, diff --git a/src/library/scala/sys/process/Process.scala b/src/library/scala/sys/process/Process.scala index c2a61af936..d56c6f2c9d 100644 --- a/src/library/scala/sys/process/Process.scala +++ b/src/library/scala/sys/process/Process.scala @@ -11,6 +11,7 @@ package process import processInternal._ import ProcessBuilder._ +import language.implicitConversions /** Represents a process that is running or has finished running. * It may be a compound process with several underlying native processes (such as `a #&& b`). diff --git a/src/library/scala/testing/Show.scala b/src/library/scala/testing/Show.scala index 7570bf705c..5ab46b8985 100644 --- a/src/library/scala/testing/Show.scala +++ b/src/library/scala/testing/Show.scala @@ -27,17 +27,17 @@ package scala.testing */ trait Show { - /** The result class of wrapper `symApply`. + /** An implicit definition that adds an apply method to Symbol which forwards to `test`. * Prints out diagnostics of method applications. */ - class SymApply(f: Symbol) { + implicit class SymApply(f: Symbol) { def apply[A](args: A*) { println(test(f, args: _*)) } } - /** An implicit definition that adds an apply method to Symbol which forwards to `test`. */ - implicit def symApply(sym: Symbol) = new SymApply(sym) + @deprecated("use SymApply instead", "2.10") + def symApply(sym: Symbol): SymApply = new SymApply(sym) /** Apply method with name of given symbol `f` to given arguments and return * a result diagnostics. diff --git a/src/library/scala/util/Random.scala b/src/library/scala/util/Random.scala index 62cba1fc5b..17c356801b 100644 --- a/src/library/scala/util/Random.scala +++ b/src/library/scala/util/Random.scala @@ -11,6 +11,7 @@ package scala.util import collection.mutable.ArrayBuffer import collection.generic.CanBuildFrom import scala.collection.immutable.{ List, Stream } +import language.{implicitConversions, higherKinds} /** * @author Stephane Micheloud @@ -117,7 +118,7 @@ class Random(val self: java.util.Random) { swap(n - 1, k) } - bf(xs) ++= buf result + (bf(xs) ++= buf).result } /** Returns a Stream of pseudorandomly chosen alphanumeric characters, diff --git a/src/library/scala/util/automata/BaseBerrySethi.scala b/src/library/scala/util/automata/BaseBerrySethi.scala index 18f36f9496..c78b2d0790 100644 --- a/src/library/scala/util/automata/BaseBerrySethi.scala +++ b/src/library/scala/util/automata/BaseBerrySethi.scala @@ -78,7 +78,7 @@ abstract class BaseBerrySethi { * @return ... */ protected def compFollow1(fol1: Set[Int], r: RegExp): Set[Int] = r match { - case x: Alt => Set(x.rs reverseMap (compFollow1(fol1, _)) flatten: _*) + case x: Alt => Set((x.rs reverseMap (compFollow1(fol1, _))).flatten: _*) case x: Meta => compFollow1(fol1, x.r) case x: Star => compFollow1(fol1 ++ compFirst(x.r), x.r) case x: Sequ => diff --git a/src/library/scala/util/automata/NondetWordAutom.scala b/src/library/scala/util/automata/NondetWordAutom.scala index fbc05de7fd..b09e82ca11 100644 --- a/src/library/scala/util/automata/NondetWordAutom.scala +++ b/src/library/scala/util/automata/NondetWordAutom.scala @@ -50,8 +50,8 @@ abstract class NondetWordAutom[T <: AnyRef] { override def toString = { val finalString = Map(finalStates map (j => j -> finals(j)) : _*).toString - val deltaString = (0 until nstates) . - map (i => " %d->%s\n _>%s\n".format(i, delta(i), default(i))) mkString + val deltaString = (0 until nstates) + .map(i => " %d->%s\n _>%s\n".format(i, delta(i), default(i))).mkString "[NondetWordAutom nstates=%d finals=%s delta=\n%s".format(nstates, finalString, deltaString) } diff --git a/src/library/scala/util/automata/SubsetConstruction.scala b/src/library/scala/util/automata/SubsetConstruction.scala index 8049d10d88..81805fce2f 100644 --- a/src/library/scala/util/automata/SubsetConstruction.scala +++ b/src/library/scala/util/automata/SubsetConstruction.scala @@ -14,7 +14,7 @@ class SubsetConstruction[T <: AnyRef](val nfa: NondetWordAutom[T]) { import nfa.labels def selectTag(Q: immutable.BitSet, finals: Array[Int]) = - Q map finals filter (_ > 0) min + (Q map finals filter (_ > 0)).min def determinize: DetWordAutom[T] = { // for assigning numbers to bitsets diff --git a/src/library/scala/util/automata/WordBerrySethi.scala b/src/library/scala/util/automata/WordBerrySethi.scala index 84b78d8dd8..a7ad92e648 100644 --- a/src/library/scala/util/automata/WordBerrySethi.scala +++ b/src/library/scala/util/automata/WordBerrySethi.scala @@ -139,7 +139,7 @@ abstract class WordBerrySethi extends BaseBerrySethi { finals = finals.updated(0, finalTag) val delta1 = immutable.Map(deltaq.zipWithIndex map (_.swap): _*) - val finalsArr = 0 until pos map (k => finals.getOrElse(k, 0)) toArray // 0 == not final + val finalsArr = (0 until pos map (k => finals.getOrElse(k, 0))).toArray // 0 == not final val initialsArr = initials.toArray val deltaArr: Array[mutable.Map[_labelT, immutable.BitSet]] = @@ -147,7 +147,7 @@ abstract class WordBerrySethi extends BaseBerrySethi { mutable.HashMap(delta1(x).toSeq map { case (k, v) => k -> immutable.BitSet(v: _*) } : _*) }).toArray - val defaultArr = 0 until pos map (k => immutable.BitSet(defaultq(k): _*)) toArray + val defaultArr = (0 until pos map (k => immutable.BitSet(defaultq(k): _*))).toArray new NondetWordAutom[_labelT] { val nstates = pos @@ -161,4 +161,4 @@ abstract class WordBerrySethi extends BaseBerrySethi { automatonFrom(Sequ(z.asInstanceOf[this.lang._regexpT]), finalTag) } } -}
\ No newline at end of file +} diff --git a/src/library/scala/util/control/Exception.scala b/src/library/scala/util/control/Exception.scala index 20a179a884..1cae8088f5 100644 --- a/src/library/scala/util/control/Exception.scala +++ b/src/library/scala/util/control/Exception.scala @@ -10,6 +10,8 @@ package scala.util.control import collection.immutable.List import java.lang.reflect.InvocationTargetException +import language.implicitConversions + /** Classes representing the components of exception handling. * Each class is independently composable. Some example usages: diff --git a/src/library/scala/util/parsing/ast/Binders.scala b/src/library/scala/util/parsing/ast/Binders.scala index 0646f57064..09ad5ce2ab 100644 --- a/src/library/scala/util/parsing/ast/Binders.scala +++ b/src/library/scala/util/parsing/ast/Binders.scala @@ -10,6 +10,7 @@ package scala.util.parsing.ast import scala.collection.AbstractIterable import scala.collection.mutable +import language.implicitConversions //DISCLAIMER: this code is highly experimental! diff --git a/src/library/scala/util/parsing/combinator/ImplicitConversions.scala b/src/library/scala/util/parsing/combinator/ImplicitConversions.scala index e993628e88..270ac680a9 100644 --- a/src/library/scala/util/parsing/combinator/ImplicitConversions.scala +++ b/src/library/scala/util/parsing/combinator/ImplicitConversions.scala @@ -9,6 +9,8 @@ package scala.util.parsing.combinator +import language.implicitConversions + /** This object contains implicit conversions that come in handy when using the `^^` combinator. * * Refer to [[scala.util.parsing.combinator.Parsers]] to construct an AST from the concrete syntax. diff --git a/src/library/scala/util/parsing/combinator/PackratParsers.scala b/src/library/scala/util/parsing/combinator/PackratParsers.scala index ea856efc3a..9516df0093 100644 --- a/src/library/scala/util/parsing/combinator/PackratParsers.scala +++ b/src/library/scala/util/parsing/combinator/PackratParsers.scala @@ -11,6 +11,7 @@ package scala.util.parsing.combinator import scala.util.parsing.combinator._ import scala.util.parsing.input.{ Reader, Position } import scala.collection.mutable +import language.implicitConversions /** * `PackratParsers` is a component that extends the parser combinators diff --git a/src/library/scala/util/parsing/combinator/Parsers.scala b/src/library/scala/util/parsing/combinator/Parsers.scala index 9aaf0aeb54..e5458f89af 100644 --- a/src/library/scala/util/parsing/combinator/Parsers.scala +++ b/src/library/scala/util/parsing/combinator/Parsers.scala @@ -12,6 +12,7 @@ import scala.util.parsing.input._ import scala.collection.mutable.ListBuffer import scala.annotation.tailrec import annotation.migration +import language.implicitConversions // TODO: better error handling (labelling like parsec's <?>) diff --git a/src/library/scala/util/parsing/combinator/RegexParsers.scala b/src/library/scala/util/parsing/combinator/RegexParsers.scala index 86eecd03c4..d685329ef1 100644 --- a/src/library/scala/util/parsing/combinator/RegexParsers.scala +++ b/src/library/scala/util/parsing/combinator/RegexParsers.scala @@ -13,6 +13,7 @@ import java.util.regex.Pattern import scala.util.matching.Regex import scala.util.parsing.input._ import scala.collection.immutable.PagedSeq +import language.implicitConversions /** The ''most important'' differences between `RegexParsers` and * [[scala.util.parsing.combinator.Parsers]] are: diff --git a/src/library/scala/util/parsing/combinator/lexical/Lexical.scala b/src/library/scala/util/parsing/combinator/lexical/Lexical.scala index 9979a420d6..6c3bc52c1a 100644 --- a/src/library/scala/util/parsing/combinator/lexical/Lexical.scala +++ b/src/library/scala/util/parsing/combinator/lexical/Lexical.scala @@ -32,7 +32,7 @@ abstract class Lexical extends Scanners with Tokens { def digit = elem("digit", _.isDigit) /** A character-parser that matches any character except the ones given in `cs` (and returns it).*/ - def chrExcept(cs: Char*) = elem("", ch => (cs forall (ch !=))) + def chrExcept(cs: Char*) = elem("", ch => (cs forall (ch != _))) /** A character-parser that matches a white-space character (and returns it).*/ def whitespaceChar = elem("space char", ch => ch <= ' ' && ch != EofCh) diff --git a/src/library/scala/util/parsing/combinator/syntactical/StandardTokenParsers.scala b/src/library/scala/util/parsing/combinator/syntactical/StandardTokenParsers.scala index e494a69cf0..215b8b792f 100644 --- a/src/library/scala/util/parsing/combinator/syntactical/StandardTokenParsers.scala +++ b/src/library/scala/util/parsing/combinator/syntactical/StandardTokenParsers.scala @@ -13,6 +13,7 @@ package syntactical import token._ import lexical.StdLexical +import language.implicitConversions /** This component provides primitive parsers for the standard tokens defined in `StdTokens`. * diff --git a/src/library/scala/util/parsing/combinator/syntactical/StdTokenParsers.scala b/src/library/scala/util/parsing/combinator/syntactical/StdTokenParsers.scala index 0901f9bbd0..7aa6178df9 100644 --- a/src/library/scala/util/parsing/combinator/syntactical/StdTokenParsers.scala +++ b/src/library/scala/util/parsing/combinator/syntactical/StdTokenParsers.scala @@ -14,6 +14,7 @@ package syntactical import token._ import scala.collection.mutable +import language.implicitConversions /** This component provides primitive parsers for the standard tokens defined in `StdTokens`. * diff --git a/src/library/scala/util/parsing/combinator/testing/RegexTest.scala b/src/library/scala/util/parsing/combinator/testing/RegexTest.scala index 299736046e..255730e5db 100644 --- a/src/library/scala/util/parsing/combinator/testing/RegexTest.scala +++ b/src/library/scala/util/parsing/combinator/testing/RegexTest.scala @@ -3,6 +3,7 @@ package scala.util.parsing.combinator.testing import scala.util.parsing.combinator._ import scala.util.parsing.input._ +import language.postfixOps case class Ident(s: String) case class Number(n: Int) diff --git a/src/library/scala/xml/Elem.scala b/src/library/scala/xml/Elem.scala index 5b6b9f2bb9..f140fd1e07 100755 --- a/src/library/scala/xml/Elem.scala +++ b/src/library/scala/xml/Elem.scala @@ -107,5 +107,5 @@ extends Node with Serializable /** Returns concatenation of `text(n)` for each child `n`. */ - override def text = child map (_.text) mkString + override def text = (child map (_.text)).mkString } diff --git a/src/library/scala/xml/MetaData.scala b/src/library/scala/xml/MetaData.scala index c516747bae..b44a817499 100644 --- a/src/library/scala/xml/MetaData.scala +++ b/src/library/scala/xml/MetaData.scala @@ -167,7 +167,7 @@ extends AbstractIterable[MetaData] /** Returns a Map containing the attributes stored as key/value pairs. */ def asAttrMap: Map[String, String] = - iterator map (x => (x.prefixedKey, x.value.text)) toMap + (iterator map (x => (x.prefixedKey, x.value.text))).toMap /** returns Null or the next MetaData item */ def next: MetaData diff --git a/src/library/scala/xml/NodeSeq.scala b/src/library/scala/xml/NodeSeq.scala index ff5618645f..f0be338fcf 100644 --- a/src/library/scala/xml/NodeSeq.scala +++ b/src/library/scala/xml/NodeSeq.scala @@ -11,6 +11,7 @@ package scala.xml import collection.{ mutable, immutable, generic, SeqLike, AbstractSeq } import mutable.{ Builder, ListBuffer } import generic.{ CanBuildFrom } +import language.implicitConversions /** This object ... * @@ -152,5 +153,5 @@ abstract class NodeSeq extends AbstractSeq[Node] with immutable.Seq[Node] with S override def toString(): String = theSeq.mkString - def text: String = this map (_.text) mkString + def text: String = (this map (_.text)).mkString } diff --git a/src/library/scala/xml/Utility.scala b/src/library/scala/xml/Utility.scala index 9f944c0e92..062a62e240 100755 --- a/src/library/scala/xml/Utility.scala +++ b/src/library/scala/xml/Utility.scala @@ -10,6 +10,7 @@ package scala.xml import scala.collection.mutable import parsing.XhtmlEntities +import language.implicitConversions /** * The `Utility` object provides utility functions for processing instances @@ -20,6 +21,8 @@ import parsing.XhtmlEntities object Utility extends AnyRef with parsing.TokenTests { final val SU = '\u001A' + // [Martin] This looks dubious. We don't convert StringBuilders to + // Strings anywhere else, why do it here? implicit def implicitSbToString(sb: StringBuilder) = sb.toString() // helper for the extremely oft-repeated sequence of creating a @@ -137,7 +140,7 @@ object Utility extends AnyRef with parsing.TokenTests { * @return `'''null'''` if `ref` was not a predefined entity. */ final def unescape(ref: String, s: StringBuilder): StringBuilder = - (unescMap get ref) map (s append _) orNull + ((unescMap get ref) map (s append _)).orNull /** * Returns a set of all namespaces used in a sequence of nodes diff --git a/src/library/scala/xml/dtd/ContentModel.scala b/src/library/scala/xml/dtd/ContentModel.scala index 1e9a3a4b58..a5d2a6bd7e 100644 --- a/src/library/scala/xml/dtd/ContentModel.scala +++ b/src/library/scala/xml/dtd/ContentModel.scala @@ -36,8 +36,8 @@ object ContentModel extends WordExp { def traverse(r: RegExp): Set[String] = r match { // !!! check for match translation problem case Letter(ElemName(name)) => Set(name) case Star( x @ _ ) => traverse( x ) // bug if x@_* - case Sequ( xs @ _* ) => Set(xs map traverse flatten: _*) - case Alt( xs @ _* ) => Set(xs map traverse flatten: _*) + case Sequ( xs @ _* ) => Set(xs flatMap traverse: _*) + case Alt( xs @ _* ) => Set(xs flatMap traverse: _*) } traverse(r) diff --git a/src/library/scala/xml/parsing/ConstructingParser.scala b/src/library/scala/xml/parsing/ConstructingParser.scala index 5571c9844d..471cde056e 100644 --- a/src/library/scala/xml/parsing/ConstructingParser.scala +++ b/src/library/scala/xml/parsing/ConstructingParser.scala @@ -16,10 +16,10 @@ import scala.io.Source object ConstructingParser { def fromFile(inp: File, preserveWS: Boolean) = - new ConstructingParser(Source.fromFile(inp), preserveWS) initialize + new ConstructingParser(Source.fromFile(inp), preserveWS).initialize def fromSource(inp: Source, preserveWS: Boolean) = - new ConstructingParser(inp, preserveWS) initialize + new ConstructingParser(inp, preserveWS).initialize } /** An xml parser. parses XML and invokes callback methods of a MarkupHandler. diff --git a/test/files/neg/macro-keyword-bind.check b/test/disabled/neg/macro-keyword-bind.check index 1f74cfe5cd..1f74cfe5cd 100644 --- a/test/files/neg/macro-keyword-bind.check +++ b/test/disabled/neg/macro-keyword-bind.check diff --git a/test/disabled/neg/macro-keyword-bind.flags b/test/disabled/neg/macro-keyword-bind.flags new file mode 100644 index 0000000000..cd66464f2f --- /dev/null +++ b/test/disabled/neg/macro-keyword-bind.flags @@ -0,0 +1 @@ +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-keyword-bind.scala b/test/disabled/neg/macro-keyword-bind.scala index a3b1553348..a3b1553348 100644 --- a/test/files/neg/macro-keyword-bind.scala +++ b/test/disabled/neg/macro-keyword-bind.scala diff --git a/test/files/neg/macro-keyword-class1.check b/test/disabled/neg/macro-keyword-class1.check index d8983180ef..d8983180ef 100644 --- a/test/files/neg/macro-keyword-class1.check +++ b/test/disabled/neg/macro-keyword-class1.check diff --git a/test/disabled/neg/macro-keyword-class1.flags b/test/disabled/neg/macro-keyword-class1.flags new file mode 100644 index 0000000000..cd66464f2f --- /dev/null +++ b/test/disabled/neg/macro-keyword-class1.flags @@ -0,0 +1 @@ +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-keyword-class1.scala b/test/disabled/neg/macro-keyword-class1.scala index 8635d1f4f6..8635d1f4f6 100644 --- a/test/files/neg/macro-keyword-class1.scala +++ b/test/disabled/neg/macro-keyword-class1.scala diff --git a/test/files/neg/macro-keyword-class2.check b/test/disabled/neg/macro-keyword-class2.check index 0e4d11bcc4..0e4d11bcc4 100644 --- a/test/files/neg/macro-keyword-class2.check +++ b/test/disabled/neg/macro-keyword-class2.check diff --git a/test/disabled/neg/macro-keyword-class2.flags b/test/disabled/neg/macro-keyword-class2.flags new file mode 100644 index 0000000000..cd66464f2f --- /dev/null +++ b/test/disabled/neg/macro-keyword-class2.flags @@ -0,0 +1 @@ +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-keyword-class2.scala b/test/disabled/neg/macro-keyword-class2.scala index af24a489d0..af24a489d0 100644 --- a/test/files/neg/macro-keyword-class2.scala +++ b/test/disabled/neg/macro-keyword-class2.scala diff --git a/test/files/neg/macro-keyword-object1.check b/test/disabled/neg/macro-keyword-object1.check index cfbd06ffd6..cfbd06ffd6 100644 --- a/test/files/neg/macro-keyword-object1.check +++ b/test/disabled/neg/macro-keyword-object1.check diff --git a/test/disabled/neg/macro-keyword-object1.flags b/test/disabled/neg/macro-keyword-object1.flags new file mode 100644 index 0000000000..cd66464f2f --- /dev/null +++ b/test/disabled/neg/macro-keyword-object1.flags @@ -0,0 +1 @@ +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-keyword-object1.scala b/test/disabled/neg/macro-keyword-object1.scala index 66eb494e6b..66eb494e6b 100644 --- a/test/files/neg/macro-keyword-object1.scala +++ b/test/disabled/neg/macro-keyword-object1.scala diff --git a/test/files/neg/macro-keyword-object2.check b/test/disabled/neg/macro-keyword-object2.check index ede31f13e5..ede31f13e5 100644 --- a/test/files/neg/macro-keyword-object2.check +++ b/test/disabled/neg/macro-keyword-object2.check diff --git a/test/disabled/neg/macro-keyword-object2.flags b/test/disabled/neg/macro-keyword-object2.flags new file mode 100644 index 0000000000..cd66464f2f --- /dev/null +++ b/test/disabled/neg/macro-keyword-object2.flags @@ -0,0 +1 @@ +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-keyword-object2.scala b/test/disabled/neg/macro-keyword-object2.scala index 6f5b9ceacd..6f5b9ceacd 100644 --- a/test/files/neg/macro-keyword-object2.scala +++ b/test/disabled/neg/macro-keyword-object2.scala diff --git a/test/files/neg/macro-keyword-package1.check b/test/disabled/neg/macro-keyword-package1.check index 22c1e11ded..22c1e11ded 100644 --- a/test/files/neg/macro-keyword-package1.check +++ b/test/disabled/neg/macro-keyword-package1.check diff --git a/test/disabled/neg/macro-keyword-package1.flags b/test/disabled/neg/macro-keyword-package1.flags new file mode 100644 index 0000000000..cd66464f2f --- /dev/null +++ b/test/disabled/neg/macro-keyword-package1.flags @@ -0,0 +1 @@ +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-keyword-package1.scala b/test/disabled/neg/macro-keyword-package1.scala index 52d3fbabf6..52d3fbabf6 100644 --- a/test/files/neg/macro-keyword-package1.scala +++ b/test/disabled/neg/macro-keyword-package1.scala diff --git a/test/files/neg/macro-keyword-package2.check b/test/disabled/neg/macro-keyword-package2.check index 0cb542a85d..0cb542a85d 100644 --- a/test/files/neg/macro-keyword-package2.check +++ b/test/disabled/neg/macro-keyword-package2.check diff --git a/test/disabled/neg/macro-keyword-package2.flags b/test/disabled/neg/macro-keyword-package2.flags new file mode 100644 index 0000000000..cd66464f2f --- /dev/null +++ b/test/disabled/neg/macro-keyword-package2.flags @@ -0,0 +1 @@ +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-keyword-package2.scala b/test/disabled/neg/macro-keyword-package2.scala index a68ebd935f..a68ebd935f 100644 --- a/test/files/neg/macro-keyword-package2.scala +++ b/test/disabled/neg/macro-keyword-package2.scala diff --git a/test/files/neg/macro-keyword-trait1.check b/test/disabled/neg/macro-keyword-trait1.check index 9586a62e08..9586a62e08 100644 --- a/test/files/neg/macro-keyword-trait1.check +++ b/test/disabled/neg/macro-keyword-trait1.check diff --git a/test/disabled/neg/macro-keyword-trait1.flags b/test/disabled/neg/macro-keyword-trait1.flags new file mode 100644 index 0000000000..cd66464f2f --- /dev/null +++ b/test/disabled/neg/macro-keyword-trait1.flags @@ -0,0 +1 @@ +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-keyword-trait1.scala b/test/disabled/neg/macro-keyword-trait1.scala index e32d4c1385..e32d4c1385 100644 --- a/test/files/neg/macro-keyword-trait1.scala +++ b/test/disabled/neg/macro-keyword-trait1.scala diff --git a/test/files/neg/macro-keyword-trait2.check b/test/disabled/neg/macro-keyword-trait2.check index 40aa764378..40aa764378 100644 --- a/test/files/neg/macro-keyword-trait2.check +++ b/test/disabled/neg/macro-keyword-trait2.check diff --git a/test/disabled/neg/macro-keyword-trait2.flags b/test/disabled/neg/macro-keyword-trait2.flags new file mode 100644 index 0000000000..cd66464f2f --- /dev/null +++ b/test/disabled/neg/macro-keyword-trait2.flags @@ -0,0 +1 @@ +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-keyword-trait2.scala b/test/disabled/neg/macro-keyword-trait2.scala index 243a54abe6..243a54abe6 100644 --- a/test/files/neg/macro-keyword-trait2.scala +++ b/test/disabled/neg/macro-keyword-trait2.scala diff --git a/test/files/neg/macro-keyword-type.check b/test/disabled/neg/macro-keyword-type.check index 4a7481114c..4a7481114c 100644 --- a/test/files/neg/macro-keyword-type.check +++ b/test/disabled/neg/macro-keyword-type.check diff --git a/test/disabled/neg/macro-keyword-type.flags b/test/disabled/neg/macro-keyword-type.flags new file mode 100644 index 0000000000..cd66464f2f --- /dev/null +++ b/test/disabled/neg/macro-keyword-type.flags @@ -0,0 +1 @@ +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-keyword-type.scala b/test/disabled/neg/macro-keyword-type.scala index 30e523bcaf..30e523bcaf 100644 --- a/test/files/neg/macro-keyword-type.scala +++ b/test/disabled/neg/macro-keyword-type.scala diff --git a/test/files/neg/macro-keyword-val.check b/test/disabled/neg/macro-keyword-val.check index 0dc4c030a9..0dc4c030a9 100644 --- a/test/files/neg/macro-keyword-val.check +++ b/test/disabled/neg/macro-keyword-val.check diff --git a/test/disabled/neg/macro-keyword-val.flags b/test/disabled/neg/macro-keyword-val.flags new file mode 100644 index 0000000000..cd66464f2f --- /dev/null +++ b/test/disabled/neg/macro-keyword-val.flags @@ -0,0 +1 @@ +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-keyword-val.scala b/test/disabled/neg/macro-keyword-val.scala index 96f57acb30..96f57acb30 100644 --- a/test/files/neg/macro-keyword-val.scala +++ b/test/disabled/neg/macro-keyword-val.scala diff --git a/test/files/neg/macro-keyword-var.check b/test/disabled/neg/macro-keyword-var.check index 96d02e0052..96d02e0052 100644 --- a/test/files/neg/macro-keyword-var.check +++ b/test/disabled/neg/macro-keyword-var.check diff --git a/test/disabled/neg/macro-keyword-var.flags b/test/disabled/neg/macro-keyword-var.flags new file mode 100644 index 0000000000..cd66464f2f --- /dev/null +++ b/test/disabled/neg/macro-keyword-var.flags @@ -0,0 +1 @@ +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-keyword-var.scala b/test/disabled/neg/macro-keyword-var.scala index a79dda6dc2..a79dda6dc2 100644 --- a/test/files/neg/macro-keyword-var.scala +++ b/test/disabled/neg/macro-keyword-var.scala diff --git a/test/files/buildmanager/t2559/D.scala b/test/files/buildmanager/t2559/D.scala index 906b69a3e7..62dc5427f9 100644 --- a/test/files/buildmanager/t2559/D.scala +++ b/test/files/buildmanager/t2559/D.scala @@ -1,8 +1,4 @@ object D { - def x(a: A) = - a match { - case _: B => () - case _: C => () - } + def x(a: A) = if (a.isInstanceOf[B] || a.isInstanceOf[C]) () } diff --git a/test/files/buildmanager/t2559/t2559.check b/test/files/buildmanager/t2559/t2559.check index 752278fbe8..4d43838cf5 100644 --- a/test/files/buildmanager/t2559/t2559.check +++ b/test/files/buildmanager/t2559/t2559.check @@ -6,9 +6,4 @@ compiling Set(A.scala) Changes: Map(class B -> List(), class C -> List(), class E -> List(Changed(Class(A))[class E extends a sealed trait A]), trait A -> List()) invalidate D.scala because it references changed class [Changed(Class(A))[class E extends a sealed trait A]] compiling Set(D.scala) -D.scala:3: warning: match is not exhaustive! -missing combination E - - a match { - ^ Changes: Map(object D -> List()) diff --git a/test/files/buildmanager/t2650_1/t2650_1.check b/test/files/buildmanager/t2650_1/t2650_1.check index ecddb33620..f1e4b1b8bc 100644 --- a/test/files/buildmanager/t2650_1/t2650_1.check +++ b/test/files/buildmanager/t2650_1/t2650_1.check @@ -1,5 +1,6 @@ builder > A.scala B.scala compiling Set(A.scala, B.scala) +warning: there were 1 feature warnings; re-run with -feature for details Changes: Map() builder > A.scala compiling Set(A.scala) diff --git a/test/files/buildmanager/t2657/t2657.check b/test/files/buildmanager/t2657/t2657.check index 74ba87a21d..cd0357599c 100644 --- a/test/files/buildmanager/t2657/t2657.check +++ b/test/files/buildmanager/t2657/t2657.check @@ -1,5 +1,6 @@ builder > A.scala B.scala compiling Set(A.scala, B.scala) +warning: there were 1 feature warnings; re-run with -feature for details Changes: Map() builder > A.scala compiling Set(A.scala) diff --git a/test/files/continuations-run/match2.scala b/test/files/continuations-run/match2.scala index 8b0fb946df..5092ce3abe 100644 --- a/test/files/continuations-run/match2.scala +++ b/test/files/continuations-run/match2.scala @@ -18,7 +18,7 @@ object Test { } - def main(args: Array[String]): Any = { + def main(args: Array[String]): Unit = { println(reset(test1())) println(reset(test2())) } diff --git a/test/files/jvm/interpreter.check b/test/files/jvm/interpreter.check index d93e314d8e..b9ff6afa2b 100755..100644 --- a/test/files/jvm/interpreter.check +++ b/test/files/jvm/interpreter.check @@ -1,372 +1,375 @@ -Type in expressions to have them evaluated.
-Type :help for more information.
-
-scala>
-
-scala> // basics
-
-scala> 3+4
-res0: Int = 7
-
-scala> def gcd(x: Int, y: Int): Int = {
- if (x == 0) y
- else if (y == 0) x
- else gcd(y%x, x)
-}
-gcd: (x: Int, y: Int)Int
-
-scala> val five = gcd(15,35)
-five: Int = 5
-
-scala> var x = 1
-x: Int = 1
-
-scala> x = 2
-x: Int = 2
-
-scala> val three = x+1
-three: Int = 3
-
-scala> type anotherint = Int
-defined type alias anotherint
-
-scala> val four: anotherint = 4
-four: anotherint = 4
-
-scala> val bogus: anotherint = "hello"
-<console>:8: error: type mismatch;
- found : String("hello")
- required: anotherint
- (which expands to) Int
- val bogus: anotherint = "hello"
- ^
-
-scala> trait PointlessTrait
-defined trait PointlessTrait
-
-scala> val (x,y) = (2,3)
-x: Int = 2
-y: Int = 3
-
-scala> println("hello")
-hello
-
-scala>
-
-scala> // ticket #1513
-
-scala> val t1513 = Array(null)
-t1513: Array[Null] = Array(null)
-
-scala> // ambiguous toString problem from #547
-
-scala> val atom = new scala.xml.Atom()
-atom: scala.xml.Atom[Unit] = ()
-
-scala> // overriding toString problem from #1404
-
-scala> class S(override val toString : String)
-defined class S
-
-scala> val fish = new S("fish")
-fish: S = fish
-
-scala> // Test that arrays pretty print nicely.
-
-scala> val arr = Array("What's", "up", "doc?")
-arr: Array[String] = Array(What's, up, doc?)
-
-scala> // Test that arrays pretty print nicely, even when we give them type Any
-
-scala> val arrInt : Any = Array(1,2,3)
-arrInt: Any = Array(1, 2, 3)
-
-scala> // Test that nested arrays are pretty-printed correctly
-
-scala> val arrArrInt : Any = Array(Array(1, 2), Array(3, 4))
-arrArrInt: Any = Array(Array(1, 2), Array(3, 4))
-
-scala>
-
-scala> // implicit conversions
-
-scala> case class Foo(n: Int)
-defined class Foo
-
-scala> case class Bar(n: Int)
-defined class Bar
-
-scala> implicit def foo2bar(foo: Foo) = Bar(foo.n)
-foo2bar: (foo: Foo)Bar
-
-scala> val bar: Bar = Foo(3)
-bar: Bar = Bar(3)
-
-scala>
-
-scala> // importing from a previous result
-
-scala> import bar._
-import bar._
-
-scala> val m = n
-m: Int = 3
-
-scala>
-
-scala> // stressing the imports mechanism
-
-scala> val one = 1
-one: Int = 1
-
-scala> val one = 1
-one: Int = 1
-
-scala> val one = 1
-one: Int = 1
-
-scala> val one = 1
-one: Int = 1
-
-scala> val one = 1
-one: Int = 1
-
-scala> val one = 1
-one: Int = 1
-
-scala> val one = 1
-one: Int = 1
-
-scala> val one = 1
-one: Int = 1
-
-scala> val one = 1
-one: Int = 1
-
-scala> val one = 1
-one: Int = 1
-
-scala> val one = 1
-one: Int = 1
-
-scala> val one = 1
-one: Int = 1
-
-scala> val one = 1
-one: Int = 1
-
-scala> val one = 1
-one: Int = 1
-
-scala> val one = 1
-one: Int = 1
-
-scala> val one = 1
-one: Int = 1
-
-scala> val one = 1
-one: Int = 1
-
-scala> val one = 1
-one: Int = 1
-
-scala> val one = 1
-one: Int = 1
-
-scala> val one = 1
-one: Int = 1
-
-scala>
-
-scala>
-
-scala> val x1 = 1
-x1: Int = 1
-
-scala> val x2 = 1
-x2: Int = 1
-
-scala> val x3 = 1
-x3: Int = 1
-
-scala> val x4 = 1
-x4: Int = 1
-
-scala> val x5 = 1
-x5: Int = 1
-
-scala> val x6 = 1
-x6: Int = 1
-
-scala> val x7 = 1
-x7: Int = 1
-
-scala> val x8 = 1
-x8: Int = 1
-
-scala> val x9 = 1
-x9: Int = 1
-
-scala> val x10 = 1
-x10: Int = 1
-
-scala> val x11 = 1
-x11: Int = 1
-
-scala> val x12 = 1
-x12: Int = 1
-
-scala> val x13 = 1
-x13: Int = 1
-
-scala> val x14 = 1
-x14: Int = 1
-
-scala> val x15 = 1
-x15: Int = 1
-
-scala> val x16 = 1
-x16: Int = 1
-
-scala> val x17 = 1
-x17: Int = 1
-
-scala> val x18 = 1
-x18: Int = 1
-
-scala> val x19 = 1
-x19: Int = 1
-
-scala> val x20 = 1
-x20: Int = 1
-
-scala>
-
-scala> val two = one + x5
-two: Int = 2
-
-scala>
-
-scala> // handling generic wildcard arrays (#2386)
-
-scala> // It's put here because type feedback is an important part of it.
-
-scala> val xs: Array[_] = Array(1, 2)
-xs: Array[_] = Array(1, 2)
-
-scala> xs.size
-res2: Int = 2
-
-scala> xs.head
-res3: Any = 1
-
-scala> xs filter (_ == 2)
-res4: Array[_] = Array(2)
-
-scala> xs map (_ => "abc")
-res5: Array[String] = Array(abc, abc)
-
-scala> xs map (x => x)
-res6: scala.collection.mutable.ArraySeq[_] = ArraySeq(1, 2)
-
-scala> xs map (x => (x, x))
-res7: Array[(_$1, _$1)] forSome { type _$1 } = Array((1,1), (2,2))
-
-scala>
-
-scala> // interior syntax errors should *not* go into multi-line input mode.
-
-scala> // both of the following should abort immediately:
-
-scala> def x => y => z
-<console>:1: error: '=' expected but '=>' found.
- def x => y => z
- ^
-
-scala> [1,2,3]
-<console>:1: error: illegal start of definition
- [1,2,3]
- ^
-
-scala>
-
-scala>
-
-scala> // multi-line XML
-
-scala> <a>
-<b
- c="c"
- d="dd"
-/></a>
-res8: scala.xml.Elem =
-<a>
-<b c="c" d="dd"/></a>
-
-scala>
-
-scala>
-
-scala> /*
- /*
- multi-line comment
- */
-*/
-
-scala>
-
-scala>
-
-scala> // multi-line string
-
-scala> """
-hello
-there
-"""
-res9: String =
-"
-hello
-there
-"
-
-scala>
-
-scala> (1 + // give up early by typing two blank lines
-
-
-You typed two blank lines. Starting a new command.
-
-scala> // defining and using quoted names should work (ticket #323)
-
-scala> def `match` = 1
-match: Int
-
-scala> val x = `match`
-x: Int = 1
-
-scala>
-
-scala> // multiple classes defined on one line
-
-scala> sealed class Exp; class Fact extends Exp; class Term extends Exp
-defined class Exp
-defined class Fact
-defined class Term
-
-scala> def f(e: Exp) = e match { // non-exhaustive warning here
- case _:Fact => 3
-}
-<console>:18: warning: match is not exhaustive!
-missing combination Exp
-missing combination Term
-
- def f(e: Exp) = e match { // non-exhaustive warning here
- ^
-f: (e: Exp)Int
-
-scala>
-
-scala>
+Type in expressions to have them evaluated. +Type :help for more information. + +scala> + +scala> // basics + +scala> 3+4 +res0: Int = 7 + +scala> def gcd(x: Int, y: Int): Int = { + if (x == 0) y + else if (y == 0) x + else gcd(y%x, x) +} +gcd: (x: Int, y: Int)Int + +scala> val five = gcd(15,35) +five: Int = 5 + +scala> var x = 1 +x: Int = 1 + +scala> x = 2 +x: Int = 2 + +scala> val three = x+1 +three: Int = 3 + +scala> type anotherint = Int +defined type alias anotherint + +scala> val four: anotherint = 4 +four: anotherint = 4 + +scala> val bogus: anotherint = "hello" +<console>:8: error: type mismatch; + found : String("hello") + required: anotherint + (which expands to) Int + val bogus: anotherint = "hello" + ^ + +scala> trait PointlessTrait +defined trait PointlessTrait + +scala> val (x,y) = (2,3) +x: Int = 2 +y: Int = 3 + +scala> println("hello") +hello + +scala> + +scala> // ticket #1513 + +scala> val t1513 = Array(null) +t1513: Array[Null] = Array(null) + +scala> // ambiguous toString problem from #547 + +scala> val atom = new scala.xml.Atom() +atom: scala.xml.Atom[Unit] = () + +scala> // overriding toString problem from #1404 + +scala> class S(override val toString : String) +defined class S + +scala> val fish = new S("fish") +fish: S = fish + +scala> // Test that arrays pretty print nicely. + +scala> val arr = Array("What's", "up", "doc?") +arr: Array[String] = Array(What's, up, doc?) + +scala> // Test that arrays pretty print nicely, even when we give them type Any + +scala> val arrInt : Any = Array(1,2,3) +arrInt: Any = Array(1, 2, 3) + +scala> // Test that nested arrays are pretty-printed correctly + +scala> val arrArrInt : Any = Array(Array(1, 2), Array(3, 4)) +arrArrInt: Any = Array(Array(1, 2), Array(3, 4)) + +scala> + +scala> // implicit conversions + +scala> case class Foo(n: Int) +defined class Foo + +scala> case class Bar(n: Int) +defined class Bar + +scala> implicit def foo2bar(foo: Foo) = Bar(foo.n) +warning: there were 1 feature warnings; re-run with -feature for details +foo2bar: (foo: Foo)Bar + +scala> val bar: Bar = Foo(3) +bar: Bar = Bar(3) + +scala> + +scala> // importing from a previous result + +scala> import bar._ +import bar._ + +scala> val m = n +m: Int = 3 + +scala> + +scala> // stressing the imports mechanism + +scala> val one = 1 +one: Int = 1 + +scala> val one = 1 +one: Int = 1 + +scala> val one = 1 +one: Int = 1 + +scala> val one = 1 +one: Int = 1 + +scala> val one = 1 +one: Int = 1 + +scala> val one = 1 +one: Int = 1 + +scala> val one = 1 +one: Int = 1 + +scala> val one = 1 +one: Int = 1 + +scala> val one = 1 +one: Int = 1 + +scala> val one = 1 +one: Int = 1 + +scala> val one = 1 +one: Int = 1 + +scala> val one = 1 +one: Int = 1 + +scala> val one = 1 +one: Int = 1 + +scala> val one = 1 +one: Int = 1 + +scala> val one = 1 +one: Int = 1 + +scala> val one = 1 +one: Int = 1 + +scala> val one = 1 +one: Int = 1 + +scala> val one = 1 +one: Int = 1 + +scala> val one = 1 +one: Int = 1 + +scala> val one = 1 +one: Int = 1 + +scala> + +scala> + +scala> val x1 = 1 +x1: Int = 1 + +scala> val x2 = 1 +x2: Int = 1 + +scala> val x3 = 1 +x3: Int = 1 + +scala> val x4 = 1 +x4: Int = 1 + +scala> val x5 = 1 +x5: Int = 1 + +scala> val x6 = 1 +x6: Int = 1 + +scala> val x7 = 1 +x7: Int = 1 + +scala> val x8 = 1 +x8: Int = 1 + +scala> val x9 = 1 +x9: Int = 1 + +scala> val x10 = 1 +x10: Int = 1 + +scala> val x11 = 1 +x11: Int = 1 + +scala> val x12 = 1 +x12: Int = 1 + +scala> val x13 = 1 +x13: Int = 1 + +scala> val x14 = 1 +x14: Int = 1 + +scala> val x15 = 1 +x15: Int = 1 + +scala> val x16 = 1 +x16: Int = 1 + +scala> val x17 = 1 +x17: Int = 1 + +scala> val x18 = 1 +x18: Int = 1 + +scala> val x19 = 1 +x19: Int = 1 + +scala> val x20 = 1 +x20: Int = 1 + +scala> + +scala> val two = one + x5 +two: Int = 2 + +scala> + +scala> // handling generic wildcard arrays (#2386) + +scala> // It's put here because type feedback is an important part of it. + +scala> val xs: Array[_] = Array(1, 2) +xs: Array[_] = Array(1, 2) + +scala> xs.size +res2: Int = 2 + +scala> xs.head +res3: Any = 1 + +scala> xs filter (_ == 2) +res4: Array[_] = Array(2) + +scala> xs map (_ => "abc") +res5: Array[String] = Array(abc, abc) + +scala> xs map (x => x) +res6: scala.collection.mutable.ArraySeq[_] = ArraySeq(1, 2) + +scala> xs map (x => (x, x)) +warning: there were 1 feature warnings; re-run with -feature for details +warning: there were 1 feature warnings; re-run with -feature for details +res7: Array[(_$1, _$1)] forSome { type _$1 } = Array((1,1), (2,2)) + +scala> + +scala> // interior syntax errors should *not* go into multi-line input mode. + +scala> // both of the following should abort immediately: + +scala> def x => y => z +<console>:1: error: '=' expected but '=>' found. + def x => y => z + ^ + +scala> [1,2,3] +<console>:1: error: illegal start of definition + [1,2,3] + ^ + +scala> + +scala> + +scala> // multi-line XML + +scala> <a> +<b + c="c" + d="dd" +/></a> +res8: scala.xml.Elem = +<a> +<b c="c" d="dd"/></a> + +scala> + +scala> + +scala> /* + /* + multi-line comment + */ +*/ + +scala> + +scala> + +scala> // multi-line string + +scala> """ +hello +there +""" +res9: String = +" +hello +there +" + +scala> + +scala> (1 + // give up early by typing two blank lines + + +You typed two blank lines. Starting a new command. + +scala> // defining and using quoted names should work (ticket #323) + +scala> def `match` = 1 +match: Int + +scala> val x = `match` +x: Int = 1 + +scala> + +scala> // multiple classes defined on one line + +scala> sealed class Exp; class Fact extends Exp; class Term extends Exp +defined class Exp +defined class Fact +defined class Term + +scala> def f(e: Exp) = e match { // non-exhaustive warning here + case _:Fact => 3 +} +<console>:18: warning: match is not exhaustive! +missing combination Exp +missing combination Term + + def f(e: Exp) = e match { // non-exhaustive warning here + ^ +f: (e: Exp)Int + +scala> + +scala> plusOne: (x: Int)Int res0: Int = 6 res0: String = after reset diff --git a/test/files/jvm/interpreter.scala b/test/files/jvm/interpreter.scala index 1f289d9335..755b2ac9ae 100644 --- a/test/files/jvm/interpreter.scala +++ b/test/files/jvm/interpreter.scala @@ -2,7 +2,7 @@ import scala.tools.nsc._ import scala.tools.partest.ReplTest object Test extends ReplTest { - override def extraSettings = "-deprecation" + override def extraSettings = "-deprecation -Xoldpatmat" def code = <code> // basics 3+4 diff --git a/test/files/neg/applydynamic_sip.check b/test/files/neg/applydynamic_sip.check new file mode 100644 index 0000000000..8845f68a52 --- /dev/null +++ b/test/files/neg/applydynamic_sip.check @@ -0,0 +1,10 @@ +applydynamic_sip.scala:7: error: applyDynamic does not support passing a vararg parameter + qual.sel(a, a2: _*) + ^ +applydynamic_sip.scala:8: error: applyDynamicNamed does not support passing a vararg parameter + qual.sel(arg = a, a2: _*) + ^ +applydynamic_sip.scala:9: error: applyDynamicNamed does not support passing a vararg parameter + qual.sel(arg, arg2 = "a2", a2: _*) + ^ +three errors found diff --git a/test/files/neg/applydynamic_sip.scala b/test/files/neg/applydynamic_sip.scala new file mode 100644 index 0000000000..362461577b --- /dev/null +++ b/test/files/neg/applydynamic_sip.scala @@ -0,0 +1,10 @@ +object Test extends App { + val qual: Dynamic = ??? + val expr = "expr" + val a = "a" + val a2 = "a2" + + qual.sel(a, a2: _*) + qual.sel(arg = a, a2: _*) + qual.sel(arg, arg2 = "a2", a2: _*) +}
\ No newline at end of file diff --git a/test/files/neg/array-not-seq.check b/test/files/neg/array-not-seq.check index c16ecdad72..a3a639e772 100644 --- a/test/files/neg/array-not-seq.check +++ b/test/files/neg/array-not-seq.check @@ -1,7 +1,13 @@ array-not-seq.scala:2: error: An Array will no longer match as Seq[_]. def f1(x: Any) = x.isInstanceOf[Seq[_]] ^ -error: An Array will no longer match as Seq[_]. -error: An Array will no longer match as Seq[_]. -error: An Array will no longer match as Seq[_]. +array-not-seq.scala:4: error: An Array will no longer match as Seq[_]. + case _: Seq[_] => true + ^ +array-not-seq.scala:16: error: An Array will no longer match as Seq[_]. + case (Some(_: Seq[_]), Nil, _) => 1 + ^ +array-not-seq.scala:17: error: An Array will no longer match as Seq[_]. + case (None, List(_: List[_], _), _) => 2 + ^ four errors found diff --git a/test/files/neg/exhausting.flags b/test/files/neg/exhausting.flags index e8fb65d50c..b7eb21d5f5 100644 --- a/test/files/neg/exhausting.flags +++ b/test/files/neg/exhausting.flags @@ -1 +1 @@ --Xfatal-warnings
\ No newline at end of file +-Xfatal-warnings -Xoldpatmat diff --git a/test/files/neg/gadts1.check b/test/files/neg/gadts1.check index 44d2b114d6..0441f604c9 100644 --- a/test/files/neg/gadts1.check +++ b/test/files/neg/gadts1.check @@ -11,4 +11,7 @@ gadts1.scala:20: error: type mismatch; required: a case Cell[a](x: Int) => c.x = 5 ^ -three errors found +gadts1.scala:20: error: Could not typecheck extractor call: case class <none> with arguments List((x @ (_: Int))) + case Cell[a](x: Int) => c.x = 5 + ^ +four errors found diff --git a/test/files/neg/macro-argtype-mismatch.flags b/test/files/neg/macro-argtype-mismatch.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-argtype-mismatch.flags +++ b/test/files/neg/macro-argtype-mismatch.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-basic-mamdmi.flags b/test/files/neg/macro-basic-mamdmi.flags index 06a7b31f11..5e5dd6ce79 100644 --- a/test/files/neg/macro-basic-mamdmi.flags +++ b/test/files/neg/macro-basic-mamdmi.flags @@ -1 +1 @@ --Xmacros +-language:experimental.macros diff --git a/test/files/neg/macro-cyclic.flags b/test/files/neg/macro-cyclic.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-cyclic.flags +++ b/test/files/neg/macro-cyclic.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-deprecate-dont-touch-backquotedidents.check b/test/files/neg/macro-deprecate-dont-touch-backquotedidents.check deleted file mode 100644 index 25df9a6a4a..0000000000 --- a/test/files/neg/macro-deprecate-dont-touch-backquotedidents.check +++ /dev/null @@ -1,10 +0,0 @@ -macro-deprecate-dont-touch-backquotedidents.scala:37: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
-package `macro` {
- ^
-macro-deprecate-dont-touch-backquotedidents.scala:38: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
- package `macro`.bar {
- ^
-macro-deprecate-dont-touch-backquotedidents.scala:43: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
- package `macro`.foo {
- ^
-three errors found
diff --git a/test/files/neg/macro-deprecate-idents.check b/test/files/neg/macro-deprecate-idents.check index bd685fc7b9..f8a7e519df 100644 --- a/test/files/neg/macro-deprecate-idents.check +++ b/test/files/neg/macro-deprecate-idents.check @@ -1,46 +1,52 @@ -macro-deprecate-idents.scala:2: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
+macro-deprecate-idents.scala:2: error: macro is now a reserved word; usage as an identifier is deprecated
val macro = ???
^
-macro-deprecate-idents.scala:6: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
+macro-deprecate-idents.scala:6: error: macro is now a reserved word; usage as an identifier is deprecated
var macro = ???
^
-macro-deprecate-idents.scala:10: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
+macro-deprecate-idents.scala:10: error: macro is now a reserved word; usage as an identifier is deprecated
type macro = Int
^
-macro-deprecate-idents.scala:14: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
+macro-deprecate-idents.scala:14: error: macro is now a reserved word; usage as an identifier is deprecated
class macro
^
-macro-deprecate-idents.scala:18: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
+macro-deprecate-idents.scala:18: error: macro is now a reserved word; usage as an identifier is deprecated
class macro
^
-macro-deprecate-idents.scala:22: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
+macro-deprecate-idents.scala:22: error: macro is now a reserved word; usage as an identifier is deprecated
object macro
^
-macro-deprecate-idents.scala:26: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
+macro-deprecate-idents.scala:26: error: macro is now a reserved word; usage as an identifier is deprecated
object macro
^
-macro-deprecate-idents.scala:30: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
+macro-deprecate-idents.scala:30: error: macro is now a reserved word; usage as an identifier is deprecated
trait macro
^
-macro-deprecate-idents.scala:34: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
+macro-deprecate-idents.scala:34: error: macro is now a reserved word; usage as an identifier is deprecated
trait macro
^
-macro-deprecate-idents.scala:37: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
+macro-deprecate-idents.scala:37: error: macro is now a reserved word; usage as an identifier is deprecated
package macro {
^
-macro-deprecate-idents.scala:38: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
+macro-deprecate-idents.scala:38: error: macro is now a reserved word; usage as an identifier is deprecated
package macro.bar {
^
-macro-deprecate-idents.scala:43: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
+macro-deprecate-idents.scala:43: error: macro is now a reserved word; usage as an identifier is deprecated
package macro.foo {
^
-macro-deprecate-idents.scala:48: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
+macro-deprecate-idents.scala:48: error: macro is now a reserved word; usage as an identifier is deprecated
val Some(macro) = Some(42)
^
-macro-deprecate-idents.scala:50: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
+macro-deprecate-idents.scala:49: error: macro is now a reserved word; usage as an identifier is deprecated
+ macro match {
+ ^
+macro-deprecate-idents.scala:50: error: macro is now a reserved word; usage as an identifier is deprecated
case macro => println(macro)
^
-macro-deprecate-idents.scala:55: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
+macro-deprecate-idents.scala:50: error: macro is now a reserved word; usage as an identifier is deprecated
+ case macro => println(macro)
+ ^
+macro-deprecate-idents.scala:55: error: macro is now a reserved word; usage as an identifier is deprecated
def macro = 2
^
-15 errors found
+17 errors found
diff --git a/test/files/neg/macro-invalidimpl-a.flags b/test/files/neg/macro-invalidimpl-a.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidimpl-a.flags +++ b/test/files/neg/macro-invalidimpl-a.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidimpl-b.flags b/test/files/neg/macro-invalidimpl-b.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidimpl-b.flags +++ b/test/files/neg/macro-invalidimpl-b.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidimpl-c.flags b/test/files/neg/macro-invalidimpl-c.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidimpl-c.flags +++ b/test/files/neg/macro-invalidimpl-c.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidimpl-d.flags b/test/files/neg/macro-invalidimpl-d.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidimpl-d.flags +++ b/test/files/neg/macro-invalidimpl-d.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidimpl-e.flags b/test/files/neg/macro-invalidimpl-e.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidimpl-e.flags +++ b/test/files/neg/macro-invalidimpl-e.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidimpl-f.flags b/test/files/neg/macro-invalidimpl-f.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidimpl-f.flags +++ b/test/files/neg/macro-invalidimpl-f.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidimpl-g.flags b/test/files/neg/macro-invalidimpl-g.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidimpl-g.flags +++ b/test/files/neg/macro-invalidimpl-g.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidimpl-h.flags b/test/files/neg/macro-invalidimpl-h.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidimpl-h.flags +++ b/test/files/neg/macro-invalidimpl-h.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidret-nontree.flags b/test/files/neg/macro-invalidret-nontree.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidret-nontree.flags +++ b/test/files/neg/macro-invalidret-nontree.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidret-nonuniversetree.flags b/test/files/neg/macro-invalidret-nonuniversetree.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidret-nonuniversetree.flags +++ b/test/files/neg/macro-invalidret-nonuniversetree.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidshape-a.flags b/test/files/neg/macro-invalidshape-a.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidshape-a.flags +++ b/test/files/neg/macro-invalidshape-a.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidshape-b.flags b/test/files/neg/macro-invalidshape-b.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidshape-b.flags +++ b/test/files/neg/macro-invalidshape-b.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidshape-c.flags b/test/files/neg/macro-invalidshape-c.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidshape-c.flags +++ b/test/files/neg/macro-invalidshape-c.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidshape-d.check b/test/files/neg/macro-invalidshape-d.check index 031aa653ab..f0d77e2f2d 100644 --- a/test/files/neg/macro-invalidshape-d.check +++ b/test/files/neg/macro-invalidshape-d.check @@ -1,4 +1,8 @@ -Macros_Test_2.scala:2: error: illegal start of statement
+Macros_Test_2.scala:2: warning: macro is now a reserved word; usage as an identifier is deprecated
def foo(x: Any) = {2; macro Impls.foo}
^
+Macros_Test_2.scala:2: error: ';' expected but '.' found.
+ def foo(x: Any) = {2; macro Impls.foo}
+ ^
+one warning found
one error found
diff --git a/test/files/neg/macro-invalidshape-d.flags b/test/files/neg/macro-invalidshape-d.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidshape-d.flags +++ b/test/files/neg/macro-invalidshape-d.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidsig-context-bounds.flags b/test/files/neg/macro-invalidsig-context-bounds.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidsig-context-bounds.flags +++ b/test/files/neg/macro-invalidsig-context-bounds.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidsig-ctx-badargc.flags b/test/files/neg/macro-invalidsig-ctx-badargc.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidsig-ctx-badargc.flags +++ b/test/files/neg/macro-invalidsig-ctx-badargc.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidsig-ctx-badtype.flags b/test/files/neg/macro-invalidsig-ctx-badtype.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidsig-ctx-badtype.flags +++ b/test/files/neg/macro-invalidsig-ctx-badtype.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidsig-ctx-badvarargs.flags b/test/files/neg/macro-invalidsig-ctx-badvarargs.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidsig-ctx-badvarargs.flags +++ b/test/files/neg/macro-invalidsig-ctx-badvarargs.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidsig-ctx-noctx.flags b/test/files/neg/macro-invalidsig-ctx-noctx.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidsig-ctx-noctx.flags +++ b/test/files/neg/macro-invalidsig-ctx-noctx.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidsig-implicit-params.flags b/test/files/neg/macro-invalidsig-implicit-params.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidsig-implicit-params.flags +++ b/test/files/neg/macro-invalidsig-implicit-params.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidsig-params-badargc.flags b/test/files/neg/macro-invalidsig-params-badargc.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidsig-params-badargc.flags +++ b/test/files/neg/macro-invalidsig-params-badargc.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidsig-params-badtype.flags b/test/files/neg/macro-invalidsig-params-badtype.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidsig-params-badtype.flags +++ b/test/files/neg/macro-invalidsig-params-badtype.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidsig-params-badvarargs.flags b/test/files/neg/macro-invalidsig-params-badvarargs.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidsig-params-badvarargs.flags +++ b/test/files/neg/macro-invalidsig-params-badvarargs.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidsig-params-namemismatch.flags b/test/files/neg/macro-invalidsig-params-namemismatch.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidsig-params-namemismatch.flags +++ b/test/files/neg/macro-invalidsig-params-namemismatch.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidsig-tparams-badtype.flags b/test/files/neg/macro-invalidsig-tparams-badtype.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidsig-tparams-badtype.flags +++ b/test/files/neg/macro-invalidsig-tparams-badtype.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidsig-tparams-bounds-a.flags b/test/files/neg/macro-invalidsig-tparams-bounds-a.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidsig-tparams-bounds-a.flags +++ b/test/files/neg/macro-invalidsig-tparams-bounds-a.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidsig-tparams-bounds-b.flags b/test/files/neg/macro-invalidsig-tparams-bounds-b.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidsig-tparams-bounds-b.flags +++ b/test/files/neg/macro-invalidsig-tparams-bounds-b.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidsig-tparams-notparams-a.flags b/test/files/neg/macro-invalidsig-tparams-notparams-a.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidsig-tparams-notparams-a.flags +++ b/test/files/neg/macro-invalidsig-tparams-notparams-a.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidsig-tparams-notparams-b.flags b/test/files/neg/macro-invalidsig-tparams-notparams-b.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidsig-tparams-notparams-b.flags +++ b/test/files/neg/macro-invalidsig-tparams-notparams-b.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidsig-tparams-notparams-c.flags b/test/files/neg/macro-invalidsig-tparams-notparams-c.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidsig-tparams-notparams-c.flags +++ b/test/files/neg/macro-invalidsig-tparams-notparams-c.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidusage-badargs.flags b/test/files/neg/macro-invalidusage-badargs.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidusage-badargs.flags +++ b/test/files/neg/macro-invalidusage-badargs.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidusage-badbounds.flags b/test/files/neg/macro-invalidusage-badbounds.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidusage-badbounds.flags +++ b/test/files/neg/macro-invalidusage-badbounds.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidusage-badtargs.flags b/test/files/neg/macro-invalidusage-badtargs.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidusage-badtargs.flags +++ b/test/files/neg/macro-invalidusage-badtargs.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-invalidusage-methodvaluesyntax.flags b/test/files/neg/macro-invalidusage-methodvaluesyntax.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-invalidusage-methodvaluesyntax.flags +++ b/test/files/neg/macro-invalidusage-methodvaluesyntax.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-keyword-bind.flags b/test/files/neg/macro-keyword-bind.flags deleted file mode 100644 index 7fea2ff901..0000000000 --- a/test/files/neg/macro-keyword-bind.flags +++ /dev/null @@ -1 +0,0 @@ --Xmacros
\ No newline at end of file diff --git a/test/files/neg/macro-keyword-class1.flags b/test/files/neg/macro-keyword-class1.flags deleted file mode 100644 index 7fea2ff901..0000000000 --- a/test/files/neg/macro-keyword-class1.flags +++ /dev/null @@ -1 +0,0 @@ --Xmacros
\ No newline at end of file diff --git a/test/files/neg/macro-keyword-class2.flags b/test/files/neg/macro-keyword-class2.flags deleted file mode 100644 index 7fea2ff901..0000000000 --- a/test/files/neg/macro-keyword-class2.flags +++ /dev/null @@ -1 +0,0 @@ --Xmacros
\ No newline at end of file diff --git a/test/files/neg/macro-keyword-object1.flags b/test/files/neg/macro-keyword-object1.flags deleted file mode 100644 index 7fea2ff901..0000000000 --- a/test/files/neg/macro-keyword-object1.flags +++ /dev/null @@ -1 +0,0 @@ --Xmacros
\ No newline at end of file diff --git a/test/files/neg/macro-keyword-object2.flags b/test/files/neg/macro-keyword-object2.flags deleted file mode 100644 index 7fea2ff901..0000000000 --- a/test/files/neg/macro-keyword-object2.flags +++ /dev/null @@ -1 +0,0 @@ --Xmacros
\ No newline at end of file diff --git a/test/files/neg/macro-keyword-package1.flags b/test/files/neg/macro-keyword-package1.flags deleted file mode 100644 index 7fea2ff901..0000000000 --- a/test/files/neg/macro-keyword-package1.flags +++ /dev/null @@ -1 +0,0 @@ --Xmacros
\ No newline at end of file diff --git a/test/files/neg/macro-keyword-package2.flags b/test/files/neg/macro-keyword-package2.flags deleted file mode 100644 index 7fea2ff901..0000000000 --- a/test/files/neg/macro-keyword-package2.flags +++ /dev/null @@ -1 +0,0 @@ --Xmacros
\ No newline at end of file diff --git a/test/files/neg/macro-keyword-trait1.flags b/test/files/neg/macro-keyword-trait1.flags deleted file mode 100644 index 7fea2ff901..0000000000 --- a/test/files/neg/macro-keyword-trait1.flags +++ /dev/null @@ -1 +0,0 @@ --Xmacros
\ No newline at end of file diff --git a/test/files/neg/macro-keyword-trait2.flags b/test/files/neg/macro-keyword-trait2.flags deleted file mode 100644 index 7fea2ff901..0000000000 --- a/test/files/neg/macro-keyword-trait2.flags +++ /dev/null @@ -1 +0,0 @@ --Xmacros
\ No newline at end of file diff --git a/test/files/neg/macro-keyword-type.flags b/test/files/neg/macro-keyword-type.flags deleted file mode 100644 index 7fea2ff901..0000000000 --- a/test/files/neg/macro-keyword-type.flags +++ /dev/null @@ -1 +0,0 @@ --Xmacros
\ No newline at end of file diff --git a/test/files/neg/macro-keyword-val.flags b/test/files/neg/macro-keyword-val.flags deleted file mode 100644 index 7fea2ff901..0000000000 --- a/test/files/neg/macro-keyword-val.flags +++ /dev/null @@ -1 +0,0 @@ --Xmacros
\ No newline at end of file diff --git a/test/files/neg/macro-keyword-var.flags b/test/files/neg/macro-keyword-var.flags deleted file mode 100644 index 7fea2ff901..0000000000 --- a/test/files/neg/macro-keyword-var.flags +++ /dev/null @@ -1 +0,0 @@ --Xmacros
\ No newline at end of file diff --git a/test/files/neg/macro-noexpand.flags b/test/files/neg/macro-noexpand.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-noexpand.flags +++ b/test/files/neg/macro-noexpand.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-noncompilertree.flags b/test/files/neg/macro-noncompilertree.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-noncompilertree.flags +++ b/test/files/neg/macro-noncompilertree.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-nontree.flags b/test/files/neg/macro-nontree.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-nontree.flags +++ b/test/files/neg/macro-nontree.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-nontypeablebody.flags b/test/files/neg/macro-nontypeablebody.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-nontypeablebody.flags +++ b/test/files/neg/macro-nontypeablebody.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-override-macro-overrides-abstract-method-a.flags b/test/files/neg/macro-override-macro-overrides-abstract-method-a.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-override-macro-overrides-abstract-method-a.flags +++ b/test/files/neg/macro-override-macro-overrides-abstract-method-a.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-override-macro-overrides-abstract-method-b.flags b/test/files/neg/macro-override-macro-overrides-abstract-method-b.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-override-macro-overrides-abstract-method-b.flags +++ b/test/files/neg/macro-override-macro-overrides-abstract-method-b.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-override-method-overrides-macro.flags b/test/files/neg/macro-override-method-overrides-macro.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/neg/macro-override-method-overrides-macro.flags +++ b/test/files/neg/macro-override-method-overrides-macro.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/neg/macro-without-xmacros-a.check b/test/files/neg/macro-without-xmacros-a.check index a3ca081f04..fd2667dbb8 100644 --- a/test/files/neg/macro-without-xmacros-a.check +++ b/test/files/neg/macro-without-xmacros-a.check @@ -1,10 +1,17 @@ -Macros_2.scala:5: error: not found: value macro
+Macros_2.scala:5: error: macro definition needs to be enabled
+by making the implicit value language.experimental.macros visible.
+This can be achieved by adding the import clause 'import language.experimental.macros'
+or by setting the compiler option -language:experimental.macros.
+See the Scala docs for value scala.language.experimental.macros for a discussion
+why the feature needs to be explicitly enabled.
def foo(x: Int): Int = macro foo_impl
- ^
-Macros_2.scala:7: error: not found: value macro
+ ^
+Macros_2.scala:7: error: macro definition needs to be enabled
+by making the implicit value language.experimental.macros visible.
def bar(x: Int): Int = macro bar_impl
- ^
-Macros_2.scala:11: error: not found: value macro
+ ^
+Macros_2.scala:11: error: macro definition needs to be enabled
+by making the implicit value language.experimental.macros visible.
def quux(x: Int): Int = macro quux_impl
- ^
+ ^
three errors found
diff --git a/test/files/neg/macro-without-xmacros-a/Impls_1.scala b/test/files/neg/macro-without-xmacros-a/Impls_1.scala index 2493c81c95..01daf12b1a 100644 --- a/test/files/neg/macro-without-xmacros-a/Impls_1.scala +++ b/test/files/neg/macro-without-xmacros-a/Impls_1.scala @@ -1,17 +1,17 @@ import scala.reflect.makro.{Context => Ctx} object Impls { - def foo_impl(c: Ctx)(x: c.Expr[Int]): c.mirror.Tree = { + def foo_impl(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { import c.mirror._ Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1)))) } - def bar_impl(c: Ctx)(x: c.Expr[Int]): c.mirror.Tree = { + def bar_impl(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { import c.mirror._ Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(2)))) } - def quux_impl(c: Ctx)(x: c.Expr[Int]): c.mirror.Tree = { + def quux_impl(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { import c.mirror._ Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(3)))) } diff --git a/test/files/neg/macro-without-xmacros-b.check b/test/files/neg/macro-without-xmacros-b.check index dce4a084c9..2d675b8319 100644 --- a/test/files/neg/macro-without-xmacros-b.check +++ b/test/files/neg/macro-without-xmacros-b.check @@ -1,10 +1,17 @@ -Macros_2.scala:3: error: ';' expected but '.' found.
+Macros_2.scala:3: error: macro definition needs to be enabled
+by making the implicit value language.experimental.macros visible.
+This can be achieved by adding the import clause 'import language.experimental.macros'
+or by setting the compiler option -language:experimental.macros.
+See the Scala docs for value scala.language.experimental.macros for a discussion
+why the feature needs to be explicitly enabled.
def foo(x: Int): Int = macro Impls.foo_impl
- ^
-Macros_2.scala:5: error: ';' expected but '.' found.
+ ^
+Macros_2.scala:5: error: macro definition needs to be enabled
+by making the implicit value language.experimental.macros visible.
def bar(x: Int): Int = macro Impls.bar_impl
- ^
-Macros_2.scala:9: error: ';' expected but '.' found.
+ ^
+Macros_2.scala:9: error: macro definition needs to be enabled
+by making the implicit value language.experimental.macros visible.
def quux(x: Int): Int = macro Impls.quux_impl
- ^
+ ^
three errors found
diff --git a/test/files/neg/macro-without-xmacros-b/Impls_1.scala b/test/files/neg/macro-without-xmacros-b/Impls_1.scala index 2493c81c95..01daf12b1a 100644 --- a/test/files/neg/macro-without-xmacros-b/Impls_1.scala +++ b/test/files/neg/macro-without-xmacros-b/Impls_1.scala @@ -1,17 +1,17 @@ import scala.reflect.makro.{Context => Ctx} object Impls { - def foo_impl(c: Ctx)(x: c.Expr[Int]): c.mirror.Tree = { + def foo_impl(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { import c.mirror._ Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1)))) } - def bar_impl(c: Ctx)(x: c.Expr[Int]): c.mirror.Tree = { + def bar_impl(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { import c.mirror._ Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(2)))) } - def quux_impl(c: Ctx)(x: c.Expr[Int]): c.mirror.Tree = { + def quux_impl(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { import c.mirror._ Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(3)))) } diff --git a/test/files/neg/pat_unreachable.flags b/test/files/neg/pat_unreachable.flags new file mode 100644 index 0000000000..ba80cad69b --- /dev/null +++ b/test/files/neg/pat_unreachable.flags @@ -0,0 +1 @@ +-Xoldpatmat diff --git a/test/files/neg/patmat-type-check.check b/test/files/neg/patmat-type-check.check index e045841ce1..ab4451f089 100644 --- a/test/files/neg/patmat-type-check.check +++ b/test/files/neg/patmat-type-check.check @@ -3,19 +3,31 @@ patmat-type-check.scala:22: error: scrutinee is incompatible with pattern type; required: String def f1 = "bob".reverse match { case Seq('b', 'o', 'b') => true } // fail ^ +patmat-type-check.scala:22: error: value _1 is not a member of object Seq + def f1 = "bob".reverse match { case Seq('b', 'o', 'b') => true } // fail + ^ patmat-type-check.scala:23: error: scrutinee is incompatible with pattern type; found : Seq[A] required: Array[Char] def f2 = "bob".toArray match { case Seq('b', 'o', 'b') => true } // fail ^ +patmat-type-check.scala:23: error: value _1 is not a member of object Seq + def f2 = "bob".toArray match { case Seq('b', 'o', 'b') => true } // fail + ^ patmat-type-check.scala:27: error: scrutinee is incompatible with pattern type; found : Seq[A] required: Test.Bop2 def f3(x: Bop2) = x match { case Seq('b', 'o', 'b') => true } // fail ^ +patmat-type-check.scala:27: error: value _1 is not a member of object Seq + def f3(x: Bop2) = x match { case Seq('b', 'o', 'b') => true } // fail + ^ patmat-type-check.scala:30: error: scrutinee is incompatible with pattern type; found : Seq[A] required: Test.Bop3[Char] def f4[T](x: Bop3[Char]) = x match { case Seq('b', 'o', 'b') => true } // fail ^ -four errors found +patmat-type-check.scala:30: error: value _1 is not a member of object Seq + def f4[T](x: Bop3[Char]) = x match { case Seq('b', 'o', 'b') => true } // fail + ^ +8 errors found diff --git a/test/files/neg/patmatexhaust.flags b/test/files/neg/patmatexhaust.flags index e8fb65d50c..b7eb21d5f5 100644 --- a/test/files/neg/patmatexhaust.flags +++ b/test/files/neg/patmatexhaust.flags @@ -1 +1 @@ --Xfatal-warnings
\ No newline at end of file +-Xfatal-warnings -Xoldpatmat diff --git a/test/files/neg/sealed-java-enums.flags b/test/files/neg/sealed-java-enums.flags index e709c65918..312f3a87ec 100644 --- a/test/files/neg/sealed-java-enums.flags +++ b/test/files/neg/sealed-java-enums.flags @@ -1 +1 @@ --Xexperimental -Xfatal-warnings +-Xexperimental -Xfatal-warnings -Xoldpatmat diff --git a/test/files/neg/switch.flags b/test/files/neg/switch.flags new file mode 100644 index 0000000000..809e9ff2f2 --- /dev/null +++ b/test/files/neg/switch.flags @@ -0,0 +1 @@ + -Xoldpatmat diff --git a/test/files/neg/t0418.check b/test/files/neg/t0418.check index 4e9ad2f9ae..50931a1bca 100644 --- a/test/files/neg/t0418.check +++ b/test/files/neg/t0418.check @@ -4,4 +4,7 @@ t0418.scala:2: error: not found: value Foo12340771 t0418.scala:2: error: not found: value x null match { case Foo12340771.Bar(x) => x } ^ -two errors found +t0418.scala:2: error: Could not typecheck extractor call: case class <none> with arguments List((x @ _)) + null match { case Foo12340771.Bar(x) => x } + ^ +three errors found diff --git a/test/files/neg/t112706A.check b/test/files/neg/t112706A.check index 30d0c3ec91..fb18b31be1 100644 --- a/test/files/neg/t112706A.check +++ b/test/files/neg/t112706A.check @@ -3,4 +3,7 @@ t112706A.scala:5: error: constructor cannot be instantiated to expected type; required: String case Tuple2(node,_) => ^ -one error found +t112706A.scala:5: error: Could not typecheck extractor call: case class Tuple2 with arguments List((node @ _), _) + case Tuple2(node,_) => + ^ +two errors found diff --git a/test/files/neg/t1878.check b/test/files/neg/t1878.check index 128741a022..b47367e12c 100644 --- a/test/files/neg/t1878.check +++ b/test/files/neg/t1878.check @@ -9,10 +9,13 @@ t1878.scala:3: error: scrutinee is incompatible with pattern type; t1878.scala:3: error: not found: value f val err1 = "" match { case Seq(f @ _*, ',') => f } ^ +t1878.scala:3: error: value _2 is not a member of object Seq + val err1 = "" match { case Seq(f @ _*, ',') => f } + ^ t1878.scala:9: error: _* may only come last val List(List(_*, arg2), _) = List(List(1,2,3), List(4,5,6)) ^ t1878.scala:13: error: _* may only come last case <p> { _* } </p> => ^ -5 errors found +6 errors found diff --git a/test/files/neg/t3098.flags b/test/files/neg/t3098.flags index e8fb65d50c..b7eb21d5f5 100644 --- a/test/files/neg/t3098.flags +++ b/test/files/neg/t3098.flags @@ -1 +1 @@ --Xfatal-warnings
\ No newline at end of file +-Xfatal-warnings -Xoldpatmat diff --git a/test/files/neg/t3392.check b/test/files/neg/t3392.check index 842d63eec9..3a39098c4e 100644 --- a/test/files/neg/t3392.check +++ b/test/files/neg/t3392.check @@ -1,4 +1,7 @@ t3392.scala:9: error: not found: value x case x@A(x/*<-- refers to the pattern that includes this comment*/.Ex(42)) => ^ -one error found +t3392.scala:9: error: Could not typecheck extractor call: case class <none> with arguments List(42) + case x@A(x/*<-- refers to the pattern that includes this comment*/.Ex(42)) => + ^ +two errors found diff --git a/test/files/neg/t3683a.flags b/test/files/neg/t3683a.flags index 85d8eb2ba2..b7eb21d5f5 100644 --- a/test/files/neg/t3683a.flags +++ b/test/files/neg/t3683a.flags @@ -1 +1 @@ --Xfatal-warnings +-Xfatal-warnings -Xoldpatmat diff --git a/test/files/neg/t3692.flags b/test/files/neg/t3692.flags new file mode 100644 index 0000000000..82becdfbfd --- /dev/null +++ b/test/files/neg/t3692.flags @@ -0,0 +1 @@ + -Xoldpatmat
\ No newline at end of file diff --git a/test/files/neg/t418.check b/test/files/neg/t418.check index 1489547823..c06088ba9d 100644 --- a/test/files/neg/t418.check +++ b/test/files/neg/t418.check @@ -4,4 +4,7 @@ t418.scala:2: error: not found: value Foo12340771 t418.scala:2: error: not found: value x null match { case Foo12340771.Bar(x) => x } ^ -two errors found +t418.scala:2: error: Could not typecheck extractor call: case class <none> with arguments List((x @ _)) + null match { case Foo12340771.Bar(x) => x } + ^ +three errors found diff --git a/test/files/neg/t4425.check b/test/files/neg/t4425.check index 4ff4b1eec0..0f2fe6f2d1 100644 --- a/test/files/neg/t4425.check +++ b/test/files/neg/t4425.check @@ -1,4 +1,4 @@ -t4425.scala:3: error: erroneous or inaccessible type +t4425.scala:3: error: isInstanceOf cannot test if value types are references. 42 match { case _ X _ => () } ^ one error found diff --git a/test/files/neg/t5589neg.check b/test/files/neg/t5589neg.check index b3ff16d7e4..fb6858a397 100644 --- a/test/files/neg/t5589neg.check +++ b/test/files/neg/t5589neg.check @@ -22,6 +22,9 @@ t5589neg.scala:4: error: constructor cannot be instantiated to expected type; t5589neg.scala:4: error: not found: value y2 def f7(x: Either[Int, (String, Int)]) = for (y1 @ Tuple1(y2) <- x.right) yield ((y1, y2)) ^ +t5589neg.scala:4: error: Could not typecheck extractor call: case class Tuple1 with arguments List((y2 @ _)) + def f7(x: Either[Int, (String, Int)]) = for (y1 @ Tuple1(y2) <- x.right) yield ((y1, y2)) + ^ t5589neg.scala:5: error: constructor cannot be instantiated to expected type; found : (T1, T2, T3) required: (String, Int) @@ -34,4 +37,4 @@ t5589neg.scala:5: error: not found: value y2 def f8(x: Either[Int, (String, Int)]) = for ((y1, y2, y3) <- x.right) yield ((y1, y2)) ^ two warnings found -7 errors found +8 errors found diff --git a/test/files/neg/t5663-badwarneq.check b/test/files/neg/t5663-badwarneq.check new file mode 100644 index 0000000000..00c2234e9d --- /dev/null +++ b/test/files/neg/t5663-badwarneq.check @@ -0,0 +1,22 @@ +t5663-badwarneq.scala:42: error: comparing case class values of types Some[Int] and None.type using `==' will always yield false + println(new Some(1) == None) // Should complain on type, was: spuriously complains on fresh object + ^ +t5663-badwarneq.scala:43: error: comparing case class values of types Some[Int] and Thing using `==' will always yield false + println(Some(1) == new Thing(1)) // Should complain on type, was: spuriously complains on fresh object + ^ +t5663-badwarneq.scala:51: error: ThingOne and Thingy are unrelated: they will most likely never compare equal + println(t1 == t2) // true, but apparently unrelated, a compromise warning + ^ +t5663-badwarneq.scala:52: error: ThingThree and Thingy are unrelated: they will most likely never compare equal + println(t4 == t2) // true, complains because ThingThree is final and Thingy not a subclass, stronger claim than unrelated + ^ +t5663-badwarneq.scala:55: error: comparing case class values of types ThingTwo and Some[Int] using `==' will always yield false + println(t3 == Some(1)) // false, warn on different cases + ^ +t5663-badwarneq.scala:56: error: comparing values of types ThingOne and Cousin using `==' will always yield false + println(t1 == c) // should warn + ^ +t5663-badwarneq.scala:64: error: comparing case class values of types Simple and SimpleSibling.type using `==' will always yield false + println(new Simple() == SimpleSibling) // like Some(1) == None, but needn't be final case + ^ +7 errors found diff --git a/test/files/neg/t5663-badwarneq.flags b/test/files/neg/t5663-badwarneq.flags new file mode 100644 index 0000000000..85d8eb2ba2 --- /dev/null +++ b/test/files/neg/t5663-badwarneq.flags @@ -0,0 +1 @@ +-Xfatal-warnings diff --git a/test/files/neg/t5663-badwarneq.scala b/test/files/neg/t5663-badwarneq.scala new file mode 100644 index 0000000000..56ec389c03 --- /dev/null +++ b/test/files/neg/t5663-badwarneq.scala @@ -0,0 +1,76 @@ + +// alias +trait Thingy + +class Gramps + +// sibling classes that extend a case class +case class Thing(i: Int) extends Gramps +class ThingOne(x:Int) extends Thing(x) +class ThingTwo(y:Int) extends Thing(y) with Thingy +final class ThingThree(z:Int) extends Thing(z) + +// not case cousin +class Cousin extends Gramps + +class SimpleParent +case class Simple() extends SimpleParent +case object SimpleSibling extends SimpleParent + +/* It's not possible to run partest without -deprecation. + * Since detecting the warnings requires a neg test with + * -Xfatal-warnings, and deprecation terminates the compile, + * we'll just comment out the nasty part. The point was + * just to show there's nothing special about a trait + * that extends a case class, which is only permitted + * (deprecatingly) by omitting the parens. + * +// common ancestor is something else +class AnyThing +case class SomeThing extends AnyThing // deprecation +class OtherThing extends AnyThing + +// how you inherit caseness doesn't matter +trait InThing extends SomeThing +class MyThing extends InThing +*/ + +object Test { + def main(a: Array[String]) { + // nothing to do with Gavin + println(new Some(1) == new Some(1)) // OK, true + println(new Some(1) == None) // Should complain on type, was: spuriously complains on fresh object + println(Some(1) == new Thing(1)) // Should complain on type, was: spuriously complains on fresh object + + val t1 = new ThingOne(11) + val t2: Thingy = new ThingTwo(11) + val t3 = new ThingTwo(11) + val t4 = new ThingThree(11) + val c = new Cousin + + println(t1 == t2) // true, but apparently unrelated, a compromise warning + println(t4 == t2) // true, complains because ThingThree is final and Thingy not a subclass, stronger claim than unrelated + println(t2 == t3) // OK, two Thingy + println(t3 == t2) // ditto with case receiver + println(t3 == Some(1)) // false, warn on different cases + println(t1 == c) // should warn + + // don't warn on fresh cases + println(new ThingOne(11) == t1) // OK, was: two cases not warnable on trunk + println(new ThingTwo(11) == t2) // true, was: spuriously complains on fresh object + println(new ThingOne(11) == t3) // two cases not warnable on trunk + println(new ThingTwo(11) == t3) // ditto + + println(new Simple() == SimpleSibling) // like Some(1) == None, but needn't be final case + + /* + val mine = new MyThing + val some = new SomeThing + val other = new OtherThing + println(mine == some) // OK, two Something + println(some == mine) + println(mine == other) // OK, two Anything? + println(mine == t1) // false + */ + } +} diff --git a/test/files/neg/tailrec.check b/test/files/neg/tailrec.check index ad92731b2c..946d3421e6 100644 --- a/test/files/neg/tailrec.check +++ b/test/files/neg/tailrec.check @@ -4,9 +4,9 @@ tailrec.scala:45: error: could not optimize @tailrec annotated method facfail: i tailrec.scala:50: error: could not optimize @tailrec annotated method fail1: it is neither private nor final so can be overridden @tailrec def fail1(x: Int): Int = fail1(x) ^ -tailrec.scala:55: error: could not optimize @tailrec annotated method fail2: it contains a recursive call not in tail position - case x :: xs => x :: fail2[T](xs) - ^ +tailrec.scala:53: error: could not optimize @tailrec annotated method fail2: it contains a recursive call not in tail position + @tailrec final def fail2[T](xs: List[T]): List[T] = xs match { + ^ tailrec.scala:59: error: could not optimize @tailrec annotated method fail3: it is called recursively with different type arguments @tailrec final def fail3[T](x: Int): Int = fail3(x - 1) ^ diff --git a/test/files/neg/unreachablechar.flags b/test/files/neg/unreachablechar.flags new file mode 100644 index 0000000000..809e9ff2f2 --- /dev/null +++ b/test/files/neg/unreachablechar.flags @@ -0,0 +1 @@ + -Xoldpatmat diff --git a/test/files/pos/generic-sigs.scala b/test/files/pos/generic-sigs.scala index 40ec044656..b112766056 100644 --- a/test/files/pos/generic-sigs.scala +++ b/test/files/pos/generic-sigs.scala @@ -1,3 +1,5 @@ +import language.existentials + object A { def f1 = List(classOf[Int], classOf[String]) def f2 = List(classOf[String], classOf[Int]) @@ -15,4 +17,4 @@ object A { class Boppy[+T1,-T2] def g1 = new Boppy[t forSome { type t <: Int }, u forSome { type u <: String }] -}
\ No newline at end of file +} diff --git a/test/files/pos/hkarray.flags b/test/files/pos/hkarray.flags index e8fb65d50c..e745d8bbe3 100644 --- a/test/files/pos/hkarray.flags +++ b/test/files/pos/hkarray.flags @@ -1 +1 @@ --Xfatal-warnings
\ No newline at end of file +-Xfatal-warnings -language:higherKinds
\ No newline at end of file diff --git a/test/files/neg/macro-deprecate-dont-touch-backquotedidents.flags b/test/files/pos/macro-deprecate-dont-touch-backquotedidents.flags index e8fb65d50c..e8fb65d50c 100644 --- a/test/files/neg/macro-deprecate-dont-touch-backquotedidents.flags +++ b/test/files/pos/macro-deprecate-dont-touch-backquotedidents.flags diff --git a/test/files/neg/macro-deprecate-dont-touch-backquotedidents.scala b/test/files/pos/macro-deprecate-dont-touch-backquotedidents.scala index dee2f1de3b..69a7333011 100644 --- a/test/files/neg/macro-deprecate-dont-touch-backquotedidents.scala +++ b/test/files/pos/macro-deprecate-dont-touch-backquotedidents.scala @@ -44,12 +44,12 @@ package foo { } } -object Test12 { - val Some(`macro`) = Some(42) - `macro` match { - case `macro` => println(`macro`) - } -} +//object Test12 { +// val Some(`macro`) = Some(42) +// `macro` match { +// case `macro` => println(`macro`) +// } +//} object Test13 { def `macro` = 2 diff --git a/test/files/pos/t1439.flags b/test/files/pos/t1439.flags index 779916d58f..1e70f5c5c7 100644 --- a/test/files/pos/t1439.flags +++ b/test/files/pos/t1439.flags @@ -1 +1 @@ --unchecked -Xfatal-warnings
\ No newline at end of file +-unchecked -Xfatal-warnings -Xoldpatmat -language:higherKinds diff --git a/test/files/pos/virtpatmat_alts_subst.flags b/test/files/pos/virtpatmat_alts_subst.flags index 9769db9257..3f5a3100e4 100644 --- a/test/files/pos/virtpatmat_alts_subst.flags +++ b/test/files/pos/virtpatmat_alts_subst.flags @@ -1 +1 @@ - -Yvirtpatmat -Xexperimental + -Xexperimental diff --git a/test/files/pos/virtpatmat_anonfun_for.flags b/test/files/pos/virtpatmat_anonfun_for.flags index 23e3dc7d26..e69de29bb2 100644 --- a/test/files/pos/virtpatmat_anonfun_for.flags +++ b/test/files/pos/virtpatmat_anonfun_for.flags @@ -1 +0,0 @@ --Yvirtpatmat
\ No newline at end of file diff --git a/test/files/pos/virtpatmat_binding_opt.flags b/test/files/pos/virtpatmat_binding_opt.flags index 9769db9257..3f5a3100e4 100644 --- a/test/files/pos/virtpatmat_binding_opt.flags +++ b/test/files/pos/virtpatmat_binding_opt.flags @@ -1 +1 @@ - -Yvirtpatmat -Xexperimental + -Xexperimental diff --git a/test/files/pos/virtpatmat_castbinder.flags b/test/files/pos/virtpatmat_castbinder.flags index 9769db9257..3f5a3100e4 100644 --- a/test/files/pos/virtpatmat_castbinder.flags +++ b/test/files/pos/virtpatmat_castbinder.flags @@ -1 +1 @@ - -Yvirtpatmat -Xexperimental + -Xexperimental diff --git a/test/files/pos/virtpatmat_exist1.flags b/test/files/pos/virtpatmat_exist1.flags index 9769db9257..3f5a3100e4 100644 --- a/test/files/pos/virtpatmat_exist1.flags +++ b/test/files/pos/virtpatmat_exist1.flags @@ -1 +1 @@ - -Yvirtpatmat -Xexperimental + -Xexperimental diff --git a/test/files/pos/virtpatmat_exist2.flags b/test/files/pos/virtpatmat_exist2.flags index 9769db9257..3f5a3100e4 100644 --- a/test/files/pos/virtpatmat_exist2.flags +++ b/test/files/pos/virtpatmat_exist2.flags @@ -1 +1 @@ - -Yvirtpatmat -Xexperimental + -Xexperimental diff --git a/test/files/pos/virtpatmat_exist3.flags b/test/files/pos/virtpatmat_exist3.flags index 9769db9257..3f5a3100e4 100644 --- a/test/files/pos/virtpatmat_exist3.flags +++ b/test/files/pos/virtpatmat_exist3.flags @@ -1 +1 @@ - -Yvirtpatmat -Xexperimental + -Xexperimental diff --git a/test/files/pos/virtpatmat_exist_uncurry.scala b/test/files/pos/virtpatmat_exist_uncurry.scala new file mode 100644 index 0000000000..e017da6343 --- /dev/null +++ b/test/files/pos/virtpatmat_exist_uncurry.scala @@ -0,0 +1,6 @@ +object Test { + trait Leaf[T] { + def collect[U](f: PartialFunction[Leaf[_], U]): List[U] + def leaves: List[Leaf[T]] = collect { case l: Leaf[T] => l } + } +}
\ No newline at end of file diff --git a/test/files/pos/virtpatmat_gadt_array.flags b/test/files/pos/virtpatmat_gadt_array.flags index 9769db9257..3f5a3100e4 100644 --- a/test/files/pos/virtpatmat_gadt_array.flags +++ b/test/files/pos/virtpatmat_gadt_array.flags @@ -1 +1 @@ - -Yvirtpatmat -Xexperimental + -Xexperimental diff --git a/test/files/pos/virtpatmat_infer_single_1.flags b/test/files/pos/virtpatmat_infer_single_1.flags index 9769db9257..3f5a3100e4 100644 --- a/test/files/pos/virtpatmat_infer_single_1.flags +++ b/test/files/pos/virtpatmat_infer_single_1.flags @@ -1 +1 @@ - -Yvirtpatmat -Xexperimental + -Xexperimental diff --git a/test/files/pos/virtpatmat_instof_valuetype.flags b/test/files/pos/virtpatmat_instof_valuetype.flags index 9769db9257..3f5a3100e4 100644 --- a/test/files/pos/virtpatmat_instof_valuetype.flags +++ b/test/files/pos/virtpatmat_instof_valuetype.flags @@ -1 +1 @@ - -Yvirtpatmat -Xexperimental + -Xexperimental diff --git a/test/files/pos/virtpatmat_obj_in_case.flags b/test/files/pos/virtpatmat_obj_in_case.flags index 9769db9257..3f5a3100e4 100644 --- a/test/files/pos/virtpatmat_obj_in_case.flags +++ b/test/files/pos/virtpatmat_obj_in_case.flags @@ -1 +1 @@ - -Yvirtpatmat -Xexperimental + -Xexperimental diff --git a/test/files/presentation/callcc-interpreter/Runner.scala b/test/files/presentation/callcc-interpreter/Runner.scala index 1ef3cf9025..61b6efd50d 100644 --- a/test/files/presentation/callcc-interpreter/Runner.scala +++ b/test/files/presentation/callcc-interpreter/Runner.scala @@ -1,3 +1,5 @@ import scala.tools.nsc.interactive.tests._ -object Test extends InteractiveTest
\ No newline at end of file +object Test extends InteractiveTest { + settings.XoldPatmat.value = true // TODO: could this be running into some kind of race condition? sometimes the match has been translated, sometimes it hasn't +}
\ No newline at end of file diff --git a/test/files/presentation/random.check b/test/files/presentation/random.check index fce4b69fb3..1b73720312 100644 --- a/test/files/presentation/random.check +++ b/test/files/presentation/random.check @@ -4,7 +4,8 @@ askType at Random.scala(18,14) ================================================================================ [response] askTypeAt at (18,14) val filter: Int => Boolean = try { - java.this.lang.Integer.parseInt(args.apply(0)) match { + case <synthetic> val x1: Int = java.this.lang.Integer.parseInt(args.apply(0)); + x1 match { case 1 => ((x: Int) => x.%(2).!=(0)) case 2 => ((x: Int) => x.%(2).==(0)) case _ => ((x: Int) => x.!=(0)) diff --git a/test/files/run/applydynamic_sip.check b/test/files/run/applydynamic_sip.check new file mode 100644 index 0000000000..d94db4417e --- /dev/null +++ b/test/files/run/applydynamic_sip.check @@ -0,0 +1,22 @@ +qual.applyDynamic(sel)() +qual.applyDynamic(sel)(a) +qual.applyDynamic(sel)(a) +.apply(a2) +qual.applyDynamic(sel)(a) +qual.applyDynamic(sel)(a) +.apply(a2) +qual.applyDynamicNamed(sel)((arg,a)) +qual.applyDynamicNamed(sel)((arg,a)) +qual.applyDynamicNamed(sel)((,a), (arg2,a2)) +qual.updateDynamic(sel)(expr) +qual.selectDynamic(sel) +qual.selectDynamic(sel) +qual.selectDynamic(sel) +.update(1, expr) +qual.selectDynamic(sel) +.update(expr) +qual.selectDynamic(sel) +.apply(1) +qual.selectDynamic(sel) +.apply +.update(1, 1) diff --git a/test/files/run/applydynamic_sip.scala b/test/files/run/applydynamic_sip.scala new file mode 100644 index 0000000000..57cb4349f7 --- /dev/null +++ b/test/files/run/applydynamic_sip.scala @@ -0,0 +1,58 @@ +object Test extends App { + object stubUpdate { + def update(as: Any*) = println(".update"+as.toList.mkString("(",", ", ")")) + } + + object stub { + def apply = {println(".apply"); stubUpdate} + def apply(as: Any*) = println(".apply"+as.toList.mkString("(",", ", ")")) + def update(as: Any*) = println(".update"+as.toList.mkString("(",", ", ")")) + } + class MyDynamic extends Dynamic { + def applyDynamic[T](n: String)(as: Any*) = {println("qual.applyDynamic("+ n +")"+ as.toList.mkString("(",", ", ")")); stub} + def applyDynamicNamed[T](n: String)(as: (String, Any)*) = {println("qual.applyDynamicNamed("+ n +")"+ as.toList.mkString("(",", ", ")")); stub} + def selectDynamic[T](n: String) = {println("qual.selectDynamic("+ n +")"); stub} + def updateDynamic(n: String)(x: Any): Unit = {println("qual.updateDynamic("+ n +")("+ x +")")} + } + val qual = new MyDynamic + val expr = "expr" + val a = "a" + val a2 = "a2" + type T = String + + // If qual.sel is followed by a potential type argument list [Ts] and an argument list (arg1, …, argn) where none of the arguments argi are named: + // qual.applyDynamic(“sel”)(arg1, …, argn) + qual.sel() + qual.sel(a) + // qual.sel(a, a2: _*) -- should not accept varargs? + qual.sel(a)(a2) + qual.sel[T](a) + qual.sel[T](a)(a2) + + // If qual.sel is followed by a potential type argument list [Ts] + // and a non-empty named argument list (x1 = arg1, …, xn = argn) where some name prefixes xi = might be missing: + // qual.applyDynamicNamed(“sel”)(xs1 -> arg1, …, xsn -> argn) + qual.sel(arg = a) + qual.sel[T](arg = a) + qual.sel(a, arg2 = "a2") + // qual.sel(a)(a2, arg2 = "a2") + // qual.sel[T](a)(a2, arg2 = "a2") + // qual.sel(arg = a, a2: _*) + // qual.sel(arg, arg2 = "a2", a2: _*) + + // If qual.sel appears immediately on the left-hand side of an assigment + // qual.updateDynamic(“sel”)(expr) + qual.sel = expr + + // If qual.sel, possibly applied to type arguments, but is + // not applied to explicit value arguments, + // nor immediately followed by an assignment operator: + // qual.selectDynamic[Ts](“sel”) + qual.sel + qual.sel[T] + + qual.sel(1) = expr // parser turns this into qual.sel.update(1, expr) + qual.sel() = expr // parser turns this into qual.sel.update(expr) + qual.sel.apply(1) + qual.sel.apply(1) = 1 +}
\ No newline at end of file diff --git a/test/files/run/constrained-types.check b/test/files/run/constrained-types.check index ac8817cb08..37784a20ca 100644 --- a/test/files/run/constrained-types.check +++ b/test/files/run/constrained-types.check @@ -75,9 +75,13 @@ scala> var four = "four" four: String = four scala> val four2 = m(four) // should have an existential bound +warning: there were 1 feature warnings; re-run with -feature for details +warning: there were 1 feature warnings; re-run with -feature for details four2: String @Annot(x) forSome { val x: String } = four scala> val four3 = four2 // should have the same type as four2 +warning: there were 1 feature warnings; re-run with -feature for details +warning: there were 1 feature warnings; re-run with -feature for details four3: String @Annot(x) forSome { val x: String } = four scala> val stuff = m("stuff") // should not crash @@ -100,6 +104,8 @@ scala> def m = { val y : String @Annot(x) = x y } // x should not escape the local scope with a narrow type +warning: there were 1 feature warnings; re-run with -feature for details +warning: there were 1 feature warnings; re-run with -feature for details m: String @Annot(x) forSome { val x: String } scala> @@ -113,6 +119,7 @@ scala> def n(y: String) = { } m("stuff".stripMargin) } // x should be existentially bound +warning: there were 1 feature warnings; re-run with -feature for details n: (y: String)String @Annot(x) forSome { val x: String } scala> diff --git a/test/files/run/dynamic-proxy.check b/test/files/run/dynamic-proxy.check new file mode 100644 index 0000000000..d1b85daff4 --- /dev/null +++ b/test/files/run/dynamic-proxy.check @@ -0,0 +1,20 @@ +noargs +noargs +nullary +value +symbolic +symbolic with args +non-existent method +before mutation +mutation 1 +after mutation 1 +mutation 2 +after mutation 2 +overloaded with object +overloaded with primitive +overloaded with object in var +overloaded with object in var 2 +typeArgs: I am a car +default: 4 +default: 3 +named: 6 diff --git a/test/files/run/dynamic-proxy.flags b/test/files/run/dynamic-proxy.flags new file mode 100644 index 0000000000..48fd867160 --- /dev/null +++ b/test/files/run/dynamic-proxy.flags @@ -0,0 +1 @@ +-Xexperimental diff --git a/test/files/run/dynamic-proxy.scala b/test/files/run/dynamic-proxy.scala new file mode 100644 index 0000000000..ab5a8b1d66 --- /dev/null +++ b/test/files/run/dynamic-proxy.scala @@ -0,0 +1,72 @@ +import scala.reflect._ + +class Car{ override def toString = "I am a car" } +object x{ + def nullary = "nullary" + def noargs() = "noargs" + def - = "symbolic" + def $(s:String) = "symbolic with args" + val value = "value" + def overloaded(i:Int) = "overloaded with primitive" + def overloaded(s:String) = s + def default( a:Int, b:Int = 2 ) = "default: "+(a+b) + def named( a:Int, b:Int, c:Int ) = "named: "+(a+b+c) + def typeArgs[T]( v:T ) = "typeArgs: "+v + var mutable = "before mutation" + def multiArgLists( a:String )( b:String ) = "multiArgList " + a + b + def bar( s:String )(implicit car:Car) = s + car.toString +} + +object Test extends App{ + val d = new DynamicProxy{ val dynamicProxyTarget = x } + + println( d.noargs ) + println( d.noargs() ) + println( d.nullary ) + println( d.value ) + println( d.- ) + println( d.$("x") ) + + try{ + println( d.test ) + } catch { + case _ => println("non-existent method") + } + + println( d.mutable ) + + println("mutation 1") + d.mutable_=("after mutation 1") + println( d.mutable ) + + println("mutation 2") + d.mutable = "after mutation 2" + println( d.mutable ) + + println( d.overloaded("overloaded with object") ) + println( d.overloaded(1) ) + + // test some non-constant arguments + def s = "overloaded with object in var" + println( d.overloaded(s) ) + println( d.overloaded(s + " 2") ) + + val car = new Car + println( d.typeArgs(car) ) // inferred + // println( d.typeArgs[Car](car) ) // explicit not working (yet) + + println( d.default( 1,3 ) ) + println( d.default( 1 ) ) + + println( d.named(1,c=3,b=2) ) // applyDynamicNamed seems to be broken + + // println( d.multiArgLists("a")("b") ) // not working yet + + /* + // may never work + // testing implicit parameters (first test works when moving x into TestDynamicReflect) + implicit val car2 = new Car + println( d.bar( "Yeah, ") ); // FAILS: could not find implicit value for parameter car + {println( d.bar( "Yeah, ") )} // FAILS: could not find implicit value for parameter car + */ +} diff --git a/test/files/run/existentials-in-compiler.check b/test/files/run/existentials-in-compiler.check index 83e3cdf435..4df4b0ca96 100644 --- a/test/files/run/existentials-in-compiler.check +++ b/test/files/run/existentials-in-compiler.check @@ -100,8 +100,8 @@ abstract trait Cov31[+A, +B, C <: (A, B)] extends Object abstract trait Cov32[+A, B, C <: (A, B)] extends Object extest.Cov32[A,B,C] forSome { +A; B; C <: (A, B) } -abstract trait Cov33[+A, -B, C <: (A, _$10) forSome { type _$10 }] extends Object - extest.Cov33[A,B,C] forSome { +A; -B; C <: (A, _$10) forSome { type _$10 } } +abstract trait Cov33[+A, -B, C <: Tuple2[A, _]] extends Object + extest.Cov33[A,B,C] forSome { +A; -B; C <: Tuple2[A, _] } abstract trait Cov34[A, +B, C <: (A, B)] extends Object extest.Cov34[A,B,C] forSome { A; +B; C <: (A, B) } @@ -109,14 +109,14 @@ abstract trait Cov34[A, +B, C <: (A, B)] extends Object abstract trait Cov35[A, B, C <: (A, B)] extends Object extest.Cov35[A,B,C] forSome { A; B; C <: (A, B) } -abstract trait Cov36[A, -B, C <: (A, _$11) forSome { type _$11 }] extends Object - extest.Cov36[A,B,C] forSome { A; -B; C <: (A, _$11) forSome { type _$11 } } +abstract trait Cov36[A, -B, C <: Tuple2[A, _]] extends Object + extest.Cov36[A,B,C] forSome { A; -B; C <: Tuple2[A, _] } -abstract trait Cov37[-A, +B, C <: (_$12, B) forSome { type _$12 }] extends Object - extest.Cov37[A,B,C] forSome { -A; +B; C <: (_$12, B) forSome { type _$12 } } +abstract trait Cov37[-A, +B, C <: Tuple2[_, B]] extends Object + extest.Cov37[A,B,C] forSome { -A; +B; C <: Tuple2[_, B] } -abstract trait Cov38[-A, B, C <: (_$13, B) forSome { type _$13 }] extends Object - extest.Cov38[A,B,C] forSome { -A; B; C <: (_$13, B) forSome { type _$13 } } +abstract trait Cov38[-A, B, C <: Tuple2[_, B]] extends Object + extest.Cov38[A,B,C] forSome { -A; B; C <: Tuple2[_, B] } abstract trait Cov39[-A, -B, C <: Tuple2[_, _]] extends Object extest.Cov39[_, _, _ <: Tuple2[_, _]] diff --git a/test/files/run/inline-ex-handlers.check b/test/files/run/inline-ex-handlers.check index 7a8a744bfa..708fcc6985 100644 --- a/test/files/run/inline-ex-handlers.check +++ b/test/files/run/inline-ex-handlers.check @@ -1,40 +1,44 @@ 172c172 -< locals: value x$1, value temp1 +< locals: value x$1, value x1 --- -> locals: value x$1, value temp1, variable boxed1 +> locals: value x$1, value x1, variable boxed1 174c174 < blocks: [1,2,3,4] --- -> blocks: [1,2,3] -187,189d186 -< 92 JUMP 4 -< -< 4: -195a193,194 +> blocks: [1,3,4] +186a187,188 > 92 STORE_LOCAL(variable boxed1) > 92 LOAD_LOCAL(variable boxed1) -386c385 -< blocks: [1,2,3,4,5,7,8,10] +195,197d196 +< 92 JUMP 2 +< +< 2: +385c384 +< blocks: [1,2,3,4,5,8,11,13,14,16] --- -> blocks: [1,2,3,4,5,7,8,10,11] -410c409,418 +> blocks: [1,2,3,5,8,11,13,14,16,17] +409c408,417 < 103 THROW(MyException) --- -> ? STORE_LOCAL(value ex$1) -> ? JUMP 11 +> ? STORE_LOCAL(value ex5) +> ? JUMP 17 > -> 11: -> 101 LOAD_LOCAL(value ex$1) -> 101 STORE_LOCAL(value temp2) -> 101 SCOPE_ENTER value temp2 -> 101 LOAD_LOCAL(value temp2) -> 101 IS_INSTANCE REF(class MyException) -> 101 CZJUMP (BOOL)NE ? 4 : 5 -501c509 +> 17: +> 101 LOAD_LOCAL(value ex5) +> 101 STORE_LOCAL(value x3) +> 101 SCOPE_ENTER value x3 +> 106 LOAD_LOCAL(value x3) +> 106 IS_INSTANCE REF(class MyException) +> 106 CZJUMP (BOOL)NE ? 5 : 11 +422,424d429 +< 101 JUMP 4 +< +< 4: +512c517 < blocks: [1,2,3,4,6,7,8,9,10] --- > blocks: [1,2,3,4,6,7,8,9,10,11,12,13] -530c538,543 +541c546,551 < 306 THROW(MyException) --- > ? JUMP 11 @@ -43,7 +47,7 @@ > ? LOAD_LOCAL(variable monitor4) > 305 MONITOR_EXIT > ? JUMP 12 -536c549,555 +547c557,563 < ? THROW(Throwable) --- > ? JUMP 12 @@ -53,7 +57,7 @@ > 304 MONITOR_EXIT > ? STORE_LOCAL(value t) > ? JUMP 13 -542c561,574 +553c569,582 < ? THROW(Throwable) --- > ? STORE_LOCAL(value t) @@ -70,19 +74,19 @@ > 310 CALL_PRIMITIVE(EndConcat) > 310 CALL_METHOD scala.Predef.println (dynamic) > 310 JUMP 2 -566c598 +577c606 < catch (Throwable) in ArrayBuffer(7, 8, 9, 10) starting at: 6 --- > catch (Throwable) in ArrayBuffer(7, 8, 9, 10, 11) starting at: 6 -569c601 +580c609 < catch (Throwable) in ArrayBuffer(4, 6, 7, 8, 9, 10) starting at: 3 --- > catch (Throwable) in ArrayBuffer(4, 6, 7, 8, 9, 10, 11, 12) starting at: 3 -601c633 +612c641 < blocks: [1,2,3,4,5,6,7,9,10] --- > blocks: [1,2,3,4,5,6,7,9,10,11,12] -625c657,663 +636c665,671 < 78 THROW(IllegalArgumentException) --- > ? STORE_LOCAL(value e) @@ -92,7 +96,7 @@ > 81 LOAD_LOCAL(value e) > ? STORE_LOCAL(variable exc1) > ? JUMP 12 -654c692,706 +665c700,714 < 81 THROW(Exception) --- > ? STORE_LOCAL(variable exc1) @@ -110,57 +114,53 @@ > 84 STORE_LOCAL(variable result) > 84 LOAD_LOCAL(variable exc1) > 84 THROW(Throwable) -676c728 +687c736 < catch (<none>) in ArrayBuffer(4, 6, 7, 9) starting at: 3 --- > catch (<none>) in ArrayBuffer(4, 6, 7, 9, 11) starting at: 3 -702c754 -< blocks: [1,2,3,4,5,6,7,8,11,12,13,14,15,16,18,19] +713c762 +< blocks: [1,2,3,4,5,6,9,12,14,17,18,19,22,25,27,28,30,31] --- -> blocks: [1,2,3,4,5,6,7,8,11,12,13,14,15,16,18,19,20,21,22] -726c778,787 +> blocks: [1,2,3,4,5,6,9,12,14,17,18,19,22,25,27,28,30,31,32,33,34] +737c786,793 < 172 THROW(MyException) --- -> ? STORE_LOCAL(value ex$4) -> ? JUMP 20 +> ? STORE_LOCAL(value ex5) +> ? JUMP 32 > -> 20: -> 170 LOAD_LOCAL(value ex$4) -> 170 STORE_LOCAL(value temp11) -> 170 SCOPE_ENTER value temp11 -> 170 LOAD_LOCAL(value temp11) -> 170 IS_INSTANCE REF(class MyException) -> 170 CZJUMP (BOOL)NE ? 12 : 13 -780c841,842 +> 32: +> 170 LOAD_LOCAL(value ex5) +> 170 STORE_LOCAL(value x3) +> 170 SCOPE_ENTER value x3 +> 170 JUMP 18 +793c849,850 < 177 THROW(MyException) --- -> ? STORE_LOCAL(value ex$5) -> ? JUMP 21 -784c846,855 +> ? STORE_LOCAL(value ex5) +> ? JUMP 33 +797c854,861 < 170 THROW(Throwable) --- -> ? STORE_LOCAL(value ex$5) -> ? JUMP 21 +> ? STORE_LOCAL(value ex5) +> ? JUMP 33 > -> 21: -> 169 LOAD_LOCAL(value ex$5) -> 169 STORE_LOCAL(value temp14) -> 169 SCOPE_ENTER value temp14 -> 169 LOAD_LOCAL(value temp14) -> 169 IS_INSTANCE REF(class MyException) -> 169 CZJUMP (BOOL)NE ? 5 : 6 -815c886,887 +> 33: +> 169 LOAD_LOCAL(value ex5) +> 169 STORE_LOCAL(value x3) +> 169 SCOPE_ENTER value x3 +> 169 JUMP 5 +830c894,895 < 182 THROW(MyException) --- > ? STORE_LOCAL(variable exc2) -> ? JUMP 22 -819c891,905 +> ? JUMP 34 +834c899,900 < 169 THROW(Throwable) --- > ? STORE_LOCAL(variable exc2) -> ? JUMP 22 -> -> 22: +> ? JUMP 34 +835a902,914 +> 34: > 184 LOAD_MODULE object Predef > 184 CONSTANT("finally") > 184 CALL_METHOD scala.Predef.println (dynamic) @@ -172,57 +172,60 @@ > 185 STORE_LOCAL(variable result) > 185 LOAD_LOCAL(variable exc2) > 185 THROW(Throwable) -841c927 -< catch (Throwable) in ArrayBuffer(11, 12, 13, 14, 15, 16, 18) starting at: 4 +> +856c935 +< catch (Throwable) in ArrayBuffer(17, 18, 19, 22, 25, 27, 28, 30) starting at: 4 --- -> catch (Throwable) in ArrayBuffer(11, 12, 13, 14, 15, 16, 18, 20) starting at: 4 -844c930 -< catch (<none>) in ArrayBuffer(4, 5, 6, 7, 11, 12, 13, 14, 15, 16, 18) starting at: 3 +> catch (Throwable) in ArrayBuffer(17, 18, 19, 22, 25, 27, 28, 30, 32) starting at: 4 +859c938 +< catch (<none>) in ArrayBuffer(4, 5, 6, 9, 12, 17, 18, 19, 22, 25, 27, 28, 30) starting at: 3 --- -> catch (<none>) in ArrayBuffer(4, 5, 6, 7, 11, 12, 13, 14, 15, 16, 18, 20, 21) starting at: 3 -870c956 -< blocks: [1,2,3,6,7,8,10,11,13] +> catch (<none>) in ArrayBuffer(4, 5, 6, 9, 12, 17, 18, 19, 22, 25, 27, 28, 30, 32, 33) starting at: 3 +885c964 +< blocks: [1,2,3,6,7,8,11,14,16,17,19] --- -> blocks: [1,2,3,6,7,8,10,11,13,14] -894c980,989 +> blocks: [1,2,3,6,7,8,11,14,16,17,19,20] +909c988,995 < 124 THROW(MyException) --- -> ? STORE_LOCAL(value ex$2) -> ? JUMP 14 +> ? STORE_LOCAL(value ex5) +> ? JUMP 20 > -> 14: -> 122 LOAD_LOCAL(value ex$2) -> 122 STORE_LOCAL(value temp5) -> 122 SCOPE_ENTER value temp5 -> 122 LOAD_LOCAL(value temp5) -> 122 IS_INSTANCE REF(class MyException) -> 122 CZJUMP (BOOL)NE ? 7 : 8 -942c1037 -< catch (IllegalArgumentException) in ArrayBuffer(6, 7, 8, 10, 11, 13) starting at: 3 ---- -> catch (IllegalArgumentException) in ArrayBuffer(6, 7, 8, 10, 11, 13, 14) starting at: 3 -968c1063 -< blocks: [1,2,3,4,5,9,10,11,13] ---- -> blocks: [1,2,3,4,5,9,10,11,13,14] -992c1087,1096 +> 20: +> 122 LOAD_LOCAL(value ex5) +> 122 STORE_LOCAL(value x3) +> 122 SCOPE_ENTER value x3 +> 122 JUMP 7 +969c1055 +< catch (IllegalArgumentException) in ArrayBuffer(6, 7, 8, 11, 14, 16, 17, 19) starting at: 3 +--- +> catch (IllegalArgumentException) in ArrayBuffer(6, 7, 8, 11, 14, 16, 17, 19, 20) starting at: 3 +995c1081 +< blocks: [1,2,3,4,5,8,11,15,16,17,19] +--- +> blocks: [1,2,3,5,8,11,15,16,17,19,20] +1019c1105,1114 < 148 THROW(MyException) --- -> ? STORE_LOCAL(value ex$3) -> ? JUMP 14 +> ? STORE_LOCAL(value ex5) +> ? JUMP 20 > -> 14: -> 145 LOAD_LOCAL(value ex$3) -> 145 STORE_LOCAL(value temp8) -> 145 SCOPE_ENTER value temp8 -> 145 LOAD_LOCAL(value temp8) -> 145 IS_INSTANCE REF(class MyException) -> 145 CZJUMP (BOOL)NE ? 4 : 5 -1236c1340 +> 20: +> 145 LOAD_LOCAL(value ex5) +> 145 STORE_LOCAL(value x3) +> 145 SCOPE_ENTER value x3 +> 154 LOAD_LOCAL(value x3) +> 154 IS_INSTANCE REF(class MyException) +> 154 CZJUMP (BOOL)NE ? 5 : 11 +1040,1042d1134 +< 145 JUMP 4 +< +< 4: +1275c1367 < blocks: [1,2,3,4,5,7] --- > blocks: [1,2,3,4,5,7,8] -1260c1364,1371 +1299c1391,1398 < 38 THROW(IllegalArgumentException) --- > ? STORE_LOCAL(value e) @@ -233,33 +236,37 @@ > 42 CONSTANT("IllegalArgumentException") > 42 CALL_METHOD scala.Predef.println (dynamic) > 42 JUMP 2 -1309c1420 -< blocks: [1,2,3,4,5,7,8,10,11,13] +1348c1447 +< blocks: [1,2,3,4,5,8,11,13,14,16,17,19] --- -> blocks: [1,2,3,4,5,7,8,10,11,13,14] -1333c1444,1445 +> blocks: [1,2,3,5,8,11,13,14,16,17,19,20] +1372c1471,1472 < 203 THROW(MyException) --- -> ? STORE_LOCAL(value ex$6) -> ? JUMP 14 -1353c1465,1474 +> ? STORE_LOCAL(value ex5) +> ? JUMP 20 +1392c1492,1501 < 209 THROW(MyException) --- -> ? STORE_LOCAL(value ex$6) -> ? JUMP 14 +> ? STORE_LOCAL(value ex5) +> ? JUMP 20 > -> 14: -> 200 LOAD_LOCAL(value ex$6) -> 200 STORE_LOCAL(value temp17) -> 200 SCOPE_ENTER value temp17 -> 200 LOAD_LOCAL(value temp17) -> 200 IS_INSTANCE REF(class MyException) -> 200 CZJUMP (BOOL)NE ? 4 : 5 -1416c1537 +> 20: +> 200 LOAD_LOCAL(value ex5) +> 200 STORE_LOCAL(value x3) +> 200 SCOPE_ENTER value x3 +> 212 LOAD_LOCAL(value x3) +> 212 IS_INSTANCE REF(class MyException) +> 212 CZJUMP (BOOL)NE ? 5 : 11 +1405,1407d1513 +< 200 JUMP 4 +< +< 4: +1467c1573 < blocks: [1,2,3,4,5,7] --- > blocks: [1,2,3,4,5,7,8] -1440c1561,1568 +1491c1597,1604 < 58 THROW(IllegalArgumentException) --- > ? STORE_LOCAL(value e) @@ -270,11 +277,11 @@ > 62 CONSTANT("RuntimeException") > 62 CALL_METHOD scala.Predef.println (dynamic) > 62 JUMP 2 -1489c1617 +1540c1653 < blocks: [1,2,3,4] --- > blocks: [1,2,3,4,5] -1509c1637,1642 +1560c1673,1678 < 229 THROW(MyException) --- > ? JUMP 5 @@ -283,19 +290,19 @@ > ? LOAD_LOCAL(variable monitor1) > 228 MONITOR_EXIT > 228 THROW(Throwable) -1515c1648 +1566c1684 < ? THROW(Throwable) --- > 228 THROW(Throwable) -1543c1676 +1594c1712 < locals: value args, variable result, variable monitor2, variable monitorResult1 --- > locals: value exception$1, value args, variable result, variable monitor2, variable monitorResult1 -1545c1678 +1596c1714 < blocks: [1,2,3,4] --- > blocks: [1,2,3,4,5] -1568c1701,1709 +1619c1737,1745 < 245 THROW(MyException) --- > ? STORE_LOCAL(value exception$1) @@ -307,7 +314,7 @@ > ? LOAD_LOCAL(variable monitor2) > 244 MONITOR_EXIT > 244 THROW(Throwable) -1574c1715 +1625c1751 < ? THROW(Throwable) --- > 244 THROW(Throwable) diff --git a/test/files/run/macro-abort-fresh.flags b/test/files/run/macro-abort-fresh.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-abort-fresh.flags +++ b/test/files/run/macro-abort-fresh.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-basic-ma-md-mi.flags b/test/files/run/macro-basic-ma-md-mi.flags index 06a7b31f11..5e5dd6ce79 100644 --- a/test/files/run/macro-basic-ma-md-mi.flags +++ b/test/files/run/macro-basic-ma-md-mi.flags @@ -1 +1 @@ --Xmacros +-language:experimental.macros diff --git a/test/files/run/macro-basic-ma-mdmi.flags b/test/files/run/macro-basic-ma-mdmi.flags index 06a7b31f11..5e5dd6ce79 100644 --- a/test/files/run/macro-basic-ma-mdmi.flags +++ b/test/files/run/macro-basic-ma-mdmi.flags @@ -1 +1 @@ --Xmacros +-language:experimental.macros diff --git a/test/files/run/macro-basic-mamd-mi.flags b/test/files/run/macro-basic-mamd-mi.flags index 06a7b31f11..5e5dd6ce79 100644 --- a/test/files/run/macro-basic-mamd-mi.flags +++ b/test/files/run/macro-basic-mamd-mi.flags @@ -1 +1 @@ --Xmacros +-language:experimental.macros diff --git a/test/files/run/macro-bodyexpandstoimpl.flags b/test/files/run/macro-bodyexpandstoimpl.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-bodyexpandstoimpl.flags +++ b/test/files/run/macro-bodyexpandstoimpl.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-annotation.flags b/test/files/run/macro-declared-in-annotation.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-declared-in-annotation.flags +++ b/test/files/run/macro-declared-in-annotation.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-anonymous.flags b/test/files/run/macro-declared-in-anonymous.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-declared-in-anonymous.flags +++ b/test/files/run/macro-declared-in-anonymous.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-block.flags b/test/files/run/macro-declared-in-block.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-declared-in-block.flags +++ b/test/files/run/macro-declared-in-block.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-class-class.flags b/test/files/run/macro-declared-in-class-class.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-declared-in-class-class.flags +++ b/test/files/run/macro-declared-in-class-class.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-class-object.flags b/test/files/run/macro-declared-in-class-object.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-declared-in-class-object.flags +++ b/test/files/run/macro-declared-in-class-object.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-class.flags b/test/files/run/macro-declared-in-class.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-declared-in-class.flags +++ b/test/files/run/macro-declared-in-class.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-default-param.flags b/test/files/run/macro-declared-in-default-param.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-declared-in-default-param.flags +++ b/test/files/run/macro-declared-in-default-param.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-implicit-class.flags b/test/files/run/macro-declared-in-implicit-class.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-declared-in-implicit-class.flags +++ b/test/files/run/macro-declared-in-implicit-class.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-method.flags b/test/files/run/macro-declared-in-method.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-declared-in-method.flags +++ b/test/files/run/macro-declared-in-method.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-object-class.flags b/test/files/run/macro-declared-in-object-class.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-declared-in-object-class.flags +++ b/test/files/run/macro-declared-in-object-class.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-object-object.flags b/test/files/run/macro-declared-in-object-object.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-declared-in-object-object.flags +++ b/test/files/run/macro-declared-in-object-object.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-object.flags b/test/files/run/macro-declared-in-object.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-declared-in-object.flags +++ b/test/files/run/macro-declared-in-object.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-package-object.flags b/test/files/run/macro-declared-in-package-object.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-declared-in-package-object.flags +++ b/test/files/run/macro-declared-in-package-object.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-refinement.flags b/test/files/run/macro-declared-in-refinement.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-declared-in-refinement.flags +++ b/test/files/run/macro-declared-in-refinement.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-trait.flags b/test/files/run/macro-declared-in-trait.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-declared-in-trait.flags +++ b/test/files/run/macro-declared-in-trait.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-def-infer-return-type-a.flags b/test/files/run/macro-def-infer-return-type-a.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-def-infer-return-type-a.flags +++ b/test/files/run/macro-def-infer-return-type-a.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-def-infer-return-type-b.flags b/test/files/run/macro-def-infer-return-type-b.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-def-infer-return-type-b.flags +++ b/test/files/run/macro-def-infer-return-type-b.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-def-infer-return-type-c.flags b/test/files/run/macro-def-infer-return-type-c.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-def-infer-return-type-c.flags +++ b/test/files/run/macro-def-infer-return-type-c.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-def-path-dependent-a.flags b/test/files/run/macro-def-path-dependent-a.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-def-path-dependent-a.flags +++ b/test/files/run/macro-def-path-dependent-a.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-def-path-dependent-b.flags b/test/files/run/macro-def-path-dependent-b.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-def-path-dependent-b.flags +++ b/test/files/run/macro-def-path-dependent-b.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-def-path-dependent-c.flags b/test/files/run/macro-def-path-dependent-c.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-def-path-dependent-c.flags +++ b/test/files/run/macro-def-path-dependent-c.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-def-path-dependent-d.flags b/test/files/run/macro-def-path-dependent-d.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-def-path-dependent-d.flags +++ b/test/files/run/macro-def-path-dependent-d.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-implicit-macro-has-implicit.flags b/test/files/run/macro-expand-implicit-macro-has-implicit.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-expand-implicit-macro-has-implicit.flags +++ b/test/files/run/macro-expand-implicit-macro-has-implicit.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-implicit-macro-is-implicit.flags b/test/files/run/macro-expand-implicit-macro-is-implicit.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-expand-implicit-macro-is-implicit.flags +++ b/test/files/run/macro-expand-implicit-macro-is-implicit.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-implicit-macro-is-val.flags b/test/files/run/macro-expand-implicit-macro-is-val.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-expand-implicit-macro-is-val.flags +++ b/test/files/run/macro-expand-implicit-macro-is-val.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-implicit-macro-is-view.flags b/test/files/run/macro-expand-implicit-macro-is-view.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-expand-implicit-macro-is-view.flags +++ b/test/files/run/macro-expand-implicit-macro-is-view.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-multiple-arglists.flags b/test/files/run/macro-expand-multiple-arglists.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-expand-multiple-arglists.flags +++ b/test/files/run/macro-expand-multiple-arglists.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-nullary-generic.flags b/test/files/run/macro-expand-nullary-generic.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-expand-nullary-generic.flags +++ b/test/files/run/macro-expand-nullary-generic.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-nullary-nongeneric.flags b/test/files/run/macro-expand-nullary-nongeneric.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-expand-nullary-nongeneric.flags +++ b/test/files/run/macro-expand-nullary-nongeneric.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-overload.flags b/test/files/run/macro-expand-overload.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-expand-overload.flags +++ b/test/files/run/macro-expand-overload.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-override.flags b/test/files/run/macro-expand-override.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-expand-override.flags +++ b/test/files/run/macro-expand-override.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-recursive.flags b/test/files/run/macro-expand-recursive.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-expand-recursive.flags +++ b/test/files/run/macro-expand-recursive.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-bounds-a.flags b/test/files/run/macro-expand-tparams-bounds-a.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-expand-tparams-bounds-a.flags +++ b/test/files/run/macro-expand-tparams-bounds-a.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-bounds-b.flags b/test/files/run/macro-expand-tparams-bounds-b.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-expand-tparams-bounds-b.flags +++ b/test/files/run/macro-expand-tparams-bounds-b.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-explicit.flags b/test/files/run/macro-expand-tparams-explicit.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-expand-tparams-explicit.flags +++ b/test/files/run/macro-expand-tparams-explicit.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-implicit.flags b/test/files/run/macro-expand-tparams-implicit.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-expand-tparams-implicit.flags +++ b/test/files/run/macro-expand-tparams-implicit.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-only-in-impl.flags b/test/files/run/macro-expand-tparams-only-in-impl.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-expand-tparams-only-in-impl.flags +++ b/test/files/run/macro-expand-tparams-only-in-impl.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-optional.flags b/test/files/run/macro-expand-tparams-optional.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-expand-tparams-optional.flags +++ b/test/files/run/macro-expand-tparams-optional.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-prefix-a.flags b/test/files/run/macro-expand-tparams-prefix-a.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-expand-tparams-prefix-a.flags +++ b/test/files/run/macro-expand-tparams-prefix-a.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-prefix-b.flags b/test/files/run/macro-expand-tparams-prefix-b.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-expand-tparams-prefix-b.flags +++ b/test/files/run/macro-expand-tparams-prefix-b.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-prefix-c1.flags b/test/files/run/macro-expand-tparams-prefix-c1.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-expand-tparams-prefix-c1.flags +++ b/test/files/run/macro-expand-tparams-prefix-c1.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-prefix-c2.flags b/test/files/run/macro-expand-tparams-prefix-c2.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-expand-tparams-prefix-c2.flags +++ b/test/files/run/macro-expand-tparams-prefix-c2.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-prefix-d1.flags b/test/files/run/macro-expand-tparams-prefix-d1.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-expand-tparams-prefix-d1.flags +++ b/test/files/run/macro-expand-tparams-prefix-d1.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad.flags b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad.flags +++ b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-good.flags b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-good.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-good.flags +++ b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-good.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-varargs-explicit-over-varargs.flags b/test/files/run/macro-expand-varargs-explicit-over-varargs.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-expand-varargs-explicit-over-varargs.flags +++ b/test/files/run/macro-expand-varargs-explicit-over-varargs.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-varargs-implicit-over-nonvarargs.flags b/test/files/run/macro-expand-varargs-implicit-over-nonvarargs.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-expand-varargs-implicit-over-nonvarargs.flags +++ b/test/files/run/macro-expand-varargs-implicit-over-nonvarargs.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-varargs-implicit-over-varargs.flags b/test/files/run/macro-expand-varargs-implicit-over-varargs.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-expand-varargs-implicit-over-varargs.flags +++ b/test/files/run/macro-expand-varargs-implicit-over-varargs.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-impl-default-params.flags b/test/files/run/macro-impl-default-params.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-impl-default-params.flags +++ b/test/files/run/macro-impl-default-params.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-impl-rename-context.flags b/test/files/run/macro-impl-rename-context.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-impl-rename-context.flags +++ b/test/files/run/macro-impl-rename-context.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-invalidret-doesnt-conform-to-def-rettype.flags b/test/files/run/macro-invalidret-doesnt-conform-to-def-rettype.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-invalidret-doesnt-conform-to-def-rettype.flags +++ b/test/files/run/macro-invalidret-doesnt-conform-to-def-rettype.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-invalidret-doesnt-conform-to-impl-rettype.flags b/test/files/run/macro-invalidret-doesnt-conform-to-impl-rettype.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-invalidret-doesnt-conform-to-impl-rettype.flags +++ b/test/files/run/macro-invalidret-doesnt-conform-to-impl-rettype.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-invalidret-nontypeable.flags b/test/files/run/macro-invalidret-nontypeable.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-invalidret-nontypeable.flags +++ b/test/files/run/macro-invalidret-nontypeable.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-invalidusage-badret.flags b/test/files/run/macro-invalidusage-badret.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-invalidusage-badret.flags +++ b/test/files/run/macro-invalidusage-badret.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-invalidusage-partialapplication.flags b/test/files/run/macro-invalidusage-partialapplication.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-invalidusage-partialapplication.flags +++ b/test/files/run/macro-invalidusage-partialapplication.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-openmacros.flags b/test/files/run/macro-openmacros.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-openmacros.flags +++ b/test/files/run/macro-openmacros.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-quasiinvalidbody-c.flags b/test/files/run/macro-quasiinvalidbody-c.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-quasiinvalidbody-c.flags +++ b/test/files/run/macro-quasiinvalidbody-c.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-range.flags b/test/files/run/macro-range.flags index 06a7b31f11..5e5dd6ce79 100644 --- a/test/files/run/macro-range.flags +++ b/test/files/run/macro-range.flags @@ -1 +1 @@ --Xmacros +-language:experimental.macros diff --git a/test/files/run/macro-reflective-ma-normal-mdmi.flags b/test/files/run/macro-reflective-ma-normal-mdmi.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-reflective-ma-normal-mdmi.flags +++ b/test/files/run/macro-reflective-ma-normal-mdmi.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-reflective-mamd-normal-mi.flags b/test/files/run/macro-reflective-mamd-normal-mi.flags deleted file mode 100644 index e69de29bb2..0000000000 --- a/test/files/run/macro-reflective-mamd-normal-mi.flags +++ /dev/null diff --git a/test/files/run/macro-reflective-mamd-normal-mi/Macros_Test_2.scala b/test/files/run/macro-reflective-mamd-normal-mi/Macros_Test_2.scala index 7cbe425fc8..cf34f1685d 100644 --- a/test/files/run/macro-reflective-mamd-normal-mi/Macros_Test_2.scala +++ b/test/files/run/macro-reflective-mamd-normal-mi/Macros_Test_2.scala @@ -12,5 +12,6 @@ object Test extends App { val module = ModuleDef(NoMods, newTermName("Macros"), Template(Nil, emptyValDef, List(modulector, macrodef))) val macroapp = Apply(Select(Ident("Macros"), newTermName("foo")), List(Literal(Constant(42)))) val tree = Block(macrodef, module, macroapp) - println(tree.eval) + val toolbox = mkToolBox(options = "-language:experimental.macros") + println(toolbox.runExpr(tree)) } diff --git a/test/files/run/macro-reify-basic.flags b/test/files/run/macro-reify-basic.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-reify-basic.flags +++ b/test/files/run/macro-reify-basic.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-reify-eval-eval.flags b/test/files/run/macro-reify-eval-eval.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-reify-eval-eval.flags +++ b/test/files/run/macro-reify-eval-eval.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-reify-eval-outside-reify.flags b/test/files/run/macro-reify-eval-outside-reify.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-reify-eval-outside-reify.flags +++ b/test/files/run/macro-reify-eval-outside-reify.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-reify-freevars.flags b/test/files/run/macro-reify-freevars.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-reify-freevars.flags +++ b/test/files/run/macro-reify-freevars.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-reify-nested-a.flags b/test/files/run/macro-reify-nested-a.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-reify-nested-a.flags +++ b/test/files/run/macro-reify-nested-a.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-reify-nested-b.flags b/test/files/run/macro-reify-nested-b.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-reify-nested-b.flags +++ b/test/files/run/macro-reify-nested-b.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-reify-ref-to-packageless.flags b/test/files/run/macro-reify-ref-to-packageless.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-reify-ref-to-packageless.flags +++ b/test/files/run/macro-reify-ref-to-packageless.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-reify-tagful-a.flags b/test/files/run/macro-reify-tagful-a.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-reify-tagful-a.flags +++ b/test/files/run/macro-reify-tagful-a.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-reify-tagless-a.flags b/test/files/run/macro-reify-tagless-a.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-reify-tagless-a.flags +++ b/test/files/run/macro-reify-tagless-a.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-reify-unreify.flags b/test/files/run/macro-reify-unreify.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-reify-unreify.flags +++ b/test/files/run/macro-reify-unreify.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-reify-value-outside-reify.flags b/test/files/run/macro-reify-value-outside-reify.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-reify-value-outside-reify.flags +++ b/test/files/run/macro-reify-value-outside-reify.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-repl-basic.check b/test/files/run/macro-repl-basic.check index 3bc899f49b..9e0f9aa1a2 100644 --- a/test/files/run/macro-repl-basic.check +++ b/test/files/run/macro-repl-basic.check @@ -1,51 +1,54 @@ -Type in expressions to have them evaluated.
-Type :help for more information.
-
-scala>
-
-scala> import scala.reflect.makro.{Context => Ctx}
-import scala.reflect.makro.{Context=>Ctx}
-
-scala>
-
-scala> object Impls {
- def foo(c: Ctx)(x: c.Expr[Int]) = {
- import c.mirror._
- val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1))))
- Expr[Int](body)
- }
-
- def bar(c: Ctx)(x: c.Expr[Int]) = {
- import c.mirror._
- val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(2))))
- Expr[Int](body)
- }
-
- def quux(c: Ctx)(x: c.Expr[Int]) = {
- import c.mirror._
- val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(3))))
- Expr[Int](body)
- }
-}
-defined module Impls
-
-scala> object Macros {
- object Shmacros {
- def foo(x: Int): Int = macro Impls.foo
- }
- def bar(x: Int): Int = macro Impls.bar
-}; class Macros {
- def quux(x: Int): Int = macro Impls.quux
-}
-defined module Macros
-defined class Macros
-
-scala>
-
-scala> import Macros.Shmacros._
-import Macros.Shmacros._
-
-scala> println(foo(2) + Macros.bar(2) * new Macros().quux(4))
-31
-
-scala>
+Type in expressions to have them evaluated. +Type :help for more information. + +scala> + +scala> import language.experimental.macros +import language.experimental.macros + +scala> import scala.reflect.makro.{Context => Ctx} +import scala.reflect.makro.{Context=>Ctx} + +scala> + +scala> object Impls { + def foo(c: Ctx)(x: c.Expr[Int]) = { + import c.mirror._ + val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1)))) + Expr[Int](body) + } + + def bar(c: Ctx)(x: c.Expr[Int]) = { + import c.mirror._ + val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(2)))) + Expr[Int](body) + } + + def quux(c: Ctx)(x: c.Expr[Int]) = { + import c.mirror._ + val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(3)))) + Expr[Int](body) + } +} +defined module Impls + +scala> object Macros { + object Shmacros { + def foo(x: Int): Int = macro Impls.foo + } + def bar(x: Int): Int = macro Impls.bar +}; class Macros { + def quux(x: Int): Int = macro Impls.quux +} +defined module Macros +defined class Macros + +scala> + +scala> import Macros.Shmacros._ +import Macros.Shmacros._ + +scala> println(foo(2) + Macros.bar(2) * new Macros().quux(4)) +31 + +scala> diff --git a/test/files/run/macro-repl-basic.scala b/test/files/run/macro-repl-basic.scala index a21eb7815f..e8849b4b56 100644 --- a/test/files/run/macro-repl-basic.scala +++ b/test/files/run/macro-repl-basic.scala @@ -1,8 +1,8 @@ import scala.tools.partest.ReplTest object Test extends ReplTest { - override def extraSettings = "-Xmacros" def code = """ + |import language.experimental.macros |import scala.reflect.makro.{Context => Ctx} | |object Impls { @@ -36,4 +36,4 @@ object Test extends ReplTest { |import Macros.Shmacros._ |println(foo(2) + Macros.bar(2) * new Macros().quux(4)) |""".stripMargin -}
\ No newline at end of file +} diff --git a/test/files/run/macro-repl-dontexpand.scala b/test/files/run/macro-repl-dontexpand.scala index 9889a8ffdf..cd1b2e1969 100644 --- a/test/files/run/macro-repl-dontexpand.scala +++ b/test/files/run/macro-repl-dontexpand.scala @@ -1,9 +1,9 @@ import scala.tools.partest.ReplTest object Test extends ReplTest { - override def extraSettings = "-Xmacros" + override def extraSettings = "-language:experimental.macros" def code = """ |def bar(c: scala.reflect.makro.Context) = ??? |def foo = macro bar |""".stripMargin -}
\ No newline at end of file +} diff --git a/test/files/run/macro-rettype-mismatch.flags b/test/files/run/macro-rettype-mismatch.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-rettype-mismatch.flags +++ b/test/files/run/macro-rettype-mismatch.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-settings.flags b/test/files/run/macro-settings.flags index cdc7512197..15479e30b8 100644 --- a/test/files/run/macro-settings.flags +++ b/test/files/run/macro-settings.flags @@ -1 +1 @@ --Xmacros -Xmacro-settings:hello=1
\ No newline at end of file +-language:experimental.macros -Xmacro-settings:hello=1
\ No newline at end of file diff --git a/test/files/run/macro-sip19-revised.flags b/test/files/run/macro-sip19-revised.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-sip19-revised.flags +++ b/test/files/run/macro-sip19-revised.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-sip19.flags b/test/files/run/macro-sip19.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-sip19.flags +++ b/test/files/run/macro-sip19.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-typecheck-implicitsdisabled.flags b/test/files/run/macro-typecheck-implicitsdisabled.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-typecheck-implicitsdisabled.flags +++ b/test/files/run/macro-typecheck-implicitsdisabled.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-typecheck-macrosdisabled.flags b/test/files/run/macro-typecheck-macrosdisabled.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-typecheck-macrosdisabled.flags +++ b/test/files/run/macro-typecheck-macrosdisabled.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-undetparams-consfromsls.flags b/test/files/run/macro-undetparams-consfromsls.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-undetparams-consfromsls.flags +++ b/test/files/run/macro-undetparams-consfromsls.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-undetparams-implicitval.flags b/test/files/run/macro-undetparams-implicitval.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-undetparams-implicitval.flags +++ b/test/files/run/macro-undetparams-implicitval.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-undetparams-macroitself.flags b/test/files/run/macro-undetparams-macroitself.flags index 7fea2ff901..cd66464f2f 100644 --- a/test/files/run/macro-undetparams-macroitself.flags +++ b/test/files/run/macro-undetparams-macroitself.flags @@ -1 +1 @@ --Xmacros
\ No newline at end of file +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/patmat_unapp_abstype.check b/test/files/run/patmat_unapp_abstype.check index ac28ccdb95..72239d16cd 100644 --- a/test/files/run/patmat_unapp_abstype.check +++ b/test/files/run/patmat_unapp_abstype.check @@ -1,2 +1,4 @@ TypeRef none of the above +Bar +Foo diff --git a/test/files/run/patmat_unapp_abstype.flags b/test/files/run/patmat_unapp_abstype.flags new file mode 100644 index 0000000000..ba80cad69b --- /dev/null +++ b/test/files/run/patmat_unapp_abstype.flags @@ -0,0 +1 @@ +-Xoldpatmat diff --git a/test/files/run/patmat_unapp_abstype.scala b/test/files/run/patmat_unapp_abstype.scala index e5adec5c16..45496f08a2 100644 --- a/test/files/run/patmat_unapp_abstype.scala +++ b/test/files/run/patmat_unapp_abstype.scala @@ -19,6 +19,11 @@ trait TypesUser extends TypesAPI { def shouldNotCrash(tp: Type): Unit = { tp match { case TypeRef(x) => println("TypeRef") + // the above checks tp.isInstanceOf[TypeRef], which is erased to tp.isInstanceOf[Type] + // before calling TypeRef.unapply(tp), which will then crash unless tp.isInstanceOf[TypesImpl#TypeRef] (which is not implied by tp.isInstanceOf[Type]) + // tp.isInstanceOf[TypesImpl#TypeRef] is equivalent to classOf[TypesImpl#TypeRef].isAssignableFrom(tp.getClass) + // this is equivalent to manifest + // it is NOT equivalent to manifest[Type] <:< typeRefMani case MethodType(x) => println("MethodType") case _ => println("none of the above") } @@ -32,8 +37,47 @@ trait TypesImpl extends TypesAPI { //lazy val typeRefMani = manifest[TypeRef] } -object Test extends TypesImpl with TypesUser with App { - shouldNotCrash(TypeRef(10)) // should and does print "TypeRef" - // once #1697/#2337 are fixed, this should generate the correct output - shouldNotCrash(MethodType(10)) // should print "MethodType" but prints "none of the above" -- good one, pattern matcher! -}
\ No newline at end of file +trait Foos { + trait Bar + type Foo <: Bar + trait FooExtractor { + def unapply(foo: Foo): Option[Int] + } + val Foo: FooExtractor +} + +trait RealFoos extends Foos { + class Foo(val x: Int) extends Bar + object Foo extends FooExtractor { + def unapply(foo: Foo): Option[Int] = Some(foo.x) + } +} + +trait Intermed extends Foos { + def crash(bar: Bar): Unit = + bar match { + case Foo(x) => println("Foo") + case _ => println("Bar") + } +} + +object TestUnappStaticallyKnownSynthetic extends TypesImpl with TypesUser { + def test() = { + shouldNotCrash(TypeRef(10)) // should and does print "TypeRef" + // once #1697/#2337 are fixed, this should generate the correct output + shouldNotCrash(MethodType(10)) // should print "MethodType" but prints "none of the above" -- good one, pattern matcher! + } +} + +object TestUnappDynamicSynth extends RealFoos with Intermed { + case class FooToo(n: Int) extends Bar + def test() = { + crash(FooToo(10)) + crash(new Foo(5)) + } +} + +object Test extends App { + TestUnappStaticallyKnownSynthetic.test() + TestUnappDynamicSynth.test() +} diff --git a/test/files/run/reify_fors.flags b/test/files/run/reify_fors.flags new file mode 100644 index 0000000000..ba80cad69b --- /dev/null +++ b/test/files/run/reify_fors.flags @@ -0,0 +1 @@ +-Xoldpatmat diff --git a/test/files/run/reify_maps.flags b/test/files/run/reify_maps.flags new file mode 100644 index 0000000000..ba80cad69b --- /dev/null +++ b/test/files/run/reify_maps.flags @@ -0,0 +1 @@ +-Xoldpatmat diff --git a/test/files/run/repl-parens.check b/test/files/run/repl-parens.check index 69f0a9ce30..4b7ce6b059 100644 --- a/test/files/run/repl-parens.check +++ b/test/files/run/repl-parens.check @@ -34,7 +34,7 @@ res7: (Int, Int) = (4,4) scala> (((2 + 2)), ((2 + 2)), 2) res8: (Int, Int, Int) = (4,4,2) -scala> ((((2 + 2)), ((2 + 2)), 2).productIterator ++ Iterator(3) mkString) +scala> (((((2 + 2)), ((2 + 2)), 2).productIterator ++ Iterator(3)).mkString) res9: String = 4423 scala> diff --git a/test/files/run/repl-parens.scala b/test/files/run/repl-parens.scala index c1cf9b50e1..e25933b1a2 100644 --- a/test/files/run/repl-parens.scala +++ b/test/files/run/repl-parens.scala @@ -11,7 +11,7 @@ object Test extends ReplTest { 5 ; ( (2 + 2 ) ) ; ((5)) (((2 + 2)), ((2 + 2))) (((2 + 2)), ((2 + 2)), 2) -((((2 + 2)), ((2 + 2)), 2).productIterator ++ Iterator(3) mkString) +(((((2 + 2)), ((2 + 2)), 2).productIterator ++ Iterator(3)).mkString) 55 ; ((2 + 2)) ; (1, 2, 3) 55 ; (x: Int) => x + 1 ; () => ((5)) @@ -26,4 +26,4 @@ foo(5)(10)(15)+foo(5)(10)(15) List(1) ++ List('a') """.trim -}
\ No newline at end of file +} diff --git a/test/files/run/repl-power.check b/test/files/run/repl-power.check index b811a4a8c5..e439a2a7f4 100644 --- a/test/files/run/repl-power.check +++ b/test/files/run/repl-power.check @@ -1,32 +1,33 @@ -Type in expressions to have them evaluated.
-Type :help for more information.
-
-scala> :power
-** Power User mode enabled - BEEP WHIR GYVE **
-** :phase has been set to 'typer'. **
-** scala.tools.nsc._ has been imported **
-** global._, definitions._ also imported **
-** Try :help, :vals, power.<tab> **
-
-scala> // guarding against "error: reference to global is ambiguous"
-
-scala> global.emptyValDef // "it is imported twice in the same scope by ..."
-res0: $r.global.emptyValDef.type = private val _ = _
-
-scala> val tp = ArrayClass[scala.util.Random] // magic with manifests
-tp: $r.global.Type = Array[scala.util.Random]
-
-scala> tp.memberType(Array_apply) // evidence
-res1: $r.global.Type = (i: Int)scala.util.Random
-
-scala> val m = LIT(10) MATCH (CASE(LIT(5)) ==> FALSE, DEFAULT ==> TRUE) // treedsl
-m: $r.treedsl.global.Match =
-10 match {
- case 5 => false
- case _ => true
-}
-
-scala> typed(m).tpe // typed is in scope
-res2: $r.treedsl.global.Type = Boolean
-
-scala>
+Type in expressions to have them evaluated. +Type :help for more information. + +scala> :power +** Power User mode enabled - BEEP WHIR GYVE ** +** :phase has been set to 'typer'. ** +** scala.tools.nsc._ has been imported ** +** global._, definitions._ also imported ** +** Try :help, :vals, power.<tab> ** + +scala> // guarding against "error: reference to global is ambiguous" + +scala> global.emptyValDef // "it is imported twice in the same scope by ..." +res0: $r.global.emptyValDef.type = private val _ = _ + +scala> val tp = ArrayClass[scala.util.Random] // magic with manifests +warning: there were 2 feature warnings; re-run with -feature for details +tp: $r.global.Type = Array[scala.util.Random] + +scala> tp.memberType(Array_apply) // evidence +res1: $r.global.Type = (i: Int)scala.util.Random + +scala> val m = LIT(10) MATCH (CASE(LIT(5)) ==> FALSE, DEFAULT ==> TRUE) // treedsl +m: $r.treedsl.global.Match = +10 match { + case 5 => false + case _ => true +} + +scala> typed(m).tpe // typed is in scope +res2: $r.treedsl.global.Type = Boolean + +scala> diff --git a/test/files/run/repl-suppressed-warnings.scala b/test/files/run/repl-suppressed-warnings.scala index a78b00f36e..9afbbaf1a5 100644 --- a/test/files/run/repl-suppressed-warnings.scala +++ b/test/files/run/repl-suppressed-warnings.scala @@ -1,6 +1,7 @@ import scala.tools.partest.ReplTest object Test extends ReplTest { + override def extraSettings = "-Xoldpatmat" def code = """ // "Is this thing on?" Not working on first couple diff --git a/test/files/run/t2886.check b/test/files/run/t2886.check index 5fe1e73a45..8d97a82799 100644 --- a/test/files/run/t2886.check +++ b/test/files/run/t2886.check @@ -1,5 +1,5 @@ -((x: scala.Predef.String) => { - val x$1 = x; - val x$2 = x; - Test.test(x$2, x$1) -}) +((x: String) => {
+ val x$1 = x;
+ val x$2 = x;
+ Test.this.test(x$2, x$1)
+})
diff --git a/test/files/run/t2886.scala b/test/files/run/t2886.scala new file mode 100644 index 0000000000..e0835a0a44 --- /dev/null +++ b/test/files/run/t2886.scala @@ -0,0 +1,9 @@ +import scala.reflect.mirror._ + +object Test { + def test(name: String, address: String) = null + def main(args: Array[String]) = { + val tree = reify((x:String) => test(address=x,name=x)).tree + println(tree) + } +} diff --git a/test/files/run/t4172.check b/test/files/run/t4172.check index da467e27ea..4598e02d1f 100644 --- a/test/files/run/t4172.check +++ b/test/files/run/t4172.check @@ -4,6 +4,8 @@ Type :help for more information. scala> scala> val c = { class C { override def toString = "C" }; ((new C, new C { def f = 2 })) } +warning: there were 1 feature warnings; re-run with -feature for details +warning: there were 1 feature warnings; re-run with -feature for details c: (C, C{def f: Int}) forSome { type C <: Object } = (C,C) scala> diff --git a/test/files/run/t4317/S_1.scala b/test/files/run/t4317/S_1.scala index 2de408268c..2756c879eb 100644 --- a/test/files/run/t4317/S_1.scala +++ b/test/files/run/t4317/S_1.scala @@ -1,3 +1,5 @@ +import language.existentials + object S_1 { def foo1(x: Class[_ <: AnyRef]) = 0 def foo2(x: Class[_ <: AnyRef], y: Int) = 99 diff --git a/test/files/run/t4710.check b/test/files/run/t4710.check index aa2f08d452..7c2b10b098 100644 --- a/test/files/run/t4710.check +++ b/test/files/run/t4710.check @@ -2,6 +2,7 @@ Type in expressions to have them evaluated. Type :help for more information. scala> def method : String = { implicit def f(s: Symbol) = "" ; 'symbol } +warning: there were 1 feature warnings; re-run with -feature for details method: String scala> diff --git a/test/files/run/t5273_1.flags b/test/files/run/t5273_1.flags new file mode 100644 index 0000000000..ba80cad69b --- /dev/null +++ b/test/files/run/t5273_1.flags @@ -0,0 +1 @@ +-Xoldpatmat diff --git a/test/files/run/t5273_2a.flags b/test/files/run/t5273_2a.flags new file mode 100644 index 0000000000..ba80cad69b --- /dev/null +++ b/test/files/run/t5273_2a.flags @@ -0,0 +1 @@ +-Xoldpatmat diff --git a/test/files/run/t5273_2b.flags b/test/files/run/t5273_2b.flags new file mode 100644 index 0000000000..ba80cad69b --- /dev/null +++ b/test/files/run/t5273_2b.flags @@ -0,0 +1 @@ +-Xoldpatmat diff --git a/test/files/run/virtpatmat_alts.flags b/test/files/run/virtpatmat_alts.flags index 9769db9257..3f5a3100e4 100644 --- a/test/files/run/virtpatmat_alts.flags +++ b/test/files/run/virtpatmat_alts.flags @@ -1 +1 @@ - -Yvirtpatmat -Xexperimental + -Xexperimental diff --git a/test/files/run/virtpatmat_apply.flags b/test/files/run/virtpatmat_apply.flags index 9769db9257..3f5a3100e4 100644 --- a/test/files/run/virtpatmat_apply.flags +++ b/test/files/run/virtpatmat_apply.flags @@ -1 +1 @@ - -Yvirtpatmat -Xexperimental + -Xexperimental diff --git a/test/files/run/virtpatmat_casting.flags b/test/files/run/virtpatmat_casting.flags index 9769db9257..3f5a3100e4 100644 --- a/test/files/run/virtpatmat_casting.flags +++ b/test/files/run/virtpatmat_casting.flags @@ -1 +1 @@ - -Yvirtpatmat -Xexperimental + -Xexperimental diff --git a/test/files/run/virtpatmat_extends_product.flags b/test/files/run/virtpatmat_extends_product.flags index ac6b805bd0..8b13789179 100644 --- a/test/files/run/virtpatmat_extends_product.flags +++ b/test/files/run/virtpatmat_extends_product.flags @@ -1 +1 @@ --Yvirtpatmat + diff --git a/test/files/run/virtpatmat_literal.flags b/test/files/run/virtpatmat_literal.flags index 9769db9257..3f5a3100e4 100644 --- a/test/files/run/virtpatmat_literal.flags +++ b/test/files/run/virtpatmat_literal.flags @@ -1 +1 @@ - -Yvirtpatmat -Xexperimental + -Xexperimental diff --git a/test/files/run/virtpatmat_nested_lists.flags b/test/files/run/virtpatmat_nested_lists.flags index 9769db9257..3f5a3100e4 100644 --- a/test/files/run/virtpatmat_nested_lists.flags +++ b/test/files/run/virtpatmat_nested_lists.flags @@ -1 +1 @@ - -Yvirtpatmat -Xexperimental + -Xexperimental diff --git a/test/files/run/virtpatmat_npe.flags b/test/files/run/virtpatmat_npe.flags index 9769db9257..3f5a3100e4 100644 --- a/test/files/run/virtpatmat_npe.flags +++ b/test/files/run/virtpatmat_npe.flags @@ -1 +1 @@ - -Yvirtpatmat -Xexperimental + -Xexperimental diff --git a/test/files/run/virtpatmat_opt_sharing.flags b/test/files/run/virtpatmat_opt_sharing.flags index 9769db9257..3f5a3100e4 100644 --- a/test/files/run/virtpatmat_opt_sharing.flags +++ b/test/files/run/virtpatmat_opt_sharing.flags @@ -1 +1 @@ - -Yvirtpatmat -Xexperimental + -Xexperimental diff --git a/test/files/run/virtpatmat_partial.flags b/test/files/run/virtpatmat_partial.flags index 9769db9257..3f5a3100e4 100644 --- a/test/files/run/virtpatmat_partial.flags +++ b/test/files/run/virtpatmat_partial.flags @@ -1 +1 @@ - -Yvirtpatmat -Xexperimental + -Xexperimental diff --git a/test/files/run/virtpatmat_staging.flags b/test/files/run/virtpatmat_staging.flags index 9769db9257..3f5a3100e4 100644 --- a/test/files/run/virtpatmat_staging.flags +++ b/test/files/run/virtpatmat_staging.flags @@ -1 +1 @@ - -Yvirtpatmat -Xexperimental + -Xexperimental diff --git a/test/files/run/virtpatmat_stringinterp.check b/test/files/run/virtpatmat_stringinterp.check new file mode 100644 index 0000000000..7927f4f2d9 --- /dev/null +++ b/test/files/run/virtpatmat_stringinterp.check @@ -0,0 +1 @@ +Node(1) diff --git a/test/files/run/virtpatmat_stringinterp.flags b/test/files/run/virtpatmat_stringinterp.flags new file mode 100644 index 0000000000..e1b37447c9 --- /dev/null +++ b/test/files/run/virtpatmat_stringinterp.flags @@ -0,0 +1 @@ +-Xexperimental
\ No newline at end of file diff --git a/test/files/run/virtpatmat_stringinterp.scala b/test/files/run/virtpatmat_stringinterp.scala new file mode 100644 index 0000000000..213712f17a --- /dev/null +++ b/test/files/run/virtpatmat_stringinterp.scala @@ -0,0 +1,13 @@ +object Test extends App { + case class Node(x: Int) + + implicit def sc2xml(sc: StringContext): XMLContext = new XMLContext(sc) + class XMLContext(sc: StringContext) { + object xml { + def unapplySeq(xml: Node): Option[Seq[Node]] = Some(List(Node(1))) + } + } + + val x: Node = Node(0) + x match { case xml"""<foo arg=$a/>""" => println(a) } +}
\ No newline at end of file diff --git a/test/files/run/virtpatmat_switch.flags b/test/files/run/virtpatmat_switch.flags index 9769db9257..3f5a3100e4 100644 --- a/test/files/run/virtpatmat_switch.flags +++ b/test/files/run/virtpatmat_switch.flags @@ -1 +1 @@ - -Yvirtpatmat -Xexperimental + -Xexperimental diff --git a/test/files/run/virtpatmat_tailcalls_verifyerror.flags b/test/files/run/virtpatmat_tailcalls_verifyerror.flags index 9769db9257..3f5a3100e4 100644 --- a/test/files/run/virtpatmat_tailcalls_verifyerror.flags +++ b/test/files/run/virtpatmat_tailcalls_verifyerror.flags @@ -1 +1 @@ - -Yvirtpatmat -Xexperimental + -Xexperimental diff --git a/test/files/run/virtpatmat_try.flags b/test/files/run/virtpatmat_try.flags index 9769db9257..3f5a3100e4 100644 --- a/test/files/run/virtpatmat_try.flags +++ b/test/files/run/virtpatmat_try.flags @@ -1 +1 @@ - -Yvirtpatmat -Xexperimental + -Xexperimental diff --git a/test/files/run/virtpatmat_typed.flags b/test/files/run/virtpatmat_typed.flags index 9769db9257..3f5a3100e4 100644 --- a/test/files/run/virtpatmat_typed.flags +++ b/test/files/run/virtpatmat_typed.flags @@ -1 +1 @@ - -Yvirtpatmat -Xexperimental + -Xexperimental diff --git a/test/files/run/virtpatmat_unapply.flags b/test/files/run/virtpatmat_unapply.flags index 9769db9257..3f5a3100e4 100644 --- a/test/files/run/virtpatmat_unapply.flags +++ b/test/files/run/virtpatmat_unapply.flags @@ -1 +1 @@ - -Yvirtpatmat -Xexperimental + -Xexperimental diff --git a/test/files/run/virtpatmat_unapplyprod.flags b/test/files/run/virtpatmat_unapplyprod.flags index 9769db9257..3f5a3100e4 100644 --- a/test/files/run/virtpatmat_unapplyprod.flags +++ b/test/files/run/virtpatmat_unapplyprod.flags @@ -1 +1 @@ - -Yvirtpatmat -Xexperimental + -Xexperimental diff --git a/test/files/run/virtpatmat_unapplyseq.flags b/test/files/run/virtpatmat_unapplyseq.flags index 9769db9257..3f5a3100e4 100644 --- a/test/files/run/virtpatmat_unapplyseq.flags +++ b/test/files/run/virtpatmat_unapplyseq.flags @@ -1 +1 @@ - -Yvirtpatmat -Xexperimental + -Xexperimental diff --git a/test/files/specialized/spec-patmatch.check b/test/files/specialized/spec-patmatch.check index 33306ab5d9..a2746c0f48 100644 --- a/test/files/specialized/spec-patmatch.check +++ b/test/files/specialized/spec-patmatch.check @@ -17,4 +17,4 @@ long double float default -2
\ No newline at end of file +10 diff --git a/test/scaladoc/resources/implicits-base-res.scala b/test/scaladoc/resources/implicits-base-res.scala index db7ca4fa51..3e3d0f01a6 100644 --- a/test/scaladoc/resources/implicits-base-res.scala +++ b/test/scaladoc/resources/implicits-base-res.scala @@ -11,23 +11,27 @@ trait MyNumeric[R] * - tests the complete type inference * - the following inherited methods should appear: * {{{ - * def convToGtColonDoubleA: Double // pimpA3: with a constraint that T <: Double - * def convToIntA: Int // pimpA2: with a constraint that T = Int - * def convToManifestA: T // pimpA7: with 2 constraints: T: Manifest and T <: Double - * def convToMyNumericA: T // pimpA6: with a constraint that there is x: MyNumeric[T] implicit in scope - * def convToNumericA: T // pimpA1: with a constraint that there is x: Numeric[T] implicit in scope - * def convToPimpedA: Bar[Foo[T]] // pimpA5: no constraints - * def convToPimpedA: S // pimpA4: with 3 constraints: T = Foo[Bar[S]], S: Foo and S: Bar - * def convToTraversableOps: T // pimpA7: with 2 constraints: T: Manifest and T <: Double - * // should not be abstract! + * def convToGtColonDoubleA(x: Double) // pimpA3: with a constraint that T <: Double + * def convToIntA(x: Int) // pimpA2: with a constraint that T = Int + * def convToManifestA(x: T) // pimpA7: with 2 constraints: T: Manifest and T <: Double + * def convToMyNumericA(x: T) // pimpA6: with a constraint that there is x: MyNumeric[T] implicit in scope + * def convToNumericA(x: T) // pimpA1: with a constraint that there is x: Numeric[T] implicit in scope + * def convToPimpedA(x: Bar[Foo[T]]) // pimpA5: no constraints + * def convToPimpedA(x: S) // pimpA4: with 3 constraints: T = Foo[Bar[S]], S: Foo and S: Bar + * def convToTraversableOps(x: T) // pimpA7: with 2 constraints: T: Manifest and T <: Double + * // should not be abstract! * }}} */ class A[T] { /** This should prevent the implicitly inherited `def convToPimpedA: T` from `pimpA0` from showing up */ - def convToPimpedA: T = sys.error("Let's check it out!") + def convToPimpedA(x: T): T = sys.error("Let's check it out!") + /** This should check implicit member elimination in the case of subtyping */ + def foo(a: T, b: AnyRef): T } /** Companion object with implicit transformations */ object A { + import language.implicitConversions // according to SIP18 + implicit def pimpA0[V](a: A[V]) = new PimpedA(a) implicit def pimpA1[ZBUR: Numeric](a: A[ZBUR]) = new NumericA[ZBUR](a) implicit def pimpA2(a: A[Int]) = new IntA(a) @@ -36,7 +40,7 @@ object A { implicit def pimpA5[Z](a: A[Z]): PimpedA[Bar[Foo[Z]]] = sys.error("not implemented") implicit def pimpA6[Z: MyNumeric](a: A[Z]) = new MyNumericA[Z](a) // TODO: Add H <: Double and see why it crashes for C and D -- context bounds, need to check! - implicit def pimpA7[H <: Double : Manifest](a: A[H]) = new ManifestA[H](a) with MyTraversableOps[H] { def convToTraversableOps: H = sys.error("no") } + implicit def pimpA7[H <: Double : Manifest](a: A[H]) = new ManifestA[H](a) with MyTraversableOps[H] { def convToTraversableOps(x: H): H = sys.error("no") } } @@ -44,13 +48,13 @@ object A { * - tests the existential type solving * - the following inherited methods should appear: * {{{ - * def convToGtColonDoubleA: Double // pimpA3: no constraints - * def convToManifestA: Double // pimpA7: no constraints - * def convToMyNumericA: Double // pimpA6: (if showAll is set) with a constraint that there is x: MyNumeric[Double] implicit in scope - * def convToNumericA: Double // pimpA1: no constraintsd - * def convToPimpedA: Bar[Foo[Double]] // pimpA5: no constraints - * def convToTraversableOps: Double // pimpA7: no constraints - * // should not be abstract! + * def convToGtColonDoubleA(x: Double) // pimpA3: no constraints + * def convToManifestA(x: Double) // pimpA7: no constraints + * def convToMyNumericA(x: Double) // pimpA6: (if showAll is set) with a constraint that there is x: MyNumeric[Double] implicit in scope + * def convToNumericA(x: Double) // pimpA1: no constraintsd + * def convToPimpedA(x: Bar[Foo[Double]]) // pimpA5: no constraints + * def convToTraversableOps(x: Double) // pimpA7: no constraints + * // should not be abstract! * }}} */ class B extends A[Double] @@ -61,10 +65,10 @@ object B extends A * - tests asSeenFrom * - the following inherited methods should appear: * {{{ - * def convToIntA: Int // pimpA2: no constraints - * def convToMyNumericA: Int // pimpA6: (if showAll is set) with a constraint that there is x: MyNumeric[Int] implicit in scope - * def convToNumericA: Int // pimpA1: no constraints - * def convToPimpedA: Bar[Foo[Int]] // pimpA5: no constraints + * def convToIntA(x: Int) // pimpA2: no constraints + * def convToMyNumericA(x: Int) // pimpA6: (if showAll is set) with a constraint that there is x: MyNumeric[Int] implicit in scope + * def convToNumericA(x: Int) // pimpA1: no constraints + * def convToPimpedA(x: Bar[Foo[Int]]) // pimpA5: no constraints * }}} */ class C extends A[Int] @@ -75,9 +79,9 @@ object C extends A * - tests implicit elimination * - the following inherited methods should appear: * {{{ - * def convToMyNumericA: String // pimpA6: (if showAll is set) with a constraint that there is x: MyNumeric[String] implicit in scope - * def convToNumericA: String // pimpA1: (if showAll is set) with a constraint that there is x: Numeric[String] implicit in scope - * def convToPimpedA: Bar[Foo[String]] // pimpA5: no constraints + * def convToMyNumericA(x: String) // pimpA6: (if showAll is set) with a constraint that there is x: MyNumeric[String] implicit in scope + * def convToNumericA(x: String) // pimpA1: (if showAll is set) with a constraint that there is x: Numeric[String] implicit in scope + * def convToPimpedA(x: Bar[Foo[String]]) // pimpA5: no constraints * }}} */ class D extends A[String] @@ -90,7 +94,7 @@ object D extends A * - A, B and C should be implicitly converted to this */ class PimpedA[V](a: A[V]) { /** The convToPimpedA: V documentation... */ - def convToPimpedA: V = sys.error("Not implemented") + def convToPimpedA(x: V): V = sys.error("Not implemented") } /** NumericA class <br/> @@ -98,7 +102,7 @@ class PimpedA[V](a: A[V]) { * - A, B and C should be implicitly converted to this */ class NumericA[U: Numeric](a: A[U]) { /** The convToNumericA: U documentation... */ - def convToNumericA: U = implicitly[Numeric[U]].zero + def convToNumericA(x: U): U = implicitly[Numeric[U]].zero } /** IntA class <br/> @@ -106,7 +110,7 @@ class NumericA[U: Numeric](a: A[U]) { * - A and C should be implicitly converted to this */ class IntA(a: A[Int]) { /** The convToIntA: Int documentation... */ - def convToIntA: Int = 0 + def convToIntA(x: Int): Int = 0 } /** GtColonDoubleA class <br/> @@ -114,7 +118,7 @@ class IntA(a: A[Int]) { * - A and B should be implicitly converted to this */ class GtColonDoubleA(a: A[T] forSome { type T <: Double }) { /** The convToGtColonDoubleA: Double documentation... */ - def convToGtColonDoubleA: Double = 0 + def convToGtColonDoubleA(x: Double): Double = 0 } /** MyNumericA class <br/> @@ -122,7 +126,7 @@ class GtColonDoubleA(a: A[T] forSome { type T <: Double }) { * - A should be implicitly converted to this */ class MyNumericA[U: MyNumeric](a: A[U]) { /** The convToMyNumericA: U documentation... */ - def convToMyNumericA: U = sys.error("dunno") + def convToMyNumericA(x: U): U = sys.error("dunno") } /** ManifestA class <br/> @@ -130,7 +134,7 @@ class MyNumericA[U: MyNumeric](a: A[U]) { * - A, B, C, D should be implicitly converted to this */ class ManifestA[W: Manifest](a: A[W]) { /** The convToManifestA: W documentation... */ - def convToManifestA: W = sys.error("dunno") + def convToManifestA(x: W): W = sys.error("dunno") } /** MyTraversableOps class <br/> @@ -138,6 +142,6 @@ class ManifestA[W: Manifest](a: A[W]) { */ trait MyTraversableOps[S] { /** The convToTraversableOps: S documentation... */ - def convToTraversableOps: S + def convToTraversableOps(x: S): S } diff --git a/test/scaladoc/resources/implicits-chaining-res.scala b/test/scaladoc/resources/implicits-chaining-res.scala index b20c8f846c..c005d5fe09 100644 --- a/test/scaladoc/resources/implicits-chaining-res.scala +++ b/test/scaladoc/resources/implicits-chaining-res.scala @@ -3,6 +3,8 @@ */ package scala.test.scaladoc.implicits { + import language.implicitConversions // according to SIP18 + // the classes involved case class Z[U](a: U) case class Intermediate[T, U](t: T, u: U) diff --git a/test/scaladoc/resources/implicits-elimination-res.scala b/test/scaladoc/resources/implicits-elimination-res.scala index 68743aee06..b23667440c 100644 --- a/test/scaladoc/resources/implicits-elimination-res.scala +++ b/test/scaladoc/resources/implicits-elimination-res.scala @@ -2,8 +2,13 @@ * Testing scaladoc implicits elimination */ package scala.test.scaladoc.implicits.elimination { + + import language.implicitConversions // according to SIP18 + /** No conversion, as B doesn't bring any member */ class A class B { class C; trait V; type T; } - object A { implicit def toB(a: A): B = null } + object A { + implicit def toB(a: A): B = null + } } diff --git a/test/scaladoc/resources/implicits-scopes-res.scala b/test/scaladoc/resources/implicits-scopes-res.scala index 4e55c3e388..aaeb43f95b 100644 --- a/test/scaladoc/resources/implicits-scopes-res.scala +++ b/test/scaladoc/resources/implicits-scopes-res.scala @@ -2,6 +2,7 @@ * Testing scaladoc implicit scopes - looking for implicits in the right places */ package scala.test.scaladoc.implicits.scopes +import language.implicitConversions // according to SIP18 // TEST1 - In package object package object test1 { diff --git a/test/scaladoc/resources/implicits-shadowing-res.scala b/test/scaladoc/resources/implicits-shadowing-res.scala new file mode 100644 index 0000000000..c5e9493bf3 --- /dev/null +++ b/test/scaladoc/resources/implicits-shadowing-res.scala @@ -0,0 +1,64 @@ +/** + * Test scaladoc implicits distinguishing -- supress all members by implicit conversion that are shadowed by the + * class' own members + * + * {{{ + * scala> class A { def foo(t: String) = 4 } + * defined class A + * + * scala> class B { def foo(t: Any) = 5 } + * defined class B + * + * scala> implicit def AtoB(a:A) = new B + * AtoB: (a: A)B + * + * scala> val a = new A + * a: A = A@28f553e3 + * + * scala> a.foo("T") + * res1: Int = 4 + * + * scala> a.foo(4) + * res2: Int = 5 + * }}} + */ +package scala.test.scaladoc.implicits.shadowing +import language.implicitConversions // according to SIP18 + +/** conv5, conv8, conv9, conv10, conv11 should be visible */ +class A[T] { + def conv1: AnyRef = ??? + def conv2: T = ??? + def conv3(l: Int): AnyRef = ??? + def conv4(l: AnyRef): AnyRef = ??? + def conv5(l: String): AnyRef = ??? + def conv6(l: AnyRef): AnyRef = ??? + def conv7(l: AnyRef): String = ??? + def conv8(l: String)(m: String): AnyRef = ??? + def conv9(l: AnyRef)(m: AnyRef): AnyRef = ??? + def conv10(l: T): T = ??? + def conv11(l: T): T = ??? +} +/** conv5, conv8, conv9, conv11 should be visible */ +class B extends A[Int] +/** conv5, conv8, conv9, conv10, conv11 should be visible */ +class C extends A[Double] +/** conv5, conv8, conv9, conv10 should be visible */ +class D extends A[AnyRef] + +class Z[T] { + def conv1: AnyRef = ??? + def conv2: T = ??? + def conv3(p: Int): AnyRef = ??? + def conv4(p: String): AnyRef = ??? + def conv5(p: AnyRef): AnyRef = ??? + def conv6(p: AnyRef): String = ??? + def conv7(p: AnyRef): AnyRef = ??? + def conv8(p: String, q: String): AnyRef = ??? + def conv9(p: AnyRef, q: AnyRef): AnyRef = ??? + def conv10(p: Int): T = ??? + def conv11(p: String): T = ??? +} +object A { + implicit def AtoZ[T](a: A[T]) = new Z[T] +} diff --git a/test/scaladoc/run/implicits-base.scala b/test/scaladoc/run/implicits-base.scala index a0dd2071d7..06d017ed70 100644 --- a/test/scaladoc/run/implicits-base.scala +++ b/test/scaladoc/run/implicits-base.scala @@ -1,5 +1,6 @@ import scala.tools.nsc.doc.model._ import scala.tools.partest.ScaladocModelTest +import language._ object Test extends ScaladocModelTest { @@ -176,4 +177,4 @@ object Test extends ScaladocModelTest { assert(conv.constraints.length == 1) assert(conv._member("convToMyNumericA").resultType.name == "String") } -}
\ No newline at end of file +} diff --git a/test/scaladoc/run/implicits-chaining.scala b/test/scaladoc/run/implicits-chaining.scala index 96e288b204..858ca9ce61 100644 --- a/test/scaladoc/run/implicits-chaining.scala +++ b/test/scaladoc/run/implicits-chaining.scala @@ -1,5 +1,6 @@ import scala.tools.nsc.doc.model._ import scala.tools.partest.ScaladocModelTest +import language._ object Test extends ScaladocModelTest { @@ -61,4 +62,4 @@ object Test extends ScaladocModelTest { assert(F._conversions(base.qualifiedName + ".convertToZ").isEmpty) } -}
\ No newline at end of file +} diff --git a/test/scaladoc/run/implicits-elimination.scala b/test/scaladoc/run/implicits-elimination.scala index 71319f9f47..ed37b9cd90 100644 --- a/test/scaladoc/run/implicits-elimination.scala +++ b/test/scaladoc/run/implicits-elimination.scala @@ -1,5 +1,6 @@ import scala.tools.nsc.doc.model._ import scala.tools.partest.ScaladocModelTest +import language._ object Test extends ScaladocModelTest { @@ -19,4 +20,4 @@ object Test extends ScaladocModelTest { assert(A._conversions(A.qualifiedName + ".toB").isEmpty) } -}
\ No newline at end of file +} diff --git a/test/scaladoc/run/implicits-scopes.scala b/test/scaladoc/run/implicits-scopes.scala index 7fb41e1ae8..7b9e80e148 100644 --- a/test/scaladoc/run/implicits-scopes.scala +++ b/test/scaladoc/run/implicits-scopes.scala @@ -1,5 +1,6 @@ import scala.tools.nsc.doc.model._ import scala.tools.partest.ScaladocModelTest +import language._ object Test extends ScaladocModelTest { @@ -73,4 +74,4 @@ object Test extends ScaladocModelTest { assert(conv.constraints.length == 0) } } -}
\ No newline at end of file +} diff --git a/test/scaladoc/run/implicits-shadowing.check b/test/scaladoc/run/implicits-shadowing.check new file mode 100644 index 0000000000..619c56180b --- /dev/null +++ b/test/scaladoc/run/implicits-shadowing.check @@ -0,0 +1 @@ +Done. diff --git a/test/scaladoc/run/implicits-shadowing.scala b/test/scaladoc/run/implicits-shadowing.scala new file mode 100644 index 0000000000..7835223d21 --- /dev/null +++ b/test/scaladoc/run/implicits-shadowing.scala @@ -0,0 +1,70 @@ +import scala.tools.nsc.doc.model._ +import scala.tools.partest.ScaladocModelTest + +object Test extends ScaladocModelTest { + + // test a file instead of a piece of code + override def resourceFile = "implicits-shadowing-res.scala" + + // start implicits + def scaladocSettings = "-implicits" + + def testModel(root: Package) = { + // get the quick access implicit defs in scope (_package(s), _class(es), _trait(s), object(s) _method(s), _value(s)) + import access._ + + // SEE THE test/resources/implicits-chaining-res.scala FOR THE EXPLANATION OF WHAT'S CHECKED HERE: + val base = root._package("scala")._package("test")._package("scaladoc")._package("implicits")._object("shadowing") + var conv: ImplicitConversion = null + +//// class A /////////////////////////////////////////////////////////////////////////////////////////////////////////// + + val A = base._class("A") + + conv = A._conversion(base._object("A").qualifiedName + ".AtoZ") + assert(conv.members.length == 5) + conv._member("conv5") + conv._member("conv8") + conv._member("conv9") + conv._member("conv10") + conv._member("conv11") + assert(conv.constraints.length == 0) + +//// class B /////////////////////////////////////////////////////////////////////////////////////////////////////////// + + val B = base._class("B") + + conv = B._conversion(base._object("A").qualifiedName + ".AtoZ") + assert(conv.members.length == 4) + conv._member("conv5") + conv._member("conv8") + conv._member("conv9") + conv._member("conv11") + assert(conv.constraints.length == 0) + +//// class C /////////////////////////////////////////////////////////////////////////////////////////////////////////// + + val C = base._class("C") + + conv = C._conversion(base._object("A").qualifiedName + ".AtoZ") + assert(conv.members.length == 5) + conv._member("conv5") + conv._member("conv8") + conv._member("conv9") + conv._member("conv10") + conv._member("conv11") + assert(conv.constraints.length == 0) + +//// class D /////////////////////////////////////////////////////////////////////////////////////////////////////////// + + val D = base._class("D") + + conv = D._conversion(base._object("A").qualifiedName + ".AtoZ") + assert(conv.members.length == 4) + conv._member("conv5") + conv._member("conv8") + conv._member("conv9") + conv._member("conv10") + assert(conv.constraints.length == 0) + } +}
\ No newline at end of file |