diff options
author | Adriaan Moors <adriaan.moors@typesafe.com> | 2013-02-12 16:06:19 -0800 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@typesafe.com> | 2013-02-12 16:06:19 -0800 |
commit | 76f167388a42e9bb8b72645d87bcb408b6981576 (patch) | |
tree | 55b62a8e1bf9d5bc908c757c2fe05e9f26ff1cf2 /src/compiler | |
parent | 14048023a1deba540502da96663deca6ca226bf6 (diff) | |
parent | f51ed74aa3aa142c8aa9d5f9d03e0c244737f66e (diff) | |
download | scala-76f167388a42e9bb8b72645d87bcb408b6981576.tar.gz scala-76f167388a42e9bb8b72645d87bcb408b6981576.tar.bz2 scala-76f167388a42e9bb8b72645d87bcb408b6981576.zip |
Merge remote-tracking branch 'scala/2.10.x' into patmat-refactor-master
Conflicts:
src/compiler/scala/tools/nsc/typechecker/Implicits.scala
Diffstat (limited to 'src/compiler')
5 files changed, 30 insertions, 13 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala index 22a28b7895..711085e6c9 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala @@ -630,7 +630,14 @@ trait Contexts { self: Analyzer => new ImplicitInfo(sym.name, pre, sym) private def collectImplicitImports(imp: ImportInfo): List[ImplicitInfo] = { - val pre = imp.qual.tpe + val qual = imp.qual + + val pre = + if (qual.tpe.typeSymbol.isPackageClass) + // SI-6225 important if the imported symbol is inherited by the the package object. + singleType(qual.tpe, qual.tpe member nme.PACKAGE) + else + qual.tpe def collect(sels: List[ImportSelector]): List[ImplicitInfo] = sels match { case List() => List() diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala index d32930f4f2..788825a6b6 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala @@ -149,7 +149,7 @@ trait Implicits { class SearchResult(val tree: Tree, val subst: TreeTypeSubstituter) { override def toString = "SearchResult(%s, %s)".format(tree, if (subst.isEmpty) "" else subst) - + def isFailure = false def isAmbiguousFailure = false final def isSuccess = !isFailure @@ -158,7 +158,7 @@ trait Implicits { lazy val SearchFailure = new SearchResult(EmptyTree, EmptyTreeTypeSubstituter) { override def isFailure = true } - + lazy val AmbiguousSearchFailure = new SearchResult(EmptyTree, EmptyTreeTypeSubstituter) { override def isFailure = true override def isAmbiguousFailure = true @@ -244,7 +244,7 @@ trait Implicits { object HasMember { private val hasMemberCache = perRunCaches.newMap[Name, Type]() def apply(name: Name): Type = hasMemberCache.getOrElseUpdate(name, memberWildcardType(name, WildcardType)) - } + } /** An extractor for types of the form ? { name: (? >: argtpe <: Any*)restp } */ @@ -1128,7 +1128,7 @@ trait Implicits { ) // todo. migrate hardcoded materialization in Implicits to corresponding implicit macros val materializer = atPos(pos.focus)(gen.mkMethodCall(TagMaterializers(tagClass), List(tp), if (prefix != EmptyTree) List(prefix) else List())) - if (settings.XlogImplicits.value) println("materializing requested %s.%s[%s] using %s".format(pre, tagClass.name, tp, materializer)) + if (settings.XlogImplicits.value) reporter.echo(pos, "materializing requested %s.%s[%s] using %s".format(pre, tagClass.name, tp, materializer)) if (context.macrosEnabled) success(materializer) // don't call `failure` here. if macros are disabled, we just fail silently // otherwise -Xlog-implicits will spam the long with zillions of "macros are disabled" diff --git a/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala b/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala index a112516b59..52497411d1 100644 --- a/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala @@ -298,6 +298,9 @@ abstract class TreeCheckers extends Analyzer { } for { sym <- referencedSymbols + // Accessors are known to steal the type of the underlying field without cloning existential symbols at the new owner. + // This happens in Namer#accessorTypeCompleter. We just look the other way here. + if !tree.symbol.isAccessor if (sym.isTypeParameter || sym.isLocal) && !(tree.symbol hasTransOwner sym.owner) } errorFn(s"The symbol, tpe or info of tree `(${tree}) : ${info}` refers to a out-of-scope symbol, ${sym.fullLocationString}. tree.symbol.ownerChain: ${tree.symbol.ownerChain.mkString(", ")}") } diff --git a/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala b/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala index af484a47e2..cfe962d65f 100644 --- a/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala +++ b/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala @@ -525,17 +525,24 @@ trait TypeDiagnostics { } object checkDead { - private var expr: Symbol = NoSymbol + private val exprStack: mutable.Stack[Symbol] = mutable.Stack(NoSymbol) + // The method being applied to `tree` when `apply` is called. + private def expr = exprStack.top private def exprOK = (expr != Object_synchronized) && !(expr.isLabel && treeInfo.isSynthCaseSymbol(expr)) // it's okay to jump to matchEnd (or another case) with an argument of type nothing - private def treeOK(tree: Tree) = tree.tpe != null && tree.tpe.typeSymbol == NothingClass + private def treeOK(tree: Tree) = { + val isLabelDef = tree match { case _: LabelDef => true; case _ => false} + tree.tpe != null && tree.tpe.typeSymbol == NothingClass && !isLabelDef + } - def updateExpr(fn: Tree) = { - if (fn.symbol != null && fn.symbol.isMethod && !fn.symbol.isConstructor) - checkDead.expr = fn.symbol + @inline def updateExpr[A](fn: Tree)(f: => A) = { + if (fn.symbol != null && fn.symbol.isMethod && !fn.symbol.isConstructor) { + exprStack push fn.symbol + try f finally exprStack.pop() + } else f } def apply(tree: Tree): Tree = { // Error suppression will squash some of these warnings unless we circumvent it. diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 4ab3d684a2..c1fcff0c4e 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -3238,8 +3238,6 @@ trait Typers extends Adaptations with Tags { // but behaves as if it were (=> T) => T) we need to know what is the actual // target of a call. Since this information is no longer available from // typedArg, it is recorded here. - checkDead.updateExpr(fun) - val args1 = // no expected type when jumping to a match label -- anything goes (this is ok since we're typing the translation of well-typed code) // ... except during erasure: we must take the expected type into account as it drives the insertion of casts! @@ -3274,7 +3272,9 @@ trait Typers extends Adaptations with Tags { else constfold(treeCopy.Apply(tree, fun, args1) setType ifPatternSkipFormals(restpe)) } - handleMonomorphicCall + checkDead.updateExpr(fun) { + handleMonomorphicCall + } } else if (needsInstantiation(tparams, formals, args)) { //println("needs inst "+fun+" "+tparams+"/"+(tparams map (_.info))) inferExprInstance(fun, tparams) |