summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2013-07-16 13:09:24 +1000
committerJason Zaugg <jzaugg@gmail.com>2013-07-16 13:09:24 +1000
commit32fc8fc3bf4201bbb68426b134d5aac95c641e5f (patch)
tree1311833758e48c64cb983e242f4ab8d0df3e8e0f
parent11dcf82910b388046e675d76d277b09b931d5363 (diff)
downloadscala-32fc8fc3bf4201bbb68426b134d5aac95c641e5f.tar.gz
scala-32fc8fc3bf4201bbb68426b134d5aac95c641e5f.tar.bz2
scala-32fc8fc3bf4201bbb68426b134d5aac95c641e5f.zip
SI-7668 Better return type inheritance for dep. method types
Return type inheritance already handles substitution of type parameters of the overriding method for those of the overriding. This commit extends this to do the same for parameter symbols.
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Namers.scala3
-rw-r--r--test/files/pos/t7668.scala12
2 files changed, 15 insertions, 0 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
index 1282cfb416..08837d9a54 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
@@ -1084,6 +1084,9 @@ trait Namers extends MethodSynthesis {
overriddenTp = overriddenTp.resultType
}
+ // SI-7668 Substitute parameters from the parent method with those of the overriding method.
+ overriddenTp = overriddenTp.substSym(overridden.paramss.flatten, vparamss.flatten.map(_.symbol))
+
overriddenTp match {
case NullaryMethodType(rtpe) => overriddenTp = rtpe
case MethodType(List(), rtpe) => overriddenTp = rtpe
diff --git a/test/files/pos/t7668.scala b/test/files/pos/t7668.scala
new file mode 100644
index 0000000000..222a13d039
--- /dev/null
+++ b/test/files/pos/t7668.scala
@@ -0,0 +1,12 @@
+trait Space {
+ type T
+ val x: T
+}
+
+trait Extractor {
+ def extract(s: Space): s.T
+}
+
+class Sub extends Extractor {
+ def extract(s: Space) = s.x
+}