diff options
author | Gilles Dubochet <gilles.dubochet@epfl.ch> | 2008-02-04 18:51:54 +0000 |
---|---|---|
committer | Gilles Dubochet <gilles.dubochet@epfl.ch> | 2008-02-04 18:51:54 +0000 |
commit | 87609b42414616a3ec1f0f2f2007f3061fa7f886 (patch) | |
tree | 3d5a8a45fe207e13f18f4d46911aa7ce5050b519 /src/compiler | |
parent | 644350e3ca3e3298de932d08affbe4b8ed69cc3e (diff) | |
download | scala-87609b42414616a3ec1f0f2f2007f3061fa7f886.tar.gz scala-87609b42414616a3ec1f0f2f2007f3061fa7f886.tar.bz2 scala-87609b42414616a3ec1f0f2f2007f3061fa7f886.zip |
Fixed issues #328 and #403.
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/nsc/symtab/Definitions.scala | 2 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/symtab/StdNames.scala | 1 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/CleanUp.scala | 32 |
3 files changed, 24 insertions, 11 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/Definitions.scala b/src/compiler/scala/tools/nsc/symtab/Definitions.scala index d31092d6b4..2528181e0e 100644 --- a/src/compiler/scala/tools/nsc/symtab/Definitions.scala +++ b/src/compiler/scala/tools/nsc/symtab/Definitions.scala @@ -50,6 +50,8 @@ trait Definitions { lazy val ThrowableClass: Symbol = getClass(sn.Throwable) lazy val NullPointerExceptionClass: Symbol = getClass(sn.NPException) lazy val NonLocalReturnExceptionClass: Symbol = getClass(sn.NLRException) + lazy val InvocationTargetExceptionClass: Symbol = + getClass("java.lang.reflect.InvocationTargetException") // java is hard coded because only used by structural values // System.ValueType lazy val ValueTypeClass: Symbol = getClass(sn.ValueType) diff --git a/src/compiler/scala/tools/nsc/symtab/StdNames.scala b/src/compiler/scala/tools/nsc/symtab/StdNames.scala index 1a2921bc1c..f3953792f3 100644 --- a/src/compiler/scala/tools/nsc/symtab/StdNames.scala +++ b/src/compiler/scala/tools/nsc/symtab/StdNames.scala @@ -282,6 +282,7 @@ trait StdNames { val forName = newTermName(if (forMSIL) "GetType" else "forName") val foreach = newTermName("foreach") val get = newTermName("get") + val getCause = newTermName("getCause") val getClass_ = newTermName("getClass") val getMethod_ = newTermName("getMethod") val hasAsInstance = newTermName("hasAsInstance") diff --git a/src/compiler/scala/tools/nsc/transform/CleanUp.scala b/src/compiler/scala/tools/nsc/transform/CleanUp.scala index ea6e66344b..20b1e0d664 100644 --- a/src/compiler/scala/tools/nsc/transform/CleanUp.scala +++ b/src/compiler/scala/tools/nsc/transform/CleanUp.scala @@ -121,7 +121,7 @@ abstract class CleanUp extends Transform { } val rmmeth = owner.newMethod(pos, unit.fresh.newName("reflMethod$Method")) - .setFlag(PRIVATE | STATIC | SYNTHETIC) + .setFlag(STATIC | SYNTHETIC) .setInfo(MethodType(List(ClassClass.tpe), MethodClass.tpe)) owner.info.decls.enter(rmmeth) val rmmdef = @@ -409,18 +409,28 @@ abstract class CleanUp extends Transform { } def callAsMethod(paramTypes: List[Type], resType: Type): Tree = localTyper.typed { - Apply( - Select( - Apply( - gen.mkAttributedRef(reflectiveMethodCache(tree.pos, ad.symbol.name.toString, paramTypes)), - List(Apply(Select(qual, ObjectClass.tpe.member(nme.getClass_)), Nil)) + val invokeExc = + currentOwner.newValue(tree.pos, newTermName(unit.fresh.newName)) setInfo InvocationTargetExceptionClass.tpe + Try( + Apply( + Select( + Apply( + gen.mkAttributedRef(reflectiveMethodCache(tree.pos, ad.symbol.name.toString, paramTypes)), + List(Apply(Select(qual, ObjectClass.tpe.member(nme.getClass_)), Nil)) + ), + MethodClass.tpe.member(nme.invoke_) ), - MethodClass.tpe.member(nme.invoke_) + List( + qual, + ArrayValue(TypeTree(ObjectClass.tpe), fixParams(params, paramTypes)) + ) ), - List( - qual, - ArrayValue(TypeTree(ObjectClass.tpe), fixParams(params, paramTypes)) - ) + List(CaseDef( + Bind(invokeExc, Typed(Ident(nme.WILDCARD), TypeTree(InvocationTargetExceptionClass.tpe))), + EmptyTree, + Throw(Apply(Select(Ident(invokeExc), nme.getCause), Nil)) + )), + EmptyTree ) } |