summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker/Infer.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2010-01-20 00:27:53 +0000
committerPaul Phillips <paulp@improving.org>2010-01-20 00:27:53 +0000
commit08013877acb1155fa46398988efaa2cab21f78ae (patch)
treeb037368cce1f0d0a3623e2b0e43d83b3be2d9832 /src/compiler/scala/tools/nsc/typechecker/Infer.scala
parent556813ccdf7b3d78ef0a43c90699bb552f8a97fe (diff)
downloadscala-08013877acb1155fa46398988efaa2cab21f78ae.tar.gz
scala-08013877acb1155fa46398988efaa2cab21f78ae.tar.bz2
scala-08013877acb1155fa46398988efaa2cab21f78ae.zip
Made some cosmetic but clarity-increasing chang...
Made some cosmetic but clarity-increasing changes to a few files. Primarily, used corresponds where possible rather than zipped.forall. Added isImplicit and isJava to MethodType so the relevant subtypes could be determined without the hideous isInstanceOf checks. Review by odersky.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Infer.scala')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Infer.scala22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
index 4d1b3c83fe..bde84827b2 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
@@ -175,8 +175,10 @@ trait Infer {
tvars map instantiate
}
- def skipImplicit(tp: Type) =
- if (tp.isInstanceOf[ImplicitMethodType]) tp.resultType else tp
+ def skipImplicit(tp: Type) = tp match {
+ case mt: MethodType if mt.isImplicit => mt.resultType
+ case _ => tp
+ }
/** Automatically perform the following conversions on expression types:
* A method type becomes the corresponding function type.
@@ -185,8 +187,8 @@ trait Infer {
* This method seems to be performance critical.
*/
def normalize(tp: Type): Type = tp match {
- case MethodType(params, restpe) if (!restpe.isDependent) =>
- if (tp.isInstanceOf[ImplicitMethodType]) normalize(restpe)
+ case mt @ MethodType(params, restpe) if (!restpe.isDependent) =>
+ if (mt.isImplicit) normalize(restpe)
else functionType(params map (_.tpe), normalize(restpe))
case PolyType(List(), restpe) => // nullary method type
normalize(restpe)
@@ -401,8 +403,8 @@ trait Infer {
isPlausiblyCompatible(mt.resultType, pt)
case ExistentialType(tparams, qtpe) =>
isPlausiblyCompatible(qtpe, pt)
- case MethodType(params, restpe) =>
- if (tp.isInstanceOf[ImplicitMethodType]) isPlausiblyCompatible(restpe, pt)
+ case mt @ MethodType(params, restpe) =>
+ if (mt.isImplicit) isPlausiblyCompatible(restpe, pt)
else pt match {
case TypeRef(pre, sym, args) =>
if (sym.isAliasType) {
@@ -457,8 +459,8 @@ trait Infer {
}
final def normSubType(tp: Type, pt: Type): Boolean = tp match {
- case MethodType(params, restpe) =>
- if (tp.isInstanceOf[ImplicitMethodType]) normSubType(restpe, pt)
+ case mt @ MethodType(params, restpe) =>
+ if (mt.isImplicit) normSubType(restpe, pt)
else pt match {
case TypeRef(pre, sym, args) =>
if (sym.isAliasType) {
@@ -517,8 +519,8 @@ trait Infer {
def isCoercible(tp: Type, pt: Type): Boolean = false
- def isCompatibleArgs(tps: List[Type], pts: List[Type]): Boolean =
- (tps, pts).zipped forall isCompatibleArg
+ def isCompatibleArgs(tps: List[Type], pts: List[Type]) =
+ (tps corresponds pts)(isCompatibleArg) // @PP: corresponds
/* -- Type instantiation------------------------------------------------ */