-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Ref #1589: Add error message for bad symbolic reference. #3605
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
allanrenucci
merged 4 commits into
scala:master
from
vitorsvieira:wip/1593-bad-symbolic-reference
Dec 11, 2017
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,8 @@ import util.Stats | |
import java.util.WeakHashMap | ||
import config.Config | ||
import config.Printers.{incremental, noPrinter} | ||
import reporting.diagnostic.Message | ||
import reporting.diagnostic.messages._ | ||
import reporting.trace | ||
|
||
trait SymDenotations { this: Context => | ||
|
@@ -1943,7 +1945,7 @@ object SymDenotations { | |
/** A completer for missing references */ | ||
class StubInfo() extends LazyType { | ||
|
||
def initializeToDefaults(denot: SymDenotation, errMsg: => String)(implicit ctx: Context) = { | ||
def initializeToDefaults(denot: SymDenotation, errMsg: => Message)(implicit ctx: Context): Unit = { | ||
denot.info = denot match { | ||
case denot: ClassDenotation => | ||
ClassInfo(denot.owner.thisType, denot.classSymbol, Nil, EmptyScope) | ||
|
@@ -1960,13 +1962,9 @@ object SymDenotations { | |
if (file != null) (s" in $file", file.toString) | ||
else ("", "the signature") | ||
val name = ctx.fresh.setSetting(ctx.settings.YdebugNames, true).nameString(denot.name) | ||
def errMsg = | ||
i"""bad symbolic reference. A signature$location | ||
|refers to $name in ${denot.owner.showKind} ${denot.owner.showFullName} which is not available. | ||
|It may be completely missing from the current classpath, or the version on | ||
|the classpath might be incompatible with the version used when compiling $src.""" | ||
ctx.error(errMsg) | ||
if (ctx.debug) throw new Error() | ||
val errMsg = BadSymbolicReference(location, name, denot.owner, src) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be a |
||
ctx.error(errMsg, sym.pos) | ||
if (ctx.debug) throw new scala.Error() | ||
initializeToDefaults(denot, errMsg) | ||
} | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1968,6 +1968,24 @@ object messages { | |
} | ||
} | ||
|
||
case class BadSymbolicReference( | ||
location: String, | ||
name: String, | ||
denotationOwner: Symbol, | ||
src: String | ||
)(implicit ctx: Context) extends Message(BadSymbolicReferenceID) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would change |
||
val kind = "Reference" | ||
val msg = | ||
hl"""Bad symbolic reference. A signature$location | ||
|refers to $name in ${denotationOwner.showKind} ${denotationOwner.showFullName} which is not available. | ||
|It may be completely missing from the current classpath, or the version on | ||
|the classpath might be incompatible with the version used when compiling $src.""" | ||
val explanation = | ||
hl"""A missing or invalid dependency was detected while loading class file '$name'. | ||
|Check your build definition for missing or conflicting dependencies. | ||
|Re-run with ${"-Ylog-classpath"} to obtain the information about what classpath is being applied.""" | ||
} | ||
|
||
case class UnableToExtendSealedClass(pclazz: Symbol)(implicit ctx: Context) extends Message(UnableToExtendSealedClassID) { | ||
val kind = "Syntax" | ||
val msg = hl"Cannot extend ${"sealed"} $pclazz in a different source file" | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only import what you need