Skip to content

Fix #12739: Handle type alias in capturing wildcards #12795

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
wants to merge 1 commit into from

Conversation

liufengyun
Copy link
Contributor

Fix #12739: Handle type alias in capturing wildcards

@dwijnand
Copy link
Member

[error] -- [E007] Type Mismatch Error: /__w/dotty/dotty/community-build/community-projects/shapeless/modules/deriving/src/test/scala/shapeless3/deriving/type-classes.scala:570:138 
[error] 570 |      genu.fromRepr(mkRecord[genu.MirroredElemLabels, genu.MirroredElemTypes, gent.MirroredElemLabels, gent.MirroredElemTypes](gent.toRepr(t)))
[error]     |                                                                                                                               ^^^^^^^^^^^^^^
[error]     |Found:    ?1.MirroredElemTypes
[error]     |Required: gent.MirroredElemTypes
[error]     |
[error]     |where:    ?1 is an unknown value of type deriving.Mirror.Product{
[error]     |  Kind = shapeless3.deriving.K0.type; MirroredType = T; MirroredElemTypes; 
[error]     |    MirroredElemTypes <: NonEmptyTuple
[error]     |}
[error] one error found
[error] one error found
[error] (deriving / Test / compileIncremental) Compilation failed
[error] Total time: 10 s, completed Jun 12, 2021 9:01:03 AM

@anatoliykmetyuk
Copy link
Contributor

@liufengyun are you planning to get back to this one? If not, can it be closed?

@dwijnand dwijnand self-assigned this Jul 27, 2021
@liufengyun
Copy link
Contributor Author

@liufengyun are you planning to get back to this one? If not, can it be closed?

I investigated the community build failure some time ago, but could not figure out the cause.

I see you self-assigned, could you lend a hand, @dwijnand? Thank you.

@dwijnand
Copy link
Member

I misread the PR, so now it's a challenge whether I can figure it out or not... :-D

@dwijnand
Copy link
Member

dwijnand commented Aug 4, 2021

Minimised:

type Foo = { type Bar }

extension (foo: Foo)
  def toBar(): foo.Bar = ???

def test(foo: Foo): foo.Bar = foo.toBar()
-- [E007] Type Mismatch Error: tests/pos/i12739-fallout.scala:6:39 -----------------------------------------------------
6 |def test(foo: Foo): foo.Bar = foo.toBar()
  |                              ^^^^^^^^^^^
  |                              Found:    ?1.Bar
  |                              Required: foo.Bar
  |
  |                              where:    ?1 is an unknown value of type Object{Bar}

@liufengyun does that ring any bells? Any ideas?

@liufengyun
Copy link
Contributor Author

Nice minimization @dwijnand 👍

It seems dealias changes the type checking path:

      val captured = captureWildcards(wtp)
      if (captured `ne` wtp)
        return readapt(tree.cast(captured))

Previously, the if branch was not taken. After dealiasing, it's taken incorrectly.

With the minimization (which is the most difficult part), you are closer to a fix. What about you make a new PR with a proper fix and we close this one?

@liufengyun liufengyun closed this Aug 5, 2021
@liufengyun liufengyun deleted the fix-12739 branch August 5, 2021 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

asInstanceOf causes type mismatch error when used in method argument position
3 participants