summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@epfl.ch>2007-05-07 12:22:56 +0000
committerAdriaan Moors <adriaan.moors@epfl.ch>2007-05-07 12:22:56 +0000
commit5be9ee030535a806c3f2467d8af1962b4131062a (patch)
treec26d5dc88f188a53838d2f152af0964348a7f421
parente5813a6b343943b574b6e8c81bda5567e3c7e2e0 (diff)
downloadscala-5be9ee030535a806c3f2467d8af1962b4131062a.tar.gz
scala-5be9ee030535a806c3f2467d8af1962b4131062a.tar.bz2
scala-5be9ee030535a806c3f2467d8af1962b4131062a.zip
fixed bug1090
widen now only normalizes when necessary
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Types.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Infer.scala6
-rw-r--r--test/files/pos/bug1090.scala16
3 files changed, 21 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala
index 9f10ab994b..156f79617e 100644
--- a/src/compiler/scala/tools/nsc/symtab/Types.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Types.scala
@@ -1206,7 +1206,7 @@ A type's symbol should never be inspected directly.
else if (isHigherKinded)
PolyType(typeParams, transform(sym.info.resultType).normalize)
else {
- log("Error: normalizing "+sym.rawname+" with mismatch between type params "+sym.info.typeParams+" and args "+args)
+ //log("Error: normalizing "+sym.rawname+" with mismatch between type params "+sym.info.typeParams+" and args "+args)
//this
transform(sym.info.resultType).normalize // technically wrong, but returning `this' is even worse (cycle!)
// only happens when compiling `val x: Class' with -Xgenerics,
diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
index 0cee1b1bba..39f8893fbd 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
@@ -860,9 +860,11 @@ trait Infer {
}
/** Type with all top-level occurrences of abstract types replaced by their bounds */
- def widen(tp: Type): Type = tp.normalize match {
- case TypeRef(pre, sym, _) if sym.isAbstractType =>
+ def widen(tp: Type): Type = tp match { // @M don't normalize here (compiler loops on pos/bug1090.scala )
+ case TypeRef(_, sym, _) if sym.isAbstractType =>
widen(tp.bounds.hi)
+ case TypeRef(_, sym, _) if sym.isAliasType =>
+ widen(tp.normalize)
case rtp @ RefinedType(parents, decls) =>
copyRefinedType(rtp, List.mapConserve(parents)(widen), decls)
case _ =>
diff --git a/test/files/pos/bug1090.scala b/test/files/pos/bug1090.scala
new file mode 100644
index 0000000000..69f757fe34
--- /dev/null
+++ b/test/files/pos/bug1090.scala
@@ -0,0 +1,16 @@
+object Test {
+ trait Manager {
+ type Node;
+ def elements : Iterator[Node]
+ }
+ trait Core {
+ type Node;
+ trait NodeImpl
+ trait Manager extends Test.Manager {
+ type Node = Core.this.Node
+ }
+ def f(manager : Manager) = manager.elements.foreach{
+ case node : NodeImpl =>
+ }
+ }
+} \ No newline at end of file