Skip to content

Fix #2156 #2158

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 31, 2017
Merged

Fix #2156 #2158

merged 6 commits into from
Mar 31, 2017

Conversation

DarkDimius
Copy link
Contributor

New testing infrastructure seems to deadlock on my machine so I can't test stuff.
Using CI instead.

ThisType doesn't have a termSymbol.
And the check is actually too strong,
and not needed.
@DarkDimius DarkDimius requested a review from odersky March 30, 2017 19:56
@DarkDimius
Copy link
Contributor Author

exception caught when loading class Class: dotty.tools.FatalError: Unexpected ClassRep 'ClassRep(Some(/usr/lib/jvm/java-1.8-openjdk/jre/lib/rt.jar(java/lang/Class$ReflectionData.class)),None)' found searching for name 'lang.Class$ReflectionData'

Does our CI work?

@DarkDimius
Copy link
Contributor Author

ping @felixmulder

@felixmulder
Copy link
Contributor

felixmulder commented Mar 30, 2017

deadlock in runAll?

You can get the old behaviour back by doing:

> set testOptions in LocalProject("dotty-compiler") += Tests.Argument(TestFrameworks.JUnit, "--exclude-categories=dotty.tools.dotc.ParallelTesting")
> set testOptions in LocalProject("dotty-compiler-bootstrapped") += Tests.Argument(TestFrameworks.JUnit, "--exclude-categories=dotty.tools.dotc.ParallelTesting")

EDIT: this will ignore the new test framework tests.

@felixmulder
Copy link
Contributor

felixmulder commented Mar 30, 2017

CI should be fine, at least the first 4 tests - they are unchanged. The two last tests are new.

Also, regarding your error - the stacktrace says that it it's in:

dotty.tools.dotc.core.classfile.ClassfileParser.enterOwnInnerClasses(ClassfileParser.scala:669)

@DarkDimius
Copy link
Contributor Author

@felixmulder, I cant reproduce the error locally and it fails in tests which don't have pattern matching at all, e.g. dotty.tools.ShowClassTests.loadDotty has nothing to do with with it, it doesn't even run compilation pipeline.

@DarkDimius
Copy link
Contributor Author

Or, dotty.tools.dotc.parsing.DocstringTests.multipleDocStringsBeforeAndAfter, which as you know, only runs parser.

@felixmulder
Copy link
Contributor

But it's failing in the bootstrapped version of Dotty.

I'll try to reproduce, 2 secs

@DarkDimius
Copy link
Contributor Author

@felixmulder, I've found the issue. No need for you to investigate anymore.

@DarkDimius
Copy link
Contributor Author

Bringing back #2156 into discussion.

@felixmulder
Copy link
Contributor

Alright, then I'm going to bed 👍

case x: ClassRep => x
case x => throw new FatalError("Unexpected ClassRep '%s' found searching for name '%s'".format(x, name))
case x: AnyClassRep => x
case x => throw new FatalError("Unexpected ClassRep '%s' found searching for name '%s'".format(x, name))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rep is an AnyClassRep so this case will never happen. I believe the original code intended to check the outer pointer, though I have no idea why, here's the commit that introduced the check: scala/scala@a1a6ab9

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code compiled by scalac doesn't contain the check:

option = rep.map((Function1)new Serializable(this, name){
                public static final long serialVersionUID = 0;
                private final String name$2;

                public final ClassRep apply(ClassRep x0$1) {
                    ClassRep classRep = x0$1;
                    if (classRep instanceof ClassRep) {
                        ClassRep classRep2;
                        ClassRep classRep3 = classRep2 = classRep;
                        return classRep3;
                    }
                    throw new dotty.tools.FatalError(new scala.collection.immutable.StringOps(Predef..MODULE$.augmentString("Unexpected ClassRep '%s' found searching for name '%s'")).format((Seq)Predef..MODULE$.genericWrapArray((Object)new Object[]{classRep, this.name$2})));
                }

                public final /* bridge */ /* synthetic */ Object apply(Object v1) {
                    return this.apply((ClassRep)v1);
                }
            });

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not saying that the check was actually performed, I'm saying that the code was written assuming that the check would be performed, which apparently it wasn't.

Copy link
Contributor

@odersky odersky Mar 31, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment on the ticket #2156. I think it's a bug in scalac. By guess is that it checks whether the test would be redundant (which is reasonable) but gets that logic messed up. For instance, here is a situation where the test should be omitted:

class Outer {
  trait Base
  class Inner extends Base

  val x: Base = ???
  x match {
    case x: Inner => ???
  }
}

scala#2158 has uncovered flaws in the classfile parser. Matches that used
to always miss led to code that made no sense. The function naming was terrible
too, that's why nobody understood what was going on. `findSourceFile` to find
the class file, seriously?
@odersky
Copy link
Contributor

odersky commented Mar 31, 2017

Otherwise LGTM

ExplicitOuter.needsOuterIfReferenced(tref.symbol.asClass)
expectedTp.dealias match {
case tref @ TypeRef(pre: SingletonType, name) =>
val s = tref
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the added definition of s. Just use tref!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

variables defined in pattern matches are rarely debuggable when compiled by scalac.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, if you prefer.

@odersky odersky merged commit 4f53a1d into scala:master Mar 31, 2017
@allanrenucci allanrenucci deleted the fix-i2165 branch December 14, 2017 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants