-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Only nullify tasty if Yflexify-tasty is set; Refine FlexibleType nullification rules
#23938
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
Changes from 10 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
fa957ca
Only nullfiy simple kinded types
HarrisL2 f2af570
Add tests for nullification of higher kinded types
HarrisL2 a542758
Enhance nullification logic: ignore type annotations; ignore some spe…
noti0na1 e445207
Refactor ImplicitNullInterop
noti0na1 75dd9d4
Fix formatting and remove duplicate null class check
noti0na1 3aa4b0d
Always nullify type param refs from Java
noti0na1 adc549b
Try to move the flexible types to outer level
noti0na1 299a72a
Update tests
noti0na1 78495ea
Skip tuple for now
noti0na1 57235ef
Add `-Ynullify-tasty` setting and only nullify compiled Scala if the …
noti0na1 1663038
Rename `YnullifyTasty` to `YflexifyTasty`
noti0na1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
275 changes: 163 additions & 112 deletions
275
compiler/src/dotty/tools/dotc/core/ImplicitNullInterop.scala
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
tests/explicit-nulls/flexible-unpickle/neg/Flexible_2.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import unsafe.* | ||
|
|
||
| @A[String] class C | ||
|
|
||
| def test = | ||
|
|
||
| val ii = Bar.f[Int](null) // error | ||
| val jj = Bar.g[String](null) // error | ||
| val jj2 = Bar.g[String | Null](null) // ok | ||
| val kk = Bar.g2[String](null) // error | ||
| val kk2 = Bar.g2[String | Null](null) // ok | ||
|
|
||
| val bar_x: Int = Bar.x | ||
| val bar_y: String | Null = Bar.y.replaceAll(" ","") | ||
|
|
||
| def testUsingFoo(using Foo[Option]) = Bar.h(null) | ||
|
|
||
| val ii2 = Bar2[String]().f(null) // error | ||
| val ii3 = Bar2[String | Null]().f(null) // ok | ||
|
|
||
| val a = Bar.ff( | ||
| (x: AnyRef) => x.toString, | ||
| 42 | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| package unsafe | ||
|
|
||
| import scala.annotation.* | ||
|
|
||
| type XtoY = [X] =>> [Y] =>> X => Y | ||
|
|
||
| class Foo[T[_]] | ||
|
|
||
| class A[T] extends Annotation | ||
|
|
||
| object Bar: | ||
| def ff(f: AnyRef => String, g: AnyRef ?=> Int): (AnyRef => String) = ??? | ||
| var x: Int = 0 | ||
| var y: String = "" | ||
| def f[T <: Int](x: T): T = x | ||
| def g[T <: AnyRef](x: T): T = x | ||
| def g2[T >: Null <: AnyRef](x: T): T = x | ||
| def h(x: String)(using Foo[Option]): String = x | ||
| def h2(a: Foo[XtoY[String]]) = ??? | ||
|
|
||
| class Bar2[T]: | ||
| def f(x: T): T = x |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| enum FormatPattern: | ||
| case AsInt | ||
| case AsLong | ||
|
|
||
| // some basic operations with enum: | ||
| def test = | ||
| val p1 = FormatPattern.AsInt | ||
| val p2 = FormatPattern.AsLong | ||
| val p3 = FormatPattern.valueOf("AsInt") | ||
| val p4 = FormatPattern.values(0) | ||
| val ord1 = p1.ordinal | ||
| val ord2 = p2.ordinal | ||
| val str1 = p1.toString() | ||
| val str2 = p2.toString() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| //> using options -Yexplicit-nulls | ||
|
|
||
| sealed abstract class IsSubtypeOfOutput[-A, +B] extends (A => B) | ||
| object IsSubtypeOfOutput: | ||
| private val instance: IsSubtypeOfOutput[Any, Any] = new IsSubtypeOfOutput[Any, Any] { def apply(a: Any): Any = a } | ||
|
|
||
| sealed trait DerivationAnnotation | ||
| class Rename(name: String) extends DerivationAnnotation |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.