Skip to content

Type member widened to Any when passed out of inline method #10343

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

Open
LPTK opened this issue Nov 16, 2020 · 2 comments
Open

Type member widened to Any when passed out of inline method #10343

LPTK opened this issue Nov 16, 2020 · 2 comments

Comments

@LPTK
Copy link
Contributor

LPTK commented Nov 16, 2020

Minimized code

class C {
  type A
  inline def test: A = ???
}
@main def m = {
  val c = C()
  val x: c.A = c.test
}

Output

Found:    Any
Required: c.A

https://scastie.scala-lang.org/dB277yJnSs6qID8kkxvZxA

Expectation

Compiles.

@odersky
Copy link
Contributor

odersky commented Apr 6, 2022

It now works with transparent inline. It also compiles OK as given with inline, but fails at Ycheck:

*** error while checking test.scala after phase inlining ***
exception occurred while compiling test.scala
java.lang.AssertionError: assertion failed: Found:    Any
Required: c.A
found: class Any in package scala with class Any, flags = open abstract <noinits> <permanent>, underlying = Any, {...}
expected: type A in class C with type A, flags = <deferred> <touched>, underlying = c.A, , Any, {...}
tree = {
  val C_this: (c : C) = c
  ??? :C_this.A
} while compiling test.scala
Exception in thread "main" java.lang.AssertionError: assertion failed: Found:    Any
Required: c.A
found: class Any in package scala with class Any, flags = open abstract <noinits> <permanent>, underlying = Any, {...}
expected: type A in class C with type A, flags = <deferred> <touched>, underlying = c.A, , Any, {...}
tree = {
  val C_this: (c : C) = c
  ??? :C_this.A
}
	at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
	at dotty.tools.dotc.transform.TreeChecker$Checker.adapt(TreeChecker.scala:598)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2960)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2964)
	at dotty.tools.dotc.transform.TreeChecker$Checker.typed(TreeChecker.scala:309)```

@odersky
Copy link
Contributor

odersky commented Apr 6, 2022

@mbovel , @nicolasstucki I assigned to you both since this is at the intersection of inlining and dependent typing.

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

4 participants