summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala17
-rw-r--r--src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala1
2 files changed, 17 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala b/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala
index 8556cc9ddc..7e0b87dbe1 100644
--- a/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala
+++ b/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala
@@ -77,11 +77,26 @@ abstract class ExtensionMethods extends Transform with TypingTransformers {
matching.head
}
+ /** This method removes the `$this` argument from the parameter list a method.
+ *
+ * A method may be a `PolyType`, in which case we tear out the `$this` and the class
+ * type params from its nested `MethodType`.
+ * It may be a `MethodType`, either with a curried parameter list in which the first argument
+ * is a `$this` - we just return the rest of the list.
+ * This means that the corresponding symbol was generated during `extmethods`.
+ *
+ * It may also be a `MethodType` in which the `$this` does not appear in a curried parameter list.
+ * The curried lists disappear during `uncurry`, and the methods may be duplicated afterwards,
+ * for instance, during `specialize`.
+ * In this case, the first argument is `$this` and we just get rid of it.
+ */
private def normalize(stpe: Type, clazz: Symbol): Type = stpe match {
case PolyType(tparams, restpe) =>
GenPolyType(tparams dropRight clazz.typeParams.length, normalize(restpe.substSym(tparams takeRight clazz.typeParams.length, clazz.typeParams), clazz))
- case MethodType(tparams, restpe) =>
+ case MethodType(List(thiz), restpe) if thiz.name == nme.SELF =>
restpe
+ case MethodType(tparams, restpe) =>
+ MethodType(tparams.drop(1), restpe)
case _ =>
stpe
}
diff --git a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
index f2e109a5ad..60461a524b 100644
--- a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
+++ b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
@@ -821,6 +821,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
debuglog("%s expands to %s in %s".format(sym, specMember.name.decode, pp(env)))
info(specMember) = NormalizedMember(sym)
overloads(sym) ::= Overload(specMember, env)
+ owner.info.decls.enter(specMember)
specMember
}
}