-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Description
As discussed here the current strategy for extracting used names might miss synthetic names for case classes like
copy,apply,unapply, etc.This ticket is a reminder for me to investigate this issue further. Both for members of case classes and other synthetic members.
steps
// A.scala
case class A(a: Int)
// B.scala
class B { def test(a: A) = a.copy() }
// > compile
// A.scala
case class A(a: Int) { private def copy = ??? }
// > compile
// [info] Compiling 1 Scala source to /Users/jason/code/scratch1/target/scala-2.11/classes...
// [success]
// > ;clean;compile
// ...
// [info] Compiling 2 Scala sources to /Users/jason/code/scratch1/target/scala-2.11/classes...
// [error] /Users/jason/code/scratch1/src/main/scala/B.scala:2: method copy in class A cannot be accessed in A
// [error] def test(a: A) = a.copy()
// [error] ^problem
Name hashing under compiles.
expectation
Changes are detected.
notes
isSynthetic is intentionally omitted.
private def eligibleAsUsedName(symbol: Symbol): Boolean = {
def emptyName(name: Name): Boolean = name match {
case nme.EMPTY | nme.EMPTY_PACKAGE_NAME | tpnme.EMPTY | tpnme.EMPTY_PACKAGE_NAME => true
case _ => false
}
(symbol != NoSymbol) &&
!symbol.isSynthetic &&
!emptyName(symbol.name)
}Reactions are currently unavailable