diff options
author | Adriaan Moors <adriaan.moors@typesafe.com> | 2013-07-29 09:44:32 -0700 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@typesafe.com> | 2013-07-29 09:44:32 -0700 |
commit | 20cd9474f0a22950c905badb81fb6eeebdf00b34 (patch) | |
tree | a96b647313da688037cbc9625bd3a54436f0a3d4 | |
parent | cf5bd70ce77f659b18cb4f326f9354f5e052277a (diff) | |
parent | 32fc8fc3bf4201bbb68426b134d5aac95c641e5f (diff) | |
download | scala-20cd9474f0a22950c905badb81fb6eeebdf00b34.tar.gz scala-20cd9474f0a22950c905badb81fb6eeebdf00b34.tar.bz2 scala-20cd9474f0a22950c905badb81fb6eeebdf00b34.zip |
Merge pull request #2739 from retronym/ticket/7668
SI-7668 Better return type inheritance for dep. method types
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Namers.scala | 3 | ||||
-rw-r--r-- | test/files/pos/t7668.scala | 12 |
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 e8a1e8e85a..cac6bd2ef2 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala @@ -1085,6 +1085,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 +} |