Permalink
Browse files

A band-aid solution for SI-5803.

Since ae5ff66, resetAttrs duplicates trees, which doesn't preserve ApplyConstructor.
My attempt to modify TreeCopier to do so proved trickier than expected.

In any case, ApplyConstructor is not long for this world, and is only used in tree printing
to distinguish `new X` from regular Apply trees, so this should suffice pending full surgery.
  • Loading branch information...
retronym committed May 17, 2012
1 parent 9fe251e commit c09bd7cbe853062853fab0692da1f54135fdbd38
Showing with 10 additions and 1 deletion.
  1. +2 −1 src/compiler/scala/tools/nsc/ast/Trees.scala
  2. +4 −0 test/files/neg/t5803.check
  3. +4 −0 test/files/neg/t5803.scala
@@ -362,7 +362,8 @@ trait Trees extends reflect.internal.Trees { self: Global =>
}
val x1 = new Transformer().transform(x)
- assert(x.getClass isInstance x1, x1.getClass)
+ // The loose invariant is a temporary workaround for SI-5803
+ assert(x.getClass.isInstance(x1) || (x.isInstanceOf[ApplyConstructor] && x1.isInstanceOf[Apply]), (x.getClass, x1.getClass))
x1.asInstanceOf[T]
}
}
@@ -0,0 +1,4 @@
+t5803.scala:3: error: could not find implicit value for parameter ev: Nothing
+ new Foo(): String
+ ^
+one error found
@@ -0,0 +1,4 @@
+object Test {
+ class Foo()(implicit ev: Nothing)
+ new Foo(): String
+}

0 comments on commit c09bd7c

Please sign in to comment.