Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 450298 | Differences between
and this patch

Collapse All | Expand All

(-)a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala (-2 / +11 lines)
Lines 626-632 abstract class ClassfileParser { Link Here
626
        sawPrivateConstructor = true
626
        sawPrivateConstructor = true
627
      in.skip(2); skipAttributes()
627
      in.skip(2); skipAttributes()
628
    } else {
628
    } else {
629
      if ((sflags & PRIVATE) != 0L && global.settings.optimise.value) {
629
      if ((sflags & PRIVATE) != 0L && global.settings.optimise.value) { // TODO this should be !optimize, no? See c4181f656d.
630
        in.skip(4); skipAttributes()
630
        in.skip(4); skipAttributes()
631
      } else {
631
      } else {
632
        val name = pool.getName(in.nextChar)
632
        val name = pool.getName(in.nextChar)
Lines 636-642 abstract class ClassfileParser { Link Here
636
          info match {
636
          info match {
637
            case MethodType(params, restpe) =>
637
            case MethodType(params, restpe) =>
638
              // if this is a non-static inner class, remove the explicit outer parameter
638
              // if this is a non-static inner class, remove the explicit outer parameter
639
              val newParams = innerClasses getEntry currentClass match {
639
              val paramsNoOuter = innerClasses getEntry currentClass match {
640
                case Some(entry) if !isScalaRaw && !isStatic(entry.jflags) =>
640
                case Some(entry) if !isScalaRaw && !isStatic(entry.jflags) =>
641
                  /* About `clazz.owner.isPackage` below: SI-5957
641
                  /* About `clazz.owner.isPackage` below: SI-5957
642
                   * For every nested java class A$B, there are two symbols in the scala compiler.
642
                   * For every nested java class A$B, there are two symbols in the scala compiler.
Lines 650-655 abstract class ClassfileParser { Link Here
650
                case _ =>
650
                case _ =>
651
                  params
651
                  params
652
              }
652
              }
653
              val newParams = paramsNoOuter match {
654
                case (init :+ tail) if (jflags & JAVA_ACC_SYNTHETIC) != 0L =>
655
                  // SI-7455 strip trailing dummy argument ("access constructor tag") from synthetic constructors which
656
                  // are added when an inner class needs to access a private constructor.
657
                  init
658
                case _ =>
659
                  paramsNoOuter
660
              }
661
653
              info = MethodType(newParams, clazz.tpe)
662
              info = MethodType(newParams, clazz.tpe)
654
          }
663
          }
655
        sym.setInfo(info)
664
        sym.setInfo(info)
(-)a/test/files/run/t7455.check (+4 lines)
Line 0 Link Here
1
private[package <empty>] def <init>(x$1: String): Outer[E]
2
private[package <empty>] def <init>(): Outer$PrivateInner
3
private[package <empty>] def <init>(): Outer$PrivateStaticInner
4
private[package <empty>] def <init>(x$2: String): Outer$PublicInner
(-)a/test/files/run/t7455/Outer.java (+31 lines)
Line 0 Link Here
1
public class Outer<E> {
2
    public void elements() {
3
        new C<E>() {
4
        };
5
    }
6
7
    private Outer(String a) {}
8
9
    static class SubSelf extends Outer<String> {
10
        public SubSelf() { super(""); }
11
    }
12
13
    private class PrivateInner {
14
    }
15
    class SubPrivateInner extends PrivateInner {
16
    }
17
18
    private class PublicInner {
19
        private PublicInner(String a) {}
20
    }
21
    class SubPublicInner extends PublicInner {
22
        public SubPublicInner() { super(""); }
23
    }
24
25
    private static class PrivateStaticInner {
26
    }
27
    public static class SubPrivateStaticInner extends PrivateStaticInner {
28
    }
29
}
30
31
class C<E> {}
(-)a/test/files/run/t7455/Test.scala (+30 lines)
Line 0 Link Here
1
import scala.tools.partest._
2
3
// javac adds dummy parameters of type Outer$1 to synthetic access constructors
4
// This test shows that we strip them from the signatures. If we don't, we trigger
5
// parsing of Outer$1 which can fail if it references type parameters of the Outer.
6
//
7
// OLD OUTPUT:
8
//  private[package <empty>] def <init>(x$2: Outer$1): Outer$PrivateInner
9
//  error: error while loading Outer$1, class file 't7455-run.obj/Outer$1.class' is broken
10
//  (class java.util.NoSuchElementException/key not found: E)
11
//  ...
12
object Test extends DirectTest {
13
  override def code = ""
14
15
  def show {
16
    val classpath = List(sys.props("partest.lib"), testOutput.path) mkString sys.props("path.separator")
17
    val compiler = newCompiler("-cp", classpath, "-d", testOutput.path)
18
    import compiler._, definitions._
19
    new compiler.Run
20
21
    for {
22
      name <- Seq("Outer", "Outer$PrivateInner", "Outer$PrivateStaticInner", "Outer$PublicInner")
23
      clazz = compiler.rootMirror.staticClass(name)
24
      constr <- clazz.info.member(nme.CONSTRUCTOR).alternatives
25
    } {
26
      println(constr.defString)
27
      fullyInitializeSymbol(constr)
28
    }
29
  }
30
}

Return to bug 450298