diff --git a/compiler/src/dotty/tools/repl/Rendering.scala b/compiler/src/dotty/tools/repl/Rendering.scala index e1e8567c6734..7d9931b74efd 100644 --- a/compiler/src/dotty/tools/repl/Rendering.scala +++ b/compiler/src/dotty/tools/repl/Rendering.scala @@ -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) diff --git a/compiler/test-resources/repl/19184 b/compiler/test-resources/repl/19184 new file mode 100644 index 000000000000..cf4ce6f1d22f --- /dev/null +++ b/compiler/test-resources/repl/19184 @@ -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