summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorLukas Rytz <lukas.rytz@epfl.ch>2010-03-31 16:56:40 +0000
committerLukas Rytz <lukas.rytz@epfl.ch>2010-03-31 16:56:40 +0000
commitf32f87226959f9def3e3e14725898bd3c39840f8 (patch)
tree92864651e64d699ea49c3de678fafea1749b800f /src/compiler
parent469dc5ebf005e980e26f6122093fd550c15ebb98 (diff)
downloadscala-f32f87226959f9def3e3e14725898bd3c39840f8.tar.gz
scala-f32f87226959f9def3e3e14725898bd3c39840f8.tar.bz2
scala-f32f87226959f9def3e3e14725898bd3c39840f8.zip
close #3183. review by community
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/tools/nsc/ast/TreeGen.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala22
2 files changed, 16 insertions, 8 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/TreeGen.scala b/src/compiler/scala/tools/nsc/ast/TreeGen.scala
index 13f26412a3..9f2065f297 100644
--- a/src/compiler/scala/tools/nsc/ast/TreeGen.scala
+++ b/src/compiler/scala/tools/nsc/ast/TreeGen.scala
@@ -192,7 +192,7 @@ abstract class TreeGen
mkTypeApply(value, tpe, (if (any) Any_asInstanceOf else Object_asInstanceOf))
def mkClassOf(tp: Type): Tree =
- Literal(Constant(tp)) setType ClassType(tp)
+ Literal(Constant(tp)) setType ConstantType(Constant(tp))// ClassType(tp)
def mkCheckInit(tree: Tree): Tree = {
val tpe =
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 2a8fcb8a68..e7410690a2 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -2640,15 +2640,23 @@ trait Typers { self: Analyzer =>
None
} else Some(NestedAnnotArg(annInfo))
- // use of: object Array.apply[A <: AnyRef](args: A*): Array[A] = ...
- // and object Array.apply(args: Int*): Array[Int] = ... (and similar)
- case Apply(fun, members) =>
+ // use of Array.apply[T: ClassManifest](xs: T*): Array[T]
+ // and Array.apply(x: Int, xs: Int*): Array[Int] (and similar)
+ case Apply(fun, args) =>
val typedFun = typed(fun, funMode(mode), WildcardType)
if (typedFun.symbol.owner == ArrayModule.moduleClass &&
- typedFun.symbol.name == nme.apply &&
- pt.typeSymbol == ArrayClass &&
- !pt.typeArgs.isEmpty)
- trees2ConstArg(members, pt.typeArgs.head)
+ typedFun.symbol.name == nme.apply)
+ pt match {
+ case TypeRef(_, sym, argts) if (sym == ArrayClass && !argts.isEmpty) =>
+ trees2ConstArg(args, argts.head)
+ case _ =>
+ // For classfile annotations, pt can only be T:
+ // BT = Int, .., String, Class[_], JavaAnnotClass
+ // T = BT | Array[BT]
+ // So an array literal as argument can only be valid if pt is Array[_]
+ error(tree.pos, "found array constant, expected argument of type "+ pt)
+ None
+ }
else
tryConst(tree, pt)