Skip to content

Drop experimental inheritance checking #16330

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

Merged
merged 1 commit into from
Nov 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions compiler/src/dotty/tools/dotc/typer/CrossVersionChecks.scala
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,6 @@ class CrossVersionChecks extends MiniPhase:
}
}

/** Check that classes extending experimental classes or nested in experimental classes have the @experimental annotation. */
private def checkExperimentalInheritance(cls: ClassSymbol)(using Context): Unit =
if !cls.isAnonymousClass && !cls.isInExperimentalScope then
cls.info.parents.find(_.typeSymbol.isExperimental) match
case Some(parent) =>
report.error(em"extension of experimental ${parent.typeSymbol} must have @experimental annotation", cls.srcPos)
case _ =>
end checkExperimentalInheritance

override def transformValDef(tree: ValDef)(using Context): ValDef =
checkDeprecatedOvers(tree)
checkExperimentalAnnots(tree.symbol)
Expand All @@ -136,12 +127,6 @@ class CrossVersionChecks extends MiniPhase:
checkExperimentalSignature(tree.symbol, tree)
tree

override def transformTemplate(tree: Template)(using Context): Tree =
val cls = ctx.owner.asClass
checkExperimentalInheritance(cls)
checkExperimentalAnnots(cls)
tree

override def transformIdent(tree: Ident)(using Context): Ident = {
checkUndesiredProperties(tree.symbol, tree.srcPos)
tree
Expand Down
11 changes: 2 additions & 9 deletions docs/_docs/reference/other-new-features/experimental-defs.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ Experimental definitions can only be referenced in an experimental scope. Experi

<details>
<summary>Example 1</summary>

```scala
import scala.annotation.experimental

Expand All @@ -242,7 +242,7 @@ Experimental definitions can only be referenced in an experimental scope. Experi
}
}
```

</details>

5. Annotations of an experimental definition are in experimental scopes. Examples:
Expand Down Expand Up @@ -270,13 +270,6 @@ Can use the `-Yno-experimental` compiler flag to disable it and run as a proper

In any other situation, a reference to an experimental definition will cause a compilation error.

## Experimental inheritance

All subclasses of an experimental `class` or `trait` must be marked as [`@experimental`](https://scala-lang.org/api/3.x/scala/annotation/experimental.html) even if they are in an experimental scope.
Anonymous classes and SAMs of experimental classes are considered experimental.

We require explicit annotations to make sure we do not have completion or cycles issues with nested classes. This restriction could be relaxed in the future.

## Experimental overriding

For an overriding member `M` and overridden member `O`, if `O` is non-experimental then `M` must be non-experimental.
Expand Down

This file was deleted.

44 changes: 0 additions & 44 deletions tests/neg/experimentalInheritance.scala

This file was deleted.

6 changes: 0 additions & 6 deletions tests/neg/experimentalInheritance2.scala

This file was deleted.