Skip to content

Unexpected error message when typing wildcard parameters in pattern #14760

Closed
@Linyxus

Description

@Linyxus

Compiler version

3.1.2-RC2

Minimized code

enum SUB[-A, +B]:
  case Refl[X]() extends SUB[X, X]

def foo[C, A >: C <: C, B](e: SUB[B, A]) = e match
  case SUB.Refl() =>

It seems that in the code snippet above, the compiler wrongly assumes that the wildcard argument X$1 (which is the type parameter of class Refl) is a higher-kinded type. And it complains that there is no type parameters supplied to X$1. However, it is simple-kinded.

I found that the bound A >: C <: C is necessary to trigger the error. And we have to match SUB[B, A] instead of SUB[A, B]. Not sure how these conditions are related to this issue.

Output

[info] running (fork) dotty.tools.dotc.Main -classpath /Users/linyxus/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.8/scala-library-2.13.8.jar:/Users/linyxus/Workspace/dotty/library/../out/bootstrap/scala3-library-bootstrapped/scala-3.1.3-RC1-bin-SNAPSHOT-nonbootstrapped/scala3-library_3-3.1.3-RC1-bin-SNAPSHOT.jar -color:never issues/simple-kind-error.scala
-- [E141] Type Error: issues/simple-kind-error.scala:5:15 -----------------------------------------------------------------------------------------------------------------------------------------------------------
5 |  case SUB.Refl() =>
  |               ^
  |               Missing type parameters for X$1
  |
  | longer explanation available when compiling with `-explain`
1 error found
[error] Nonzero exit code returned from runner: 1
[error] (scala3-compiler / Compile / runMain) Nonzero exit code returned from runner: 1
[error] Total time: 3 s, completed Mar 23, 2022, 7:59:28 PM

Expectation

The code should compile.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions