Skip to content

Ycheck fails with bad interaction between inline parameters and singleton types #11163

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
nicolasstucki opened this issue Jan 19, 2021 · 2 comments · Fixed by #12847
Closed

Comments

@nicolasstucki
Copy link
Contributor

Minimized code

inline def summonA[T](using x: T): x.type = x
inline def summonB[T](using inline x: T): x.type = x
inline def summonC[T](using inline x: T): T = x

trait Foo:
  def f: Int = 9

def test(using Foo) =
  summonA[Foo].f
  summonB[Foo].f
  summonC[Foo].f
  ()

Output

10 |  summonB[Foo].f
   |  ^^^^^^^^^^^^^^
   |  value f is not a member of T

Expectation

summonB[Foo].f should compile

@nicolasstucki
Copy link
Contributor Author

nicolasstucki commented Jan 19, 2021

Workaround

transparent inline def summonD[T](using inline x: T): T = x

or

transparent inline def summonD[T](using inline x: T): x.type = x

@odersky
Copy link
Contributor

odersky commented Feb 25, 2021

This now fails Ycheck after phase inlining with

*** error while checking i11163.scala after phase inlining ***
exception occurred while compiling i11163.scala
java.lang.AssertionError: assertion failed: Selection (x$1:x$1.type).f with type T#f.type does not have a denotation while compiling i11163.scala
Exception in thread "main" java.lang.AssertionError: assertion failed: Selection (x$1:x$1.type).f with type T#f.type does not have a denotation

The offending line is this:

exception while typing (x$1:x$1.type).f of class class dotty.tools.dotc.ast.Trees$Select # -1

@odersky odersky assigned nicolasstucki and unassigned odersky Feb 25, 2021
@nicolasstucki nicolasstucki changed the title Bad interaction between inline parameters and singleton types Ycheck fails with bad interaction between inline parameters and singleton types Apr 15, 2021
@nicolasstucki nicolasstucki removed their assignment Apr 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants