Skip to content

Fix #10044 #15080

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/ast/tpd.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1397,7 +1397,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
def desugarIdent(tree: Ident)(using Context): RefTree = {
val qual = desugarIdentPrefix(tree)
if (qual.isEmpty) tree
else qual.select(tree.symbol)
else atPhase(Phases.typerPhase)(qual.select(tree.symbol))
}

/** Recover identifier prefix (e.g. this) if it exists */
Expand Down
10 changes: 10 additions & 0 deletions compiler/test-resources/repl/i10044a
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
scala> object opaques { opaque type IArr[+T] = Array[_ <: T]; given arrayOps: AnyRef with { extension [T](arr: IArr[T]) { def reverse: IArr[T] = genericArrayOps(arr).reverse ; def sorted(using math.Ordering[T]): IArr[T] = genericArrayOps(arr).sorted }}}; type IArr[+T] = opaques.IArr[T] ; object IArr { inline def apply(inline x: Int, inline xs: Int*): IArr[Int] = Array(x, xs: _*).asInstanceOf }
// defined object opaques
// defined alias type IArr[+T] = opaques.IArr[T]
// defined object IArr

scala> IArr(1,2,3).reverse.sorted
val res0: opaques.IArr[Int] = Array(1, 2, 3)

scala> IArr(1,2,3).reverse.sorted
val res1: opaques.IArr[Int] = Array(1, 2, 3)
12 changes: 12 additions & 0 deletions compiler/test-resources/repl/i10044b
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
scala> object Foo { opaque type Bar = Int ; object Bar { extension (b: Bar) def flip: Bar = -b ; def apply(x: Int): Bar = x } }
// defined object Foo
scala> val a = Foo.Bar(42)
val a: Foo.Bar = 42
scala> val b0 = a.flip
val b0: Foo.Bar = -42
scala> val b1 = a.flip
val b1: Foo.Bar = -42
scala> val c = b1.flip
val c: Foo.Bar = 42
scala> val d = c.flip
val d: Foo.Bar = -42