Skip to content

Opaque types not allowed in a class #6227

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

Closed
panacekcz opened this issue Apr 4, 2019 · 2 comments
Closed

Opaque types not allowed in a class #6227

panacekcz opened this issue Apr 4, 2019 · 2 comments

Comments

@panacekcz
Copy link
Contributor

Although all the examples of opaque types define them in objects, I didn't see any mention in the proposal of opaque types being intentionally disallowed in classes, so I guess it is an issue of the implementation.

Test code:

class C {
  opaque type T = Int
}

Output:

-- Error: opaque-class.scala:2:2 -----------------------------------
2 |  opaque type T = Int
  |  ^
  |type T in object T cannot be accessed as a member of C.this.T.type from class C.
one error found
@b-studios
Copy link
Contributor

As of 0.17.0-bin-20190623-49c4a12-NIGHTLY your example crashes the compiler with:

[error] scala.MatchError: NoType (of class dotty.tools.dotc.core.Types$NoType$)
[error] 	at dotty.tools.dotc.core.tasty.TreePickler.pickleNewType(TreePickler.scala:270)
[error] 	at dotty.tools.dotc.core.tasty.TreePickler.pickleType(TreePickler.scala:144)
[error] 	at dotty.tools.dotc.core.tasty.TreePickler.pickleNewType$$anonfun$4(TreePickler.scala:226)
[error] 	at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
[error] 	at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:44)
[error] 	at dotty.tools.dotc.core.tasty.TreePickler.pickleNewType(TreePickler.scala:228)
[error] 	at dotty.tools.dotc.core.tasty.TreePickler.pickleType(TreePickler.scala:144)
[error] 	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$25(TreePickler.scala:529)
[error] 	at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
[error] 	at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:44)
[error] 	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:533)
[error] 	at dotty.tools.dotc.core.tasty.TreePickler.pickleDef$$anonfun$2(TreePickler.scala:307)
[error] 	at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
[error] 	at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:44)
[error] 	at dotty.tools.dotc.core.tasty.TreePickler.pickleDef(TreePickler.scala:312)
[error] 	at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:508)
[error] 	at dotty.tools.dotc.core.tasty.TreePickler.pickleStats$$anonfun$2(TreePickler.scala:331)
[error] 	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] 	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] 	at scala.collection.immutable.List.foreach(List.scala:392)

@allanrenucci
Copy link
Contributor

Regression test added in #6956

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants