diff options
author | mihaylov <mihaylov@epfl.ch> | 2008-03-12 07:21:34 +0000 |
---|---|---|
committer | mihaylov <mihaylov@epfl.ch> | 2008-03-12 07:21:34 +0000 |
commit | a29fd9c86152dd72b8dc70d38ee66f7f7934f24b (patch) | |
tree | ddb59fc2592d29b7e68bd3e54c485e3d0341829e | |
parent | e717d05c2e0d4585283efb79e3b8c562ad74e3f4 (diff) | |
download | scala-a29fd9c86152dd72b8dc70d38ee66f7f7934f24b.tar.gz scala-a29fd9c86152dd72b8dc70d38ee66f7f7934f24b.tar.bz2 scala-a29fd9c86152dd72b8dc70d38ee66f7f7934f24b.zip |
small code cleanup in a .NET-related method in ...
small code cleanup in a .NET-related method in Definitions
-rw-r--r-- | src/compiler/scala/tools/nsc/symtab/Definitions.scala | 40 |
1 files changed, 14 insertions, 26 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/Definitions.scala b/src/compiler/scala/tools/nsc/symtab/Definitions.scala index 282d1962cb..e76be5a09d 100644 --- a/src/compiler/scala/tools/nsc/symtab/Definitions.scala +++ b/src/compiler/scala/tools/nsc/symtab/Definitions.scala @@ -60,7 +60,7 @@ trait Definitions { var Delegate_scalaCallers: List[Symbol] = List() // Symbol -> (Symbol, Type): scalaCaller -> (scalaMethodSym, DelegateType) // var Delegate_scalaCallerInfos: HashMap[Symbol, (Symbol, Type)] = _ - var Delegate_scalaCallerTargets: HashMap[Symbol, Symbol] = _ + lazy val Delegate_scalaCallerTargets: HashMap[Symbol, Symbol] = new HashMap() // the scala value classes var UnitClass: Symbol = _ @@ -246,28 +246,19 @@ trait Definitions { } def isCorrespondingDelegate(delegateType: Type, functionType: Type): Boolean = { - var isCD: Boolean = false - if (DelegateClass != null && delegateType != null && - isSubType(delegateType, DelegateClass.tpe)) - { - val meth: Symbol = delegateType.member(nme.apply) - meth.tpe match { - case MethodType(delegateParams, delegateReturn) => - val delegateParamsO = delegateParams.map(pt => {if (pt == definitions.AnyClass.tpe) definitions.ObjectClass.tpe else pt}) - if (isFunctionType(functionType)) - functionType.normalize match { - case TypeRef(_, _, args) => - if (delegateParamsO == args.dropRight(1) && - delegateReturn == args.last) - isCD = true; - - case _ => () - } - - case _ => () - } - } - isCD + isSubType(delegateType, DelegateClass.tpe) && + (delegateType.member(nme.apply).tpe match { + case MethodType(delegateParams, delegateReturn) => + isFunctionType(functionType) && + (functionType.normalize match { + case TypeRef(_, _, args) => + (delegateParams.map(pt => { + if (pt == AnyClass.tpe) definitions.ObjectClass.tpe else pt}) + ::: List(delegateReturn)) == args + case _ => false + }) + case _ => false + }) } def seqType(arg: Type) = @@ -806,9 +797,6 @@ trait Definitions { newMethod(StringClass, "replace", List(charType, charType), stringType); newMethod(StringClass, "toCharArray", List(), appliedType(ArrayClass.typeConstructor, List(charType))); - - // Delegate_scalaCallerInfos = new HashMap() - Delegate_scalaCallerTargets = new HashMap() } AnnotationDefaultAttr = newClass(RootClass, |