From 8b84cab7c62617e96652a03e5c24b6b3663040f9 Mon Sep 17 00:00:00 2001 From: Nikita Gazarov Date: Sat, 23 Dec 2023 01:43:17 -0800 Subject: [PATCH] Add tests to verify that crash is fixed elsewhere. Fixes #19328 [Cherry-picked 8d7eda44260db1a2baf4434a06c448c078b462f4] --- tests/neg/i19328.check | 4 ++++ tests/neg/i19328.scala | 14 ++++++++++++++ tests/neg/i19328conversion.check | 4 ++++ tests/neg/i19328conversion.scala | 13 +++++++++++++ 4 files changed, 35 insertions(+) create mode 100644 tests/neg/i19328.check create mode 100644 tests/neg/i19328.scala create mode 100644 tests/neg/i19328conversion.check create mode 100644 tests/neg/i19328conversion.scala diff --git a/tests/neg/i19328.check b/tests/neg/i19328.check new file mode 100644 index 000000000000..357be5b2d530 --- /dev/null +++ b/tests/neg/i19328.check @@ -0,0 +1,4 @@ +-- [E172] Type Error: tests/neg/i19328.scala:14:5 ---------------------------------------------------------------------- +14 | bar // error: missing implicit (should not crash) + | ^ + | No given instance of type Boolean was found for parameter bool of method bar in object i19328 diff --git a/tests/neg/i19328.scala b/tests/neg/i19328.scala new file mode 100644 index 000000000000..246491e663bd --- /dev/null +++ b/tests/neg/i19328.scala @@ -0,0 +1,14 @@ +import scala.language.implicitConversions + +object i19328: + + trait Foo[B] + given foo[C]: Foo[C] = new Foo[C] {} + + type Id[A] = A + + implicit def wrapId[A](a: A): Id[A] = a + + def bar(using bool: Boolean): Unit = () + + bar // error: missing implicit (should not crash) diff --git a/tests/neg/i19328conversion.check b/tests/neg/i19328conversion.check new file mode 100644 index 000000000000..46d05211d43d --- /dev/null +++ b/tests/neg/i19328conversion.check @@ -0,0 +1,4 @@ +-- [E172] Type Error: tests/neg/i19328conversion.scala:13:5 ------------------------------------------------------------ +13 | bar // error: missing implicit (should not crash) + | ^ + | No given instance of type Boolean was found for parameter bool of method bar in object i19328conversion diff --git a/tests/neg/i19328conversion.scala b/tests/neg/i19328conversion.scala new file mode 100644 index 000000000000..46dd1058b579 --- /dev/null +++ b/tests/neg/i19328conversion.scala @@ -0,0 +1,13 @@ +object i19328conversion: + + trait Foo[B] + given foo[C]: Foo[C] = new Foo[C] {} + + type Id[A] = A + + given wrapId[A]: Conversion[A, Id[A]] with + def apply(x: A): Id[A] = x + + def bar(using bool: Boolean): Unit = () + + bar // error: missing implicit (should not crash)