Skip to content

The rules for block typing are non-intuitive #360

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

Closed
smarter opened this issue Feb 11, 2015 · 1 comment
Closed

The rules for block typing are non-intuitive #360

smarter opened this issue Feb 11, 2015 · 1 comment
Assignees

Comments

@smarter
Copy link
Member

smarter commented Feb 11, 2015

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

@smarter smarter self-assigned this Nov 23, 2015
@smarter
Copy link
Member Author

smarter commented Nov 23, 2015

Here's another example that fails with dotty and works with scala2:

class Foo {
  type A
}
object Test {
  def foo(foo: Foo)(y: foo.A) = y
  foo(new Foo { type A = Int })(1)
}

odersky added a commit to dotty-staging/dotty that referenced this issue Mar 12, 2017
odersky added a commit to dotty-staging/dotty that referenced this issue Mar 12, 2017
tgodzik added a commit to tgodzik/scala3 that referenced this issue Apr 29, 2025
Backport "Call dealias after stripping type variables for tupleElementTypesUpTo" to 3.3 LTS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant