summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Kossakowski <grzegorz.kossakowski@gmail.com>2012-10-08 12:27:40 -0700
committerGrzegorz Kossakowski <grzegorz.kossakowski@gmail.com>2012-10-08 12:27:40 -0700
commit859ec02495993f225647df50397b042a3172351b (patch)
treed6f878c72625849b90123003eb288e68fbd78693
parent6745756926c989c1551267d6dff6888d9d270c8e (diff)
parentd46f2d519de0f155d37a43927fb3924d2f2fbdb2 (diff)
downloadscala-859ec02495993f225647df50397b042a3172351b.tar.gz
scala-859ec02495993f225647df50397b042a3172351b.tar.bz2
scala-859ec02495993f225647df50397b042a3172351b.zip
Merge pull request #1442 from adriaanm/ticket-6215
SI-6215 Fix compiler crash on private method in value class
-rw-r--r--src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala8
-rw-r--r--test/files/pos/t6215.scala1
-rw-r--r--test/files/run/t6344.check16
3 files changed, 13 insertions, 12 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala b/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala
index 8a9d0e58ec..6dd937c0ad 100644
--- a/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala
+++ b/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala
@@ -56,11 +56,11 @@ abstract class ExtensionMethods extends Transform with TypingTransformers {
case OverloadedType(_, alts) =>
val index = alts indexOf imeth
assert(index >= 0, alts+" does not contain "+imeth)
- def altName(index: Int) = newTermName("extension"+index+"$"+imeth.name)
+ def altName(index: Int) = newTermName(imeth.name+"$extension"+index)
altName(index) #:: ((0 until alts.length).toStream filter (index != _) map altName)
case tpe =>
assert(tpe != NoType, imeth.name+" not found in "+imeth.owner+"'s decls: "+imeth.owner.info.decls)
- Stream(newTermName("extension$"+imeth.name))
+ Stream(newTermName(imeth.name+"$extension"))
}
}
@@ -68,10 +68,10 @@ abstract class ExtensionMethods extends Transform with TypingTransformers {
*/
def extensionMethod(imeth: Symbol): Symbol = atPhase(currentRun.refchecksPhase) {
val companionInfo = imeth.owner.companionModule.info
- val candidates = extensionNames(imeth) map (companionInfo.decl(_))
+ val candidates = extensionNames(imeth) map (companionInfo.decl(_)) filter (_.exists)
val matching = candidates filter (alt => normalize(alt.tpe, imeth.owner) matches imeth.tpe)
assert(matching.nonEmpty,
- s"no extension method found for $imeth:${imeth.tpe}+among ${candidates map (c => c.name+":"+c.tpe)} / ${extensionNames(imeth)}")
+ s"no extension method found for $imeth:${imeth.tpe} among ${candidates map (c => c.name+":"+c.tpe)} / ${extensionNames(imeth)}")
matching.head
}
diff --git a/test/files/pos/t6215.scala b/test/files/pos/t6215.scala
new file mode 100644
index 0000000000..2f66892b69
--- /dev/null
+++ b/test/files/pos/t6215.scala
@@ -0,0 +1 @@
+class Foo(val v: String) extends AnyVal { private def len = v.length ; def f = len }
diff --git a/test/files/run/t6344.check b/test/files/run/t6344.check
index 5ac04d0320..8d9adac849 100644
--- a/test/files/run/t6344.check
+++ b/test/files/run/t6344.check
@@ -101,14 +101,14 @@ public int ValueInt.x()
public int ValueInt.x()
public java.lang.Object ValueInt.x()
public java.lang.Object ValueInt.x()
-public static Gen ValueInt.extension$plus(int,Gen,Gen)
-public static Gen<java.lang.Object> ValueInt.extension$plus(int,Gen<java.lang.Object>,Gen<java.lang.Object>)
-public static boolean ValueInt.extension$equals(int,java.lang.Object)
-public static boolean ValueInt.extension$equals(int,java.lang.Object)
-public static int ValueInt.extension$hashCode(int)
-public static int ValueInt.extension$hashCode(int)
-public static int ValueInt.extension$iplus(int,int,int)
-public static int ValueInt.extension$iplus(int,int,int)
+public static Gen ValueInt.plus$extension(int,Gen,Gen)
+public static Gen<java.lang.Object> ValueInt.plus$extension(int,Gen<java.lang.Object>,Gen<java.lang.Object>)
+public static boolean ValueInt.equals$extension(int,java.lang.Object)
+public static boolean ValueInt.equals$extension(int,java.lang.Object)
+public static int ValueInt.hashCode$extension(int)
+public static int ValueInt.hashCode$extension(int)
+public static int ValueInt.iplus$extension(int,int,int)
+public static int ValueInt.iplus$extension(int,int,int)
RefInt
public Gen RefInt.plus(Gen,Gen)