summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@epfl.ch>2007-05-15 22:58:06 +0000
committerAdriaan Moors <adriaan.moors@epfl.ch>2007-05-15 22:58:06 +0000
commitc4181de5eb0fd4e2f03a67d3e1c7a13dd90c2860 (patch)
tree00e4b199f3c71ab2d8752c2ccba8161e474c35ba
parentbbe0f5e2284bc52a623290609e0fab33b505e7d7 (diff)
downloadscala-c4181de5eb0fd4e2f03a67d3e1c7a13dd90c2860.tar.gz
scala-c4181de5eb0fd4e2f03a67d3e1c7a13dd90c2860.tar.bz2
scala-c4181de5eb0fd4e2f03a67d3e1c7a13dd90c2860.zip
fixed bug1112
-rw-r--r--src/compiler/scala/tools/nsc/doc/ModelToXML.scala2
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Definitions.scala2
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Types.scala5
-rw-r--r--test/files/neg/bug1112.check4
-rw-r--r--test/files/neg/bug1112.scala14
5 files changed, 23 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/doc/ModelToXML.scala b/src/compiler/scala/tools/nsc/doc/ModelToXML.scala
index 85e6e117a6..234b640546 100644
--- a/src/compiler/scala/tools/nsc/doc/ModelToXML.scala
+++ b/src/compiler/scala/tools/nsc/doc/ModelToXML.scala
@@ -35,7 +35,7 @@ trait ModelToXML extends ModelExtractor {
def link(tpe: Type)(implicit frame: Frame): NodeSeq = {
if (!tpe.typeArgs.isEmpty) {
if (definitions.isFunctionType(tpe)) {
- val (args,r) = tpe.typeArgs.splitAt(tpe.typeArgs.length - 1);
+ val (args,r) = tpe.normalize.typeArgs.splitAt(tpe.normalize.typeArgs.length - 1);
args.mkXML("(", ", ", ")")(link) ++ Text(" => ") ++ link(r.head);
} else if (tpe.symbol == definitions.RepeatedParamClass) {
assert(tpe.typeArgs.length == 1);
diff --git a/src/compiler/scala/tools/nsc/symtab/Definitions.scala b/src/compiler/scala/tools/nsc/symtab/Definitions.scala
index a7f40f84ec..6c663d4e8c 100644
--- a/src/compiler/scala/tools/nsc/symtab/Definitions.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Definitions.scala
@@ -299,7 +299,7 @@ trait Definitions {
case MethodType(delegateParams, delegateReturn) =>
val delegateParamsO = delegateParams.map(pt => {if (pt == definitions.AnyClass.tpe) definitions.ObjectClass.tpe else pt})
if (isFunctionType(functionType))
- functionType match {
+ functionType.normalize match {
case TypeRef(_, _, args) =>
if (delegateParamsO == args.dropRight(1) &&
delegateReturn == args.last)
diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala
index 26134d0087..60e39bcebf 100644
--- a/src/compiler/scala/tools/nsc/symtab/Types.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Types.scala
@@ -1242,8 +1242,9 @@ A type's symbol should never be inspected directly.
override def normalize =
if (sym.isAliasType) {
- if (sym.info.typeParams.length == args.length || !sym.info.isComplete) // beta-reduce -- check if the info has been loaded, if not, the arity check is meaningless
+ if (sym.info.typeParams.length == args.length) // beta-reduce -- check if the info has been loaded, if not, the arity check is meaningless
// Martin to Adriaan: I believe sym.info.isComplete is redundant here
+ // @M: correct: it was a remnant of a previous fix for the problem in the last else {} branch
transform(sym.info.resultType).normalize // cycles have been checked in typeRef
else if (isHigherKinded)
PolyType(typeParams, transform(sym.info.resultType).normalize)
@@ -1303,7 +1304,7 @@ A type's symbol should never be inspected directly.
if (sym == ByNameParamClass && !args.isEmpty)
return "=> " + args(0).toString()
if (isFunctionType(this))
- return args.init.mkString("(", ", ", ")") + " => " + args.last
+ return normalize.typeArgs.init.mkString("(", ", ", ")") + " => " + normalize.typeArgs.last
if (isTupleType(this))
return args.mkString("(", ", ", if (args.length == 1) ",)" else ")")
}
diff --git a/test/files/neg/bug1112.check b/test/files/neg/bug1112.check
new file mode 100644
index 0000000000..3be45a87fe
--- /dev/null
+++ b/test/files/neg/bug1112.check
@@ -0,0 +1,4 @@
+bug1112.scala:12: error: wrong number of arguments for method call: (int)(=> () => unit)unit
+ call(0,() => System.out.println("here we are"))
+ ^
+one error found
diff --git a/test/files/neg/bug1112.scala b/test/files/neg/bug1112.scala
new file mode 100644
index 0000000000..3e108e39af
--- /dev/null
+++ b/test/files/neg/bug1112.scala
@@ -0,0 +1,14 @@
+// checks that error doesn't crash the compiler
+// (due to isFunctionType normalizing Type1 to a function type,
+// but then the code that used that test not using the normalized type for further operations)
+class Test {
+ type Type1 = () => unit
+
+ def call(p: int)(f: => Type1) = {
+ f()
+ }
+
+ def run = {
+ call(0,() => System.out.println("here we are"))
+ }
+} \ No newline at end of file