diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2013-09-10 00:49:49 -0700 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2013-09-10 00:49:49 -0700 |
commit | 1015d129a5ce69aad8c273734b23e35c7648b686 (patch) | |
tree | 4c2f72c2844c5cc5f5dfe305392b6692363484a9 /src/compiler | |
parent | 7ecffb0c6719a15c46a1bce5ec8545fb9a1cb24f (diff) | |
parent | cb028ba477f37778bccfc23e597acc0284259681 (diff) | |
download | scala-1015d129a5ce69aad8c273734b23e35c7648b686.tar.gz scala-1015d129a5ce69aad8c273734b23e35c7648b686.tar.bz2 scala-1015d129a5ce69aad8c273734b23e35c7648b686.zip |
Merge pull request #2916 from retronym/ticket/7818
SI-7818 Cast our way out of extended existential angst
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala b/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala index bc54054028..e0c0cd0fdb 100644 --- a/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala +++ b/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala @@ -231,9 +231,14 @@ abstract class ExtensionMethods extends Transform with TypingTransformers { .substituteThis(origThis, extensionThis) .changeOwner(origMeth -> extensionMeth) ) + val castBody = + if (extensionBody.tpe <:< extensionMono.finalResultType) + extensionBody + else + gen.mkCastPreservingAnnotations(extensionBody, extensionMono.finalResultType) // SI-7818 e.g. mismatched existential skolems // Record the extension method ( FIXME: because... ? ) - extensionDefs(companion) += atPos(tree.pos)(DefDef(extensionMeth, extensionBody)) + extensionDefs(companion) += atPos(tree.pos)(DefDef(extensionMeth, castBody)) // These three lines are assembling Foo.bar$extension[T1, T2, ...]($this) // which leaves the actual argument application for extensionCall. |