Skip to content

Commit

Permalink
Backport "Only consider methods with 0 parameters in valueOf" to LTS (#…
Browse files Browse the repository at this point in the history
…21153)

Backports #20543 to the LTS branch.

PR submitted by the release tooling.
[skip ci]
  • Loading branch information
WojciechMazur authored Jul 10, 2024
2 parents c192315 + 3ff5115 commit d120926
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion compiler/src/dotty/tools/repl/Rendering.scala
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ private[repl] class Rendering(parentClassLoader: Option[ClassLoader] = None):
val objectName = sym.owner.fullName.encode.toString.stripSuffix("$")
val resObj: Class[?] = Class.forName(objectName, true, classLoader())
val symValue = resObj
.getDeclaredMethods.find(_.getName == sym.name.encode.toString)
.getDeclaredMethods
.find(method => method.getName == sym.name.encode.toString && method.getParameterCount == 0)
.flatMap(result => rewrapValueClass(sym.info.classSymbol, result.invoke(null)))
symValue
.filter(_ => sym.is(Flags.Method) || sym.info != defn.UnitType)
Expand Down
5 changes: 5 additions & 0 deletions compiler/test-resources/repl/19184
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
scala> def o(s: String) = "o"; def oo(s: String) = "oo"; val o = "o"; val oo = "oo"
def o(s: String): String
def oo(s: String): String
val o: String = o
val oo: String = oo

0 comments on commit d120926

Please sign in to comment.