Skip to content

Commit e9f2ab0

Browse files
nicolasstuckiWojciechMazur
authored andcommitted
Add extra info in unqualified getClass warning
[Cherry-picked a0a8f0e]
1 parent 3005598 commit e9f2ab0

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

compiler/src/dotty/tools/dotc/reporting/messages.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2406,9 +2406,14 @@ class UnqualifiedCallToAnyRefMethod(stat: untpd.Tree, method: Symbol)(using Cont
24062406
def kind = MessageKind.PotentialIssue
24072407
def msg(using Context) = i"Suspicious top-level unqualified call to ${hl(method.name.toString)}"
24082408
def explain(using Context) =
2409+
val getClassExtraHint =
2410+
if method.name == nme.getClass_ && ctx.settings.classpath.value.contains("scala3-staging") then
2411+
i"""\n\n
2412+
|This class should not be used to get the classloader for `scala.quoted.staging.Compile.make`."""
2413+
else ""
24092414
i"""Top-level unqualified calls to ${hl("AnyRef")} or ${hl("Any")} methods such as ${hl(method.name.toString)} are
24102415
|resolved to calls on ${hl("Predef")} or on imported methods. This might not be what
2411-
|you intended."""
2416+
|you intended.$getClassExtraHint"""
24122417
}
24132418

24142419
class SynchronizedCallOnBoxedClass(stat: tpd.Tree)(using Context)

0 commit comments

Comments
 (0)