aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-01-03 15:28:51 +0100
committerMartin Odersky <odersky@gmail.com>2014-01-03 15:28:51 +0100
commit2023b940f0ec91705d9fd8017fa08d59aa11ac99 (patch)
treefa099bb13e7174c5fbe906fab50ba6ca6aacd30f /src
parentc81a21a8ecc690813bbe4eaece0640f262434f84 (diff)
downloaddotty-2023b940f0ec91705d9fd8017fa08d59aa11ac99.tar.gz
dotty-2023b940f0ec91705d9fd8017fa08d59aa11ac99.tar.bz2
dotty-2023b940f0ec91705d9fd8017fa08d59aa11ac99.zip
Making namedPartsWith more robust.
When called from implicitScope, we formed an AndType with a WildcardType. No problem, except that this broke the AndType assertion. The assertion is not needed for this sepcial case.
Diffstat (limited to 'src')
-rw-r--r--src/dotty/tools/dotc/core/Types.scala8
-rw-r--r--src/dotty/tools/dotc/typer/Inferencing.scala2
2 files changed, 7 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala
index a3639cbde..8fe813e4d 100644
--- a/src/dotty/tools/dotc/core/Types.scala
+++ b/src/dotty/tools/dotc/core/Types.scala
@@ -1385,7 +1385,6 @@ object Types {
}
abstract case class AndType(tp1: Type, tp2: Type) extends CachedGroundType with AndOrType {
- assert(tp1.isInstanceOf[ValueType] && tp2.isInstanceOf[ValueType], s"$tp1 & $tp2")
def derivedAndType(tp1: Type, tp2: Type)(implicit ctx: Context) =
if ((tp1 eq this.tp1) && (tp2 eq this.tp2)) this
@@ -1397,8 +1396,13 @@ object Types {
final class CachedAndType(tp1: Type, tp2: Type) extends AndType(tp1, tp2)
object AndType {
- def apply(tp1: Type, tp2: Type)(implicit ctx: Context) =
+ def apply(tp1: Type, tp2: Type)(implicit ctx: Context) = {
+ assert(tp1.isInstanceOf[ValueType] && tp2.isInstanceOf[ValueType], s"$tp1 & $tp2")
+ unchecked(tp1, tp2)
+ }
+ def unchecked(tp1: Type, tp2: Type)(implicit ctx: Context) = {
unique(new CachedAndType(tp1, tp2))
+ }
}
abstract case class OrType(tp1: Type, tp2: Type) extends CachedGroundType with AndOrType {
diff --git a/src/dotty/tools/dotc/typer/Inferencing.scala b/src/dotty/tools/dotc/typer/Inferencing.scala
index 76e701fee..b85b7b6ca 100644
--- a/src/dotty/tools/dotc/typer/Inferencing.scala
+++ b/src/dotty/tools/dotc/typer/Inferencing.scala
@@ -140,7 +140,7 @@ object Inferencing {
ctx.typer.isApplicable(tp, argType :: Nil, resultType)
}
override def namedPartsWith(p: NamedType => Boolean)(implicit ctx: Context): collection.Set[NamedType] =
- AndType(argType, resultType).namedPartsWith(p) // this is more efficient than oring two namedParts sets
+ AndType.unchecked(argType, resultType).namedPartsWith(p) // this is more efficient than oring two namedParts sets
override def computeHash = doHash(argType, resultType)
}