-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14352 from Xavientois/eq-ne-always-valid-init-check
Add special case to init checker to always allow certain methods
- Loading branch information
Showing
4 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 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,7 @@ | ||
final class MyAsInstanceOfClass(o: MyAsInstanceOfClass) { | ||
val other: MyAsInstanceOfClass = { | ||
if (o.asInstanceOf[MyAsInstanceOfClass].oRef ne null) o // error | ||
else new MyAsInstanceOfClass(this) | ||
} | ||
val oRef = o | ||
} |
This file contains 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,13 @@ | ||
final class MyNeClass(o: MyNeClass) { | ||
val other: MyNeClass = { | ||
if (o ne null) o // o is cold, but ne is always valid | ||
else new MyNeClass(this) | ||
} | ||
} | ||
|
||
final class MyEqClass(o: MyEqClass) { | ||
val other: MyEqClass = { | ||
if (o eq null) new MyEqClass(this) // o is cold, but eq is always valid | ||
else o | ||
} | ||
} |
This file contains 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 @@ | ||
final class MyIsInstanceOfClass(o: MyIsInstanceOfClass) { | ||
val other: MyIsInstanceOfClass = { | ||
if (!o.isInstanceOf[Object]) new MyIsInstanceOfClass(this) // o is cold, but isInstanceOf is always valid | ||
else o | ||
} | ||
} | ||
|
||
final class MyAsInstanceOfClass(o: MyAsInstanceOfClass) { | ||
val other: MyAsInstanceOfClass = { | ||
if (o.asInstanceOf[Object] ne null) o // o is cold, but ne and AsInstanceOf is always valid | ||
else new MyAsInstanceOfClass(this) | ||
} | ||
} | ||
|
||
final class MyAsInstanceOfFieldClass(o: MyAsInstanceOfFieldClass) { | ||
val oRef = o | ||
val other: MyAsInstanceOfFieldClass = { | ||
if (this.asInstanceOf[MyAsInstanceOfFieldClass].oRef ne null) oRef // o is cold, but ne and AsInstanceOf is always valid | ||
else new MyAsInstanceOfFieldClass(this) | ||
} | ||
} | ||
|