Skip to content
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

Error on type projection C[_]#K #12463

Open
lrytz opened this issue Sep 16, 2021 · 6 comments
Open

Error on type projection C[_]#K #12463

lrytz opened this issue Sep 16, 2021 · 6 comments
Assignees
Labels
fixed in Scala 3 This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/) infer
Milestone

Comments

@lrytz
Copy link
Member

lrytz commented Sep 16, 2021

import scala.language.higherKinds

trait B
class C[CC[_] <: B] {
  class K
}

object O {
  def t1(x: Any): Int = x match {
    case _: C[_]#K => 0
  }
  def t2(x: Any) = x.isInstanceOf[C[_]#K]
}

t1 fails in type checking, only if CC is higher-kinded

A.scala:10: error: type arguments [_] do not conform to class C's type parameter bounds [CC[_] <: B]
    case _: C[_]#K => 0
            ^

t2 fails in parsing

A.scala:12: error: unbound wildcard type
  def t2(x: Any) = x.isInstanceOf[C[_]#K]
                                    ^

Both work in Scala 3.

Interestingly, t1 compiles with Scala 2.12.14/15, but fails in the same way as 2.13.6 when adding the semanticdb-scalac compiler plugin (🤷‍♂️).

$> sc12 -Xplugin:/Users/luc/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scalameta/semanticdb-scalac_2.12.15/4.4.28/semanticdb-scalac_2.12.15-4.4.28.jar A.scala
A.scala:10: error: type arguments [_] do not conform to class C's type parameter bounds [CC[_] <: B]
    case _: C[_]#K => 0
            ^
@lrytz lrytz added the infer label Sep 16, 2021
@lrytz lrytz added this to the 2.13.7 milestone Sep 16, 2021
@lrytz lrytz self-assigned this Sep 16, 2021
@som-snytt
Copy link

No diff with scala/scala#9712

@lrytz
Copy link
Member Author

lrytz commented Sep 17, 2021

Also in the same ballpark, works in Scala 3:

scala> class C[CC[_]]
scala> def f: C[_] = null
                ^
       error: _$1 takes no type parameters, expected: 1

@joroKr21
Copy link
Member

Isn't that related to #8039?

@lrytz
Copy link
Member Author

lrytz commented Sep 17, 2021

very much, thanks @joroKr21. It comes with one of @retronym's wip branches :-) https://github.com/retronym/scala/tree/ticket/8039

@joroKr21
Copy link
Member

@lrytz did you try that patch? I saw that you merged a workaround.

@lrytz
Copy link
Member Author

lrytz commented Sep 27, 2021

@joroKr21 no, I didn't try the patch...

@SethTisue SethTisue modified the milestones: 2.13.7, 2.13.8 Oct 21, 2021
@dwijnand dwijnand added the fixed in Scala 3 This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/) label Nov 18, 2021
@SethTisue SethTisue modified the milestones: 2.13.8, 2.13.9 Dec 15, 2021
@SethTisue SethTisue modified the milestones: 2.13.9, 2.13.10, Backlog Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed in Scala 3 This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/) infer
Projects
None yet
Development

No branches or pull requests

5 participants