Skip to content

Recent regression in interaction between match types and implicit conversion under separate compilation #20136

Closed
@smarter

Description

@smarter

Compiler version

This broke after #19871 was merged. It works in d2a6392

Minimized code

A_1.scala:

package a

trait Expr:
  type Value
object Expr:
  type Of[V] = Expr { type Value = V }
  type ExtractValue[E <: Expr] = E match
    case Expr.Of[v] => v

B_2.scala

package a

trait TC[E <: Expr]:
  type Elem = Expr.ExtractValue[E]
class BIExpr extends Expr:
  type Value = BigInt
class Foo extends TC[BIExpr]:
  val v: Elem = 0

Output

> scalac A_1.scala B_2.scala -d join_out
> scalac A_1.scala -d a_out
> scalac B_2.scala -classpath a_out -d b_out
-- [E007] Type Mismatch Error: B_2.scala:8:16
8 |  val v: Elem = 0
  |                ^
  |                Found:    (0 : Int)
  |                Required: Foo.this.Elem
  |
  |                The following import might fix the problem:
  |
  |                  import scala.math.BigInt.int2bigInt
  |

Expectation

Join and separate compilation should both compile.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions