aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/typer/Inferencing.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/dotty/tools/dotc/typer/Inferencing.scala')
-rw-r--r--src/dotty/tools/dotc/typer/Inferencing.scala13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/typer/Inferencing.scala b/src/dotty/tools/dotc/typer/Inferencing.scala
index b8f0e245b..a9d0b287a 100644
--- a/src/dotty/tools/dotc/typer/Inferencing.scala
+++ b/src/dotty/tools/dotc/typer/Inferencing.scala
@@ -27,8 +27,8 @@ object Inferencing {
* 3. there is an implicit conversion from `tp` to `pt`.
*/
def isCompatible(tp: Type, pt: Type)(implicit ctx: Context): Boolean = (
- tp <:< pt
- || pt.typeSymbol == defn.ByNameParamClass && tp <:< pt.typeArgs.head
+ conforms(tp, pt)
+ || pt.typeSymbol == defn.ByNameParamClass && conforms(tp, pt.typeArgs.head)
|| viewExists(tp, pt))
}
@@ -83,6 +83,10 @@ object Inferencing {
case class PolyProto(nargs: Int, override val resultType: Type) extends UncachedGroundType
+ object AnyFunctionProto extends UncachedGroundType with ProtoType {
+ def isMatchedBy(tp: Type)(implicit ctx: Context) = true
+ }
+
/** The normalized form of a type
* - unwraps polymorphic types, tracking their parameters in the current constraint
* - skips implicit parameters
@@ -131,6 +135,11 @@ object Inferencing {
case tp => tp
}
+ def conforms(tpe: Type, pt: Type)(implicit ctx: Context): Boolean = pt match {
+ case pt: ProtoType => pt.isMatchedBy(tpe)
+ case _ => tpe <:< pt
+ }
+
def checkBounds(args: List[Tree], poly: PolyType, pos: Position)(implicit ctx: Context): Unit = {
}