Skip to content

Fix #12278: Also tryNormalize LazyRefs #12281

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 1 commit into from
May 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2816,6 +2816,8 @@ object Types {
private var myRef: Type = null
private var computed = false

override def tryNormalize(using Context): Type = ref.tryNormalize

def ref(using Context): Type =
if computed then
if myRef == null then
Expand Down
16 changes: 16 additions & 0 deletions tests/pos/12278.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import scala.compiletime.ops.int.*

object Test {
type Fib[N <: Int] <: Int = N match {
case 0 => 0
case 1 => 1
case Any => Fib[N - 1] + Fib[N - 2]
}
val fib0: Fib[0] = 0
val fib1: Fib[1] = 1
val fib2: Fib[2] = 1
val fib3: Fib[3] = 2
val fib4: Fib[4] = 3
val fib5: Fib[5] = 5
val fib6: Fib[6] = 8
}