Skip to content

Commit 2f719f8

Browse files
Merge pull request #7945 from dotty-staging/fix-#6662
Fix #6662: Add regression test
2 parents 428568f + 4f8cdb7 commit 2f719f8

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

tests/neg/i6662.scala

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
opaque type Opt[A >: Null] = A
2+
3+
inline def (x: Opt[A]) nonEmpty[A >: Null]: Boolean = x.get != null // error: Implementation restriction
4+
inline def (x: Opt[A]) isEmpty[A >: Null]: Boolean = x.get == null // error: Implementation restriction
5+
inline def (x: Opt[A]) isDefined[A >: Null]: Boolean = x.nonEmpty // error: Implementation restriction
6+
inline def (x: Opt[A]) get[A >: Null]: A = Opt.unOpt(x) // error: Implementation restriction
7+
8+
object Opt
9+
{
10+
inline def unOpt[A >: Null](x: Opt[A]): A = x // error: Implementation restriction
11+
inline def apply[A >: Null](x: A): Opt[A] = x // error: Implementation restriction
12+
inline def some[A >: Null](x: A): Opt[A] = x // error: Implementation restriction
13+
inline def none[A >: Null]: Opt[A] = null // error: Implementation restriction
14+
inline def fromOption[A >: Null](x: Option[A]) = x.orNull // error: Implementation restriction
15+
}

0 commit comments

Comments
 (0)