Skip to content

Cannot write refined given aliases #8284

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
nicolasstucki opened this issue Feb 11, 2020 · 1 comment
Closed

Cannot write refined given aliases #8284

nicolasstucki opened this issue Feb 11, 2020 · 1 comment
Assignees

Comments

@nicolasstucki
Copy link
Contributor

minimized code

type Foo
given myFoo1 as Foo { type X = Int } = ??? // error

type Bar = Foo { type X = Int }
given myFoo2 as Bar = ???

Compilation output

2 |given myFoo1 as Foo { type X = Int } = ???
  |                                     ^
  |                                   end of statement expected but '=' found
-- [E040] Syntax Error: Foo.scala:2:39 -----------------------------------------
2 |given myFoo1 as Foo { type X = Int } = ???
  |                                       ^^^
  |                                       ';' expected, but identifier found
-- Error: Foo.scala:2:16 -------------------------------------------------------
2 |given myFoo1 as Foo { type X = Int } = ???
  |                ^^^
  |                Foo is not a class type

expectation

given myFoo1 as Foo { type X = Int } = ??? 

myFoo1 should be handled as a given alias and should compile the same way myFoo2 does.

@odersky
Copy link
Contributor

odersky commented Feb 11, 2020

You need to put the refined type in parens

smarter added a commit that referenced this issue Feb 11, 2020
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

2 participants