diff options
author | Paul Phillips <paulp@improving.org> | 2012-01-16 16:17:29 -0800 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-01-16 16:52:22 -0800 |
commit | 8e9873f550110df8a028c77343154daf79a324df (patch) | |
tree | 41bcadcc8730274aed5c52f3a41c3bc866339cdd /src/compiler | |
parent | 484af96c6d4a8684a4a1927693fd2485dd64e9ce (diff) | |
download | scala-8e9873f550110df8a028c77343154daf79a324df.tar.gz scala-8e9873f550110df8a028c77343154daf79a324df.tar.bz2 scala-8e9873f550110df8a028c77343154daf79a324df.zip |
Improved a cyclic reference error message.
"illegal cyclic reference involving value <import>" not
so useful.
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala b/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala index 02c6e86fde..fe3ceafa2d 100644 --- a/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala +++ b/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala @@ -494,6 +494,11 @@ trait TypeDiagnostics { def cyclicReferenceMessage(sym: Symbol, tree: Tree) = condOpt(tree) { case ValDef(_, _, tpt, _) if tpt.tpe == null => "recursive "+sym+" needs type" case DefDef(_, _, _, _, tpt, _) if tpt.tpe == null => List(cyclicAdjective(sym), sym, "needs result type") mkString " " + case Import(expr, selectors) => + ( "encountered unrecoverable cycle resolving import." + + "\nNote: this is often due in part to a class depending on a definition nested within its companion." + + "\nIf applicable, you may wish to try moving some members into another object." + ) } /** Report a type error. @@ -508,7 +513,11 @@ trait TypeDiagnostics { ex match { case CyclicReference(sym, info: TypeCompleter) => - contextError(ex.pos, cyclicReferenceMessage(sym, info.tree) getOrElse ex.getMessage()) + val pos = info.tree match { + case Import(expr, _) => expr.pos + case _ => ex.pos + } + contextError(pos, cyclicReferenceMessage(sym, info.tree) getOrElse ex.getMessage()) if (sym == ObjectClass) throw new FatalError("cannot redefine root "+sym) |