From ed8326a3981ea9a8206dd44a63e2160c234c098f Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Tue, 18 Dec 2007 13:41:35 +0000 Subject: made Typers more lenient wrt to redundant type ... made Typers more lenient wrt to redundant type parameters --- src/compiler/scala/tools/nsc/typechecker/Typers.scala | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 61f383c240..2e3290c8d1 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -66,6 +66,10 @@ trait Typers { self: Analyzer => sym } + /** when in 1.4 mode the compiler accepts and ignores useless + * type parameters of Java generics + */ + def onePointFourMode = true // todo changeto: settings.target.value == "jvm-1.4" // Mode constants @@ -2007,7 +2011,7 @@ trait Typers { self: Analyzer => } } } - for (t <- tp) { + for (t <- tp) { t match { case ExistentialType(tparams, _) => boundSyms ++= tparams @@ -2032,7 +2036,7 @@ trait Typers { self: Analyzer => } object substLocals extends TypeMap { - override val dropNonConstraintAnnotations = true + override val dropNonConstraintAnnotations = true def apply(t: Type): Type = t match { case TypeRef(_, sym, args) if (sym.isLocal && args.length > 0) => @@ -2844,7 +2848,8 @@ trait Typers { self: Analyzer => }} TypeTree(owntype) setOriginal(tree) // setPos tree.pos } else if (tparams.length == 0) { - errorTree(tree, tpt1.tpe+" does not take type parameters") + if (onePointFourMode && (tpt1.symbol hasFlag JAVA)) tpt1 + else errorTree(tree, tpt1.tpe+" does not take type parameters") } else { //Console.println("\{tpt1}:\{tpt1.symbol}:\{tpt1.symbol.info}") if (settings.debug.value) Console.println(tpt1+":"+tpt1.symbol+":"+tpt1.symbol.info);//debug -- cgit v1.2.3