-
Notifications
You must be signed in to change notification settings - Fork 2
Update to Scala 3.3.0 #2
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
Conversation
Ok, so it looks like the type inference is what causes the issue. When using methods that make use of the That being said, given it's a fix that can only be done by the user, I'm not sure we should upgrade to 3.3.0 yet. Here is the stack trace of the compiler error:
|
I ran a code snippet on the compiler code base (snippet at the end) and found out that this bug was introduced in the commit scala/scala3@b429e6b. That being said, it is fairly possible that this commit only exhibit the issue (cause of the added cast) as opposed to be the root cause of it. code snippetpackage mock
import eu.monniot.scala3mock.main.withExpectations
import eu.monniot.scala3mock.functions.MockFunctions
import eu.monniot.scala3mock.main.*
import eu.monniot.scala3mock.matchers.MatchAny
import eu.monniot.scala3mock.macros.*
import eu.monniot.scala3mock.handlers.CallHandler1
import eu.monniot.scala3mock.functions.MockFunction1
import eu.monniot.scala3mock.context.MockContext
import eu.monniot.scala3mock.main.Default
trait TestTrait {
//def polymorphic[T](x: List[T]): String
def polymorphic(x: (Int, Double)): String
def oneParam(x: List[Int]): String
}
def main(using mc: MockContext) =
val m = mock[TestTrait]
when(m.oneParam).expects(List(2))
() |
Confirmed that the commit only made the error apparent. When compiling the snippet under 3.2.2 with the |
Thanks for the investigation! I've minimized this to: class MockFunction1[T1]:
def expects(v1: T1 | Foo): Any = ???
def expects(matcher: String): Any = ???
def when[T1](f: T1 => Any): MockFunction1[T1] =
???
class Foo
def main =
val f: Foo = new Foo
when((x: Foo) => "").expects(f) I'm working on a fix currently. |
Oh nice! I didn't had time to work on side projects over the past two weeks, thanks for taking the time to write a minimizer! |
This fixes the logic taking the signature of a type uninstantiated type variables (using tpnme.Uninstantiated) and non-permanently instantiated type variables (which have a legitimate signature in the currenty TyperState but cannot be cached). The test case was minimized from fmonniot/scala3mock#2.
Given it's the first LTS, we should try to stay on it. Although given metaprogramming is one aspect that make progress relatively quickly, maybe we will jump on a feature release (for example if the implicit/using modified is made accessible when creating functions)