Skip to content

Regression in Community Build: 2.13 std lib #5147

Closed
@allanrenucci

Description

@allanrenucci
Contributor

#4964 introduced a regression in the community build

Activity

allanrenucci

allanrenucci commented on Sep 24, 2018

@allanrenucci
ContributorAuthor

Here is a minimisation:

import scala.collection.immutable

 // Code below is to trick the compiler into thinking that we are
// compiling with the 2.13 standard library on the classpath.
package scala.collection {
  class IterableOnce
}
package scala.runtime {
  object ScalaRunTime {
    abstract class ArraySeq[+A] extends immutable.Seq[A]
    def genericWrapArray[T](xs: Array[T]): ArraySeq[T]          = ???
    def wrapRefArray[T <: AnyRef](xs: Array[T]): ArraySeq[T]    = ???
    def wrapIntArray(xs: Array[Int]): ArraySeq[Int]             = ???
    def wrapDoubleArray(xs: Array[Double]): ArraySeq[Double]    = ???
    def wrapLongArray(xs: Array[Long]): ArraySeq[Long]          = ???
    def wrapFloatArray(xs: Array[Float]): ArraySeq[Float]       = ???
    def wrapCharArray(xs: Array[Char]): ArraySeq[Char]          = ???
    def wrapByteArray(xs: Array[Byte]): ArraySeq[Byte]          = ???
    def wrapShortArray(xs: Array[Short]): ArraySeq[Short]       = ???
    def wrapBooleanArray(xs: Array[Boolean]): ArraySeq[Boolean] = ???
    def wrapUnitArray(xs: Array[Unit]): ArraySeq[Unit]          = ???
  }
}
 // Start of Test
class Test {
  inline def foo = 1
   def bar = foo
}
exception occurred while typechecking tests/allan/Test.scala
exception occurred while compiling tests/allan/Test.scala
Exception in thread "main" java.lang.AssertionError: assertion failed
	at scala.Predef$.assert(Predef.scala:204)
	at dotty.tools.dotc.core.Types$Type.annotatedToRepeated(Types.scala:1441)
	at dotty.tools.dotc.core.Types$MethodTypeCompanion.paramInfo$1(Types.scala:3044)
	at dotty.tools.dotc.core.Types$MethodTypeCompanion.$anonfun$fromSymbols$3(Types.scala:3049)
	at scala.collection.immutable.List.map(List.scala:287)
	at dotty.tools.dotc.core.Types$MethodTypeCompanion.$anonfun$fromSymbols$2(Types.scala:3049)
	at dotty.tools.dotc.core.Types$MethodType.<init>(Types.scala:2967)
	at dotty.tools.dotc.core.Types$CachedMethodType.<init>(Types.scala:2986)
	at dotty.tools.dotc.core.Types$MethodTypeCompanion.apply(Types.scala:3054)
	at dotty.tools.dotc.core.Types$MethodTypeCompanion.fromSymbols(Types.scala:3048)
	at dotty.tools.dotc.typer.NamerContextOps.$anonfun$methodType$1(Namer.scala:144)
	at scala.collection.immutable.List.$anonfun$foldRight$1(List.scala:405)
	at scala.collection.immutable.List.foldRight(List.scala:86)
	at scala.collection.TraversableOnce.$colon$bslash(TraversableOnce.scala:153)
	at scala.collection.TraversableOnce.$colon$bslash$(TraversableOnce.scala:153)
	at scala.collection.AbstractTraversable.$colon$bslash(Traversable.scala:104)
	at dotty.tools.dotc.typer.NamerContextOps.methodType(Namer.scala:136)
	at dotty.tools.dotc.typer.NamerContextOps.methodType$(Namer.scala:134)
	at dotty.tools.dotc.core.Contexts$Context.methodType(Contexts.scala:73)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readNewDef(TreeUnpickler.scala:771)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readIndexedDef(TreeUnpickler.scala:720)
	at dotty.tools.dotc.core.tasty.TreeUnpickler$Completer.complete(TreeUnpickler.scala:110)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:237)
	at dotty.tools.dotc.core.Denotations$Denotation.completeInfo$1(Denotations.scala:184)
	at dotty.tools.dotc.core.Denotations$Denotation.info(Denotations.scala:186)
	at dotty.tools.dotc.core.Denotations$SingleDenotation.signature(Denotations.scala:694)
	at dotty.tools.dotc.core.Denotations$SingleDenotation.matches(Denotations.scala:1078)
	at dotty.tools.dotc.core.Denotations$SingleDenotation.filterDisjoint(Denotations.scala:1086)
	at dotty.tools.dotc.core.Denotations$SingleDenotation.mapInherited(Denotations.scala:1090)
	at dotty.tools.dotc.core.Denotations$SingleDenotation.mapInherited(Denotations.scala:687)
	at dotty.tools.dotc.core.SymDenotations$ClassDenotation.collect$1(SymDenotations.scala:1614)
	at dotty.tools.dotc.core.SymDenotations$ClassDenotation.$anonfun$computeNPMembersNamed$1(SymDenotations.scala:1622)
	at dotty.tools.dotc.util.Stats$.track(Stats.scala:37)
	at dotty.tools.dotc.core.SymDenotations$ClassDenotation.computeNPMembersNamed(SymDenotations.scala:1601)
	at dotty.tools.dotc.core.SymDenotations$ClassDenotation.nonPrivateMembersNamed(SymDenotations.scala:1591)
	at dotty.tools.dotc.core.SymDenotations$ClassDenotation.membersNamed(SymDenotations.scala:1578)
	at dotty.tools.dotc.core.SymDenotations$ClassDenotation.findMember(SymDenotations.scala:1626)
	at dotty.tools.dotc.core.Types$Type.go$1(Types.scala:549)
	at dotty.tools.dotc.core.Types$Type.findMember(Types.scala:694)
	at dotty.tools.dotc.core.Types$Type.memberExcluding(Types.scala:531)
	at dotty.tools.dotc.core.Types$Type.$anonfun$member$1(Types.scala:517)
	at dotty.tools.dotc.util.Stats$.track(Stats.scala:37)
	at dotty.tools.dotc.core.Types$Type.member(Types.scala:517)
	at dotty.tools.dotc.core.Denotations$Denotation.requiredMethod(Denotations.scala:299)
	at dotty.tools.dotc.core.Denotations$Denotation.requiredMethodRef(Denotations.scala:301)
	at dotty.tools.dotc.core.Definitions.Typelevel_errorR$lzycompute(Definitions.scala:223)
	at dotty.tools.dotc.core.Definitions.Typelevel_errorR(Definitions.scala:223)
	at dotty.tools.dotc.core.Definitions.Typelevel_error(Definitions.scala:224)
	at dotty.tools.dotc.typer.Inliner.$anonfun$inlined$12(Inliner.scala:494)
	at dotty.tools.dotc.reporting.trace$.apply(trace.scala:40)
	at dotty.tools.dotc.typer.Inliner.inlined(Inliner.scala:475)
	at dotty.tools.dotc.typer.Inliner$.inlineCall(Inliner.scala:125)
	at dotty.tools.dotc.typer.Typer.adaptNoArgsOther$1(Typer.scala:2450)
	at dotty.tools.dotc.typer.Typer.adaptNoArgs$1(Typer.scala:2514)
	at dotty.tools.dotc.typer.Typer.adapt1(Typer.scala:2646)
	at dotty.tools.dotc.typer.Typer.$anonfun$adapt$3(Typer.scala:2195)
	at dotty.tools.dotc.reporting.trace$.apply(trace.scala:40)
	at dotty.tools.dotc.typer.Typer.$anonfun$adapt$1(Typer.scala:2194)
	at dotty.tools.dotc.util.Stats$.track(Stats.scala:37)
	at dotty.tools.dotc.typer.Typer.adapt(Typer.scala:2194)
	at dotty.tools.dotc.typer.Typer.$anonfun$typed$2(Typer.scala:1969)
	at dotty.tools.dotc.reporting.trace$.apply(trace.scala:40)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1965)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1981)
	at dotty.tools.dotc.typer.Namer.$anonfun$typedAheadExpr$1(Namer.scala:972)
	at dotty.tools.dotc.typer.Namer.typedAheadImpl(Namer.scala:962)
	at dotty.tools.dotc.typer.Namer.typedAheadExpr(Namer.scala:972)
	at dotty.tools.dotc.typer.Namer.rhsType$1(Namer.scala:1095)
	at dotty.tools.dotc.typer.Namer.cookedRhsType$1(Namer.scala:1107)
	at dotty.tools.dotc.typer.Namer.lhsType$1(Namer.scala:1108)
	at dotty.tools.dotc.typer.Namer.inferredType$1(Namer.scala:1126)
	at dotty.tools.dotc.typer.Namer.valOrDefDefSig(Namer.scala:1134)
	at dotty.tools.dotc.typer.Namer.defDefSig(Namer.scala:1201)
	at dotty.tools.dotc.typer.Namer$Completer.typeSig(Namer.scala:721)
	at dotty.tools.dotc.typer.Namer$Completer.completeInCreationContext(Namer.scala:801)
	at dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:746)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:237)
	at dotty.tools.dotc.core.Denotations$Denotation.completeInfo$1(Denotations.scala:184)
	at dotty.tools.dotc.core.Denotations$Denotation.info(Denotations.scala:186)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:343)
	at dotty.tools.dotc.typer.Typer.retrieveSym(Typer.scala:1836)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:1861)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1937)
	at dotty.tools.dotc.typer.Typer.$anonfun$typed$2(Typer.scala:1969)
	at dotty.tools.dotc.reporting.trace$.apply(trace.scala:40)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1965)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1981)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2000)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2034)
	at dotty.tools.dotc.typer.Typer.$anonfun$typedClassDef$1(Typer.scala:1601)
	at dotty.tools.dotc.util.Stats$.track(Stats.scala:37)
	at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:1523)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:1874)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1937)
	at dotty.tools.dotc.typer.Typer.$anonfun$typed$2(Typer.scala:1969)
	at dotty.tools.dotc.reporting.trace$.apply(trace.scala:40)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1965)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1981)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2000)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2034)
	at dotty.tools.dotc.typer.Typer.$anonfun$typedPackageDef$1(Typer.scala:1709)
	at dotty.tools.dotc.util.Stats$.track(Stats.scala:37)
	at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:1702)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:1916)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1938)
	at dotty.tools.dotc.typer.Typer.$anonfun$typed$2(Typer.scala:1969)
	at dotty.tools.dotc.reporting.trace$.apply(trace.scala:40)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1965)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1981)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2038)
	at dotty.tools.dotc.typer.FrontEnd.$anonfun$typeCheck$1(FrontEnd.scala:60)
	at dotty.tools.dotc.typer.FrontEnd.monitor(FrontEnd.scala:34)
	at dotty.tools.dotc.typer.FrontEnd.typeCheck(FrontEnd.scala:58)
	at dotty.tools.dotc.typer.FrontEnd.$anonfun$runOn$6(FrontEnd.scala:88)
	at dotty.tools.dotc.typer.FrontEnd.$anonfun$runOn$6$adapted(FrontEnd.scala:88)
	at scala.collection.immutable.List.foreach(List.scala:389)
	at dotty.tools.dotc.typer.FrontEnd.runOn(FrontEnd.scala:88)
	at dotty.tools.dotc.Run.$anonfun$compileUnits$3(Run.scala:175)
	at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
	at dotty.tools.dotc.util.Stats$.trackTime(Stats.scala:49)
	at dotty.tools.dotc.Run.$anonfun$compileUnits$2(Run.scala:172)
	at dotty.tools.dotc.Run.$anonfun$compileUnits$2$adapted(Run.scala:170)
	at scala.collection.IndexedSeqOptimized.foreach(IndexedSeqOptimized.scala:32)
	at scala.collection.IndexedSeqOptimized.foreach$(IndexedSeqOptimized.scala:29)
	at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:194)
	at dotty.tools.dotc.Run.runPhases$1(Run.scala:170)
	at dotty.tools.dotc.Run.$anonfun$compileUnits$1(Run.scala:195)
	at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
	at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:90)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:150)
	at dotty.tools.dotc.Run.compileSources(Run.scala:137)
	at dotty.tools.dotc.Run.compile(Run.scala:121)
	at dotty.tools.dotc.Driver.doCompile(Driver.scala:31)
	at dotty.tools.dotc.Driver.process(Driver.scala:134)
	at dotty.tools.dotc.Driver.process(Driver.scala:103)
	at dotty.tools.dotc.Driver.process(Driver.scala:115)
	at dotty.tools.dotc.Driver.main(Driver.scala:142)
	at dotty.tools.dotc.Main.main(Main.scala)
allanrenucci

allanrenucci commented on Sep 27, 2018

@allanrenucci
ContributorAuthor

The issue is that when we compile the 2.13 std lib we are still loading classes from our classpath (i.e. classes from the dotty lib that are not part of the 2.13 std lib sources). These classes were compiled with a different version of the std lib which then breaks invariants in the compiler.

For instance classes on the classpath were compiled with scala.Seq being an alias for scala.collection.Seq but classes from sources are compiled with scala.Seq being an alias for scala.collection.immutable.Seq.

We fix this in the community build, by augmenting the 2.13 std lib with classes from the Dotty std lib. See dotty-staging/scala@f8eee12

allanrenucci

allanrenucci commented on Sep 27, 2018

@allanrenucci
ContributorAuthor
allanrenucci

allanrenucci commented on Sep 27, 2018

@allanrenucci
ContributorAuthor

For reference, the regression was introduced in #4964 because now the inliner loads a symbol from the Dotty lib: https://github.com/lampepfl/dotty/blob/19cdeb4e2cd9e5346a0758c1fa8570d733b8dd7d/compiler/src/dotty/tools/dotc/typer/Inliner.scala#L465

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @allanrenucci

        Issue actions

          Regression in Community Build: 2.13 std lib · Issue #5147 · scala/scala3