Skip to content

The rules for block typing are non-intuitive #360

@smarter

Description

@smarter

This example from tests/pos/t1569a.scala works:

object Bug2 {
  class C { type T }
  class D extends C { type T = String }
  def foo(x: Int)(y: C)(z: y.T): Unit = {}
  foo(3)(new D)("hello")
}

But replacing new D by new D {} fails with:

tests/pos/t1569a.scala:11: error: type mismatch:
 found   : String("hello")
 required: Bug2.C#T
  foo(3)(new D { })("hello")
                    ^
one error found

Whether the expected type of the parameter is used or not is determined by Typer#ensureNoLocalRefs

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions