aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2015-06-23 11:59:28 +0200
committerMartin Odersky <odersky@gmail.com>2015-06-23 12:01:48 +0200
commitffac03ab718637c414f5e23524f458b4f4e8f817 (patch)
treefaf93ef6cd206834c3eba7679c4754befd90f6a2 /src/dotty/tools/dotc
parent890b8a45cc9d83a6ef67fee3ee05084313f34688 (diff)
downloaddotty-ffac03ab718637c414f5e23524f458b4f4e8f817.tar.gz
dotty-ffac03ab718637c414f5e23524f458b4f4e8f817.tar.bz2
dotty-ffac03ab718637c414f5e23524f458b4f4e8f817.zip
Handle normalization of implicit dependent methods.
Now handles included test if toplevel implicit is given, but not yet without.
Diffstat (limited to 'src/dotty/tools/dotc')
-rw-r--r--src/dotty/tools/dotc/typer/ProtoTypes.scala26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/dotty/tools/dotc/typer/ProtoTypes.scala b/src/dotty/tools/dotc/typer/ProtoTypes.scala
index 9a012c30e..13011cb85 100644
--- a/src/dotty/tools/dotc/typer/ProtoTypes.scala
+++ b/src/dotty/tools/dotc/typer/ProtoTypes.scala
@@ -341,7 +341,8 @@ object ProtoTypes {
/** The normalized form of a type
* - unwraps polymorphic types, tracking their parameters in the current constraint
- * - skips implicit parameters
+ * - skips implicit parameters; if result type depends on implicit parameter,
+ * replace with Wildcard.
* - converts non-dependent method types to the corresponding function types
* - dereferences parameterless method types
* - dereferences nullary method types provided the corresponding function type
@@ -356,17 +357,22 @@ object ProtoTypes {
def normalize(tp: Type, pt: Type)(implicit ctx: Context): Type = Stats.track("normalize") {
tp.widenSingleton match {
case poly: PolyType => normalize(constrained(poly).resultType, pt)
- case mt: MethodType if !mt.isDependent /*&& !pt.isInstanceOf[ApplyingProto]*/ =>
- if (mt.isImplicit) mt.resultType
- else {
- val rt = normalize(mt.resultType, pt)
- if (pt.isInstanceOf[ApplyingProto])
- mt.derivedMethodType(mt.paramNames, mt.paramTypes, rt)
+ case mt: MethodType =>
+ if (mt.isImplicit)
+ if (mt.isDependent)
+ mt.resultType.substParams(mt, mt.paramTypes.map(Function.const(WildcardType)))
+ else mt.resultType
+ else
+ if (mt.isDependent) tp
else {
- val ft = defn.FunctionType(mt.paramTypes, rt)
- if (mt.paramTypes.nonEmpty || ft <:< pt) ft else rt
+ val rt = normalize(mt.resultType, pt)
+ if (pt.isInstanceOf[ApplyingProto])
+ mt.derivedMethodType(mt.paramNames, mt.paramTypes, rt)
+ else {
+ val ft = defn.FunctionType(mt.paramTypes, rt)
+ if (mt.paramTypes.nonEmpty || ft <:< pt) ft else rt
+ }
}
- }
case et: ExprType => et.resultType
case _ => tp
}