Skip to content

Commit

Permalink
Merge pull request scala#3894 from adriaanm/depmsg
Browse files Browse the repository at this point in the history
Better error message than 'bad symbolic reference'.
  • Loading branch information
gkossakowski committed Jul 25, 2014
2 parents 5a878c2 + c436048 commit 4445615
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 21 deletions.
11 changes: 6 additions & 5 deletions src/reflect/scala/reflect/internal/pickling/UnPickler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -254,12 +254,13 @@ abstract class UnPickler {
// (4) Call the mirror's "missing" hook.
adjust(mirrorThatLoaded(owner).missingHook(owner, name)) orElse {
// (5) Create a stub symbol to defer hard failure a little longer.
val fullName = s"${owner.fullName}.$name"
val advice = moduleAdvice(s"${owner.fullName}.$name")
val missingMessage =
s"""|bad symbolic reference to $fullName encountered in class file '$filename'.
|Cannot access ${name.longString} in ${owner.kindString} ${owner.fullName}. The current classpath may be
|missing a definition for $fullName, or $filename may have been compiled against a version that's
|incompatible with the one found on the current classpath.${moduleAdvice(fullName)}""".stripMargin
s"""|missing or invalid dependency detected while loading class file '$filename'.
|Could not access ${name.longString} in ${owner.kindString} ${owner.fullName},
|because it (or its dependencies) are missing. Check your build definition for
|missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
|A full rebuild may help if '$filename' was compiled against an incompatible version of ${owner.fullName}.$advice""".stripMargin
owner.newStubSymbol(name, missingMessage)
}
}
Expand Down
9 changes: 5 additions & 4 deletions test/files/neg/t5148.check
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
error: bad symbolic reference to scala.tools.nsc.interpreter.IMain.Request encountered in class file 'Imports.class'.
Cannot access type Request in class scala.tools.nsc.interpreter.IMain. The current classpath may be
missing a definition for scala.tools.nsc.interpreter.IMain.Request, or Imports.class may have been compiled against a version that's
incompatible with the one found on the current classpath.
error: missing or invalid dependency detected while loading class file 'Imports.class'.
Could not access type Request in class scala.tools.nsc.interpreter.IMain,
because it (or its dependencies) are missing. Check your build definition for
missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
A full rebuild may help if 'Imports.class' was compiled against an incompatible version of scala.tools.nsc.interpreter.IMain.
one error found
9 changes: 5 additions & 4 deletions test/files/run/t6440.check
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pos: source-newSource1.scala,line-9,offset=109 bad symbolic reference to <root>.pack1 encountered in class file 'U.class'.
Cannot access term pack1 in package <root>. The current classpath may be
missing a definition for <root>.pack1, or U.class may have been compiled against a version that's
incompatible with the one found on the current classpath. ERROR
pos: source-newSource1.scala,line-9,offset=109 missing or invalid dependency detected while loading class file 'U.class'.
Could not access term pack1 in package <root>,
because it (or its dependencies) are missing. Check your build definition for
missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
A full rebuild may help if 'U.class' was compiled against an incompatible version of <root>. ERROR
9 changes: 5 additions & 4 deletions test/files/run/t6440b.check
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pos: NoPosition bad symbolic reference to pack1.T encountered in class file 'U.class'.
Cannot access type T in package pack1. The current classpath may be
missing a definition for pack1.T, or U.class may have been compiled against a version that's
incompatible with the one found on the current classpath. ERROR
pos: NoPosition missing or invalid dependency detected while loading class file 'U.class'.
Could not access type T in package pack1,
because it (or its dependencies) are missing. Check your build definition for
missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
A full rebuild may help if 'U.class' was compiled against an incompatible version of pack1. ERROR
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ object Test extends StoreReporterDirectTest {
println(filteredInfos.mkString("\n"))
storeReporter.infos.clear()
compileApp();
// we should get bad symbolic reference errors, because we're trying to use an implicit that can't be unpickled
// we should get "missing or invalid dependency detected" errors, because we're trying to use an implicit that can't be unpickled
// but we don't know the number of these errors and their order, so I just ignore them all
println(filteredInfos.filterNot(_.msg.contains("bad symbolic reference")).mkString("\n"))
println(filteredInfos.filterNot(_.msg.contains("missing or invalid dependency detected")).mkString("\n"))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ object Test extends StoreReporterDirectTest {
println(filteredInfos.mkString("\n"))
storeReporter.infos.clear()
compileApp();
// we should get bad symbolic reference errors, because we're trying to use an implicit that can't be unpickled
// we should get "missing or invalid dependency detected" errors, because we're trying to use an implicit that can't be unpickled
// but we don't know the number of these errors and their order, so I just ignore them all
println(filteredInfos.filterNot (_.msg.contains("bad symbolic reference")).mkString("\n"))
println(filteredInfos.filterNot (_.msg.contains("missing or invalid dependency detected")).mkString("\n"))
}
}

0 comments on commit 4445615

Please sign in to comment.