diff options
author | Martin Odersky <odersky@gmail.com> | 2014-01-26 10:17:00 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2014-01-26 18:52:33 +0100 |
commit | 14021cb5e7c8831c7f64d56b8665b7ca79771601 (patch) | |
tree | 6aea50cd88713b457cf00df008e5906eaf5368ea /src/dotty/tools | |
parent | 8b1cc2270c67157f60111a853680fd4f20418d59 (diff) | |
download | dotty-14021cb5e7c8831c7f64d56b8665b7ca79771601.tar.gz dotty-14021cb5e7c8831c7f64d56b8665b7ca79771601.tar.bz2 dotty-14021cb5e7c8831c7f64d56b8665b7ca79771601.zip |
Special casing of numeric widenings in viewExists
To save time we handle these directly, rather than looking for implicit conversions. Reason: this saves time (looks like 5-10% of frontend), and we know these are always available.
The scheme would be foiled if someone introduced additional implicit conversions between numeric types. We could detect and forbid that.
Diffstat (limited to 'src/dotty/tools')
-rw-r--r-- | src/dotty/tools/dotc/typer/Implicits.scala | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/typer/Implicits.scala b/src/dotty/tools/dotc/typer/Implicits.scala index 397ebec53..8a1b9f554 100644 --- a/src/dotty/tools/dotc/typer/Implicits.scala +++ b/src/dotty/tools/dotc/typer/Implicits.scala @@ -279,7 +279,18 @@ trait Implicits { self: Typer => !from.isError && !to.isError && (ctx.mode is Mode.ImplicitsEnabled) - && (inferView(dummyTreeOfType(from), to)(ctx.fresh.withExploreTyperState).isInstanceOf[SearchSuccess]) + && { 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 _ => + } + inferView(dummyTreeOfType(from), to)(ctx.fresh.withExploreTyperState).isInstanceOf[SearchSuccess] + } ) /** Find an implicit conversion to apply to given tree `from` so that the @@ -300,7 +311,7 @@ trait Implicits { self: Typer => * !!! todo: catch potential cycles */ def inferImplicit(pt: Type, argument: Tree, pos: Position)(implicit ctx: Context): SearchResult = track("inferImplicit") { - ctx.traceIndented(s"search implicit ${pt.show}, arg = ${argument.show}: ${argument.tpe.show}, constraint = ${ctx.typerState.constraint.show}", implicits, show = true) { + ctx.traceIndented(s"search implicit ${pt.show}, arg = ${argument.show}: ${argument.tpe.show}", implicits, show = true) { assert(!pt.isInstanceOf[ExprType]) val isearch = if (ctx.settings.explaintypes.value) new ExplainedImplicitSearch(pt, argument, pos) |