scala / scala3

The Scala 3 compiler, also known as Dotty.
https://dotty.epfl.ch
Apache License 2.0
5.72k stars 1.04k forks source link

Context bounds types are not simplified in TASTy #20901

Closed bishabosha closed 6 days ago

bishabosha commented 1 week ago

Compiler version

3.5.0-RC1

Context bounds are not simplified before TASTy any more (possibly due to modularity PR?),

e.g.

def test[T: ClassTag] = ???

will appear in TASTy as

def test[T](implicit evidence$1: ([T1] =>> ClassTag[T1])[T]) = ???

Minimized code

package foo

import scala.reflect.ClassTag

class Foo {
  def test[T: ClassTag] = new Array[T](0)
}

Output

> scalac -decompile out/foo/Foo.tasty
/** Decompiled from out/foo/Foo.tasty */
package foo {
  import scala.reflect.{ClassTag}
  @scala.annotation.internal.SourceFile("Foo.scala") class Foo() {
    def test[T](implicit evidence$1: [T >: scala.Nothing <: scala.Any] =>> scala.reflect.ClassTag[T][T]): scala.Array[T] = scala.runtime.Arrays.newGenericArray[T](0)(evidence$1)
  }
}

Expectation

As with 3.4.2:

/** Decompiled from out-3.4/foo/Foo.tasty */
package foo {
  import scala.reflect.{ClassTag}
  @scala.annotation.internal.SourceFile("Foo.scala") class Foo() {
    def test[T](implicit evidence$1: scala.reflect.ClassTag[T]): scala.Array[T] = scala.runtime.Arrays.newGenericArray[T](0)(evidence$1)
  }
}