Giter VIP home page Giter VIP logo

scala3's Introduction

Dotty

Dotty CI Join the chat at https://discord.com/invite/scala

Try it out

To try it in your project see also the Getting Started User Guide.

Building a Local Distribution

  1. sbt dist/packArchive
  2. Find the newly-built distributions in dist/target/

Code of Conduct

Dotty uses the Scala Code of Conduct for all communication and discussion. This includes both GitHub, Discord and other more direct lines of communication such as email.

How to Contribute

License

Dotty is licensed under the Apache License Version 2.0

scala3's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

scala3's Issues

bin/dotc doesn't include scala-xml.jar

cat test.scala
object Test {
  <foo/>
}
  ~/code/dotty ./bin/dotc test.scala
exception occured while parsing test.scala
Exception in thread "main" java.lang.NoClassDefFoundError: scala/xml/Utility$

dotty class file parser doesn't accept Java8 bytecode

./bin/dotc test.scala
exception caught when loading class GenericDeclaration: ERROR at ?: error while loading AnnotatedElement,
 class file /Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home/jre/lib/rt.jar(java/lang/reflect/AnnotatedElement.class) is broken, reading aborted with java.lang.RuntimeException: bad constant pool tag 18 at byte 76.getClass
bad constant pool tag 18 at byte 76
exception caught when loading class Class: ERROR at ?: error while loading AnnotatedElement,
 class file /Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home/jre/lib/rt.jar(java/lang/reflect/AnnotatedElement.class) is broken, reading aborted with java.lang.RuntimeException: bad constant pool tag 18 at byte 76.getClass
bad constant pool tag 18 at byte 76
error occurred during: ClassInfo(ThisType(module class lang), class Object): ClassInfo(ThisType(module class lang), class Object) member getClass
Exception in thread "main" ERROR at ?: error while loading AnnotatedElement,
 class file /Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home/jre/lib/rt.jar(java/lang/reflect/AnnotatedElement.class) is broken, reading aborted with java.lang.RuntimeException: bad constant pool tag 18 at byte 76.getClass
bad constant pool tag 18 at byte 76

Scala 2.10.4 handles this correctly.

git log v2.10.0..v2.10.4-RC3 --oneline -- /Users/jason/code/scala/src/compiler/scala/tools/nsc/symtab/classfile
f0d913b SI-8062 Fix inliner cycle with recursion, separate compilation
ed230b5 Merge remote-tracking branch 'origin/2.10.2' into merge/2.10.2-to-2.10.x
f91242c SI-7014 Annot arg may refer to annotated class's member
050b4c9 SI-7455 Drop dummy param for synthetic access constructor
75251f7 SI-7532 Fix regression in Java inner classfile reader
90ac5c4 [nomaster] SI-5923 instantiates targs in deferred macro applications
1ee5cc4 Merge pull request #2456 from paulp/pr/jdk8-210x
34d28aa Merge pull request #2458 from paulp/issue/7426-210
3abdaf4 SI-5634 eliminate overly verbose error message
df3cae7 SI-7426 Crash in pickler.
b2c67b3 SI-7398 Add support for java8 default methods
28a6574 Merge pull request #2257 from JamesIry/2.10.x_classfile_51
b7cbda7 Log when invokedynamic instruction is encountered
395e90a SI-7251, compiler crash with $.
e78896f Read version 51 (JDK 7) class files.
4f1bfec Fix SI-7107: scala now thinks every exception is polymorphic
9164c2a Merge pull request #2035 from scalamacros/ticket/6989
02ed5fb SI-6989 privateWithin is now populated in reflect
0bcdf71 pullrequest feedback
f1701f7 SI-7008 @throws annotations are now populated in reflect
309ff57 Merge pull request #2015 from paulp/rc1-backports
fefe6cc SI-7009: `@throws` annotation synthesized incorrectly
f3f1e50 SI-5353, imperfect error message.
7ee299b evicts assert(false) from the compiler
aedc853 Merge branch '2.10.0-wip' into merge-2.10.0

Investigate making 'nextPhase' default period for Tree transformations

If the phase is an info transformer in most cases it will transform the tree at 'nextPhase' in order to have info transformation already performed.
It feels like making all tree transformations run at 'nextPhase' a default should break phases that do not introduce info transformers.
If so, than a bit of naming change would simplify that sheme a lot: we can just say that current 'nextPhase' should actually be a period of current phase, effectively shifting all periods by one.

Keep classpath used to run the compiler separate from compilation classpath.

A program should not be able to see the classes of the compiler that's compiling it unless the compiler's classes are explicitly added to the compilation (user) classpath. Currently, they all leak through by default (you have one chance to opt-out by not setting usejavacp): https://github.com/lampepfl/dotty/blob/master/src/dotty/tools/dotc/config/PathResolver.scala#L227

This is not a problem in sbt (it manages the classpath itself), and you might consider it a feature in the REPL, but it's pretty complicated for build tools to navigate the maze of settings. Would be good to clean this up early on.

tpd.ModuleDef strips flags, eg. "module" flag

Pattern matcher does not generate ValDefs for defined pattern bound variables

When compiling pos/functions1.scala I observe the following code snippet

  val x33: String => String = {
    def $anonfun(x22: String): String = {
      case val selector11: String = x22
      {
        def case11(): String = {
          def case21(): String = {
            def matchFail11(): String = throw new MatchError(selector11)
            {
              x34
            }
          }
          if "abc".equals(selector11) then {
            val x21: String = selector11
            {
              ""
            }
          } else case21()
        }
        case11()
      }
    }
    closure($anonfun)
  }

You need to compile against the latest commit with the changed functions1.scala or else compile with -uniqid to observe the effect: In both cases, the definition of the pattern bound variable x34 is missing.

Detected when trying to lambda-lift this code.

Tailcalls generates references to labels from local functions.

... and LambdaLift does not know what to do about them. In fact, I think we should not let TailCalls generate such labels.

To reproduce, check out branch transform/lambdalift and run the compiler with
-Ycheck:lambda on tests/pending/pos/tailcalls/t1672.scala.

Incorrect infering "Nothing" as a type argument of `fun` in 'Unapply'

object test {
  class Foo[a](val arg : a)

  object Foo  {
    def unapply [a](m : Foo[a]) = Some (m.arg)
  }
  def matchAndGetArgFromFoo[a]( e:Foo[a]):a = {e match { case Foo(x) => x }}
// Unapply node here will have type argument [a] instantiated to scala.Nothing:
// UnApply(TypeApply(Select(Ident(Foo),unapply),List(TypeTree[TypeVar(PolyParam(a) -> TypeRef(ThisType(TypeRef(NoPrefix,scala)),Nothing))])),List(),List(Bind(x,Ident(_))))
// but the type of the UnApply node itself is correct: RefinedType(TypeRef(ThisType(TypeRef(ThisType(TypeRef(NoPrefix,<empty>)),test$)),Foo), test$$Foo$$a, TypeAlias(TypeRef(NoPrefix,a)))
}

Given such types the rewriting from UnApply(fun,Nil,_) to
val result = fun(matchSelector) cannot be applied as sel has type not matching fun(because fun was instantiated with wrong type arguments)

Annotations on polymorphic method parameter/return types get lost

Annotations on parameter/return types disappear when the type of a polymorphic method is built. This only happens where the annotations have an underlying PolyParam.

trait Annot extends annotation.StaticAnnotation with annotation.TypeConstraint

trait PolyBug {

    // This works
    type T
    def m(param1: T @Annot): T @Annot

    // These do not: annotations are dropped
    def m1[P](param1: P @Annot): P @Annot
    def m2[P](param1: List[P @Annot] @Annot): List[P @Annot] @Annot

    // This doesn't work either, but the annotations on T remain intact
    def m3[P](param1: Map[P @Annot,T @Annot] @Annot): Map[P @Annot,T @Annot] @Annot
}

In all cases above, the annotations exist on the typed tree. Annotations also exist on the typed tree's type, except for the type of the DefDef tree.

The computed types of the methods above are:

m: (param1: PolyBug.this.T @Annot)PolyBug.this.T @Annot
m1: [P](param1: P)P
m2: [P](param1: scala.collection.immutable.List[P])scala.collection.immutable.List[P]
m3: [P](param1: scala.collection.immutable.Map[P, PolyBug.this.T @Annot])
        scala.collection.immutable.Map[P, PolyBug.this.T @Annot]

Annotations still exist on the ValDef trees' types, but they are lost when computing the DefDef trees' types.

muDOT zoo example takes a long (infinite?) time to check

zoo.scala is as follows:

object Test {
type Meat = {
  type IsMeat = Any
}
type Grass = {
  type IsGrass = Any
}
type Animal = {
  type Food
  def eats(food: Food): Unit
  def gets: Food
}
type Cow = {
  type IsMeat = Any
  type Food <: Grass
  def eats(food: Grass): Unit
  def gets: Grass
}
type Lion = {
  type Food = Meat
  def eats(food: Meat): Unit
  def gets: Meat
}
def newMeat: Meat = new {
  type IsMeat = Any
}
def newGrass: Grass = new {
  type IsGrass = Any
}
def newCow: Cow = new {
  type IsMeat = Any
  type Food = Grass
  def eats(food: Grass) = ()
  def gets = newGrass
}
def newLion: Lion = new {
  type Food = Meat
  def eats(food: Meat) = ()
  def gets = newMeat
}
val milka = newCow
val leo = newLion
leo.eats(milka)
}

scalac zoo.scala fails with:

zoo.scala:10: error: Parameter type in structural refinement may not
refer to a type member of that refinement
  def eats(food: Food): Unit

while dottyc zoo.scala just seems to hang.

Types refined with terms cannot be refined further

The following code:

object Test {
  type F = { val x: Int }
  type G = F {}
}

makes dotty throw an exception because normalizeToRef does not handle parents which are RefinedType where the refinement is a term and not a type:

[error] Exception in thread "main" dotty.tools.dotc.core.Types$TypeError: unexpected parent type: RefinedType(TypeRef(ThisType(TypeRef(NoPrefix,lang)),Object), x, TypeRef(TermRef(ThisType(TypeRef(NoPrefix,<root>)),scala),Int))
[error]         at dotty.tools.dotc.core.TypeOps$class.normalizeToRef$1(TypeOps.scala:286)
[error]         at dotty.tools.dotc.core.TypeOps$$anonfun$5.apply(TypeOps.scala:288)
[error]         at dotty.tools.dotc.core.TypeOps$$anonfun$5.apply(TypeOps.scala:288)
[error]         at scala.collection.immutable.List.map(List.scala:274)
[error]         at dotty.tools.dotc.core.TypeOps$class.normalizeToClassRefs(TypeOps.scala:288)
[error]         at dotty.tools.dotc.core.Contexts$Context.normalizeToClassRefs(Contexts.scala:51)
[error]         at dotty.tools.dotc.typer.Namer$ClassCompleter.completeInCreationContext(Namer.scala:489)
[error]         at dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:424)
[error]         at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:151)
[error]         at dotty.tools.dotc.core.SymDenotations$SymDenotation.info(SymDenotations.scala:133)
[error]         at dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:234)
[error]         at dotty.tools.dotc.typer.Typer.retrieveSym(Typer.scala:920)
[error]         at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:945)
[error]         at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1005)
[error]         at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:1017)
[error]         at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:1015)
[error]         at dotty.tools.dotc.reporting.Reporting$class.traceIndented(Reporter.scala:162)
[error]         at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:51)
[error]         at dotty.tools.dotc.reporting.Reporting$class.traceIndented(Reporter.scala:146)
[error]         at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:51)
[error]         at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1015)
[error]         at dotty.tools.dotc.typer.Typer$$anonfun$typedRefinedTypeTree$1.apply(Typer.scala:732)
[error]         at dotty.tools.dotc.typer.Typer$$anonfun$typedRefinedTypeTree$1.apply(Typer.scala:728)
[error]         at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
[error]         at dotty.tools.dotc.typer.Typer.typedRefinedTypeTree(Typer.scala:728)
[error]         at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:991)
[error]         at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1007)
[error]         at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:1017)
[error]         at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:1015)
[error]         at dotty.tools.dotc.reporting.Reporting$class.traceIndented(Reporter.scala:162)
[error]         at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:51)
[error]         at dotty.tools.dotc.reporting.Reporting$class.traceIndented(Reporter.scala:146)
[error]         at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:51)
[error]         at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1015)
[error]         at dotty.tools.dotc.typer.Namer.typedAheadImpl(Namer.scala:503)
[error]         at dotty.tools.dotc.typer.Namer.typedAheadType(Namer.scala:510)
[error]         at dotty.tools.dotc.typer.Namer.typeDefSig(Namer.scala:670)
[error]         at dotty.tools.dotc.typer.Namer$Completer.typeSig(Namer.scala:402)
[error]         at dotty.tools.dotc.typer.Namer$Completer.completeInCreationContext(Namer.scala:428)
[error]         at dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:424)
[error]         at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:151)
[error]         at dotty.tools.dotc.core.SymDenotations$SymDenotation.info(SymDenotations.scala:133)
[error]         at dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:234)
[error]         at dotty.tools.dotc.typer.Typer.retrieveSym(Typer.scala:920)
[error]         at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:945)
[error]         at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1005)
[error]         at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:1017)
[error]         at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:1015)
[error]         at dotty.tools.dotc.reporting.Reporting$class.traceIndented(Reporter.scala:162)
[error]         at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:51)
[error]         at dotty.tools.dotc.reporting.Reporting$class.traceIndented(Reporter.scala:146)
[error]         at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:51)
[error]         at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1015)
[error]         at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:1039)
[error]         at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:1051)
[error]         at dotty.tools.dotc.typer.Typer$$anonfun$typedClassDef$1.apply(Typer.scala:852)
[error]         at dotty.tools.dotc.typer.Typer$$anonfun$typedClassDef$1.apply(Typer.scala:834)
[error]         at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
[error]         at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:834)
[error]         at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:959)
[error]         at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1005)
[error]         at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:1017)
[error]         at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:1015)
[error]         at dotty.tools.dotc.reporting.Reporting$class.traceIndented(Reporter.scala:162)
[error]         at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:51)
[error]         at dotty.tools.dotc.reporting.Reporting$class.traceIndented(Reporter.scala:146)
[error]         at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:51)
[error]         at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1015)
[error]         at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:1039)
[error]         at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:1051)
[error]         at dotty.tools.dotc.typer.Typer$$anonfun$typedPackageDef$1.apply(Typer.scala:899)
[error]         at dotty.tools.dotc.typer.Typer$$anonfun$typedPackageDef$1.apply(Typer.scala:890)
[error]         at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
[error]         at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:890)
[error]         at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:996)
[error]         at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1007)
[error]         at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:1017)
[error]         at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:1015)
[error]         at dotty.tools.dotc.reporting.Reporting$class.traceIndented(Reporter.scala:162)
[error]         at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:51)
[error]         at dotty.tools.dotc.reporting.Reporting$class.traceIndented(Reporter.scala:146)
[error]         at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:51)
[error]         at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1015)
[error]         at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:1055)
[error]         at dotty.tools.dotc.typer.FrontEnd$$anonfun$typeCheck$1.apply$mcV$sp(FrontEnd.scala:37)
[error]         at dotty.tools.dotc.typer.FrontEnd.monitor(FrontEnd.scala:16)
[error]         at dotty.tools.dotc.typer.FrontEnd.typeCheck(FrontEnd.scala:35)
[error]         at dotty.tools.dotc.typer.FrontEnd$$anonfun$runOn$3.apply(FrontEnd.scala:48)
[error]         at dotty.tools.dotc.typer.FrontEnd$$anonfun$runOn$3.apply(FrontEnd.scala:48)
[error]         at scala.collection.immutable.List.foreach(List.scala:383)
[error]         at dotty.tools.dotc.typer.FrontEnd.runOn(FrontEnd.scala:48)
[error]         at dotty.tools.dotc.Run$$anonfun$compileSources$1$$anonfun$apply$mcV$sp$3.apply(Run.scala:49)
[error]         at dotty.tools.dotc.Run$$anonfun$compileSources$1$$anonfun$apply$mcV$sp$3.apply(Run.scala:47)
[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:47)
[error]         at dotty.tools.dotc.Run$$anonfun$compileSources$1.apply(Run.scala:39)
[error]         at dotty.tools.dotc.Run$$anonfun$compileSources$1.apply(Run.scala:39)
[error]         at dotty.tools.dotc.util.Stats$.monitorHeartBeat(Stats.scala:68)
[error]         at dotty.tools.dotc.Run.compileSources(Run.scala:38)
[error]         at dotty.tools.dotc.Run.compile(Run.scala:29)
[error]         at dotty.tools.dotc.Driver.doCompile(Driver.scala:19)
[error]         at dotty.tools.dotc.Main$.doCompile(Main.scala:26)
[error]         at dotty.tools.dotc.Driver.process(Driver.scala:30)
[error]         at dotty.tools.dotc.Driver.main(Driver.scala:44)
[error]         at dotty.tools.dotc.Main.main(Main.scala)

Scalac compiles the code correctly, is this a missing feature in Dotty or are you not supporting these refinements intentionally?
CC @odersky @DarkDimius @namin

Typesafety breach due to inner trait overriding

The following code typechecks, but it seems to me that if we ran it, it would access val sort on an object of type Food, which doesn't have such a field, i.e. we'd have a typesafety breach.
I think the problem is that it should be forbidden to override trait D inside trait A2.

object test5289 {

  trait Food {}
  trait Apple extends Food {
    val sort: String
  }

  trait E {
    type T >: Food
  }

  trait A {
    trait D
    val de: D & E = new D with E
  }

  trait A2 extends A {
    // overriding trait D of A should be forbidden
    trait D {
      type T <: Apple
    }
  }

  val a2: A2 = new A2

  val de: a2.D & E = a2.de

  def downcastFoodToApple(f: Food): Apple = {
    (f: de.T): Apple
  }

  val myFood = new Food

  // myApple of type Apple references a Food (without val sort)
  val myApple: Apple = downcastFoodToApple(myFood)

  // runtime error!
  println(myApple.sort)

}

Star in patterns

A.scala:4: error: not found: type _*
  val List(1, 2, rest: _*) = List(1, 2, 3, 4, 5) // was
                       ^
exception occured while typechecking A.scala
Exception in thread "main" java.lang.ClassCastException: _$times is not a term name
    at dotty.tools.dotc.core.Names$TypeName.asTermName(Names.scala:184)
    at dotty.tools.dotc.core.Names$TypeName.asTermName(Names.scala:178)
    at dotty.tools.dotc.typer.Typer$$anonfun$typedBind$1.apply(Typer.scala:738)
    at dotty.tools.dotc.typer.Typer$$anonfun$typedBind$1.apply(Typer.scala:735)
    at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
    at dotty.tools.dotc.typer.Typer.typedBind(Typer.scala:735)
    at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:905)
    at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:958)
    at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:967)
    at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:965)
    at dotty.tools.dotc.reporting.Reporting$class.traceIndented(Reporter.scala:145)
    at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:50)
    at dotty.tools.dotc.typer.Typer.typed(Typer.scala:965)
    at dotty.tools.dotc.typer.Typer$$anonfun$typedIdent$1.apply(Typer.scala:252)
    at dotty.tools.dotc.typer.Typer$$anonfun$typedIdent$1.apply(Typer.scala:77)
    at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
    at dotty.tools.dotc.typer.Typer.typedIdent(Typer.scala:77)
    at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:902)
    at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:958)
    at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:967)
    at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:965)
    at dotty.tools.dotc.reporting.Reporting$class.traceIndented(Reporter.scala:145)
    at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:50)
    at dotty.tools.dotc.typer.Typer.typed(Typer.scala:965)
    at dotty.tools.dotc.typer.Typer.typedType(Typer.scala:1007)
    at dotty.tools.dotc.typer.Typer$$anonfun$typedTyped$1.regularTyped$1(Typer.scala:328)
    at dotty.tools.dotc.typer.Typer$$anonfun$typedTyped$1.apply(Typer.scala:336)
    at dotty.tools.dotc.typer.Typer$$anonfun$typedTyped$1.apply(Typer.scala:326)
    at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
    at dotty.tools.dotc.typer.Typer.typedTyped(Typer.scala:326)
    at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:926)
    at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:960)
    at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:967)
    at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:965)
    at dotty.tools.dotc.reporting.Reporting$class.traceIndented(Reporter.scala:145)
    at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:50)
    at dotty.tools.dotc.typer.Typer.typed(Typer.scala:965)
    at dotty.tools.dotc.typer.Typer$$anonfun$typedBind$1.apply(Typer.scala:736)
    at dotty.tools.dotc.typer.Typer$$anonfun$typedBind$1.apply(Typer.scala:735)
    at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
    at dotty.tools.dotc.typer.Typer.typedBind(Typer.scala:735)
    at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:905)
    at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:958)
    at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:967)
    at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:965)
    at dotty.tools.dotc.reporting.Reporting$class.traceIndented(Reporter.scala:145)
    at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:50)
    at dotty.tools.dotc.typer.Typer.typed(Typer.scala:965)
    at dotty.tools.dotc.typer.Typer$$anonfun$typedTyped$1.apply(Typer.scala:339)
    at dotty.tools.dotc.typer.Typer$$anonfun$typedTyped$1.apply(Typer.scala:326)
    at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
    at dotty.tools.dotc.typer.Typer.typedTyped(Typer.scala:326)
    at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:926)
    at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:960)
    at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:967)
    at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:965)
    at dotty.tools.dotc.reporting.Reporting$class.traceIndented(Reporter.scala:145)
    at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:50)
    at dotty.tools.dotc.typer.Typer.typed(Typer.scala:965)
    at dotty.tools.dotc.typer.Applications$$anonfun$typedUnApply$1$$anonfun$15.apply(Applications.scala:696)
    at dotty.tools.dotc.typer.Applications$$anonfun$typedUnApply$1$$anonfun$15.apply(Applications.scala:696)
    at scala.runtime.Tuple2Zipped$$anonfun$map$extension$1.apply(Tuple2Zipped.scala:42)
    at scala.runtime.Tuple2Zipped$$anonfun$map$extension$1.apply(Tuple2Zipped.scala:40)
    at scala.collection.immutable.List.foreach(List.scala:383)
    at scala.runtime.Tuple2Zipped$.map$extension(Tuple2Zipped.scala:40)
    at dotty.tools.dotc.typer.Applications$$anonfun$typedUnApply$1.apply(Applications.scala:696)
    at dotty.tools.dotc.typer.Applications$$anonfun$typedUnApply$1.apply(Applications.scala:529)
    at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
    at dotty.tools.dotc.typer.Applications$class.typedUnApply(Applications.scala:529)
    at dotty.tools.dotc.typer.Typer.typedUnApply(Typer.scala:56)
    at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:921)
    at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:960)
    at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:967)
    at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:965)
    at dotty.tools.dotc.reporting.Reporting$class.traceIndented(Reporter.scala:145)
    at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:50)
    at dotty.tools.dotc.typer.Typer.typed(Typer.scala:965)
    at dotty.tools.dotc.typer.Typer.typedPattern(Typer.scala:1009)
    at dotty.tools.dotc.typer.Typer$$anonfun$typedMatch$1$$anonfun$dotty$tools$dotc$typer$Typer$$anonfun$$typedCase$1$1$$anonfun$12.apply(Typer.scala:596)
    at dotty.tools.dotc.typer.Typer$$anonfun$typedMatch$1$$anonfun$dotty$tools$dotc$typer$Typer$$anonfun$$typedCase$1$1$$anonfun$12.apply(Typer.scala:596)
    at dotty.tools.dotc.typer.Typer$$anonfun$typedMatch$1$$anonfun$dotty$tools$dotc$typer$Typer$$anonfun$$typedCase$1$1.apply(Typer.scala:597)
    at dotty.tools.dotc.typer.Typer$$anonfun$typedMatch$1$$anonfun$dotty$tools$dotc$typer$Typer$$anonfun$$typedCase$1$1.apply(Typer.scala:582)
    at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
    at dotty.tools.dotc.typer.Typer$$anonfun$typedMatch$1.dotty$tools$dotc$typer$Typer$$anonfun$$typedCase$1(Typer.scala:582)
    at dotty.tools.dotc.typer.Typer$$anonfun$typedMatch$1$$anonfun$13.apply(Typer.scala:600)
    at dotty.tools.dotc.typer.Typer$$anonfun$typedMatch$1$$anonfun$13.apply(Typer.scala:600)
    at dotty.tools.dotc.core.Decorators$ListDecorator$.loop$1(Decorators.scala:50)
    at dotty.tools.dotc.core.Decorators$ListDecorator$.mapconserve$extension(Decorators.scala:66)
    at dotty.tools.dotc.typer.Typer$$anonfun$typedMatch$1.apply(Typer.scala:600)
    at dotty.tools.dotc.typer.Typer$$anonfun$typedMatch$1.apply(Typer.scala:554)
    at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
    at dotty.tools.dotc.typer.Typer.typedMatch(Typer.scala:553)
    at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:933)
    at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:960)
    at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:967)
    at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:965)
    at dotty.tools.dotc.reporting.Reporting$class.traceIndented(Reporter.scala:145)
    at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:50)
    at dotty.tools.dotc.typer.Typer.typed(Typer.scala:965)
    at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:1005)
    at dotty.tools.dotc.typer.Typer$$anonfun$typedValDef$1.apply(Typer.scala:769)
    at dotty.tools.dotc.typer.Typer$$anonfun$typedValDef$1.apply(Typer.scala:763)
    at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
    at dotty.tools.dotc.typer.Typer.typedValDef(Typer.scala:763)
    at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:908)
    at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:958)
    at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:967)
    at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:965)
    at dotty.tools.dotc.reporting.Reporting$class.traceIndented(Reporter.scala:145)
    at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:50)
    at dotty.tools.dotc.typer.Typer.typed(Typer.scala:965)
    at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:989)
    at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:1001)
    at dotty.tools.dotc.typer.Typer$$anonfun$typedClassDef$1.apply(Typer.scala:821)
    at dotty.tools.dotc.typer.Typer$$anonfun$typedClassDef$1.apply(Typer.scala:793)
    at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
    at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:793)
    at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:913)
    at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:958)
    at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:967)
    at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:965)
    at dotty.tools.dotc.reporting.Reporting$class.traceIndented(Reporter.scala:145)
    at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:50)
    at dotty.tools.dotc.typer.Typer.typed(Typer.scala:965)
    at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:989)
    at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:1001)
    at dotty.tools.dotc.typer.Typer$$anonfun$typedPackageDef$1.apply(Typer.scala:854)
    at dotty.tools.dotc.typer.Typer$$anonfun$typedPackageDef$1.apply(Typer.scala:845)
    at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
    at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:845)
    at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:949)
    at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:960)
    at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:967)
    at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:965)
    at dotty.tools.dotc.reporting.Reporting$class.traceIndented(Reporter.scala:145)
    at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:50)
    at dotty.tools.dotc.typer.Typer.typed(Typer.scala:965)
    at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:1005)
    at dotty.tools.dotc.typer.FrontEnd$$anonfun$typeCheck$1.apply$mcV$sp(FrontEnd.scala:37)
    at dotty.tools.dotc.typer.FrontEnd.monitor(FrontEnd.scala:16)
    at dotty.tools.dotc.typer.FrontEnd.typeCheck(FrontEnd.scala:35)
    at dotty.tools.dotc.typer.FrontEnd$$anonfun$runOn$3.apply(FrontEnd.scala:48)
    at dotty.tools.dotc.typer.FrontEnd$$anonfun$runOn$3.apply(FrontEnd.scala:48)
    at scala.collection.immutable.List.foreach(List.scala:383)
    at dotty.tools.dotc.typer.FrontEnd.runOn(FrontEnd.scala:48)
    at dotty.tools.dotc.Run$$anonfun$compileSources$1$$anonfun$apply$mcV$sp$3.apply(Run.scala:42)
    at dotty.tools.dotc.Run$$anonfun$compileSources$1$$anonfun$apply$mcV$sp$3.apply(Run.scala:40)
    at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:33)
    at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:186)
    at dotty.tools.dotc.Run$$anonfun$compileSources$1.apply$mcV$sp(Run.scala:40)
    at dotty.tools.dotc.Run$$anonfun$compileSources$1.apply(Run.scala:32)
    at dotty.tools.dotc.Run$$anonfun$compileSources$1.apply(Run.scala:32)
    at dotty.tools.dotc.util.Stats$.monitorHeartBeat(Stats.scala:68)
    at dotty.tools.dotc.Run.compileSources(Run.scala:31)
    at dotty.tools.dotc.Run.compile(Run.scala:28)
    at dotty.tools.dotc.Driver.doCompile(Driver.scala:19)
    at dotty.tools.dotc.Main$.doCompile(Main.scala:26)
    at dotty.tools.dotc.Driver.process(Driver.scala:30)
    at dotty.tools.dotc.Driver.main(Driver.scala:44)
    at dotty.tools.dotc.Main.main(Main.scala)

allow lazy loading of parts of types

similar to using TypeCompleters to defer loading the info of a Symbol,
it would be useful to be able to defer loading a PolyType's result type,
so that we can accurately find out its type parameters without forcing the result type (which may cause cycles / be too costly)

Infinite recursion when printing cyclic types

In this example

object infpaths {

  object a {
    trait T { t =>
      type M <: t.b.M
      type T <: a.T
      val b: t.T
    }
    val x: a.T = ???
  }

  val m1: a.x.M = ???
  val m2: a.x.b.M = m1
  val m3: a.x.b.b.M = m2

}

we run into an infinite recursion:

[info] error occurred during: TypeBounds(TypeRef(ThisType(module class scala),Nothing), TypeRef(TermRef(ThisType(module class infpaths$),a),T)): TypeBounds(TypeRef(ThisType(module class scala),Nothing), TypeRef(TermRef(ThisType(module class infpaths$),a),T)) member M
[info] exception occured while typechecking tests/pos/infpaths.scala
[error] Exception in thread "main" java.lang.StackOverflowError
[error]     at java.lang.String.getChars(String.java:826)
[error]     at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:416)
[error]     at java.lang.StringBuilder.append(StringBuilder.java:132)
[error]     at scala.collection.mutable.StringBuilder.<init>(StringBuilder.scala:47)
[error]     at scala.collection.mutable.StringBuilder.<init>(StringBuilder.scala:52)
[error]     at scala.runtime.ScalaRunTime$._toString(ScalaRunTime.scala:166)
[error]     at dotty.tools.dotc.core.Types$TermRef.toString(Types.scala:1124)
[error]     at java.lang.String.valueOf(String.java:2854)
[error]     at scala.collection.mutable.StringBuilder.append(StringBuilder.scala:198) 
[error]     at scala.collection.TraversableOnce$$anonfun$addString$1.apply(TraversableOnce.scala:345)
[error]     at scala.collection.Iterator$class.foreach(Iterator.scala:743)
[error]     at scala.collection.AbstractIterator.foreach(Iterator.scala:1174)
[error]     at scala.collection.TraversableOnce$class.addString(TraversableOnce.scala:343)
[error]     at scala.collection.AbstractIterator.addString(Iterator.scala:1174)
[error]     at scala.collection.TraversableOnce$class.mkString(TraversableOnce.scala:309)
...

Note that scalac correctly rejects this example:

<console>:12: error: cyclic aliasing or subtyping involving type M
             type M <: t.b.M
                  ^

I suspect that there might not only be a problem with printing, but also with cycle detection...

Pattern matcher produces scope-incorrect code.

When compiling pos/Coder.scala the pattern matcher produces code like this

  private val charCode0$$local: scala.collection.immutable.Map = 
  Coder.this.mnemonics.withFilter({
    def $anonfun: (x$1: Tuple2)Boolean = {
      case val selector12: Tuple2 = x$1
      {
        def case31: ()Boolean = {
          {
            def case41: ()Boolean = {
              def matchFail21: ()Boolean = throw new MatchError(selector12)
              {
                false
              }
            }
            case41()
          }
          {
            val o32: Option = Tuple2.unapply[Char, String](selector12)
            if o32.isDefined.unary_! then {
              true
            } else case41()
          }
        }
        case31()
      }
    }
    closure($anonfun)
  }

Note the second reference to case41(),

} else case41()

That reference occurs outside the block in which case41 is defined. This makes changeOwner break,
because it substitutes symbols only in the scope where the symbol is defined. Consequently, after changeOwner, the definition of case41 gets a new symbol but the last reference still points to the old symbol. And this makes LambdaLift break.

Infinite loop when type indirectly bound by itself

The following (devious) code results in an infinite loop:

class A {
  type T <: x.type
  val x: T = 42
}

This could probably be fixed by improving the checks for cycles, but it might be simpler and saner to just disallow having types bound by x.type, just like scalac, what do you think?
CC @odersky @namin .

Infinite recursion in Typer.checkAccessible

In the following example, the Typer runs into an infinite recursion (StackOverflowError):

object test534 {

  trait B {
    type D <: { type T }
    def d: D
  }

  val bc: B = new B {
    def d: D = ???
  }

  val d: bc.D = bc.d

  // infinite loop in Typer
  val asT: d.T = ???

}

Please right bias Either

Not sure what benefit there is in leaving Either unbiased (beyond, of course, not breaking existing Scala code).

Any chance this request can make it in to Dotty? I know a production ready compiler is a long way off, just putting this out there on the nice-to-have list.

Thanks

TreeTransform should allow miniphases to run fully at group end

I currently cannot merge privateToStatic with Flatten because I get a "denotation demanded before it is defined" error. The problem is the error does not appear in Flatten, in fact Flatten is nowhere on the stacktrace. The error is produced by a treecopier invoked from the standard TreeTransform.

The error could be avoided if there is some way we could run the whole phase at group end, not just some operations from it.

Missing override checks

Missing override keyword

class A

class X {
  def f: A = ???
}
class Y extends X {
  def f: A = ???
}

scalac output:

override.scala:7: error: overriding method f in class X of type => A;
 method f needs `override' modifier
  def f: A = ???
      ^
one error found

Dotty does not detect that error.

Invalid overriding

class A
class B

class X {
  def f: A = ???
}
class Y extends X {
  override def f: B = ???
}

scalac output:

override.scala:8: error: overriding method f in class X of type => A;
 method f has incompatible type
  override def f: B = ???
               ^
one error found

Dotty does not detect that error either.

CC @odersky @DarkDimius @namin

Test for memory leaks

When compiling multiple times:

  • keep a weak reference to the existing RootContext
  • after compiling, do System.gc()
  • assert that the weak reference is dead, so the RootContext was gc-ed
  • later refinement: use yourkit api to print out the links from the root (alive) objects to the objects that were supposed to be dead

-Ycheck should ensure global uniqueness of definitions

#203 uncovered a problem where a closure was generated twice with the same symbol. It was caught by phase RestoreScopes when the closure symbol ended up in two definitions in the scope of the enclosing class. This would have been caught earlier if -Ycheck verified that every symbol is defined only once in a compilation unit. Right now it detects only double definition in the same scope, or nested scopes.

isVolatile incorrect for intersection types

@namin and me had a look at the isVolatile method in Types/TypeOps.

If we try the following example:

object Test {
  trait A {
    type X = String
  }
  trait B {
    type X = Int
  }
  lazy val o: A & B = ???

  def xToString(x: o.X): String = x

  def intToString(i: Int): String = xToString(i)
}

It's accepted by dotty, which means that we can cast Int to String...

I added debug output for the results of isVolatile, and it prints

isVolatile(AndType(TypeRef(ThisType(module class Test$),A),TypeRef(ThisType(module class Test$),B)))=false

But as we understood isVolatile, it should return true for all types which are possibly uninhabited.

The and-case in needsChecking looks bad:

case AndType(l, r) =>
  needsChecking(l, true) || needsChecking(r, true)

because we cannot just look seperately at l and r, but we should check if there are conflicting members in l and r.

In Scala, this is not a problem, because we only have with, which is asymmetric, so the members of r override those of l and in our example, o.X is only Int.

From a theoretical point of view, we are bothered by the fact that !isVolatile is not preserved by weakening, i.e.

A <: B and !isVolatile(B) does not imply !isVolatile(A)

so we doubt if a !isVolatile judgment would be useful in a typesafety proof (needs more thinking...).

Additionally, if we replace the implementation of needsChecking (which seems to be just an optimization) by this

def needsChecking(tp: Type, isPart: Boolean): Boolean = true

we get a java.util.NoSuchElementException: head of empty list, so it's not just an optimization...

stale symbol; type scala$Predef$$Class$$T#4741 in type Class, defined in run 2, is referred to in run 3

When running the following test:

checkCompile("intercepted",
    """
    class A
    """
) { (tree, context) =>
  implicit val ctx = context
  println(tree.show)
}

I get the following exception:

error occurred during: ClassInfo(ThisType(module class scala), class AnyVal): ClassInfo(ThisType(module class scala), class AnyVal) member getClass
[error] Test test.transform.ConstructorsTest.printTest failed: stale symbol; type scala$Predef$$Class$$T#4741 in type Class, defined in run 2, is referred to in run 3
[error]     at dotty.tools.dotc.core.Denotations$SingleDenotation.staleSymbolError(Denotations.scala:604)
[error]     at dotty.tools.dotc.core.Denotations$SingleDenotation.bringForward(Denotations.scala:497)
[error]     at dotty.tools.dotc.core.Denotations$SingleDenotation.current(Denotations.scala:517)
[error]     at dotty.tools.dotc.core.Symbols$Symbol.denot(Symbols.scala:338)
[error]     at dotty.tools.dotc.core.Symbols$.toDenot(Symbols.scala:535)
[error]     at dotty.tools.dotc.core.pickling.UnPickler.isLocal(UnPickler.scala:283)
[error]     at dotty.tools.dotc.core.pickling.UnPickler.readType(UnPickler.scala:642)
[error]     at dotty.tools.dotc.core.pickling.UnPickler$$anonfun$readTypeRef$1.apply(UnPickler.scala:764)
[error]     at dotty.tools.dotc.core.pickling.UnPickler$$anonfun$readTypeRef$1.apply(UnPickler.scala:764)
[error]     at dotty.tools.dotc.core.pickling.UnPickler.atReadPos(UnPickler.scala:307)
[error]     at dotty.tools.dotc.core.pickling.UnPickler.at(UnPickler.scala:297)
[error]     at dotty.tools.dotc.core.pickling.UnPickler.readTypeRef(UnPickler.scala:764)
[error]     at dotty.tools.dotc.core.pickling.UnPickler$$anonfun$15.apply(UnPickler.scala:647)
[error]     at dotty.tools.dotc.core.pickling.UnPickler$$anonfun$15.apply(UnPickler.scala:647)
[error]     at dotty.tools.dotc.core.pickling.PickleBuffer.until(PickleBuffer.scala:161)
[error]     at dotty.tools.dotc.core.pickling.UnPickler.readType(UnPickler.scala:647)
[error]     at dotty.tools.dotc.core.pickling.UnPickler$$anonfun$readTypeRef$1.apply(UnPickler.scala:764)
[error]     at dotty.tools.dotc.core.pickling.UnPickler$$anonfun$readTypeRef$1.apply(UnPickler.scala:764)
[error]     at dotty.tools.dotc.core.pickling.UnPickler.atReadPos(UnPickler.scala:307)
[error]     at dotty.tools.dotc.core.pickling.UnPickler.at(UnPickler.scala:297)
[error]     at dotty.tools.dotc.core.pickling.UnPickler.readTypeRef(UnPickler.scala:764)
[error]     at dotty.tools.dotc.core.pickling.UnPickler.readType(UnPickler.scala:679)
[error]     at dotty.tools.dotc.core.pickling.UnPickler$LocalUnpickler$$anonfun$9.apply(UnPickler.scala:511)
[error]     at dotty.tools.dotc.core.pickling.UnPickler$LocalUnpickler$$anonfun$9.apply(UnPickler.scala:511)
[error]     at dotty.tools.dotc.core.pickling.UnPickler.atReadPos(UnPickler.scala:307)
[error]     at dotty.tools.dotc.core.pickling.UnPickler.at(UnPickler.scala:297)
[error]     at dotty.tools.dotc.core.pickling.UnPickler$LocalUnpickler.dotty$tools$dotc$core$pickling$UnPickler$LocalUnpickler$$parseToCompletion$1(UnPickler.scala:511)
[error]     at dotty.tools.dotc.core.pickling.UnPickler$LocalUnpickler$$anonfun$complete$1.apply$mcV$sp(UnPickler.scala:536)
[error]     at dotty.tools.dotc.core.pickling.UnPickler$LocalUnpickler$$anonfun$complete$1.apply(UnPickler.scala:536)
[error]     at dotty.tools.dotc.core.pickling.UnPickler$LocalUnpickler$$anonfun$complete$1.apply(UnPickler.scala:536)
[error]     at dotty.tools.dotc.core.pickling.UnPickler.atReadPos(UnPickler.scala:307)
[error]     at dotty.tools.dotc.core.pickling.UnPickler$LocalUnpickler.complete(UnPickler.scala:536)
[error]     at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:150)
[error]     at dotty.tools.dotc.core.SymDenotations$SymDenotation.info(SymDenotations.scala:132)
[error]     at dotty.tools.dotc.core.Types$NamedType.info(Types.scala:1130)
[error]     at dotty.tools.dotc.core.Types$TypeRef.underlying(Types.scala:1217)
[error]     at dotty.tools.dotc.core.TypeApplications$$anonfun$appliedTo$extension0$1.apply(TypeApplications.scala:137)
[error]     at dotty.tools.dotc.core.TypeApplications$$anonfun$appliedTo$extension0$1.apply(TypeApplications.scala:112)
[error]     at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
[error]     at dotty.tools.dotc.core.TypeApplications$.appliedTo$extension0(TypeApplications.scala:112)
[error]     at dotty.tools.dotc.core.pickling.UnPickler.readType(UnPickler.scala:649)
[error]     at dotty.tools.dotc.core.pickling.UnPickler$$anonfun$readTypeRef$1.apply(UnPickler.scala:764)
[error]     at dotty.tools.dotc.core.pickling.UnPickler$$anonfun$readTypeRef$1.apply(UnPickler.scala:764)
[error]     at dotty.tools.dotc.core.pickling.UnPickler.atReadPos(UnPickler.scala:307)
[error]     at dotty.tools.dotc.core.pickling.UnPickler.at(UnPickler.scala:297)
[error]     at dotty.tools.dotc.core.pickling.UnPickler.readTypeRef(UnPickler.scala:764)
[error]     at dotty.tools.dotc.core.pickling.UnPickler.readType(UnPickler.scala:684)
[error]     at dotty.tools.dotc.core.pickling.UnPickler$$anonfun$readTypeRef$1.apply(UnPickler.scala:764)
[error]     at dotty.tools.dotc.core.pickling.UnPickler$$anonfun$readTypeRef$1.apply(UnPickler.scala:764)
[error]     at dotty.tools.dotc.core.pickling.UnPickler.atReadPos(UnPickler.scala:307)
[error]     at dotty.tools.dotc.core.pickling.UnPickler.at(UnPickler.scala:297)
[error]     at dotty.tools.dotc.core.pickling.UnPickler.readTypeRef(UnPickler.scala:764)
[error]     at dotty.tools.dotc.core.pickling.UnPickler.readType(UnPickler.scala:671)
[error]     at dotty.tools.dotc.core.pickling.UnPickler$LocalUnpickler$$anonfun$9.apply(UnPickler.scala:511)
[error]     at dotty.tools.dotc.core.pickling.UnPickler$LocalUnpickler$$anonfun$9.apply(UnPickler.scala:511)
[error]     at dotty.tools.dotc.core.pickling.UnPickler.atReadPos(UnPickler.scala:307)
[error]     at dotty.tools.dotc.core.pickling.UnPickler.at(UnPickler.scala:297)
[error]     at dotty.tools.dotc.core.pickling.UnPickler$LocalUnpickler.dotty$tools$dotc$core$pickling$UnPickler$LocalUnpickler$$parseToCompletion$1(UnPickler.scala:511)
[error]     at dotty.tools.dotc.core.pickling.UnPickler$LocalUnpickler$$anonfun$complete$1.apply$mcV$sp(UnPickler.scala:536)
[error]     at dotty.tools.dotc.core.pickling.UnPickler$LocalUnpickler$$anonfun$complete$1.apply(UnPickler.scala:536)
[error]     at dotty.tools.dotc.core.pickling.UnPickler$LocalUnpickler$$anonfun$complete$1.apply(UnPickler.scala:536)
[error]     at dotty.tools.dotc.core.pickling.UnPickler.atReadPos(UnPickler.scala:307)
[error]     at dotty.tools.dotc.core.pickling.UnPickler$LocalUnpickler.complete(UnPickler.scala:536)
[error]     at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:150)
[error]     at dotty.tools.dotc.core.SymDenotations$SymDenotation.info(SymDenotations.scala:132)
[error]     at dotty.tools.dotc.core.Denotations$SingleDenotation.signature(Denotations.scala:377)
[error]     at dotty.tools.dotc.core.Denotations$SingleDenotation.containsSig(Denotations.scala:623)
[error]     at dotty.tools.dotc.core.Denotations$SingleDenotation.filterDisjoint(Denotations.scala:627)
[error]     at dotty.tools.dotc.core.Denotations$SingleDenotation.mapInherited(Denotations.scala:631)
[error]     at dotty.tools.dotc.core.Denotations$SingleDenotation.mapInherited(Denotations.scala:371)
[error]     at dotty.tools.dotc.core.SymDenotations$ClassDenotation$$anonfun$computeNPMembersNamed$1.collect$1(SymDenotations.scala:1107)
[error]     at dotty.tools.dotc.core.SymDenotations$ClassDenotation$$anonfun$computeNPMembersNamed$1.apply(SymDenotations.scala:1115)
[error]     at dotty.tools.dotc.core.SymDenotations$ClassDenotation$$anonfun$computeNPMembersNamed$1.apply(SymDenotations.scala:1092)
[error]     at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
[error]     at dotty.tools.dotc.core.SymDenotations$ClassDenotation.computeNPMembersNamed(SymDenotations.scala:1091)
[error]     at dotty.tools.dotc.core.SymDenotations$ClassDenotation.nonPrivateMembersNamed(SymDenotations.scala:1081)
[error]     at dotty.tools.dotc.core.SymDenotations$ClassDenotation.membersNamed(SymDenotations.scala:1068)
[error]     at dotty.tools.dotc.core.SymDenotations$ClassDenotation.findMember(SymDenotations.scala:1120)
[error]     at dotty.tools.dotc.core.Types$Type.go$1(Types.scala:364)
[error]     at dotty.tools.dotc.core.Types$Type.findMember(Types.scala:399)
[error]     at dotty.tools.dotc.core.Types$Type$$anonfun$member$1.apply(Types.scala:334)
[error]     at dotty.tools.dotc.core.Types$Type$$anonfun$member$1.apply(Types.scala:334)
[error]     at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
[error]     at dotty.tools.dotc.core.Types$Type.member(Types.scala:333)
[error]     at dotty.tools.dotc.core.Denotations$Denotation.requiredMethod(Denotations.scala:191)
[error]     at dotty.tools.dotc.core.Definitions.AnyVal_getClass$lzycompute(Definitions.scala:129)
[error]     at dotty.tools.dotc.core.Definitions.AnyVal_getClass(Definitions.scala:129)
[error]     at dotty.tools.dotc.transform.InterceptedMethods.init(InterceptedMethods.scala:53)
[error]     at dotty.tools.dotc.transform.TreeTransforms$TreeTransformer$$anonfun$transform$1.apply(TreeTransform.scala:500)
[error]     at dotty.tools.dotc.transform.TreeTransforms$TreeTransformer$$anonfun$transform$1.apply(TreeTransform.scala:497)
[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.transform.TreeTransforms$TreeTransformer.transform(TreeTransform.scala:497)
[error]     at dotty.tools.dotc.transform.TreeTransforms$TreeTransformer.run(TreeTransform.scala:430)
[error]     at dotty.tools.dotc.core.Phases$Phase$$anonfun$runOn$1.apply(Phases.scala:197)
[error]     at dotty.tools.dotc.core.Phases$Phase$$anonfun$runOn$1.apply(Phases.scala:197)
[error]     at scala.collection.immutable.List.foreach(List.scala:383)
[error]     at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:197)
[error]     at dotty.tools.dotc.Run$$anonfun$compileSources$1$$anonfun$apply$mcV$sp$3.apply(Run.scala:42)
[error]     at dotty.tools.dotc.Run$$anonfun$compileSources$1$$anonfun$apply$mcV$sp$3.apply(Run.scala:40)
[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:40)
[error]     at dotty.tools.dotc.Run$$anonfun$compileSources$1.apply(Run.scala:32)
[error]     at dotty.tools.dotc.Run$$anonfun$compileSources$1.apply(Run.scala:32)
[error]     at dotty.tools.dotc.util.Stats$.monitorHeartBeat(Stats.scala:68)
[error]     at dotty.tools.dotc.Run.compileSources(Run.scala:31)
[error]     at dotty.tools.dotc.Run.compile(Run.scala:63)
[error]     at test.DottyTest.checkCompile(DottyTest.scala:60)

Assertion error when compiling config files in resident mode.

using this command in directory src/dotty/tools/dotc:

scala dotty.tools.dotc.Bench #runs 2 config/Properties.scala config/PathResolver.scala

We get an assertion error on the second run. here's the full output:

max constraint = Constraint(
uninstVars = String';
constrained types = [A](xs: A*)scala.collection.immutable.List[A],
[A1 >: String'](elem: A1)Boolean
;
constraint =
A
A1 >: String'
)
time elapsed: 2176ms
assertion failure for >: String <: String <:< A, frozen = false
: String <: String is a class dotty.tools.dotc.core.Types$CachedTypeBounds
polyparam A found in [A](self: A)ArrowAssoc[A]
assertion failure for (self: A)ArrowAssoc[A] <:< >: String <: String ?=>? >: String <: String, frozen = false
(self: A)ArrowAssoc[A] is a class dotty.tools.dotc.core.Types$CachedMethodType
: String <: String ?=>? >: String <: String is a class dotty.tools.dotc.typer.Inferencing$CachedViewProto
exception occured while typechecking dotc/config/PathResolver.scala
java.lang.AssertionError: assertion failed
at scala.Predef$.assert(Predef.scala:151)
at dotty.tools.dotc.core.Types$TypeBounds.(Types.scala:1870)
at dotty.tools.dotc.core.Types$CachedTypeBounds.(Types.scala:1962)
at dotty.tools.dotc.core.Uniques$TypeBoundsUniques.newBounds$1(Uniques.scala:84)
at dotty.tools.dotc.core.Uniques$TypeBoundsUniques.enterIfNew(Uniques.scala:90)
at dotty.tools.dotc.core.Types$TypeBounds$.apply(Types.scala:1978)`

Self definition shadows members in template

The way it works now in Scala 2.11:

scala> new { foo => val foo = 2; println(foo) }
$line5.$read$$iw$$iw$$anon$1@5ef50743
res2: AnyRef{val foo: Int} = $anon$1@5ef50743

This behaviour is quite surprising. I'd expect to either see a double definition error or to have template member shadow self definition in that scope.

LMS-inspired test cases for higher-kinded types

This compiles without error:

import scala.language.higherKinds

trait Base {
  type Rep[T]
}

trait BaseExp extends Base {
  type Rep[T] = Exp[T]
  case class Exp[T](v: T)
}

The next trait compiles with an error (which feels inadequate and the source location is lost during reporting):

trait BaseStr extends Base {
  type Rep[T] = String
}
error: right-hand side of parameterized alias type must refer to a class
one error found

The next trait compiles with the same error (though I guess it is by design here and the source location is preserved):

trait BaseDirect extends Base {
  type Rep[T] = T
}
error: right-hand side of parameterized alias type must refer to a class
  type Rep[T] = T
             ^
one error found

All these traits compile fine with Scala 2.10.3.

Typer calls NoDenotation.owner if bad structural type

[Low priority]

In this example,

object test {
  type X = { val m: BadType }
}

the BadType is correctly rejected, but then typechecking continues and throws an uncaught exception:

[error] tests/neg/NoDenotationOwner.scala:2: error: not found: type BadType
[error]   type X = { val m: BadType }
[error]                     ^
[info] exception occured while typechecking tests/neg/NoDenotationOwner.scala
[error] Exception in thread "main" java.lang.AssertionError: NoDenotation.owner
[error]     at dotty.tools.dotc.core.SymDenotations$NoDenotation$.owner(SymDenotations.scala:1228)
[error]     at dotty.tools.dotc.typer.Typer$$anonfun$typedRefinedTypeTree$1$$anonfun$dotty$tools$dotc$typer$Typer$$anonfun$$addRefinement$1$2.apply(Typer.scala:671)
[error]     at dotty.tools.dotc.typer.Typer$$anonfun$typedRefinedTypeTree$1$$anonfun$dotty$tools$dotc$typer$Typer$$anonfun$$addRefinement$1$2.apply(Typer.scala:669)
[error]     at dotty.tools.dotc.ast.Trees$Instance$$anon$1.traverse(Trees.scala:889)
...

Migration tool should add result types of implicit definitions

I noted that a lot of tests have implicit definitions such as

 implicit val hello = "hello"
 implicit def convert(x: String) = x.length

which lack an explicit result type. These are no longer valid in dotty. So it would be great if the migration tool adds the result type.

Deal with expansion lost caused by intersection

From Section 4.2 of the FOOL'12 DOT paper:

object test {

  trait T1 {
    type A <: B
    type B
  }

  trait T2 {
    type A
    type B <: A
  }

  val x: T1 & T2 = ???
  val y: x.A = 42

}

This example sends dotty into an infinite loop. In Scala 2, this cannot happen because there's no symmetric type intersection.

typer hang using `type` keyword on a class type param

class B[type X] { def foo(x: X) = ??? }
"main" prio=5 tid=7fe537800800 nid=0x104197000 runnable [104191000]
   java.lang.Thread.State: RUNNABLE
    at dotty.tools.dotc.core.Types$Type.termSymbol(Types.scala:251)
    at dotty.tools.dotc.typer.Checking$class.checkValue(Checking.scala:42)
    at dotty.tools.dotc.typer.Typer.checkValue(Typer.scala:51)
    at dotty.tools.dotc.typer.Typer$$anonfun$typedIdent$1.apply(Typer.scala:263)
    at dotty.tools.dotc.typer.Typer$$anonfun$typedIdent$1.apply(Typer.scala:72)
    at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
    at dotty.tools.dotc.typer.Typer.typedIdent(Typer.scala:72)

The cycle:

(this, this.underlying(ctx), this.underlying(ctx).underlying(ctx), this.underlying(ctx).underlying(ctx).underlying(ctx))

_1 = {dotty.tools.dotc.core.Types$CachedTypeBounds@2600}"TypeAlias(TypeRef(ThisType(class B),X))"
_2 = {dotty.tools.dotc.core.Types$CachedTypeRef@2642}"TypeRef(ThisType(class B),X)"
_3 = {dotty.tools.dotc.core.Types$CachedTypeBounds@2600}"TypeAlias(TypeRef(ThisType(class B),X))"
_4 = {dotty.tools.dotc.core.Types$CachedTypeRef@2642}"TypeRef(ThisType(class B),X)"

tpd.ModuleDef fails if owner isn't a class

If one tries to construct such class by hand using tpd.*

class A{
  def p() = {
    object B {val d = 1};
    B.d
  }
}

During creation of object B, Symbol.newModuleSymbol will try to get TermRef(owner.thisType, name), with will obviously lead to prefix being NoPrefix(just like it is in typeCheker generated symbols for such code) which in turn will cause this assertion to fail: https://github.com/lampepfl/dotty/blob/d827b0180b05e7461856f668c3c4ca0ea6ed5d62/src/dotty/tools/dotc/core/Types.scala#L1186

necessary and sufficient conditions for inclusion in InnerClasses JVM attribute

Emitting a class file involves populating its InnerClass table as per the JVM spec.

For that, GenBCode follows the same strategy GenASM does (which in turn follows what GenJVM did): intercepting via asmClassType() each usage of a class-name in the class file being emitted.

That gives the right answer about 99.9% of the time. However as https://issues.scala-lang.org/browse/SI-6759 explains, there are cases where that approach includes too much in the InnerClasses table.

GenBCode has a solution for that, refreshInnerClasses(), which should be adopted as the primary mechanism (throwing away the innerClassBufferASM that's part of the BCInnerClassGen trait).

Select symbols also need to be modified in TreeTypeMap\TreeMap

Such code will break extensionMethods(and similar breaks tailcalls).

package dotty.tools.dotc
package transform

import dotty.tools.dotc.core.Denotations._
import dotty.tools.dotc.core.Symbols._
import dotty.tools.dotc.core.Contexts._

class TC5(val ctx: Context) extends AnyVal {
  def candidates(mbr: SingleDenotation): Boolean = {
    implicit val c: Context = ctx
    mbr.symbol.exists
  }
}

After creating a fullyParameterizedDef, Select(mbr, 'symbol') has invalid symbol and thus NoType. Ycheck will die trying to find implicit conversion.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.