Skip to content

Commit a0a8f0e

Browse files
committed
Add extra info in unqualified getClass warning
1 parent 693a80a commit a0a8f0e

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
@@ -2415,9 +2415,14 @@ class UnqualifiedCallToAnyRefMethod(stat: untpd.Tree, method: Symbol)(using Cont
24152415
def kind = MessageKind.PotentialIssue
24162416
def msg(using Context) = i"Suspicious top-level unqualified call to ${hl(method.name.toString)}"
24172417
def explain(using Context) =
2418+
val getClassExtraHint =
2419+
if method.name == nme.getClass_ && ctx.settings.classpath.value.contains("scala3-staging") then
2420+
i"""\n\n
2421+
|This class should not be used to get the classloader for `scala.quoted.staging.Compile.make`."""
2422+
else ""
24182423
i"""Top-level unqualified calls to ${hl("AnyRef")} or ${hl("Any")} methods such as ${hl(method.name.toString)} are
24192424
|resolved to calls on ${hl("Predef")} or on imported methods. This might not be what
2420-
|you intended."""
2425+
|you intended.$getClassExtraHint"""
24212426
}
24222427

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

0 commit comments

Comments
 (0)