From 51f574ac9ff0dbcb665f48a8c1a380c59f2bb641 Mon Sep 17 00:00:00 2001 From: Adriaan Moors Date: Thu, 10 Jan 2013 13:25:33 -0800 Subject: clean up synthesizePartialFunction implement the following review comments by @retronym: - [x] Please clothe this naked assert. - [x] Use match to dissect targs and check isFullyDefined. - [x] Instead of `targs.head`/`targs.last`, use `val argTp :: resTp :: Nil = targs`. - [x] Add a quasi-quote-style comment for `apply`. - [x] Factor out mkCastPreservingAnnotations. --- src/compiler/scala/tools/nsc/ast/TreeGen.scala | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/compiler/scala/tools/nsc/ast/TreeGen.scala') diff --git a/src/compiler/scala/tools/nsc/ast/TreeGen.scala b/src/compiler/scala/tools/nsc/ast/TreeGen.scala index 5cb43575b8..96146b7343 100644 --- a/src/compiler/scala/tools/nsc/ast/TreeGen.scala +++ b/src/compiler/scala/tools/nsc/ast/TreeGen.scala @@ -253,6 +253,11 @@ abstract class TreeGen extends scala.reflect.internal.TreeGen with TreeDSL { } } + // drop annotations generated by CPS plugin etc, since its annotationchecker rejects T @cps[U] <: Any + // let's assume for now annotations don't affect casts, drop them there, and bring them back using the outer Typed tree + def mkCastPreservingAnnotations(tree: Tree, pt: Type) = + Typed(mkCast(tree, pt.withoutAnnotations.dealias), TypeTree(pt)) + /** Generate a cast for tree Tree representing Array with * elem type elemtp to expected type pt. */ -- cgit v1.2.3