diff options
Diffstat (limited to 'src')
10 files changed, 72 insertions, 70 deletions
diff --git a/src/compiler/scala/tools/nsc/doc/Settings.scala b/src/compiler/scala/tools/nsc/doc/Settings.scala index 02630a99b2..8c0628c073 100644 --- a/src/compiler/scala/tools/nsc/doc/Settings.scala +++ b/src/compiler/scala/tools/nsc/doc/Settings.scala @@ -249,10 +249,7 @@ class Settings(error: String => Unit, val printMsg: String => Unit = println(_)) } } - def appendIndex(url: String): String = { - val index = "/index.html" - if (url.endsWith(index)) url else url + index - } + def appendIndex(url: String): String = url.stripSuffix("index.html").stripSuffix("/") + "/index.html" // Deprecated together with 'docExternalUrls' option. lazy val extUrlPackageMapping: Map[String, String] = (Map.empty[String, String] /: docExternalUrls.value) { diff --git a/src/compiler/scala/tools/nsc/doc/html/resource/lib/index.js b/src/compiler/scala/tools/nsc/doc/html/resource/lib/index.js index 70073b272a..96689ae701 100644 --- a/src/compiler/scala/tools/nsc/doc/html/resource/lib/index.js +++ b/src/compiler/scala/tools/nsc/doc/html/resource/lib/index.js @@ -14,9 +14,9 @@ var title = $(document).attr('title'); var lastHash = ""; $(document).ready(function() { - $('body').layout({ + $('body').layout({ west__size: '20%', - center__maskContents: true + center__maskContents: true }); $('#browser').layout({ center__paneSelector: ".ui-west-center" @@ -342,11 +342,6 @@ function configureTextFilter() { if (event.keyCode == 27) { // escape input.attr("value", ""); } - if (event.keyCode == 9) { // tab - $("#template").contents().find("#mbrsel-input").focus(); - input.attr("value", ""); - return false; - } if (event.keyCode == 40) { // down arrow $(window).unbind("keydown"); keyboardScrolldownLeftPane(); @@ -354,6 +349,14 @@ function configureTextFilter() { } textFilter(); }); + input.bind('keydown', function(event) { + if (event.keyCode == 9) { // tab + $("#template").contents().find("#mbrsel-input").focus(); + input.attr("value", ""); + return false; + } + textFilter(); + }); input.focus(function(event) { input.select(); }); }); scheduler.add("init", function() { diff --git a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala index e0dbe98780..b9cff5b2d3 100644 --- a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala +++ b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala @@ -1307,6 +1307,11 @@ trait ContextErrors { throw MacroBodyTypecheckException // don't call fail, because we don't need IS_ERROR } + def MacroDefIsQmarkQmarkQmark() = { + macroLogVerbose("typecheck terminated unexpectedly: macro is ???") + throw MacroBodyTypecheckException + } + def MacroFeatureNotEnabled() = { macroLogVerbose("typecheck terminated unexpectedly: language.experimental.macros feature is not enabled") fail() diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala index 193e589470..ef87a32c1d 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala @@ -996,12 +996,15 @@ trait Implicits { if (divergence || DivergentImplicitRecovery.sym != null) { if (settings.Xdivergence211.value) DivergingImplicitExpansionError(tree, pt, DivergentImplicitRecovery.sym)(context) else throw DivergentImplicit - } else invalidImplicits take 1 foreach { sym => - def isSensibleAddendum = pt match { + } + else if (invalidImplicits.nonEmpty) { + val sym = invalidImplicits.head + // We don't even dare look if errors are being buffered + // !sym.hasFlag(LOCKED) is a hail mary between SI-2206 and SI-7486 + def isSensibleAddendum = !sym.hasFlag(LOCKED) && (pt match { case Function1(_, out) => out <:< sym.tpe.finalResultType - case tp => tp <:< sym.tpe.finalResultType - case _ => false - } + case _ => pt <:< sym.tpe.finalResultType + }) // Don't pitch in with this theory unless it looks plausible that the // implicit would have helped setAddendum(pos, () => diff --git a/src/compiler/scala/tools/nsc/typechecker/Macros.scala b/src/compiler/scala/tools/nsc/typechecker/Macros.scala index 5ad568b1e6..816f977890 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Macros.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Macros.scala @@ -412,6 +412,9 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces { // Phase II: typecheck the right-hand side of the macro def val typed = typecheckRhs(macroDdef.rhs) typed match { + case MacroImplReference(_, meth, _) if meth == Predef_??? => + bindMacroImpl(macroDef, typed) + MacroDefIsQmarkQmarkQmark() case MacroImplReference(owner, meth, targs) => if (!meth.isMethod) MacroDefInvalidBodyError() if (!meth.isPublic) MacroImplNotPublicError() @@ -521,26 +524,30 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces { val methName = binding.methName macroLogVerbose(s"resolved implementation as $className.$methName") - // I don't use Scala reflection here, because it seems to interfere with JIT magic - // whenever you instantiate a mirror (and not do anything with in, just instantiate), performance drops by 15-20% - // I'm not sure what's the reason - for me it's pure voodoo - // upd. my latest experiments show that everything's okay - // it seems that in 2.10.1 we can easily switch to Scala reflection - try { - macroLogVerbose(s"loading implementation class: $className") - macroLogVerbose(s"classloader is: ${ReflectionUtils.show(macroClassloader)}") - val implObj = ReflectionUtils.staticSingletonInstance(macroClassloader, className) - // relies on the fact that macro impls cannot be overloaded - // so every methName can resolve to at maximum one method - val implMeths = implObj.getClass.getDeclaredMethods.find(_.getName == methName) - val implMeth = implMeths getOrElse { throw new NoSuchMethodException(s"$className.$methName") } - macroLogVerbose(s"successfully loaded macro impl as ($implObj, $implMeth)") - args => implMeth.invoke(implObj, ((args.c +: args.others) map (_.asInstanceOf[AnyRef])): _*) - } catch { - case ex: Exception => - macroLogVerbose(s"macro runtime failed to load: ${ex.toString}") - macroDef setFlag IS_ERROR - null + if (binding.className == Predef_???.owner.fullName.toString && binding.methName == Predef_???.name.encoded) { + args => throw new AbortMacroException(args.c.enclosingPosition, "macro implementation is missing") + } else { + // I don't use Scala reflection here, because it seems to interfere with JIT magic + // whenever you instantiate a mirror (and not do anything with in, just instantiate), performance drops by 15-20% + // I'm not sure what's the reason - for me it's pure voodoo + // upd. my latest experiments show that everything's okay + // it seems that in 2.10.1 we can easily switch to Scala reflection + try { + macroLogVerbose(s"loading implementation class: $className") + macroLogVerbose(s"classloader is: ${ReflectionUtils.show(macroClassloader)}") + val implObj = ReflectionUtils.staticSingletonInstance(macroClassloader, className) + // relies on the fact that macro impls cannot be overloaded + // so every methName can resolve to at maximum one method + val implMeths = implObj.getClass.getDeclaredMethods.find(_.getName == methName) + val implMeth = implMeths getOrElse { throw new NoSuchMethodException(s"$className.$methName") } + macroLogVerbose(s"successfully loaded macro impl as ($implObj, $implMeth)") + args => implMeth.invoke(implObj, ((args.c +: args.others) map (_.asInstanceOf[AnyRef])): _*) + } catch { + case ex: Exception => + macroLogVerbose(s"macro runtime failed to load: ${ex.toString}") + macroDef setFlag IS_ERROR + null + } } }) } diff --git a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala index fa72ad64bf..bad49385aa 100644 --- a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala +++ b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala @@ -80,32 +80,11 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT private def transformArgs(params: List[Symbol], args: List[Tree]) = { treeInfo.mapMethodParamsAndArgs(params, args) { (param, arg) => if (isByNameParamType(param.tpe)) - withInvalidOwner { checkPackedConforms(transform(arg), param.tpe.typeArgs.head) } + withInvalidOwner(transform(arg)) else transform(arg) } } - private def checkPackedConforms(tree: Tree, pt: Type): Tree = { - def typeError(typer: analyzer.Typer, pos: Position, found: Type, req: Type) { - if (!found.isErroneous && !req.isErroneous) { - val msg = analyzer.ErrorUtils.typeErrorMsg(found, req, typer.infer.isPossiblyMissingArgs(found, req)) - typer.context.error(pos, analyzer.withAddendum(pos)(msg)) - if (settings.explaintypes.value) - explainTypes(found, req) - } - } - - if (tree.tpe exists (_.typeSymbol.isExistentialSkolem)) { - val packed = localTyper.packedType(tree, NoSymbol) - if (!(packed <:< pt)) { - val errorContext = localTyper.context.make(localTyper.context.tree) - errorContext.setReportErrors() - typeError(analyzer.newTyper(errorContext), tree.pos, packed, pt) - } - } - tree - } - /** Check that a class and its companion object to not both define * a class or module with same name */ diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index b89b570cd8..c59ef4ebda 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -5792,7 +5792,7 @@ trait Typers extends Modes with Adaptations with Tags { tree1 } - val isMacroBodyOkay = !tree.symbol.isErroneous && !(tree1 exists (_.isErroneous)) + val isMacroBodyOkay = !tree.symbol.isErroneous && !(tree1 exists (_.isErroneous)) && tree1 != EmptyTree val shouldInheritMacroImplReturnType = ddef.tpt.isEmpty if (isMacroBodyOkay && shouldInheritMacroImplReturnType) computeMacroDefTypeFromMacroImpl(ddef, tree1.symbol) else AnyClass.tpe } diff --git a/src/library/scala/concurrent/impl/Future.scala b/src/library/scala/concurrent/impl/Future.scala index 8c2a77c75f..89d10e5c47 100644 --- a/src/library/scala/concurrent/impl/Future.scala +++ b/src/library/scala/concurrent/impl/Future.scala @@ -28,7 +28,7 @@ private[concurrent] object Future { def apply[T](body: =>T)(implicit executor: ExecutionContext): scala.concurrent.Future[T] = { val runnable = new PromiseCompletingRunnable(body) - executor.execute(runnable) + executor.prepare.execute(runnable) runnable.promise.future } } diff --git a/src/reflect/scala/reflect/api/Mirrors.scala b/src/reflect/scala/reflect/api/Mirrors.scala index d0d8a37584..76a75940ff 100644 --- a/src/reflect/scala/reflect/api/Mirrors.scala +++ b/src/reflect/scala/reflect/api/Mirrors.scala @@ -133,9 +133,7 @@ package api * scala> fmX.get * res0: Any = 2 * - * scala> fmX.set(3) - * scala.ScalaReflectionException: cannot set an immutable field x - * ... + * scala> fmX.set(3) // NOTE: can set an underlying value of an immutable field! * * scala> val fieldY = typeOf[C].declaration(newTermName("y")).asTerm.accessed.asTerm * fieldY: reflect.runtime.universe.TermSymbol = variable y diff --git a/src/reflect/scala/reflect/runtime/JavaMirrors.scala b/src/reflect/scala/reflect/runtime/JavaMirrors.scala index 3442e3d22e..ccc727451c 100644 --- a/src/reflect/scala/reflect/runtime/JavaMirrors.scala +++ b/src/reflect/scala/reflect/runtime/JavaMirrors.scala @@ -133,6 +133,7 @@ private[reflect] trait JavaMirrors extends internal.SymbolTable with api.JavaUni sm"""Scala field ${sym.name} isn't represented as a Java field, neither it has a Java accessor method |note that private parameters of class constructors don't get mapped onto fields and/or accessors, |unless they are used outside of their declaring constructors.""") + @deprecated("corresponding check has been removed from FieldMirror.set, this method is also being phased out", "2.11.0") private def ErrorSetImmutableField(sym: Symbol) = throw new ScalaReflectionException(s"cannot set an immutable field ${sym.name}") private def ErrorNotConstructor(sym: Symbol, owner: Symbol) = throw new ScalaReflectionException(s"expected a constructor of $owner, you provided $sym") private def ErrorFree(member: Symbol, freeType: Symbol) = throw new ScalaReflectionException(s"cannot reflect ${member.kindString} ${member.name}, because it's a member of a weak type ${freeType.name}") @@ -282,9 +283,13 @@ private[reflect] trait JavaMirrors extends internal.SymbolTable with api.JavaUni } def get = jfield.get(receiver) def set(value: Any) = { - if (!symbol.isMutable) ErrorSetImmutableField(symbol) + // it appears useful to be able to set values of vals, therefore I'm disabling this check + // if (!symbol.isMutable) ErrorSetImmutableField(symbol) jfield.set(receiver, value) } + // this dummy method is necessary to prevent the optimizer from stripping off ErrorSetImmutableField + // which would break binary compatibility with 2.10.0 + private def dummy(symbol: Symbol) = ErrorSetImmutableField(symbol) override def toString = s"field mirror for ${symbol.fullName} (bound to $receiver)" } @@ -687,7 +692,8 @@ private[reflect] trait JavaMirrors extends internal.SymbolTable with api.JavaUni (if (jModifier.isStatic(mods)) module.moduleClass else clazz).info.decls enter sym for (jinner <- jclazz.getDeclaredClasses) { - enter(jclassAsScala(jinner, clazz), jinner.getModifiers) + jclassAsScala(jinner) // inner class is entered as a side-effect + // no need to call enter explicitly } pendingLoadActions = { () => @@ -1046,13 +1052,17 @@ private[reflect] trait JavaMirrors extends internal.SymbolTable with api.JavaUni * @param jclazz The Java class * @return A Scala class symbol that wraps all reflection info of `jclazz` */ - private def jclassAsScala(jclazz: jClass[_]): Symbol = jclassAsScala(jclazz, sOwner(jclazz)) + private def jclassAsScala(jclazz: jClass[_]): Symbol = { + val clazz = sOwner(jclazz) // sOwner called outside of closure for binary compatibility + toScala(classCache, jclazz){ (mirror, jclazz) => + mirror.jclassAsScala(jclazz, clazz) + } + } private def jclassAsScala(jclazz: jClass[_], owner: Symbol): ClassSymbol = { - val name = scalaSimpleName(jclazz) - val completer = (clazz: Symbol, module: Symbol) => new FromJavaClassCompleter(clazz, module, jclazz) - val (clazz, module) = createClassModule(owner, name, completer) - classCache enter (jclazz, clazz) + val name = scalaSimpleName(jclazz) + val completer = (clazz: Symbol, module: Symbol) => new FromJavaClassCompleter(clazz, module, jclazz) + val (clazz, _) = createClassModule(owner, name, completer) clazz } |