forked from scala/scala3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Heal member-select on opaque reference
When the prefix of an opaque isn't the .this reference of the module class, then its RHS isn't visible. TypeComparer uses ctx.owner to "heal" or "lift" this type such that it is. We reuse that logic for member selection.
- Loading branch information
Showing
4 changed files
with
50 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
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,12 @@ | ||
object o { | ||
opaque type T = String | ||
|
||
summon[o.T =:= T] // OK | ||
summon[o.T =:= String] // OK | ||
|
||
def test1(t: T): Int = | ||
t.length // OK | ||
|
||
def test2(t: o.T): Int = | ||
t.length // Error: value length is not a member of Playground.o.T | ||
} |
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,24 @@ | ||
object o { u => | ||
opaque type T = String | ||
|
||
def st = summon[String =:= T] | ||
def su = summon[String =:= u.T] | ||
def so = summon[String =:= o.T] | ||
|
||
def ts = summon[T =:= String] | ||
def tu = summon[T =:= u.T] | ||
def to = summon[T =:= o.T] | ||
|
||
def us = summon[u.T =:= String] | ||
def ut = summon[u.T =:= T] | ||
def uo = summon[u.T =:= o.T] | ||
|
||
def os = summon[o.T =:= String] | ||
def ot = summon[o.T =:= T] | ||
def ou = summon[o.T =:= u.T] | ||
|
||
def ms(x: String): Int = x.length // ok | ||
def mt(x: T): Int = x.length // ok | ||
def mu(x: u.T): Int = x.length // ok | ||
def mo(x: o.T): Int = x.length // was: error: value length is not a member of o.T | ||
} |