-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix NamedTuple selection on an unstable prefix (#20455)
Without a stable prefix, asSeenFrom could end up widening `Fields` to `>: Nothing <: Any`.
- Loading branch information
Showing
2 changed files
with
17 additions
and
1 deletion.
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,15 @@ | ||
import scala.language.experimental.namedTuples | ||
import NamedTuple.{AnyNamedTuple, NamedTuple} | ||
|
||
trait Foo extends Selectable: | ||
val f: Any | ||
type Fields = (myfield: f.type) | ||
def selectDynamic(name: String): Any | ||
|
||
object Test: | ||
val elem1: Foo { val f: Int } = ??? | ||
def elem2: Foo { val f: Int } = ??? | ||
|
||
def test: Unit = | ||
val a: Int = elem1.myfield // OK | ||
val b: Int = elem2.myfield // error: value myfield is not a member of Foo { val f: Int } |