Skip to content

Usages of experimentals are not always checked in types #14034

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
prolativ opened this issue Dec 3, 2021 · 3 comments · Fixed by #14047
Closed

Usages of experimentals are not always checked in types #14034

prolativ opened this issue Dec 3, 2021 · 3 comments · Fixed by #14047

Comments

@prolativ
Copy link
Contributor

prolativ commented Dec 3, 2021

Compiler version

3.1.1-RC1

Minimized code

import annotation.experimental

@experimental trait Exp
@experimental val exp = 1

type Foo = Option[Exp]
type Bar = Option[exp.type]
type Baz = Exp | Int
type Quux = [X] = X match
  case Exp => Int
type Quuz[A <: Exp] = Int

Output

Compiles successfully

Expectation

The compilation should fail and all the usages of the experimentals should be reported as errors

@odersky
Copy link
Contributor

odersky commented Dec 6, 2021

What happens with @deprecated? The two should work exactly the same.

@nicolasstucki
Copy link
Contributor

We also miss all these cases with @deprecated.

Only one error is emitted for the following example. Scala 2 emits all of them except the exp.type.

@deprecated trait Exp
@deprecated val exp = 1

def test1 = exp // error
def test2(a: Exp) = ()

type Foo0 = Exp
type Foo = Option[Exp]
type Bar = Option[exp.type]
type Baz = Exp | Int // error
type Quux = [X] =>> X match
  case Exp => Int
type Quuz[A <: Exp] = Int

See https://scastie.scala-lang.org/U0JDQtjQTBK64CRf7PqPTA for Scala 2 example

nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Dec 7, 2021
Undesired references can be to deprecated or experimental terms or types.

Fixes scala#14034
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Dec 7, 2021
Undesired references can be to deprecated or experimental terms or types.

Fixes scala#14034
@odersky
Copy link
Contributor

odersky commented Dec 7, 2021

I think the right fix is to check deprecation and experimental before RefChecks, when we still have the full types.

nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Dec 9, 2021
Undesired references can be to deprecated or experimental terms or types.

Fixes scala#14034
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Dec 9, 2021
Undesired references can be to deprecated or experimental terms or types.

Fixes scala#14034
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Dec 9, 2021
Undesired references can be to deprecated or experimental terms or types.

Fixes scala#14034
olsdavis pushed a commit to olsdavis/dotty that referenced this issue Apr 4, 2022
Undesired references can be to deprecated or experimental terms or types.

Fixes scala#14034
@Kordyjan Kordyjan added this to the 3.1.2 milestone Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants