Skip to content

Unnecessary widening of type parameter with path dependency #9531

Closed
@nicolasstucki

Description

@nicolasstucki

Minimized example

trait Scope:
  type Expr[+T]

def exprQuote[T](x: T)(using s: Scope): s.Expr[T] = ???

def test(using s: Scope): Unit =
  val t1: s.Expr[1] = exprQuote(1)
  val t2 = exprQuote(1)
  val t3: s.Expr[1] = t2

Output

-- [E007] Type Mismatch Error: Foo.scala:9:22 ----------------------------------
9 |  val t1: s.Expr[1] = exprQuote(1)
  |                      ^^^^^^^^^^^^
  |                      Found:    s.Expr[Int]
  |                      Required: s.Expr[(1 : Int)]
-- [E007] Type Mismatch Error: Foo.scala:11:22 ---------------------------------
11 |  val t3: s.Expr[1] = t2
   |                      ^^
   |                      Found:    (t2 : s.Expr[Int])
   |                      Required: s.Expr[(1 : Int)]

Expectation

Should be able to infer the precise type

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions