diff options
author | Adriaan Moors <adriaan.moors@typesafe.com> | 2013-07-08 16:05:05 -0700 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@typesafe.com> | 2013-07-08 16:05:05 -0700 |
commit | 72863241ead712ace45071a21b84288959f6ce53 (patch) | |
tree | 2dc6ad982cc7cac0955042f9da9cf59568ee81df /src | |
parent | 9e064f783e7ee42b9d27655e2b15d830f8bae5f0 (diff) | |
parent | ede32ba3421be657a4369b847e60d5fb2b9def14 (diff) | |
download | scala-72863241ead712ace45071a21b84288959f6ce53.tar.gz scala-72863241ead712ace45071a21b84288959f6ce53.tar.bz2 scala-72863241ead712ace45071a21b84288959f6ce53.zip |
Merge pull request #2650 from paulp/issue/6221
SI-6221 inference with Function1 subtypes.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 353e8e4810..0ae68d2ba1 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -2797,16 +2797,11 @@ trait Typers extends Adaptations with Tags { if (numVparams > definitions.MaxFunctionArity) return MaxFunctionArityError(fun) - def decompose(pt: Type): (Symbol, List[Type], Type) = - if ((isFunctionType(pt) || (pt.typeSymbol == PartialFunctionClass && numVparams == 1 && fun.body.isInstanceOf[Match])) && // see bug901 for a reason why next conditions are needed - ( pt.dealiasWiden.typeArgs.length - 1 == numVparams - || fun.vparams.exists(_.tpt.isEmpty) - )) - (pt.typeSymbol, pt.dealiasWiden.typeArgs.init, pt.dealiasWiden.typeArgs.last) - else - (FunctionClass(numVparams), fun.vparams map (x => NoType), WildcardType) - - val (clazz, argpts, respt) = decompose(pt) + val FunctionSymbol = FunctionClass(numVparams) + val (argpts, respt) = pt baseType FunctionSymbol match { + case TypeRef(_, FunctionSymbol, args :+ res) => (args, res) + case _ => (fun.vparams map (_ => NoType), WildcardType) + } if (argpts.lengthCompare(numVparams) != 0) WrongNumberOfParametersError(fun, argpts) else { @@ -2856,7 +2851,7 @@ trait Typers extends Adaptations with Tags { val formals = vparamSyms map (_.tpe) val body1 = typed(fun.body, respt) val restpe = packedType(body1, fun.symbol).deconst.resultType - val funtpe = appliedType(clazz, formals :+ restpe: _*) + val funtpe = appliedType(FunctionSymbol, formals :+ restpe: _*) treeCopy.Function(fun, vparams, body1) setType funtpe } |