aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGuillaume Martres <smarter@ubuntu.com>2016-01-12 23:00:57 +0100
committerGuillaume Martres <smarter@ubuntu.com>2016-05-31 16:53:33 +0200
commit8d0312f69966fbfcfc2f9602ccf660dfe7513885 (patch)
tree884e1b2373e6a7baa22f2affbb14270e4aef2dba /src
parent5c2a19bfbbb158c809969fa2a9685b5c7e2695ea (diff)
downloaddotty-8d0312f69966fbfcfc2f9602ccf660dfe7513885.tar.gz
dotty-8d0312f69966fbfcfc2f9602ccf660dfe7513885.tar.bz2
dotty-8d0312f69966fbfcfc2f9602ccf660dfe7513885.zip
Avoid creating AndTypes with Any
This reduces the number of implicit scopes we cache.
Diffstat (limited to 'src')
-rw-r--r--src/dotty/tools/dotc/core/Types.scala7
-rw-r--r--src/dotty/tools/dotc/typer/Implicits.scala2
2 files changed, 7 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala
index 42079b4b8..f514a329e 100644
--- a/src/dotty/tools/dotc/core/Types.scala
+++ b/src/dotty/tools/dotc/core/Types.scala
@@ -2145,7 +2145,12 @@ object Types {
unique(new CachedAndType(tp1, tp2))
}
def make(tp1: Type, tp2: Type)(implicit ctx: Context): Type =
- if (tp1 eq tp2) tp1 else apply(tp1, tp2)
+ if ((tp1 eq tp2) || (tp2 eq defn.AnyType))
+ tp1
+ else if (tp1 eq defn.AnyType)
+ tp2
+ else
+ apply(tp1, tp2)
}
abstract case class OrType(tp1: Type, tp2: Type) extends CachedGroundType with AndOrType {
diff --git a/src/dotty/tools/dotc/typer/Implicits.scala b/src/dotty/tools/dotc/typer/Implicits.scala
index 257828fb3..b59d177b1 100644
--- a/src/dotty/tools/dotc/typer/Implicits.scala
+++ b/src/dotty/tools/dotc/typer/Implicits.scala
@@ -287,7 +287,7 @@ trait ImplicitRunInfo { self: RunInfo =>
case tp: TypeRef if tp.symbol.isAbstractOrAliasType =>
val pre = tp.prefix
def joinClass(tp: Type, cls: ClassSymbol) =
- AndType(tp, cls.typeRef.asSeenFrom(pre, cls.owner))
+ AndType.make(tp, cls.typeRef.asSeenFrom(pre, cls.owner))
val lead = if (tp.prefix eq NoPrefix) defn.AnyType else apply(tp.prefix)
(lead /: tp.classSymbols)(joinClass)
case tp: TypeVar =>