Skip to content

Commit 3c0d04b

Browse files
committed
Don't expand the name of accessors
I couldn't find a single use case where this is needed. The callee is usually either not an accessor or all declarations in scope are looped over and expanded. On the other hand this fixes a bug in specialization. After all the accessor(s) could be implementing an abstract method.
1 parent 698c4e8 commit 3c0d04b

File tree

6 files changed

+23
-15
lines changed

6 files changed

+23
-15
lines changed

src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ abstract class ExtensionMethods extends Transform with TypingTransformers {
115115
extensionDefs(currentOwner.companionModule) = new mutable.ListBuffer[Tree]
116116
currentOwner.primaryConstructor.makeNotPrivate(NoSymbol)
117117
// scala/bug#7859 make param accessors accessible so the erasure can generate unbox operations.
118-
currentOwner.info.decls.foreach(sym => if (sym.isParamAccessor && sym.isMethod) sym.makeNotPrivate(currentOwner))
118+
currentOwner.info.decls.foreach(sym => if (sym.isParamAccessor) sym.makeNotPrivate(currentOwner))
119119
super.transform(tree)
120120
} else if (currentOwner.isStaticOwner) {
121121
super.transform(tree)

src/reflect/scala/reflect/internal/Symbols.scala

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -838,10 +838,9 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
838838
isAbstractType && !isExistential && !isTypeParameterOrSkolem && isLocalToBlock
839839

840840
/** change name by appending $$<fully-qualified-name-of-class `base`>
841-
* Do the same for any accessed symbols or setters/getters.
842841
* Implementation in TermSymbol.
843842
*/
844-
def expandName(base: Symbol): Unit = { }
843+
def expandName(base: Symbol): Unit = ()
845844

846845
// In java.lang, Predef, or scala package/package object
847846
def isInDefaultNamespace = UnqualifiedOwners(effectiveOwner)
@@ -2987,19 +2986,10 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
29872986
this
29882987
}
29892988

2990-
/** change name by appending $$<fully-qualified-name-of-class `base`>
2991-
* Do the same for any accessed symbols or setters/getters
2992-
*/
2989+
/** change name by appending $$<fully-qualified-name-of-class `base`> */
29932990
override def expandName(base: Symbol): Unit = {
29942991
if (!hasFlag(EXPANDEDNAME)) {
29952992
setFlag(EXPANDEDNAME)
2996-
if (hasAccessorFlag && !isDeferred) {
2997-
accessed.expandName(base)
2998-
}
2999-
else if (hasGetter) {
3000-
getterIn(owner).expandName(base)
3001-
setterIn(owner).expandName(base)
3002-
}
30032993
name = nme.expandedName(name.toTermName, base)
30042994
}
30052995
}

test/files/run/t12222.check

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0

test/files/run/t12222/Buffer_1.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
trait ABuffer[@specialized(Float)T] {
2+
def count: Int
3+
}
4+
5+
class Buffer[@specialized(Float) T](array_par: Array[T]) extends ABuffer[T] {
6+
var array: Array[T] = array_par
7+
var count: Int = 0
8+
}
9+
10+
class Float32Buffer(array_par: Array[Float]) extends Buffer[Float](array_par)

test/files/run/t12222/Test_2.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
object Test {
2+
def main(args: Array[String]): Unit = {
3+
val vertices = Array[Float]()
4+
val attribute = new Float32Buffer(vertices)
5+
println(attribute.count)
6+
}
7+
}

test/files/run/t3897.check

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
(One$$messages,scala.collection.mutable.ListBuffer<java.lang.String>)
1+
(messages,scala.collection.mutable.ListBuffer<java.lang.String>)
22
(One$$messages,scala.collection.mutable.ListBuffer<java.lang.String>)
33
(messages,scala.collection.mutable.ListBuffer<java.lang.String>)
44
(messages,scala.collection.mutable.ListBuffer<java.lang.String>)
5-
(One$$messages,scala.collection.mutable.ListBuffer<java.lang.String>)
5+
(messages,scala.collection.mutable.ListBuffer<java.lang.String>)
66
(One$$messages,scala.collection.mutable.ListBuffer<java.lang.String>)
77
(messages,scala.collection.mutable.ListBuffer<java.lang.String>)
88
(messages,scala.collection.mutable.ListBuffer<java.lang.String>)

0 commit comments

Comments
 (0)