From 19b95504732dcb4699e403134e2c752dfb045c02 Mon Sep 17 00:00:00 2001 From: Alexey Romanov Date: Thu, 20 Aug 2015 13:12:02 +0300 Subject: [PATCH] [backport] Include owner in ErrorNonExistentField message This should be particularly helpful for synthetic field names like `evidence$21`. --- src/reflect/scala/reflect/runtime/JavaMirrors.scala | 6 +++--- test/files/run/reflection-fieldmirror-ctorparam.check | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/reflect/scala/reflect/runtime/JavaMirrors.scala b/src/reflect/scala/reflect/runtime/JavaMirrors.scala index d0670f337a4d..50442519f2ca 100644 --- a/src/reflect/scala/reflect/runtime/JavaMirrors.scala +++ b/src/reflect/scala/reflect/runtime/JavaMirrors.scala @@ -124,9 +124,9 @@ private[scala] trait JavaMirrors extends internal.SymbolTable with api.JavaUnive private def ErrorArrayConstructor(sym: Symbol, owner: Symbol) = abort(s"Cannot instantiate arrays with mirrors. Consider using `scala.reflect.ClassTag().newArray()` instead") private def ErrorFree(member: Symbol, freeType: Symbol) = abort(s"cannot reflect ${member.kindString} ${member.name}, because it's a member of a weak type ${freeType.name}") private def ErrorNonExistentField(sym: Symbol) = abort( - sm"""Scala field ${sym.name} isn't represented as a Java field, neither it has a Java accessor method - |note that private parameters of class constructors don't get mapped onto fields and/or accessors, - |unless they are used outside of their declaring constructors.""") + sm"""Scala field ${sym.name} of ${sym.owner} isn't represented as a Java field, nor does it have a + |Java accessor method. One common reason for this is that it may be a private class parameter + |not used outside the primary constructor.""") /** Helper functions for extracting typed values from a (Class[_], Any) * representing an annotation argument. diff --git a/test/files/run/reflection-fieldmirror-ctorparam.check b/test/files/run/reflection-fieldmirror-ctorparam.check index e391e7ccfec3..c66be94ed712 100644 --- a/test/files/run/reflection-fieldmirror-ctorparam.check +++ b/test/files/run/reflection-fieldmirror-ctorparam.check @@ -1,3 +1,3 @@ -class scala.ScalaReflectionException: Scala field x isn't represented as a Java field, neither it has a Java accessor method -note that private parameters of class constructors don't get mapped onto fields and/or accessors, -unless they are used outside of their declaring constructors. +class scala.ScalaReflectionException: Scala field x of class A isn't represented as a Java field, nor does it have a +Java accessor method. One common reason for this is that it may be a private class parameter +not used outside the primary constructor.