aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorodersky <odersky@gmail.com>2015-06-21 13:01:13 +0200
committerodersky <odersky@gmail.com>2015-06-21 13:01:13 +0200
commita654d206d80e3f88cbd79f71ca84ac842988527f (patch)
tree03ea276366652b6b84f3e2cdd76dee9a7a9b6693
parentbb75d4039ee127dfee2630609924f7f3c9132ff6 (diff)
parent0c60f215a1afb225330d01b2bed47bef20cb7bd2 (diff)
downloaddotty-a654d206d80e3f88cbd79f71ca84ac842988527f.tar.gz
dotty-a654d206d80e3f88cbd79f71ca84ac842988527f.tar.bz2
dotty-a654d206d80e3f88cbd79f71ca84ac842988527f.zip
Merge pull request #674 from dotty-staging/fix/#655-eta-expansion
Fix/#655 eta expansion
-rw-r--r--src/dotty/tools/dotc/core/Types.scala13
-rw-r--r--src/dotty/tools/dotc/typer/EtaExpansion.scala4
-rw-r--r--src/dotty/tools/dotc/typer/Implicits.scala19
-rw-r--r--tests/run/t5610a.check (renamed from tests/pending/run/t5610a.check)0
-rw-r--r--tests/run/t5610a.scala (renamed from tests/pending/run/t5610a.scala)0
5 files changed, 19 insertions, 17 deletions
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala
index ba39e7bef..026e69539 100644
--- a/src/dotty/tools/dotc/core/Types.scala
+++ b/src/dotty/tools/dotc/core/Types.scala
@@ -601,6 +601,19 @@ object Types {
ctx.typeComparer.isSameType(this, that)
}
+ /** Is this type a primitive value type which can be widened to the primitive value type `that`? */
+ def isValueSubType(that: Type)(implicit ctx: Context) = widenExpr match {
+ case self: TypeRef if defn.ScalaValueClasses contains self.symbol =>
+ that.widenExpr match {
+ case that: TypeRef if defn.ScalaValueClasses contains that.symbol =>
+ defn.isValueSubClass(self.symbol, that.symbol)
+ case _ =>
+ false
+ }
+ case _ =>
+ false
+ }
+
/** Is this type a legal type for a member that overrides another
* member of type `that`? This is the same as `<:<`, except that
* the types ()T and => T are identified, and T is seen as overriding
diff --git a/src/dotty/tools/dotc/typer/EtaExpansion.scala b/src/dotty/tools/dotc/typer/EtaExpansion.scala
index 1c0e6a11f..4fa3d78eb 100644
--- a/src/dotty/tools/dotc/typer/EtaExpansion.scala
+++ b/src/dotty/tools/dotc/typer/EtaExpansion.scala
@@ -57,8 +57,8 @@ object EtaExpansion {
/** Lift arguments that are not-idempotent into ValDefs in buffer `defs`
* and replace by the idents of so created ValDefs.
*/
- def liftArgs(defs: mutable.ListBuffer[Tree], methType: Type, args: List[Tree])(implicit ctx: Context) =
- methType match {
+ def liftArgs(defs: mutable.ListBuffer[Tree], methRef: Type, args: List[Tree])(implicit ctx: Context) =
+ methRef.widen match {
case MethodType(paramNames, paramTypes) =>
(args, paramNames, paramTypes).zipped map { (arg, name, tp) =>
if (tp.isInstanceOf[ExprType]) arg
diff --git a/src/dotty/tools/dotc/typer/Implicits.scala b/src/dotty/tools/dotc/typer/Implicits.scala
index 841390ef1..43d93b2b8 100644
--- a/src/dotty/tools/dotc/typer/Implicits.scala
+++ b/src/dotty/tools/dotc/typer/Implicits.scala
@@ -382,21 +382,10 @@ trait Implicits { self: Typer =>
&& !to.isError
&& !ctx.isAfterTyper
&& (ctx.mode is Mode.ImplicitsEnabled)
- && { from.widenExpr match {
- case from: TypeRef if defn.ScalaValueClasses contains from.symbol =>
- to.widenExpr match {
- case to: TypeRef if defn.ScalaValueClasses contains to.symbol =>
- util.Stats.record("isValueSubClass")
- return defn.isValueSubClass(from.symbol, to.symbol)
- case _ =>
- }
- case from: ValueType =>
- ;
- case _ =>
- return false
- }
- inferView(dummyTreeOfType(from), to)(ctx.fresh.setExploreTyperState).isInstanceOf[SearchSuccess]
- }
+ && from.isInstanceOf[ValueType]
+ && ( from.isValueSubType(to)
+ || inferView(dummyTreeOfType(from), to)(ctx.fresh.setExploreTyperState).isInstanceOf[SearchSuccess]
+ )
)
/** Find an implicit conversion to apply to given tree `from` so that the
diff --git a/tests/pending/run/t5610a.check b/tests/run/t5610a.check
index 2aa46b3b9..2aa46b3b9 100644
--- a/tests/pending/run/t5610a.check
+++ b/tests/run/t5610a.check
diff --git a/tests/pending/run/t5610a.scala b/tests/run/t5610a.scala
index 3787c0984..3787c0984 100644
--- a/tests/pending/run/t5610a.scala
+++ b/tests/run/t5610a.scala