-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Make dotty compile backend. #543
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
Conversation
Currently fails at erasure with
@odersky can you have a look? |
…y compiled. It seems wasteful to load the member classes even of classes that are not currently compiled. It also makes us vulnerable to any misinterpretation of Java file formats. In th particular case of scala#536, we parsed a class an anonymous Collection$1 which was referring to the type parameter of its enclosing class, but was not diagnosed as an inner class of the enclosing class.
…ate. Symbols never change betwene terms and types. So we do not need to the current denotation to decide what they are. Less forcing -> less potential for cyclic references.
What was the actual assertion violation? I can't reproduce this. It's really weird. When I first pulled the branch and do sbt test I did get findMember exceptions which were NotDefinedHere violations. I made them go away by adding FutureDefsOK to the rootContext. But now I cannot even get there. I get lots of errors like this: ./src/dotty/tools/backend/jvm/CollectEntryPoints.scala:72: error: type mismatch: followed by a assertion failure in withType. I get the same errors with eclipse. Something seems to be wrong with the classpaths here. |
The errors that you have I haven't seen. Though travis failed with a different error. The actual violation is
And It I can reproduce it locally on a clean clone of the repo. |
Travis reproduced the error. |
I figured out what the previous errors are. Now we get much further, and die in BackendInterface#memberClasses. |
@DarkDimius I suggest you merge with #544. memberClasses is causing this error, and the way it is defined here it is definitely broken. |
I believe that bb9eb23 silences actual error: we have a denotation for |
Indeed the error was the NotDefinedHere, and the other symptom was a follow-on. I have pushed a commit that undoes the previous two commits and solves the NotDefinedHere problem. We are now |
…his run. See discussion in scala#544
We used to require that the result type of an extractor `get` is a product, or else the type of the `get` itself would be taken as the result type of the unapply. This is now relaxed so that we automatically select with _1, _2, ... as soon as there are multiple argument patterns, and (1) the result type is not a Seq, (2) the number of consecutive product conselectors matches the number of arguments.
…s path and in compiled source. [error] Test dotc.tests.dotty failed: java.lang.AssertionError: assertion failed: data race? overwriting symbol of dotty.DottyPredef$ / TypeRef(ThisType(TypeRef(NoPrefix,dotty)),DottyPredef$) / class dotty.tools.dotc.core.Types$CachedTypeRef / 9007 / 9748, took 1.276 sec [error] at scala.Predef$.assert(Predef.scala:165) [error] at dotty.tools.dotc.core.Types$NamedType.checkSymAssign(Types.scala:1263) [error] at dotty.tools.dotc.core.Types$NamedType.setDenot(Types.scala:1293) [error] at dotty.tools.dotc.core.Types$NamedType.withDenot(Types.scala:1286) [error] at dotty.tools.dotc.core.Types$TypeRef$.apply(Types.scala:1669) [error] at dotty.tools.dotc.core.Types$Type.select(Types.scala:819) [error] at dotty.tools.dotc.typer.Namer.moduleValSig(Namer.scala:602) [error] at dotty.tools.dotc.typer.Namer$Completer.typeSig(Namer.scala:465) [error] at dotty.tools.dotc.typer.Namer$Completer.completeInCreationContext(Namer.scala:499) [error] at dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:495) [error] at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:161) [error] at dotty.tools.dotc.core.SymDenotations$SymDenotation.info(SymDenotations.scala:143) [error] at dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:253) [error] at dotty.tools.dotc.core.SymDenotations$SymDenotation.flags(SymDenotations.scala:97) [error] at dotty.tools.dotc.core.SymDenotations$SymDenotation.is(SymDenotations.scala:119) [error] at dotty.tools.dotc.core.SymDenotations$SymDenotation.isStable(SymDenotations.scala:464) [error] at dotty.tools.dotc.core.Types$Type.widenIfUnstable(Types.scala:691) [error] at dotty.tools.dotc.core.Types$Type$$anonfun$member$1.apply(Types.scala:394) [error] at dotty.tools.dotc.core.Types$Type$$anonfun$member$1.apply(Types.scala:394) [error] at dotty.tools.dotc.util.Stats$.track(Stats.scala:35) [error] at dotty.tools.dotc.core.Types$Type.member(Types.scala:393) [error] at dotty.tools.dotc.typer.Typer$$anonfun$typedIdent$1.wildImportRef$1(Typer.scala:192) [error] at dotty.tools.dotc.typer.Typer$$anonfun$typedIdent$1.findRef$1(Typer.scala:240) [error] at dotty.tools.dotc.typer.Typer$$anonfun$typedIdent$1.apply(Typer.scala:263) [error] at dotty.tools.dotc.typer.Typer$$anonfun$typedIdent$1.apply(Typer.scala:79) [error] at dotty.tools.dotc.util.Stats$.track(Stats.scala:35) [error] at dotty.tools.dotc.typer.Typer.typedIdent(Typer.scala:79) [error] at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:1017) [error] at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1076) [error] at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:1088) [error] at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:1086) [error] at dotty.tools.dotc.reporting.Reporting$class.traceIndented(Reporter.scala:147) [error] at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:51) [error] at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1086) [error] at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:1125) [error] at dotty.tools.dotc.typer.Typer$$anonfun$typedPackageDef$1.apply(Typer.scala:961) [error] at dotty.tools.dotc.typer.Typer$$anonfun$typedPackageDef$1.apply(Typer.scala:960) [error] at dotty.tools.dotc.util.Stats$.track(Stats.scala:35) [error] at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:960) [error] at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:1066) [error] at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1078) [error] at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:1088) [error] at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:1086) [error] at dotty.tools.dotc.reporting.Reporting$class.traceIndented(Reporter.scala:147) [error] at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:51) [error] at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1086) [error] at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:1125) [error] at dotty.tools.dotc.typer.FrontEnd$$anonfun$typeCheck$1.apply$mcV$sp(FrontEnd.scala:41) [error] at dotty.tools.dotc.typer.FrontEnd.monitor(FrontEnd.scala:18) [error] at dotty.tools.dotc.typer.FrontEnd.typeCheck(FrontEnd.scala:39) [error] at dotty.tools.dotc.typer.FrontEnd$$anonfun$runOn$3.apply(FrontEnd.scala:52) [error] at dotty.tools.dotc.typer.FrontEnd$$anonfun$runOn$3.apply(FrontEnd.scala:52) [error] at scala.collection.immutable.List.foreach(List.scala:381) [error] at dotty.tools.dotc.typer.FrontEnd.runOn(FrontEnd.scala:52) [error] at dotty.tools.dotc.Run$$anonfun$compileSources$1$$anonfun$apply$mcV$sp$3.apply(Run.scala:55) [error] at dotty.tools.dotc.Run$$anonfun$compileSources$1$$anonfun$apply$mcV$sp$3.apply(Run.scala:52) [error] at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:33) [error] at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:186) [error] at dotty.tools.dotc.Run$$anonfun$compileSources$1.apply$mcV$sp(Run.scala:52) [error] at dotty.tools.dotc.Run$$anonfun$compileSources$1.apply(Run.scala:47) [error] at dotty.tools.dotc.Run$$anonfun$compileSources$1.apply(Run.scala:47) [error] at dotty.tools.dotc.util.Stats$.monitorHeartBeat(Stats.scala:68) [error] at dotty.tools.dotc.Run.compileSources(Run.scala:46) [error] at dotty.tools.dotc.Run.compile(Run.scala:33) [error] at dotty.tools.dotc.Driver.doCompile(Driver.scala:20) [error] at dotty.tools.dotc.Bench$.dotty$tools$dotc$Bench$$super$doCompile(Bench.scala:38) [error] at dotty.tools.dotc.Bench$$anonfun$doCompile$1.apply(Bench.scala:38) [error] at dotty.tools.dotc.Bench$$anonfun$doCompile$1.apply(Bench.scala:36) [error] at dotty.tools.dotc.Bench$$anonfun$ntimes$1.apply(Bench.scala:30) [error] at dotty.tools.dotc.Bench$$anonfun$ntimes$1.apply(Bench.scala:30) [error] at scala.collection.TraversableOnce$$anonfun$foldLeft$1.apply(TraversableOnce.scala:142) [error] at scala.collection.TraversableOnce$$anonfun$foldLeft$1.apply(TraversableOnce.scala:142) [error] at scala.collection.immutable.Range.foreach(Range.scala:166) [error] at scala.collection.TraversableOnce$class.foldLeft(TraversableOnce.scala:142) [error] at scala.collection.AbstractTraversable.foldLeft(Traversable.scala:104) [error] at scala.collection.TraversableOnce$class.$div$colon(TraversableOnce.scala:136) [error] at scala.collection.AbstractTraversable.$div$colon(Traversable.scala:104) [error] at dotty.tools.dotc.Bench$.ntimes(Bench.scala:30) [error] at dotty.tools.dotc.Bench$.doCompile(Bench.scala:36) [error] at dotty.tools.dotc.Driver.process(Driver.scala:31) [error] at dotty.tools.dotc.Bench$.dotty$tools$dotc$Bench$$super$process(Bench.scala:53) [error] at dotty.tools.dotc.Bench$$anonfun$process$1.apply(Bench.scala:53) [error] at dotty.tools.dotc.Bench$$anonfun$process$1.apply(Bench.scala:53) [error] at dotty.tools.dotc.Bench$$anonfun$ntimes$1.apply(Bench.scala:30) [error] at dotty.tools.dotc.Bench$$anonfun$ntimes$1.apply(Bench.scala:30) [error] at scala.collection.TraversableOnce$$anonfun$foldLeft$1.apply(TraversableOnce.scala:142) [error] at scala.collection.TraversableOnce$$anonfun$foldLeft$1.apply(TraversableOnce.scala:142) [error] at scala.collection.immutable.Range.foreach(Range.scala:166) [error] at scala.collection.TraversableOnce$class.foldLeft(TraversableOnce.scala:142) [error] at scala.collection.AbstractTraversable.foldLeft(Traversable.scala:104) [error] at scala.collection.TraversableOnce$class.$div$colon(TraversableOnce.scala:136) [error] at scala.collection.AbstractTraversable.$div$colon(Traversable.scala:104) [error] at dotty.tools.dotc.Bench$.ntimes(Bench.scala:30) [error] at dotty.tools.dotc.Bench$.process(Bench.scala:53) [error] at test.CompilerTest.compileArgs(CompilerTest.scala:159) [error] at test.CompilerTest.compileDir(CompilerTest.scala:104) [error] at dotc.tests.dotty(tests.scala:141)
Implicit vals need explicit type, anonymous classes are widened.
Includes fixes to lambas, and no type projections in signatures.
Up to now a NotDefinedHere exception was thrown if a denotation was not defined at the current phase, but was defined elsewhere in the current run. However, if the denotation is a SingleDenotation or MultiDenotation it is possible that the particular Single- or Multi-Denotation was not computed at the current phase, but the underlying SymDenotation is valid. With the changes in this commit, we reaload the denotation as a second try.
def nestedClasses: List[Symbol] = memberClasses //exitingPhase(currentRun.lambdaliftPhase)(sym.memberClasses) | ||
def memberClasses: List[Symbol] = toDenot(sym).info.memberClasses.map(_.symbol).toList | ||
|
||
/** For currently compiled classes: All locally defined classes including local classes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the difference between a "locally defined class" and a "local class"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My guess is:
class A{
class B
def foo = {
class C
}
}
Class B
is locally defined, class C
is local.
Though the naming here is indeed confusing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, "local classes" is Java lingo.
On Fri, May 8, 2015 at 4:43 PM, Dmitry Petrashko [email protected]
wrote:
In src/dotty/tools/backend/jvm/DottyBackendInterface.scala
#543 (comment):@@ -678,8 +686,24 @@ class DottyBackendInterface()(implicit ctx: Context) extends BackendInterface{
// members def primaryConstructor: Symbol = toDenot(sym).primaryConstructor
- def nestedClasses: List[Symbol] = memberClasses //exitingPhase(currentRun.lambdaliftPhase)(sym.memberClasses)
- def memberClasses: List[Symbol] = toDenot(sym).info.memberClasses.map(_.symbol).toList
- /** For currently compiled classes: All locally defined classes including local classes.
My guess is:
class A{
class B
def foo = {
class C
}
}Class B is locally defined, class C is local.
Though the naming here is indeed confusing.—
Reply to this email directly or view it on GitHub
https://github.com/lampepfl/dotty/pull/543/files#r29944973.
Martin Odersky
EPFL
I think we can merge this now to make progress. I'll get back to the dotty deviation once this is in. |
Changes that make dotty one step closer to bootstrap.
And a fix to Pattern matcher revealed by backend.