aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/dotty/tools/dotc/transform/ResolveSuper.scala
diff options
context:
space:
mode:
authorNicolas Stucki <nicolas.stucki@gmail.com>2017-01-06 10:58:12 +0100
committerNicolas Stucki <nicolas.stucki@gmail.com>2017-01-06 15:12:05 +0100
commit9f505a42a1c100eedab9748321a77d4bc345af61 (patch)
treea1d53549419e63f8dab3b596d0169b8c5bf57b8a /compiler/src/dotty/tools/dotc/transform/ResolveSuper.scala
parent42eb864dc752254fc3b8b0428570fe94aa1dafc7 (diff)
downloaddotty-9f505a42a1c100eedab9748321a77d4bc345af61.tar.gz
dotty-9f505a42a1c100eedab9748321a77d4bc345af61.tar.bz2
dotty-9f505a42a1c100eedab9748321a77d4bc345af61.zip
Fix #1877: Add forwarders for primitive/generic mixins.
Diffstat (limited to 'compiler/src/dotty/tools/dotc/transform/ResolveSuper.scala')
-rw-r--r--compiler/src/dotty/tools/dotc/transform/ResolveSuper.scala14
1 files changed, 13 insertions, 1 deletions
diff --git a/compiler/src/dotty/tools/dotc/transform/ResolveSuper.scala b/compiler/src/dotty/tools/dotc/transform/ResolveSuper.scala
index e718a7e60..c4d8f5e33 100644
--- a/compiler/src/dotty/tools/dotc/transform/ResolveSuper.scala
+++ b/compiler/src/dotty/tools/dotc/transform/ResolveSuper.scala
@@ -38,6 +38,14 @@ import ResolveSuper._
*
* <mods> def f[Ts](ps1)...(psN): U = super[M].f[Ts](ps1)...(psN)
*
+ * 3.3 (done in `methodPrimitiveForwarders`) For every method that is declared both
+ * as generic with a primitive type and with a primitive type
+ * `<mods> def f[Ts](ps1)...(psN): U` in trait M` and
+ * `<mods> def f[Ts](ps1)...(psN): V = ...` in implemented in N`
+ * where U is a primitive and V a polymorphic type (or vice versa) needs:
+ *
+ * <mods> def f[Ts](ps1)...(psN): U = super[N].f[Ts](ps1)...(psN)
+ *
* A method in M needs to be disambiguated if it is concrete, not overridden in C,
* and if it overrides another concrete method.
*
@@ -65,7 +73,11 @@ class ResolveSuper extends MiniPhaseTransform with IdentityDenotTransformer { th
for (meth <- mixin.info.decls.toList if needsForwarder(meth))
yield polyDefDef(implementation(meth.asTerm), forwarder(meth))
- val overrides = mixins.flatMap(mixin => superAccessors(mixin) ::: methodOverrides(mixin))
+ def methodPrimitiveForwarders: List[Tree] =
+ for (meth <- mixins.flatMap(_.info.decls.flatMap(needsPrimitiveForwarderTo)).distinct)
+ yield polyDefDef(implementation(meth.asTerm), forwarder(meth))
+
+ val overrides = mixins.flatMap(mixin => superAccessors(mixin) ::: methodOverrides(mixin)) ::: methodPrimitiveForwarders
cpy.Template(impl)(body = overrides ::: impl.body)
}