-
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.
Only include accessible base classes in orDominator (#16477)
By joining union types we could previously uncover inaccessible base classes that could lead to access errors at runtime. We now filter out such classes when computing the orDominator. Fixes #16474
- Loading branch information
Showing
9 changed files
with
73 additions
and
2 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,13 @@ | ||
object o: | ||
|
||
private[o] trait A | ||
trait B | ||
class C extends A, B | ||
class D extends A, B | ||
|
||
def test = | ||
def f[T](x: T): T => T = identity | ||
val g = f(if ??? then o.C() else o.D()) | ||
g(new o.B{}) | ||
|
||
|
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,6 @@ | ||
// BaseProvider.java | ||
package repro.impl; | ||
|
||
import repro.*; | ||
abstract class BaseProvider{} | ||
|
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,9 @@ | ||
// Case1.java | ||
package repro; | ||
|
||
import repro.impl.*; | ||
|
||
public class Case1 extends Case1Provider implements Encrypter { | ||
public Case1(){} | ||
} | ||
|
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,5 @@ | ||
// Case1Provider.java | ||
package repro.impl; | ||
|
||
public abstract class Case1Provider extends BaseProvider {} | ||
|
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,8 @@ | ||
// Case2.java | ||
package repro; | ||
|
||
import repro.impl.*; | ||
|
||
public class Case2 extends Case2Provider implements Encrypter { | ||
public Case2(){} | ||
} |
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,5 @@ | ||
// Case2Provider.java | ||
package repro.impl; | ||
|
||
public abstract class Case2Provider extends BaseProvider {} | ||
|
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,4 @@ | ||
// Encrypter.java | ||
package repro; | ||
public interface Encrypter{} | ||
|
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,15 @@ | ||
// scalajs: --skip | ||
// test.scala | ||
import repro.* | ||
import scala.util.Try | ||
|
||
def get(arg: Any): Try[Encrypter] = Try { | ||
val x: Any = 1 | ||
arg match | ||
case 1 => new Case1() | ||
case 2 => new Case2() | ||
case _ => throw new RuntimeException(s"Unsupported got $arg") | ||
} | ||
|
||
@main def Test = | ||
val result = get(null) |