diff options
author | Martin Odersky <odersky@gmail.com> | 2015-11-03 14:04:45 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2015-11-03 14:04:45 +0100 |
commit | d2ed587d8711bcbeaaf970043e7d80955ada164a (patch) | |
tree | a98c22088a14e9c7ea7e7a718724dfe20ad7ddad /src | |
parent | f2187f3deb90b3584a4e7f3030b1d3b716cac775 (diff) | |
download | dotty-d2ed587d8711bcbeaaf970043e7d80955ada164a.tar.gz dotty-d2ed587d8711bcbeaaf970043e7d80955ada164a.tar.bz2 dotty-d2ed587d8711bcbeaaf970043e7d80955ada164a.zip |
Enable <:< implicits as conversions.
These were disabled before, which means that having evidence
of S <:< T did not introduce a usable implicit conversion from
S to T. We do do it like scalac: just disable Predef.$conforms.
This makes TraversableOnce compile. Fixes #914.
Diffstat (limited to 'src')
-rw-r--r-- | src/dotty/tools/dotc/core/Definitions.scala | 4 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/Implicits.scala | 4 |
2 files changed, 6 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/core/Definitions.scala b/src/dotty/tools/dotc/core/Definitions.scala index a503a2d23..6f322904e 100644 --- a/src/dotty/tools/dotc/core/Definitions.scala +++ b/src/dotty/tools/dotc/core/Definitions.scala @@ -192,6 +192,9 @@ class Definitions { ScalaPackageClass, tpnme.Null, AbstractFinal, List(ObjectClass.typeRef)) lazy val ScalaPredefModule = ctx.requiredModule("scala.Predef") + + lazy val Predef_conforms = ctx.requiredMethod(ScalaPredefModule.moduleClass.asClass, "$conforms") + lazy val ScalaRuntimeModule = ctx.requiredModule("scala.runtime.ScalaRunTime") lazy val ScalaRuntimeClass = ScalaRuntimeModule.moduleClass.asClass @@ -210,7 +213,6 @@ class Definitions { def newRefArrayMethod = ctx.requiredMethod(DottyArraysModule.moduleClass.asClass, "newRefArray") lazy val NilModule = ctx.requiredModule("scala.collection.immutable.Nil") - lazy val PredefConformsClass = ctx.requiredClass("scala.Predef." + tpnme.Conforms) // lazy val FunctionClass: ClassSymbol = ctx.requiredClass("scala.Function") lazy val SingletonClass: ClassSymbol = diff --git a/src/dotty/tools/dotc/typer/Implicits.scala b/src/dotty/tools/dotc/typer/Implicits.scala index e3626fe20..8e4453e4f 100644 --- a/src/dotty/tools/dotc/typer/Implicits.scala +++ b/src/dotty/tools/dotc/typer/Implicits.scala @@ -65,7 +65,9 @@ object Implicits { case tpw => //if (ctx.typer.isApplicable(tp, argType :: Nil, resultType)) // println(i"??? $tp is applicable to $this / typeSymbol = ${tpw.typeSymbol}") - !tpw.derivesFrom(defn.FunctionClass(1)) || tpw.isRef(defn.PredefConformsClass) + !tpw.derivesFrom(defn.FunctionClass(1)) || + ref.symbol == defn.Predef_conforms // + // as an implicit conversion, Predef.$conforms is a no-op, so exclude it } def discardForValueType(tpw: Type): Boolean = tpw match { |