Skip to content

Yet more errors in code execution order #11756

@soronpo

Description

@soronpo

This is a following bug to #11397
Indeed that bug was fixed, but as it turns out the general problem was not fixed. Here is a minimized code that throws an exception when the problem exists.

trait MyAny {
  type TSomething
  type This <: MyAny
}

class MyBool extends MyAny {
  type TSomething = DummyImplicit
  type This = MyBool
}

object Test extends App {
  val i = new MyBool
  var call = 0
  var callList : List[Int] = List()

  final class MyMatch[MV <: MyAny](val matchVal : MV)  {
    def myCase[MC](pattern : Boolean)(block : => Unit)(
      implicit patternBld : matchVal.TSomething
    ) : MyMatch[MV] = {
      call -= 1
      block
      this
    }
  }

  def myMatch[MV <: MyAny](matchValue : MV) : MyMatch[matchValue.This] = {
    callList = callList :+ call
    call += 1
    new MyMatch[matchValue.This](matchValue.asInstanceOf[matchValue.This])
  }

  myMatch(i)
    .myCase(true) {
      myMatch(i)
        .myCase(true) {

        }
    }
    .myCase(true) {
      myMatch(i)
        .myCase(true) {

        }
    }
  
  assert(callList == List(0, 0, -1))
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions