Skip to content

SCL-23859: show kind mismatch error for existential types #696

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
wants to merge 1 commit into
base: idea251.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,10 @@ object ScParameterizedTypeElementAnnotator extends ElementAnnotator[ScParameteri
(arg, param) <- args.zip(params)
argTy <- getType(arg).toOption
range = if (isForContextBound) annotationRange else arg.getTextRange
if !argTy.is[ScExistentialArgument, ScExistentialType] &&
!argIsDesignatedToTypeVariable(arg) &&
if !argIsDesignatedToTypeVariable(arg) &&
!KindProjectorUtil.syntaxIdsFor(arg).contains(arg.getText)
} {
checkBounds(range, argTy, param, substitute)
if(!argTy.is[ScExistentialArgument, ScExistentialType]) checkBounds(range, argTy, param, substitute)
checkHigherKindedType(range, argTy, param, substitute)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ class ScGenericCallAnnotatorTest extends SimpleTestCase {
assertMessages(messages("testHk[HkArg]"))(
Error("HkArg", "Type constructor HkArg does not conform to CC[X >: B <: B, _]")
)

assertMessages(messages("class Test[X, Y]; testHk[Test[_, _]]"))(
Error("Test[_, _]", "Expected type constructor CC[X >: B <: B, _]")
)
}

def testTypeConstructorParameter(): Unit = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,19 @@ class ScParameterizedTypeElementAnnotatorTest_scala_2 extends ScParameterizedTyp
))
}

def testExistentialTypeKindMismatch(): Unit = {
assertMessages(messages(
"""
|class Option[A]
|class TestClass[F[_]]
|
|def test: TestClass[Option[_]] = ???
|""".stripMargin
))(
Error("Option[_]", "Expected type constructor F[_]")
)
}

def testUnresolved(): Unit = {
assertNothing(messages(
"""
Expand Down
Loading