Regression in type inference
Closed this issue · 3 comments
WojciechMazur commented
Issues observed in multiple OpenCB projects, currently reproduced based on tkrs/fluflu
All of the projects below are pointing to the same commit when performing a project-wise bisect.
| Project Name | Version | Build Logs | Notes |
|---|---|---|---|
| ichoran/kse3 | 0.3.11 | Open CB logs | Needs minimization |
| appliedtopology/tda4j | 0.1.0-alpha | Open CB logs | Needs minimization |
| thoughtworksinc/dsl.scala | 2.0.0 | Open CB logs | Needs minimization |
| sagifogel/proptics | 0.5.2 | Open CB logs | Needs minimization |
| quafadas/vecxt | 0.0.25 -> 0.0.26 | Open CB logs | Needs minimization |
| unibas-gravis/scalismo | 1.0-RC1 | Open CB logs | Needs minimization |
| tkrs/fluflu | 0.24.11 | Open CB logs | Reproducer below |
Compiler version
3.7.0-RC1-NIGHTLY
Bisect points to #21744 - 32ac2e6
Minimized code
import java.util.concurrent.ScheduledExecutorService
import java.util.concurrent.TimeUnit
def Test = {
val worker: ScheduledExecutorService = ???
object Worker extends Runnable {
def fails(): Either[Exception, Unit] = Right(worker.schedule(this, 5, TimeUnit.NANOSECONDS))
def works(): Either[Exception, Unit] = Right {
worker.schedule(this, 5, TimeUnit.NANOSECONDS); ()
}
def run(): Unit = ???
}
}Output
-- [E007] Type Mismatch Error: /Users/wmazur/projects/scala/community-build3/test.scala:7:65 ---------------------------------------------------------------------------------------------------------------
7 | def fails(): Either[Exception, Unit] = Right(worker.schedule(this, 5, TimeUnit.NANOSECONDS))
| ^^^^
| Found: (test$package.Worker : Worker.type)
| Required: java.util.concurrent.Callable[V]
|
| where: V is a type variableExpectation
Should compile
smarter commented
Minimized a bit more:
trait Invariant[T]
trait Foo
trait Bar[T]
trait Worker:
def schedule(command: Foo): Invariant[?]
def schedule[V](callable: Bar[V]): Invariant[V]
object Test:
def test(worker: Worker, foo: Foo): Option[Unit] =
Some(worker.schedule(foo))
// error: Found: Foo
// Required: Bar[V]
Gedochao commented
@WojciechMazur we likely need to revert the change for 3.7.0