Skip to content

Error tpe obtained for type alias defined in package object #12663

Closed
scala/scala
#10988
@kpodsiad

Description

@kpodsiad

Issue originally raised in Metals - scalameta/metals#4495

Reproduction steps

Scala version: 2.13.8, 2.13.9, probably earlier ones too

Here's repo with reproduction.

a/package.scala

package object a {
  type FancyInt = Int
}

a/Main.scala

package a
object Main extends App {
  def foo(n: FancyInt, k: Int): Unit = {
    n
    k
  }
}

Problem

There are no completions for type alias
Screenshot 2022-10-07 at 07 28 13
Screenshot 2022-10-07 at 07 30 32

I initially thought that this is the problem with Metals but @tgodzik created a testcase with reproduction https://github.com/scalameta/metals/compare/main...tgodzik:metals:add-test?expand=1 which shows that this is the compiler issue.

This is what Metals gets from compiler:

CompletionProvider.scala:451 typeMembers: List(
  ScopeMember(
    sym = value n,
    tpe = <error>,
    accessible = true,
    viaImport = <empty>,
    aliasInfo = None
  ),
  ScopeMember(
    sym = value k,
    tpe = TypeRef(pre = ThisType(sym = package scala), sym = class Int, args = List()),
    accessible = true,
    viaImport = <empty>,
    aliasInfo = None
  ),
...

note tpe = <error> for n whereas k has correct tpe.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions